summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/device.h
diff options
context:
space:
mode:
authorMichael Brown2006-05-16 16:10:21 +0200
committerMichael Brown2006-05-16 16:10:21 +0200
commitceba6ecb756418f7976b3d88d168c790b7a40e21 (patch)
tree345d63ca2f751f0783d7acd4d3e39dda7e5879b3 /src/include/gpxe/device.h
parentChange movetoyx(), putc() and getc() to methods of the screen. (diff)
downloadipxe-ceba6ecb756418f7976b3d88d168c790b7a40e21.tar.gz
ipxe-ceba6ecb756418f7976b3d88d168c790b7a40e21.tar.xz
ipxe-ceba6ecb756418f7976b3d88d168c790b7a40e21.zip
Added generic device model.
Diffstat (limited to 'src/include/gpxe/device.h')
-rw-r--r--src/include/gpxe/device.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/include/gpxe/device.h b/src/include/gpxe/device.h
new file mode 100644
index 00000000..43bbf604
--- /dev/null
+++ b/src/include/gpxe/device.h
@@ -0,0 +1,70 @@
+#ifndef _GPXE_DEVICE_H
+#define _GPXE_DEVICE_H
+
+/**
+ * @file
+ *
+ * Device model
+ *
+ */
+
+#include <gpxe/list.h>
+#include <gpxe/tables.h>
+
+/** A hardware device */
+struct device {
+ /** Devices on the same bus */
+ struct list_head siblings;
+ /** Devices attached to this device */
+ struct list_head children;
+ /** Bus device */
+ struct device *parent;
+};
+
+/**
+ * A root device
+ *
+ * Root devices are system buses such as PCI, EISA, etc.
+ *
+ */
+struct root_device {
+ /** Name */
+ const char *name;
+ /** Device chain
+ *
+ * A root device has a NULL parent field.
+ */
+ struct device dev;
+ /** Root device driver */
+ struct root_driver *driver;
+};
+
+/** A root device driver */
+struct root_driver {
+ /**
+ * Add root device
+ *
+ * @v rootdev Root device
+ * @ret rc Return status code
+ *
+ * Called from probe_devices() for all root devices in the build.
+ */
+ int ( * probe ) ( struct root_device *rootdev );
+ /**
+ * Remove root device
+ *
+ * @v rootdev Root device
+ *
+ * Called from remove_device() for all successfully-probed
+ * root devices.
+ */
+ void ( * remove ) ( struct root_device *rootdev );
+};
+
+/** Declare a root device */
+#define __root_device __table ( root_devices, 01 )
+
+extern int probe_devices ( void );
+extern void remove_devices ( void );
+
+#endif /* _GPXE_DEVICE_H */