dde_kit: enable pci lookup by device_class

Instead of trying all PCI devices by a specific PCI driver, now the device or
the device class can be limited to the one actually supported by the specific
driver.
This commit is contained in:
Alexander Boettcher
2013-02-20 11:44:12 +01:00
committed by Norman Feske
parent ce075c05b9
commit be0fa1f63a
7 changed files with 48 additions and 23 deletions

View File

@ -31,9 +31,10 @@ extern "C" {
static const bool verbose = false;
static Dde_kit::Pci_tree *pci_tree()
static Dde_kit::Pci_tree *pci_tree(unsigned device_class = 0,
unsigned class_mask = 0)
{
static Dde_kit::Pci_tree _pci_tree;
static Dde_kit::Pci_tree _pci_tree(device_class, class_mask);
return &_pci_tree;
}
@ -141,10 +142,10 @@ extern "C" int dde_kit_pci_next_device(int *bus, int *dev, int *fun)
** Initialization **
********************/
extern "C" void dde_kit_pci_init(void)
extern "C" void dde_kit_pci_init(unsigned device_class, unsigned class_mask)
{
try {
pci_tree();
pci_tree(device_class, class_mask);
} catch (...) {
PERR("PCI initialization failed");
}

View File

@ -49,24 +49,25 @@ void Pci_device::config_write(unsigned char address, uint32_t val,
** PCI bus **
*************/
Pci_tree::Pci_tree()
Pci_tree::Pci_tree(unsigned device_class, unsigned class_mask)
{
/*
* Iterate through all accessible devices and populate virtual
* PCI bus tree.
*/
Pci::Device_capability prev_device_cap,
device_cap = _pci_drv.first_device();
Pci::Device_capability prev_device_cap;
Pci::Device_capability device_cap = _pci_drv.first_device(device_class,
class_mask);
while (device_cap.valid()) {
Pci_device *device = new (env()->heap())
Pci_device(device_cap);
Pci_device *device = new (env()->heap()) Pci_device(device_cap);
_devices.insert(device);
prev_device_cap = device_cap;
device_cap = _pci_drv.next_device(prev_device_cap);
device_cap = _pci_drv.next_device(prev_device_cap, device_class,
class_mask);
}
if (verbose)

View File

@ -198,7 +198,7 @@ namespace Dde_kit {
public:
Pci_tree();
Pci_tree(unsigned device_class, unsigned class_mask);
uint32_t config_read(int bus, int dev, int fun, unsigned char address,
Pci::Device::Access_size size)