summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2005-04-26 14:30:14 +0200
committerMichael Brown2005-04-26 14:30:14 +0200
commit3dbdeb588f27eea038b5b5ac9819e67698d636e0 (patch)
treeb7c62bb438157e9fd7499cdff0cc4784a8d0e742
parentPCI_DRIVER changed (diff)
downloadipxe-3dbdeb588f27eea038b5b5ac9819e67698d636e0.tar.gz
ipxe-3dbdeb588f27eea038b5b5ac9819e67698d636e0.tar.xz
ipxe-3dbdeb588f27eea038b5b5ac9819e67698d636e0.zip
ISA bus driver updated to report devices as present only if a driver
thinks they are. Other bus drivers modified for consistency.
-rw-r--r--src/arch/i386/drivers/disk/floppy.c3
-rw-r--r--src/arch/i386/include/bios_disks.h11
-rw-r--r--src/arch/i386/scripts/i386.lds3
-rw-r--r--src/drivers/bus/isa.c90
-rw-r--r--src/include/dev.h2
-rw-r--r--src/include/eisa.h9
-rw-r--r--src/include/isa.h9
-rw-r--r--src/include/isapnp.h9
-rw-r--r--src/include/mca.h9
-rw-r--r--src/include/pci.h3
10 files changed, 86 insertions, 62 deletions
diff --git a/src/arch/i386/drivers/disk/floppy.c b/src/arch/i386/drivers/disk/floppy.c
index 86527339..0582ca18 100644
--- a/src/arch/i386/drivers/disk/floppy.c
+++ b/src/arch/i386/drivers/disk/floppy.c
@@ -21,8 +21,7 @@ static void floppy_disable ( struct disk *disk,
}
-static struct bios_disk_driver floppy_driver =
- BIOS_DISK_DRIVER ( fill_floppy_name, 0x00, 0x7f );
+BIOS_DISK_DRIVER ( floppy_driver, fill_floppy_name, 0x00, 0x7f );
DRIVER ( "floppy", disk_driver, bios_disk_driver, floppy_driver,
floppy_probe, floppy_disable );
diff --git a/src/arch/i386/include/bios_disks.h b/src/arch/i386/include/bios_disks.h
index 1a2c31aa..0dd7c4eb 100644
--- a/src/arch/i386/include/bios_disks.h
+++ b/src/arch/i386/include/bios_disks.h
@@ -47,11 +47,12 @@ struct bios_disk_driver {
* Define a BIOS disk driver
*
*/
-#define BIOS_DISK_DRIVER( _fill_drive_name, _min_drive, _max_drive ) { \
- .fill_drive_name = _fill_drive_name, \
- .min_drive = _min_drive, \
- .max_drive = _max_drive, \
-}
+#define BIOS_DISK_DRIVER( _name, _fill_drive_name, _min_drive, _max_drive ) \
+ static struct bios_disk_driver _name = { \
+ .fill_drive_name = _fill_drive_name, \
+ .min_drive = _min_drive, \
+ .max_drive = _max_drive, \
+ }
/*
* Functions in bios_disks.c
diff --git a/src/arch/i386/scripts/i386.lds b/src/arch/i386/scripts/i386.lds
index 0ed9955d..51cfbd33 100644
--- a/src/arch/i386/scripts/i386.lds
+++ b/src/arch/i386/scripts/i386.lds
@@ -145,6 +145,9 @@ SECTIONS {
device_drivers = .;
*(.drivers.device)
device_drivers_end = .;
+ isa_drivers = . ;
+ *(.drivers.isa)
+ isa_drivers_end = .;
bus_drivers = .;
*(.drivers.bus)
bus_drivers_end = .;
diff --git a/src/drivers/bus/isa.c b/src/drivers/bus/isa.c
index 526c6022..3766a739 100644
--- a/src/drivers/bus/isa.c
+++ b/src/drivers/bus/isa.c
@@ -17,8 +17,8 @@
*
* The ISA probe address list can be overridden by config.h; if the
* user specifies ISA_PROBE_ADDRS then that list will be used first.
- * (If ISA_PROBE_ADDRS ends with a zero, the driver's own list will
- * never be used).
+ * (If ISA_PROBE_ONLY is defined, the driver's own list will never be
+ * used).
*/
/*
@@ -34,20 +34,33 @@ static isa_probe_addr_t isa_extra_probe_addrs[] = {
( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
#ifdef ISA_PROBE_ONLY
-# define ISA_PROBE_IDX_LIMIT isa_extra_probe_addr_count
+#define ISA_PROBE_ADDR_COUNT(driver) ( isa_extra_probe_addr_count )
#else
-# define ISA_PROBE_IDX_LIMIT ( ISA_MAX_PROBE_IDX + 1 )
+#define ISA_PROBE_ADDR_COUNT(driver) \
+ ( isa_extra_probe_addr_count + (driver)->addr_count )
#endif
/*
+ * Symbols defined by linker
+ *
+ */
+extern struct isa_driver isa_drivers[];
+extern struct isa_driver isa_drivers_end[];
+
+/*
* Increment a bus_loc structure to the next possible ISA location.
* Leave the structure zeroed and return 0 if there are no more valid
* locations.
*
+ * There is no sensible concept of a device location on an ISA bus, so
+ * we use the probe address list for each ISA driver to define the
+ * list of ISA locations.
+ *
*/
static int isa_next_location ( struct bus_loc *bus_loc ) {
struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
-
+ struct isa_driver *driver;
+
/*
* Ensure that there is sufficient space in the shared bus
* structures for a struct isa_loc and a struct
@@ -57,8 +70,18 @@ static int isa_next_location ( struct bus_loc *bus_loc ) {
BUS_LOC_CHECK ( struct isa_loc );
BUS_DEV_CHECK ( struct isa_device );
- return ( ( ++isa_loc->probe_idx < ISA_PROBE_IDX_LIMIT ) ?
- 1 : ( isa_loc->probe_idx = 0 ) );
+ /* Move to next probe address within this driver */
+ driver = &isa_drivers[isa_loc->driver];
+ if ( ++isa_loc->probe_idx < ISA_PROBE_ADDR_COUNT ( driver ) )
+ return 1;
+
+ /* Move to next driver */
+ isa_loc->probe_idx = 0;
+ if ( ( ++isa_loc->driver, ++driver ) < isa_drivers_end )
+ return 1;
+
+ isa_loc->driver = 0;
+ return 0;
}
/*
@@ -73,17 +96,29 @@ static int isa_fill_device ( struct bus_dev *bus_dev,
struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
struct isa_device *isa = ( struct isa_device * ) bus_dev;
signed int driver_probe_idx;
-
+
+ /* Fill in struct isa from struct isa_loc */
+ isa->driver = &isa_drivers[isa_loc->driver];
driver_probe_idx = isa_loc->probe_idx - isa_extra_probe_addr_count;
if ( driver_probe_idx < 0 ) {
isa->ioaddr = isa_extra_probe_addrs[isa_loc->probe_idx];
} else {
- isa->ioaddr = 0;
- isa->driver_probe_idx = driver_probe_idx;
+ isa->ioaddr = isa->driver->probe_addrs[driver_probe_idx];
+ }
+
+ /* Call driver's probe_addr method to determine if a device is
+ * physically present
+ */
+ if ( isa->driver->probe_addr ( isa->ioaddr ) ) {
+ isa->name = isa->driver->name;
+ isa->mfg_id = isa->driver->mfg_id;
+ isa->prod_id = isa->driver->prod_id;
+ DBG ( "ISA found %s device at address %hx\n",
+ isa->name, isa->ioaddr );
+ return 1;
}
- isa->mfg_id = isa->prod_id = 0;
- isa->name = "?";
- return 1;
+
+ return 0;
}
/*
@@ -97,29 +132,7 @@ int isa_check_driver ( struct bus_dev *bus_dev,
struct isa_driver *driver
= ( struct isa_driver * ) device_driver->bus_driver_info;
- /* If ioaddr is zero, it means we're using a driver-specified
- * ioaddr
- */
- if ( ! isa->ioaddr ) {
- if ( isa->driver_probe_idx >= driver->addr_count )
- return 0;
- isa->ioaddr = driver->probe_addrs[isa->driver_probe_idx];
- }
-
- /* Use probe_addr method to see if there's a device
- * present at this address.
- */
- if ( driver->probe_addr ( isa->ioaddr ) ) {
- DBG ( "ISA found %s device at address %hx\n",
- driver->name, isa->ioaddr );
- isa->name = driver->name;
- isa->mfg_id = driver->mfg_id;
- isa->prod_id = driver->prod_id;
- return 1;
- }
-
- /* No device found */
- return 0;
+ return ( driver == isa->driver );
}
/*
@@ -128,9 +141,10 @@ int isa_check_driver ( struct bus_dev *bus_dev,
*/
static char * isa_describe_device ( struct bus_dev *bus_dev ) {
struct isa_device *isa = ( struct isa_device * ) bus_dev;
- static char isa_description[] = "ISA 0000";
+ static char isa_description[] = "ISA 0000 (00)";
- sprintf ( isa_description + 4, "%hx", isa->ioaddr );
+ sprintf ( isa_description + 4, "%hx (%hhx)", isa->ioaddr,
+ isa->driver - isa_drivers );
return isa_description;
}
diff --git a/src/include/dev.h b/src/include/dev.h
index 5f1d32e1..94833495 100644
--- a/src/include/dev.h
+++ b/src/include/dev.h
@@ -28,7 +28,7 @@ struct device_driver;
* A physical device location on a bus.
*
*/
-#define BUS_LOC_SIZE 4
+#define BUS_LOC_SIZE 8
struct bus_loc {
char bytes[BUS_LOC_SIZE];
};
diff --git a/src/include/eisa.h b/src/include/eisa.h
index ad716c28..403a133f 100644
--- a/src/include/eisa.h
+++ b/src/include/eisa.h
@@ -66,10 +66,11 @@ struct eisa_driver {
* Define an EISA driver
*
*/
-#define EISA_DRIVER( _ids ) { \
- .ids = _ids, \
- .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
-}
+#define EISA_DRIVER( _name, _ids ) \
+ static struct eisa_driver _name = { \
+ .ids = _ids, \
+ .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
+ }
/*
* Functions in eisa.c
diff --git a/src/include/isa.h b/src/include/isa.h
index 97f5f7e1..1a4c8705 100644
--- a/src/include/isa.h
+++ b/src/include/isa.h
@@ -9,10 +9,11 @@
* A location on an ISA bus
*
*/
+struct isa_driver;
struct isa_loc {
+ unsigned int driver;
unsigned int probe_idx;
};
-#define ISA_MAX_PROBE_IDX 255 /* Unlikely to ever be more than ~20 */
/*
* A physical ISA device
@@ -20,7 +21,7 @@ struct isa_loc {
*/
struct isa_device {
const char *name;
- unsigned int driver_probe_idx;
+ struct isa_driver *driver;
uint16_t ioaddr;
uint16_t mfg_id;
uint16_t prod_id;
@@ -47,12 +48,14 @@ struct isa_driver {
uint16_t mfg_id;
uint16_t prod_id;
};
+#define __isa_driver __attribute__ (( section ( ".drivers.isa" ) ))
/*
* Define an ISA driver
*
*/
-#define ISA_DRIVER( _probe_addrs, _probe_addr, _mfg_id, _prod_id ) { \
+#define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id ) \
+static struct isa_driver _name __isa_driver = { \
.probe_addrs = _probe_addrs, \
.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
.probe_addr = _probe_addr, \
diff --git a/src/include/isapnp.h b/src/include/isapnp.h
index ec0b8fc9..476b26f8 100644
--- a/src/include/isapnp.h
+++ b/src/include/isapnp.h
@@ -200,10 +200,11 @@ struct isapnp_driver {
* Define an ISAPnP driver
*
*/
-#define ISAPNP_DRIVER( _ids ) { \
- .ids = _ids, \
- .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
-}
+#define ISAPNP_DRIVER( _name, _ids ) \
+ static struct isapnp_driver _name = { \
+ .ids = _ids, \
+ .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
+ }
/*
* Functions in isapnp.c
diff --git a/src/include/mca.h b/src/include/mca.h
index aff8073f..31285580 100644
--- a/src/include/mca.h
+++ b/src/include/mca.h
@@ -67,10 +67,11 @@ struct mca_driver {
* Define an MCA driver
*
*/
-#define MCA_DRIVER( _ids ) { \
- .ids = _ids, \
- .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
-}
+#define MCA_DRIVER( _name, _ids ) \
+ static struct mca_driver _name = { \
+ .ids = _ids, \
+ .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
+ }
/*
* Functions in mca.c
diff --git a/src/include/pci.h b/src/include/pci.h
index 677e09a6..c50b79a8 100644
--- a/src/include/pci.h
+++ b/src/include/pci.h
@@ -307,7 +307,8 @@ struct pci_driver {
* Define a PCI driver.
*
*/
-#define PCI_DRIVER( _ids, _class ) { \
+#define PCI_DRIVER( _name, _ids, _class ) \
+ static struct pci_driver _name = { \
.ids = _ids, \
.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
.class = _class, \