From 1872bfbc1f4a5b3c4980fae889787ab15ddcc83b Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 16:06:15 -0500 Subject: Porting on x86_64 --- Makefile | 6 +++++- SConstruct | 7 ++++++- include/cycles.h | 43 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 409067e..bb8fffa 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,14 @@ -.PHONY: all-32 all-64 clean purge +.PHONY: all-32 all-64 all-sparc clean purge all-32: echo "Legacy warning: Building is done with scons." ARCH=x86 scons all-64: ARCH=x86_64 scons + +all-sparc: + ARCH=sparc64 scons + clean: echo "Legacy warning: Building is now done with scons." scons -c diff --git a/SConstruct b/SConstruct index 8e6981a..1f2a35b 100644 --- a/SConstruct +++ b/SConstruct @@ -58,7 +58,12 @@ else: arch_flags = Split(SUPPORTED_ARCHS[arch]) # add architecture dependent include search path -KERNEL_ARCH_INCLUDE = '%s/arch/%s/include' % (LITMUS_KERNEL, arch) +if arch in ['x86','x86_64']: + include_arch = 'x86' +else: + include_arch = 'sparc' + +KERNEL_ARCH_INCLUDE = '%s/arch/%s/include' % (LITMUS_KERNEL, include_arch) INCLUDE_DIRS = INCLUDE_DIRS + ' ' + KERNEL_ARCH_INCLUDE # Set Environment diff --git a/include/cycles.h b/include/cycles.h index 01f36a9..e9b0e11 100644 --- a/include/cycles.h +++ b/include/cycles.h @@ -1,23 +1,50 @@ #ifndef CYCLES_H #define CYCLES_H -#ifdef __i386__ +#ifdef __x86_64__ + +#define rdtscll(val) do { \ + unsigned int __a,__d; \ + __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); \ + (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ +} while(0) + +static __inline__ unsigned long long native_read_tsc(void) +{ + unsigned long long val; + + __asm__ __volatile__("mfence":::"memory"); + rdtscll(val); + __asm__ __volatile__("mfence":::"memory"); + + return val; +} -typedef unsigned long long cycles_t; #define CYCLES_FMT "llu" -static inline cycles_t get_cycles(void) +typedef unsigned long long cycles_t; + +static inline cycles_t get_cycles(void) { - unsigned long long ret; - __asm__ __volatile__("rdtsc" : "=A" (ret)); - return ret; + return native_read_tsc(); +} +#elif defined __i386__ +static inline unsigned long long native_read_tsc(void) { + unsigned long long val; + __asm__ __volatile__("rdtsc" : "=A" (val)); + return val; } -#endif +typedef unsigned long long cycles_t; +#define CYCLES_FMT "llu" -#ifdef __sparc__ +static inline cycles_t get_cycles(void) +{ + return native_read_tsc(); +} +#elif defined __sparc__ #define NPT_BIT 63 -- cgit v1.2.2