From 3a4541a514dc6da3580401c084489910bc769ab7 Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 2 Jun 2006 13:54:36 +0000 Subject: [PATCH] ppc update git-svn-id: http://ltt.polymtl.ca/svn@1877 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt-usertrace/Makefile | 31 +++++---- ltt-usertrace/README | 10 ++- .../ltt/ltt-facility-custom-user_generic.h | 2 +- ltt-usertrace/ltt/ltt-usertrace-fast.h | 1 - ltt-usertrace/ltt/ltt-usertrace-ppc.h | 68 ++----------------- ltt-usertrace/ltt/ltt-usertrace.h | 26 ++++++- ltt-usertrace/ltt/system-ppc.h | 6 +- ltt-usertrace/ltt/system-ppc64.h | 12 ++-- ltt-usertrace/ltt/timex-ppc.h | 53 +++++++++++++++ 9 files changed, 121 insertions(+), 88 deletions(-) create mode 100644 ltt-usertrace/ltt/timex-ppc.h diff --git a/ltt-usertrace/Makefile b/ltt-usertrace/Makefile index baf12fcb..cfd4622f 100644 --- a/ltt-usertrace/Makefile +++ b/ltt-usertrace/Makefile @@ -1,10 +1,10 @@ CC=gcc INCLUDE_DIR=/usr/include -LIB_DIR=/usr/lib +LIB_DIR?=/usr/lib RANLIB=ranlib -CFLAGS=-I. -O2 -L. +LTT_CFLAGS=-I. -O2 -L. #For testing lib ltt-usertrace-fast #CFLAGS+=-DLTT_SUBBUF_SIZE_CPU=134217728 @@ -18,22 +18,22 @@ samples: sample sample-highspeed sample-printf \ sample-instrument-fct sample-thread-slow sample-thread-fast sample: sample.c ltt-facility-loader-user_generic.c - $(CC) $(CFLAGS) -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -o $@ $^ sample-highspeed: sample-highspeed.c ltt-facility-loader-user_generic.c - $(CC) $(CFLAGS) -lltt-usertrace-fast -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -lltt-usertrace-fast -o $@ $^ sample-printf: sample-printf.c ltt-facility-loader-user_generic.c - $(CC) $(CFLAGS) -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -o $@ $^ sample-instrument-fct: sample-instrument-fct.c - $(CC) $(CFLAGS) -g -finstrument-functions -lltt-instrument-functions -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -g -finstrument-functions -lltt-instrument-functions -o $@ $^ sample-thread-slow: sample-thread-slow.c ltt-facility-loader-user_generic.c - $(CC) $(CFLAGS) -lpthread -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -o $@ $^ sample-thread-fast: sample-thread-fast.c ltt-facility-loader-user_generic.c - $(CC) $(CFLAGS) -lpthread -lltt-usertrace-fast -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -lltt-usertrace-fast -o $@ $^ #LIBRAIRIES @@ -48,7 +48,7 @@ libltt-usertrace-fast.a: ltt-usertrace-fast.o libltt-usertrace-fast.so.0: ltt-usertrace-fast.o @rm -f libltt-usertrace-fast.so libltt-usertrace-fast.so.0 - $(CC) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-usertrace-fast.so -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-usertrace-fast.so -o $@ $^ ln -s libltt-usertrace-fast.so.0 libltt-usertrace-fast.so libltt-instrument-functions.a: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o @@ -58,17 +58,24 @@ libltt-instrument-functions.a: ltt-instrument-functions.o ltt-facility-loader-us libltt-instrument-functions.so.0: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o @rm -f libltt-instrument-functions.so libltt-instrument-functions.so.0 - $(CC) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-instrument-functions.so -o $@ $^ + $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-instrument-functions.so -o $@ $^ ln -s libltt-instrument-functions.so.0 libltt-instrument-functions.so -.PHONY : clean install libs samples +%.o: %.c + $(CC) $(LTT_CFLAGS) $(CFLAGS) -c -o $@ $+ -install: +.PHONY : clean install libs install_libs install_headers samples + +install_headers: if [ ! -e "$(INCLUDE_DIR)/ltt" ] ; then mkdir $(INCLUDE_DIR)/ltt ; fi cp -f ltt/*.h $(INCLUDE_DIR)/ltt + +install_libs: cp -df libltt-instrument-functions.so* libltt-instrument-functions.a $(LIB_DIR) cp -df libltt-usertrace-fast.so* libltt-usertrace-fast.a $(LIB_DIR) +install: install_headers libs install_libs + clean: rm -fr *.o *~ sample-thread sample sample-highspeed sample-printf sample-instrument-fct libltt-instrument-functions.so* libltt-instrument-functions.a libltt-usertrace-fast.a libltt-usertrace-fast.so* sample-thread-slow sample-thread-fast diff --git a/ltt-usertrace/README b/ltt-usertrace/README index 205fcca4..7e61df23 100644 --- a/ltt-usertrace/README +++ b/ltt-usertrace/README @@ -27,10 +27,18 @@ gzip -cd ltt-usertrace-x.x.tar.gz | tar xvof - * Build the sample programs and install the headers and librairies into your system : +(32 bits) su cd /usr/src/ltt-usertrace +make clean +make install (will build and install headers and libraries) make -make install +(64 bits) +su +cd /usr/src/ltt-usertrace +make clean +LIB_DIR=/usr/lib64 make install CFLAGS=-m64 +make CFLAGS=-m64 Feel free to look at the sample programs and the Makefile : they demonstrate very well the features of the usertrace package and how to use them. diff --git a/ltt-usertrace/ltt/ltt-facility-custom-user_generic.h b/ltt-usertrace/ltt/ltt-facility-custom-user_generic.h index 2008bae8..c819e3aa 100644 --- a/ltt-usertrace/ltt/ltt-facility-custom-user_generic.h +++ b/ltt-usertrace/ltt/ltt-facility-custom-user_generic.h @@ -8,7 +8,7 @@ #include #include -static inline int trace_user_generic_slow_printf( +static int trace_user_generic_slow_printf( const char *fmt, ...) #ifndef LTT_TRACE { diff --git a/ltt-usertrace/ltt/ltt-usertrace-fast.h b/ltt-usertrace/ltt/ltt-usertrace-fast.h index b0b0ea5c..bfca0c10 100644 --- a/ltt-usertrace/ltt/ltt-usertrace-fast.h +++ b/ltt-usertrace/ltt/ltt-usertrace-fast.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/ltt-usertrace/ltt/ltt-usertrace-ppc.h b/ltt-usertrace/ltt/ltt-usertrace-ppc.h index 002142e4..da729cf0 100644 --- a/ltt-usertrace/ltt/ltt-usertrace-ppc.h +++ b/ltt-usertrace/ltt/ltt-usertrace-ppc.h @@ -5,70 +5,14 @@ #define __LTT_USERTRACE_PPC_H #ifdef __powerpc64__ -#include "ltt/atomic-ppc64.h" -#include "ltt/system-ppc64.h" +#include +#include #else -#include "ltt/ppc_asm-ppc.h" -#include "ltt/atomic-ppc.h" -#include "ltt/system-ppc.h" +#include +#include +#include +#include #endif -#define CPU_FTR_601 0x00000100 - -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - -typedef uint64_t cycles_t; - -/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */ -static inline unsigned long get_tbl(void) -{ - unsigned long tbl; - -//#if defined(CONFIG_403GCX) -// asm volatile("mfspr %0, 0x3dd" : "=r" (tbl)); -//#else - asm volatile("mftb %0" : "=r" (tbl)); -//#endif - return tbl; -} - -static inline unsigned int get_tbu(void) -{ - unsigned int tbu; - -//#if defined(CONFIG_403GCX) -// asm volatile("mfspr %0, 0x3dc" : "=r" (tbu)); -//#else - asm volatile("mftbu %0" : "=r" (tbu)); -//#endif - return tbu; -} - - -#ifdef __powerpc64__ -static inline uint64_t get_tb(void) -{ - return mftb(); -} -#else -static inline uint64_t get_tb(void) -{ - unsigned int tbhi, tblo, tbhi2; - - do { - tbhi = get_tbu(); - tblo = get_tbl(); - tbhi2 = get_tbu(); - } while (tbhi != tbhi2); - - return ((uint64_t)tbhi << 32) | tblo; -} -#endif - -static inline cycles_t get_cycles(void) -{ - return get_tb(); -} - #endif /* __LTT_USERTRACE_PPC_H */ diff --git a/ltt-usertrace/ltt/ltt-usertrace.h b/ltt-usertrace/ltt/ltt-usertrace.h index 90729c67..be3a73d6 100644 --- a/ltt-usertrace/ltt/ltt-usertrace.h +++ b/ltt-usertrace/ltt/ltt-usertrace.h @@ -15,9 +15,22 @@ #include #include #include + +#define inline inline __attribute__((always_inline)) + #if defined(__powerpc__) || defined(__powerpc64__) -#include "ltt/ltt-usertrace-ppc.h" +#ifdef __powerpc64__ +#include +#include +#include +#else +#include +#include +#include +#include +#endif #else +#include #include #endif @@ -32,13 +45,22 @@ #define NR_syscalls 313 #endif -#ifdef powerpc +#ifdef __powerpc__ +#define __NR_ltt_trace_generic 283 +#define __NR_ltt_register_generic 284 +#undef NR_syscalls +#define NR_syscalls 285 +#endif + +#ifdef __powerpc64__ #define __NR_ltt_trace_generic 283 #define __NR_ltt_register_generic 284 #undef NR_syscalls #define NR_syscalls 285 #endif + + //FIXME : setup for ARM //FIXME : setup for MIPS diff --git a/ltt-usertrace/ltt/system-ppc.h b/ltt-usertrace/ltt/system-ppc.h index 0f13837c..a4498e75 100644 --- a/ltt-usertrace/ltt/system-ppc.h +++ b/ltt-usertrace/ltt/system-ppc.h @@ -45,7 +45,7 @@ #define smp_read_barrier_depends() do { } while(0) #endif /* CONFIG_SMP */ -static __inline__ unsigned long +static inline unsigned long xchg_u32(volatile void *p, unsigned long val) { unsigned long prev; @@ -95,7 +95,7 @@ extern inline void * xchg_ptr(void * m, void * val) #define __HAVE_ARCH_CMPXCHG 1 -static __inline__ unsigned long +static inline unsigned long __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) { unsigned int prev; @@ -122,7 +122,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) if something tries to do an invalid cmpxchg(). */ extern void __cmpxchg_called_with_bad_pointer(void); -static __inline__ unsigned long +static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { switch (size) { diff --git a/ltt-usertrace/ltt/system-ppc64.h b/ltt-usertrace/ltt/system-ppc64.h index 5fe60537..0d28bc9c 100644 --- a/ltt-usertrace/ltt/system-ppc64.h +++ b/ltt-usertrace/ltt/system-ppc64.h @@ -66,7 +66,7 @@ * Inline asm pulled from arch/ppc/kernel/misc.S so ppc64 * is more like most of the other architectures. */ -static __inline__ unsigned long +static inline unsigned long __xchg_u32(volatile int *m, unsigned long val) { unsigned long dummy; @@ -84,7 +84,7 @@ __xchg_u32(volatile int *m, unsigned long val) return (dummy); } -static __inline__ unsigned long +static inline unsigned long __xchg_u64(volatile long *m, unsigned long val) { unsigned long dummy; @@ -108,7 +108,7 @@ __xchg_u64(volatile long *m, unsigned long val) */ extern void __xchg_called_with_bad_pointer(void); -static __inline__ unsigned long +static inline unsigned long __xchg(volatile void *ptr, unsigned long x, int size) { switch (size) { @@ -131,7 +131,7 @@ __xchg(volatile void *ptr, unsigned long x, int size) #define __HAVE_ARCH_CMPXCHG 1 -static __inline__ unsigned long +static inline unsigned long __cmpxchg_u32(volatile int *p, int old, int new) { unsigned int prev; @@ -153,7 +153,7 @@ __cmpxchg_u32(volatile int *p, int old, int new) return prev; } -static __inline__ unsigned long +static inline unsigned long __cmpxchg_u64(volatile long *p, unsigned long old, unsigned long new) { unsigned long prev; @@ -179,7 +179,7 @@ __cmpxchg_u64(volatile long *p, unsigned long old, unsigned long new) if something tries to do an invalid cmpxchg(). */ extern void __cmpxchg_called_with_bad_pointer(void); -static __inline__ unsigned long +static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { switch (size) { diff --git a/ltt-usertrace/ltt/timex-ppc.h b/ltt-usertrace/ltt/timex-ppc.h new file mode 100644 index 00000000..2449907a --- /dev/null +++ b/ltt-usertrace/ltt/timex-ppc.h @@ -0,0 +1,53 @@ +#ifndef __TIMEX_PPC_H +#define __TIMEX_PPC_H + +#define CPU_FTR_601 0x00000100 + +#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ + +typedef uint64_t cycles_t; + +/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */ +static inline unsigned long get_tbl(void) +{ + unsigned long tbl; + +//#if defined(CONFIG_403GCX) +// asm volatile("mfspr %0, 0x3dd" : "=r" (tbl)); +//#else + asm volatile("mftb %0" : "=r" (tbl)); +//#endif + return tbl; +} + +static inline unsigned int get_tbu(void) +{ + unsigned int tbu; + +//#if defined(CONFIG_403GCX) +// asm volatile("mfspr %0, 0x3dc" : "=r" (tbu)); +//#else + asm volatile("mftbu %0" : "=r" (tbu)); +//#endif + return tbu; +} + +static inline uint64_t get_tb(void) +{ + unsigned int tbhi, tblo, tbhi2; + + do { + tbhi = get_tbu(); + tblo = get_tbl(); + tbhi2 = get_tbu(); + } while (tbhi != tbhi2); + + return ((uint64_t)tbhi << 32) | tblo; +} + +static inline cycles_t get_cycles(void) +{ + return get_tb(); +} + +#endif //__TIMEX_PPC_H -- 2.34.1