From 60009e261013c6bcbdbaa624eaa4c5225d366aef Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 2 Jun 2006 12:08:03 +0000 Subject: [PATCH] ppc fix git-svn-id: http://ltt.polymtl.ca/svn@1876 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt-usertrace/ltt/atomic-ppc.h | 5 +- ltt-usertrace/ltt/ltt-usertrace-fast.h | 8 -- ltt-usertrace/ltt/ltt-usertrace-ppc.h | 102 +------------------------ ltt-usertrace/ltt/ltt-usertrace.h | 5 ++ ltt-usertrace/ltt/ppc_asm-ppc.h | 2 - ltt-usertrace/ltt/system-ppc.h | 59 +------------- ltt-usertrace/ltt/system-ppc64.h | 96 +---------------------- 7 files changed, 12 insertions(+), 265 deletions(-) diff --git a/ltt-usertrace/ltt/atomic-ppc.h b/ltt-usertrace/ltt/atomic-ppc.h index eeafd505..ecd1f757 100644 --- a/ltt-usertrace/ltt/atomic-ppc.h +++ b/ltt-usertrace/ltt/atomic-ppc.h @@ -7,8 +7,6 @@ typedef struct { volatile int counter; } atomic_t; -#ifdef __KERNEL__ - #define ATOMIC_INIT(i) { (i) } #define atomic_read(v) ((v)->counter) @@ -16,7 +14,7 @@ typedef struct { volatile int counter; } atomic_t; extern void atomic_clear_mask(unsigned long mask, unsigned long *addr); -#ifdef CONFIG_SMP +#if 0 // We only do operation on one CPU at a time (LTT) #define SMP_SYNC "sync" #define SMP_ISYNC "\n\tisync" #else @@ -210,5 +208,4 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v) #define smp_mb__before_atomic_inc() __MB #define smp_mb__after_atomic_inc() __MB -#endif /* __KERNEL__ */ #endif /* _ASM_PPC_ATOMIC_H_ */ diff --git a/ltt-usertrace/ltt/ltt-usertrace-fast.h b/ltt-usertrace/ltt/ltt-usertrace-fast.h index b71585a0..b0b0ea5c 100644 --- a/ltt-usertrace/ltt/ltt-usertrace-fast.h +++ b/ltt-usertrace/ltt/ltt-usertrace-fast.h @@ -18,14 +18,6 @@ #include #include #include -#ifdef powerpc -#define __KERNEL__ /* Ugly hack : atomic.h is broken */ -#endif -#include -#ifdef powerpc -#include "ltt/ltt-usertrace-ppc.h" -#undef __KERNEL__ /* Ugly hack : atomic.h is broken */ -#endif #include diff --git a/ltt-usertrace/ltt/ltt-usertrace-ppc.h b/ltt-usertrace/ltt/ltt-usertrace-ppc.h index 417eca01..002142e4 100644 --- a/ltt-usertrace/ltt/ltt-usertrace-ppc.h +++ b/ltt-usertrace/ltt/ltt-usertrace-ppc.h @@ -6,109 +6,13 @@ #ifdef __powerpc64__ #include "ltt/atomic-ppc64.h" +#include "ltt/system-ppc64.h" #else +#include "ltt/ppc_asm-ppc.h" #include "ltt/atomic-ppc.h" +#include "ltt/system-ppc.h" #endif -static __inline__ unsigned long -xchg_u32(volatile void *p, unsigned long val) -{ - unsigned long prev; - - __asm__ __volatile__ ("\n\ -1: lwarx %0,0,%2 \n" -" stwcx. %3,0,%2 \n\ - bne- 1b" - : "=&r" (prev), "=m" (*(volatile unsigned long *)p) - : "r" (p), "r" (val), "m" (*(volatile unsigned long *)p) - : "cc", "memory"); - - return prev; -} - -/* - * This function doesn't exist, so you'll get a linker error - * if something tries to do an invalid xchg(). - */ -extern void __xchg_called_with_bad_pointer(void); - -#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) -#define tas(ptr) (xchg((ptr),1)) - -static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size) -{ - switch (size) { - case 4: - return (unsigned long) xchg_u32(ptr, x); -#if 0 /* xchg_u64 doesn't exist on 32-bit PPC */ - case 8: - return (unsigned long) xchg_u64(ptr, x); -#endif /* 0 */ - } - __xchg_called_with_bad_pointer(); - return x; - - -} - -extern inline void * xchg_ptr(void * m, void * val) -{ - return (void *) xchg_u32(m, (unsigned long) val); -} - - -#define __HAVE_ARCH_CMPXCHG 1 - -static __inline__ unsigned long -__cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) -{ - unsigned int prev; - - __asm__ __volatile__ ("\n\ -1: lwarx %0,0,%2 \n\ - cmpw 0,%0,%3 \n\ - bne 2f \n" -" stwcx. %4,0,%2 \n\ - bne- 1b\n" -#ifdef CONFIG_SMP -" sync\n" -#endif /* CONFIG_SMP */ -"2:" - : "=&r" (prev), "=m" (*p) - : "r" (p), "r" (old), "r" (new), "m" (*p) - : "cc", "memory"); - - return prev; -} - -/* This function doesn't exist, so you'll get a linker error - if something tries to do an invalid cmpxchg(). */ -extern void __cmpxchg_called_with_bad_pointer(void); - -static __inline__ unsigned long -__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) -{ - switch (size) { - case 4: - return __cmpxchg_u32(ptr, old, new); -#if 0 /* we don't have __cmpxchg_u64 on 32-bit PPC */ - case 8: - return __cmpxchg_u64(ptr, old, new); -#endif /* 0 */ - } - __cmpxchg_called_with_bad_pointer(); - return old; -} - -#define cmpxchg(ptr,o,n) \ - ({ \ - __typeof__(*(ptr)) _o_ = (o); \ - __typeof__(*(ptr)) _n_ = (n); \ - (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ - (unsigned long)_n_, sizeof(*(ptr))); \ - }) - - #define CPU_FTR_601 0x00000100 #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ diff --git a/ltt-usertrace/ltt/ltt-usertrace.h b/ltt-usertrace/ltt/ltt-usertrace.h index eb8f9c85..90729c67 100644 --- a/ltt-usertrace/ltt/ltt-usertrace.h +++ b/ltt-usertrace/ltt/ltt-usertrace.h @@ -15,6 +15,11 @@ #include #include #include +#if defined(__powerpc__) || defined(__powerpc64__) +#include "ltt/ltt-usertrace-ppc.h" +#else +#include +#endif #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) diff --git a/ltt-usertrace/ltt/ppc_asm-ppc.h b/ltt-usertrace/ltt/ppc_asm-ppc.h index f76221de..e625aed0 100644 --- a/ltt-usertrace/ltt/ppc_asm-ppc.h +++ b/ltt-usertrace/ltt/ppc_asm-ppc.h @@ -11,8 +11,6 @@ * 2 of the License, or (at your option) any later version. */ -#include - /* * Macros for storing registers into and loading registers from * exception frames. diff --git a/ltt-usertrace/ltt/system-ppc.h b/ltt-usertrace/ltt/system-ppc.h index 82395f30..0f13837c 100644 --- a/ltt-usertrace/ltt/system-ppc.h +++ b/ltt-usertrace/ltt/system-ppc.h @@ -4,9 +4,6 @@ #ifndef __PPC_SYSTEM_H #define __PPC_SYSTEM_H -#include -#include - #include #include @@ -48,59 +45,6 @@ #define smp_read_barrier_depends() do { } while(0) #endif /* CONFIG_SMP */ -#ifdef __KERNEL__ -struct task_struct; -struct pt_regs; - -extern void print_backtrace(unsigned long *); -extern void show_regs(struct pt_regs * regs); -extern void flush_instruction_cache(void); -extern void hard_reset_now(void); -extern void poweroff_now(void); -#ifdef CONFIG_6xx -extern long _get_L2CR(void); -extern long _get_L3CR(void); -extern void _set_L2CR(unsigned long); -extern void _set_L3CR(unsigned long); -#else -#define _get_L2CR() 0L -#define _get_L3CR() 0L -#define _set_L2CR(val) do { } while(0) -#define _set_L3CR(val) do { } while(0) -#endif -extern void via_cuda_init(void); -extern void pmac_nvram_init(void); -extern void read_rtc_time(void); -extern void pmac_find_display(void); -extern void giveup_fpu(struct task_struct *); -extern void enable_kernel_fp(void); -extern void enable_kernel_altivec(void); -extern void giveup_altivec(struct task_struct *); -extern void load_up_altivec(struct task_struct *); -extern void giveup_spe(struct task_struct *); -extern void load_up_spe(struct task_struct *); -extern int fix_alignment(struct pt_regs *); -extern void cvt_fd(float *from, double *to, unsigned long *fpscr); -extern void cvt_df(double *from, float *to, unsigned long *fpscr); -extern int call_rtas(const char *, int, int, unsigned long *, ...); -extern void cacheable_memzero(void *p, unsigned int nb); -extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long); -extern void bad_page_fault(struct pt_regs *, unsigned long, int); -extern void die(const char *, struct pt_regs *, long); - -struct device_node; -extern void note_scsi_host(struct device_node *, void *); - -extern struct task_struct *__switch_to(struct task_struct *, - struct task_struct *); -#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next))) - -struct thread_struct; -extern struct task_struct *_switch(struct thread_struct *prev, - struct thread_struct *next); - -extern unsigned int rtas_data; - static __inline__ unsigned long xchg_u32(volatile void *p, unsigned long val) { @@ -163,7 +107,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) PPC405_ERR77(0,%2) " stwcx. %4,0,%2 \n\ bne- 1b\n" -#ifdef CONFIG_SMP +#if 0 //only using one CPU at a time (LTT) // def CONFIG_SMP " sync\n" #endif /* CONFIG_SMP */ "2:" @@ -203,5 +147,4 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) #define arch_align_stack(x) (x) -#endif /* __KERNEL__ */ #endif /* __PPC_SYSTEM_H */ diff --git a/ltt-usertrace/ltt/system-ppc64.h b/ltt-usertrace/ltt/system-ppc64.h index 98d120ca..5fe60537 100644 --- a/ltt-usertrace/ltt/system-ppc64.h +++ b/ltt-usertrace/ltt/system-ppc64.h @@ -8,8 +8,8 @@ * 2 of the License, or (at your option) any later version. */ -#include -#include +//#include +//#include #include #include #include @@ -57,97 +57,6 @@ #define smp_read_barrier_depends() do { } while(0) #endif /* CONFIG_SMP */ -#ifdef __KERNEL__ -struct task_struct; -struct pt_regs; - -#ifdef CONFIG_DEBUGGER - -extern int (*__debugger)(struct pt_regs *regs); -extern int (*__debugger_ipi)(struct pt_regs *regs); -extern int (*__debugger_bpt)(struct pt_regs *regs); -extern int (*__debugger_sstep)(struct pt_regs *regs); -extern int (*__debugger_iabr_match)(struct pt_regs *regs); -extern int (*__debugger_dabr_match)(struct pt_regs *regs); -extern int (*__debugger_fault_handler)(struct pt_regs *regs); - -#define DEBUGGER_BOILERPLATE(__NAME) \ -static inline int __NAME(struct pt_regs *regs) \ -{ \ - if (unlikely(__ ## __NAME)) \ - return __ ## __NAME(regs); \ - return 0; \ -} - -DEBUGGER_BOILERPLATE(debugger) -DEBUGGER_BOILERPLATE(debugger_ipi) -DEBUGGER_BOILERPLATE(debugger_bpt) -DEBUGGER_BOILERPLATE(debugger_sstep) -DEBUGGER_BOILERPLATE(debugger_iabr_match) -DEBUGGER_BOILERPLATE(debugger_dabr_match) -DEBUGGER_BOILERPLATE(debugger_fault_handler) - -#ifdef CONFIG_XMON -extern void xmon_init(void); -#endif - -#else -static inline int debugger(struct pt_regs *regs) { return 0; } -static inline int debugger_ipi(struct pt_regs *regs) { return 0; } -static inline int debugger_bpt(struct pt_regs *regs) { return 0; } -static inline int debugger_sstep(struct pt_regs *regs) { return 0; } -static inline int debugger_iabr_match(struct pt_regs *regs) { return 0; } -static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; } -static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; } -#endif - -extern int fix_alignment(struct pt_regs *regs); -extern void bad_page_fault(struct pt_regs *regs, unsigned long address, - int sig); -extern void show_regs(struct pt_regs * regs); -extern void low_hash_fault(struct pt_regs *regs, unsigned long address); -extern int die(const char *str, struct pt_regs *regs, long err); - -extern int _get_PVR(void); -extern void giveup_fpu(struct task_struct *); -extern void disable_kernel_fp(void); -extern void flush_fp_to_thread(struct task_struct *); -extern void enable_kernel_fp(void); -extern void giveup_altivec(struct task_struct *); -extern void disable_kernel_altivec(void); -extern void enable_kernel_altivec(void); -extern int emulate_altivec(struct pt_regs *); -extern void cvt_fd(float *from, double *to, unsigned long *fpscr); -extern void cvt_df(double *from, float *to, unsigned long *fpscr); - -#ifdef CONFIG_ALTIVEC -extern void flush_altivec_to_thread(struct task_struct *); -#else -static inline void flush_altivec_to_thread(struct task_struct *t) -{ -} -#endif - -extern int mem_init_done; /* set on boot once kmalloc can be called */ - -/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */ -extern unsigned char e2a(unsigned char); - -extern struct task_struct *__switch_to(struct task_struct *, - struct task_struct *); -#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next))) - -struct thread_struct; -extern struct task_struct * _switch(struct thread_struct *prev, - struct thread_struct *next); - -static inline int __is_processor(unsigned long pv) -{ - unsigned long pvr; - asm("mfspr %0, 0x11F" : "=r" (pvr)); - return(PVR_VER(pvr) == pv); -} - /* * Atomic exchange * @@ -302,5 +211,4 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) #define arch_align_stack(x) (x) -#endif /* __KERNEL__ */ #endif -- 2.34.1