Rev 4399 | Rev 4438 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4399 | Rev 4418 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | static int pci_pass_dev(pci_drv_t *drv, pci_dev_t *dev); |
16 | static int pci_pass_dev(pci_drv_t *drv, pci_dev_t *dev); |
17 | static void pci_lookup_driver(pci_dev_t *dev); |
17 | static void pci_lookup_driver(pci_dev_t *dev); |
18 | static void pci_lookup_devices(pci_drv_t *drv); |
18 | static void pci_lookup_devices(pci_drv_t *drv); |
19 | 19 | ||
20 | 20 | ||
21 | // TODO: think about locking |
- | |
22 | void pci_bus_scan(pci_bus_t *bus) |
21 | void pci_bus_scan(pci_bus_t *bus) |
23 | { |
22 | { |
24 | pci_dev_t *dev = pci_alloc_dev(); |
23 | pci_dev_t *dev = pci_alloc_dev(); |
25 | pci_bus_t *child_bus = NULL; |
24 | pci_bus_t *child_bus = NULL; |
26 | int dnum, fnum; |
25 | int dnum, fnum, bus_num; |
27 | bool multi; |
26 | bool multi; |
28 | uint8_t header_type; |
27 | uint8_t header_type; |
29 | 28 | ||
30 | printf("PCI: scanning bus number %d\n", bus->num); |
29 | printf("PCI: scanning bus number %d\n", bus->num); |
31 | 30 | ||
32 | for (dnum = 0; dnum < 4/*256*/; dnum++) { |
31 | for (dnum = 0; dnum < 256; dnum++) { |
33 | multi = true; |
32 | multi = true; |
34 | for (fnum = 0; multi && fnum < 8; fnum++) { |
33 | for (fnum = 0; multi && fnum < 8; fnum++) { |
35 | pci_init_dev(dev, bus, dnum, fnum); |
34 | pci_init_dev(dev, bus, dnum, fnum); |
36 | dev->vendor_id = pci_conf_read_16(dev, PCI_VENDOR_ID); |
35 | dev->vendor_id = pci_conf_read_16(dev, PCI_VENDOR_ID); |
37 | dev->device_id = pci_conf_read_16(dev, PCI_DEVICE_ID); |
36 | dev->device_id = pci_conf_read_16(dev, PCI_DEVICE_ID); |
Line 43... | Line 42... | ||
43 | multi = header_type >> 7; // is the device multifunction? |
42 | multi = header_type >> 7; // is the device multifunction? |
44 | } |
43 | } |
45 | header_type = header_type & 0x7F; // clear the multifunction bit |
44 | header_type = header_type & 0x7F; // clear the multifunction bit |
46 | 45 | ||
47 | printf("PCI: adding new device %d : %d", dnum, fnum); |
46 | printf("PCI: adding new device %d : %d", dnum, fnum); |
48 | printf(" - vendor = %x, device = %x.\n", dev->vendor_id, dev->device_id); |
47 | printf(" - vendor = 0x%x, device = 0x%x.\n", dev->vendor_id, dev->device_id); |
49 | pci_device_register(dev); |
48 | pci_device_register(dev); |
50 | dev = pci_alloc_dev(); // alloc new aux. dev. structure |
49 | dev = pci_alloc_dev(); // alloc new aux. dev. structure |
51 | 50 | ||
52 | if (header_type == PCI_HEADER_TYPE_BRIDGE || header_type == PCI_HEADER_TYPE_CARDBUS ) { |
51 | if (header_type == PCI_HEADER_TYPE_BRIDGE || header_type == PCI_HEADER_TYPE_CARDBUS ) { |
- | 52 | bus_num = pci_conf_read_8(dev, PCI_BRIDGE_SEC_BUS_NUM); |
|
53 | if (dnum != 0 && fnum != 0) { |
53 | if(bus_num != bus->num) { |
54 | child_bus = pci_alloc_bus(); |
54 | child_bus = pci_alloc_bus(); |
55 | pci_init_bus(child_bus, bus, pci_conf_read_8(dev, PCI_BRIDGE_SEC_BUS_NUM)); |
55 | pci_init_bus(child_bus, bus, bus_num); |
56 | pci_bus_register(child_bus); |
56 | pci_bus_register(child_bus); |
57 | pci_bus_scan(child_bus); |
57 | pci_bus_scan(child_bus); |
58 | } |
58 | } |
59 | } |
59 | } |
60 | } |
60 | } |
61 | } |
61 | } |
62 | 62 | ||
63 | if (dev->vendor_id == 0xFFFF) { |
63 | if (dev->vendor_id == 0xFFFF) { |