From patchwork Wed Oct 14 23:40:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 36036 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 B9C5DB7B70 for ; Thu, 15 Oct 2009 10:50:19 +1100 (EST) Received: from localhost ([127.0.0.1]:35818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyDbk-0001tZ-Vg for incoming@patchwork.ozlabs.org; Wed, 14 Oct 2009 19:50:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MyDSV-0004tO-3v for qemu-devel@nongnu.org; Wed, 14 Oct 2009 19:40:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MyDSQ-0004lG-AS for qemu-devel@nongnu.org; Wed, 14 Oct 2009 19:40:42 -0400 Received: from [199.232.76.173] (port=41478 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyDSP-0004kd-Pa for qemu-devel@nongnu.org; Wed, 14 Oct 2009 19:40:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64055) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MyDSP-0003Vp-9F for qemu-devel@nongnu.org; Wed, 14 Oct 2009 19:40:37 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9ENea1a008177 for ; Wed, 14 Oct 2009 19:40:36 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9ENeR9m015721; Wed, 14 Oct 2009 19:40:35 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 15 Oct 2009 01:40:01 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: rjones@redhat.com Subject: [Qemu-devel] [PATCH 5/6] ib700: move timer to IB700State 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/wdt_ib700.c | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c index e598df5..d2b9b41 100644 --- a/hw/wdt_ib700.c +++ b/hw/wdt_ib700.c @@ -37,17 +37,18 @@ typedef struct IB700state { ISADevice dev; + QEMUTimer *timer; } IB700State; /* This is the timer. We use a global here because the watchdog * code ensures there is only one watchdog (it is located at a fixed, * unchangable IO port, so there could only ever be one anyway). */ -static QEMUTimer *timer = NULL; /* A write to this register enables the timer. */ static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data) { + IB700State *s = vp; static int time_map[] = { 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0 @@ -57,37 +58,45 @@ static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data) ib700_debug("addr = %x, data = %x\n", addr, data); timeout = (int64_t) time_map[data & 0xF] * get_ticks_per_sec(); - qemu_mod_timer(timer, qemu_get_clock (vm_clock) + timeout); + qemu_mod_timer(s->timer, qemu_get_clock (vm_clock) + timeout); } /* A write (of any value) to this register disables the timer. */ static void ib700_write_disable_reg(void *vp, uint32_t addr, uint32_t data) { + IB700State *s = vp; + ib700_debug("addr = %x, data = %x\n", addr, data); - qemu_del_timer(timer); + qemu_del_timer(s->timer); } /* This is called when the watchdog expires. */ static void ib700_timer_expired(void *vp) { + IB700State *s = vp; + ib700_debug("watchdog expired\n"); watchdog_perform_action(); - qemu_del_timer(timer); + qemu_del_timer(s->timer); } static void ib700_save(QEMUFile *f, void *vp) { - qemu_put_timer(f, timer); + IB700State *s = vp; + + qemu_put_timer(f, s->timer); } static int ib700_load(QEMUFile *f, void *vp, int version) { + IB700State *s = vp; + if (version != 0) return -EINVAL; - qemu_get_timer(f, timer); + qemu_get_timer(f, s->timer); return 0; } @@ -96,7 +105,7 @@ static int wdt_ib700_init(ISADevice *dev) { IB700State *s = DO_UPCAST(IB700State, dev, dev); - timer = qemu_new_timer(vm_clock, ib700_timer_expired, s); + s->timer = qemu_new_timer(vm_clock, ib700_timer_expired, s); register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, s); register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, s); register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, s);