Skip to contentSkip to conversation

serial.c: Add support for [load|save]vm

Qemu-devel Vincent Pelletier 2 participants 3 messages Nov 5, 2005

lore
Share & tools
lore
#0 lore raw

Hi.

I posted it on the forum, but as I prefer mailing lists, I post it here. (btw : it tok about one hour for the ML "registration" confirmation message to came in my mailbox, that's why I posted on the forum first)

2005-11-05 Vincent Pelletier <[email protected]>

* hw/serial.c (serial_save, serial_load): New functions. (serial_init): Register added functions in savevm system.

Vincent Pelletier

Index: hw/serial.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/serial.c,v
retrieving revision 1.7

serial.c +37 -0
diff -u -p -r1.7 serial.c
@@ -258,6 +258,41 @@ static void serial_event(void *opaque, i
         serial_receive_break(s);
 }
 
+static void serial_save(QEMUFile *f, void *opaque)
+{
+    SerialState *s = opaque;
+
+    qemu_put_8s(f,&s->divider);
+    qemu_put_8s(f,&s->rbr);
+    qemu_put_8s(f,&s->ier);
+    qemu_put_8s(f,&s->iir);
+    qemu_put_8s(f,&s->lcr);
+    qemu_put_8s(f,&s->mcr);
+    qemu_put_8s(f,&s->lsr);
+    qemu_put_8s(f,&s->msr);
+    qemu_put_8s(f,&s->scr);
+}
+
+static int serial_load(QEMUFile *f, void *opaque, int version_id)
+{
+    SerialState *s = opaque;
+
+    if(version_id != 1)
+        return -EINVAL;
+
+    qemu_get_8s(f,&s->divider);
+    qemu_get_8s(f,&s->rbr);
+    qemu_get_8s(f,&s->ier);
+    qemu_get_8s(f,&s->iir);
+    qemu_get_8s(f,&s->lcr);
+    qemu_get_8s(f,&s->mcr);
+    qemu_get_8s(f,&s->lsr);
+    qemu_get_8s(f,&s->msr);
+    qemu_get_8s(f,&s->scr);
+
+    return 0;
+}
+
 /* If fd is zero, it means that the serial device uses the console */
 SerialState *serial_init(int base, int irq, CharDriverState *chr)
 {
@@ -269,6 +304,8 @@ SerialState *serial_init(int base, int i
     s->irq = irq;
     s->lsr = UART_LSR_TEMT | UART_LSR_THRE;
     s->iir = UART_IIR_NO_INT;
+
+    register_savevm("serial", base, 1, serial_save, serial_load, s);
 
     register_ioport_write(base, 8, 1, serial_ioport_write, s);
     register_ioport_read(base, 8, 1, serial_ioport_read, s);
#1 lore raw
Quoted 6 lines · Vincent Pelletier

Hi.

I posted it on the forum, but as I prefer mailing lists, I post it here. (btw : it tok about one hour for the ML "registration" confirmation message to came in my mailbox, that's why I posted on the forum first)

Quoted 8 lines

2005-11-05 Vincent Pelletier <[email protected]>

* hw/serial.c (serial_save, serial_load): New functions. (serial_init): Register added functions in savevm system.

Vincent Pelletier
plain text document attachment (serial.c.diff)
Index: hw/serial.c

What does it do? I'm guessing saving/restoring the virtual serial port device state?

-- John.

#2 lore raw
Quoted 2 lines · John R. Hogerhuis

What does it do? I'm guessing saving/restoring the virtual serial port device state?

Yes. It adds the 2 needed functions and register them with the saving/loading system.

Vincent Pelletier