[XenPPC] [linux-ppc-2.6] [POWERPC][XEN] Use new Xen based Real Time Clock logic in DomUs

2006-12-19 Thread Xen patchbot-linux-ppc-2 . 6
# HG changeset patch
# User Jimi Xenidis <[EMAIL PROTECTED]>
# Node ID bbf2db4ddf5400e908ee6bf92ac798e5cfed82a0
# Parent  c8d1f32fd7deebb9c15e5dc4ec3bcbd3678d9488
[POWERPC][XEN] Use new Xen based Real Time Clock logic in DomUs

Signed-off-by: Jimi Xenidis <[EMAIL PROTECTED]>
---
 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.cWed Nov 22 14:51:54 2006 -0500
+++ b/arch/powerpc/platforms/xen/setup.cTue 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.hWed Nov 22 14:51:54 2006 -0500
+++ b/arch/powerpc/platforms/xen/setup.hTue 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 +
+++ b/arch/powerpc/platforms/xen/time.c Tue Dec 19 09:22:37 2006 -0500
@@ -0,0 +1,96 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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);
+ 

[XenPPC] [xenppc-unstable] [XEN][POWERPC] DomU real time clock based off of the real one in Dom0

2006-12-19 Thread Xen patchbot-xenppc-unstable
# HG changeset patch
# User Jimi Xenidis <[EMAIL PROTECTED]>
# Node ID db52c7d043bb2a7f3dc67f4f2fb4f6498b92e558
# Parent  014c4ef0e124a81a072a92bd4cff17e6214d8897
[XEN][POWERPC] DomU real time clock based off of the real one in Dom0

Signed-off-by: Jimi Xenidis <[EMAIL PROTECTED]>
---
 xen/arch/powerpc/domain.c |   21 -
 xen/arch/powerpc/time.c   |6 --
 xen/include/public/arch-powerpc.h |2 +-
 3 files changed, 13 insertions(+), 16 deletions(-)

diff -r 014c4ef0e124 -r db52c7d043bb xen/arch/powerpc/domain.c
--- a/xen/arch/powerpc/domain.c Sun Dec 17 12:54:30 2006 -0500
+++ b/xen/arch/powerpc/domain.c Tue Dec 19 09:20:58 2006 -0500
@@ -152,17 +152,20 @@ void vcpu_destroy(struct vcpu *v)
 
 int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_t *c)
 { 
+struct domain *d = v->domain;
+
 memcpy(&v->arch.ctxt, &c->user_regs, sizeof(c->user_regs));
 
-printk("Domain[%d].%d: initializing\n",
-   v->domain->domain_id, v->vcpu_id);
-
-if (v->domain->arch.htab.order == 0)
-panic("Page table never allocated for Domain: %d\n",
-  v->domain->domain_id);
-if (v->domain->arch.rma_order == 0)
-panic("RMA never allocated for Domain: %d\n",
-  v->domain->domain_id);
+printk("Domain[%d].%d: initializing\n", d->domain_id, v->vcpu_id);
+
+if (d->arch.htab.order == 0)
+panic("Page table never allocated for Domain: %d\n", d->domain_id);
+if (d->arch.rma_order == 0)
+panic("RMA never allocated for Domain: %d\n", d->domain_id);
+
+d->shared_info->wc_sec = dom0->shared_info->wc_sec;
+d->shared_info->wc_nsec = dom0->shared_info->wc_nsec;
+d->shared_info->arch.boot_timebase = dom0->shared_info->arch.boot_timebase;
 
 set_bit(_VCPUF_initialised, &v->vcpu_flags);
 
diff -r 014c4ef0e124 -r db52c7d043bb xen/arch/powerpc/time.c
--- a/xen/arch/powerpc/time.c   Sun Dec 17 12:54:30 2006 -0500
+++ b/xen/arch/powerpc/time.c   Tue Dec 19 09:20:58 2006 -0500
@@ -85,12 +85,6 @@ void send_timer_event(struct vcpu *v)
 vcpu_unblock(v);
 }
 
-/* Set clock to  after 00:00:00 UTC, 1 January, 1970. */
-void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
-{
-unimplemented();
-}
-
 void update_vcpu_system_time(struct vcpu *v)
 {
 }
diff -r 014c4ef0e124 -r db52c7d043bb xen/include/public/arch-powerpc.h
--- a/xen/include/public/arch-powerpc.h Sun Dec 17 12:54:30 2006 -0500
+++ b/xen/include/public/arch-powerpc.h Tue Dec 19 09:20:58 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 {

___
Xen-ppc-devel mailing list
Xen-ppc-devel@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel