Skip to contentSkip to conversation

Save/load PC speaker internal state

PATCH Jan Kiszka 1 participant 1 message Aug 27, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jan Kiszka

author
#1 lore raw
Quoted 14 lines · Pavel Dovgaluk

Save PC speaker state to remove differences between system states after saving the snapshot and after loading it again. This patch is needed for deterministic replay of the execution.

---
 hw/pcspk.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
hw/pcspk.c +0 -0
index e430324..3fb3dd1 100644

hw/pcspk.c static const MemoryRegionOps pcspk_io_ops = { · line 168

Quoted 10 lines
hw/pcspk.c +7 -0
@@ -159,10 +159,28 @@ static const MemoryRegionOps pcspk_io_ops = {
     },
 };
 
+static const VMStateDescription vmstate_spk = {
+    .name = "pcspk",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_UINT8_ARRAY(sample_buf, PCSpkState, PCSPK_BUF_LEN),

Can be regenerated on load.

hw/pcspk.c static const MemoryRegionOps pcspk_io_ops = { · line 170

Quoted 2 lines
hw/pcspk.c +2 -0
+        VMSTATE_UINT32(pit_count, PCSpkState),
+        VMSTATE_UINT32(samples, PCSpkState),

Same here.

hw/pcspk.c static const MemoryRegionOps pcspk_io_ops = { · line 183

Quoted 13 lines
hw/pcspk.c +9 -0
+        VMSTATE_UINT32(play_pos, PCSpkState),
+        VMSTATE_INT32(data_on, PCSpkState),
+        VMSTATE_INT32(dummy_refresh_clock, PCSpkState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static int pcspk_initfn(ISADevice *dev)
 {
     PCSpkState *s = DO_UPCAST(PCSpkState, dev, dev);
 
+    vmstate_register(NULL, 0, &vmstate_spk, s);
+

This function is for legacy users only. You have to register the vmstate via pcspk_class_initfn (set vmsd of the device class).

hw/pcspk.c static const MemoryRegionOps pcspk_io_ops = { · line 186

Quoted 6 lines
hw/pcspk.c +0 -0
     memory_region_init_io(&s->ioport, &pcspk_io_ops, s, "elcr", 1);
     isa_register_ioport(dev, &s->ioport, s->iobase);
 

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux