mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-18 21:43:14 +00:00
ISA bus driver updated to report devices as present only if a driver
thinks they are. Other bus drivers modified for consistency.
This commit is contained in:
parent
3a7967a38a
commit
3dbdeb588f
@ -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 );
|
||||
|
@ -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
|
||||
|
@ -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 = .;
|
||||
|
@ -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];
|
||||
}
|
||||
isa->mfg_id = isa->prod_id = 0;
|
||||
isa->name = "?";
|
||||
return 1;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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, \
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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, \
|
||||
|
Loading…
x
Reference in New Issue
Block a user