diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2009-12-17 16:06:15 -0500 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2009-12-17 16:06:15 -0500 |
commit | 1872bfbc1f4a5b3c4980fae889787ab15ddcc83b (patch) | |
tree | ee980ec191b585f16ddee75c7537250aa1e054b6 | |
parent | aaf499a6cab77b827d427f234e5c1f1e21c410ef (diff) |
Porting on x86_64
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | SConstruct | 7 | ||||
-rw-r--r-- | include/cycles.h | 43 |
3 files changed, 46 insertions, 10 deletions
@@ -1,10 +1,14 @@ | |||
1 | .PHONY: all-32 all-64 clean purge | 1 | .PHONY: all-32 all-64 all-sparc clean purge |
2 | 2 | ||
3 | all-32: | 3 | all-32: |
4 | echo "Legacy warning: Building is done with scons." | 4 | echo "Legacy warning: Building is done with scons." |
5 | ARCH=x86 scons | 5 | ARCH=x86 scons |
6 | all-64: | 6 | all-64: |
7 | ARCH=x86_64 scons | 7 | ARCH=x86_64 scons |
8 | |||
9 | all-sparc: | ||
10 | ARCH=sparc64 scons | ||
11 | |||
8 | clean: | 12 | clean: |
9 | echo "Legacy warning: Building is now done with scons." | 13 | echo "Legacy warning: Building is now done with scons." |
10 | scons -c | 14 | scons -c |
@@ -58,7 +58,12 @@ else: | |||
58 | arch_flags = Split(SUPPORTED_ARCHS[arch]) | 58 | arch_flags = Split(SUPPORTED_ARCHS[arch]) |
59 | 59 | ||
60 | # add architecture dependent include search path | 60 | # add architecture dependent include search path |
61 | KERNEL_ARCH_INCLUDE = '%s/arch/%s/include' % (LITMUS_KERNEL, arch) | 61 | if arch in ['x86','x86_64']: |
62 | include_arch = 'x86' | ||
63 | else: | ||
64 | include_arch = 'sparc' | ||
65 | |||
66 | KERNEL_ARCH_INCLUDE = '%s/arch/%s/include' % (LITMUS_KERNEL, include_arch) | ||
62 | INCLUDE_DIRS = INCLUDE_DIRS + ' ' + KERNEL_ARCH_INCLUDE | 67 | INCLUDE_DIRS = INCLUDE_DIRS + ' ' + KERNEL_ARCH_INCLUDE |
63 | 68 | ||
64 | # Set Environment | 69 | # 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 @@ | |||
1 | #ifndef CYCLES_H | 1 | #ifndef CYCLES_H |
2 | #define CYCLES_H | 2 | #define CYCLES_H |
3 | 3 | ||
4 | #ifdef __i386__ | 4 | #ifdef __x86_64__ |
5 | |||
6 | #define rdtscll(val) do { \ | ||
7 | unsigned int __a,__d; \ | ||
8 | __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); \ | ||
9 | (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ | ||
10 | } while(0) | ||
11 | |||
12 | static __inline__ unsigned long long native_read_tsc(void) | ||
13 | { | ||
14 | unsigned long long val; | ||
15 | |||
16 | __asm__ __volatile__("mfence":::"memory"); | ||
17 | rdtscll(val); | ||
18 | __asm__ __volatile__("mfence":::"memory"); | ||
19 | |||
20 | return val; | ||
21 | } | ||
5 | 22 | ||
6 | typedef unsigned long long cycles_t; | ||
7 | 23 | ||
8 | #define CYCLES_FMT "llu" | 24 | #define CYCLES_FMT "llu" |
9 | 25 | ||
10 | static inline cycles_t get_cycles(void) | 26 | typedef unsigned long long cycles_t; |
27 | |||
28 | static inline cycles_t get_cycles(void) | ||
11 | { | 29 | { |
12 | unsigned long long ret; | 30 | return native_read_tsc(); |
13 | __asm__ __volatile__("rdtsc" : "=A" (ret)); | 31 | } |
14 | return ret; | 32 | #elif defined __i386__ |
33 | static inline unsigned long long native_read_tsc(void) { | ||
34 | unsigned long long val; | ||
35 | __asm__ __volatile__("rdtsc" : "=A" (val)); | ||
36 | return val; | ||
15 | } | 37 | } |
16 | 38 | ||
17 | #endif | 39 | typedef unsigned long long cycles_t; |
18 | 40 | ||
41 | #define CYCLES_FMT "llu" | ||
19 | 42 | ||
20 | #ifdef __sparc__ | 43 | static inline cycles_t get_cycles(void) |
44 | { | ||
45 | return native_read_tsc(); | ||
46 | } | ||
47 | #elif defined __sparc__ | ||
21 | 48 | ||
22 | #define NPT_BIT 63 | 49 | #define NPT_BIT 63 |
23 | 50 | ||