nubus.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. #include <asm/nubus.h>
  11. #include <uapi/linux/nubus.h>
  12. struct nubus_board {
  13. struct nubus_board* next;
  14. struct nubus_dev* first_dev;
  15. /* Only 9-E actually exist, though 0-8 are also theoretically
  16. possible, and 0 is a special case which represents the
  17. motherboard and onboard peripherals (Ethernet, video) */
  18. int slot;
  19. /* For slot 0, this is bogus. */
  20. char name[64];
  21. /* Format block */
  22. unsigned char* fblock;
  23. /* Root directory (does *not* always equal fblock + doffset!) */
  24. unsigned char* directory;
  25. unsigned long slot_addr;
  26. /* Offset to root directory (sometimes) */
  27. unsigned long doffset;
  28. /* Length over which to compute the crc */
  29. unsigned long rom_length;
  30. /* Completely useless most of the time */
  31. unsigned long crc;
  32. unsigned char rev;
  33. unsigned char format;
  34. unsigned char lanes;
  35. };
  36. struct nubus_dev {
  37. /* Next link in device list */
  38. struct nubus_dev* next;
  39. /* Directory entry in /proc/bus/nubus */
  40. struct proc_dir_entry* procdir;
  41. /* The functional resource ID of this device */
  42. unsigned char resid;
  43. /* These are mostly here for convenience; we could always read
  44. them from the ROMs if we wanted to */
  45. unsigned short category;
  46. unsigned short type;
  47. unsigned short dr_sw;
  48. unsigned short dr_hw;
  49. /* This is the device's name rather than the board's.
  50. Sometimes they are different. Usually the board name is
  51. more correct. */
  52. char name[64];
  53. /* MacOS driver (I kid you not) */
  54. unsigned char* driver;
  55. /* Actually this is an offset */
  56. unsigned long iobase;
  57. unsigned long iosize;
  58. unsigned char flags, hwdevid;
  59. /* Functional directory */
  60. unsigned char* directory;
  61. /* Much of our info comes from here */
  62. struct nubus_board* board;
  63. };
  64. /* This is all NuBus devices (used to find devices later on) */
  65. extern struct nubus_dev* nubus_devices;
  66. /* This is all NuBus cards */
  67. extern struct nubus_board* nubus_boards;
  68. /* Generic NuBus interface functions, modelled after the PCI interface */
  69. void nubus_scan_bus(void);
  70. #ifdef CONFIG_PROC_FS
  71. extern void nubus_proc_init(void);
  72. #else
  73. static inline void nubus_proc_init(void) {}
  74. #endif
  75. int get_nubus_list(char *buf);
  76. int nubus_proc_attach_device(struct nubus_dev *dev);
  77. /* If we need more precision we can add some more of these */
  78. struct nubus_dev* nubus_find_device(unsigned short category,
  79. unsigned short type,
  80. unsigned short dr_hw,
  81. unsigned short dr_sw,
  82. const struct nubus_dev* from);
  83. struct nubus_dev* nubus_find_type(unsigned short category,
  84. unsigned short type,
  85. const struct nubus_dev* from);
  86. /* Might have more than one device in a slot, you know... */
  87. struct nubus_dev* nubus_find_slot(unsigned int slot,
  88. const struct nubus_dev* from);
  89. /* These are somewhat more NuBus-specific. They all return 0 for
  90. success and -1 for failure, as you'd expect. */
  91. /* The root directory which contains the board and functional
  92. directories */
  93. int nubus_get_root_dir(const struct nubus_board* board,
  94. struct nubus_dir* dir);
  95. /* The board directory */
  96. int nubus_get_board_dir(const struct nubus_board* board,
  97. struct nubus_dir* dir);
  98. /* The functional directory */
  99. int nubus_get_func_dir(const struct nubus_dev* dev,
  100. struct nubus_dir* dir);
  101. /* These work on any directory gotten via the above */
  102. int nubus_readdir(struct nubus_dir* dir,
  103. struct nubus_dirent* ent);
  104. int nubus_find_rsrc(struct nubus_dir* dir,
  105. unsigned char rsrc_type,
  106. struct nubus_dirent* ent);
  107. int nubus_rewinddir(struct nubus_dir* dir);
  108. /* Things to do with directory entries */
  109. int nubus_get_subdir(const struct nubus_dirent* ent,
  110. struct nubus_dir* dir);
  111. void nubus_get_rsrc_mem(void* dest,
  112. const struct nubus_dirent *dirent,
  113. int len);
  114. void nubus_get_rsrc_str(void* dest,
  115. const struct nubus_dirent *dirent,
  116. int maxlen);
  117. #endif /* LINUX_NUBUS_H */