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