1 |
39 |
zeus |
/////////////////////////////////////////////////////////////////////////
|
2 |
52 |
zeus |
// $Id: instrument.h,v 1.27 2008/04/19 10:12:09 sshwarts Exp $
|
3 |
39 |
zeus |
/////////////////////////////////////////////////////////////////////////
|
4 |
|
|
//
|
5 |
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
6 |
|
|
//
|
7 |
|
|
// MandrakeSoft S.A.
|
8 |
|
|
// 43, rue d'Aboukir
|
9 |
|
|
// 75002 Paris - France
|
10 |
|
|
// http://www.linux-mandrake.com/
|
11 |
|
|
// http://www.mandrakesoft.com/
|
12 |
|
|
//
|
13 |
|
|
// This library is free software; you can redistribute it and/or
|
14 |
|
|
// modify it under the terms of the GNU Lesser General Public
|
15 |
|
|
// License as published by the Free Software Foundation; either
|
16 |
|
|
// version 2 of the License, or (at your option) any later version.
|
17 |
|
|
//
|
18 |
|
|
// This library is distributed in the hope that it will be useful,
|
19 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
21 |
|
|
// Lesser General Public License for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU Lesser General Public
|
24 |
|
|
// License along with this library; if not, write to the Free Software
|
25 |
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
// possible types passed to BX_INSTR_TLB_CNTRL()
|
29 |
|
|
#define BX_INSTR_MOV_CR3 10
|
30 |
|
|
#define BX_INSTR_INVLPG 11
|
31 |
|
|
#define BX_INSTR_TASKSWITCH 12
|
32 |
|
|
|
33 |
|
|
// possible types passed to BX_INSTR_CACHE_CNTRL()
|
34 |
|
|
#define BX_INSTR_INVD 20
|
35 |
|
|
#define BX_INSTR_WBINVD 21
|
36 |
|
|
|
37 |
|
|
// possible types passed to BX_INSTR_FAR_BRANCH()
|
38 |
|
|
#define BX_INSTR_IS_CALL 10
|
39 |
|
|
#define BX_INSTR_IS_RET 11
|
40 |
|
|
#define BX_INSTR_IS_IRET 12
|
41 |
|
|
#define BX_INSTR_IS_JMP 13
|
42 |
|
|
#define BX_INSTR_IS_INT 14
|
43 |
|
|
#define BX_INSTR_IS_SYSCALL 15
|
44 |
|
|
#define BX_INSTR_IS_SYSRET 16
|
45 |
|
|
#define BX_INSTR_IS_SYSENTER 17
|
46 |
|
|
#define BX_INSTR_IS_SYSEXIT 18
|
47 |
|
|
|
48 |
|
|
// possible types passed to BX_INSTR_PREFETCH_HINT()
|
49 |
|
|
#define BX_INSTR_PREFETCH_NTA 0
|
50 |
|
|
#define BX_INSTR_PREFETCH_T0 1
|
51 |
|
|
#define BX_INSTR_PREFETCH_T1 2
|
52 |
|
|
#define BX_INSTR_PREFETCH_T2 3
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
#if BX_INSTRUMENTATION
|
56 |
|
|
|
57 |
|
|
class bxInstruction_c;
|
58 |
|
|
|
59 |
|
|
// called from the CPU core
|
60 |
|
|
|
61 |
|
|
void bx_instr_init(unsigned cpu);
|
62 |
|
|
void bx_instr_reset(unsigned cpu);
|
63 |
|
|
void bx_instr_start();
|
64 |
|
|
void bx_instr_stop();
|
65 |
|
|
void bx_instr_print();
|
66 |
|
|
void bx_instr_new_instruction(unsigned cpu);
|
67 |
|
|
|
68 |
|
|
void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip);
|
69 |
|
|
void bx_instr_cnear_branch_not_taken(unsigned cpu);
|
70 |
|
|
void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip);
|
71 |
|
|
void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address new_eip);
|
72 |
|
|
|
73 |
|
|
void bx_instr_opcode(unsigned cpu, const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64);
|
74 |
|
|
void bx_instr_fetch_decode_completed(unsigned cpu, bxInstruction_c *i);
|
75 |
|
|
|
76 |
|
|
void bx_instr_prefix(unsigned cpu, Bit8u prefix);
|
77 |
|
|
|
78 |
|
|
void bx_instr_interrupt(unsigned cpu, unsigned vector);
|
79 |
|
|
void bx_instr_exception(unsigned cpu, unsigned vector);
|
80 |
|
|
void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address eip);
|
81 |
|
|
|
82 |
|
|
void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw);
|
83 |
|
|
|
84 |
|
|
/* simulation init, shutdown, reset */
|
85 |
|
|
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id)
|
86 |
|
|
# define BX_INSTR_EXIT(cpu_id)
|
87 |
|
|
# define BX_INSTR_RESET(cpu_id) bx_instr_reset(cpu_id)
|
88 |
|
|
# define BX_INSTR_HLT(cpu_id)
|
89 |
|
|
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
|
90 |
|
|
# define BX_INSTR_NEW_INSTRUCTION(cpu_id) bx_instr_new_instruction(cpu_id)
|
91 |
|
|
|
92 |
|
|
/* called from command line debugger */
|
93 |
|
|
# define BX_INSTR_DEBUG_PROMPT()
|
94 |
|
|
# define BX_INSTR_START() bx_instr_start()
|
95 |
|
|
# define BX_INSTR_STOP() bx_instr_stop()
|
96 |
|
|
# define BX_INSTR_PRINT() bx_instr_print()
|
97 |
|
|
|
98 |
|
|
/* branch resoultion */
|
99 |
|
|
# define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) bx_instr_cnear_branch_taken(cpu_id, new_eip)
|
100 |
|
|
# define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) bx_instr_cnear_branch_not_taken(cpu_id)
|
101 |
|
|
# define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) bx_instr_ucnear_branch(cpu_id, what, new_eip)
|
102 |
|
|
# define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) bx_instr_far_branch(cpu_id, what, new_cs, new_eip)
|
103 |
|
|
|
104 |
|
|
/* decoding completed */
|
105 |
|
|
# define BX_INSTR_OPCODE(cpu_id, opcode, len, is32, is64) \
|
106 |
|
|
bx_instr_opcode(cpu_id, opcode, len, is32, is64)
|
107 |
|
|
# define BX_INSTR_FETCH_DECODE_COMPLETED(cpu_id, i) \
|
108 |
|
|
bx_instr_fetch_decode_completed(cpu_id, i)
|
109 |
|
|
|
110 |
|
|
/* prefix byte decoded */
|
111 |
|
|
# define BX_INSTR_PREFIX(cpu_id, prefix) bx_instr_prefix(cpu_id, prefix)
|
112 |
|
|
|
113 |
|
|
/* exceptional case and interrupt */
|
114 |
|
|
# define BX_INSTR_EXCEPTION(cpu_id, vector) bx_instr_exception(cpu_id, vector)
|
115 |
|
|
# define BX_INSTR_INTERRUPT(cpu_id, vector) bx_instr_interrupt(cpu_id, vector)
|
116 |
|
|
# define BX_INSTR_HWINTERRUPT(cpu_id, vector, cs, eip) bx_instr_hwinterrupt(cpu_id, vector, cs, eip)
|
117 |
|
|
|
118 |
|
|
/* TLB/CACHE control instruction executed */
|
119 |
|
|
# define BX_INSTR_CLFLUSH(cpu_id, laddr, paddr)
|
120 |
|
|
# define BX_INSTR_CACHE_CNTRL(cpu_id, what)
|
121 |
|
|
# define BX_INSTR_TLB_CNTRL(cpu_id, what, new_cr3)
|
122 |
|
|
# define BX_INSTR_PREFETCH_HINT(cpu_id, what, seg, offset)
|
123 |
|
|
|
124 |
|
|
/* execution */
|
125 |
|
|
# define BX_INSTR_BEFORE_EXECUTION(cpu_id, i)
|
126 |
|
|
# define BX_INSTR_AFTER_EXECUTION(cpu_id, i)
|
127 |
|
|
# define BX_INSTR_REPEAT_ITERATION(cpu_id, i)
|
128 |
|
|
|
129 |
|
|
/* memory access */
|
130 |
|
|
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
131 |
|
|
|
132 |
|
|
/* memory access */
|
133 |
|
|
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw) \
|
134 |
|
|
bx_instr_mem_data_access(cpu_id, seg, offset, len, rw)
|
135 |
|
|
|
136 |
|
|
/* called from memory object */
|
137 |
|
|
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
138 |
|
|
# define BX_INSTR_PHY_READ(cpu_id, addr, len)
|
139 |
|
|
|
140 |
|
|
/* feedback from device units */
|
141 |
|
|
# define BX_INSTR_INP(addr, len)
|
142 |
|
|
# define BX_INSTR_INP2(addr, len, val)
|
143 |
|
|
# define BX_INSTR_OUTP(addr, len)
|
144 |
|
|
# define BX_INSTR_OUTP2(addr, len, val)
|
145 |
|
|
|
146 |
|
|
/* wrmsr callback */
|
147 |
|
|
# define BX_INSTR_WRMSR(cpu_id, addr, value)
|
148 |
|
|
|
149 |
|
|
#else
|
150 |
|
|
|
151 |
|
|
/* simulation init, shutdown, reset */
|
152 |
|
|
# define BX_INSTR_INIT(cpu_id)
|
153 |
|
|
# define BX_INSTR_EXIT(cpu_id)
|
154 |
|
|
# define BX_INSTR_RESET(cpu_id)
|
155 |
|
|
# define BX_INSTR_HLT(cpu_id)
|
156 |
|
|
# define BX_INSTR_MWAIT(cpu_id, addr, len, flags)
|
157 |
|
|
# define BX_INSTR_NEW_INSTRUCTION(cpu_id)
|
158 |
|
|
|
159 |
|
|
/* called from command line debugger */
|
160 |
|
|
# define BX_INSTR_DEBUG_PROMPT()
|
161 |
|
|
# define BX_INSTR_START()
|
162 |
|
|
# define BX_INSTR_STOP()
|
163 |
|
|
# define BX_INSTR_PRINT()
|
164 |
|
|
|
165 |
|
|
/* branch resoultion */
|
166 |
|
|
# define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip)
|
167 |
|
|
# define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id)
|
168 |
|
|
# define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip)
|
169 |
|
|
# define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip)
|
170 |
|
|
|
171 |
|
|
/* decoding completed */
|
172 |
|
|
# define BX_INSTR_OPCODE(cpu_id, opcode, len, is32, is64)
|
173 |
|
|
# define BX_INSTR_FETCH_DECODE_COMPLETED(cpu_id, i)
|
174 |
|
|
|
175 |
|
|
/* prefix byte decoded */
|
176 |
|
|
# define BX_INSTR_PREFIX(cpu_id, prefix)
|
177 |
|
|
|
178 |
|
|
/* exceptional case and interrupt */
|
179 |
|
|
# define BX_INSTR_EXCEPTION(cpu_id, vector)
|
180 |
|
|
# define BX_INSTR_INTERRUPT(cpu_id, vector)
|
181 |
|
|
# define BX_INSTR_HWINTERRUPT(cpu_id, vector, cs, eip)
|
182 |
|
|
|
183 |
|
|
/* TLB/CACHE control instruction executed */
|
184 |
|
|
# define BX_INSTR_CLFLUSH(cpu_id, laddr, paddr)
|
185 |
|
|
# define BX_INSTR_CACHE_CNTRL(cpu_id, what)
|
186 |
|
|
# define BX_INSTR_TLB_CNTRL(cpu_id, what, new_cr3)
|
187 |
|
|
# define BX_INSTR_PREFETCH_HINT(cpu_id, what, seg, offset)
|
188 |
|
|
|
189 |
|
|
/* execution */
|
190 |
|
|
# define BX_INSTR_BEFORE_EXECUTION(cpu_id, i)
|
191 |
|
|
# define BX_INSTR_AFTER_EXECUTION(cpu_id, i)
|
192 |
|
|
# define BX_INSTR_REPEAT_ITERATION(cpu_id, i)
|
193 |
|
|
|
194 |
|
|
/* memory access */
|
195 |
|
|
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
196 |
|
|
|
197 |
|
|
/* memory access */
|
198 |
|
|
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw)
|
199 |
|
|
|
200 |
|
|
/* called from memory object */
|
201 |
|
|
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
202 |
|
|
# define BX_INSTR_PHY_READ(cpu_id, addr, len)
|
203 |
|
|
|
204 |
|
|
/* feedback from device units */
|
205 |
|
|
# define BX_INSTR_INP(addr, len)
|
206 |
|
|
# define BX_INSTR_INP2(addr, len, val)
|
207 |
|
|
# define BX_INSTR_OUTP(addr, len)
|
208 |
|
|
# define BX_INSTR_OUTP2(addr, len, val)
|
209 |
|
|
|
210 |
|
|
/* wrmsr callback */
|
211 |
|
|
# define BX_INSTR_WRMSR(cpu_id, addr, value)
|
212 |
|
|
|
213 |
|
|
#endif
|