Home | History | Annotate | Line # | Download | only in nubus
nubus.h revision 1.6
      1 /*	$NetBSD: nubus.h,v 1.6 1995/05/05 05:40:13 briggs Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995 Allen Briggs.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by Allen Briggs.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Nubus cards in Macintoshes are identified by 4 16-bit numbers:
     34  * Category:	What is the main purpose of this card?
     35  * Type:	Within this overall category, what kind of card?
     36  * DrSW:	What software interface does it use?
     37  * DrHW:	What specific hardware is it?
     38  *
     39  * For example, the "Toby Frame Buffer" display card is
     40  *     Category 3 (display)
     41  *     Type     1 (video)
     42  *     DrSW     1 (Apple)
     43  * and DrHW     1 (TFB).
     44  */
     45 
     46 #define NUBUS_CATEGORY_BOARD	0x0001
     47 
     48 #define NUBUS_CATEGORY_DISPLAY	0x0003
     49 #define  NUBUS_TYPE_VIDEO	0x0001
     50 #define  NUBUS_TYPE_LCD		0x0002
     51 #define   NUBUS_DRSW_APPLE	0x0001
     52 #define    NUBUS_DRHW_TFB	0x0001
     53 #define    NUBUS_DRHW_M2HRVC	0x0013
     54 #define    NUBUS_DRHW_MICRON	0x0146
     55 
     56 #define NUBUS_CATEGORY_NETWORK	0x0004
     57 #define  NUBUS_TYPE_ETHERNET	0x0001
     58 #define   NUBUS_DRSW_3COM	0x0000
     59 #define   NUBUS_DRSW_GATOR	0x0103
     60 #define    NUBUS_DRHW_INTERLAN	0x0100
     61 #define    NUBUS_DRHW_KINETICS	0x0106
     62 #define   NUBUS_DRSW_ASANTE	0x0104
     63 #define    NUBUS_DRHW_SONIC	0x0110
     64 
     65 #define NUBUS_CATEGORY_FONT	0x0009	/* KanjiTalk Font Card? */
     66 
     67 #define NUBUS_CATEGORY_CPU	0x000A
     68 #define  NUBUS_TYPE_68000	0x0002
     69 #define  NUBUS_TYPE_68020	0x0003
     70 #define  NUBUS_TYPE_68030	0x0004
     71 #define  NUBUS_TYPE_68040	0x0005
     72 
     73 /*
     74  * This is the same as Apple's Format Block for a card, with the
     75  * addition of a pointer to the base of the NuBUS slot.
     76  *
     77  * This basically describes a nubus card--this structure is held in the last
     78  * N bytes of each valid card's declaration ROM.
     79  */
     80 typedef struct _nubus_slot {
     81 	u_long		top;
     82 	u_int8_t	slot;
     83 	u_int8_t	bytelanes;
     84 	u_int8_t	step;
     85 	u_int32_t	test_pattern;
     86 	u_int8_t	format;
     87 	u_int8_t	revision_level;
     88 	u_int32_t	crc;
     89 	u_int32_t	length;
     90 	u_int32_t	directory_offset;
     91 } nubus_slot;
     92 
     93 /*
     94  * Just a structure to ease comparison of type for drivers, etc.
     95  */
     96 typedef struct _nubus_type {
     97 	u_int16_t	category;
     98 	u_int16_t	type;
     99 	u_int16_t	drsw;
    100 	u_int16_t	drhw;
    101 } nubus_type;
    102 
    103 /*
    104  * nubus_dir is a structure that describes a nubus directory.
    105  * The nubus*dir() functions should be used to traverse this.
    106  */
    107 typedef struct _nubus_dir {
    108 	u_int32_t	dirbase;
    109 	u_int32_t	curr_ent;
    110 } nubus_dir;
    111 
    112 /*
    113  * This is the equivalent of an Apple sResource directory entry
    114  * with the addition of a pointer to itself (essentially) for easy
    115  * calculation of jump to indirect data.
    116  */
    117 typedef struct _nubus_dirent {
    118 	u_int32_t	myloc;
    119 	u_int8_t	rsrc_id;
    120 	u_int32_t	offset;
    121 } nubus_dirent;
    122 
    123 /*
    124  * This is the equivalent of an Apple sResource with the addition of
    125  * a pointer back to the sResource directory from whence we came.
    126  *
    127  * According to the Apple documentation, each sResource is of one of the
    128  * following forms:
    129  *	all:	bits 31-24	Identification number
    130  *
    131  *	offset:	bits 23-0	Offset to long data, cString, sBlock, etc.
    132  *	word:	bits 23-16	0x00
    133  *		bits 15-0	word data
    134  *	byte:	bits 23-8	0x0000
    135  *		bits 7-0	byte data
    136  *
    137  * The last resource has id = 0xff and data = 0x000000.
    138  */
    139 typedef struct _nubus_rsrc {
    140 	u_int32_t	myloc;
    141 	u_int8_t	id;
    142 	u_int32_t	data;
    143 } nubus_rsrc;
    144 
    145 /* Resource IDs for NUBUS_CATEGORY_* (All) */
    146 #define NUBUS_RSRC_TYPE		0x01	/* Type (required)		*/
    147 #define NUBUS_RSRC_NAME		0x02	/* Name (required)		*/
    148 #define NUBUS_RSRC_ICON		0x03	/* Icon				*/
    149 #define NUBUS_RSRC_DRVRDIR	0x04	/* Driver directory		*/
    150 #define NUBUS_RSRC_LOADREC	0x05	/* Load record for resource	*/
    151 #define NUBUS_RSRC_BOOTREC	0x06	/* Boot record			*/
    152 #define NUBUS_RSRC_FLAGS	0x07	/* sResource Flags		*/
    153 #define NUBUS_RSRC_HWDEVID	0x08	/* Hardware device ID		*/
    154 #define NUBUS_RSRC_MINOR_BASEOS	0x0A	/* Offset to hw in std space	*/
    155 #define NUBUS_RSRC_MINOR_LENGTH	0x0B	/* Length of std space		*/
    156 #define NUBUS_RSRC_MAJOR_BASEOS	0x0C	/* Offset to hw in super space	*/
    157 #define NUBUS_RSRC_MAJOR_LENGTH	0x0D	/* Length of super space	*/
    158 #define NUBUS_RSRC_CICN		0x0F	/* Color icon			*/
    159 #define NUBUS_RSRC_ICL8		0x10	/* 8-bit icon data		*/
    160 #define NUBUS_RSRC_ICL4		0x11	/* 4-bit icon data		*/
    161 
    162 /* Resource IDs for NUBUS_CATEGORY_DISPLAY */
    163 #define NUBUS_RSRC_GAMMADIR	0x40	/* ID for gamma directory	*/
    164 #define NUBUS_RSRC_VIDNAMES	0x41	/* ID for video name directory	*/
    165 #define NUBUS_RSRC_FIRSTMODE	0x80	/* ID for first mode (1-bit)	*/
    166 #define NUBUS_RSRC_SECONDMODE	0x81	/* ID for 2nd mode (2-bit)	*/
    167 #define NUBUS_RSRC_THIRDMODE	0x82	/* ID for 3rd mode (4-bit)	*/
    168 #define NUBUS_RSRC_FOURTHMODE	0x83	/* ID for 4th mode (8-bit)	*/
    169 #define NUBUS_RSRC_FIFTHMODE	0x84	/* ID for 5th mode (16-bit)	*/
    170 #define NUBUS_RSRC_SIXTHMODE	0x85	/* ID for 6th mode (32-bit)	*/
    171 
    172 /* Resource IDs for NUBUS_CATEGORY_BOARD */
    173 #define NUBUS_RSRC_BOARDID	0x20	/* Board ID			*/
    174 #define NUBUS_RSRC_PRAMINITDATA	0x21	/* Private board data for PRAM	*/
    175 #define NUBUS_RSRC_PRIMARYINIT	0x22	/* Primary init record		*/
    176 #define NUBUS_RSRC_TIMEOUTCONST	0x23	/* Timeout constant		*/
    177 #define NUBUS_RSRC_VENDORINFO	0x24	/* Vendor info list		*/
    178 #define NUBUS_RSRC_BOARDFLAGS	0x25	/* Board flags			*/
    179 #define NUBUS_RSRC_SECONDINIT	0x26	/* Secondary init record	*/
    180 
    181 #define NUBUS_RSRC_VEND_ID	0x01	/* Card vendor's design ID	*/
    182 #define NUBUS_RSRC_VEND_SERIAL	0x02	/* Card's serial number		*/
    183 #define NUBUS_RSRC_VEND_REV	0x03	/* Card design's revision level	*/
    184 #define NUBUS_RSRC_VEND_PART	0x04	/* Card part number		*/
    185 #define NUBUS_RSRC_VEND_DATE	0x05	/* Card revision date		*/
    186 
    187 typedef struct _NUBUS_DRIVER {
    188 	u_int8_t	drvr_id;
    189 	u_int32_t	offset;
    190 } NUBUS_DRIVER;
    191 
    192 typedef struct _NUBUS_BLOCK {
    193 	u_int32_t	size;		/* Size of block of data	*/
    194 	caddr_t		data;		/* Pointer to data		*/
    195 } NUBUS_BLOCK;
    196 
    197 typedef struct _NUBUS_EXEC_BLOCK {
    198 	u_int32_t	size;		/* Size of total block - 4 	*/
    199 	u_int8_t	revision;	/* Always 0x2			*/
    200 	u_int8_t	cpu;		/* Which processor?		*/
    201 	u_int32_t	code_offset;	/* Offset base to start of code	*/
    202 	caddr_t		code;		/* pointer to base of code.	*/
    203 } NUBUS_EXEC_BLOCK;
    204 
    205 #define NUBUS_EXEC_CPU_68000	1
    206 #define NUBUS_EXEC_CPU_68020	2
    207 #define NUBUS_EXEC_CPU_68030	3
    208 #define NUBUS_EXEC_CPU_68040	4
    209 
    210 #define NUBUS_MIN_SLOT		0x9
    211 #define NUBUS_MAX_SLOT		0xE
    212 #define NUBUS_ROM_TEST_PATTERN	0x5A932BC7
    213 
    214 #define NUBUS_BASE_TO_SLOT(x)	(((x) >> 24) & 0x0F)
    215 #define NUBUS_SLOT_TO_BASE(x)	(0xF0000000 | (((x) & 0xF) << 24))
    216 
    217 struct nubus_softc {
    218 	struct	device	sc_dev;
    219 };
    220 
    221 void	nubus_get_main_dir __P((nubus_slot *slot, nubus_dir *dir_return));
    222 int	nubus_find_rsrc __P((nubus_slot *slot, nubus_dir *dir, u_int8_t rsrcid,
    223 			     nubus_dirent *dirent_return));
    224 void	nubus_get_dir_from_rsrc __P((nubus_slot *slot, nubus_dirent *dirent,
    225 				     nubus_dir *dir_return));
    226 int	nubus_get_ind_data __P((nubus_slot *slot, nubus_dirent *dirent,
    227 				caddr_t data_return, int nbytes));
    228 int	nubus_get_c_string __P((nubus_slot *slot, nubus_dirent *dirent,
    229 				caddr_t data_return, int max_bytes));
    230 char	*nubus_get_vendor __P((nubus_slot *slot, int rsrc));
    231 char	*nubus_get_card_name __P((nubus_slot *slot));
    232 
    233