aboutsummaryrefslogtreecommitdiff
path: root/hw/gus.c
diff options
context:
space:
mode:
authormalc <malc@c046a42c-6fe2-441c-8c8c-71466251a162>2008-06-21 17:14:54 +0000
committermalc <malc@c046a42c-6fe2-441c-8c8c-71466251a162>2008-06-21 17:14:54 +0000
commit5b5ef0db745c70d9ba967ea133542be3fc927180 (patch)
tree6fd3d6c41465ac64f264be1863a1393d132c710d /hw/gus.c
parent279a65442eb53e74083b31fa629a10c0ed78e3f0 (diff)
Add VM save/load support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4767 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/gus.c')
-rw-r--r--hw/gus.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/hw/gus.c b/hw/gus.c
index c7a88463f0..d39d918724 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -220,6 +220,40 @@ int GUS_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
return dma_len;
}
+static void GUS_save (QEMUFile *f, void *opaque)
+{
+ int32_t val;
+ GUSState *s = opaque;
+
+ val = s->freq; qemu_put_be32s (f, &val);
+ val = s->pos; qemu_put_be32s (f, &val);
+ val = s->left; qemu_put_be32s (f, &val);
+ val = s->shift; qemu_put_be32s (f, &val);
+ val = s->irqs; qemu_put_be32s (f, &val);
+ val = s->samples; qemu_put_be32s (f, &val);
+ qemu_put_be64s (f, &s->last_ticks);
+ qemu_put_buffer (f, s->himem, sizeof (s->himem));
+}
+
+static int GUS_load (QEMUFile *f, void *opaque, int version_id)
+{
+ int32_t val;
+ GUSState *s = opaque;
+
+ if (version_id != 1)
+ return -EINVAL;
+
+ qemu_get_be32s (f, &val); s->freq = val;
+ qemu_get_be32s (f, &val); s->pos = val;
+ qemu_get_be32s (f, &val); s->left = val;
+ qemu_get_be32s (f, &val); s->shift = val;
+ qemu_get_be32s (f, &val); s->irqs = val;
+ qemu_get_be32s (f, &val); s->samples = val;
+ qemu_get_be64s (f, &s->last_ticks);
+ qemu_get_buffer (f, s->himem, sizeof (s->himem));
+ return 0;
+}
+
int GUS_init (AudioState *audio, qemu_irq *pic)
{
GUSState *s;
@@ -296,5 +330,7 @@ int GUS_init (AudioState *audio, qemu_irq *pic)
s->pic = pic;
AUD_set_active_out (s->voice, 1);
+
+ register_savevm ("gus", 0, 1, GUS_save, GUS_load, s);
return 0;
}