diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-x86/feather_trace.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/include/asm-x86/feather_trace.h b/include/asm-x86/feather_trace.h index f60fbed07afb..253067eceeec 100644 --- a/include/asm-x86/feather_trace.h +++ b/include/asm-x86/feather_trace.h | |||
@@ -1,6 +1,97 @@ | |||
1 | #ifndef _ARCH_FEATHER_TRACE_H | 1 | #ifndef _ARCH_FEATHER_TRACE_H |
2 | #define _ARCH_FEATHER_TRACE_H | 2 | #define _ARCH_FEATHER_TRACE_H |
3 | 3 | ||
4 | static inline int fetch_and_inc(int *val) | ||
5 | { | ||
6 | int ret = 1; | ||
7 | __asm__ __volatile__("lock; xaddl %0, %1" : "+r" (ret), "+m" (*val) : : "memory" ); | ||
8 | return ret; | ||
9 | } | ||
10 | |||
11 | static inline int fetch_and_dec(int *val) | ||
12 | { | ||
13 | int ret = -1; | ||
14 | __asm__ __volatile__("lock; xaddl %0, %1" : "+r" (ret), "+m" (*val) : : "memory" ); | ||
15 | return ret; | ||
16 | } | ||
17 | |||
18 | #define feather_callback __attribute__((regparm(0))) | ||
19 | |||
20 | /* make the compiler reload any register that is not saved in | ||
21 | * a cdecl function call | ||
22 | */ | ||
23 | #define CLOBBER_LIST "memory", "cc", "eax", "ecx", "edx" | ||
24 | |||
25 | #define ft_event(id, callback) \ | ||
26 | __asm__ __volatile__( \ | ||
27 | "1: jmp 2f \n\t" \ | ||
28 | " call " #callback " \n\t" \ | ||
29 | ".section __event_table, \"aw\" \n\t" \ | ||
30 | ".long " #id ", 0, 1b, 2f \n\t" \ | ||
31 | ".previous \n\t" \ | ||
32 | "2: \n\t" \ | ||
33 | : : : CLOBBER_LIST) | ||
34 | |||
35 | #define ft_event0(id, callback) \ | ||
36 | __asm__ __volatile__( \ | ||
37 | "1: jmp 2f \n\t" \ | ||
38 | " subl $4, %%esp \n\t" \ | ||
39 | " movl $" #id ", (%%esp) \n\t" \ | ||
40 | " call " #callback " \n\t" \ | ||
41 | " addl $4, %%esp \n\t" \ | ||
42 | ".section __event_table, \"aw\" \n\t" \ | ||
43 | ".long " #id ", 0, 1b, 2f \n\t" \ | ||
44 | ".previous \n\t" \ | ||
45 | "2: \n\t" \ | ||
46 | : : : CLOBBER_LIST) | ||
47 | |||
48 | #define ft_event1(id, callback, param) \ | ||
49 | __asm__ __volatile__( \ | ||
50 | "1: jmp 2f \n\t" \ | ||
51 | " subl $8, %%esp \n\t" \ | ||
52 | " movl %0, 4(%%esp) \n\t" \ | ||
53 | " movl $" #id ", (%%esp) \n\t" \ | ||
54 | " call " #callback " \n\t" \ | ||
55 | " addl $8, %%esp \n\t" \ | ||
56 | ".section __event_table, \"aw\" \n\t" \ | ||
57 | ".long " #id ", 0, 1b, 2f \n\t" \ | ||
58 | ".previous \n\t" \ | ||
59 | "2: \n\t" \ | ||
60 | : : "r" (param) : CLOBBER_LIST) | ||
61 | |||
62 | #define ft_event2(id, callback, param, param2) \ | ||
63 | __asm__ __volatile__( \ | ||
64 | "1: jmp 2f \n\t" \ | ||
65 | " subl $12, %%esp \n\t" \ | ||
66 | " movl %1, 8(%%esp) \n\t" \ | ||
67 | " movl %0, 4(%%esp) \n\t" \ | ||
68 | " movl $" #id ", (%%esp) \n\t" \ | ||
69 | " call " #callback " \n\t" \ | ||
70 | " addl $12, %%esp \n\t" \ | ||
71 | ".section __event_table, \"aw\" \n\t" \ | ||
72 | ".long " #id ", 0, 1b, 2f \n\t" \ | ||
73 | ".previous \n\t" \ | ||
74 | "2: \n\t" \ | ||
75 | : : "r" (param), "r" (param2) : CLOBBER_LIST) | ||
76 | |||
77 | |||
78 | #define ft_event3(id, callback, p, p2, p3) \ | ||
79 | __asm__ __volatile__( \ | ||
80 | "1: jmp 2f \n\t" \ | ||
81 | " subl $16, %%esp \n\t" \ | ||
82 | " movl %1, 12(%%esp) \n\t" \ | ||
83 | " movl %1, 8(%%esp) \n\t" \ | ||
84 | " movl %0, 4(%%esp) \n\t" \ | ||
85 | " movl $" #id ", (%%esp) \n\t" \ | ||
86 | " call " #callback " \n\t" \ | ||
87 | " addl $16, %%esp \n\t" \ | ||
88 | ".section __event_table, \"aw\" \n\t" \ | ||
89 | ".long " #id ", 0, 1b, 2f \n\t" \ | ||
90 | ".previous \n\t" \ | ||
91 | "2: \n\t" \ | ||
92 | : : "r" (p), "r" (p2), "r" (p3) : CLOBBER_LIST) | ||
93 | |||
94 | |||
4 | static inline unsigned long long ft_timestamp(void) | 95 | static inline unsigned long long ft_timestamp(void) |
5 | { | 96 | { |
6 | unsigned long long ret; | 97 | unsigned long long ret; |
@@ -8,4 +99,6 @@ static inline unsigned long long ft_timestamp(void) | |||
8 | return ret; | 99 | return ret; |
9 | } | 100 | } |
10 | 101 | ||
102 | #define __ARCH_HAS_FEATHER_TRACE | ||
103 | |||
11 | #endif | 104 | #endif |