Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: rstracer.h | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #ifndef _rstracer_h_9ecb7c16_ | |
24 | #define _rstracer_h_9ecb7c16_ | |
25 | ||
26 | /* rstracer.h */ | |
27 | static const int max_ncpu = 1024; | |
28 | ||
29 | static const char id[] = "SAM.rstracer"; | |
30 | ||
31 | // the per-cpu-tracer structure | |
32 | class rst_pct { | |
33 | public: | |
34 | ||
35 | int cpuid; | |
36 | ||
37 | enum state_e { | |
38 | state_NIL=0, // invalid | |
39 | state_DELAY, // skipping "delay" insts | |
40 | state_WAIT_SYNC_START, // skipped delay insts; waiting to sync up with other cpus | |
41 | state_WAIT_START, // not all cpus have reached sync point. waiting for last one to flag me | |
42 | state_TRACE_START, // will start trace at the next instr callback | |
43 | state_TRACING, // actively tracing | |
44 | state_WAIT_SYNC_STOP, // traced specified # of insts. waiting to sync up with other cpus | |
45 | state_WAIT_STOP, // not all cpus have reached sync point. waiting for last one to flag me | |
46 | state_MAX // invalid | |
47 | }; | |
48 | ||
49 | volatile state_e state; | |
50 | ||
51 | uint32_t icontext; | |
52 | uint32_t dcontext; | |
53 | ||
54 | uint64_t mask_pstate_am; | |
55 | ||
56 | // we check the pcontext and scontext values at each pavadiff record | |
57 | // If they have changed, we output a regval record | |
58 | uint32_t pcontext; | |
59 | uint32_t scontext; | |
60 | ||
61 | uint64_t pc_pavadiff; | |
62 | uint64_t ea_pavadiff; | |
63 | ||
64 | int64_t ninsts; | |
65 | int64_t nrecs; | |
66 | int64_t dinsts; // delay inst count (#insts since trace_on) | |
67 | ||
68 | char fname[PATH_MAX]; | |
69 | ||
70 | rstf_regvalT regval; | |
71 | ||
72 | uint8_t hpr; // hpstate.hpriv | |
73 | uint8_t pr; // pstate.priv | |
74 | ||
75 | #ifdef USE_RZ3 | |
76 | Rstzip * rz; | |
77 | #else | |
78 | FILE * trf; | |
79 | #endif | |
80 | ||
81 | uint64_t * memcache; | |
82 | rstf_memval64T mv64; | |
83 | rstf_memval128T mv128; | |
84 | ||
85 | ||
86 | // default constructor | |
87 | rst_pct() { | |
88 | state = state_NIL; | |
89 | } | |
90 | ||
91 | void init(int arg_cpuid, const char * tmp_tracefilename); | |
92 | ||
93 | void emit_trace_preamble(); | |
94 | ||
95 | void add_regval(int rstregtype, int rstregid, uint64_t v64); | |
96 | ||
97 | void flush_regval(); | |
98 | ||
99 | void addrec(rstf_unionT * ru); | |
100 | ||
101 | void string2rst(const char * str); | |
102 | ||
103 | int memcache_ref(uint64_t pa); // returns hit(1) or miss(0) | |
104 | ||
105 | void fini(); | |
106 | ||
107 | }; // struct rst_pct | |
108 | ||
109 | class rstracer : public VTracer { | |
110 | public: | |
111 | rstracer(const char * tmp_modname); | |
112 | ~rstracer(); | |
113 | ||
114 | int process_ui_cmd(int argc, char **tmp_argv); | |
115 | int attach(VTracer_SAM_intf * sam_intf); | |
116 | int instr(VCPU_Instruction * ii); | |
117 | int trap ( VCPU_Trap * ti); | |
118 | int tlb ( VCPU_TLB * ti); | |
119 | int async ( VCPU_AsyncData * di); | |
120 | int sync ( VCPU_Sync * si); | |
121 | int hwop (VCPU_HwOp * hi); | |
122 | ||
123 | private: | |
124 | ||
125 | // the parse_args_*() methods return 0 if success, error code otherwise | |
126 | int parse_args_v4(int argc, const char * tmp_argv[]); | |
127 | int parse_args_v5(int argc, const char * tmp_argv[]); | |
128 | ||
129 | void trace_on(); // initialize a new trace | |
130 | ||
131 | void print_status(); | |
132 | ||
133 | void trace_off(); | |
134 | ||
135 | const char * modname; | |
136 | ||
137 | VTracer_SAM_intf * SAM_intf; | |
138 | ||
139 | int ncpus; // total number of vcpu's | |
140 | int first_vcpu_id; // id of the first vcpu | |
141 | int last_vcpu_id; // id of the last vcpu | |
142 | ||
143 | bool tracing; | |
144 | ||
145 | int ntraces; | |
146 | int traces_done; | |
147 | int64_t initial_delay; | |
148 | ||
149 | int64_t insts_per_cpu; | |
150 | int64_t trace_period; // >= insts_per_cpu. the interval between starting points of periodic traces | |
151 | ||
152 | char tracefilename[PATH_MAX]; | |
153 | ||
154 | int64_t delay; // starts with initial_delay, then equal to (trace_period-insts_per_cpu) | |
155 | ||
156 | rst_pct * pcs; | |
157 | ||
158 | // for synchronized start/stop | |
159 | int sync_count; | |
160 | mutex_t mu; | |
161 | }; // class rstracer | |
162 | ||
163 | ||
164 | ||
165 | #endif // _rstracer_h_9ecb7c16_ |