From 8738a8d079b661a612e89612844dc270ef5f0924 Mon Sep 17 00:00:00 2001 From: bellard Date: Sun, 6 Nov 2005 15:48:04 +0000 Subject: serial load/save VM support (Vincent Pelletier) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1602 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/serial.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'hw') diff --git a/hw/serial.c b/hw/serial.c index 3fe482c391..ac04e65225 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -258,6 +258,41 @@ static void serial_event(void *opaque, int event) 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) { @@ -270,6 +305,8 @@ SerialState *serial_init(int base, int irq, CharDriverState *chr) 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); s->chr = chr; -- cgit v1.2.3