direct-io.hg

changeset 11494:94aa7e921ccd

[POWERPC][XEN] Make many of the timbase routine static inline

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Fri Sep 01 13:14:53 2006 -0400 (2006-09-01)
parents 18b3cbb04dc3
children ccdaa3ea71a7
files xen/arch/powerpc/time.c xen/include/asm-powerpc/time.h
line diff
     1.1 --- a/xen/arch/powerpc/time.c	Fri Sep 01 12:37:29 2006 -0400
     1.2 +++ b/xen/arch/powerpc/time.c	Fri Sep 01 13:14:53 2006 -0400
     1.3 @@ -34,40 +34,6 @@ ulong ticks_per_usec;
     1.4  unsigned long cpu_khz;
     1.5  unsigned int timebase_freq;
     1.6  
     1.7 -u64 get_timebase(void)
     1.8 -{
     1.9 -    u64 s;
    1.10 -
    1.11 -#ifdef __PPC64__
    1.12 -    s = mftb();
    1.13 -#else
    1.14 -    do {
    1.15 -        unsigned up;
    1.16 -        unsigned lo;
    1.17 -        unsigned up2;
    1.18 -
    1.19 -        up = mftbu();
    1.20 -        lo = mftbl();
    1.21 -        up2 = mftbu();
    1.22 -    } while (up1 != up2);
    1.23 -    s = ((ulong)up << 32) | lo;
    1.24 -#endif
    1.25 -    return s;
    1.26 -}
    1.27 -
    1.28 -static ulong ns_to_tb(ulong ns)
    1.29 -{
    1.30 -    return (ns * timebase_freq) / 1000000000ULL;
    1.31 -}
    1.32 -
    1.33 -static ulong tb_to_ns(ulong tb)
    1.34 -{
    1.35 -    return tb * (1000000000ULL / timebase_freq);
    1.36 -}
    1.37 -
    1.38 -/*
    1.39 - * Return nanoseconds from time of boot
    1.40 - */
    1.41  s_time_t get_s_time(void)
    1.42  {
    1.43      return tb_to_ns(get_timebase());
     2.1 --- a/xen/include/asm-powerpc/time.h	Fri Sep 01 12:37:29 2006 -0400
     2.2 +++ b/xen/include/asm-powerpc/time.h	Fri Sep 01 13:14:53 2006 -0400
     2.3 @@ -13,15 +13,19 @@
     2.4   * along with this program; if not, write to the Free Software
     2.5   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     2.6   *
     2.7 - * Copyright (C) IBM Corp. 2005
     2.8 + * Copyright (C) IBM Corp. 2005, 2006
     2.9   *
    2.10   * Authors: Hollis Blanchard <hollisb@us.ibm.com>
    2.11 + *          Hollis Blanchard <jimix@watson.ibm.com>
    2.12   */
    2.13  
    2.14  #ifndef _ASM_TIME_H_
    2.15  #define _ASM_TIME_H_
    2.16  
    2.17  #include <xen/types.h>
    2.18 +#include <xen/time.h>
    2.19 +#include <xen/percpu.h>
    2.20 +#include <asm/processor.h>
    2.21  
    2.22  extern unsigned int timebase_freq;
    2.23  #define CLOCK_TICK_RATE timebase_freq
    2.24 @@ -29,7 +33,26 @@ extern unsigned int timebase_freq;
    2.25  #define watchdog_disable() ((void)0)
    2.26  #define watchdog_enable()  ((void)0)
    2.27  
    2.28 -extern u64 get_timebase(void);
    2.29 +static inline u64 get_timebase(void)
    2.30 +{
    2.31 +    u64 s;
    2.32 +
    2.33 +#ifdef __PPC64__
    2.34 +    s = mftb();
    2.35 +#else
    2.36 +    do {
    2.37 +        unsigned up;
    2.38 +        unsigned lo;
    2.39 +        unsigned up2;
    2.40 +
    2.41 +        up = mftbu();
    2.42 +        lo = mftbl();
    2.43 +        up2 = mftbu();
    2.44 +    } while (up1 != up2);
    2.45 +    s = ((ulong)up << 32) | lo;
    2.46 +#endif
    2.47 +    return s;
    2.48 +}
    2.49  
    2.50  typedef u64 cycles_t;
    2.51  static inline cycles_t get_cycles(void)
    2.52 @@ -39,4 +62,15 @@ static inline cycles_t get_cycles(void)
    2.53      return c;
    2.54  }
    2.55  
    2.56 +#define __nano(s) ((s) * 1000000000ULL)
    2.57 +
    2.58 +static inline u64 ns_to_tb(u64 ns)
    2.59 +{
    2.60 +    return (ns * timebase_freq) / __nano(1);
    2.61 +}
    2.62 +
    2.63 +static inline u64 tb_to_ns(u64 tb)
    2.64 +{
    2.65 +    return tb * (__nano(1) / timebase_freq);
    2.66 +}
    2.67  #endif