qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: seabios@seabios.org
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 4/6] pci: bridges can have two regions too
Date: Wed, 29 Feb 2012 12:45:08 +0100	[thread overview]
Message-ID: <1330515910-725-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1330515910-725-1-git-send-email-kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 src/pciinit.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/pciinit.c b/src/pciinit.c
index aa391a0..33b9bf7 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -402,7 +402,7 @@ static void pci_bios_check_devices(struct pci_bus *busses)
 
     struct pci_device *pci;
     struct pci_bus *bus;
-    int i;
+    int i, num_regions;
 
     // init pci bridges
     foreachpci(pci) {
@@ -414,12 +414,11 @@ static void pci_bios_check_devices(struct pci_bus *busses)
 
     // discover pci bars
     foreachpci(pci) {
-        if (pci->class == PCI_CLASS_BRIDGE_PCI)
-            continue;
+        num_regions = (pci->class == PCI_CLASS_BRIDGE_PCI) ? 2 : PCI_NUM_REGIONS;
         dprintf(1, "PCI: check device bdf=%02x:%02x.%x\n",
                 pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf),
                 pci_bdf_to_fn(pci->bdf));
-        for (i = 0; i < PCI_NUM_REGIONS; i++) {
+        for (i = 0; i < num_regions; i++) {
             pci_bios_get_bar(pci, i, &pci->bars[i]);
             if (pci->bars[i].addr == 0)
                 continue;
@@ -431,10 +430,9 @@ static void pci_bios_check_devices(struct pci_bus *busses)
 
     // alloc ressources for pci bars
     foreachpci(pci) {
-        if (pci->class == PCI_CLASS_BRIDGE_PCI)
-            continue;
+        num_regions = (pci->class == PCI_CLASS_BRIDGE_PCI) ? 2 : PCI_NUM_REGIONS;
         bus = &busses[pci_bdf_to_bus(pci->bdf)];
-        for (i = 0; i < PCI_NUM_REGIONS; i++) {
+        for (i = 0; i < num_regions; i++) {
             enum pci_region_type type;
             if (pci->bars[i].addr == 0)
                 continue;
@@ -545,7 +543,7 @@ static void pci_bios_map_devices(struct pci_bus *busses)
     pci_bios_init_bus_bases(&busses[0]);
 
     // Map regions on each secondary bus.
-    int secondary_bus;
+    int secondary_bus, num_regions, i;
     for (secondary_bus=1; secondary_bus<=MaxPCIBus; secondary_bus++) {
         struct pci_bus *s = &busses[secondary_bus];
         if (!s->bus_dev)
@@ -583,14 +581,12 @@ static void pci_bios_map_devices(struct pci_bus *busses)
     // Map regions on each device.
     struct pci_device *pci;
     foreachpci(pci) {
-        if (pci->class == PCI_CLASS_BRIDGE_PCI)
-            continue;
+        num_regions = (pci->class == PCI_CLASS_BRIDGE_PCI) ? 2 : PCI_NUM_REGIONS;
         u16 bdf = pci->bdf;
         dprintf(1, "PCI: map device bdf=%02x:%02x.%x\n"
                 , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf));
         struct pci_bus *bus = &busses[pci_bdf_to_bus(bdf)];
-        int i;
-        for (i = 0; i < PCI_NUM_REGIONS; i++) {
+        for (i = 0; i < num_regions; i++) {
             if (pci->bars[i].addr == 0)
                 continue;
 
-- 
1.7.1

  parent reply	other threads:[~2012-02-29 11:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29 11:45 [Qemu-devel] [PATCH v2 0/6] pci: 64bit support Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 1/6] output: add 64bit hex print support Gerd Hoffmann
2012-03-05 15:23   ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2012-03-06  7:03     ` Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 2/6] pci: split device discovery into multiple steps Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 3/6] pci: 64bit support Gerd Hoffmann
2012-02-29 11:45 ` Gerd Hoffmann [this message]
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 5/6] pci: fix bridge ressource allocation Gerd Hoffmann
2012-02-29 11:45 ` [Qemu-devel] [PATCH v2 6/6] pci: add prefmem64 Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330515910-725-5-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).