Revision 6b075b8a hw/mc146818rtc.c
b/hw/mc146818rtc.c | ||
---|---|---|
501 | 501 |
rtc_set_memory(s, REG_IBM_PS2_CENTURY_BYTE, val); |
502 | 502 |
} |
503 | 503 |
|
504 |
static void rtc_save(QEMUFile *f, void *opaque) |
|
505 |
{ |
|
506 |
RTCState *s = opaque; |
|
507 |
|
|
508 |
qemu_put_buffer(f, s->cmos_data, 128); |
|
509 |
qemu_put_8s(f, &s->cmos_index); |
|
510 |
|
|
511 |
qemu_put_be32(f, s->current_tm.tm_sec); |
|
512 |
qemu_put_be32(f, s->current_tm.tm_min); |
|
513 |
qemu_put_be32(f, s->current_tm.tm_hour); |
|
514 |
qemu_put_be32(f, s->current_tm.tm_wday); |
|
515 |
qemu_put_be32(f, s->current_tm.tm_mday); |
|
516 |
qemu_put_be32(f, s->current_tm.tm_mon); |
|
517 |
qemu_put_be32(f, s->current_tm.tm_year); |
|
518 |
|
|
519 |
qemu_put_timer(f, s->periodic_timer); |
|
520 |
qemu_put_be64(f, s->next_periodic_time); |
|
521 |
|
|
522 |
qemu_put_be64(f, s->next_second_time); |
|
523 |
qemu_put_timer(f, s->second_timer); |
|
524 |
qemu_put_timer(f, s->second_timer2); |
|
525 |
qemu_put_be32(f, s->irq_coalesced); |
|
526 |
qemu_put_be32(f, s->period); |
|
527 |
} |
|
528 |
|
|
529 |
static int rtc_load(QEMUFile *f, void *opaque, int version_id) |
|
504 |
static int rtc_post_load(void *opaque, int version_id) |
|
530 | 505 |
{ |
506 |
#ifdef TARGET_I386 |
|
531 | 507 |
RTCState *s = opaque; |
532 | 508 |
|
533 |
if (version_id < 1 || version_id > 2) |
|
534 |
return -EINVAL; |
|
535 |
|
|
536 |
qemu_get_buffer(f, s->cmos_data, 128); |
|
537 |
qemu_get_8s(f, &s->cmos_index); |
|
538 |
|
|
539 |
s->current_tm.tm_sec=qemu_get_be32(f); |
|
540 |
s->current_tm.tm_min=qemu_get_be32(f); |
|
541 |
s->current_tm.tm_hour=qemu_get_be32(f); |
|
542 |
s->current_tm.tm_wday=qemu_get_be32(f); |
|
543 |
s->current_tm.tm_mday=qemu_get_be32(f); |
|
544 |
s->current_tm.tm_mon=qemu_get_be32(f); |
|
545 |
s->current_tm.tm_year=qemu_get_be32(f); |
|
546 |
|
|
547 |
qemu_get_timer(f, s->periodic_timer); |
|
548 |
s->next_periodic_time=qemu_get_be64(f); |
|
549 |
|
|
550 |
s->next_second_time=qemu_get_be64(f); |
|
551 |
qemu_get_timer(f, s->second_timer); |
|
552 |
qemu_get_timer(f, s->second_timer2); |
|
553 |
|
|
554 | 509 |
if (version_id >= 2) { |
555 |
s->irq_coalesced = qemu_get_be32(f); |
|
556 |
s->period = qemu_get_be32(f); |
|
557 |
#ifdef TARGET_I386 |
|
558 | 510 |
if (rtc_td_hack) { |
559 | 511 |
rtc_coalesced_timer_update(s); |
560 | 512 |
} |
561 |
#endif |
|
562 | 513 |
} |
514 |
#endif |
|
563 | 515 |
return 0; |
564 | 516 |
} |
565 | 517 |
|
518 |
static const VMStateDescription vmstate_rtc = { |
|
519 |
.name = "mc146818rtc", |
|
520 |
.version_id = 2, |
|
521 |
.minimum_version_id = 1, |
|
522 |
.minimum_version_id_old = 1, |
|
523 |
.post_load = rtc_post_load, |
|
524 |
.fields = (VMStateField []) { |
|
525 |
VMSTATE_BUFFER(cmos_data, RTCState), |
|
526 |
VMSTATE_UINT8(cmos_index, RTCState), |
|
527 |
VMSTATE_INT32(current_tm.tm_sec, RTCState), |
|
528 |
VMSTATE_INT32(current_tm.tm_min, RTCState), |
|
529 |
VMSTATE_INT32(current_tm.tm_hour, RTCState), |
|
530 |
VMSTATE_INT32(current_tm.tm_wday, RTCState), |
|
531 |
VMSTATE_INT32(current_tm.tm_mday, RTCState), |
|
532 |
VMSTATE_INT32(current_tm.tm_mon, RTCState), |
|
533 |
VMSTATE_INT32(current_tm.tm_year, RTCState), |
|
534 |
VMSTATE_TIMER(periodic_timer, RTCState), |
|
535 |
VMSTATE_INT64(next_periodic_time, RTCState), |
|
536 |
VMSTATE_INT64(next_second_time, RTCState), |
|
537 |
VMSTATE_TIMER(second_timer, RTCState), |
|
538 |
VMSTATE_TIMER(second_timer2, RTCState), |
|
539 |
VMSTATE_UINT32_V(irq_coalesced, RTCState, 2), |
|
540 |
VMSTATE_UINT32_V(period, RTCState, 2), |
|
541 |
VMSTATE_END_OF_LIST() |
|
542 |
} |
|
543 |
}; |
|
544 |
|
|
566 | 545 |
static void rtc_reset(void *opaque) |
567 | 546 |
{ |
568 | 547 |
RTCState *s = opaque; |
... | ... | |
609 | 588 |
register_ioport_write(base, 2, 1, cmos_ioport_write, s); |
610 | 589 |
register_ioport_read(base, 2, 1, cmos_ioport_read, s); |
611 | 590 |
|
612 |
register_savevm("mc146818rtc", base, 2, rtc_save, rtc_load, s);
|
|
591 |
vmstate_register(base, &vmstate_rtc, s);
|
|
613 | 592 |
qemu_register_reset(rtc_reset, s); |
614 | 593 |
return 0; |
615 | 594 |
} |
... | ... | |
741 | 720 |
io_memory = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s); |
742 | 721 |
cpu_register_physical_memory(base, 2 << it_shift, io_memory); |
743 | 722 |
|
744 |
register_savevm("mc146818rtc", base, 2, rtc_save, rtc_load, s);
|
|
723 |
vmstate_register(base, &vmstate_rtc, s);
|
|
745 | 724 |
qemu_register_reset(rtc_reset, s); |
746 | 725 |
return s; |
747 | 726 |
} |
Also available in: Unified diff