aboutsummaryrefslogtreecommitdiff
path: root/hw/hpet.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-09-10 03:04:45 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-09-11 11:10:09 -0500
commite6cb4d4589058c61093e292a79aa44bd5b44927c (patch)
treef1e5b3bd87dee2dfe8914bacfe21a0b0158ca8f8 /hw/hpet.c
parent67f0875ebc3197fc28a52fb71092f8ec519471ff (diff)
downloadqemu-e6cb4d4589058c61093e292a79aa44bd5b44927c.zip
qemu-e6cb4d4589058c61093e292a79aa44bd5b44927c.tar.gz
qemu-e6cb4d4589058c61093e292a79aa44bd5b44927c.tar.bz2
vmstate: port hpet device
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/hpet.c')
-rw-r--r--hw/hpet.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/hw/hpet.c b/hw/hpet.c
index 98a769e..c1ead34 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -157,53 +157,56 @@ static void update_irq(struct HPETTimer *timer)
}
}
-static void hpet_save(QEMUFile *f, void *opaque)
+static void hpet_pre_save(const void *opaque)
{
- HPETState *s = opaque;
- int i;
- qemu_put_be64s(f, &s->config);
- qemu_put_be64s(f, &s->isr);
+ HPETState *s = (void *)opaque;
/* save current counter value */
s->hpet_counter = hpet_get_ticks();
- qemu_put_be64s(f, &s->hpet_counter);
-
- for (i = 0; i < HPET_NUM_TIMERS; i++) {
- qemu_put_8s(f, &s->timer[i].tn);
- qemu_put_be64s(f, &s->timer[i].config);
- qemu_put_be64s(f, &s->timer[i].cmp);
- qemu_put_be64s(f, &s->timer[i].fsb);
- qemu_put_be64s(f, &s->timer[i].period);
- qemu_put_8s(f, &s->timer[i].wrap_flag);
- qemu_put_timer(f, s->timer[i].qemu_timer);
- }
}
-static int hpet_load(QEMUFile *f, void *opaque, int version_id)
+static int hpet_post_load(void *opaque)
{
HPETState *s = opaque;
- int i;
- if (version_id != 1)
- return -EINVAL;
-
- qemu_get_be64s(f, &s->config);
- qemu_get_be64s(f, &s->isr);
- qemu_get_be64s(f, &s->hpet_counter);
/* Recalculate the offset between the main counter and guest time */
s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_get_clock(vm_clock);
-
- for (i = 0; i < HPET_NUM_TIMERS; i++) {
- qemu_get_8s(f, &s->timer[i].tn);
- qemu_get_be64s(f, &s->timer[i].config);
- qemu_get_be64s(f, &s->timer[i].cmp);
- qemu_get_be64s(f, &s->timer[i].fsb);
- qemu_get_be64s(f, &s->timer[i].period);
- qemu_get_8s(f, &s->timer[i].wrap_flag);
- qemu_get_timer(f, s->timer[i].qemu_timer);
- }
return 0;
}
+static const VMStateDescription vmstate_hpet_timer = {
+ .name = "hpet_timer",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT8(tn, HPETTimer),
+ VMSTATE_UINT64(config, HPETTimer),
+ VMSTATE_UINT64(cmp, HPETTimer),
+ VMSTATE_UINT64(fsb, HPETTimer),
+ VMSTATE_UINT64(period, HPETTimer),
+ VMSTATE_UINT8(wrap_flag, HPETTimer),
+ VMSTATE_TIMER(qemu_timer, HPETTimer),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static const VMStateDescription vmstate_hpet = {
+ .name = "hpet",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .pre_save = hpet_pre_save,
+ .post_load = hpet_post_load,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT64(config, HPETState),
+ VMSTATE_UINT64(isr, HPETState),
+ VMSTATE_UINT64(hpet_counter, HPETState),
+ VMSTATE_STRUCT_ARRAY(timer, HPETState, HPET_NUM_TIMERS, 0,
+ vmstate_hpet_timer, HPETTimer),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
/*
* timer expiration callback
*/
@@ -575,7 +578,7 @@ void hpet_init(qemu_irq *irq) {
timer->qemu_timer = qemu_new_timer(vm_clock, hpet_timer, timer);
}
hpet_reset(s);
- register_savevm("hpet", -1, 1, hpet_save, hpet_load, s);
+ vmstate_register(-1, &vmstate_hpet, s);
qemu_register_reset(hpet_reset, s);
/* HPET Area */
iomemtype = cpu_register_io_memory(hpet_ram_read,