1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox disassembler:
|
---|
4 | * Internal header
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef ___DisasmInternal_h___
|
---|
24 | #define ___DisasmInternal_h___
|
---|
25 |
|
---|
26 | #include <VBox/cdefs.h>
|
---|
27 | #include <VBox/types.h>
|
---|
28 | #include <VBox/dis.h>
|
---|
29 |
|
---|
30 | #define ExceptionMemRead 0x666
|
---|
31 | #define ExceptionInvalidModRM 0x667
|
---|
32 | #define ExceptionInvalidParameter 0x668
|
---|
33 |
|
---|
34 | #define IDX_ParseNop 0
|
---|
35 | #define IDX_ParseModRM 1
|
---|
36 | #define IDX_UseModRM 2
|
---|
37 | #define IDX_ParseImmByte 3
|
---|
38 | #define IDX_ParseImmBRel 4
|
---|
39 | #define IDX_ParseImmUshort 5
|
---|
40 | #define IDX_ParseImmV 6
|
---|
41 | #define IDX_ParseImmVRel 7
|
---|
42 | #define IDX_ParseImmAddr 8
|
---|
43 | #define IDX_ParseFixedReg 9
|
---|
44 | #define IDX_ParseImmUlong 10
|
---|
45 | #define IDX_ParseImmQword 11
|
---|
46 | #define IDX_ParseTwoByteEsc 12
|
---|
47 | #define IDX_ParseImmGrpl 13
|
---|
48 | #define IDX_ParseShiftGrp2 14
|
---|
49 | #define IDX_ParseGrp3 15
|
---|
50 | #define IDX_ParseGrp4 16
|
---|
51 | #define IDX_ParseGrp5 17
|
---|
52 | #define IDX_Parse3DNow 18
|
---|
53 | #define IDX_ParseGrp6 19
|
---|
54 | #define IDX_ParseGrp7 20
|
---|
55 | #define IDX_ParseGrp8 21
|
---|
56 | #define IDX_ParseGrp9 22
|
---|
57 | #define IDX_ParseGrp10 23
|
---|
58 | #define IDX_ParseGrp12 24
|
---|
59 | #define IDX_ParseGrp13 25
|
---|
60 | #define IDX_ParseGrp14 26
|
---|
61 | #define IDX_ParseGrp15 27
|
---|
62 | #define IDX_ParseGrp16 28
|
---|
63 | #define IDX_ParseModFence 29
|
---|
64 | #define IDX_ParseYv 30
|
---|
65 | #define IDX_ParseYb 31
|
---|
66 | #define IDX_ParseXv 32
|
---|
67 | #define IDX_ParseXb 33
|
---|
68 | #define IDX_ParseEscFP 34
|
---|
69 | #define IDX_ParseNopPause 35
|
---|
70 | #define IDX_ParseImmByteSX 36
|
---|
71 | #define IDX_ParseImmZ 37
|
---|
72 | #define IDX_ParseThreeByteEsc4 38
|
---|
73 | #define IDX_ParseThreeByteEsc5 39
|
---|
74 | #define IDX_ParseMax (IDX_ParseThreeByteEsc5+1)
|
---|
75 |
|
---|
76 | #ifdef IN_RING0
|
---|
77 | #define DIS_THROW(a) /* Not available. */
|
---|
78 | #elif __L4ENV__
|
---|
79 | #define DIS_THROW(a) longjmp(*pCpu->pJumpBuffer, a)
|
---|
80 | #else
|
---|
81 | #define DIS_THROW(a) throw(a)
|
---|
82 | #endif
|
---|
83 |
|
---|
84 |
|
---|
85 | extern PFNDISPARSE pfnFullDisasm[IDX_ParseMax];
|
---|
86 | extern PFNDISPARSE pfnCalcSize[IDX_ParseMax];
|
---|
87 |
|
---|
88 |
|
---|
89 | __BEGIN_DECLS
|
---|
90 |
|
---|
91 | unsigned ParseInstruction(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, PDISCPUSTATE pCpu);
|
---|
92 |
|
---|
93 | unsigned ParseIllegal(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
94 | unsigned ParseModRM(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
95 | unsigned ParseModRM_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
96 | unsigned UseModRM(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
97 | unsigned ParseImmByte(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
98 | unsigned ParseImmByte_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
99 | unsigned ParseImmByteSX(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
100 | unsigned ParseImmByteSX_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
101 | unsigned ParseImmBRel(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
102 | unsigned ParseImmBRel_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
103 | unsigned ParseImmUshort(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
104 | unsigned ParseImmUshort_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
105 | unsigned ParseImmV(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
106 | unsigned ParseImmV_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
107 | unsigned ParseImmVRel(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
108 | unsigned ParseImmVRel_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
109 | unsigned ParseImmZ(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
110 | unsigned ParseImmZ_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
111 |
|
---|
112 | unsigned ParseImmAddr(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
113 | unsigned ParseImmAddr_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
114 | unsigned ParseFixedReg(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
115 | unsigned ParseImmUlong(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
116 | unsigned ParseImmUlong_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
117 | unsigned ParseImmQword(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
118 | unsigned ParseImmQword_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
119 |
|
---|
120 | unsigned ParseTwoByteEsc(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
121 | unsigned ParseThreeByteEsc4(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
122 | unsigned ParseThreeByteEsc5(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
123 | unsigned ParseImmGrpl(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
124 | unsigned ParseShiftGrp2(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
125 | unsigned ParseGrp3(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
126 | unsigned ParseGrp4(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
127 | unsigned ParseGrp5(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
128 | unsigned Parse3DNow(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
129 | unsigned ParseGrp6(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
130 | unsigned ParseGrp7(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
131 | unsigned ParseGrp8(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
132 | unsigned ParseGrp9(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
133 | unsigned ParseGrp10(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
134 | unsigned ParseGrp12(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
135 | unsigned ParseGrp13(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
136 | unsigned ParseGrp14(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
137 | unsigned ParseGrp15(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
138 | unsigned ParseGrp16(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
139 | unsigned ParseModFence(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
140 | unsigned ParseNopPause(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
141 |
|
---|
142 | unsigned ParseYv(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
143 | unsigned ParseYb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
144 | unsigned ParseXv(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
145 | unsigned ParseXb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
146 |
|
---|
147 | /* Floating point parsing */
|
---|
148 | unsigned ParseEscFP(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
|
---|
149 |
|
---|
150 | void disValidateLockSequence(PDISCPUSTATE pCpu);
|
---|
151 |
|
---|
152 | /* Disassembler printf */
|
---|
153 | void disasmSprintf(char *pszOutput, RTUINTPTR pu8Instruction, PDISCPUSTATE pCpu, POP_PARAMETER pParam1, POP_PARAMETER pParam2, POP_PARAMETER pParam3 = NULL);
|
---|
154 | void disasmGetPtrString(PDISCPUSTATE pCpu, PCOPCODE pOp, POP_PARAMETER pParam);
|
---|
155 | void disasmModRMReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam, int fRegAddr);
|
---|
156 | void disasmModRMReg16(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam);
|
---|
157 | void disasmModRMSReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam);
|
---|
158 | void disasmPrintAbs32(POP_PARAMETER pParam);
|
---|
159 | void disasmPrintDisp32(POP_PARAMETER pParam);
|
---|
160 | void disasmPrintDisp64(POP_PARAMETER pParam);
|
---|
161 | void disasmPrintDisp8(POP_PARAMETER pParam);
|
---|
162 | void disasmPrintDisp16(POP_PARAMETER pParam);
|
---|
163 |
|
---|
164 |
|
---|
165 | #ifdef IN_RC
|
---|
166 | #define DISReadByte(pCpu, pAddress) (*(uint8_t *)(pAddress))
|
---|
167 | #define DISReadWord(pCpu, pAddress) (*(uint16_t *)(pAddress))
|
---|
168 | #define DISReadDWord(pCpu, pAddress) (*(uint32_t *)(pAddress))
|
---|
169 | #define DISReadQWord(pCpu, pAddress) (*(uint64_t *)(pAddress))
|
---|
170 | #else
|
---|
171 | /* Read functions */
|
---|
172 | uint8_t DISReadByte(PDISCPUSTATE pCpu, RTUINTPTR pAddress);
|
---|
173 | uint16_t DISReadWord(PDISCPUSTATE pCpu, RTUINTPTR pAddress);
|
---|
174 | uint32_t DISReadDWord(PDISCPUSTATE pCpu, RTUINTPTR pAddress);
|
---|
175 | uint64_t DISReadQWord(PDISCPUSTATE pCpu, RTUINTPTR pAddress);
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | size_t disFormatBytes(PCDISCPUSTATE pCpu, char *pszDst, size_t cchDst, uint32_t fFlags);
|
---|
179 |
|
---|
180 | __END_DECLS
|
---|
181 |
|
---|
182 | #endif /* !___DisasmInternal_h___ */
|
---|
183 |
|
---|