1 #ifndef _GPXE_DEVICE_H 2 #define _GPXE_DEVICE_H 3 4 /** 5 * @file 6 * 7 * Device model 8 * 9 */ 10 11 FILE_LICENCE ( GPL2_OR_LATER ); 12 13 #include <gpxe/list.h> 14 #include <gpxe/tables.h> 15 16 /** A hardware device description */ 17 struct device_description { 18 /** Bus type 19 * 20 * This must be a BUS_TYPE_XXX constant. 21 */ 22 unsigned int bus_type; 23 /** Location 24 * 25 * The interpretation of this field is bus-type-specific. 26 */ 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; 38 }; 39 40 /** PCI bus type */ 41 #define BUS_TYPE_PCI 1 42 43 /** ISAPnP bus type */ 44 #define BUS_TYPE_ISAPNP 2 45 46 /** EISA bus type */ 47 #define BUS_TYPE_EISA 3 48 49 /** MCA bus type */ 50 #define BUS_TYPE_MCA 4 51 52 /** ISA bus type */ 53 #define BUS_TYPE_ISA 5 54 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; 67 }; 68 69 /** 70 * A root device 71 * 72 * Root devices are system buses such as PCI, EISA, etc. 73 * 74 */ 75 struct root_device { 76 /** Device chain 77 * 78 * A root device has a NULL parent field. 79 */ 80 struct device dev; 81 /** Root device driver */ 82 struct root_driver *driver; 83 }; 84 85 /** A root device driver */ 86 struct root_driver { 87 /** 88 * Add root device 89 * 90 * @v rootdev Root device 91 * @ret rc Return status code 92 * 93 * Called from probe_devices() for all root devices in the build. 94 */ 95 int ( * probe ) ( struct root_device *rootdev ); 96 /** 97 * Remove root device 98 * 99 * @v rootdev Root device 100 * 101 * Called from remove_device() for all successfully-probed 102 * root devices. 103 */ 104 void ( * remove ) ( struct root_device *rootdev ); 105 }; 106 107 /** Root device table */ 108 #define ROOT_DEVICES __table ( struct root_device, "root_devices" ) 109 110 /** Declare a root device */ 111 #define __root_device __table_entry ( ROOT_DEVICES, 01 ) 112 113 #endif /* _GPXE_DEVICE_H */ 114