From: Jan Kiszka <jan.kiszka@web.de>
To: seabios <seabios@seabios.org>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] Probe PCI existence
Date: Wed, 21 Sep 2011 08:16:21 +0200 [thread overview]
Message-ID: <4E798135.1050000@web.de> (raw)
In-Reply-To: <4E7904AD.6040807@reactos.org>
From: Jan Kiszka <jan.kiszka@siemens.com>
This prevents lockups when trying to allocate PCI resources on an
ISA-only system like QEMU can emulate.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
src/pci.c | 14 +++++++++++++-
src/pci.h | 3 ++-
src/pciinit.c | 7 +++++--
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/pci.c b/src/pci.c
index 49698ac..6031c9f 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -88,9 +88,21 @@ pci_next(int bdf, int bus)
struct pci_device *PCIDevices;
int MaxPCIBus VAR16VISIBLE;
+// Check if PCI is available at all
+int
+pci_probe_host(void)
+{
+ outl(0x80000000, PORT_PCI_CMD);
+ if (inl(PORT_PCI_CMD) != 0x80000000) {
+ dprintf(1, "Detected non-PCI system\n");
+ return -1;
+ }
+ return 0;
+}
+
// Find all PCI devices and populate PCIDevices linked list.
void
-pci_probe(void)
+pci_probe_devices(void)
{
dprintf(3, "PCI probe\n");
struct pci_device *busdevs[256];
diff --git a/src/pci.h b/src/pci.h
index 3e28af2..a2a5a4c 100644
--- a/src/pci.h
+++ b/src/pci.h
@@ -62,7 +62,8 @@ struct pci_device {
};
extern struct pci_device *PCIDevices;
extern int MaxPCIBus;
-void pci_probe(void);
+int pci_probe_host(void);
+void pci_probe_devices(void);
static inline u32 pci_classprog(struct pci_device *pci) {
return (pci->class << 8) | pci->prog_if;
}
diff --git a/src/pciinit.c b/src/pciinit.c
index 597c8ea..a857da0 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -577,7 +577,7 @@ pci_setup(void)
{
if (CONFIG_COREBOOT || usingXen()) {
// PCI setup already done by coreboot or Xen - just do probe.
- pci_probe();
+ pci_probe_devices();
return;
}
@@ -587,10 +587,13 @@ pci_setup(void)
u32 end = BUILD_PCIMEM_END;
dprintf(1, "=== PCI bus & bridge init ===\n");
+ if (pci_probe_host() != 0) {
+ return;
+ }
pci_bios_init_bus();
dprintf(1, "=== PCI device probing ===\n");
- pci_probe();
+ pci_probe_devices();
dprintf(1, "=== PCI new allocation pass #1 ===\n");
busses = malloc_tmp(sizeof(*busses) * busses_count);
--
1.7.3.4
next prev parent reply other threads:[~2011-09-21 6:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-18 16:04 [Qemu-devel] [PATCH] isapc: give system address space when pci is disabled Hervé Poussineau
2011-09-19 7:57 ` Jan Kiszka
2011-09-19 18:49 ` Hervé Poussineau
2011-09-20 8:27 ` Jan Kiszka
2011-09-20 21:25 ` Hervé Poussineau
2011-09-21 6:16 ` Jan Kiszka [this message]
2011-09-23 4:23 ` [Qemu-devel] [PATCH] Probe PCI existence Kevin O'Connor
2011-10-10 14:29 ` Gerd Hoffmann
2011-09-23 16:05 ` [Qemu-devel] [PATCH] isapc: give system address space when pci is disabled Anthony Liguori
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=4E798135.1050000@web.de \
--to=jan.kiszka@web.de \
--cc=hpoussin@reactos.org \
--cc=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).