[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / gpxe / device.h
blob1db3ff906d1ea36974ef9f55628068e83cd64f37
1 #ifndef _GPXE_DEVICE_H
2 #define _GPXE_DEVICE_H
4 /**
5 * @file
7 * Device model
9 */
11 FILE_LICENCE ( GPL2_OR_LATER );
13 #include <gpxe/list.h>
14 #include <gpxe/tables.h>
16 /** A hardware device description */
17 struct device_description {
18 /** Bus type
20 * This must be a BUS_TYPE_XXX constant.
22 unsigned int bus_type;
23 /** Location
25 * The interpretation of this field is bus-type-specific.
27 unsigned int location;
28 /** Vendor ID */
29 unsigned int vendor;
30 /** Device ID */
31 unsigned int device;
32 /** Device class */
33 unsigned long class;
34 /** I/O address */
35 unsigned long ioaddr;
36 /** IRQ */
37 unsigned int irq;
40 /** PCI bus type */
41 #define BUS_TYPE_PCI 1
43 /** ISAPnP bus type */
44 #define BUS_TYPE_ISAPNP 2
46 /** EISA bus type */
47 #define BUS_TYPE_EISA 3
49 /** MCA bus type */
50 #define BUS_TYPE_MCA 4
52 /** ISA bus type */
53 #define BUS_TYPE_ISA 5
55 /** A hardware device */
56 struct device {
57 /** Name */
58 char name[16];
59 /** Device description */
60 struct device_description desc;
61 /** Devices on the same bus */
62 struct list_head siblings;
63 /** Devices attached to this device */
64 struct list_head children;
65 /** Bus device */
66 struct device *parent;
69 /**
70 * A root device
72 * Root devices are system buses such as PCI, EISA, etc.
75 struct root_device {
76 /** Device chain
78 * A root device has a NULL parent field.
80 struct device dev;
81 /** Root device driver */
82 struct root_driver *driver;
85 /** A root device driver */
86 struct root_driver {
87 /**
88 * Add root device
90 * @v rootdev Root device
91 * @ret rc Return status code
93 * Called from probe_devices() for all root devices in the build.
95 int ( * probe ) ( struct root_device *rootdev );
96 /**
97 * Remove root device
99 * @v rootdev Root device
101 * Called from remove_device() for all successfully-probed
102 * root devices.
104 void ( * remove ) ( struct root_device *rootdev );
107 /** Root device table */
108 #define ROOT_DEVICES __table ( struct root_device, "root_devices" )
110 /** Declare a root device */
111 #define __root_device __table_entry ( ROOT_DEVICES, 01 )
113 #endif /* _GPXE_DEVICE_H */