015365eaf23e929acc657f640ef167fad05a403a
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\
16 : "=&r" (prev
), "=m" (*(volatile unsigned long *)p
)
17 : "r" (p
), "r" (val
), "m" (*(volatile unsigned long *)p
)
24 * This function doesn't exist, so you'll get a linker error
25 * if something tries to do an invalid xchg().
27 extern void __xchg_called_with_bad_pointer(void);
29 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
30 #define tas(ptr) (xchg((ptr),1))
32 static inline unsigned long __xchg(unsigned long x
, volatile void *ptr
, int size
)
36 return (unsigned long) xchg_u32(ptr
, x
);
37 #if 0 /* xchg_u64 doesn't exist on 32-bit PPC */
39 return (unsigned long) xchg_u64(ptr
, x
);
42 __xchg_called_with_bad_pointer();
48 extern inline void * xchg_ptr(void * m
, void * val
)
50 return (void *) xchg_u32(m
, (unsigned long) val
);
54 #define __HAVE_ARCH_CMPXCHG 1
56 static __inline__
unsigned long
57 __cmpxchg_u32(volatile unsigned int *p
, unsigned int old
, unsigned int new)
61 __asm__
__volatile__ ("\n\
69 #endif /* CONFIG_SMP */
71 : "=&r" (prev
), "=m" (*p
)
72 : "r" (p
), "r" (old
), "r" (new), "m" (*p
)
78 /* This function doesn't exist, so you'll get a linker error
79 if something tries to do an invalid cmpxchg(). */
80 extern void __cmpxchg_called_with_bad_pointer(void);
82 static __inline__
unsigned long
83 __cmpxchg(volatile void *ptr
, unsigned long old
, unsigned long new, int size
)
87 return __cmpxchg_u32(ptr
, old
, new);
88 #if 0 /* we don't have __cmpxchg_u64 on 32-bit PPC */
90 return __cmpxchg_u64(ptr
, old
, new);
93 __cmpxchg_called_with_bad_pointer();
97 #define cmpxchg(ptr,o,n) \
99 __typeof__(*(ptr)) _o_ = (o); \
100 __typeof__(*(ptr)) _n_ = (n); \
101 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
102 (unsigned long)_n_, sizeof(*(ptr))); \
106 #define CPU_FTR_601 0x00000100
108 #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
110 typedef uint64_t cycles_t
;
112 /* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
113 static inline unsigned long get_tbl(void)
117 //#if defined(CONFIG_403GCX)
118 // asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
120 asm volatile("mftb %0" : "=r" (tbl
));
125 static inline unsigned int get_tbu(void)
129 //#if defined(CONFIG_403GCX)
130 // asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
132 asm volatile("mftbu %0" : "=r" (tbu
));
139 static inline uint64_t get_tb(void)
144 static inline uint64_t get_tb(void)
146 unsigned int tbhi
, tblo
, tbhi2
;
152 } while (tbhi
!= tbhi2
);
154 return ((uint64_t)tbhi
<< 32) | tblo
;
158 static inline cycles_t
get_cycles(void)
164 #endif /* __LTT_USERTRACE_PPC_H */
This page took 0.044424 seconds and 4 git commands to generate.