2 #include "config/isa.h"
6 * isa.c implements a "classical" port-scanning method of ISA device
7 * detection. The driver must provide a list of probe addresses
8 * (probe_addrs), together with a function (probe_addr) that can be
9 * used to test for the physical presence of a device at any given
12 * Note that this should probably be considered the "last resort" for
13 * device probing. If the card supports ISAPnP or EISA, use that
14 * instead. Some cards (e.g. the 3c509) implement a proprietary
15 * ISAPnP-like mechanism.
17 * The ISA probe address list can be overridden by config.c; if the
18 * user specifies ISA_PROBE_ADDRS then that list will be used first.
19 * (If ISA_PROBE_ADDRS ends with a zero, the driver's own list will
24 * Ensure that there is sufficient space in the shared dev_bus
25 * structure for a struct isa_device.
28 DEV_BUS( struct isa_device, isa_dev );
29 static char isa_magic[0]; /* guaranteed unique symbol */
32 * User-supplied probe address list
35 static isa_probe_addr_t isa_extra_probe_addrs[] = {
41 #define isa_extra_probe_addr_count \
42 ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
45 * Find an ISA device matching the specified driver
48 int find_isa_device ( struct isa_device *isa, struct isa_driver *driver ) {
52 /* Initialise struct isa if it's the first time it's been used. */
53 if ( isa->magic != isa_magic ) {
54 memset ( isa, 0, sizeof ( *isa ) );
55 isa->magic = isa_magic;
58 /* Iterate through any ISA probe addresses specified by the
59 * user, starting where we left off.
61 DBG ( "ISA searching for device matching driver %s\n", driver->name );
62 for ( i = isa->probe_idx ; i < isa_extra_probe_addr_count ; i++ ) {
63 /* If we've already used this device, skip it */
64 if ( isa->already_tried ) {
65 isa->already_tried = 0;
70 ioaddr = isa_extra_probe_addrs[i];
72 /* An I/O address of 0 in extra_probe_addrs list means
73 * stop probing (i.e. don't continue to the
74 * driver-provided list)
79 /* Use probe_addr method to see if there's a device
80 * present at this address.
82 if ( driver->probe_addr ( ioaddr ) ) {
88 /* Iterate through all ISA probe addresses provided by the
89 * driver, starting where we left off.
91 for ( i = isa->probe_idx - isa_extra_probe_addr_count ;
92 i < driver->addr_count ; i++ ) {
94 /* If we've already used this device, skip it */
95 if ( isa->already_tried ) {
96 isa->already_tried = 0;
100 /* Set I/O address */
101 ioaddr = driver->probe_addrs[i];
103 /* Use probe_addr method to see if there's a device
104 * present at this address.
106 if ( driver->probe_addr ( ioaddr ) ) {
107 isa->probe_idx = i + isa_extra_probe_addr_count;
113 /* No device found */
114 DBG ( "ISA found no device matching driver %s\n", driver->name );
119 DBG ( "ISA found %s device at address %hx\n", driver->name, ioaddr );
120 isa->ioaddr = ioaddr;
121 isa->already_tried = 1;
126 * Find the next ISA device that can be used to boot using the
130 int find_isa_boot_device ( struct dev *dev, struct isa_driver *driver ) {
131 struct isa_device *isa = ( struct isa_device * )dev->bus;
133 if ( ! find_isa_device ( isa, driver ) )
136 dev->name = driver->name;
137 dev->devid.bus_type = ISA_BUS_TYPE;
138 dev->devid.vendor_id = driver->mfg_id;
139 dev->devid.device_id = driver->prod_id;