--- /dev/null
+#include "etherboot.h"
+#include "isa.h"
+
+/*
+ * isa.c implements a "classical" port-scanning method of ISA device
+ * detection. The driver must provide a list of probe addresses
+ * (probe_addrs), together with a function (probe_addr) that can be
+ * used to test for the physical presence of a device at any given
+ * address.
+ *
+ * Note that this should probably be considered the "last resort" for
+ * device probing. If the card supports ISAPnP or EISA, use that
+ * instead. Some cards (e.g. the 3c509) implement a proprietary
+ * ISAPnP-like mechanism.
+ *
+ * The ISA probe address list can be overridden by config.c; if
+ */
+
+/*
+ * Ensure that there is sufficient space in the shared dev_bus
+ * structure for a struct isa_device.
+ *
+ */
+DEV_BUS( struct isa_device, isa_dev );
+static char isa_magic[0]; /* guaranteed unique symbol */
+
+/*
+ * Find an ISA device matching the specified driver
+ *
+ */
+int find_isa_device ( struct isa_device *isa, struct isa_driver *driver ) {
+ unsigned int i;
+ uint16_t ioaddr;
+
+ /* Initialise struct isa if it's the first time it's been used. */
+ if ( isa->magic != isa_magic ) {
+ memset ( isa, 0, sizeof ( *isa ) );
+ isa->magic = isa_magic;
+ }
+
+ /* Iterate through any ISA probe addresses specified by
+ * config.c, starting where we left off.
+ */
+ for ( i = isa->probe_idx ; i < isa_extra_probe_addr_count ; i++ ) {
+ /* If we've already used this device, skip it */
+ if ( isa->already_tried ) {
+ isa->already_tried = 0;
+ continue;
+ }
+
+ /* Set I/O address */
+ ioaddr = isa_extra_probe_addrs[i].addr;
+
+ /* An I/O address of 0 in extra_probe_addrs list means
+ * stop probing (i.e. don't continue to the
+ * driver-provided list)
+ */
+ if ( ! ioaddr )
+ goto notfound;
+
+ /* Use probe_addr method to see if there's a device
+ * present at this address.
+ */
+ if ( driver->probe_addr ( ioaddr ) ) {
+ isa->probe_idx = i;
+ goto found;
+ }
+ }
+
+ /* Iterate through all ISA probe addresses provided by the
+ * driver, starting where we left off.
+ */
+ for ( i = isa->probe_idx - isa_extra_probe_addr_count ;
+ i < driver->addr_count ; i++ ) {
+
+ /* If we've already used this device, skip it */
+ if ( isa->already_tried ) {
+ isa->already_tried = 0;
+ continue;
+ }
+
+ /* Set I/O address */
+ ioaddr = driver->probe_addrs[i].addr;
+
+ /* Use probe_addr method to see if there's a device
+ * present at this address.
+ */
+ if ( driver->probe_addr ( ioaddr ) ) {
+ isa->probe_idx = i + isa_extra_probe_addr_count;
+ goto found;
+ }
+ }
+
+ notfound:
+ /* No device found */
+ isa->probe_idx = 0;
+ return 0;
+
+ found:
+ DBG ( "Found %s ISA device at address %hx\n", driver->name, ioaddr );
+ isa->ioaddr = ioaddr;
+ isa->already_tried = 1;
+ return 1;
+}
+
+/*
+ * Find the next ISA device that can be used to boot using the
+ * specified driver.
+ *
+ */
+int find_isa_boot_device ( struct dev *dev, struct isa_driver *driver ) {
+ struct isa_device *isa = ( struct isa_device * )dev->bus;
+
+ if ( ! find_isa_device ( isa, driver ) )
+ return 0;
+
+ dev->name = driver->name;
+ dev->devid.bus_type = ISA_BUS_TYPE;
+ dev->devid.vendor_id = driver->mfg_id;
+ dev->devid.device_id = driver->prod_id;
+
+ return 1;
+}
#define ISA_H
#include "isa_ids.h"
+#include "dev.h"
-struct dev;
+/*
+ * A physical ISA device
+ *
+ */
+struct isa_device {
+ char *magic; /* must be first */
+ unsigned int probe_idx;
+ uint16_t ioaddr;
+ int already_tried;
+};
+
+/*
+ * An individual ISA device, identified by probe address
+ *
+ */
+struct isa_probe_addr {
+ uint16_t addr;
+} __attribute__ (( packed ));
-struct isa_driver
-{
- int type;
+/*
+ * An ISA driver, with a probe address list and a probe_addr method.
+ * probe_addr() should return 1 if a card is physically present,
+ * leaving the other operations (read MAC address etc.) down to the
+ * main probe() routine.
+ *
+ */
+struct isa_driver {
const char *name;
- int (*probe)(struct dev *, unsigned short *);
- unsigned short *ioaddrs;
+ struct isa_probe_addr *probe_addrs;
+ unsigned int addr_count;
+ int ( * probe_addr ) ( uint16_t addr );
+ uint16_t mfg_id;
+ uint16_t prod_id;
};
-#ifndef __HYPERSTONE__
-#define __isa_driver __attribute__ ((used,__section__(".drivers.isa")))
-#else
-#define __isa_driver __attribute__ ((used,__section__(".drivisa")))
-#endif
+/*
+ * Define an ISA driver
+ *
+ */
+#define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id ) { \
+ .name = _name, \
+ .probe_addrs = _probe_addrs, \
+ .addr_count = sizeof ( _probe_addrs ) / sizeof ( probe_addrs[0] ), \
+ .probe_addr = _probe_addr, \
+ .mfg_id = _mfg_id, \
+ .prod_id = _prod_id, \
+}
+
+/*
+ * ISA_ROM is parsed by parserom.pl to generate Makefile rules and
+ * files for rom-o-matic.
+ *
+ */
+#define ISA_ROM( IMAGE, DESCRIPTION )
-extern const struct isa_driver isa_drivers[];
-extern const struct isa_driver isa_drivers_end[];
+/*
+ * Functions in isa.c
+ *
+ */
+extern int find_isa_device ( struct isa_device *eisa,
+ struct isa_driver *driver );
+extern int find_isa_boot_device ( struct dev *dev,
+ struct isa_driver *driver );
-#define ISA_ROM(IMAGE, DESCRIPTION)
+/*
+ * config.c defines isa_extra_probe_addrs and isa_extra_probe_addr_count.
+ *
+ */
+extern struct isa_probe_addr isa_extra_probe_addrs[];
+extern unsigned int isa_extra_probe_addr_count;
#endif /* ISA_H */