From patchwork Wed Mar 7 00:15:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 145120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 56DF9B6EF1 for ; Wed, 7 Mar 2012 11:15:26 +1100 (EST) Received: from localhost ([::1]:59448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S54XM-0007SW-4i for incoming@patchwork.ozlabs.org; Tue, 06 Mar 2012 19:15:24 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S54XE-0007ME-HX for qemu-devel@nongnu.org; Tue, 06 Mar 2012 19:15:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S54XC-0005hl-1Y for qemu-devel@nongnu.org; Tue, 06 Mar 2012 19:15:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S54XB-0005hS-Po for qemu-devel@nongnu.org; Tue, 06 Mar 2012 19:15:13 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q270FCCq006162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Mar 2012 19:15:12 -0500 Received: from bling.home ([10.3.113.14]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q270FBZT023644; Tue, 6 Mar 2012 19:15:11 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Tue, 06 Mar 2012 17:15:11 -0700 Message-ID: <20120307001457.3079.22760.stgit@bling.home> In-Reply-To: <20120307000340.3079.87515.stgit@bling.home> References: <20120307000340.3079.87515.stgit@bling.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: alex.williamson@redhat.com, ddutile@redhat.com, gleb@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 5/6] acpi_piix4: Use pci_get/set_byte X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Remove stray direct access Signed-off-by: Alex Williamson --- hw/acpi_piix4.c | 53 +++++++++++++++++++++++++++-------------------------- 1 files changed, 27 insertions(+), 26 deletions(-) diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 7e766e5..4640e2e 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -178,11 +178,12 @@ static const IORangeOps pm_iorange_ops = { static void apm_ctrl_changed(uint32_t val, void *arg) { PIIX4PMState *s = arg; + PCIDevice *dev = &s->dev; /* ACPI specs 3.0, 4.7.2.5 */ acpi_pm1_cnt_update(&s->pm1_cnt, val == ACPI_ENABLE, val == ACPI_DISABLE); - if (s->dev.config[0x5b] & (1 << 1)) { + if (pci_get_byte(dev->config + 0x5b) & (1 << 1)) { if (s->smi_irq) { qemu_irq_raise(s->smi_irq); } @@ -196,10 +197,11 @@ static void acpi_dbg_writel(void *opaque, uint32_t addr, uint32_t val) static void pm_io_space_update(PIIX4PMState *s) { + PCIDevice *dev = &s->dev; uint32_t pm_io_base; - if (s->dev.config[0x80] & 1) { - pm_io_base = le32_to_cpu(*(uint32_t *)(s->dev.config + 0x40)); + if (pci_get_byte(dev->config + 0x80) & 1) { + pm_io_base = pci_get_long(dev->config + 0x40); pm_io_base &= 0xffc0; /* XXX: need to improve memory and ioport allocation */ @@ -302,16 +304,16 @@ static void piix4_update_hotplug(PIIX4PMState *s) static void piix4_reset(void *opaque) { PIIX4PMState *s = opaque; - uint8_t *pci_conf = s->dev.config; + PCIDevice *dev = &s->dev; - pci_conf[0x58] = 0; - pci_conf[0x59] = 0; - pci_conf[0x5a] = 0; - pci_conf[0x5b] = 0; + pci_set_byte(dev->config + 0x58, 0); + pci_set_byte(dev->config + 0x59, 0); + pci_set_byte(dev->config + 0x5a, 0); + pci_set_byte(dev->config + 0x5b, 0); if (s->kvm_enabled) { /* Mark SMM as already inited (until KVM supports SMM). */ - pci_conf[0x5B] = 0x02; + pci_set_byte(dev->config + 0x5B, 0x02); } piix4_update_hotplug(s); } @@ -328,13 +330,14 @@ static void piix4_powerdown(void *opaque, int irq, int power_failing) static void piix4_pm_machine_ready(Notifier *n, void *opaque) { PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready); - uint8_t *pci_conf; + PCIDevice *dev = &s->dev; - pci_conf = s->dev.config; - pci_conf[0x5f] = (isa_is_ioport_assigned(0x378) ? 0x80 : 0) | 0x10; - pci_conf[0x63] = 0x60; - pci_conf[0x67] = (isa_is_ioport_assigned(0x3f8) ? 0x08 : 0) | - (isa_is_ioport_assigned(0x2f8) ? 0x90 : 0); + pci_set_byte(dev->config + 0x5f, + (isa_is_ioport_assigned(0x378) ? 0x80 : 0) | 0x10); + pci_set_byte(dev->config + 0x63, 0x60); + pci_set_byte(dev->config + 0x67, + (isa_is_ioport_assigned(0x3f8) ? 0x08 : 0) | + (isa_is_ioport_assigned(0x2f8) ? 0x90 : 0)); } @@ -353,18 +356,16 @@ static PIIX4PMState *global_piix4_pm_state; /* cpu hotadd */ static int piix4_pm_initfn(PCIDevice *dev) { PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev); - uint8_t *pci_conf; /* for cpu hotadd */ global_piix4_pm_state = s; - pci_conf = s->dev.config; - pci_conf[0x06] = 0x80; - pci_conf[0x07] = 0x02; - pci_conf[0x09] = 0x00; - pci_conf[0x3d] = 0x01; // interrupt pin 1 + pci_set_byte(dev->config + 0x06, 0x80); + pci_set_byte(dev->config + 0x07, 0x02); + pci_set_byte(dev->config + 0x09, 0x00); + pci_set_byte(dev->config + 0x3d, 0x01); /* interrupt pin 1 */ - pci_conf[0x40] = 0x01; /* PM io base read only bit */ + pci_set_byte(dev->config + 0x40, 0x01); /* PM io base read only bit */ /* APM */ apm_init(&s->apm, apm_ctrl_changed, s); @@ -374,14 +375,14 @@ static int piix4_pm_initfn(PCIDevice *dev) if (s->kvm_enabled) { /* Mark SMM as already inited to prevent SMM from running. KVM does not * support SMM mode. */ - pci_conf[0x5B] = 0x02; + pci_set_byte(dev->config + 0x5B, 0x02); } /* XXX: which specification is used ? The i82731AB has different mappings */ - pci_conf[0x90] = s->smb_io_base | 1; - pci_conf[0x91] = s->smb_io_base >> 8; - pci_conf[0xd2] = 0x09; + pci_set_byte(dev->config + 0x90, s->smb_io_base | 1); + pci_set_byte(dev->config + 0x91, s->smb_io_base >> 8); + pci_set_byte(dev->config + 0xd2, 0x09); register_ioport_write(s->smb_io_base, 64, 1, smb_ioport_writeb, &s->smb); register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);