aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-01-19 19:38:14 -0500
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-01-19 19:38:14 -0500
commitca4a474ff184b93bc1d2c49b1d80edac844e65cf (patch)
tree62b0da916328d1e974669bcad62c6cc2f7efd4b8 /arch/x86/kernel
parente745cd9f0d056f1d00951c1eecdad2374b343d67 (diff)
Add Feather-Trace x86_32 architecture dependent code
Add x86_32 architecture dependent code and add the infrastructure for x86_32 - x86_64 integration.
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/ft_event.c112
2 files changed, 114 insertions, 0 deletions
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index d8e5d0cdd678..a99b34d1b3b8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -117,6 +117,8 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
117 117
118obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o 118obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
119 119
120obj-$(CONFIG_FEATHER_TRACE) += ft_event.o
121
120### 122###
121# 64 bit specific files 123# 64 bit specific files
122ifeq ($(CONFIG_X86_64),y) 124ifeq ($(CONFIG_X86_64),y)
diff --git a/arch/x86/kernel/ft_event.c b/arch/x86/kernel/ft_event.c
new file mode 100644
index 000000000000..e07ee30dfff9
--- /dev/null
+++ b/arch/x86/kernel/ft_event.c
@@ -0,0 +1,112 @@
1#include <linux/types.h>
2
3#include <litmus/feather_trace.h>
4
5#ifdef __ARCH_HAS_FEATHER_TRACE
6/* the feather trace management functions assume
7 * exclusive access to the event table
8 */
9
10
11#define BYTE_JUMP 0xeb
12#define BYTE_JUMP_LEN 0x02
13
14/* for each event, there is an entry in the event table */
15struct trace_event {
16 long id;
17 long count;
18 long start_addr;
19 long end_addr;
20};
21
22extern struct trace_event __start___event_table[];
23extern struct trace_event __stop___event_table[];
24
25int ft_enable_event(unsigned long id)
26{
27 struct trace_event* te = __start___event_table;
28 int count = 0;
29 char* delta;
30 unsigned char* instr;
31
32 while (te < __stop___event_table) {
33 if (te->id == id && ++te->count == 1) {
34 instr = (unsigned char*) te->start_addr;
35 /* make sure we don't clobber something wrong */
36 if (*instr == BYTE_JUMP) {
37 delta = (((unsigned char*) te->start_addr) + 1);
38 *delta = 0;
39 }
40 }
41 if (te->id == id)
42 count++;
43 te++;
44 }
45
46 printk(KERN_DEBUG "ft_enable_event: enabled %d events\n", count);
47 return count;
48}
49
50int ft_disable_event(unsigned long id)
51{
52 struct trace_event* te = __start___event_table;
53 int count = 0;
54 char* delta;
55 unsigned char* instr;
56
57 while (te < __stop___event_table) {
58 if (te->id == id && --te->count == 0) {
59 instr = (unsigned char*) te->start_addr;
60 if (*instr == BYTE_JUMP) {
61 delta = (((unsigned char*) te->start_addr) + 1);
62 *delta = te->end_addr - te->start_addr -
63 BYTE_JUMP_LEN;
64 }
65 }
66 if (te->id == id)
67 count++;
68 te++;
69 }
70
71 printk(KERN_DEBUG "ft_disable_event: disabled %d events\n", count);
72 return count;
73}
74
75int ft_disable_all_events(void)
76{
77 struct trace_event* te = __start___event_table;
78 int count = 0;
79 char* delta;
80 unsigned char* instr;
81
82 while (te < __stop___event_table) {
83 if (te->count) {
84 instr = (unsigned char*) te->start_addr;
85 if (*instr == BYTE_JUMP) {
86 delta = (((unsigned char*) te->start_addr)
87 + 1);
88 *delta = te->end_addr - te->start_addr -
89 BYTE_JUMP_LEN;
90 te->count = 0;
91 count++;
92 }
93 }
94 te++;
95 }
96 return count;
97}
98
99int ft_is_event_enabled(unsigned long id)
100{
101 struct trace_event* te = __start___event_table;
102
103 while (te < __stop___event_table) {
104 if (te->id == id)
105 return te->count;
106 te++;
107 }
108 return 0;
109}
110
111#endif
112