From: Alexander Graf <agraf@suse.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Blue Swirl <blauwirbel@gmail.com>, Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 2/6] Add config space conversion function for uni_north
Date: Sun, 3 Jan 2010 02:50:46 +0100 [thread overview]
Message-ID: <1262483450-15206-3-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1262483450-15206-1-git-send-email-agraf@suse.de>
As stated in the previous patch, the Uninorth PCI bridge requires different
layouts in its PCI config space accessors.
This patch introduces a conversion function that makes it compatible with
the way Linux accesses it.
I also kept an OpenBIOS compatibility hack in. I think it'd be better to
take small steps here and do the config space access rework in OpenBIOS
later on. When that's done we can remove that hack.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/unin_pci.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/hw/unin_pci.c b/hw/unin_pci.c
index fdb9401..1c49008 100644
--- a/hw/unin_pci.c
+++ b/hw/unin_pci.c
@@ -75,6 +75,40 @@ static void pci_unin_reset(void *opaque)
{
}
+static uint32_t unin_get_config_reg(PCIHostState *s, uint32_t addr)
+{
+ uint32_t retval;
+ uint32_t reg = s->config_reg;
+
+ if (reg & (1u << 31)) {
+ /* XXX OpenBIOS compatibility hack */
+ retval = reg;
+ addr |= reg & 7;
+ } else if (reg & 1) {
+ /* Set upper valid bit and remove lower one */
+ retval = (reg & ~3u) | (1u << 31);
+ } else {
+ uint32_t slot, func;
+ uint32_t devfn;
+
+ /* Grab CFA0 style values */
+ slot = ffs(reg & 0xfffff800) - 1;
+ func = (reg >> 8) & 7;
+ devfn = PCI_DEVFN(slot, func);
+
+ /* ... and then convert them to x86 format */
+ retval = (reg & 0xfc) | (devfn << 8) | (1u << 31);
+ }
+
+ retval &= ~3u;
+ retval |= (addr & 7);
+
+ UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
+ reg, addr, retval);
+
+ return retval;
+}
+
static int pci_unin_main_init_device(SysBusDevice *dev)
{
UNINState *s;
@@ -85,6 +119,7 @@ static int pci_unin_main_init_device(SysBusDevice *dev)
s = FROM_SYSBUS(UNINState, dev);
pci_host_init(&s->host_state);
+ s->host_state.get_config_reg = unin_get_config_reg;
pci_mem_config = pci_host_conf_register_mmio(&s->host_state);
pci_mem_data = pci_host_data_register_mmio(&s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
--
1.6.0.2
next prev parent reply other threads:[~2010-01-03 1:51 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-03 1:50 [Qemu-devel] [PATCH 0/6] PPC NewWorld fixery Alexander Graf
2010-01-03 1:50 ` [Qemu-devel] [PATCH 1/6] Make config space accessor host bus trapable Alexander Graf
2010-01-03 15:45 ` [Qemu-devel] " Michael S. Tsirkin
2010-01-03 16:09 ` Alexander Graf
2010-01-03 17:29 ` Michael S. Tsirkin
2010-01-03 17:40 ` Alexander Graf
2010-01-03 17:44 ` Michael S. Tsirkin
2010-01-03 17:50 ` Alexander Graf
2010-01-03 18:06 ` Michael S. Tsirkin
2010-01-03 19:18 ` Blue Swirl
2010-01-10 18:41 ` Blue Swirl
2010-01-11 21:29 ` Blue Swirl
2010-01-11 22:33 ` Igor Kovalenko
2010-01-12 19:29 ` Blue Swirl
2010-01-18 19:47 ` Blue Swirl
2010-01-03 20:27 ` Alexander Graf
2010-01-03 20:50 ` Benjamin Herrenschmidt
2010-01-04 3:26 ` Alexander Graf
2010-01-04 10:45 ` Isaku Yamahata
2010-01-04 10:55 ` Alexander Graf
2010-01-04 11:08 ` Isaku Yamahata
2010-01-04 11:07 ` Michael S. Tsirkin
2010-01-04 11:13 ` Alexander Graf
2010-01-04 20:10 ` Benjamin Herrenschmidt
2010-01-04 21:12 ` Michael S. Tsirkin
2010-01-04 21:25 ` Benjamin Herrenschmidt
2010-01-04 21:30 ` Michael S. Tsirkin
2010-01-04 21:53 ` Benjamin Herrenschmidt
2010-01-04 22:25 ` Michael S. Tsirkin
2010-01-04 22:51 ` Benjamin Herrenschmidt
2010-01-04 22:59 ` Michael S. Tsirkin
2010-01-04 23:08 ` Alexander Graf
2010-01-04 23:12 ` Michael S. Tsirkin
2010-01-04 23:39 ` Benjamin Herrenschmidt
2010-01-04 23:33 ` Benjamin Herrenschmidt
2010-01-03 1:50 ` Alexander Graf [this message]
2010-01-03 15:32 ` [Qemu-devel] Re: [PATCH 2/6] Add config space conversion function for uni_north Michael S. Tsirkin
2010-01-03 15:40 ` Alexander Graf
2010-01-03 15:47 ` Michael S. Tsirkin
2010-01-03 16:13 ` Alexander Graf
2010-01-03 16:20 ` Michael S. Tsirkin
2010-01-03 16:35 ` Alexander Graf
2010-01-03 17:23 ` Michael S. Tsirkin
2010-01-03 15:48 ` Michael S. Tsirkin
2010-01-03 1:50 ` [Qemu-devel] [PATCH 3/6] Use Mac99_U3 type on ppc64 Alexander Graf
2010-01-03 1:50 ` [Qemu-devel] [PATCH 4/6] Include dump of lspci -nn on real G5 Alexander Graf
2010-01-03 1:50 ` [Qemu-devel] [PATCH 5/6] Make interrupts work Alexander Graf
2010-01-03 1:50 ` [Qemu-devel] [PATCH 6/6] Enable secondary cmd64x Alexander Graf
-- strict thread matches above, loose matches on Subject: below --
2010-01-04 7:32 [Qemu-devel] [PATCH 0/6] PPC NewWorld fixery v2 Alexander Graf
2010-01-04 7:32 ` [Qemu-devel] [PATCH 2/6] Add config space conversion function for uni_north Alexander Graf
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=1262483450-15206-3-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.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).