6,8 → 6,6 |
#include "pci_regs.h" |
#include "pci_conf.h" |
|
#define NAME "PCI" |
|
LIST_INITIALIZE(devices_list); |
LIST_INITIALIZE(buses_list); |
LIST_INITIALIZE(drivers_list); |
47,13 → 45,13 |
} |
header_type = header_type & 0x7F; // clear the multifunction bit |
|
printf(NAME ": adding new device %3d : %2d : %2d", dev->bus->num, dnum, fnum); |
printf("PCI: adding new device %d : %d : %d", dev->bus->num, dnum, fnum); |
printf(" - vendor = 0x%04X, device = 0x%04X.\n", dev->vendor_id, dev->device_id); |
pci_device_register(dev); |
|
if (header_type == PCI_HEADER_TYPE_BRIDGE || header_type == PCI_HEADER_TYPE_CARDBUS ) { |
bus_num = pci_conf_read_8(dev, PCI_BRIDGE_SEC_BUS_NUM); |
printf(NAME ": device is pci-to-pci bridge, secondary bus number = %d.\n", bus_num); |
printf("PCI: device is pci-to-pci bridge, secondary bus number = %d.\n", bus_num); |
if(bus_num > bus->num) { |
child_bus = pci_alloc_bus(); |
pci_init_bus(child_bus, bus, bus_num); |
77,10 → 75,8 |
static int pci_pass_dev(pci_drv_t *drv, pci_dev_t *dev) |
{ |
assert(dev->driver == NULL); |
assert(drv->name != NULL); |
|
printf(NAME ": passing device to driver '%s'.\n", drv->name); |
if (drv->ops->add_device != NULL && drv->ops->add_device(dev)) { |
if (drv->ops->add_device(dev)) { |
dev->driver = drv; |
return 1; |
} |
99,7 → 95,7 |
while (item != &drivers_list) { |
drv = list_get_instance(item, pci_drv_t, link); |
if (pci_match(drv, dev) && pci_pass_dev(drv, dev)) { |
return; |
break; |
} |
item = item->next; |
} |
113,8 → 109,6 |
link_t *item = devices_list.next; |
pci_dev_t *dev = NULL; |
|
printf(NAME ": looking up devices for a newly added driver '%s'.\n", drv->name); |
|
while (item != &devices_list) { |
dev = list_get_instance(item, pci_dev_t, link); |
if (dev->driver == NULL && pci_match(drv, dev)) { |
126,7 → 120,7 |
|
static int pci_match(pci_drv_t *drv, pci_dev_t *dev) |
{ |
return drv->vendor_id == dev->vendor_id && drv->device_id == dev->device_id; |
return drv->vendor_id == dev->vendor_id && drv->device_id == dev->vendor_id; |
} |
|
void pci_bus_register(pci_bus_t *bus) |
153,11 → 147,8 |
} |
|
void pci_driver_register(pci_drv_t *drv) |
{ |
assert(drv->name != NULL); |
|
{ |
futex_down(&pci_bus_futex); |
printf(NAME ": registering new driver '%s'.\n", drv->name); |
list_append(&(drv->link), &drivers_list); |
|
// try to find compatible devices |