2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4 #ifndef __LTT_USERTRACE_PPC_H
5 #define __LTT_USERTRACE_PPC_H
8 #include "ltt/atomic-ppc64.h"
10 #include "ltt/atomic-ppc.h"
13 static __inline__
unsigned long
14 xchg_u32(volatile void *p
, unsigned long val
)
18 __asm__
__volatile__ ("\n\
22 : "=&r" (prev
), "=m" (*(volatile unsigned long *)p
)
23 : "r" (p
), "r" (val
), "m" (*(volatile unsigned long *)p
)
30 * This function doesn't exist, so you'll get a linker error
31 * if something tries to do an invalid xchg().
33 extern void __xchg_called_with_bad_pointer(void);
35 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
36 #define tas(ptr) (xchg((ptr),1))
38 static inline unsigned long __xchg(unsigned long x
, volatile void *ptr
, int size
)
42 return (unsigned long) xchg_u32(ptr
, x
);
43 #if 0 /* xchg_u64 doesn't exist on 32-bit PPC */
45 return (unsigned long) xchg_u64(ptr
, x
);
48 __xchg_called_with_bad_pointer();
54 extern inline void * xchg_ptr(void * m
, void * val
)
56 return (void *) xchg_u32(m
, (unsigned long) val
);
60 #define __HAVE_ARCH_CMPXCHG 1
62 static __inline__
unsigned long
63 __cmpxchg_u32(volatile unsigned int *p
, unsigned int old
, unsigned int new)
67 __asm__
__volatile__ ("\n\
75 #endif /* CONFIG_SMP */
77 : "=&r" (prev
), "=m" (*p
)
78 : "r" (p
), "r" (old
), "r" (new), "m" (*p
)
84 /* This function doesn't exist, so you'll get a linker error
85 if something tries to do an invalid cmpxchg(). */
86 extern void __cmpxchg_called_with_bad_pointer(void);
88 static __inline__
unsigned long
89 __cmpxchg(volatile void *ptr
, unsigned long old
, unsigned long new, int size
)
93 return __cmpxchg_u32(ptr
, old
, new);
94 #if 0 /* we don't have __cmpxchg_u64 on 32-bit PPC */
96 return __cmpxchg_u64(ptr
, old
, new);
99 __cmpxchg_called_with_bad_pointer();
103 #define cmpxchg(ptr,o,n) \
105 __typeof__(*(ptr)) _o_ = (o); \
106 __typeof__(*(ptr)) _n_ = (n); \
107 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
108 (unsigned long)_n_, sizeof(*(ptr))); \
112 #define CPU_FTR_601 0x00000100
114 #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
116 typedef uint64_t cycles_t
;
118 /* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
119 static inline unsigned long get_tbl(void)
123 //#if defined(CONFIG_403GCX)
124 // asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
126 asm volatile("mftb %0" : "=r" (tbl
));
131 static inline unsigned int get_tbu(void)
135 //#if defined(CONFIG_403GCX)
136 // asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
138 asm volatile("mftbu %0" : "=r" (tbu
));
145 static inline uint64_t get_tb(void)
150 static inline uint64_t get_tb(void)
152 unsigned int tbhi
, tblo
, tbhi2
;
158 } while (tbhi
!= tbhi2
);
160 return ((uint64_t)tbhi
<< 32) | tblo
;
164 static inline cycles_t
get_cycles(void)
170 #endif /* __LTT_USERTRACE_PPC_H */
This page took 0.042479 seconds and 4 git commands to generate.