qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/6] A cumulative MIPS patchset


From: Aurelien Jarno
Subject: Re: [Qemu-devel] [PATCH 3/6] A cumulative MIPS patchset
Date: Tue, 21 Nov 2006 17:46:01 +0100
User-agent: Mutt/1.5.9i

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
 `. `'   address@hidden         | address@hidden
   `-    people.debian.org/~aurel32 | www.aurel32.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]