device.h

Go to the documentation of this file.
00001 #ifndef _GPXE_DEVICE_H
00002 #define _GPXE_DEVICE_H
00003 
00004 /**
00005  * @file
00006  *
00007  * Device model
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER );
00012 
00013 #include <gpxe/list.h>
00014 #include <gpxe/tables.h>
00015 
00016 /** A hardware device description */
00017 struct device_description {
00018         /** Bus type
00019          *
00020          * This must be a BUS_TYPE_XXX constant.
00021          */
00022         unsigned int bus_type;
00023         /** Location
00024          *
00025          * The interpretation of this field is bus-type-specific.
00026          */
00027         unsigned int location;
00028         /** Vendor ID */
00029         unsigned int vendor;
00030         /** Device ID */
00031         unsigned int device;
00032         /** Device class */
00033         unsigned long class;
00034         /** I/O address */
00035         unsigned long ioaddr;
00036         /** IRQ */
00037         unsigned int irq;
00038 };
00039 
00040 /** PCI bus type */
00041 #define BUS_TYPE_PCI 1
00042 
00043 /** ISAPnP bus type */
00044 #define BUS_TYPE_ISAPNP 2
00045 
00046 /** EISA bus type */
00047 #define BUS_TYPE_EISA 3
00048 
00049 /** MCA bus type */
00050 #define BUS_TYPE_MCA 4
00051 
00052 /** ISA bus type */
00053 #define BUS_TYPE_ISA 5
00054 
00055 /** A hardware device */
00056 struct device {
00057         /** Name */
00058         char name[16];
00059         /** Device description */
00060         struct device_description desc;
00061         /** Devices on the same bus */
00062         struct list_head siblings;
00063         /** Devices attached to this device */
00064         struct list_head children;
00065         /** Bus device */
00066         struct device *parent;
00067 };
00068 
00069 /**
00070  * A root device
00071  *
00072  * Root devices are system buses such as PCI, EISA, etc.
00073  *
00074  */
00075 struct root_device {
00076         /** Device chain
00077          *
00078          * A root device has a NULL parent field.
00079          */
00080         struct device dev;
00081         /** Root device driver */
00082         struct root_driver *driver;
00083 };
00084 
00085 /** A root device driver */
00086 struct root_driver {
00087         /**
00088          * Add root device
00089          *
00090          * @v rootdev   Root device
00091          * @ret rc      Return status code
00092          *
00093          * Called from probe_devices() for all root devices in the build.
00094          */
00095         int ( * probe ) ( struct root_device *rootdev );
00096         /**
00097          * Remove root device
00098          *
00099          * @v rootdev   Root device
00100          *
00101          * Called from remove_device() for all successfully-probed
00102          * root devices.
00103          */
00104         void ( * remove ) ( struct root_device *rootdev );
00105 };
00106 
00107 /** Root device table */
00108 #define ROOT_DEVICES __table ( struct root_device, "root_devices" )
00109 
00110 /** Declare a root device */
00111 #define __root_device __table_entry ( ROOT_DEVICES, 01 )
00112 
00113 #endif /* _GPXE_DEVICE_H */

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1