2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4 #ifndef __LTT_USERTRACE_PPC_H
5 #define __LTT_USERTRACE_PPC_H
7 static __inline__
unsigned long
8 xchg_u32(volatile void *p
, unsigned long val
)
12 __asm__
__volatile__ ("\n\
17 : "=&r" (prev
), "=m" (*(volatile unsigned long *)p
)
18 : "r" (p
), "r" (val
), "m" (*(volatile unsigned long *)p
)
25 * This function doesn't exist, so you'll get a linker error
26 * if something tries to do an invalid xchg().
28 extern void __xchg_called_with_bad_pointer(void);
30 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
31 #define tas(ptr) (xchg((ptr),1))
33 static inline unsigned long __xchg(unsigned long x
, volatile void *ptr
, int size
)
37 return (unsigned long) xchg_u32(ptr
, x
);
38 #if 0 /* xchg_u64 doesn't exist on 32-bit PPC */
40 return (unsigned long) xchg_u64(ptr
, x
);
43 __xchg_called_with_bad_pointer();
49 extern inline void * xchg_ptr(void * m
, void * val
)
51 return (void *) xchg_u32(m
, (unsigned long) val
);
55 #define __HAVE_ARCH_CMPXCHG 1
57 static __inline__
unsigned long
58 __cmpxchg_u32(volatile unsigned int *p
, unsigned int old
, unsigned int new)
62 __asm__
__volatile__ ("\n\
71 #endif /* CONFIG_SMP */
73 : "=&r" (prev
), "=m" (*p
)
74 : "r" (p
), "r" (old
), "r" (new), "m" (*p
)
80 /* This function doesn't exist, so you'll get a linker error
81 if something tries to do an invalid cmpxchg(). */
82 extern void __cmpxchg_called_with_bad_pointer(void);
84 static __inline__
unsigned long
85 __cmpxchg(volatile void *ptr
, unsigned long old
, unsigned long new, int size
)
89 return __cmpxchg_u32(ptr
, old
, new);
90 #if 0 /* we don't have __cmpxchg_u64 on 32-bit PPC */
92 return __cmpxchg_u64(ptr
, old
, new);
95 __cmpxchg_called_with_bad_pointer();
99 #define cmpxchg(ptr,o,n) \
101 __typeof__(*(ptr)) _o_ = (o); \
102 __typeof__(*(ptr)) _n_ = (n); \
103 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
104 (unsigned long)_n_, sizeof(*(ptr))); \
108 #define CPU_FTR_601 0x00000100
110 #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
112 typedef uint64_t cycles_t
;
114 /* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
115 static inline unsigned long get_tbl(void)
119 //#if defined(CONFIG_403GCX)
120 // asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
122 asm volatile("mftb %0" : "=r" (tbl
));
127 static inline unsigned int get_tbu(void)
131 //#if defined(CONFIG_403GCX)
132 // asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
134 asm volatile("mftbu %0" : "=r" (tbu
));
141 static inline uint64_t get_tb(void)
146 static inline uint64_t get_tb(void)
148 unsigned int tbhi
, tblo
, tbhi2
;
154 } while (tbhi
!= tbhi2
);
156 return ((uint64_t)tbhi
<< 32) | tblo
;
160 static inline cycles_t
get_cycles(void)
166 #endif /* __LTT_USERTRACE_PPC_H */
This page took 0.031717 seconds and 4 git commands to generate.