qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/6] ib700: move timer to IB700State


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 5/6] ib700: move timer to IB700State
Date: Thu, 15 Oct 2009 01:40:01 +0200

Signed-off-by: Juan Quintela <address@hidden>
---
 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);
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]