From patchwork Mon Jan 4 07:32:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 42049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B1FB9B6F17 for ; Mon, 4 Jan 2010 18:41:50 +1100 (EST) Received: from localhost ([127.0.0.1]:40095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NRhZT-0004XE-DK for incoming@patchwork.ozlabs.org; Mon, 04 Jan 2010 02:41:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NRhR2-00022L-Sz for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:33:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NRhQx-0001wI-HX for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:33:04 -0500 Received: from [199.232.76.173] (port=50915 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NRhQx-0001vx-6K for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:32:59 -0500 Received: from cantor.suse.de ([195.135.220.2]:33222 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NRhQw-0007YG-N5 for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:32:59 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 8F2BE9417A; Mon, 4 Jan 2010 08:32:56 +0100 (CET) From: Alexander Graf To: QEMU Developers Date: Mon, 4 Jan 2010 08:32:51 +0100 Message-Id: <1262590375-11431-3-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1262590375-11431-1-git-send-email-agraf@suse.de> References: <1262590375-11431-1-git-send-email-agraf@suse.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Blue Swirl , Aurelien Jarno , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 2/6] Add config space conversion function for uni_north X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 CC: Michael S. Tsirkin CC: Benjamin Herrenschmidt --- v1 -> v2: - convert Uninorth to use config space decoder --- hw/unin_pci.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/hw/unin_pci.c b/hw/unin_pci.c index fdb9401..5e69725 100644 --- a/hw/unin_pci.c +++ b/hw/unin_pci.c @@ -75,6 +75,36 @@ static void pci_unin_reset(void *opaque) { } +static void unin_decode_config_reg(PCIHostState *s, uint32_t config_reg, + PCIConfigAddress *decoded) +{ + decoded->addr.domain = s->bus; + decoded->addr_mask = 7; + decoded->offset = config_reg & 0xfc; + decoded->addr.fn = (config_reg >> 8) & 0x7; + + if (config_reg & (1u << 31)) { + /* XXX OpenBIOS compatibility hack */ + pci_host_decode_config_reg(s, config_reg, decoded); + } else if (config_reg & 1) { + /* CFA1 style values */ + + decoded->valid = (config_reg & 1) ? true : false; + decoded->addr.bus = (config_reg >> 16) & 0xff; + decoded->addr.slot = (config_reg >> 11) & 0x1f; + } else { + /* CFA0 style values */ + + decoded->valid = true; + decoded->addr.bus = 0; + decoded->addr.slot = ffs(config_reg & 0xfffff800) - 1; + } + + UNIN_DPRINTF("Converted config space accessor %08x -> %02x %02x %x\n", + config_reg, decoded->addr.bus, decoded->addr.slot, + decoded->addr.fn); +} + static int pci_unin_main_init_device(SysBusDevice *dev) { UNINState *s; @@ -85,6 +115,7 @@ static int pci_unin_main_init_device(SysBusDevice *dev) s = FROM_SYSBUS(UNINState, dev); pci_host_init(&s->host_state); + s->host_state.decode_config_reg = unin_decode_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);