1 #ifndef __ANALYZE_H
2 # define __ANALYZE_H
3 
4 #include <stdint.h>
5 
6 #include <xen-tools/libs.h>
7 
8 #define TRC_GEN_MAIN     0
9 #define TRC_SCHED_MAIN   1
10 #define TRC_DOM0OP_MAIN  2
11 #define TRC_HVM_MAIN     3
12 #define TRC_MEM_MAIN     4
13 #define TRC_PV_MAIN      5
14 #define TRC_SHADOW_MAIN  6
15 #define TRC_HW_MAIN      7
16 
17 #define TRC_LOST_RECORDS_END    (TRC_GEN + 50)
18 
19 #define NR_CPUS 128
20 #if __x86_64__
21 # define BITS_PER_LONG 64
22 #else
23 # define BITS_PER_LONG 32
24 #endif
25 
26 #define BITS_TO_LONGS(bits) \
27     (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
28 #define DECLARE_BITMAP(name,bits) \
29     unsigned long name[BITS_TO_LONGS(bits)]
30 typedef struct cpumask{ DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
31 
32 enum {
33     TRCE_SFLAG_SET_AD,
34     TRCE_SFLAG_SET_A,
35     TRCE_SFLAG_SHADOW_L1_GET_REF,
36     TRCE_SFLAG_SHADOW_L1_PUT_REF,
37     TRCE_SFLAG_L2_PROPAGATE,
38     TRCE_SFLAG_SET_CHANGED,
39     TRCE_SFLAG_SET_FLUSH,
40     TRCE_SFLAG_SET_ERROR,
41     TRCE_SFLAG_DEMOTE,
42     TRCE_SFLAG_PROMOTE,
43     TRCE_SFLAG_WRMAP,
44     TRCE_SFLAG_WRMAP_GUESS_FOUND,
45     TRCE_SFLAG_WRMAP_BRUTE_FORCE,
46     TRCE_SFLAG_EARLY_UNSHADOW,
47     TRCE_SFLAG_EMULATION_2ND_PT_WRITTEN,
48     TRCE_SFLAG_EMULATION_LAST_FAILED,
49     TRCE_SFLAG_EMULATE_FULL_PT,
50     TRCE_SFLAG_PREALLOC_UNPIN,
51     TRCE_SFLAG_PREALLOC_UNHOOK
52 };
53 
54 #define TRC_HVM_OP_DESTROY_PROC (TRC_HVM_HANDLER + 0x100)
55 
56 typedef unsigned long long tsc_t;
57 
58 /* -- on-disk trace buffer definitions -- */
59 struct trace_record {
60     union {
61         struct {
62             unsigned event:28,
63                 extra_words:3,
64                 cycle_flag:1;
65             union {
66                 struct {
67                     uint32_t tsc_lo, tsc_hi;
68                     uint32_t data[7];
69                 } tsc;
70                 struct {
71                     uint32_t data[7];
72                 } notsc;
73             } u;
74         };
75         uint32_t raw[8];
76     };
77 };
78 
79 /* -- General info about a current record -- */
80 struct time_struct {
81     unsigned long long time;
82     unsigned int s, ns;
83 };
84 
85 #define DUMP_HEADER_MAX 256
86 
87 struct record_info {
88     int cpu;
89     tsc_t tsc;
90     union {
91         unsigned event;
92         struct {
93             unsigned minor:12,
94                 sub:4,
95                 main:12,
96                 unused:4;
97         } evt;
98     };
99     int extra_words;
100     int size;
101     uint32_t *d;
102     char dump_header[DUMP_HEADER_MAX];
103     struct time_struct t;
104     struct trace_record rec;
105 };
106 
107 #endif
108