diff options
| author | Michael Brown | 2005-04-14 15:44:07 +0200 |
|---|---|---|
| committer | Michael Brown | 2005-04-14 15:44:07 +0200 |
| commit | 104880ca19e230ebbe6a4f46fa17e32ff05324f2 (patch) | |
| tree | d99a776582dfb278218299f88c3ee8fd8203e631 /src/drivers/bus | |
| parent | Separate out bus-scanning and device-probing logic. (diff) | |
| download | ipxe-104880ca19e230ebbe6a4f46fa17e32ff05324f2.tar.gz ipxe-104880ca19e230ebbe6a4f46fa17e32ff05324f2.tar.xz ipxe-104880ca19e230ebbe6a4f46fa17e32ff05324f2.zip | |
Tweak API to allow separation of bus-scanning and device-probing logic.
Diffstat (limited to 'src/drivers/bus')
| -rw-r--r-- | src/drivers/bus/eisa.c | 56 | ||||
| -rw-r--r-- | src/drivers/bus/mca.c | 49 | ||||
| -rw-r--r-- | src/drivers/bus/pci.c | 54 |
3 files changed, 78 insertions, 81 deletions
diff --git a/src/drivers/bus/eisa.c b/src/drivers/bus/eisa.c index 29d1d83d0..1cd53c9b8 100644 --- a/src/drivers/bus/eisa.c +++ b/src/drivers/bus/eisa.c @@ -48,37 +48,22 @@ static int fill_eisa_device ( struct eisa_device *eisa ) { } /* - * Obtain a struct eisa * from a struct dev * + * Find an EISA device matching the specified driver * - * If dev has not previously been used for an EISA device scan, blank - * out struct eisa */ -struct eisa_device * eisa_device ( struct dev *dev ) { - struct eisa_device *eisa = dev->bus;; +int find_eisa_device ( struct eisa_device *eisa, struct eisa_driver *driver ) { + unsigned int i; + /* Initialise struct eisa if it's the first time it's been used. */ if ( eisa->magic != eisa_magic ) { memset ( eisa, 0, sizeof ( *eisa ) ); eisa->magic = eisa_magic; + eisa->slot = EISA_MIN_SLOT; } - eisa->dev = dev; - return eisa; -} - -/* - * Find an EISA device matching the specified driver - * - */ -int find_eisa_device ( struct eisa_device *eisa, struct eisa_driver *driver ) { - unsigned int i; /* Iterate through all possible EISA slots, starting where we - * left off. If eisa->slot is zero (which it will be if we - * have a zeroed structure), start from slot EISA_MIN_SLOT, - * since slot 0 doesn't exist. + * left off. */ - if ( ! eisa->slot ) { - eisa->slot = EISA_MIN_SLOT; - } for ( ; eisa->slot <= EISA_MAX_SLOT ; eisa->slot++ ) { /* If we've already used this device, skip it */ if ( eisa->already_tried ) { @@ -102,15 +87,7 @@ int find_eisa_device ( struct eisa_device *eisa, struct eisa_driver *driver ) { id->name, driver->name, isa_id_string ( eisa->mfg_id, eisa->prod_id ) ); - if ( eisa->dev ) { - eisa->dev->name = driver->name; - eisa->dev->devid.bus_type - = ISA_BUS_TYPE; - eisa->dev->devid.vendor_id - = eisa->mfg_id; - eisa->dev->devid.device_id - = eisa->prod_id; - } + eisa->name = id->name; eisa->already_tried = 1; return 1; } @@ -123,6 +100,25 @@ int find_eisa_device ( struct eisa_device *eisa, struct eisa_driver *driver ) { } /* + * Find the next EISA device that can be used to boot using the + * specified driver. + * + */ +int find_eisa_boot_device ( struct dev *dev, struct eisa_driver *driver ) { + struct eisa_device *eisa = ( struct eisa_device * )dev->bus; + + if ( ! find_eisa_device ( eisa, driver ) ) + return 0; + + dev->name = eisa->name; + dev->devid.bus_type = ISA_BUS_TYPE; + dev->devid.vendor_id = eisa->mfg_id; + dev->devid.device_id = eisa->prod_id; + + return 1; +} + +/* * Reset and enable an EISA device * */ diff --git a/src/drivers/bus/mca.c b/src/drivers/bus/mca.c index 1d20a6651..f87da8d2e 100644 --- a/src/drivers/bus/mca.c +++ b/src/drivers/bus/mca.c @@ -49,31 +49,20 @@ static int fill_mca_device ( struct mca_device *mca ) { } /* - * Obtain a struct mca * from a struct dev * + * Find an MCA device matching the specified driver * - * If dev has not previously been used for an MCA device scan, blank - * out struct mca */ -struct mca_device * mca_device ( struct dev *dev ) { - struct mca_device *mca = dev->bus; +int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { + unsigned int i; + /* Initialise struct mca if it's the first time it's been used. */ if ( mca->magic != mca_magic ) { memset ( mca, 0, sizeof ( *mca ) ); mca->magic = mca_magic; } - mca->dev = dev; - return mca; -} - -/* - * Find an MCA device matching the specified driver - * - */ -int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { - unsigned int i; /* Iterate through all possible MCA slots, starting where we - * left off/ + * left off */ for ( ; mca->slot < MCA_MAX_SLOT_NR ; mca->slot++ ) { /* If we've already used this device, skip it */ @@ -94,14 +83,7 @@ int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { if ( MCA_ID ( mca ) == id->id ) { DBG ( "Device %s (driver %s) matches ID %hx\n", id->name, driver->name, id->id ); - if ( mca->dev ) { - mca->dev->name = driver->name; - mca->dev->devid.bus_type - = MCA_BUS_TYPE; - mca->dev->devid.vendor_id - = GENERIC_MCA_VENDOR; - mca->dev->devid.device_id = id->id; - } + mca->name = id->name; mca->already_tried = 1; return 1; } @@ -112,3 +94,22 @@ int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) { mca->slot = 0; return 0; } + +/* + * Find the next MCA device that can be used to boot using the + * specified driver. + * + */ +int find_mca_boot_device ( struct dev *dev, struct mca_driver *driver ) { + struct mca_device *mca = ( struct mca_device * )dev->bus; + + if ( ! find_mca_device ( mca, driver ) ) + return 0; + + dev->name = mca->name; + dev->devid.bus_type = MCA_BUS_TYPE; + dev->devid.vendor_id = GENERIC_MCA_VENDOR; + dev->devid.device_id = MCA_ID ( mca ); + + return 1; +} diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c index 034ef114e..e98319138 100644 --- a/src/drivers/bus/pci.c +++ b/src/drivers/bus/pci.c @@ -110,23 +110,6 @@ void adjust_pci_device ( struct pci_device *pci ) { } /* - * Obtain a struct pci * from a struct dev * - * - * If dev has not previously been used for a PCI device scan, blank - * out struct pci - */ -struct pci_device * pci_device ( struct dev *dev ) { - struct pci_device *pci = dev->bus; - - if ( pci->magic != pci_magic ) { - memset ( pci, 0, sizeof ( *pci ) ); - pci->magic = pci_magic; - } - pci->dev = dev; - return pci; -} - -/* * Set PCI device to use. * * This routine can be called by e.g. the ROM prefix to specify that @@ -148,6 +131,12 @@ int find_pci_device ( struct pci_device *pci, struct pci_driver *driver ) { int i; + /* Initialise struct pci if it's the first time it's been used. */ + if ( pci->magic != pci_magic ) { + memset ( pci, 0, sizeof ( *pci ) ); + pci->magic = pci_magic; + } + /* Iterate through all possible PCI bus:dev.fn combinations, * starting where we left off. */ @@ -166,19 +155,12 @@ int find_pci_device ( struct pci_device *pci, /* Fix up PCI device */ adjust_pci_device ( pci ); - /* Fill in dev structure, if present */ - if ( pci->dev ) { - pci->dev->name = driver->name; - pci->dev->devid.bus_type = PCI_BUS_TYPE; - pci->dev->devid.vendor_id = pci->vendor; - pci->dev->devid.device_id = pci->dev_id; - } - /* If driver has a class, and class matches, use it */ if ( driver->class && ( driver->class == pci->class ) ) { DBG ( "Driver %s matches class %hx\n", driver->name, driver->class ); + pci->name = driver->name; pci->already_tried = 1; return 1; } @@ -192,8 +174,7 @@ int find_pci_device ( struct pci_device *pci, DBG ( "Device %s (driver %s) matches " "ID %hx:%hx\n", id->name, driver->name, id->vendor, id->dev_id ); - if ( pci->dev ) - pci->dev->name = id->name; + pci->name = id->name; pci->already_tried = 1; return 1; } @@ -207,6 +188,25 @@ int find_pci_device ( struct pci_device *pci, } /* + * Find the next PCI device that can be used to boot using the + * specified driver. + * + */ +int find_pci_boot_device ( struct dev *dev, struct pci_driver *driver ) { + struct pci_device *pci = ( struct pci_device * )dev->bus; + + if ( ! find_pci_device ( pci, driver ) ) + return 0; + + dev->name = pci->name; + dev->devid.bus_type = PCI_BUS_TYPE; + dev->devid.vendor_id = pci->vendor; + dev->devid.device_id = pci->dev_id; + + return 1; +} + +/* * Find the start of a pci resource. */ unsigned long pci_bar_start ( struct pci_device *pci, unsigned int index ) { |
