aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2009-12-17 16:06:15 -0500
committerAndrea Bastoni <bastoni@cs.unc.edu>2009-12-17 16:06:15 -0500
commit1872bfbc1f4a5b3c4980fae889787ab15ddcc83b (patch)
treeee980ec191b585f16ddee75c7537250aa1e054b6
parentaaf499a6cab77b827d427f234e5c1f1e21c410ef (diff)
Porting on x86_64
-rw-r--r--Makefile6
-rw-r--r--SConstruct7
-rw-r--r--include/cycles.h43
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 @@
1.PHONY: all-32 all-64 clean purge 1.PHONY: all-32 all-64 all-sparc clean purge
2 2
3all-32: 3all-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
6all-64: 6all-64:
7 ARCH=x86_64 scons 7 ARCH=x86_64 scons
8
9all-sparc:
10 ARCH=sparc64 scons
11
8clean: 12clean:
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
diff --git a/SConstruct b/SConstruct
index 8e6981a..1f2a35b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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
61KERNEL_ARCH_INCLUDE = '%s/arch/%s/include' % (LITMUS_KERNEL, arch) 61if arch in ['x86','x86_64']:
62 include_arch = 'x86'
63else:
64 include_arch = 'sparc'
65
66KERNEL_ARCH_INCLUDE = '%s/arch/%s/include' % (LITMUS_KERNEL, include_arch)
62INCLUDE_DIRS = INCLUDE_DIRS + ' ' + KERNEL_ARCH_INCLUDE 67INCLUDE_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
12static __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
6typedef unsigned long long cycles_t;
7 23
8#define CYCLES_FMT "llu" 24#define CYCLES_FMT "llu"
9 25
10static inline cycles_t get_cycles(void) 26typedef unsigned long long cycles_t;
27
28static 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__
33static 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 39typedef unsigned long long cycles_t;
18 40
41#define CYCLES_FMT "llu"
19 42
20#ifdef __sparc__ 43static 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