nubus.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*
  2. nubus.h: various definitions and prototypes for NuBus drivers to use.
  3. Originally written by Alan Cox.
  4. Hacked to death by C. Scott Ananian and David Huggins-Daines.
  5. Some of the constants in here are from the corresponding
  6. NetBSD/OpenBSD header file, by Allen Briggs. We figured out the
  7. rest of them on our own. */
  8. #ifndef LINUX_NUBUS_H
  9. #define LINUX_NUBUS_H
  10. #ifdef __KERNEL__
  11. #include <asm/nubus.h>
  12. #endif
  13. enum nubus_category {
  14. NUBUS_CAT_BOARD = 0x0001,
  15. NUBUS_CAT_DISPLAY = 0x0003,
  16. NUBUS_CAT_NETWORK = 0x0004,
  17. NUBUS_CAT_COMMUNICATIONS = 0x0006,
  18. NUBUS_CAT_FONT = 0x0009,
  19. NUBUS_CAT_CPU = 0x000A,
  20. /* For lack of a better name */
  21. NUBUS_CAT_DUODOCK = 0x0020
  22. };
  23. enum nubus_type_network {
  24. NUBUS_TYPE_ETHERNET = 0x0001,
  25. NUBUS_TYPE_RS232 = 0x0002
  26. };
  27. enum nubus_type_display {
  28. NUBUS_TYPE_VIDEO = 0x0001
  29. };
  30. enum nubus_type_cpu {
  31. NUBUS_TYPE_68020 = 0x0003,
  32. NUBUS_TYPE_68030 = 0x0004,
  33. NUBUS_TYPE_68040 = 0x0005
  34. };
  35. /* Known <Cat,Type,SW,HW> tuples: (according to TattleTech and Slots)
  36. * 68030 motherboards: <10,4,0,24>
  37. * 68040 motherboards: <10,5,0,24>
  38. * DuoDock Plus: <32,1,1,2>
  39. *
  40. * Toby Frame Buffer card: <3,1,1,1>
  41. * RBV built-in video (IIci): <3,1,1,24>
  42. * Valkyrie built-in video (Q630): <3,1,1,46>
  43. * Macintosh Display Card: <3,1,1,25>
  44. * Sonora built-in video (P460): <3,1,1,34>
  45. * Jet framebuffer (DuoDock Plus): <3,1,1,41>
  46. *
  47. * SONIC comm-slot/on-board and DuoDock Ethernet: <4,1,1,272>
  48. * SONIC LC-PDS Ethernet (Dayna, but like Apple 16-bit, sort of): <4,1,1,271>
  49. * Sonic Systems Ethernet A-Series Card: <4,1,268,256>
  50. * Asante MacCon NuBus-A: <4,1,260,256> (alpha-1.0,1.1 revision)
  51. * ROM on the above card: <2,1,0,0>
  52. * Cabletron ethernet card: <4,1,1,265>
  53. * Farallon ethernet card: <4,1,268,256> (identical to Sonic Systems card)
  54. * Kinetics EtherPort IIN: <4,1,259,262>
  55. * API Engineering EtherRun_LCa PDS enet card: <4,1,282,256>
  56. *
  57. * Add your devices to the list! You can obtain the "Slots" utility
  58. * from Apple's FTP site at:
  59. * ftp://dev.apple.com/devworld/Tool_Chest/Devices_-_Hardware/NuBus_Slot_Manager/
  60. *
  61. * Alternately, TattleTech can be found at any Info-Mac mirror site.
  62. * or from its distribution site: ftp://ftp.decismkr.com/dms
  63. */
  64. /* DrSW: Uniquely identifies the software interface to a board. This
  65. is usually the one you want to look at when writing a driver. It's
  66. not as useful as you think, though, because as we should know by
  67. now (duh), "Apple Compatible" can mean a lot of things... */
  68. /* Add known DrSW values here */
  69. enum nubus_drsw {
  70. /* NUBUS_CAT_DISPLAY */
  71. NUBUS_DRSW_APPLE = 0x0001,
  72. NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */
  73. /* NUBUS_CAT_NETWORK */
  74. NUBUS_DRSW_CABLETRON = 0x0001,
  75. NUBUS_DRSW_SONIC_LC = 0x0001,
  76. NUBUS_DRSW_KINETICS = 0x0103,
  77. NUBUS_DRSW_ASANTE = 0x0104,
  78. NUBUS_DRSW_DAYNA = 0x010b,
  79. NUBUS_DRSW_FARALLON = 0x010c,
  80. NUBUS_DRSW_APPLE_SN = 0x010f,
  81. NUBUS_DRSW_DAYNA2 = 0x0115,
  82. NUBUS_DRSW_FOCUS = 0x011a,
  83. NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */
  84. NUBUS_DRSW_DAYNA_LC = 0x011e,
  85. /* NUBUS_CAT_CPU */
  86. NUBUS_DRSW_NONE = 0x0000,
  87. };
  88. /* DrHW: Uniquely identifies the hardware interface to a board (or at
  89. least, it should... some video cards are known to incorrectly
  90. identify themselves as Toby cards) */
  91. /* Add known DrHW values here */
  92. enum nubus_drhw {
  93. /* NUBUS_CAT_DISPLAY */
  94. NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */
  95. NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High Res Video card */
  96. NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */
  97. NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */
  98. NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */
  99. NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */
  100. NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
  101. NUBUS_DRHW_THUNDER24 = 0x02cb, /* SuperMac Thunder/24 */
  102. /* NUBUS_CAT_NETWORK */
  103. NUBUS_DRHW_INTERLAN = 0x0100,
  104. NUBUS_DRHW_SMC9194 = 0x0101,
  105. NUBUS_DRHW_KINETICS = 0x0106,
  106. NUBUS_DRHW_CABLETRON = 0x0109,
  107. NUBUS_DRHW_ASANTE_LC = 0x010f,
  108. NUBUS_DRHW_SONIC = 0x0110,
  109. NUBUS_DRHW_SONIC_NB = 0x0118,
  110. NUBUS_DRHW_SONIC_LC = 0x0119,
  111. /* NUBUS_CAT_COMMUNICATIONS */
  112. NUBUS_DRHW_DOVEFAX = 0x0100,
  113. };
  114. /* Resource IDs: These are the identifiers for the various weird and
  115. wonderful tidbits of information that may or may not reside in the
  116. NuBus ROM directory. */
  117. enum nubus_res_id {
  118. NUBUS_RESID_TYPE = 0x0001,
  119. NUBUS_RESID_NAME = 0x0002,
  120. NUBUS_RESID_ICON = 0x0003,
  121. NUBUS_RESID_DRVRDIR = 0x0004,
  122. NUBUS_RESID_LOADREC = 0x0005,
  123. NUBUS_RESID_BOOTREC = 0x0006,
  124. NUBUS_RESID_FLAGS = 0x0007,
  125. NUBUS_RESID_HWDEVID = 0x0008,
  126. NUBUS_RESID_MINOR_BASEOS = 0x000a,
  127. NUBUS_RESID_MINOR_LENGTH = 0x000b,
  128. NUBUS_RESID_MAJOR_BASEOS = 0x000c,
  129. NUBUS_RESID_MAJOR_LENGTH = 0x000d,
  130. NUBUS_RESID_CICN = 0x000f,
  131. NUBUS_RESID_ICL8 = 0x0010,
  132. NUBUS_RESID_ICL4 = 0x0011,
  133. };
  134. /* Category-specific resources. */
  135. enum nubus_board_res_id {
  136. NUBUS_RESID_BOARDID = 0x0020,
  137. NUBUS_RESID_PRAMINITDATA = 0x0021,
  138. NUBUS_RESID_PRIMARYINIT = 0x0022,
  139. NUBUS_RESID_TIMEOUTCONST = 0x0023,
  140. NUBUS_RESID_VENDORINFO = 0x0024,
  141. NUBUS_RESID_BOARDFLAGS = 0x0025,
  142. NUBUS_RESID_SECONDINIT = 0x0026,
  143. /* Not sure why Apple put these next two in here */
  144. NUBUS_RESID_VIDNAMES = 0x0041,
  145. NUBUS_RESID_VIDMODES = 0x007e
  146. };
  147. /* Fields within the vendor info directory */
  148. enum nubus_vendor_res_id {
  149. NUBUS_RESID_VEND_ID = 0x0001,
  150. NUBUS_RESID_VEND_SERIAL = 0x0002,
  151. NUBUS_RESID_VEND_REV = 0x0003,
  152. NUBUS_RESID_VEND_PART = 0x0004,
  153. NUBUS_RESID_VEND_DATE = 0x0005
  154. };
  155. enum nubus_net_res_id {
  156. NUBUS_RESID_MAC_ADDRESS = 0x0080
  157. };
  158. enum nubus_cpu_res_id {
  159. NUBUS_RESID_MEMINFO = 0x0081,
  160. NUBUS_RESID_ROMINFO = 0x0082
  161. };
  162. enum nubus_display_res_id {
  163. NUBUS_RESID_GAMMADIR = 0x0040,
  164. NUBUS_RESID_FIRSTMODE = 0x0080,
  165. NUBUS_RESID_SECONDMODE = 0x0081,
  166. NUBUS_RESID_THIRDMODE = 0x0082,
  167. NUBUS_RESID_FOURTHMODE = 0x0083,
  168. NUBUS_RESID_FIFTHMODE = 0x0084,
  169. NUBUS_RESID_SIXTHMODE = 0x0085
  170. };
  171. struct nubus_dir
  172. {
  173. unsigned char *base;
  174. unsigned char *ptr;
  175. int done;
  176. int mask;
  177. };
  178. struct nubus_dirent
  179. {
  180. unsigned char *base;
  181. unsigned char type;
  182. __u32 data; /* Actually 24bits used */
  183. int mask;
  184. };
  185. struct nubus_board {
  186. struct nubus_board* next;
  187. struct nubus_dev* first_dev;
  188. /* Only 9-E actually exist, though 0-8 are also theoretically
  189. possible, and 0 is a special case which represents the
  190. motherboard and onboard peripherals (Ethernet, video) */
  191. int slot;
  192. /* For slot 0, this is bogus. */
  193. char name[64];
  194. /* Format block */
  195. unsigned char* fblock;
  196. /* Root directory (does *not* always equal fblock + doffset!) */
  197. unsigned char* directory;
  198. unsigned long slot_addr;
  199. /* Offset to root directory (sometimes) */
  200. unsigned long doffset;
  201. /* Length over which to compute the crc */
  202. unsigned long rom_length;
  203. /* Completely useless most of the time */
  204. unsigned long crc;
  205. unsigned char rev;
  206. unsigned char format;
  207. unsigned char lanes;
  208. };
  209. struct nubus_dev {
  210. /* Next link in device list */
  211. struct nubus_dev* next;
  212. /* Directory entry in /proc/bus/nubus */
  213. struct proc_dir_entry* procdir;
  214. /* The functional resource ID of this device */
  215. unsigned char resid;
  216. /* These are mostly here for convenience; we could always read
  217. them from the ROMs if we wanted to */
  218. unsigned short category;
  219. unsigned short type;
  220. unsigned short dr_sw;
  221. unsigned short dr_hw;
  222. /* This is the device's name rather than the board's.
  223. Sometimes they are different. Usually the board name is
  224. more correct. */
  225. char name[64];
  226. /* MacOS driver (I kid you not) */
  227. unsigned char* driver;
  228. /* Actually this is an offset */
  229. unsigned long iobase;
  230. unsigned long iosize;
  231. unsigned char flags, hwdevid;
  232. /* Functional directory */
  233. unsigned char* directory;
  234. /* Much of our info comes from here */
  235. struct nubus_board* board;
  236. };
  237. /* This is all NuBus devices (used to find devices later on) */
  238. extern struct nubus_dev* nubus_devices;
  239. /* This is all NuBus cards */
  240. extern struct nubus_board* nubus_boards;
  241. /* Generic NuBus interface functions, modelled after the PCI interface */
  242. void nubus_scan_bus(void);
  243. extern void nubus_proc_init(void);
  244. int get_nubus_list(char *buf);
  245. int nubus_proc_attach_device(struct nubus_dev *dev);
  246. int nubus_proc_detach_device(struct nubus_dev *dev);
  247. /* If we need more precision we can add some more of these */
  248. struct nubus_dev* nubus_find_device(unsigned short category,
  249. unsigned short type,
  250. unsigned short dr_hw,
  251. unsigned short dr_sw,
  252. const struct nubus_dev* from);
  253. struct nubus_dev* nubus_find_type(unsigned short category,
  254. unsigned short type,
  255. const struct nubus_dev* from);
  256. /* Might have more than one device in a slot, you know... */
  257. struct nubus_dev* nubus_find_slot(unsigned int slot,
  258. const struct nubus_dev* from);
  259. /* These are somewhat more NuBus-specific. They all return 0 for
  260. success and -1 for failure, as you'd expect. */
  261. /* The root directory which contains the board and functional
  262. directories */
  263. int nubus_get_root_dir(const struct nubus_board* board,
  264. struct nubus_dir* dir);
  265. /* The board directory */
  266. int nubus_get_board_dir(const struct nubus_board* board,
  267. struct nubus_dir* dir);
  268. /* The functional directory */
  269. int nubus_get_func_dir(const struct nubus_dev* dev,
  270. struct nubus_dir* dir);
  271. /* These work on any directory gotten via the above */
  272. int nubus_readdir(struct nubus_dir* dir,
  273. struct nubus_dirent* ent);
  274. int nubus_find_rsrc(struct nubus_dir* dir,
  275. unsigned char rsrc_type,
  276. struct nubus_dirent* ent);
  277. int nubus_rewinddir(struct nubus_dir* dir);
  278. /* Things to do with directory entries */
  279. int nubus_get_subdir(const struct nubus_dirent* ent,
  280. struct nubus_dir* dir);
  281. void nubus_get_rsrc_mem(void* dest,
  282. const struct nubus_dirent *dirent,
  283. int len);
  284. void nubus_get_rsrc_str(void* dest,
  285. const struct nubus_dirent *dirent,
  286. int maxlen);
  287. /* We'd like to get rid of this eventually. Only daynaport.c uses it now. */
  288. static inline void *nubus_slot_addr(int slot)
  289. {
  290. return (void *)(0xF0000000|(slot<<24));
  291. }
  292. #endif /* LINUX_NUBUS_H */