|
|
@@ -2,6 +2,20 @@
|
|
2
|
2
|
#include "stddef.h"
|
|
3
|
3
|
#include "dev.h"
|
|
4
|
4
|
|
|
|
5
|
+/*
|
|
|
6
|
+ * Each driver specifies a name, the bus-scanning function
|
|
|
7
|
+ * (find_bus_boot_device) that it wants to use, a driver information
|
|
|
8
|
+ * structure (bus_driver) containing e.g. device IDs to be passed to
|
|
|
9
|
+ * find_bus_boot_device, and a probe function (probe) to be called
|
|
|
10
|
+ * whenever a suitable device is found.
|
|
|
11
|
+ *
|
|
|
12
|
+ * The generic device-probing code knows nothing about particular bus
|
|
|
13
|
+ * types; it simply passes the driver information structure
|
|
|
14
|
+ * (bus_driver) to the bus-scanning function (find_bus_boot_device),
|
|
|
15
|
+ * then passes the result of that function (if not NULL) to the probe
|
|
|
16
|
+ * function (probe).
|
|
|
17
|
+ */
|
|
|
18
|
+
|
|
5
|
19
|
/* Defined by linker */
|
|
6
|
20
|
extern struct boot_driver boot_drivers[];
|
|
7
|
21
|
extern struct boot_driver boot_drivers_end[];
|
|
|
@@ -19,19 +33,30 @@ void print_drivers ( void ) {
|
|
19
|
33
|
}
|
|
20
|
34
|
|
|
21
|
35
|
/* Get the next available boot device */
|
|
22
|
|
-int probe ( struct dev *dev ) {
|
|
23
|
|
-
|
|
|
36
|
+int find_boot_device ( struct dev *dev ) {
|
|
24
|
37
|
for ( ; boot_driver < boot_drivers_end ; boot_driver++ ) {
|
|
25
|
|
- dev->name = "unknown";
|
|
26
|
|
- if ( boot_driver->probe ( dev ) )
|
|
|
38
|
+ dev->driver = boot_driver;
|
|
|
39
|
+ dev->name = boot_driver->name;
|
|
|
40
|
+ DBG ( "Probing driver %s...\n", dev->name );
|
|
|
41
|
+ if ( boot_driver->find_bus_boot_device ( dev,
|
|
|
42
|
+ boot_driver->bus_driver ) ) {
|
|
|
43
|
+ DBG ( "Found device %s (ID %hhx:%hx:%hx)\n",
|
|
|
44
|
+ dev->name, dev->devid->bus_type,
|
|
|
45
|
+ dev->devid->vendor_id, dev->devid->device_id );
|
|
27
|
46
|
return 1;
|
|
|
47
|
+ }
|
|
28
|
48
|
}
|
|
29
|
|
-
|
|
|
49
|
+
|
|
30
|
50
|
/* No more boot devices found */
|
|
31
|
51
|
boot_driver = boot_drivers;
|
|
32
|
52
|
return 0;
|
|
33
|
53
|
}
|
|
34
|
54
|
|
|
|
55
|
+/* Probe the boot device */
|
|
|
56
|
+int probe ( struct dev *dev ) {
|
|
|
57
|
+ return dev->driver->probe ( dev, dev->bus );
|
|
|
58
|
+}
|
|
|
59
|
+
|
|
35
|
60
|
/* Disable a device */
|
|
36
|
61
|
void disable ( struct dev *dev ) {
|
|
37
|
62
|
if ( dev->dev_op ) {
|