source: trunk/packages/xen-common/xen-common/tools/ioemu/patches/hypervisor-rtc @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 4.2 KB
Line 
1# HG changeset patch
2# User kfraser@localhost.localdomain
3# Node ID 71e2a165aa7f81602c569430b18ba1ea705f0b70
4# Parent  da66691687dfd90c55420cfdf27f55d18cca7810
5[HVM] Move RTC emulation into the hypervisor.
6Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
7
8Index: ioemu/Makefile.target
9===================================================================
10--- ioemu.orig/Makefile.target  2006-12-08 01:41:15.000000000 +0000
11+++ ioemu/Makefile.target       2006-12-08 01:41:15.000000000 +0000
12@@ -295,7 +295,11 @@
13 endif
14 
15 # qemu-dm objects
16+ifeq ($(ARCH),ia64)
17 LIBOBJS=helper2.o exec-dm.o i8259-dm.o
18+else
19+LIBOBJS=helper2.o exec-dm.o i8259-dm.o rtc-dm.o
20+endif
21 
22 all: $(PROGS)
23 
24@@ -355,7 +359,11 @@
25 ifeq ($(TARGET_BASE_ARCH), i386)
26 # Hardware support
27 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
28+ifeq ($(ARCH),ia64)
29 VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
30+else
31+VL_OBJS+= fdc.o serial.o pc.o
32+endif
33 VL_OBJS+= cirrus_vga.o mixeng.o parallel.o acpi.o piix_pci.o
34 VL_OBJS+= usb-uhci.o
35 VL_OBJS+= piix4acpi.o
36Index: ioemu/target-i386-dm/rtc-dm.c
37===================================================================
38--- /dev/null   1970-01-01 00:00:00.000000000 +0000
39+++ ioemu/target-i386-dm/rtc-dm.c       2006-12-08 01:41:15.000000000 +0000
40@@ -0,0 +1,107 @@
41+/*
42+ * QEMU MC146818 RTC emulation
43+ *
44+ * Copyright (c) 2003-2004 Fabrice Bellard
45+ *
46+ * Permission is hereby granted, free of charge, to any person obtaining a copy
47+ * of this software and associated documentation files (the "Software"), to deal
48+ * in the Software without restriction, including without limitation the rights
49+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50+ * copies of the Software, and to permit persons to whom the Software is
51+ * furnished to do so, subject to the following conditions:
52+ *
53+ * The above copyright notice and this permission notice shall be included in
54+ * all copies or substantial portions of the Software.
55+ *
56+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
59+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
62+ * THE SOFTWARE.
63+ */
64+
65+#include "vl.h"
66+
67+//#define DEBUG_CMOS
68+
69+struct RTCState {
70+    uint8_t cmos_data[128];
71+    uint8_t cmos_index;
72+};
73+
74+void rtc_set_memory(RTCState *s, int addr, int val)
75+{
76+    if (addr >= 0 && addr <= 127)
77+        s->cmos_data[addr] = val;
78+}
79+
80+static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data)
81+{
82+    RTCState *s = opaque;
83+
84+    if ((addr & 1) == 0) {
85+        s->cmos_index = data & 0x7f;
86+    } else {
87+#ifdef DEBUG_CMOS
88+        printf("cmos: write index=0x%02x val=0x%02x\n",
89+               s->cmos_index, data);
90+#endif       
91+        s->cmos_data[s->cmos_index] = data;
92+    }
93+}
94+
95+static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
96+{
97+    RTCState *s = opaque;
98+    int ret;
99+    if ((addr & 1) == 0) {
100+        return 0xff;
101+    } else {
102+        ret = s->cmos_data[s->cmos_index];
103+#ifdef DEBUG_CMOS
104+        printf("cmos: read index=0x%02x val=0x%02x\n",
105+               s->cmos_index, ret);
106+#endif
107+        return ret;
108+    }
109+}
110+
111+static void rtc_save(QEMUFile *f, void *opaque)
112+{
113+    RTCState *s = opaque;
114+
115+    qemu_put_buffer(f, s->cmos_data, 128);
116+    qemu_put_8s(f, &s->cmos_index);
117+}
118+
119+static int rtc_load(QEMUFile *f, void *opaque, int version_id)
120+{
121+    RTCState *s = opaque;
122+
123+    if (version_id != 1)
124+        return -EINVAL;
125+
126+    qemu_get_buffer(f, s->cmos_data, 128);
127+    qemu_get_8s(f, &s->cmos_index);
128+
129+    return 0;
130+}
131+
132+RTCState *rtc_init(int base, int irq)
133+{
134+    RTCState *s;
135+
136+    s = qemu_mallocz(sizeof(RTCState));
137+    if (!s)
138+        return NULL;
139+
140+    register_ioport_write(base, 2, 1, cmos_ioport_write, s);
141+    register_ioport_read(base, 2, 1, cmos_ioport_read, s);
142+
143+    register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
144+    return s;
145+}
146+
147+void rtc_set_date(RTCState *s, const struct tm *tm) {}
Note: See TracBrowser for help on using the repository browser.