1 /******************************************************************************
2 * include/xen/trace.h
3 *
4 * Xen Trace Buffer
5 *
6 * Copyright (C) 2003 by Intel Research Cambridge
7 *
8 * Author: Mark Williamson, mark.a.williamson@intel.com
9 * Date: January 2004
10 *
11 * Copyright (C) 2005 Bin Ren
12 *
13 * The trace buffer code is designed to allow debugging traces of Xen to be
14 * generated on UP / SMP machines. Each trace entry is timestamped so that
15 * it's possible to reconstruct a chronological record of trace events.
16 *
17 * Access to the trace buffers is via a dom0 hypervisor op and analysis of
18 * trace buffer contents can then be performed using a userland tool.
19 */
20
21 #ifndef __XEN_TRACE_H__
22 #define __XEN_TRACE_H__
23
24 extern int tb_init_done;
25
26 #include <public/sysctl.h>
27 #include <public/trace.h>
28 #include <asm/trace.h>
29
30 /* Used to initialise trace buffer functionality */
31 void init_trace_bufs(void);
32
33 /* used to retrieve the physical address of the trace buffers */
34 int tb_control(struct xen_sysctl_tbuf_op *tbc);
35
36 int trace_will_trace_event(u32 event);
37
38 void __trace_var(u32 event, bool_t cycles, unsigned int extra, const void *);
39
trace_var(u32 event,int cycles,int extra,const void * extra_data)40 static inline void trace_var(u32 event, int cycles, int extra,
41 const void *extra_data)
42 {
43 if ( unlikely(tb_init_done) )
44 __trace_var(event, cycles, extra, extra_data);
45 }
46
47 void __trace_hypercall(uint32_t event, unsigned long op,
48 const xen_ulong_t *args);
49
50 /* Convenience macros for calling the trace function. */
51 #define TRACE_0D(_e) \
52 do { \
53 trace_var(_e, 1, 0, NULL); \
54 } while ( 0 )
55
56 #define TRACE_1D(_e,d1) \
57 do { \
58 if ( unlikely(tb_init_done) ) \
59 { \
60 u32 _d[1]; \
61 _d[0] = d1; \
62 __trace_var(_e, 1, sizeof(_d), _d); \
63 } \
64 } while ( 0 )
65
66 #define TRACE_2D(_e,d1,d2) \
67 do { \
68 if ( unlikely(tb_init_done) ) \
69 { \
70 u32 _d[2]; \
71 _d[0] = d1; \
72 _d[1] = d2; \
73 __trace_var(_e, 1, sizeof(_d), _d); \
74 } \
75 } while ( 0 )
76
77 #define TRACE_3D(_e,d1,d2,d3) \
78 do { \
79 if ( unlikely(tb_init_done) ) \
80 { \
81 u32 _d[3]; \
82 _d[0] = d1; \
83 _d[1] = d2; \
84 _d[2] = d3; \
85 __trace_var(_e, 1, sizeof(_d), _d); \
86 } \
87 } while ( 0 )
88
89 #define TRACE_4D(_e,d1,d2,d3,d4) \
90 do { \
91 if ( unlikely(tb_init_done) ) \
92 { \
93 u32 _d[4]; \
94 _d[0] = d1; \
95 _d[1] = d2; \
96 _d[2] = d3; \
97 _d[3] = d4; \
98 __trace_var(_e, 1, sizeof(_d), _d); \
99 } \
100 } while ( 0 )
101
102 #define TRACE_5D(_e,d1,d2,d3,d4,d5) \
103 do { \
104 if ( unlikely(tb_init_done) ) \
105 { \
106 u32 _d[5]; \
107 _d[0] = d1; \
108 _d[1] = d2; \
109 _d[2] = d3; \
110 _d[3] = d4; \
111 _d[4] = d5; \
112 __trace_var(_e, 1, sizeof(_d), _d); \
113 } \
114 } while ( 0 )
115
116 #define TRACE_6D(_e,d1,d2,d3,d4,d5,d6) \
117 do { \
118 if ( unlikely(tb_init_done) ) \
119 { \
120 u32 _d[6]; \
121 _d[0] = d1; \
122 _d[1] = d2; \
123 _d[2] = d3; \
124 _d[3] = d4; \
125 _d[4] = d5; \
126 _d[5] = d6; \
127 __trace_var(_e, 1, sizeof(_d), _d); \
128 } \
129 } while ( 0 )
130
131 #endif /* __XEN_TRACE_H__ */
132