Rev 4418 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4418 | Rev 4438 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | pci_bus_t *child_bus = NULL; |
24 | pci_bus_t *child_bus = NULL; |
25 | int dnum, fnum, bus_num; |
25 | int dnum, fnum, bus_num; |
26 | bool multi; |
26 | bool multi; |
27 | uint8_t header_type; |
27 | uint8_t header_type; |
28 | 28 | ||
29 | printf("PCI: scanning bus number %d\n", bus->num); |
- | |
30 | - | ||
31 | for (dnum = 0; dnum < 256; dnum++) { |
29 | for (dnum = 0; dnum < 32; dnum++) { |
32 | multi = true; |
30 | multi = true; |
33 | for (fnum = 0; multi && fnum < 8; fnum++) { |
31 | for (fnum = 0; multi && fnum < 8; fnum++) { |
34 | pci_init_dev(dev, bus, dnum, fnum); |
32 | pci_init_dev(dev, bus, dnum, fnum); |
35 | dev->vendor_id = pci_conf_read_16(dev, PCI_VENDOR_ID); |
33 | dev->vendor_id = pci_conf_read_16(dev, PCI_VENDOR_ID); |
36 | dev->device_id = pci_conf_read_16(dev, PCI_DEVICE_ID); |
34 | dev->device_id = pci_conf_read_16(dev, PCI_DEVICE_ID); |
- | 35 | if (dev->vendor_id == 0xFFFF) { // device is not present, go on scanning the bus |
|
37 | if (dev->vendor_id == 0xFFFF) { |
36 | if (fnum == 0) { |
- | 37 | break; |
|
- | 38 | } else { |
|
38 | continue; // device is not present, go on scanning the bus |
39 | continue; |
- | 40 | } |
|
39 | } |
41 | } |
40 | header_type = pci_conf_read_8(dev, PCI_HEADER_TYPE); |
42 | header_type = pci_conf_read_8(dev, PCI_HEADER_TYPE); |
41 | if (fnum == 0) { |
43 | if (fnum == 0) { |
42 | multi = header_type >> 7; // is the device multifunction? |
44 | multi = header_type >> 7; // is the device multifunction? |
43 | } |
45 | } |
44 | header_type = header_type & 0x7F; // clear the multifunction bit |
46 | header_type = header_type & 0x7F; // clear the multifunction bit |
45 | 47 | ||
46 | printf("PCI: adding new device %d : %d", dnum, fnum); |
48 | printf("PCI: adding new device %d : %d : %d", dev->bus->num, dnum, fnum); |
47 | printf(" - vendor = 0x%x, device = 0x%x.\n", dev->vendor_id, dev->device_id); |
49 | printf(" - vendor = 0x%04X, device = 0x%04X.\n", dev->vendor_id, dev->device_id); |
48 | pci_device_register(dev); |
50 | pci_device_register(dev); |
49 | dev = pci_alloc_dev(); // alloc new aux. dev. structure |
- | |
50 | 51 | ||
51 | if (header_type == PCI_HEADER_TYPE_BRIDGE || header_type == PCI_HEADER_TYPE_CARDBUS ) { |
52 | 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 | bus_num = pci_conf_read_8(dev, PCI_BRIDGE_SEC_BUS_NUM); |
- | 54 | printf("PCI: device is pci-to-pci bridge, secondary bus number = %d.\n", bus_num); |
|
53 | if(bus_num != bus->num) { |
55 | if(bus_num > bus->num) { |
54 | child_bus = pci_alloc_bus(); |
56 | child_bus = pci_alloc_bus(); |
55 | pci_init_bus(child_bus, bus, bus_num); |
57 | pci_init_bus(child_bus, bus, bus_num); |
56 | pci_bus_register(child_bus); |
58 | pci_bus_register(child_bus); |
57 | pci_bus_scan(child_bus); |
59 | pci_bus_scan(child_bus); |
58 | } |
60 | } |
59 | } |
61 | } |
- | 62 | ||
- | 63 | dev = pci_alloc_dev(); // alloc new aux. dev. structure |
|
60 | } |
64 | } |
61 | } |
65 | } |
62 | 66 | ||
63 | if (dev->vendor_id == 0xFFFF) { |
67 | if (dev->vendor_id == 0xFFFF) { |
64 | pci_free_dev(dev); // free the auxiliary device structure |
68 | pci_free_dev(dev); // free the auxiliary device structure |