提交 3fbc1c0c 编写于 作者: J Jan Kiszka 提交者: Avi Kivity

i8254: Open-code timer restore

Same as for the APIC: To enable migration between accelerated and
non-accelerated models, we need to arm the channel 0 timer only inside
the emulated PIT model. The common code just saves/restores that timer
to the the next_transition_time field.
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 d11e859e
...@@ -300,6 +300,17 @@ static const MemoryRegionOps pit_ioport_ops = { ...@@ -300,6 +300,17 @@ static const MemoryRegionOps pit_ioport_ops = {
.old_portio = pit_portio .old_portio = pit_portio
}; };
static void pit_post_load(PITCommonState *s)
{
PITChannelState *sc = &s->channels[0];
if (sc->next_transition_time != -1) {
qemu_mod_timer(sc->irq_timer, sc->next_transition_time);
} else {
qemu_del_timer(sc->irq_timer);
}
}
static int pit_initfn(PITCommonState *pit) static int pit_initfn(PITCommonState *pit)
{ {
PITChannelState *s; PITChannelState *s;
...@@ -329,6 +340,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data) ...@@ -329,6 +340,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data)
k->init = pit_initfn; k->init = pit_initfn;
k->set_channel_gate = pit_set_channel_gate; k->set_channel_gate = pit_set_channel_gate;
k->get_channel_info = pit_get_channel_info_common; k->get_channel_info = pit_get_channel_info_common;
k->post_load = pit_post_load;
dc->reset = pit_reset; dc->reset = pit_reset;
dc->props = pit_properties; dc->props = pit_properties;
} }
......
...@@ -211,6 +211,7 @@ static const VMStateDescription vmstate_pit_channel = { ...@@ -211,6 +211,7 @@ static const VMStateDescription vmstate_pit_channel = {
static int pit_load_old(QEMUFile *f, void *opaque, int version_id) static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
{ {
PITCommonState *pit = opaque; PITCommonState *pit = opaque;
PITCommonClass *c = PIT_COMMON_GET_CLASS(pit);
PITChannelState *s; PITChannelState *s;
int i; int i;
...@@ -234,11 +235,13 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id) ...@@ -234,11 +235,13 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
qemu_get_8s(f, &s->gate); qemu_get_8s(f, &s->gate);
s->count_load_time = qemu_get_be64(f); s->count_load_time = qemu_get_be64(f);
s->irq_disabled = 0; s->irq_disabled = 0;
if (s->irq_timer) { if (i == 0) {
s->next_transition_time = qemu_get_be64(f); s->next_transition_time = qemu_get_be64(f);
qemu_get_timer(f, s->irq_timer);
} }
} }
if (c->post_load) {
c->post_load(pit);
}
return 0; return 0;
} }
...@@ -275,7 +278,8 @@ static const VMStateDescription vmstate_pit_common = { ...@@ -275,7 +278,8 @@ static const VMStateDescription vmstate_pit_common = {
VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3), VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2, VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
vmstate_pit_channel, PITChannelState), vmstate_pit_channel, PITChannelState),
VMSTATE_TIMER(channels[0].irq_timer, PITCommonState), VMSTATE_INT64(channels[0].next_transition_time,
PITCommonState), /* formerly irq_timer */
VMSTATE_END_OF_LIST() VMSTATE_END_OF_LIST()
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册