From patchwork Tue Aug 18 13:34:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 31560 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 13AE4B6F2B for ; Tue, 18 Aug 2009 23:45:40 +1000 (EST) Received: from localhost ([127.0.0.1]:56960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MdP0G-0008HK-U2 for incoming@patchwork.ozlabs.org; Tue, 18 Aug 2009 09:45:32 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MdOrd-0005Vw-TM for qemu-devel@nongnu.org; Tue, 18 Aug 2009 09:36:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MdOrY-0005Tj-Fo for qemu-devel@nongnu.org; Tue, 18 Aug 2009 09:36:36 -0400 Received: from [199.232.76.173] (port=55926 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MdOrY-0005Tg-6E for qemu-devel@nongnu.org; Tue, 18 Aug 2009 09:36:32 -0400 Received: from mx2.redhat.com ([66.187.237.31]:43656) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MdOrX-0001uc-MN for qemu-devel@nongnu.org; Tue, 18 Aug 2009 09:36:32 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7IDaV2C000567 for ; Tue, 18 Aug 2009 09:36:31 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7IDaTss018974; Tue, 18 Aug 2009 09:36:29 -0400 Received: from localhost.localdomain (vpn1-4-110.ams2.redhat.com [10.36.4.110]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7IDaKT0006375; Tue, 18 Aug 2009 09:36:28 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Aug 2009 15:34:10 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH 5/5] Port apic to new VMState design 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 Signed-off-by: Juan Quintela --- hw/apic.c | 96 +++++++++++++++++------------------------------------------- 1 files changed, 27 insertions(+), 69 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index 1927811..2c1dbf4 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -864,75 +864,33 @@ static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) } } -static void apic_save(QEMUFile *f, void *opaque) -{ - APICState *s = opaque; - int i; - - qemu_put_be32s(f, &s->apicbase); - qemu_put_8s(f, &s->id); - qemu_put_8s(f, &s->arb_id); - qemu_put_8s(f, &s->tpr); - qemu_put_be32s(f, &s->spurious_vec); - qemu_put_8s(f, &s->log_dest); - qemu_put_8s(f, &s->dest_mode); - for (i = 0; i < 8; i++) { - qemu_put_be32s(f, &s->isr[i]); - qemu_put_be32s(f, &s->tmr[i]); - qemu_put_be32s(f, &s->irr[i]); - } - for (i = 0; i < APIC_LVT_NB; i++) { - qemu_put_be32s(f, &s->lvt[i]); +static VMStateDescription vmstate_apic = { + .name = "apic", + .version_id = 3, + .minimum_version_id = 3, + .fields = (VMStateField []) { + VMSTATE_UINT32(apicbase, APICState, 0), + VMSTATE_UINT8(id, APICState, 0), + VMSTATE_UINT8(arb_id, APICState, 0), + VMSTATE_UINT8(tpr, APICState, 0), + VMSTATE_UINT32(spurious_vec, APICState, 0), + VMSTATE_UINT8(log_dest, APICState, 0), + VMSTATE_UINT8(dest_mode, APICState, 0), + VMSTATE_UINT32_ARRAY(isr, APICState, 0, 8), + VMSTATE_UINT32_ARRAY(tmr, APICState, 0, 8), + VMSTATE_UINT32_ARRAY(irr, APICState, 0, 8), + VMSTATE_UINT32_ARRAY(lvt, APICState, 0, APIC_LVT_NB), + VMSTATE_UINT32(esr, APICState, 0), + VMSTATE_UINT32_ARRAY(icr, APICState, 0, 2), + VMSTATE_UINT32(divide_conf, APICState, 0), + VMSTATE_INT32(count_shift, APICState, 0), + VMSTATE_UINT32(initial_count, APICState, 0), + VMSTATE_INT64(initial_count_load_time, APICState, 0), + VMSTATE_INT64(next_time, APICState, 0), + VMSTATE_TIMER(timer, APICState, 2), + VMSTATE_END_OF_LIST() } - qemu_put_be32s(f, &s->esr); - qemu_put_be32s(f, &s->icr[0]); - qemu_put_be32s(f, &s->icr[1]); - qemu_put_be32s(f, &s->divide_conf); - qemu_put_be32(f, s->count_shift); - qemu_put_be32s(f, &s->initial_count); - qemu_put_be64(f, s->initial_count_load_time); - qemu_put_be64(f, s->next_time); - - qemu_put_timer(f, s->timer); -} - -static int apic_load(QEMUFile *f, void *opaque, int version_id) -{ - APICState *s = opaque; - int i; - - if (version_id > 2) - return -EINVAL; - - /* XXX: what if the base changes? (registered memory regions) */ - qemu_get_be32s(f, &s->apicbase); - qemu_get_8s(f, &s->id); - qemu_get_8s(f, &s->arb_id); - qemu_get_8s(f, &s->tpr); - qemu_get_be32s(f, &s->spurious_vec); - qemu_get_8s(f, &s->log_dest); - qemu_get_8s(f, &s->dest_mode); - for (i = 0; i < 8; i++) { - qemu_get_be32s(f, &s->isr[i]); - qemu_get_be32s(f, &s->tmr[i]); - qemu_get_be32s(f, &s->irr[i]); - } - for (i = 0; i < APIC_LVT_NB; i++) { - qemu_get_be32s(f, &s->lvt[i]); - } - qemu_get_be32s(f, &s->esr); - qemu_get_be32s(f, &s->icr[0]); - qemu_get_be32s(f, &s->icr[1]); - qemu_get_be32s(f, &s->divide_conf); - s->count_shift=qemu_get_be32(f); - qemu_get_be32s(f, &s->initial_count); - s->initial_count_load_time=qemu_get_be64(f); - s->next_time=qemu_get_be64(f); - - if (version_id >= 2) - qemu_get_timer(f, s->timer); - return 0; -} +}; static void apic_reset(void *opaque) { @@ -996,7 +954,7 @@ int apic_init(CPUState *env) } s->timer = qemu_new_timer(vm_clock, apic_timer, s); - register_savevm("apic", s->idx, 2, apic_save, apic_load, s); + vmstate_register(s->idx, &vmstate_apic, s); qemu_register_reset(apic_reset, s); local_apics[s->idx] = s;