1
From f441666dbdf0e9f78442a6b33b086699ff6f5a21 Mon Sep 17 00:00:00 2001
2
From: Isaku Yamahata <yamahata@valinux.co.jp>
3
Date: Tue, 22 Jun 2010 17:57:52 +0900
4
Subject: [PATCH 49/54] seabios: pciinit: pci bridge bus initialization.
6
pci bridge bus initialization.
8
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
10
src/pciinit.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11
1 files changed, 70 insertions(+), 0 deletions(-)
13
diff --git a/src/pciinit.c b/src/pciinit.c
14
index 23b79bc..d22ee10 100644
17
@@ -247,6 +247,74 @@ static void pci_bios_init_device(u16 bdf)
22
+pci_bios_init_bus_rec(int bus, u8 *pci_bus)
27
+ dprintf(1, "PCI: %s bus = 0x%x\n", __func__, bus);
29
+ /* prevent accidental access to unintended devices */
30
+ foreachpci_in_bus(bdf, max, bus) {
31
+ class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
32
+ if (class == PCI_CLASS_BRIDGE_PCI) {
33
+ pci_config_writeb(bdf, PCI_SECONDARY_BUS, 255);
34
+ pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, 0);
38
+ foreachpci_in_bus(bdf, max, bus) {
39
+ class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
40
+ if (class != PCI_CLASS_BRIDGE_PCI) {
43
+ dprintf(1, "PCI: %s bdf = 0x%x\n", __func__, bdf);
45
+ u8 pribus = pci_config_readb(bdf, PCI_PRIMARY_BUS);
46
+ if (pribus != bus) {
47
+ dprintf(1, "PCI: primary bus = 0x%x -> 0x%x\n", pribus, bus);
48
+ pci_config_writeb(bdf, PCI_PRIMARY_BUS, bus);
50
+ dprintf(1, "PCI: primary bus = 0x%x\n", pribus);
53
+ u8 secbus = pci_config_readb(bdf, PCI_SECONDARY_BUS);
55
+ if (*pci_bus != secbus) {
56
+ dprintf(1, "PCI: secondary bus = 0x%x -> 0x%x\n",
59
+ pci_config_writeb(bdf, PCI_SECONDARY_BUS, secbus);
61
+ dprintf(1, "PCI: secondary bus = 0x%x\n", secbus);
64
+ /* set to max for access to all subordinate buses.
65
+ later set it to accurate value */
66
+ u8 subbus = pci_config_readb(bdf, PCI_SUBORDINATE_BUS);
67
+ pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, 255);
69
+ pci_bios_init_bus_rec(secbus, pci_bus);
71
+ if (subbus != *pci_bus) {
72
+ dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
76
+ dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus);
78
+ pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, subbus);
83
+pci_bios_init_bus(void)
86
+ pci_bios_init_bus_rec(0 /* host bus */, &pci_bus);
92
@@ -260,6 +328,8 @@ pci_setup(void)
93
pci_bios_mem_addr = BUILD_PCIMEM_START;
94
pci_bios_prefmem_addr = BUILD_PCIPREFMEM_START;
96
+ pci_bios_init_bus();
99
foreachpci(bdf, max) {
100
pci_bios_init_bridges(bdf);