ia64/xen-unstable

changeset 16115:cd889a7ccae4

[IA64] Support console_timestamps on IA64

This patch intends to support console_timestamps on IA64.
At this moment, EFIRTC is used for start time.

If we support synchronize HV time to Dom0 system time for long period,
Dom0 sys_settimeofday and sys_adjtimex functions should implement
Dom0-HV time sync functionality.

Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com>
author Alex Williamson <alex.williamson@hp.com>
date Mon Oct 15 11:39:30 2007 -0600 (2007-10-15)
parents 503756587ccf
children 2863852e02f6
files xen/arch/ia64/xen/xentime.c xen/include/asm-ia64/time.h
line diff
     1.1 --- a/xen/arch/ia64/xen/xentime.c	Mon Oct 15 11:31:29 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/xentime.c	Mon Oct 15 11:39:30 2007 -0600
     1.3 @@ -42,6 +42,9 @@ static s_time_t        stime_irq = 0x0; 
     1.4  unsigned long itc_scale __read_mostly, ns_scale __read_mostly;
     1.5  unsigned long itc_at_irq;
     1.6  
     1.7 +static u32 wc_sec, wc_nsec; /* UTC time at last 'time update'. */
     1.8 +static void ia64_wallclock_set(void);
     1.9 +
    1.10  /* We don't expect an absolute cycle value here, since then no way
    1.11   * to prevent overflow for large norminator. Normally this conversion
    1.12   * is used for relative offset.
    1.13 @@ -196,11 +199,35 @@ ia64_time_init (void)
    1.14  	ia64_init_itm();
    1.15  }
    1.16  
    1.17 +/* wallclock set from efi.get_time */
    1.18 +static void ia64_wallclock_set()
    1.19 +{
    1.20 +    efi_time_t tv;
    1.21 +    efi_time_cap_t tc;
    1.22 +    efi_status_t status = 0;
    1.23 +
    1.24 +    status = (*efi.get_time)(&tv, &tc);
    1.25 +    if (status != 0) {
    1.26 +        wc_sec = 0; wc_nsec = 0;
    1.27 +        printk("EFIRTC Get Time failed\n");
    1.28 +        return;
    1.29 +    }
    1.30 +
    1.31 +    wc_sec  = mktime(tv.year, tv.month, tv.day, tv.hour, tv.minute, tv.second);
    1.32 +    wc_nsec = tv.nanosecond;
    1.33 +    if (tv.timezone != EFI_UNSPECIFIED_TIMEZONE) {
    1.34 +        wc_sec -= tv.timezone * 60;
    1.35 +        printk("Time Zone is %d minutes difference from UTC\n", tv.timezone);
    1.36 +    } else {
    1.37 +        printk("Time Zone is not specified on EFIRTC\n");
    1.38 +    }
    1.39 +}
    1.40  
    1.41  /* Late init function (after all CPUs are booted). */
    1.42  int __init init_xen_time()
    1.43  {
    1.44      ia64_time_init();
    1.45 +    ia64_wallclock_set();
    1.46      itc_scale  = 1000000000UL << 32 ;
    1.47      itc_scale /= local_cpu_data->itc_freq;
    1.48      ns_scale = (local_cpu_data->itc_freq << 32) / 1000000000UL;
    1.49 @@ -243,3 +270,18 @@ void send_timer_event(struct vcpu *v)
    1.50  	send_guest_vcpu_virq(v, VIRQ_TIMER);
    1.51  }
    1.52  
    1.53 +/* This is taken from xen/arch/x86/time.c.
    1.54 + * and the value is replaced 
    1.55 + * from 1000000000ull to NSEC_PER_SEC.
    1.56 + */
    1.57 +struct tm wallclock_time(void)
    1.58 +{
    1.59 +    uint64_t seconds;
    1.60 +
    1.61 +    if (!wc_sec)
    1.62 +        return (struct tm) { 0 };
    1.63 +
    1.64 +    seconds = NOW() + (wc_sec * NSEC_PER_SEC) + wc_nsec;
    1.65 +    do_div(seconds, NSEC_PER_SEC);
    1.66 +    return gmtime(seconds);
    1.67 +}
     2.1 --- a/xen/include/asm-ia64/time.h	Mon Oct 15 11:31:29 2007 -0600
     2.2 +++ b/xen/include/asm-ia64/time.h	Mon Oct 15 11:39:30 2007 -0600
     2.3 @@ -4,6 +4,7 @@
     2.4  #include <asm/linux/time.h>
     2.5  #include <asm/timex.h>
     2.6  
     2.7 -#define wallclock_time() ((struct tm) { 0 })
     2.8 +struct tm;
     2.9 +struct tm wallclock_time(void);
    2.10  
    2.11  #endif /* _ASM_TIME_H_ */