From patchwork Mon Aug 8 17:06:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 1045882 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p78H7gWL030976 for ; Mon, 8 Aug 2011 17:07:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753470Ab1HHRHj (ORCPT ); Mon, 8 Aug 2011 13:07:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2245 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257Ab1HHRHi (ORCPT ); Mon, 8 Aug 2011 13:07:38 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p78H7Ciq028194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Aug 2011 13:07:12 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p78H7BNc006924; Mon, 8 Aug 2011 13:07:11 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id B2C13250B44; Mon, 8 Aug 2011 20:07:10 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Subject: [PATCH 02/24] apic: convert to memory API Date: Mon, 8 Aug 2011 20:06:47 +0300 Message-Id: <1312823229-12822-3-git-send-email-avi@redhat.com> In-Reply-To: <1312823229-12822-1-git-send-email-avi@redhat.com> References: <1312823229-12822-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 08 Aug 2011 17:07:42 +0000 (UTC) Signed-off-by: Avi Kivity --- hw/apic.c | 25 ++++++++++--------------- 1 files changed, 10 insertions(+), 15 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index 9febf40..7d0b0f6 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -80,6 +80,7 @@ typedef struct APICState APICState; struct APICState { SysBusDevice busdev; + MemoryRegion io_memory; void *cpu_env; uint32_t apicbase; uint8_t id; @@ -979,31 +980,25 @@ static void apic_reset(DeviceState *d) } } -static CPUReadMemoryFunc * const apic_mem_read[3] = { - apic_mem_readb, - apic_mem_readw, - apic_mem_readl, -}; - -static CPUWriteMemoryFunc * const apic_mem_write[3] = { - apic_mem_writeb, - apic_mem_writew, - apic_mem_writel, +static const MemoryRegionOps apic_io_ops = { + .old_mmio = { + .read = { apic_mem_readb, apic_mem_readw, apic_mem_readl, }, + .write = { apic_mem_writeb, apic_mem_writew, apic_mem_writel, }, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static int apic_init1(SysBusDevice *dev) { APICState *s = FROM_SYSBUS(APICState, dev); - int apic_io_memory; static int last_apic_idx; if (last_apic_idx >= MAX_APICS) { return -1; } - apic_io_memory = cpu_register_io_memory(apic_mem_read, - apic_mem_write, NULL, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, MSI_ADDR_SIZE, apic_io_memory); + memory_region_init_io(&s->io_memory, &apic_io_ops, s, "apic", + MSI_ADDR_SIZE); + sysbus_init_mmio_region(dev, &s->io_memory); s->timer = qemu_new_timer_ns(vm_clock, apic_timer, s); s->idx = last_apic_idx++;