|
@@ -0,0 +1,123 @@
|
|
1
|
+#include "etherboot.h"
|
|
2
|
+#include "isa.h"
|
|
3
|
+
|
|
4
|
+/*
|
|
5
|
+ * isa.c implements a "classical" port-scanning method of ISA device
|
|
6
|
+ * detection. The driver must provide a list of probe addresses
|
|
7
|
+ * (probe_addrs), together with a function (probe_addr) that can be
|
|
8
|
+ * used to test for the physical presence of a device at any given
|
|
9
|
+ * address.
|
|
10
|
+ *
|
|
11
|
+ * Note that this should probably be considered the "last resort" for
|
|
12
|
+ * device probing. If the card supports ISAPnP or EISA, use that
|
|
13
|
+ * instead. Some cards (e.g. the 3c509) implement a proprietary
|
|
14
|
+ * ISAPnP-like mechanism.
|
|
15
|
+ *
|
|
16
|
+ * The ISA probe address list can be overridden by config.c; if
|
|
17
|
+ */
|
|
18
|
+
|
|
19
|
+/*
|
|
20
|
+ * Ensure that there is sufficient space in the shared dev_bus
|
|
21
|
+ * structure for a struct isa_device.
|
|
22
|
+ *
|
|
23
|
+ */
|
|
24
|
+DEV_BUS( struct isa_device, isa_dev );
|
|
25
|
+static char isa_magic[0]; /* guaranteed unique symbol */
|
|
26
|
+
|
|
27
|
+/*
|
|
28
|
+ * Find an ISA device matching the specified driver
|
|
29
|
+ *
|
|
30
|
+ */
|
|
31
|
+int find_isa_device ( struct isa_device *isa, struct isa_driver *driver ) {
|
|
32
|
+ unsigned int i;
|
|
33
|
+ uint16_t ioaddr;
|
|
34
|
+
|
|
35
|
+ /* Initialise struct isa if it's the first time it's been used. */
|
|
36
|
+ if ( isa->magic != isa_magic ) {
|
|
37
|
+ memset ( isa, 0, sizeof ( *isa ) );
|
|
38
|
+ isa->magic = isa_magic;
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ /* Iterate through any ISA probe addresses specified by
|
|
42
|
+ * config.c, starting where we left off.
|
|
43
|
+ */
|
|
44
|
+ for ( i = isa->probe_idx ; i < isa_extra_probe_addr_count ; i++ ) {
|
|
45
|
+ /* If we've already used this device, skip it */
|
|
46
|
+ if ( isa->already_tried ) {
|
|
47
|
+ isa->already_tried = 0;
|
|
48
|
+ continue;
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ /* Set I/O address */
|
|
52
|
+ ioaddr = isa_extra_probe_addrs[i].addr;
|
|
53
|
+
|
|
54
|
+ /* An I/O address of 0 in extra_probe_addrs list means
|
|
55
|
+ * stop probing (i.e. don't continue to the
|
|
56
|
+ * driver-provided list)
|
|
57
|
+ */
|
|
58
|
+ if ( ! ioaddr )
|
|
59
|
+ goto notfound;
|
|
60
|
+
|
|
61
|
+ /* Use probe_addr method to see if there's a device
|
|
62
|
+ * present at this address.
|
|
63
|
+ */
|
|
64
|
+ if ( driver->probe_addr ( ioaddr ) ) {
|
|
65
|
+ isa->probe_idx = i;
|
|
66
|
+ goto found;
|
|
67
|
+ }
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ /* Iterate through all ISA probe addresses provided by the
|
|
71
|
+ * driver, starting where we left off.
|
|
72
|
+ */
|
|
73
|
+ for ( i = isa->probe_idx - isa_extra_probe_addr_count ;
|
|
74
|
+ i < driver->addr_count ; i++ ) {
|
|
75
|
+
|
|
76
|
+ /* If we've already used this device, skip it */
|
|
77
|
+ if ( isa->already_tried ) {
|
|
78
|
+ isa->already_tried = 0;
|
|
79
|
+ continue;
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ /* Set I/O address */
|
|
83
|
+ ioaddr = driver->probe_addrs[i].addr;
|
|
84
|
+
|
|
85
|
+ /* Use probe_addr method to see if there's a device
|
|
86
|
+ * present at this address.
|
|
87
|
+ */
|
|
88
|
+ if ( driver->probe_addr ( ioaddr ) ) {
|
|
89
|
+ isa->probe_idx = i + isa_extra_probe_addr_count;
|
|
90
|
+ goto found;
|
|
91
|
+ }
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ notfound:
|
|
95
|
+ /* No device found */
|
|
96
|
+ isa->probe_idx = 0;
|
|
97
|
+ return 0;
|
|
98
|
+
|
|
99
|
+ found:
|
|
100
|
+ DBG ( "Found %s ISA device at address %hx\n", driver->name, ioaddr );
|
|
101
|
+ isa->ioaddr = ioaddr;
|
|
102
|
+ isa->already_tried = 1;
|
|
103
|
+ return 1;
|
|
104
|
+}
|
|
105
|
+
|
|
106
|
+/*
|
|
107
|
+ * Find the next ISA device that can be used to boot using the
|
|
108
|
+ * specified driver.
|
|
109
|
+ *
|
|
110
|
+ */
|
|
111
|
+int find_isa_boot_device ( struct dev *dev, struct isa_driver *driver ) {
|
|
112
|
+ struct isa_device *isa = ( struct isa_device * )dev->bus;
|
|
113
|
+
|
|
114
|
+ if ( ! find_isa_device ( isa, driver ) )
|
|
115
|
+ return 0;
|
|
116
|
+
|
|
117
|
+ dev->name = driver->name;
|
|
118
|
+ dev->devid.bus_type = ISA_BUS_TYPE;
|
|
119
|
+ dev->devid.vendor_id = driver->mfg_id;
|
|
120
|
+ dev->devid.device_id = driver->prod_id;
|
|
121
|
+
|
|
122
|
+ return 1;
|
|
123
|
+}
|