# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID bbf2db4ddf5400e908ee6bf92ac798e5cfed82a0
# Parent c8d1f32fd7deebb9c15e5dc4ec3bcbd3678d9488
[POWERPC][XEN] Use new Xen based Real Time Clock logic in DomUs
Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
arch/powerpc/platforms/xen/Makefile | 1
arch/powerpc/platforms/xen/setup.c | 10 +--
arch/powerpc/platforms/xen/setup.h | 1
arch/powerpc/platforms/xen/time.c | 96 +++++++++++++++++++++++++++++++++++
include/xen/interface/arch-powerpc.h | 2
5 files changed, 104 insertions(+), 6 deletions(-)
diff -r c8d1f32fd7de -r bbf2db4ddf54 arch/powerpc/platforms/xen/Makefile
--- a/arch/powerpc/platforms/xen/Makefile Wed Nov 22 14:51:54 2006 -0500
+++ b/arch/powerpc/platforms/xen/Makefile Tue Dec 19 09:22:37 2006 -0500
@@ -3,6 +3,7 @@ obj-y += hcall.o
obj-y += hcall.o
obj-y += reboot.o
obj-y += setup.o
+obj-y += time.o
obj-y += udbg_xen.o
obj-y += xen_guest.o
obj-y += xencomm.o
diff -r c8d1f32fd7de -r bbf2db4ddf54 arch/powerpc/platforms/xen/setup.c
--- a/arch/powerpc/platforms/xen/setup.c Wed Nov 22 14:51:54 2006 -0500
+++ b/arch/powerpc/platforms/xen/setup.c Tue Dec 19 09:22:37 2006 -0500
@@ -109,12 +109,12 @@ static void __init xen_init_early(void)
DBG(" console_mfn %llx\n", xen_start_info->console.domU.mfn);
DBG(" console_evtchn %x\n", xen_start_info->console.domU.evtchn);
+ xen_setup_time(&mach_maple_md);
+
if (is_initial_xendomain()) {
- ppc_md.pcibios_fixup = mach_maple_md.pcibios_fixup;
- ppc_md.pci_get_legacy_ide_irq =
mach_maple_md.pci_get_legacy_ide_irq;
- ppc_md.get_boot_time = mach_maple_md.get_boot_time;
- ppc_md.set_rtc_time = mach_maple_md.set_rtc_time;
- ppc_md.get_rtc_time = mach_maple_md.get_rtc_time;
+ ppc_md.pcibios_fixup = mach_maple_md.pcibios_fixup;
+ ppc_md.pci_get_legacy_ide_irq =
+ mach_maple_md.pci_get_legacy_ide_irq;
add_preferred_console("ttyS", 0, NULL);
}
diff -r c8d1f32fd7de -r bbf2db4ddf54 arch/powerpc/platforms/xen/setup.h
--- a/arch/powerpc/platforms/xen/setup.h Wed Nov 22 14:51:54 2006 -0500
+++ b/arch/powerpc/platforms/xen/setup.h Tue Dec 19 09:22:37 2006 -0500
@@ -26,3 +26,4 @@ extern struct page *alloc_foreign_page(v
extern struct page *alloc_foreign_page(void);
extern void free_foreign_page(struct page *page);
+extern void __init xen_setup_time(struct machdep_calls *host_md);
diff -r c8d1f32fd7de -r bbf2db4ddf54 include/xen/interface/arch-powerpc.h
--- a/include/xen/interface/arch-powerpc.h Wed Nov 22 14:51:54 2006 -0500
+++ b/include/xen/interface/arch-powerpc.h Tue Dec 19 09:22:37 2006 -0500
@@ -108,7 +108,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_conte
DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
struct arch_shared_info {
- uint64_t pad[32];
+ uint64_t boot_timebase;
};
struct arch_vcpu_info {
diff -r c8d1f32fd7de -r bbf2db4ddf54 arch/powerpc/platforms/xen/time.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/arch/powerpc/platforms/xen/time.c Tue Dec 19 09:22:37 2006 -0500
@@ -0,0 +1,96 @@
+#include <linux/module.h>
+#include <linux/time.h>
+#include <linux/rtc.h>
+#include <asm/hypervisor.h>
+#include <asm/machdep.h>
+#include <asm/time.h>
+#include <asm/udbg.h>
+
+#define DEBUG
+
+#ifdef DEBUG
+#define DBG(fmt...) printk(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
+static inline ulong time_from_shared(void)
+{
+ ulong t;
+
+ DBG("tb_freq: %ld\n", ppc_tb_freq);
+
+ t = mftb() - HYPERVISOR_shared_info->arch.boot_timebase;
+ t /= ppc_tb_freq;
+ t += HYPERVISOR_shared_info->wc_sec;
+
+ return t;
+}
+
+static void (*host_md_get_rtc_time)(struct rtc_time *tm);
+static void xen_get_rtc_time(struct rtc_time *tm)
+{
+ if (is_initial_xendomain()) {
+ host_md_get_rtc_time(tm);
+ return;
+ } else {
+ ulong t;
+
+ t = time_from_shared();
+ to_tm(t, tm);
+ }
+}
+
+static int (*host_md_set_rtc_time)(struct rtc_time *tm);
+static int xen_set_rtc_time(struct rtc_time *tm)
+{
+ ulong sec;
+
+ if (is_initial_xendomain()) {
+ host_md_set_rtc_time(tm);
+ return 0;
+ }
+
+ sec = mktime(tm->tm_year, tm->tm_mon, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ HYPERVISOR_shared_info->wc_sec = sec;
+ HYPERVISOR_shared_info->arch.boot_timebase = mftb();
+
+ return 0;
+}
+
+static unsigned long (*host_md_get_boot_time)(void);
+static unsigned long __init xen_get_boot_time(void)
+{
+ ulong t;
+
+ if (is_initial_xendomain()) {
+ t = host_md_get_boot_time();
+
+ HYPERVISOR_shared_info->wc_sec = t;
+ HYPERVISOR_shared_info->arch.boot_timebase = mftb();
+ DBG("%s: time: %ld\n", __func__, t);
+ } else {
+ t = time_from_shared();
+ DBG("%s: %ld\n", __func__, t);
+ }
+ return t;
+}
+
+void __init xen_setup_time(struct machdep_calls *host_md)
+{
+ ppc_md.get_boot_time = xen_get_boot_time;
+ host_md_get_boot_time = host_md->get_boot_time;
+
+
+ ppc_md.set_rtc_time = xen_set_rtc_time;
+ host_md_set_rtc_time = host_md->set_rtc_time;
+
+
+ ppc_md.get_rtc_time = xen_get_rtc_time;
+ host_md_get_rtc_time = host_md->get_rtc_time;
+}
+
+
+
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|