}
/*
- * 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 ) {
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;
}
return 0;
}
+/*
+ * 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
*
}
/*
- * 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 */
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;
}
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;
+}
}
}
-/*
- * 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.
*
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.
*/
/* 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;
}
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;
}
return 0;
}
+/*
+ * 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.
*/
* A physical EISA device
*
*/
-struct dev;
struct eisa_device {
char *magic; /* must be first */
- struct dev *dev;
+ const char *name;
unsigned int slot;
uint16_t ioaddr;
uint16_t mfg_id;
* Functions in eisa.c
*
*/
-extern struct eisa_device * eisa_device ( struct dev *dev );
extern int find_eisa_device ( struct eisa_device *eisa,
struct eisa_driver *driver );
+extern int find_eisa_boot_device ( struct dev *dev,
+ struct eisa_driver *driver );
extern void enable_eisa_device ( struct eisa_device *eisa );
#endif /* EISA_H */
* A physical MCA device
*
*/
-struct dev;
struct mca_device {
char *magic; /* must be first */
- struct dev *dev;
+ const char *name;
unsigned int slot;
unsigned char pos[8];
int already_tried;
* Functions in mca.c
*
*/
-extern struct mca_device * mca_device ( struct dev *dev );
extern int find_mca_device ( struct mca_device *mca,
struct mca_driver *driver );
+extern int find_mca_boot_device ( struct dev *dev, struct mca_driver *driver );
#endif
* A physical PCI device
*
*/
-struct dev;
struct pci_device {
char * magic; /* must be first */
- struct dev * dev;
+ const char * name;
uint32_t membase; /* BAR 1 */
uint32_t ioaddr; /* first IO BAR */
uint16_t vendor, dev_id;
* Functions in pci.c
*
*/
-extern struct pci_device * pci_device ( struct dev *dev );
extern int find_pci_device ( struct pci_device *pci,
struct pci_driver *driver );
+extern int find_pci_boot_device ( struct dev *dev, struct pci_driver *driver );
extern void adjust_pci_device ( struct pci_device *pci );
extern unsigned long pci_bar_start ( struct pci_device *pci,
unsigned int bar );