diff options
author | Juan Quintela <quintela@redhat.com> | 2009-10-15 00:54:28 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-27 12:28:48 -0500 |
commit | e8f27c728cb3a9b98f5e6f65bcafee0fe565698e (patch) | |
tree | 214dbd2a8cbdf73f4910213694907e20a4d487b8 /hw/wdt_ib700.c | |
parent | f309270bee241bbf83fc2a1a7acf0abb37debf85 (diff) |
ib700: move timer to IB700State
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/wdt_ib700.c')
-rw-r--r-- | 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 e598df5381..d2b9b4199b 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); |