iPXE
|
ISAPnP bus support. More...
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/io.h>
#include <unistd.h>
#include <ipxe/isapnp.h>
Go to the source code of this file.
Macros | |
#define | ISAPNP_CARD_ID_FMT "ID %04x:%04x (\"%s\") serial %x" |
#define | ISAPNP_CARD_ID_DATA(identifier) |
#define | ISAPNP_DEV_ID_FMT "ID %04x:%04x (\"%s\")" |
#define | ISAPNP_DEV_ID_DATA(isapnp) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
static void | isapnpbus_remove (struct root_device *rootdev) |
Remove ISAPnP root bus. More... | |
static void | isapnp_write_address (unsigned int address) |
static void | isapnp_write_data (unsigned int data) |
static unsigned int | isapnp_read_data (void) |
static void | isapnp_write_byte (unsigned int address, unsigned int value) |
static unsigned int | isapnp_read_byte (unsigned int address) |
static unsigned int | isapnp_read_word (unsigned int address) |
static void | isapnp_set_read_port (void) |
Inform cards of a new read port address. More... | |
static void | isapnp_serialisolation (void) |
Enter the Isolation state. More... | |
static void | isapnp_wait_for_key (void) |
Enter the Wait for Key state. More... | |
static void | isapnp_reset_csn (void) |
Reset (i.e. More... | |
static void | isapnp_wake (uint8_t csn) |
Place a specified card into the Config state. More... | |
static unsigned int | isapnp_read_resourcedata (void) |
static unsigned int | isapnp_read_status (void) |
static void | isapnp_write_csn (unsigned int csn) |
Assign a Card Select Number to a card, and enter the Config state. More... | |
static void | isapnp_logicaldevice (unsigned int logdev) |
static void | isapnp_activate (unsigned int logdev) |
static void | isapnp_deactivate (unsigned int logdev) |
static unsigned int | isapnp_read_iobase (unsigned int index) |
static unsigned int | isapnp_read_irqno (unsigned int index) |
static void | isapnp_delay (void) |
static unsigned int | isapnp_lfsr_next (unsigned int lfsr, unsigned int input_bit) |
Linear feedback shift register. More... | |
static void | isapnp_send_key (void) |
Send the ISAPnP initiation key. More... | |
static unsigned int | isapnp_checksum (struct isapnp_identifier *identifier) |
Compute ISAPnP identifier checksum. More... | |
static unsigned int | isapnp_peek_byte (void) |
static void | isapnp_peek (void *buf, size_t len) |
Read resource data. More... | |
static int | isapnp_find_tag (unsigned int wanted_tag, void *buf, size_t len) |
Find a tag within the resource data. More... | |
static int | isapnp_find_logdevid (unsigned int logdev, struct isapnp_logdevid *logdevid) |
Find specified Logical Device ID tag. More... | |
static int | isapnp_try_isolate (void) |
Try isolating ISAPnP cards at the current read port. More... | |
static void | isapnp_isolate (void) |
Find a valid read port and isolate all ISAPnP cards. More... | |
void | isapnp_device_activation (struct isapnp_device *isapnp, int activation) |
Activate or deactivate an ISAPnP device. More... | |
static int | isapnp_probe (struct isapnp_device *isapnp) |
Probe an ISAPnP device. More... | |
static void | isapnp_remove (struct isapnp_device *isapnp) |
Remove an ISAPnP device. More... | |
static int | isapnpbus_probe (struct root_device *rootdev) |
Probe ISAPnP root bus. More... | |
Variables | |
uint16_t | isapnp_read_port |
ISAPnP Read Port address. More... | |
static struct root_driver | isapnp_root_driver |
ISAPnP bus root device driver. More... | |
struct root_device isapnp_root_device | __root_device |
ISAPnP bus root device. More... | |
ISAPnP bus support.
Etherboot orignally gained ISAPnP support in a very limited way for the 3c515 NIC. The current implementation is almost a complete rewrite based on the ISAPnP specification, with passing reference to the Linux ISAPnP code.
There can be only one ISAPnP bus in a system. Once the read port is known and all cards have been allocated CSNs, there's nothing to be gained by re-scanning for cards.
External code (e.g. the ISAPnP ROM prefix) may already know the read port address, in which case it can store it in isapnp_read_port. Note that setting the read port address in this way will prevent further isolation from taking place; you should set the read port address only if you know that devices have already been allocated CSNs.
Definition in file isapnp.c.
#define ISAPNP_CARD_ID_FMT "ID %04x:%04x (\"%s\") serial %x" |
#define ISAPNP_CARD_ID_DATA | ( | identifier | ) |
#define ISAPNP_DEV_ID_DATA | ( | isapnp | ) |
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
|
static |
Remove ISAPnP root bus.
rootdev | ISAPnP bus root device |
Definition at line 734 of file isapnp.c.
References device::children, root_device::dev, isapnp_device::dev, free, isapnp_remove(), list_del, list_for_each_entry_safe, device::siblings, and tmp.
Referenced by isapnpbus_probe().
|
inlinestatic |
Definition at line 95 of file isapnp.c.
References address, ISAPNP_ADDRESS, and outb.
Referenced by isapnp_read_byte(), isapnp_send_key(), isapnp_serialisolation(), and isapnp_write_byte().
|
inlinestatic |
Definition at line 99 of file isapnp.c.
References data, ISAPNP_WRITE_DATA, and outb.
Referenced by isapnp_write_byte().
|
inlinestatic |
Definition at line 103 of file isapnp.c.
References inb(), and isapnp_read_port.
Referenced by isapnp_read_byte(), and isapnp_try_isolate().
|
inlinestatic |
Definition at line 107 of file isapnp.c.
References address, isapnp_write_address(), isapnp_write_data(), and value.
Referenced by isapnp_activate(), isapnp_deactivate(), isapnp_logicaldevice(), isapnp_reset_csn(), isapnp_set_read_port(), isapnp_wait_for_key(), isapnp_wake(), and isapnp_write_csn().
|
inlinestatic |
Definition at line 113 of file isapnp.c.
References address, isapnp_read_data(), and isapnp_write_address().
Referenced by isapnp_read_irqno(), isapnp_read_resourcedata(), isapnp_read_status(), and isapnp_read_word().
|
inlinestatic |
Definition at line 118 of file isapnp.c.
References address, and isapnp_read_byte().
Referenced by isapnp_read_iobase().
|
inlinestatic |
Inform cards of a new read port address.
Definition at line 125 of file isapnp.c.
References isapnp_read_port, ISAPNP_READPORT, and isapnp_write_byte().
Referenced by isapnp_try_isolate().
|
inlinestatic |
Enter the Isolation state.
Only cards currently in the Sleep state will respond to this command.
Definition at line 135 of file isapnp.c.
References ISAPNP_SERIALISOLATION, and isapnp_write_address().
Referenced by isapnp_try_isolate().
|
inlinestatic |
Enter the Wait for Key state.
All cards will respond to this command, regardless of their current state.
Definition at line 145 of file isapnp.c.
References ISAPNP_CONFIG_WAIT_FOR_KEY, ISAPNP_CONFIGCONTROL, and isapnp_write_byte().
Referenced by isapnp_device_activation(), isapnp_try_isolate(), and isapnpbus_probe().
|
inlinestatic |
Reset (i.e.
remove) Card Select Number.
Only cards currently in the Sleep state will respond to this command.
Definition at line 155 of file isapnp.c.
References ISAPNP_CONFIG_RESET_CSN, ISAPNP_CONFIGCONTROL, and isapnp_write_byte().
Referenced by isapnp_try_isolate().
|
inlinestatic |
Place a specified card into the Config state.
csn | Card Select Number |
None | - |
None | - |
Only cards currently in the Sleep, Isolation, or Config states will respond to this command. The card that has the specified CSN will enter the Config state, all other cards will enter the Sleep state.
Definition at line 170 of file isapnp.c.
References ISAPNP_WAKE, and isapnp_write_byte().
Referenced by isapnp_device_activation(), isapnp_try_isolate(), and isapnpbus_probe().
|
inlinestatic |
Definition at line 174 of file isapnp.c.
References isapnp_read_byte(), and ISAPNP_RESOURCEDATA.
Referenced by isapnp_peek_byte().
|
inlinestatic |
Definition at line 178 of file isapnp.c.
References isapnp_read_byte(), and ISAPNP_STATUS.
Referenced by isapnp_peek_byte().
|
inlinestatic |
Assign a Card Select Number to a card, and enter the Config state.
csn | Card Select Number |
Only cards in the Isolation state will respond to this command. The isolation protocol is designed so that only one card will remain in the Isolation state by the time the isolation protocol completes.
Definition at line 192 of file isapnp.c.
References ISAPNP_CARDSELECTNUMBER, and isapnp_write_byte().
Referenced by isapnp_try_isolate().
|
inlinestatic |
Definition at line 196 of file isapnp.c.
References ISAPNP_LOGICALDEVICENUMBER, and isapnp_write_byte().
Referenced by isapnp_activate(), isapnp_deactivate(), isapnp_device_activation(), and isapnpbus_probe().
|
inlinestatic |
Definition at line 200 of file isapnp.c.
References ISAPNP_ACTIVATE, isapnp_logicaldevice(), and isapnp_write_byte().
Referenced by isapnp_device_activation().
|
inlinestatic |
Definition at line 205 of file isapnp.c.
References ISAPNP_ACTIVATE, isapnp_logicaldevice(), and isapnp_write_byte().
|
inlinestatic |
Definition at line 210 of file isapnp.c.
References index, ISAPNP_IOBASE, and isapnp_read_word().
Referenced by isapnpbus_probe().
|
inlinestatic |
Definition at line 214 of file isapnp.c.
References index, ISAPNP_IRQNO, and isapnp_read_byte().
Referenced by isapnpbus_probe().
|
static |
Definition at line 218 of file isapnp.c.
References udelay().
Referenced by isapnp_device_activation(), isapnp_peek_byte(), isapnp_send_key(), and isapnp_try_isolate().
|
inlinestatic |
Linear feedback shift register.
lfsr | Current value of the LFSR |
input_bit | Current input bit to the LFSR |
lfsr | Next value of the LFSR |
This routine implements the linear feedback shift register as described in Appendix B of the PnP ISA spec. The hardware implementation uses eight D-type latches and two XOR gates. I think this is probably the smallest possible implementation in software. Six instructions when input_bit is a constant 0 (for isapnp_send_key). :)
Definition at line 236 of file isapnp.c.
Referenced by isapnp_checksum(), and isapnp_send_key().
|
static |
Send the ISAPnP initiation key.
Sending the key causes all ISAPnP cards that are currently in the Wait for Key state to transition into the Sleep state.
Definition at line 251 of file isapnp.c.
References isapnp_delay(), isapnp_lfsr_next(), ISAPNP_LFSR_SEED, and isapnp_write_address().
Referenced by isapnp_device_activation(), isapnp_try_isolate(), and isapnpbus_probe().
|
static |
Compute ISAPnP identifier checksum.
identifier | ISAPnP identifier |
checksum | Expected checksum value |
Definition at line 272 of file isapnp.c.
References isapnp_lfsr_next(), and ISAPNP_LFSR_SEED.
Referenced by isapnp_try_isolate().
|
inlinestatic |
Definition at line 293 of file isapnp.c.
References isapnp_delay(), isapnp_read_resourcedata(), and isapnp_read_status().
Referenced by isapnp_find_tag(), and isapnp_peek().
|
static |
Read resource data.
buf | Buffer in which to store data, or NULL |
bytes | Number of bytes to read |
Resource data is read from the current location. If #buf is NULL, the data is discarded.
Definition at line 317 of file isapnp.c.
References isapnp_peek_byte(), and len.
Referenced by isapnp_find_tag(), and isapnpbus_probe().
|
static |
Find a tag within the resource data.
wanted_tag | The tag that we're looking for |
buf | Buffer in which to store the tag's contents |
len | Length of buffer |
rc | Return status code |
Scan through the resource data until we find a particular tag, and read its contents into a buffer.
Definition at line 339 of file isapnp.c.
References DBG2, ENOENT, ISAPNP_IS_SMALL_TAG, ISAPNP_LARGE_TAG_NAME, isapnp_peek(), isapnp_peek_byte(), ISAPNP_SMALL_TAG_LEN, ISAPNP_SMALL_TAG_NAME, ISAPNP_TAG_END, len, NULL, and tag.
Referenced by isapnp_find_logdevid().
|
static |
Find specified Logical Device ID tag.
logdev | Logical device ID |
logdevid | Logical device ID structure to fill in |
rc | Return status code |
Definition at line 376 of file isapnp.c.
References isapnp_find_tag(), ISAPNP_TAG_LOGDEVID, and rc.
Referenced by isapnpbus_probe().
|
static |
Try isolating ISAPnP cards at the current read port.
Definition at line 400 of file isapnp.c.
References isapnp_identifier::checksum, data, DBG, ISAPNP_CARD_ID_DATA, ISAPNP_CARD_ID_FMT, isapnp_checksum(), isapnp_delay(), isapnp_read_data(), isapnp_read_port, isapnp_reset_csn(), isapnp_send_key(), isapnp_serialisolation(), isapnp_set_read_port(), isapnp_wait_for_key(), isapnp_wake(), isapnp_write_csn(), and memset().
Referenced by isapnp_isolate().
|
static |
Find a valid read port and isolate all ISAPnP cards.
Definition at line 524 of file isapnp.c.
References isapnp_read_port, ISAPNP_READ_PORT_MAX, ISAPNP_READ_PORT_START, ISAPNP_READ_PORT_STEP, and isapnp_try_isolate().
Referenced by isapnpbus_probe().
void isapnp_device_activation | ( | struct isapnp_device * | isapnp, |
int | activation | ||
) |
Activate or deactivate an ISAPnP device.
isapnp | ISAPnP device |
activation | True to enable, False to disable the device |
None | - |
None | - |
This routine simply activates the device in its current configuration, or deactivates the device. It does not attempt any kind of resource arbitration.
Definition at line 554 of file isapnp.c.
References isapnp_device::csn, DBG, isapnp_activate(), isapnp_delay(), isapnp_logicaldevice(), isapnp_send_key(), isapnp_wait_for_key(), isapnp_wake(), and isapnp_device::logdev.
Referenced by activate_isapnp_device(), and deactivate_isapnp_device().
|
static |
Probe an ISAPnP device.
isapnp | ISAPnP device |
rc | Return status code |
Searches for a driver for the ISAPnP device. If a driver is found, its probe() routine is called.
Definition at line 583 of file isapnp.c.
References isapnp_device::csn, DBG, isapnp_device::dev, isapnp_device::driver, device::driver_name, ENOTTY, for_each_table_entry, id, isapnp_driver::id_count, isapnp_driver::ids, isapnp_device::ioaddr, isapnp_device::irqno, isa_id_string(), ISA_PROD_ID, ISAPNP_DRIVERS, isapnp_device::logdev, isapnp_driver::probe, isapnp_device::prod_id, rc, and isapnp_device::vendor_id.
Referenced by isapnpbus_probe().
|
static |
Remove an ISAPnP device.
isapnp | ISAPnP device |
Definition at line 623 of file isapnp.c.
References isapnp_device::csn, DBG, isapnp_device::driver, isapnp_device::logdev, and isapnp_driver::remove.
Referenced by isapnpbus_remove().
|
static |
Probe ISAPnP root bus.
rootdev | ISAPnP bus root device |
Scans the ISAPnP bus for devices and registers all devices it can find.
Definition at line 637 of file isapnp.c.
References device_description::bus_type, BUS_TYPE_ISAPNP, device::children, isapnp_device::csn, device::desc, root_device::dev, isapnp_device::dev, device_description::device, done, ENOMEM, free, INIT_LIST_HEAD, device_description::ioaddr, isapnp_device::ioaddr, device_description::irq, isapnp_device::irqno, isapnp_find_logdevid(), isapnp_isolate(), isapnp_logicaldevice(), isapnp_peek(), isapnp_probe(), isapnp_read_iobase(), isapnp_read_irqno(), isapnp_read_port, isapnp_send_key(), isapnp_wait_for_key(), isapnp_wake(), isapnpbus_remove(), list_add, list_del, isapnp_device::logdev, malloc(), memset(), device::name, NULL, device::parent, isapnp_logdevid::prod_id, isapnp_device::prod_id, rc, device::siblings, snprintf(), device_description::vendor, isapnp_identifier::vendor_id, isapnp_logdevid::vendor_id, and isapnp_device::vendor_id.
uint16_t isapnp_read_port |
ISAPnP Read Port address.
ROM prefix may be able to set this address, which is why this is non-static.
Definition at line 76 of file isapnp.c.
Referenced by isapnp_isolate(), isapnp_read_data(), isapnp_set_read_port(), isapnp_try_isolate(), and isapnpbus_probe().
|
static |
ISAPnP bus root device driver.
struct root_device isapnp_root_device __root_device |
ISAPnP bus root device.