2005-04-17 12:51:05 +02:00
|
|
|
#include "string.h"
|
2005-04-22 04:28:16 +02:00
|
|
|
#include "console.h"
|
2005-04-18 13:00:42 +02:00
|
|
|
#include "config/isa.h"
|
2006-06-05 17:41:22 +02:00
|
|
|
#include "dev.h"
|
2005-04-14 20:46:43 +02:00
|
|
|
#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.
|
|
|
|
*
|
2005-04-22 04:28:16 +02:00
|
|
|
* The ISA probe address list can be overridden by config.h; if the
|
2005-04-16 11:30:48 +02:00
|
|
|
* user specifies ISA_PROBE_ADDRS then that list will be used first.
|
2005-04-26 14:30:14 +02:00
|
|
|
* (If ISA_PROBE_ONLY is defined, the driver's own list will never be
|
|
|
|
* used).
|
2005-04-14 20:46:43 +02:00
|
|
|
*/
|
|
|
|
|
2005-04-18 13:00:42 +02:00
|
|
|
/*
|
|
|
|
* User-supplied probe address list
|
|
|
|
*
|
|
|
|
*/
|
2005-04-22 04:28:16 +02:00
|
|
|
static isa_probe_addr_t isa_extra_probe_addrs[] = {
|
2005-04-18 14:43:18 +02:00
|
|
|
#ifdef ISA_PROBE_ADDRS
|
2005-04-22 04:28:16 +02:00
|
|
|
ISA_PROBE_ADDRS
|
2005-04-18 13:00:42 +02:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#define isa_extra_probe_addr_count \
|
|
|
|
( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
|
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
#ifdef ISA_PROBE_ONLY
|
2005-04-26 14:30:14 +02:00
|
|
|
#define ISA_PROBE_ADDR_COUNT(driver) ( isa_extra_probe_addr_count )
|
2005-04-22 04:28:16 +02:00
|
|
|
#else
|
2005-04-26 14:30:14 +02:00
|
|
|
#define ISA_PROBE_ADDR_COUNT(driver) \
|
|
|
|
( isa_extra_probe_addr_count + (driver)->addr_count )
|
2005-04-22 04:28:16 +02:00
|
|
|
#endif
|
|
|
|
|
2005-04-26 14:30:14 +02:00
|
|
|
/*
|
|
|
|
* Symbols defined by linker
|
|
|
|
*
|
|
|
|
*/
|
2005-04-27 14:24:38 +02:00
|
|
|
static struct isa_driver isa_drivers[0] __table_start ( isa_driver );
|
|
|
|
static struct isa_driver isa_drivers_end[0] __table_end ( isa_driver );
|
2005-04-26 14:30:14 +02:00
|
|
|
|
2005-04-14 20:46:43 +02:00
|
|
|
/*
|
2005-04-22 04:28:16 +02:00
|
|
|
* 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.
|
2005-04-14 20:46:43 +02:00
|
|
|
*
|
2005-04-26 14:30:14 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2005-04-14 20:46:43 +02:00
|
|
|
*/
|
2005-04-22 04:28:16 +02:00
|
|
|
static int isa_next_location ( struct bus_loc *bus_loc ) {
|
|
|
|
struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
|
2005-04-26 14:30:14 +02:00
|
|
|
struct isa_driver *driver;
|
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
/*
|
|
|
|
* Ensure that there is sufficient space in the shared bus
|
|
|
|
* structures for a struct isa_loc and a struct
|
|
|
|
* isa_dev, as mandated by bus.h.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BUS_LOC_CHECK ( struct isa_loc );
|
|
|
|
BUS_DEV_CHECK ( struct isa_device );
|
|
|
|
|
2005-04-26 14:30:14 +02:00
|
|
|
/* 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;
|
2005-04-22 04:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in parameters (vendor & device ids, class, membase etc.) for
|
|
|
|
* an ISA device based on bus_loc.
|
|
|
|
*
|
|
|
|
* Returns 1 if a device was found, 0 for no device present.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int isa_fill_device ( struct bus_dev *bus_dev,
|
|
|
|
struct bus_loc *bus_loc ) {
|
|
|
|
struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
|
|
|
|
struct isa_device *isa = ( struct isa_device * ) bus_dev;
|
|
|
|
signed int driver_probe_idx;
|
2005-04-26 14:30:14 +02:00
|
|
|
|
|
|
|
/* Fill in struct isa from struct isa_loc */
|
|
|
|
isa->driver = &isa_drivers[isa_loc->driver];
|
2005-04-22 04:28:16 +02:00
|
|
|
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 {
|
2005-04-26 14:30:14 +02:00
|
|
|
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;
|
2005-04-14 20:46:43 +02:00
|
|
|
}
|
2005-04-26 14:30:14 +02:00
|
|
|
|
|
|
|
return 0;
|
2005-04-22 04:28:16 +02:00
|
|
|
}
|
2005-04-14 20:46:43 +02:00
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
/*
|
|
|
|
* Test whether or not a driver is capable of driving the specified
|
|
|
|
* device.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int isa_check_driver ( struct bus_dev *bus_dev,
|
|
|
|
struct device_driver *device_driver ) {
|
|
|
|
struct isa_device *isa = ( struct isa_device * ) bus_dev;
|
|
|
|
struct isa_driver *driver
|
|
|
|
= ( struct isa_driver * ) device_driver->bus_driver_info;
|
|
|
|
|
2005-04-26 14:30:14 +02:00
|
|
|
return ( driver == isa->driver );
|
2005-04-22 04:28:16 +02:00
|
|
|
}
|
2005-04-14 20:46:43 +02:00
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
/*
|
|
|
|
* Describe a ISA device
|
|
|
|
*
|
|
|
|
*/
|
2005-04-25 20:54:15 +02:00
|
|
|
static char * isa_describe_device ( struct bus_dev *bus_dev ) {
|
2005-04-22 04:28:16 +02:00
|
|
|
struct isa_device *isa = ( struct isa_device * ) bus_dev;
|
2005-04-26 14:30:14 +02:00
|
|
|
static char isa_description[] = "ISA 0000 (00)";
|
2005-04-22 04:28:16 +02:00
|
|
|
|
2005-04-26 14:30:14 +02:00
|
|
|
sprintf ( isa_description + 4, "%hx (%hhx)", isa->ioaddr,
|
|
|
|
isa->driver - isa_drivers );
|
2005-04-22 04:28:16 +02:00
|
|
|
return isa_description;
|
2005-04-14 20:46:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-04-22 04:28:16 +02:00
|
|
|
* Name a ISA device
|
2005-04-14 20:46:43 +02:00
|
|
|
*
|
|
|
|
*/
|
2005-04-25 20:54:15 +02:00
|
|
|
static const char * isa_name_device ( struct bus_dev *bus_dev ) {
|
2005-04-22 04:28:16 +02:00
|
|
|
struct isa_device *isa = ( struct isa_device * ) bus_dev;
|
|
|
|
|
|
|
|
return isa->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ISA bus operations table
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct bus_driver isa_driver __bus_driver = {
|
2005-04-25 20:54:15 +02:00
|
|
|
.name = "ISA",
|
|
|
|
.next_location = isa_next_location,
|
|
|
|
.fill_device = isa_fill_device,
|
|
|
|
.check_driver = isa_check_driver,
|
|
|
|
.describe_device = isa_describe_device,
|
|
|
|
.name_device = isa_name_device,
|
2005-04-22 04:28:16 +02:00
|
|
|
};
|
2005-04-14 20:46:43 +02:00
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
/*
|
|
|
|
* Fill in a nic structure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void isa_fill_nic ( struct nic *nic, struct isa_device *isa ) {
|
2005-04-14 20:46:43 +02:00
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
/* Fill in ioaddr and irqno */
|
|
|
|
nic->ioaddr = isa->ioaddr;
|
|
|
|
nic->irqno = 0;
|
2005-04-14 20:46:43 +02:00
|
|
|
|
2005-04-22 04:28:16 +02:00
|
|
|
/* Fill in DHCP device ID structure */
|
|
|
|
nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
|
|
|
|
nic->dhcp_dev_id.vendor_id = htons ( isa->mfg_id );
|
|
|
|
nic->dhcp_dev_id.device_id = htons ( isa->prod_id );
|
2005-04-14 20:46:43 +02:00
|
|
|
}
|