Revision 42fc73a1 hw/mc146818rtc.c
b/hw/mc146818rtc.c | ||
---|---|---|
60 | 60 |
uint8_t cmos_data[128]; |
61 | 61 |
uint8_t cmos_index; |
62 | 62 |
struct tm current_tm; |
63 |
int base_year; |
|
63 | 64 |
qemu_irq irq; |
64 | 65 |
int it_shift; |
65 | 66 |
/* periodic timer */ |
... | ... | |
235 | 236 |
tm->tm_wday = from_bcd(s, s->cmos_data[RTC_DAY_OF_WEEK]) - 1; |
236 | 237 |
tm->tm_mday = from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]); |
237 | 238 |
tm->tm_mon = from_bcd(s, s->cmos_data[RTC_MONTH]) - 1; |
238 |
tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + 100;
|
|
239 |
tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + s->base_year - 1900;
|
|
239 | 240 |
} |
240 | 241 |
|
241 | 242 |
static void rtc_copy_date(RTCState *s) |
242 | 243 |
{ |
243 | 244 |
const struct tm *tm = &s->current_tm; |
245 |
int year; |
|
244 | 246 |
|
245 | 247 |
s->cmos_data[RTC_SECONDS] = to_bcd(s, tm->tm_sec); |
246 | 248 |
s->cmos_data[RTC_MINUTES] = to_bcd(s, tm->tm_min); |
... | ... | |
256 | 258 |
s->cmos_data[RTC_DAY_OF_WEEK] = to_bcd(s, tm->tm_wday + 1); |
257 | 259 |
s->cmos_data[RTC_DAY_OF_MONTH] = to_bcd(s, tm->tm_mday); |
258 | 260 |
s->cmos_data[RTC_MONTH] = to_bcd(s, tm->tm_mon + 1); |
259 |
s->cmos_data[RTC_YEAR] = to_bcd(s, tm->tm_year % 100); |
|
261 |
year = (tm->tm_year - s->base_year) % 100; |
|
262 |
if (year < 0) |
|
263 |
year += 100; |
|
264 |
s->cmos_data[RTC_YEAR] = to_bcd(s, year); |
|
260 | 265 |
} |
261 | 266 |
|
262 | 267 |
/* month is between 0 and 11. */ |
... | ... | |
522 | 527 |
} |
523 | 528 |
#endif |
524 | 529 |
|
525 |
RTCState *rtc_init(int base, qemu_irq irq) |
|
530 |
RTCState *rtc_init(int base, qemu_irq irq, int base_year)
|
|
526 | 531 |
{ |
527 | 532 |
RTCState *s; |
528 | 533 |
|
... | ... | |
536 | 541 |
s->cmos_data[RTC_REG_C] = 0x00; |
537 | 542 |
s->cmos_data[RTC_REG_D] = 0x80; |
538 | 543 |
|
544 |
s->base_year = base_year; |
|
539 | 545 |
rtc_set_date_from_host(s); |
540 | 546 |
|
541 | 547 |
s->periodic_timer = qemu_new_timer(vm_clock, |
... | ... | |
631 | 637 |
&cmos_mm_writel, |
632 | 638 |
}; |
633 | 639 |
|
634 |
RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq) |
|
640 |
RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, |
|
641 |
int base_year) |
|
635 | 642 |
{ |
636 | 643 |
RTCState *s; |
637 | 644 |
int io_memory; |
... | ... | |
646 | 653 |
s->cmos_data[RTC_REG_C] = 0x00; |
647 | 654 |
s->cmos_data[RTC_REG_D] = 0x80; |
648 | 655 |
|
656 |
s->base_year = base_year; |
|
649 | 657 |
rtc_set_date_from_host(s); |
650 | 658 |
|
651 | 659 |
s->periodic_timer = qemu_new_timer(vm_clock, |
Also available in: Unified diff