Home | History | Annotate | Line # | Download | only in nubus
nubus.h revision 1.51
      1 /*	$NetBSD: nubus.h,v 1.51 2000/12/05 05:02:36 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 #include <machine/cpu.h>
     47 
     48 #define NUBUS_CATEGORY_BOARD	0x0001
     49 
     50 #define NUBUS_CATEGORY_DISPLAY	0x0003
     51 #define  NUBUS_TYPE_VIDEO	0x0001
     52 #define  NUBUS_TYPE_LCD		0x0002
     53 #define   NUBUS_DRSW_APPLE	0x0001
     54 #define    NUBUS_DRHW_TFB	0x0001	/* Apple Toby Frame Buffer */
     55 #define    NUBUS_DRHW_WVC	0x0006	/* Apple Workstation Video Card */
     56 #define	   NUBUS_DRHW_COLORMAX	0x0007	/* Sigma Designs ColorMax */
     57 #define    NUBUS_DRHW_SE30	0x0009	/* Apple SE/30 pseudo-slot video */
     58 #define    NUBUS_DRHW_M2HRVC	0x0013	/* Apple Mac II High-Res Video Card */
     59 #define    NUBUS_DRHW_PVC	0x0017	/* Apple Mac II Portrait Video Card */
     60 #define    NUBUS_DRHW_MDC	0x0019	/* Apple Macintosh Display Card */
     61 #define    NUBUS_DRHW_SUPRGFX	0x0105	/* SuperMac GFX */
     62 #define    NUBUS_DRHW_FORMAC	0x013A	/* Formac color card II */
     63 #define    NUBUS_DRHW_CB264	0x013B	/* RasterOps ColorBoard 264 */
     64 #define    NUBUS_DRHW_MICRON	0x0146	/* Micron Exceed color */
     65 #define    NUBUS_DRHW_RADGSC	0x0153	/* Radius GS/C */
     66 #define    NUBUS_DRHW_SPECTRM8	0x017b	/* SuperMac Spectrum/8  Series III */
     67 #define    NUBUS_DRHW_SPECTRUM	0x017c	/* SuperMac Spectrum/24 Series III */
     68 #define    NUBUS_DRHW_VIMAGE	0x026E	/* Interware Co., Ltd. Vimage */
     69 #define    NUBUS_DRHW_CB364	0x026F	/* RasterOps ColorBoard 364 */
     70 #define    NUBUS_DRHW_LVIEW	0x0278	/* Sigma Designs L-View */
     71 #define	   NUBUS_DRHW_RPC8	0x0291	/* Radius PrecisionColor 8 */
     72 #define	   NUBUS_DRHW_LAPIS	0x0292	/* SE/30 Lapis ProColorServer 8 PDS */
     73 #define	   NUBUS_DRHW_ROPS24LXI	0x02A0	/* RasterOps 8/24 XLi */
     74 #define    NUBUS_DRHW_FUTURASX	0x02AE	/* E-Machines Futura-SX */
     75 #define    NUBUS_DRHW_ROPS24XLTV 0x02B7	/* RasterOps 24XlTV */
     76 #define    NUBUS_DRHW_THUNDER24	0x02CB	/* SuperMac Thunder/24 */
     77 #define    NUBUS_DRHW_ROPS24MXTV 0x03DF	/* RasterOps 24MxTV */
     78 #define    NUBUS_DRHW_GVIMAGE	0x03FB	/* Interware Co., Ltd. Grand Vimage */
     79 #define	   NUBUS_DRHW_RPC24XP	0x0406	/* Radius PrecisionColor 24Xp */
     80 #define	   NUBUS_DRHW_RPC24X	0x040A	/* Radius PrecisionColor 24X */
     81 #define	   NUBUS_DRHW_RPC8XJ	0x040B	/* Radius PrecisionColor 8xj */
     82 #define	   NUBUS_DRHW_FIILX	0x0417	/* Futura II LX */
     83 #define	   NUBUS_DRHW_FIISXDSP	0x042F	/* Futura II SX/DSP */
     84 #define	   NUBUS_DRHW_MC2124NB	0x0462	/* MicroConversions 2124NB II */
     85 
     86 /* False DrHW values for video cards masquerading as other cards */
     87 #define    NUBUS_DRHW_SAM768	0x10000	/* Cornerstone/Samsung 768x1006 */
     88 
     89 #define NUBUS_CATEGORY_NETWORK	0x0004
     90 #define  NUBUS_TYPE_ETHERNET	0x0001
     91 #define   NUBUS_DRSW_3COM	0x0000
     92 #define   NUBUS_DRSW_CABLETRON	0x0001
     93 #define   NUBUS_DRSW_GATOR	0x0103
     94 #define   NUBUS_DRSW_ASANTE	0x0104
     95 #define   NUBUS_DRSW_TECHWORKS	0x0109
     96 #define	  NUBUS_DRSW_DAYNA	0x010B
     97 #define   NUBUS_DRSW_FARALLON	0x010C
     98 #define   NUBUS_DRSW_DAYNA2	0x0115
     99 #define   NUBUS_DRSW_FOCUS	0x011A
    100 #define   NUBUS_DRSW_ASANTEF	0x011D
    101 #define   NUBUS_DRSW_TFLLAN	0x011E
    102 #define    NUBUS_DRHW_INTERLAN	0x0100
    103 #define    NUBUS_DRHW_ASANTEF	0x0101
    104 #define    NUBUS_DRHW_KINETICS	0x0106
    105 #define    NUBUS_DRHW_CABLETRON	0x0109
    106 #define    NUBUS_DRHW_NUVOLINK	0x010B
    107 #define    NUBUS_DRHW_ASANTE_LC	0x010F
    108 #define    NUBUS_DRHW_SONIC	0x0110
    109 #define    NUBUS_DRHW_TECHWORKS	0x0112
    110 #define    NUBUS_DRHW_APPLE_SNT	0x0118
    111 #define    NUBUS_DRHW_APPLE_SN	0x0119
    112 
    113 #define NUBUS_CATEGORY_COMMUNICATIONS	0x0006
    114 #define  NUBUS_TYPE_RS232	0x0002
    115 #define   NUBUS_DRSW_HDS	0x0102
    116 #define    NUBUS_DRHW_HDS	0x0102
    117 
    118 #define NUBUS_CATEGORY_MEMORY	0x0009	/* Also KanjiTalk Font Card? */
    119 #define  NUBUS_TYPE_RAMCACHE	0x010C	/* From Apple PDS card */
    120 #define   NUBUS_DRSW_AWGSPDS	0x0100
    121 #define    NUBUS_DRHW_AWGSPDS	0x0100
    122 
    123 #define NUBUS_CATEGORY_CPU	0x000A
    124 #define  NUBUS_TYPE_68000	0x0002
    125 #define  NUBUS_TYPE_68020	0x0003
    126 #define  NUBUS_TYPE_68030	0x0004
    127 #define  NUBUS_TYPE_68040	0x0005
    128 
    129 #define NUBUS_CATEGORY_INTBUS	0x000C
    130 #define  NUBUS_TYPE_SCSI	0x0008
    131 #define   NUBUS_DRSW_AWGSPDS	0x0006
    132 #define    NUBUS_DRHW_AWGSPDS	0x0100
    133 #define   NUBUS_DRSW_PLI	0x0108
    134 #define    NUBUS_DRHW_PLI	0x0100
    135 #define   NUBUS_DRSW_FWB	0x010C
    136 #define    NUBUS_DRHW_FWB	0x0100
    137 
    138 /*
    139  * This is the same as Apple's Format Block for a card, with the
    140  * addition of a pointer to the base of the NuBUS slot.
    141  *
    142  * This basically describes a nubus card--this structure is held in the last
    143  * N bytes of each valid card's declaration ROM.
    144  */
    145 typedef struct _nubus_slot {
    146 	u_long		top;
    147 	u_int8_t	slot;
    148 	u_int8_t	bytelanes;
    149 	u_int8_t	step;
    150 	u_int32_t	test_pattern;
    151 	u_int8_t	format;
    152 	u_int8_t	revision_level;
    153 	u_int32_t	crc;
    154 	u_int32_t	length;
    155 	u_int32_t	directory_offset;
    156 } nubus_slot;
    157 
    158 /*
    159  * Just a structure to ease comparison of type for drivers, etc.
    160  */
    161 typedef struct _nubus_type {
    162 	u_int16_t	category;
    163 	u_int16_t	type;
    164 	u_int16_t	drsw;
    165 	u_int16_t	drhw;
    166 } nubus_type;
    167 
    168 /*
    169  * nubus_dir is a structure that describes a nubus directory.
    170  * The nubus*dir() functions should be used to traverse this.
    171  */
    172 typedef struct _nubus_dir {
    173 	u_int32_t	dirbase;
    174 	u_int32_t	curr_ent;
    175 } nubus_dir;
    176 
    177 /*
    178  * This is the equivalent of an Apple sResource directory entry
    179  * with the addition of a pointer to itself (essentially) for easy
    180  * calculation of jump to indirect data.
    181  */
    182 typedef struct _nubus_dirent {
    183 	u_int32_t	myloc;
    184 	u_int8_t	rsrc_id;
    185 	u_int32_t	offset;
    186 } nubus_dirent;
    187 
    188 /*
    189  * This is the equivalent of an Apple sResource with the addition of
    190  * a pointer back to the sResource directory from whence we came.
    191  *
    192  * According to the Apple documentation, each sResource is of one of the
    193  * following forms:
    194  *	all:	bits 31-24	Identification number
    195  *
    196  *	offset:	bits 23-0	Offset to long data, cString, sBlock, etc.
    197  *	word:	bits 23-16	0x00
    198  *		bits 15-0	word data
    199  *	byte:	bits 23-8	0x0000
    200  *		bits 7-0	byte data
    201  *
    202  * The last resource has id = 0xff and data = 0x000000.
    203  */
    204 typedef struct _nubus_rsrc {
    205 	u_int32_t	myloc;
    206 	u_int8_t	id;
    207 	u_int32_t	data;
    208 } nubus_rsrc;
    209 
    210 /* Resource IDs for NUBUS_CATEGORY_* (All) */
    211 #define NUBUS_RSRC_TYPE		0x01	/* Type (required)		*/
    212 #define NUBUS_RSRC_NAME		0x02	/* Name (required)		*/
    213 #define NUBUS_RSRC_ICON		0x03	/* Icon				*/
    214 #define NUBUS_RSRC_DRVRDIR	0x04	/* Driver directory		*/
    215 #define NUBUS_RSRC_LOADREC	0x05	/* Load record for resource	*/
    216 #define NUBUS_RSRC_BOOTREC	0x06	/* Boot record			*/
    217 #define NUBUS_RSRC_FLAGS	0x07	/* sResource Flags		*/
    218 #define NUBUS_RSRC_HWDEVID	0x08	/* Hardware device ID		*/
    219 #define NUBUS_RSRC_MINOR_BASEOS	0x0A	/* Offset to hw in std space	*/
    220 #define NUBUS_RSRC_MINOR_LENGTH	0x0B	/* Length of std space		*/
    221 #define NUBUS_RSRC_MAJOR_BASEOS	0x0C	/* Offset to hw in super space	*/
    222 #define NUBUS_RSRC_MAJOR_LENGTH	0x0D	/* Length of super space	*/
    223 #define NUBUS_RSRC_CICN		0x0F	/* Color icon			*/
    224 #define NUBUS_RSRC_ICL8		0x10	/* 8-bit icon data		*/
    225 #define NUBUS_RSRC_ICL4		0x11	/* 4-bit icon data		*/
    226 
    227 /* Resource IDs for NUBUS_CATEGORY_DISPLAY */
    228 #define NUBUS_RSRC_GAMMADIR	0x40	/* ID for gamma directory	*/
    229 #define NUBUS_RSRC_VIDNAMES	0x41	/* ID for video name directory	*/
    230 #define NUBUS_RSRC_FIRSTMODE	0x80	/* ID for first mode (1-bit)	*/
    231 #define NUBUS_RSRC_SECONDMODE	0x81	/* ID for 2nd mode (2-bit)	*/
    232 #define NUBUS_RSRC_THIRDMODE	0x82	/* ID for 3rd mode (4-bit)	*/
    233 #define NUBUS_RSRC_FOURTHMODE	0x83	/* ID for 4th mode (8-bit)	*/
    234 #define NUBUS_RSRC_FIFTHMODE	0x84	/* ID for 5th mode (16-bit)	*/
    235 #define NUBUS_RSRC_SIXTHMODE	0x85	/* ID for 6th mode (32-bit)	*/
    236 
    237 /* Resource IDs for NUBUS_CATEGORY_BOARD */
    238 #define NUBUS_RSRC_BOARDID	0x20	/* Board ID			*/
    239 #define NUBUS_RSRC_PRAMINITDATA	0x21	/* Private board data for PRAM	*/
    240 #define NUBUS_RSRC_PRIMARYINIT	0x22	/* Primary init record		*/
    241 #define NUBUS_RSRC_TIMEOUTCONST	0x23	/* Timeout constant		*/
    242 #define NUBUS_RSRC_VENDORINFO	0x24	/* Vendor info list		*/
    243 #define NUBUS_RSRC_BOARDFLAGS	0x25	/* Board flags			*/
    244 #define NUBUS_RSRC_SECONDINIT	0x26	/* Secondary init record	*/
    245 
    246 #define NUBUS_RSRC_VEND_ID	0x01	/* Card vendor's design ID	*/
    247 #define NUBUS_RSRC_VEND_SERIAL	0x02	/* Card's serial number		*/
    248 #define NUBUS_RSRC_VEND_REV	0x03	/* Card design's revision level	*/
    249 #define NUBUS_RSRC_VEND_PART	0x04	/* Card part number		*/
    250 #define NUBUS_RSRC_VEND_DATE	0x05	/* Card revision date		*/
    251 
    252 typedef struct _NUBUS_DRIVER {
    253 	u_int8_t	drvr_id;
    254 	u_int32_t	offset;
    255 } NUBUS_DRIVER;
    256 
    257 typedef struct _NUBUS_BLOCK {
    258 	u_int32_t	size;		/* Size of block of data	*/
    259 	caddr_t		data;		/* Pointer to data		*/
    260 } NUBUS_BLOCK;
    261 
    262 typedef struct _NUBUS_EXEC_BLOCK {
    263 	u_int32_t	size;		/* Size of total block - 4 	*/
    264 	u_int8_t	revision;	/* Always 0x2			*/
    265 	u_int8_t	cpu;		/* Which processor?		*/
    266 	u_int32_t	code_offset;	/* Offset base to start of code	*/
    267 	caddr_t		code;		/* pointer to base of code.	*/
    268 } NUBUS_EXEC_BLOCK;
    269 
    270 #define NUBUS_EXEC_CPU_68000	1
    271 #define NUBUS_EXEC_CPU_68020	2
    272 #define NUBUS_EXEC_CPU_68030	3
    273 #define NUBUS_EXEC_CPU_68040	4
    274 
    275 #define NUBUS_MIN_SLOT		0x9
    276 #define NUBUS_MAX_SLOT		0xE
    277 #define NUBUS_ROM_TEST_PATTERN	0x5A932BC7
    278 
    279 #define NUBUS_SLOT2PA(x)	(0xf9000000 + \
    280 				 ((((x) - NUBUS_MIN_SLOT) & 0xf) << 24))
    281 
    282 struct nubus_attach_args {
    283 	bus_space_tag_t	na_tag;
    284 	int		slot;
    285 	int		rsrcid;
    286 	u_int16_t	category;
    287 	u_int16_t	type;
    288 	u_int16_t	drsw;
    289 	u_int16_t	drhw;
    290 	nubus_slot	*fmt;
    291 };
    292 
    293 struct nubus_softc {
    294 	struct	device	sc_dev;
    295 };
    296 
    297 void	nubus_get_main_dir __P((nubus_slot *slot, nubus_dir *dir_return));
    298 void	nubus_get_dir_from_rsrc __P((nubus_slot *slot, nubus_dirent *dirent,
    299 	    nubus_dir *dir_return));
    300 
    301 int	nubus_find_rsrc __P((bus_space_tag_t, bus_space_handle_t,
    302 	    nubus_slot *slot, nubus_dir *dir, u_int8_t rsrcid,
    303 	    nubus_dirent *dirent_return));
    304 int	nubus_get_ind_data __P((bus_space_tag_t, bus_space_handle_t,
    305 	    nubus_slot *slot, nubus_dirent *dirent,
    306 	    caddr_t data_return, int nbytes));
    307 int	nubus_get_c_string __P((bus_space_tag_t, bus_space_handle_t,
    308 	    nubus_slot *slot, nubus_dirent *dirent,
    309 	    caddr_t data_return, int max_bytes));
    310 
    311 char	*nubus_get_vendor __P((bus_space_tag_t, bus_space_handle_t,
    312 	    nubus_slot *slot, int rsrc));
    313 char	*nubus_get_card_name __P((bus_space_tag_t, bus_space_handle_t,
    314 	    nubus_slot *slot));
    315 #ifdef DEBUG
    316 void	nubus_scan_slot __P((bus_space_tag_t, int));
    317 #endif
    318