X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=hw%2Fmax111x.c;h=8425bee576ae1e148b0d11525aaa6385758af3fd;hb=cd346349b45ef056f138a184f660b8c34c3213cc;hp=69019de7a270cc56bfe7debacde102b5d08b7a4b;hpb=c824cacdb1aa8bfd9e057dd64b4b8a16f5727fff;p=qemu diff --git a/hw/max111x.c b/hw/max111x.c index 69019de..8425bee 100644 --- a/hw/max111x.c +++ b/hw/max111x.c @@ -89,6 +89,39 @@ void max111x_write(void *opaque, uint32_t value) qemu_irq_raise(s->interrupt); } +static void max111x_save(QEMUFile *f, void *opaque) +{ + struct max111x_s *s = (struct max111x_s *) opaque; + int i; + + qemu_put_8s(f, &s->tb1); + qemu_put_8s(f, &s->rb2); + qemu_put_8s(f, &s->rb3); + qemu_put_be32(f, s->inputs); + qemu_put_be32(f, s->com); + for (i = 0; i < s->inputs; i ++) + qemu_put_byte(f, s->input[i]); +} + +static int max111x_load(QEMUFile *f, void *opaque, int version_id) +{ + struct max111x_s *s = (struct max111x_s *) opaque; + int i; + + qemu_get_8s(f, &s->tb1); + qemu_get_8s(f, &s->rb2); + qemu_get_8s(f, &s->rb3); + if (s->inputs != qemu_get_be32(f)) + return -EINVAL; + s->com = qemu_get_be32(f); + for (i = 0; i < s->inputs; i ++) + s->input[i] = qemu_get_byte(f); + + return 0; +} + +static int max111x_iid = 0; + static struct max111x_s *max111x_init(qemu_irq cb) { struct max111x_s *s; @@ -108,6 +141,10 @@ static struct max111x_s *max111x_init(qemu_irq cb) s->input[6] = 0x90; s->input[7] = 0x80; s->com = 0; + + register_savevm("max111x", max111x_iid ++, 0, + max111x_save, max111x_load, s); + return s; }