summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael Brown2005-04-12 18:38:23 +0200
committerMichael Brown2005-04-12 18:38:23 +0200
commit17c1ca90e70597a834604f21dce8a0106f082050 (patch)
tree3ea872cb84351714ff35036914283fb132d62f40 /src/core
parentNew PCI scan functions now work. (diff)
downloadipxe-17c1ca90e70597a834604f21dce8a0106f082050.tar.gz
ipxe-17c1ca90e70597a834604f21dce8a0106f082050.tar.xz
ipxe-17c1ca90e70597a834604f21dce8a0106f082050.zip
New device probing mechanism
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dev.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/core/dev.c b/src/core/dev.c
new file mode 100644
index 000000000..cd69d3495
--- /dev/null
+++ b/src/core/dev.c
@@ -0,0 +1,44 @@
+#include "etherboot.h"
+#include "stddef.h"
+#include "dev.h"
+
+/* Defined by linker */
+extern struct boot_driver boot_drivers[];
+extern struct boot_driver boot_drivers_end[];
+
+/* Current attempted boot driver */
+static struct boot_driver *boot_driver = boot_drivers;
+
+/* Current boot device */
+struct dev dev;
+
+/* Print all drivers */
+void print_drivers ( void ) {
+ struct boot_driver *driver;
+
+ for ( driver = boot_drivers ; driver < boot_drivers_end ; driver++ ) {
+ printf ( "%s ", driver->name );
+ }
+}
+
+/* Get the next available boot device */
+int probe ( struct dev *dev ) {
+
+ for ( ; boot_driver < boot_drivers_end ; boot_driver++ ) {
+ dev->name = "unknown";
+ if ( boot_driver->probe ( dev ) )
+ return 1;
+ }
+
+ /* No more boot devices found */
+ boot_driver = boot_drivers;
+ return 0;
+}
+
+/* Disable a device */
+void disable ( struct dev *dev ) {
+ if ( dev->dev_op ) {
+ dev->dev_op->disable ( dev );
+ dev->dev_op = NULL;
+ }
+}