~ubuntu-branches/ubuntu/precise/seabios/precise-updates

« back to all changes in this revision

Viewing changes to debian/patches/0049-seabios-pciinit-pci-bridge-bus-initialization.patch

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-10-22 11:04:31 UTC
  • Revision ID: james.westby@ubuntu.com-20101022110431-fnfj73ra6xkq623n
Tags: 0.6.0-0ubuntu2
Add all patches which were included in qemu-0.13.0-rc2 (per
commit on Jul 13, 2010).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 
 
6
pci bridge bus initialization.
 
7
 
 
8
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
 
9
---
 
10
 src/pciinit.c |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
11
 1 files changed, 70 insertions(+), 0 deletions(-)
 
12
 
 
13
diff --git a/src/pciinit.c b/src/pciinit.c
 
14
index 23b79bc..d22ee10 100644
 
15
--- a/src/pciinit.c
 
16
+++ b/src/pciinit.c
 
17
@@ -247,6 +247,74 @@ static void pci_bios_init_device(u16 bdf)
 
18
     }
 
19
 }
 
20
 
 
21
+static void
 
22
+pci_bios_init_bus_rec(int bus, u8 *pci_bus)
 
23
+{
 
24
+    int bdf, max;
 
25
+    u16 class;
 
26
+
 
27
+    dprintf(1, "PCI: %s bus = 0x%x\n", __func__, bus);
 
28
+
 
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);
 
35
+        }
 
36
+    }
 
37
+
 
38
+    foreachpci_in_bus(bdf, max, bus) {
 
39
+        class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
 
40
+        if (class != PCI_CLASS_BRIDGE_PCI) {
 
41
+            continue;
 
42
+        }
 
43
+        dprintf(1, "PCI: %s bdf = 0x%x\n", __func__, bdf);
 
44
+
 
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);
 
49
+        } else {
 
50
+            dprintf(1, "PCI: primary bus = 0x%x\n", pribus);
 
51
+        }
 
52
+
 
53
+        u8 secbus = pci_config_readb(bdf, PCI_SECONDARY_BUS);
 
54
+        (*pci_bus)++;
 
55
+        if (*pci_bus != secbus) {
 
56
+            dprintf(1, "PCI: secondary bus = 0x%x -> 0x%x\n",
 
57
+                    secbus, *pci_bus);
 
58
+            secbus = *pci_bus;
 
59
+            pci_config_writeb(bdf, PCI_SECONDARY_BUS, secbus);
 
60
+        } else {
 
61
+            dprintf(1, "PCI: secondary bus = 0x%x\n", secbus);
 
62
+        }
 
63
+
 
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);
 
68
+
 
69
+        pci_bios_init_bus_rec(secbus, pci_bus);
 
70
+
 
71
+        if (subbus != *pci_bus) {
 
72
+            dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
 
73
+                    subbus, *pci_bus);
 
74
+            subbus = *pci_bus;
 
75
+        } else {
 
76
+            dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus);
 
77
+        }
 
78
+        pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, subbus);
 
79
+    }
 
80
+}
 
81
+
 
82
+static void
 
83
+pci_bios_init_bus(void)
 
84
+{
 
85
+    u8 pci_bus = 0;
 
86
+    pci_bios_init_bus_rec(0 /* host bus */, &pci_bus);
 
87
+}
 
88
+
 
89
 void
 
90
 pci_setup(void)
 
91
 {
 
92
@@ -260,6 +328,8 @@ pci_setup(void)
 
93
     pci_bios_mem_addr = BUILD_PCIMEM_START;
 
94
     pci_bios_prefmem_addr = BUILD_PCIPREFMEM_START;
 
95
 
 
96
+    pci_bios_init_bus();
 
97
+
 
98
     int bdf, max;
 
99
     foreachpci(bdf, max) {
 
100
         pci_bios_init_bridges(bdf);
 
101
-- 
 
102
1.7.1
 
103