From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GmYlE-0000qA-PI for qemu-devel@nongnu.org; Tue, 21 Nov 2006 11:46:16 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GmYl5-0000bX-R3 for qemu-devel@nongnu.org; Tue, 21 Nov 2006 11:46:16 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GmYl5-0000bI-GR for qemu-devel@nongnu.org; Tue, 21 Nov 2006 11:46:07 -0500 Received: from [82.232.2.251] (helo=farad.aurel32.net) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GmYl5-0000By-6y for qemu-devel@nongnu.org; Tue, 21 Nov 2006 11:46:07 -0500 Received: from aurel32 by farad.aurel32.net with local (Exim 4.50) id 1GmYkz-0006ih-3Q for qemu-devel@nongnu.org; Tue, 21 Nov 2006 17:46:01 +0100 Date: Tue, 21 Nov 2006 17:46:01 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH 3/6] A cumulative MIPS patchset Message-ID: <20061121164600.GA25749@farad.aurel32.net> References: <20061121144037.GD12745@networkno.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20061121144037.GD12745@networkno.de> Sender: Aurelien Jarno 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 On Tue, Nov 21, 2006 at 02:40:37PM +0000, Thiemo Seufer wrote: > Hello All, Hi ! > this patch adds more devices to the MIPS system emulation, most > importantly a RTC emulation which e.g. keeps timestamps on a > linux filesystem sane. > I suggest to use the patch below instead. It is based on the patch I posted [1] on the mailing list a few days ago. it moves the initialisation of the RTC date/time into hw/mc146818rtc.c, to avoid duplication of code. I guess all platform using this RTC chip will want to setup at least the date and time. [1] http://lists.gnu.org/archive/html/qemu-devel/2006-11/msg00165.html Index: Makefile.target =================================================================== RCS file: /sources/qemu/qemu/Makefile.target,v retrieving revision 1.132 diff -u -r1.132 Makefile.target --- Makefile.target 29 Oct 2006 15:38:28 -0000 1.132 +++ Makefile.target 21 Nov 2006 16:41:24 -0000 @@ -358,7 +358,8 @@ endif ifeq ($(TARGET_ARCH), mips) VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o ide.o -#VL_OBJS+= #pckbd.o fdc.o m48t59.o +VL_OBJS+= pckbd.o ps2.o mc146818rtc.o +#VL_OBJS+= #fdc.o m48t59.o endif ifeq ($(TARGET_BASE_ARCH), sparc) ifeq ($(TARGET_ARCH), sparc64) Index: hw/mc146818rtc.c =================================================================== RCS file: /sources/qemu/qemu/hw/mc146818rtc.c,v retrieving revision 1.6 diff -u -r1.6 mc146818rtc.c --- hw/mc146818rtc.c 3 Jun 2004 12:51:19 -0000 1.6 +++ hw/mc146818rtc.c 21 Nov 2006 16:41:25 -0000 @@ -380,6 +380,29 @@ rtc_copy_date(s); } +/* PC cmos mappings */ +#define REG_IBM_CENTURY_BYTE 0x32 +#define REG_IBM_PS2_CENTURY_BYTE 0x37 + +void rtc_set_date_from_host(RTCState *s) +{ + time_t ti; + struct tm *tm; + int val; + + /* set the CMOS date */ + time(&ti); + if (rtc_utc) + tm = gmtime(&ti); + else + tm = localtime(&ti); + rtc_set_date(s, tm); + + val = to_bcd(s, (tm->tm_year / 100) + 19); + rtc_set_memory(s, REG_IBM_CENTURY_BYTE, val); + rtc_set_memory(s, REG_IBM_PS2_CENTURY_BYTE, val); +} + static void rtc_save(QEMUFile *f, void *opaque) { RTCState *s = opaque; @@ -444,6 +467,8 @@ s->cmos_data[RTC_REG_C] = 0x00; s->cmos_data[RTC_REG_D] = 0x80; + rtc_set_date_from_host(s); + s->periodic_timer = qemu_new_timer(vm_clock, rtc_periodic_timer, s); s->second_timer = qemu_new_timer(vm_clock, Index: hw/mips_r4k.c =================================================================== RCS file: /sources/qemu/qemu/hw/mips_r4k.c,v retrieving revision 1.21 diff -u -r1.21 mips_r4k.c --- hw/mips_r4k.c 29 Oct 2006 15:38:28 -0000 1.21 +++ hw/mips_r4k.c 21 Nov 2006 16:41:25 -0000 @@ -1,7 +1,8 @@ #include "vl.h" #define BIOS_FILENAME "mips_bios.bin" -//#define BIOS_FILENAME "system.bin" +#define LINUX_BOOT_FILENAME "linux_boot.bin" + #define KERNEL_LOAD_ADDR 0x80010000 #define INITRD_LOAD_ADDR 0x80800000 @@ -13,6 +14,7 @@ extern FILE *logfile; +static RTCState *rtc_state; static PITState *pit; static void pic_irq_request(void *opaque, int level) @@ -184,12 +186,15 @@ cpu_mips_clock_init(env); cpu_mips_irqctrl_init(); + rtc_state = rtc_init(0x70, 8); + /* Register 64 KB of ISA IO space at 0x14000000 */ isa_mmio_init(0x14000000, 0x00010000); isa_mem_base = 0x10000000; isa_pic = pic_init(pic_irq_request, env); pit = pit_init(0x40, 0); + serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]); isa_vga_init(ds, phys_ram_base + ram_size, ram_size, vga_ram_size); @@ -207,6 +212,9 @@ for(i = 0; i < 2; i++) isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], bs_table[2 * i], bs_table[2 * i + 1]); + + kbd_init(); + DMA_init(1); } QEMUMachine mips_machine = { Index: hw/pc.c =================================================================== RCS file: /sources/qemu/qemu/hw/pc.c,v retrieving revision 1.62 diff -u -r1.62 pc.c --- hw/pc.c 24 Sep 2006 18:48:00 -0000 1.62 +++ hw/pc.c 21 Nov 2006 16:41:25 -0000 @@ -111,14 +111,6 @@ /* PC cmos mappings */ #define REG_EQUIPMENT_BYTE 0x14 -#define REG_IBM_CENTURY_BYTE 0x32 -#define REG_IBM_PS2_CENTURY_BYTE 0x37 - - -static inline int to_bcd(RTCState *s, int a) -{ - return ((a / 10) << 4) | (a % 10); -} static int cmos_get_fd_drive_type(int fd0) { @@ -171,18 +163,6 @@ struct tm *tm; int i; - /* set the CMOS date */ - time(&ti); - if (rtc_utc) - tm = gmtime(&ti); - else - tm = localtime(&ti); - rtc_set_date(s, tm); - - val = to_bcd(s, (tm->tm_year / 100) + 19); - rtc_set_memory(s, REG_IBM_CENTURY_BYTE, val); - rtc_set_memory(s, REG_IBM_PS2_CENTURY_BYTE, val); - /* various important CMOS locations needed by PC/Bochs bios */ /* memory size */ -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net