Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4438 → Rev 4667

/branches/dd/uspace/srv/pci/pci.c
6,6 → 6,8
#include "pci_regs.h"
#include "pci_conf.h"
 
#define NAME "PCI"
 
LIST_INITIALIZE(devices_list);
LIST_INITIALIZE(buses_list);
LIST_INITIALIZE(drivers_list);
45,13 → 47,13
}
header_type = header_type & 0x7F; // clear the multifunction bit
printf("PCI: adding new device %d : %d : %d", dev->bus->num, dnum, fnum);
printf(NAME ": adding new device %3d : %2d : %2d", 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("PCI: device is pci-to-pci bridge, secondary bus number = %d.\n", bus_num);
printf(NAME ": 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);
75,8 → 77,10
static int pci_pass_dev(pci_drv_t *drv, pci_dev_t *dev)
{
assert(dev->driver == NULL);
assert(drv->name != NULL);
if (drv->ops->add_device(dev)) {
printf(NAME ": passing device to driver '%s'.\n", drv->name);
if (drv->ops->add_device != NULL && drv->ops->add_device(dev)) {
dev->driver = drv;
return 1;
}
95,7 → 99,7
while (item != &drivers_list) {
drv = list_get_instance(item, pci_drv_t, link);
if (pci_match(drv, dev) && pci_pass_dev(drv, dev)) {
break;
return;
}
item = item->next;
}
109,6 → 113,8
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)) {
120,7 → 126,7
 
static int pci_match(pci_drv_t *drv, pci_dev_t *dev)
{
return drv->vendor_id == dev->vendor_id && drv->device_id == dev->vendor_id;
return drv->vendor_id == dev->vendor_id && drv->device_id == dev->device_id;
}
 
void pci_bus_register(pci_bus_t *bus)
147,8 → 153,11
}
 
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