1 /* SPDX-License-Identifier: GPL-2.0 */
3 nubus.h: various definitions and prototypes for NuBus drivers to use.
5 Originally written by Alan Cox.
7 Hacked to death by C. Scott Ananian and David Huggins-Daines.
9 Some of the constants in here are from the corresponding
10 NetBSD/OpenBSD header file, by Allen Briggs. We figured out the
11 rest of them on our own. */
15 #include <asm/nubus.h>
16 #include <uapi/linux/nubus.h>
19 struct nubus_board* next;
20 struct nubus_dev* first_dev;
22 /* Only 9-E actually exist, though 0-8 are also theoretically
23 possible, and 0 is a special case which represents the
24 motherboard and onboard peripherals (Ethernet, video) */
26 /* For slot 0, this is bogus. */
30 unsigned char* fblock;
31 /* Root directory (does *not* always equal fblock + doffset!) */
32 unsigned char* directory;
34 unsigned long slot_addr;
35 /* Offset to root directory (sometimes) */
36 unsigned long doffset;
37 /* Length over which to compute the crc */
38 unsigned long rom_length;
39 /* Completely useless most of the time */
47 /* Next link in device list */
48 struct nubus_dev* next;
49 /* Directory entry in /proc/bus/nubus */
50 struct proc_dir_entry* procdir;
52 /* The functional resource ID of this device */
54 /* These are mostly here for convenience; we could always read
55 them from the ROMs if we wanted to */
56 unsigned short category;
60 /* This is the device's name rather than the board's.
61 Sometimes they are different. Usually the board name is
64 /* MacOS driver (I kid you not) */
65 unsigned char* driver;
66 /* Actually this is an offset */
69 unsigned char flags, hwdevid;
71 /* Functional directory */
72 unsigned char* directory;
73 /* Much of our info comes from here */
74 struct nubus_board* board;
77 /* This is all NuBus devices (used to find devices later on) */
78 extern struct nubus_dev* nubus_devices;
79 /* This is all NuBus cards */
80 extern struct nubus_board* nubus_boards;
82 /* Generic NuBus interface functions, modelled after the PCI interface */
83 void nubus_scan_bus(void);
85 extern void nubus_proc_init(void);
87 static inline void nubus_proc_init(void) {}
89 int get_nubus_list(char *buf);
90 int nubus_proc_attach_device(struct nubus_dev *dev);
91 /* If we need more precision we can add some more of these */
92 struct nubus_dev* nubus_find_device(unsigned short category,
96 const struct nubus_dev* from);
97 struct nubus_dev* nubus_find_type(unsigned short category,
99 const struct nubus_dev* from);
100 /* Might have more than one device in a slot, you know... */
101 struct nubus_dev* nubus_find_slot(unsigned int slot,
102 const struct nubus_dev* from);
104 /* These are somewhat more NuBus-specific. They all return 0 for
105 success and -1 for failure, as you'd expect. */
107 /* The root directory which contains the board and functional
109 int nubus_get_root_dir(const struct nubus_board* board,
110 struct nubus_dir* dir);
111 /* The board directory */
112 int nubus_get_board_dir(const struct nubus_board* board,
113 struct nubus_dir* dir);
114 /* The functional directory */
115 int nubus_get_func_dir(const struct nubus_dev* dev,
116 struct nubus_dir* dir);
118 /* These work on any directory gotten via the above */
119 int nubus_readdir(struct nubus_dir* dir,
120 struct nubus_dirent* ent);
121 int nubus_find_rsrc(struct nubus_dir* dir,
122 unsigned char rsrc_type,
123 struct nubus_dirent* ent);
124 int nubus_rewinddir(struct nubus_dir* dir);
126 /* Things to do with directory entries */
127 int nubus_get_subdir(const struct nubus_dirent* ent,
128 struct nubus_dir* dir);
129 void nubus_get_rsrc_mem(void* dest,
130 const struct nubus_dirent *dirent,
132 void nubus_get_rsrc_str(void* dest,
133 const struct nubus_dirent *dirent,
135 #endif /* LINUX_NUBUS_H */