Commit 8738a8d079b661a612e89612844dc270ef5f0924
1 parent
c0fe3827
serial load/save VM support (Vincent Pelletier)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1602 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
37 additions
and
0 deletions
hw/serial.c
... | ... | @@ -258,6 +258,41 @@ static void serial_event(void *opaque, int event) |
258 | 258 | serial_receive_break(s); |
259 | 259 | } |
260 | 260 | |
261 | +static void serial_save(QEMUFile *f, void *opaque) | |
262 | +{ | |
263 | + SerialState *s = opaque; | |
264 | + | |
265 | + qemu_put_8s(f,&s->divider); | |
266 | + qemu_put_8s(f,&s->rbr); | |
267 | + qemu_put_8s(f,&s->ier); | |
268 | + qemu_put_8s(f,&s->iir); | |
269 | + qemu_put_8s(f,&s->lcr); | |
270 | + qemu_put_8s(f,&s->mcr); | |
271 | + qemu_put_8s(f,&s->lsr); | |
272 | + qemu_put_8s(f,&s->msr); | |
273 | + qemu_put_8s(f,&s->scr); | |
274 | +} | |
275 | + | |
276 | +static int serial_load(QEMUFile *f, void *opaque, int version_id) | |
277 | +{ | |
278 | + SerialState *s = opaque; | |
279 | + | |
280 | + if(version_id != 1) | |
281 | + return -EINVAL; | |
282 | + | |
283 | + qemu_get_8s(f,&s->divider); | |
284 | + qemu_get_8s(f,&s->rbr); | |
285 | + qemu_get_8s(f,&s->ier); | |
286 | + qemu_get_8s(f,&s->iir); | |
287 | + qemu_get_8s(f,&s->lcr); | |
288 | + qemu_get_8s(f,&s->mcr); | |
289 | + qemu_get_8s(f,&s->lsr); | |
290 | + qemu_get_8s(f,&s->msr); | |
291 | + qemu_get_8s(f,&s->scr); | |
292 | + | |
293 | + return 0; | |
294 | +} | |
295 | + | |
261 | 296 | /* If fd is zero, it means that the serial device uses the console */ |
262 | 297 | SerialState *serial_init(int base, int irq, CharDriverState *chr) |
263 | 298 | { |
... | ... | @@ -270,6 +305,8 @@ SerialState *serial_init(int base, int irq, CharDriverState *chr) |
270 | 305 | s->lsr = UART_LSR_TEMT | UART_LSR_THRE; |
271 | 306 | s->iir = UART_IIR_NO_INT; |
272 | 307 | |
308 | + register_savevm("serial", base, 1, serial_save, serial_load, s); | |
309 | + | |
273 | 310 | register_ioport_write(base, 8, 1, serial_ioport_write, s); |
274 | 311 | register_ioport_read(base, 8, 1, serial_ioport_read, s); |
275 | 312 | s->chr = chr; | ... | ... |