From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQmtk-0007Vx-Lz for qemu-devel@nongnu.org; Sat, 24 Jan 2009 13:06:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQmtj-0007Vl-07 for qemu-devel@nongnu.org; Sat, 24 Jan 2009 13:06:23 -0500 Received: from [199.232.76.173] (port=49209 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQmti-0007Vi-QV for qemu-devel@nongnu.org; Sat, 24 Jan 2009 13:06:22 -0500 Received: from savannah.gnu.org ([199.232.41.3]:46488 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LQmti-0008Ty-Cn for qemu-devel@nongnu.org; Sat, 24 Jan 2009 13:06:22 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LQmth-0007p4-RB for qemu-devel@nongnu.org; Sat, 24 Jan 2009 18:06:21 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LQmth-0007p0-Io for qemu-devel@nongnu.org; Sat, 24 Jan 2009 18:06:21 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sat, 24 Jan 2009 18:06:21 +0000 Subject: [Qemu-devel] [6429] Support epoch of 1980 in RTC emulation for MIPS Magnum Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6429 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6429 Author: aurel32 Date: 2009-01-24 18:06:21 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Support epoch of 1980 in RTC emulation for MIPS Magnum On the MIPS Magnum, the time that is held in the RTC's NVRAM should be relative to midnight on 1980-01-01. This patch adds an extra parameter to rtc_init(), allowing different epochs to be used. For the Magnum, 1980 is specified, and for all other machines, 2000 is specified. I've not modified the handling of the century byte, as with an epoch of 1980 and a year of 2009, one could argue that it should hold either 0, 1, 19 or 20. NT 3.50 on MIPS does not read the century byte. Signed-off-by: Stuart Brady Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/hw/mc146818rtc.c trunk/hw/mips_jazz.c trunk/hw/mips_malta.c trunk/hw/mips_r4k.c trunk/hw/pc.c trunk/hw/pc.h trunk/hw/ppc_prep.c Modified: trunk/hw/mc146818rtc.c =================================================================== --- trunk/hw/mc146818rtc.c 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/mc146818rtc.c 2009-01-24 18:06:21 UTC (rev 6429) @@ -60,6 +60,7 @@ uint8_t cmos_data[128]; uint8_t cmos_index; struct tm current_tm; + int base_year; qemu_irq irq; int it_shift; /* periodic timer */ @@ -235,12 +236,13 @@ tm->tm_wday = from_bcd(s, s->cmos_data[RTC_DAY_OF_WEEK]) - 1; tm->tm_mday = from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]); tm->tm_mon = from_bcd(s, s->cmos_data[RTC_MONTH]) - 1; - tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + 100; + tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + s->base_year - 1900; } static void rtc_copy_date(RTCState *s) { const struct tm *tm = &s->current_tm; + int year; s->cmos_data[RTC_SECONDS] = to_bcd(s, tm->tm_sec); s->cmos_data[RTC_MINUTES] = to_bcd(s, tm->tm_min); @@ -256,7 +258,10 @@ s->cmos_data[RTC_DAY_OF_WEEK] = to_bcd(s, tm->tm_wday + 1); s->cmos_data[RTC_DAY_OF_MONTH] = to_bcd(s, tm->tm_mday); s->cmos_data[RTC_MONTH] = to_bcd(s, tm->tm_mon + 1); - s->cmos_data[RTC_YEAR] = to_bcd(s, tm->tm_year % 100); + year = (tm->tm_year - s->base_year) % 100; + if (year < 0) + year += 100; + s->cmos_data[RTC_YEAR] = to_bcd(s, year); } /* month is between 0 and 11. */ @@ -522,7 +527,7 @@ } #endif -RTCState *rtc_init(int base, qemu_irq irq) +RTCState *rtc_init(int base, qemu_irq irq, int base_year) { RTCState *s; @@ -536,6 +541,7 @@ s->cmos_data[RTC_REG_C] = 0x00; s->cmos_data[RTC_REG_D] = 0x80; + s->base_year = base_year; rtc_set_date_from_host(s); s->periodic_timer = qemu_new_timer(vm_clock, @@ -631,7 +637,8 @@ &cmos_mm_writel, }; -RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq) +RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, + int base_year) { RTCState *s; int io_memory; @@ -646,6 +653,7 @@ s->cmos_data[RTC_REG_C] = 0x00; s->cmos_data[RTC_REG_D] = 0x80; + s->base_year = base_year; rtc_set_date_from_host(s); s->periodic_timer = qemu_new_timer(vm_clock, Modified: trunk/hw/mips_jazz.c =================================================================== --- trunk/hw/mips_jazz.c 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/mips_jazz.c 2009-01-24 18:06:21 UTC (rev 6429) @@ -241,7 +241,7 @@ fdctrl_init(rc4030[1], 0, 1, 0x80003000, fds); /* Real time clock */ - rtc_init(0x70, i8259[8]); + rtc_init(0x70, i8259[8], 1980); s_rtc = cpu_register_io_memory(0, rtc_read, rtc_write, env); cpu_register_physical_memory(0x80004000, 0x00001000, s_rtc); Modified: trunk/hw/mips_malta.c =================================================================== --- trunk/hw/mips_malta.c 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/mips_malta.c 2009-01-24 18:06:21 UTC (rev 6429) @@ -918,7 +918,7 @@ /* Super I/O */ i8042_init(i8259[1], i8259[12], 0x60); - rtc_state = rtc_init(0x70, i8259[8]); + rtc_state = rtc_init(0x70, i8259[8], 2000); serial_init(0x3f8, i8259[4], 115200, serial_hds[0]); serial_init(0x2f8, i8259[3], 115200, serial_hds[1]); if (parallel_hds[0]) Modified: trunk/hw/mips_r4k.c =================================================================== --- trunk/hw/mips_r4k.c 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/mips_r4k.c 2009-01-24 18:06:21 UTC (rev 6429) @@ -235,7 +235,7 @@ /* The PIC is attached to the MIPS CPU INT0 pin */ i8259 = i8259_init(env->irq[2]); - rtc_state = rtc_init(0x70, i8259[8]); + rtc_state = rtc_init(0x70, i8259[8], 2000); /* Register 64 KB of ISA IO space at 0x14000000 */ isa_mmio_init(0x14000000, 0x00010000); Modified: trunk/hw/pc.c =================================================================== --- trunk/hw/pc.c 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/pc.c 2009-01-24 18:06:21 UTC (rev 6429) @@ -968,7 +968,7 @@ } } - rtc_state = rtc_init(0x70, i8259[8]); + rtc_state = rtc_init(0x70, i8259[8], 2000); qemu_register_boot_set(pc_boot_set, rtc_state); Modified: trunk/hw/pc.h =================================================================== --- trunk/hw/pc.h 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/pc.h 2009-01-24 18:06:21 UTC (rev 6429) @@ -83,8 +83,9 @@ typedef struct RTCState RTCState; -RTCState *rtc_init(int base, qemu_irq irq); -RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq); +RTCState *rtc_init(int base, qemu_irq irq, int base_year); +RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, + int base_year); void rtc_set_memory(RTCState *s, int addr, int val); void rtc_set_date(RTCState *s, const struct tm *tm); void cmos_set_s3_resume(void); Modified: trunk/hw/ppc_prep.c =================================================================== --- trunk/hw/ppc_prep.c 2009-01-24 16:37:31 UTC (rev 6428) +++ trunk/hw/ppc_prep.c 2009-01-24 18:06:21 UTC (rev 6429) @@ -659,7 +659,7 @@ vga_ram_size, 0, 0); // openpic = openpic_init(0x00000000, 0xF0000000, 1); // pit = pit_init(0x40, i8259[0]); - rtc_init(0x70, i8259[8]); + rtc_init(0x70, i8259[8], 2000); serial_init(0x3f8, i8259[4], 115200, serial_hds[0]); nb_nics1 = nb_nics;