mirror of https://github.com/xqemu/xqemu.git
ib700: move timer to IB700State
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
f309270bee
commit
e8f27c728c
|
@ -37,17 +37,18 @@
|
||||||
|
|
||||||
typedef struct IB700state {
|
typedef struct IB700state {
|
||||||
ISADevice dev;
|
ISADevice dev;
|
||||||
|
QEMUTimer *timer;
|
||||||
} IB700State;
|
} IB700State;
|
||||||
|
|
||||||
/* This is the timer. We use a global here because the watchdog
|
/* 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,
|
* code ensures there is only one watchdog (it is located at a fixed,
|
||||||
* unchangable IO port, so there could only ever be one anyway).
|
* unchangable IO port, so there could only ever be one anyway).
|
||||||
*/
|
*/
|
||||||
static QEMUTimer *timer = NULL;
|
|
||||||
|
|
||||||
/* A write to this register enables the timer. */
|
/* A write to this register enables the timer. */
|
||||||
static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data)
|
static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data)
|
||||||
{
|
{
|
||||||
|
IB700State *s = vp;
|
||||||
static int time_map[] = {
|
static int time_map[] = {
|
||||||
30, 28, 26, 24, 22, 20, 18, 16,
|
30, 28, 26, 24, 22, 20, 18, 16,
|
||||||
14, 12, 10, 8, 6, 4, 2, 0
|
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);
|
ib700_debug("addr = %x, data = %x\n", addr, data);
|
||||||
|
|
||||||
timeout = (int64_t) time_map[data & 0xF] * get_ticks_per_sec();
|
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. */
|
/* 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)
|
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);
|
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. */
|
/* This is called when the watchdog expires. */
|
||||||
static void ib700_timer_expired(void *vp)
|
static void ib700_timer_expired(void *vp)
|
||||||
{
|
{
|
||||||
|
IB700State *s = vp;
|
||||||
|
|
||||||
ib700_debug("watchdog expired\n");
|
ib700_debug("watchdog expired\n");
|
||||||
|
|
||||||
watchdog_perform_action();
|
watchdog_perform_action();
|
||||||
qemu_del_timer(timer);
|
qemu_del_timer(s->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ib700_save(QEMUFile *f, void *vp)
|
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)
|
static int ib700_load(QEMUFile *f, void *vp, int version)
|
||||||
{
|
{
|
||||||
|
IB700State *s = vp;
|
||||||
|
|
||||||
if (version != 0)
|
if (version != 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
qemu_get_timer(f, timer);
|
qemu_get_timer(f, s->timer);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +105,7 @@ static int wdt_ib700_init(ISADevice *dev)
|
||||||
{
|
{
|
||||||
IB700State *s = DO_UPCAST(IB700State, dev, 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_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, s);
|
||||||
register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, s);
|
register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, s);
|
||||||
register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, s);
|
register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, s);
|
||||||
|
|
Loading…
Reference in New Issue