qemu-devel
[Top][All Lists]
Advanced

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

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


From: Thiemo Seufer
Subject: [Qemu-devel] [PATCH 3/6] A cumulative MIPS patchset
Date: Tue, 21 Nov 2006 14:40:37 +0000
User-agent: Mutt/1.5.13 (2006-08-11)

Hello All,

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.


Thiemo


Index: qemu-work/Makefile.target
===================================================================
--- qemu-work.orig/Makefile.target      2006-11-20 01:18:46.000000000 +0000
+++ qemu-work/Makefile.target   2006-11-20 01:21:22.000000000 +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: qemu-work/hw/mips_r4k.c
===================================================================
--- qemu-work.orig/hw/mips_r4k.c        2006-11-20 01:21:18.000000000 +0000
+++ qemu-work/hw/mips_r4k.c     2006-11-20 01:21:22.000000000 +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)
@@ -110,6 +112,35 @@
     cpu_mips_update_count(env, 1, 0);
 }
 
+#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 void cmos_init(int ram_size, int boot_device, BlockDriverState 
**hd_table)
+{
+    RTCState *s = rtc_state;
+    int val;
+    time_t ti;
+    struct tm *tm;
+
+    /* 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 mips_qemu_writel (void *opaque, target_phys_addr_t addr,
                              uint32_t val)
 {
@@ -251,12 +282,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);
@@ -274,6 +308,11 @@
     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);
+
+    cmos_init(ram_size, boot_device, bs_table);
 }
 
 QEMUMachine mips_machine = {

Attachment: qemu.drow-halt-reboot
Description: Text document


reply via email to

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