VirtualBox

source: vbox/trunk/src/VBox/VMM/include/IEMInternal.h@ 36944

Last change on this file since 36944 was 36857, checked in by vboxsync, 14 years ago

IEM: bsf, bsr, bt, btc, bts, btr and leave. Some cleaning up.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 34.5 KB
Line 
1/* $Id: IEMInternal.h 36857 2011-04-27 14:54:49Z vboxsync $ */
2/** @file
3 * IEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___IEMInternal_h
19#define ___IEMInternal_h
20
21#include <VBox/vmm/stam.h>
22#include <VBox/vmm/cpum.h>
23#include <VBox/param.h>
24
25
26RT_C_DECLS_BEGIN
27
28
29/** @defgroup grp_iem_int Internals
30 * @ingroup grp_iem
31 * @internal
32 * @{
33 */
34
35
36/**
37 * Operand or addressing mode.
38 */
39typedef enum IEMMODE
40{
41 IEMMODE_16BIT = 0,
42 IEMMODE_32BIT,
43 IEMMODE_64BIT
44} IEMMODE;
45AssertCompileSize(IEMMODE, 4);
46
47/**
48 * Extended operand mode that includes a representation of 8-bit.
49 *
50 * This is used for packing down modes when invoking some C instruction
51 * implementations.
52 */
53typedef enum IEMMODEX
54{
55 IEMMODEX_16BIT = IEMMODE_16BIT,
56 IEMMODEX_32BIT = IEMMODE_32BIT,
57 IEMMODEX_64BIT = IEMMODE_64BIT,
58 IEMMODEX_8BIT
59} IEMMODEX;
60AssertCompileSize(IEMMODEX, 4);
61
62
63#ifdef IEM_VERIFICATION_MODE
64
65/**
66 * Verification event type.
67 */
68typedef enum IEMVERIFYEVENT
69{
70 IEMVERIFYEVENT_INVALID = 0,
71 IEMVERIFYEVENT_IOPORT_READ,
72 IEMVERIFYEVENT_IOPORT_WRITE,
73 IEMVERIFYEVENT_RAM_WRITE,
74 IEMVERIFYEVENT_RAM_READ
75} IEMVERIFYEVENT;
76
77/** Checks if the event type is a RAM read or write. */
78# define IEMVERIFYEVENT_IS_RAM(a_enmType) ((a_enmType) == IEMVERIFYEVENT_RAM_WRITE || (a_enmType) == IEMVERIFYEVENT_RAM_READ)
79
80/**
81 * Verification event record.
82 */
83typedef struct IEMVERIFYEVTREC
84{
85 /** Pointer to the next record in the list. */
86 struct IEMVERIFYEVTREC *pNext;
87 /** The event type. */
88 IEMVERIFYEVENT enmEvent;
89 /** The event data. */
90 union
91 {
92 /** IEMVERIFYEVENT_IOPORT_READ */
93 struct
94 {
95 RTIOPORT Port;
96 uint32_t cbValue;
97 } IOPortRead;
98
99 /** IEMVERIFYEVENT_IOPORT_WRITE */
100 struct
101 {
102 RTIOPORT Port;
103 uint32_t cbValue;
104 uint32_t u32Value;
105 } IOPortWrite;
106
107 /** IEMVERIFYEVENT_RAM_READ */
108 struct
109 {
110 RTGCPHYS GCPhys;
111 uint32_t cb;
112 } RamRead;
113
114 /** IEMVERIFYEVENT_RAM_WRITE */
115 struct
116 {
117 RTGCPHYS GCPhys;
118 uint32_t cb;
119 uint8_t ab[32];
120 } RamWrite;
121 } u;
122} IEMVERIFYEVTREC;
123/** Pointer to an IEM event verification records. */
124typedef IEMVERIFYEVTREC *PIEMVERIFYEVTREC;
125
126#endif /* IEM_VERIFICATION_MODE */
127
128
129/**
130 * The per-CPU IEM state.
131 */
132typedef struct IEMCPU
133{
134 /** Pointer to the CPU context - ring-3 contex. */
135 R3PTRTYPE(PCPUMCTX) pCtxR3;
136 /** Pointer to the CPU context - ring-0 contex. */
137 R0PTRTYPE(PCPUMCTX) pCtxR0;
138 /** Pointer to the CPU context - raw-mode contex. */
139 RCPTRTYPE(PCPUMCTX) pCtxRC;
140
141 /** Offset of the VMCPU structure relative to this structure (negative). */
142 int32_t offVMCpu;
143 /** Offset of the VM structure relative to this structure (negative). */
144 int32_t offVM;
145
146 /** Whether to bypass access handlers or not. */
147 bool fByPassHandlers;
148 /** Explicit alignment padding. */
149 bool afAlignment0[6];
150
151 /** The CPL. */
152 uint8_t uCpl;
153 /** The current CPU execution mode (CS). */
154 IEMMODE enmCpuMode;
155
156 /** @name Statistics
157 * @{ */
158 /** The number of instructions we've executed. */
159 uint32_t cInstructions;
160 /** The number of potential exits. */
161 uint32_t cPotentialExits;
162#ifdef IEM_VERIFICATION_MODE
163 /** The Number of I/O port reads that has been performed. */
164 uint32_t cIOReads;
165 /** The Number of I/O port writes that has been performed. */
166 uint32_t cIOWrites;
167 /** Set if no comparison to REM is currently performed.
168 * This is used to skip past really slow bits. */
169 bool fNoRem;
170 bool afAlignment1[3];
171 /** Mask of undefined eflags.
172 * The verifier will any difference in these flags. */
173 uint32_t fUndefinedEFlags;
174 /** The physical address corresponding to abOpcodes[0]. */
175 RTGCPHYS GCPhysOpcodes;
176#endif
177 /** @} */
178
179 /** @name Decoder state.
180 * @{ */
181
182 /** The default addressing mode . */
183 IEMMODE enmDefAddrMode;
184 /** The effective addressing mode . */
185 IEMMODE enmEffAddrMode;
186 /** The default operand mode . */
187 IEMMODE enmDefOpSize;
188 /** The effective operand mode . */
189 IEMMODE enmEffOpSize;
190
191 /** The prefix mask (IEM_OP_PRF_XXX). */
192 uint32_t fPrefixes;
193 /** The extra REX ModR/M register field bit (REX.R << 3). */
194 uint8_t uRexReg;
195 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
196 * (REX.B << 3). */
197 uint8_t uRexB;
198 /** The extra REX SIB index field bit (REX.X << 3). */
199 uint8_t uRexIndex;
200 /** The effective segment register (X86_SREG_XXX). */
201 uint8_t iEffSeg;
202
203 /** The current offset into abOpcodes. */
204 uint8_t offOpcode;
205 /** The size of what has currently been fetched into abOpcodes. */
206 uint8_t cbOpcode;
207 /** The opcode bytes. */
208 uint8_t abOpcode[15];
209
210 /** @}*/
211
212 /** Alignment padding for aMemMappings. */
213 uint8_t abAlignment2[5];
214
215 /** The number of active guest memory mappings. */
216 uint8_t cActiveMappings;
217 /** The next unused mapping index. */
218 uint8_t iNextMapping;
219 /** Records for tracking guest memory mappings. */
220 struct
221 {
222 /** The address of the mapped bytes. */
223 void *pv;
224#if defined(IN_RC) && HC_ARCH_BITS == 64
225 uint32_t u32Alignment3; /**< Alignment padding. */
226#endif
227 /** The access flags (IEM_ACCESS_XXX).
228 * IEM_ACCESS_INVALID if the entry is unused. */
229 uint32_t fAccess;
230#if HC_ARCH_BITS == 64
231 uint32_t u32Alignment4; /**< Alignment padding. */
232#endif
233 } aMemMappings[3];
234
235 /** Bounce buffer info.
236 * This runs in parallel to aMemMappings. */
237 struct
238 {
239 /** The physical address of the first byte. */
240 RTGCPHYS GCPhysFirst;
241 /** The physical address of the second page. */
242 RTGCPHYS GCPhysSecond;
243 /** The number of bytes in the first page. */
244 uint16_t cbFirst;
245 /** The number of bytes in the second page. */
246 uint16_t cbSecond;
247 /** Whether it's unassigned memory. */
248 bool fUnassigned;
249 /** Explicit alignment padding. */
250 bool afAlignment5[3];
251 } aMemBbMappings[3];
252
253 /** Bounce buffer storage.
254 * This runs in parallel to aMemMappings and aMemBbMappings. */
255 struct
256 {
257 uint8_t ab[64];
258 } aBounceBuffers[3];
259
260#ifdef IEM_VERIFICATION_MODE
261 /** The event verification records for what IEM did (LIFO). */
262 R3PTRTYPE(PIEMVERIFYEVTREC) pIemEvtRecHead;
263 /** Insertion point for pIemEvtRecHead. */
264 R3PTRTYPE(PIEMVERIFYEVTREC *) ppIemEvtRecNext;
265 /** The event verification records for what the other party did (FIFO). */
266 R3PTRTYPE(PIEMVERIFYEVTREC) pOtherEvtRecHead;
267 /** Insertion point for pOtherEvtRecHead. */
268 R3PTRTYPE(PIEMVERIFYEVTREC *) ppOtherEvtRecNext;
269 /** List of free event records. */
270 R3PTRTYPE(PIEMVERIFYEVTREC) pFreeEvtRec;
271#endif
272} IEMCPU;
273/** Pointer to the per-CPU IEM state. */
274typedef IEMCPU *PIEMCPU;
275
276/** Converts a IEMCPU pointer to a VMCPU pointer.
277 * @returns VMCPU pointer.
278 * @param a_pIemCpu The IEM per CPU instance data.
279 */
280#define IEMCPU_TO_VMCPU(a_pIemCpu) ((PVMCPU)( (uintptr_t)(a_pIemCpu) + a_pIemCpu->offVMCpu ))
281
282/** Converts a IEMCPU pointer to a VM pointer.
283 * @returns VM pointer.
284 * @param a_pIemCpu The IEM per CPU instance data.
285 */
286#define IEMCPU_TO_VM(a_pIemCpu) ((PVM)( (uintptr_t)(a_pIemCpu) + a_pIemCpu->offVM ))
287
288/** @name IEM_ACCESS_XXX - Access details.
289 * @{ */
290#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
291#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
292#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
293#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
294#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
295#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
296#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
297#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
298#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
299#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
300/** Used in aMemMappings to indicate that the entry is bounce buffered. */
301#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000100)
302/** Read+write data alias. */
303#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
304/** Write data alias. */
305#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
306/** Read data alias. */
307#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
308/** Instruction fetch alias. */
309#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
310/** Stack write alias. */
311#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
312/** Stack read alias. */
313#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
314/** @} */
315
316/** @name Prefix constants (IEMCPU::fPrefixes)
317 * @{ */
318#define IEM_OP_PRF_SEG_CS RT_BIT_32(0)
319#define IEM_OP_PRF_SEG_SS RT_BIT_32(1)
320#define IEM_OP_PRF_SEG_DS RT_BIT_32(2)
321#define IEM_OP_PRF_SEG_ES RT_BIT_32(3)
322#define IEM_OP_PRF_SEG_FS RT_BIT_32(4)
323#define IEM_OP_PRF_SEG_GS RT_BIT_32(5)
324#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
325
326#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8)
327#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9)
328#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10)
329
330#define IEM_OP_PRF_LOCK RT_BIT_32(16)
331#define IEM_OP_PRF_REPNZ RT_BIT_32(17)
332#define IEM_OP_PRF_REPZ RT_BIT_32(18)
333
334#define IEM_OP_PRF_REX RT_BIT_32(24)
335#define IEM_OP_PRF_REX_R RT_BIT_32(25)
336#define IEM_OP_PRF_REX_B RT_BIT_32(26)
337#define IEM_OP_PRF_REX_X RT_BIT_32(27)
338/** @} */
339
340/**
341 * Tests if verification mode is enabled.
342 *
343 * This expands to @c false when IEM_VERIFICATION_MODE is not defined and
344 * should therefore cause the compiler to eliminate the verification branch
345 * of an if statement. */
346#ifdef IEM_VERIFICATION_MODE
347# define IEM_VERIFICATION_ENABLED(a_pIemCpu) (!(a_pIemCpu)->fNoRem)
348#else
349# define IEM_VERIFICATION_ENABLED(a_pIemCpu) (false)
350#endif
351
352/**
353 * Indicates to the verifier that the given flag set is undefined.
354 *
355 * Can be invoked again to add more flags.
356 *
357 * This is a NOOP if the verifier isn't compiled in.
358 */
359#ifdef IEM_VERIFICATION_MODE
360# define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { pIemCpu->fUndefinedEFlags |= (a_fEfl); } while (0)
361#else
362# define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { } while (0)
363#endif
364
365
366/** @def IEM_DECL_IMPL_TYPE
367 * For typedef'ing an instruction implementation function.
368 *
369 * @param a_RetType The return type.
370 * @param a_Name The name of the type.
371 * @param a_ArgList The argument list enclosed in parentheses.
372 */
373
374/** @def IEM_DECL_IMPL_DEF
375 * For defining an instruction implementation function.
376 *
377 * @param a_RetType The return type.
378 * @param a_Name The name of the type.
379 * @param a_ArgList The argument list enclosed in parentheses.
380 */
381
382#if defined(__GNUC__) && defined(RT_ARCH_X86)
383# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
384 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
385# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
386 __attribute__((__fastcall__, __nothrow__)) a_RetType a_Name a_ArgList
387
388#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
389# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
390 a_RetType (__fastcall a_Name) a_ArgList
391# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
392 a_RetType __fastcall a_Name a_ArgList
393
394#else
395# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
396 a_RetType (VBOXCALL a_Name) a_ArgList
397# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
398 a_RetType VBOXCALL a_Name a_ArgList
399
400#endif
401
402/** @name Arithmetic assignment operations on bytes (binary).
403 * @{ */
404typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU8, (uint8_t *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
405typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
406FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
407FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
408FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
409FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
410FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
411FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
412FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
413/** @} */
414
415/** @name Arithmetic assignment operations on words (binary).
416 * @{ */
417typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU16, (uint16_t *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
418typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
419FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
420FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
421FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
422FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
423FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
424FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
425FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
426/** @} */
427
428/** @name Arithmetic assignment operations on double words (binary).
429 * @{ */
430typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU32, (uint32_t *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
431typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
432FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
433FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
434FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
435FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
436FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
437FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
438FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
439/** @} */
440
441/** @name Arithmetic assignment operations on quad words (binary).
442 * @{ */
443typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU64, (uint64_t *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
444typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
445FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
446FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
447FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
448FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
449FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
450FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
451FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
452/** @} */
453
454/** @name Compare operations (thrown in with the binary ops).
455 * @{ */
456FNIEMAIMPLBINU8 iemAImpl_cmp_u8;
457FNIEMAIMPLBINU16 iemAImpl_cmp_u16;
458FNIEMAIMPLBINU32 iemAImpl_cmp_u32;
459FNIEMAIMPLBINU64 iemAImpl_cmp_u64;
460/** @} */
461
462/** @name Test operations (thrown in with the binary ops).
463 * @{ */
464FNIEMAIMPLBINU8 iemAImpl_test_u8;
465FNIEMAIMPLBINU16 iemAImpl_test_u16;
466FNIEMAIMPLBINU32 iemAImpl_test_u32;
467FNIEMAIMPLBINU64 iemAImpl_test_u64;
468/** @} */
469
470/** @name Bit operations operations (thrown in with the binary ops).
471 * @{ */
472FNIEMAIMPLBINU16 iemAImpl_bt_u16, iemAImpl_bt_u16_locked;
473FNIEMAIMPLBINU32 iemAImpl_bt_u32, iemAImpl_bt_u32_locked;
474FNIEMAIMPLBINU64 iemAImpl_bt_u64, iemAImpl_bt_u64_locked;
475FNIEMAIMPLBINU16 iemAImpl_btc_u16, iemAImpl_btc_u16_locked;
476FNIEMAIMPLBINU32 iemAImpl_btc_u32, iemAImpl_btc_u32_locked;
477FNIEMAIMPLBINU64 iemAImpl_btc_u64, iemAImpl_btc_u64_locked;
478FNIEMAIMPLBINU16 iemAImpl_btr_u16, iemAImpl_btr_u16_locked;
479FNIEMAIMPLBINU32 iemAImpl_btr_u32, iemAImpl_btr_u32_locked;
480FNIEMAIMPLBINU64 iemAImpl_btr_u64, iemAImpl_btr_u64_locked;
481FNIEMAIMPLBINU16 iemAImpl_bts_u16, iemAImpl_bts_u16_locked;
482FNIEMAIMPLBINU32 iemAImpl_bts_u32, iemAImpl_bts_u32_locked;
483FNIEMAIMPLBINU64 iemAImpl_bts_u64, iemAImpl_bts_u64_locked;
484/** @} */
485
486/** @name Exchange memory with register operations.
487 * @{ */
488IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8, (uint8_t *pu8Mem, uint8_t *pu8Reg));
489IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16,(uint16_t *pu16Mem, uint16_t *pu16Reg));
490IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32,(uint32_t *pu32Mem, uint32_t *pu32Reg));
491IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64,(uint64_t *pu64Mem, uint64_t *pu64Reg));
492/** @} */
493
494/** @name Double precision shifts
495 * @{ */
496typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU16,(uint16_t *pu16Dst, uint16_t u16Src, uint8_t cShift, uint32_t *pEFlags));
497typedef FNIEMAIMPLSHIFTDBLU16 *PFNIEMAIMPLSHIFTDBLU16;
498typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU32,(uint32_t *pu32Dst, uint32_t u32Src, uint8_t cShift, uint32_t *pEFlags));
499typedef FNIEMAIMPLSHIFTDBLU32 *PFNIEMAIMPLSHIFTDBLU32;
500typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t cShift, uint32_t *pEFlags));
501typedef FNIEMAIMPLSHIFTDBLU64 *PFNIEMAIMPLSHIFTDBLU64;
502FNIEMAIMPLSHIFTDBLU16 iemAImpl_shld_u16;
503FNIEMAIMPLSHIFTDBLU32 iemAImpl_shld_u32;
504FNIEMAIMPLSHIFTDBLU64 iemAImpl_shld_u64;
505FNIEMAIMPLSHIFTDBLU16 iemAImpl_shrd_u16;
506FNIEMAIMPLSHIFTDBLU32 iemAImpl_shrd_u32;
507FNIEMAIMPLSHIFTDBLU64 iemAImpl_shrd_u64;
508/** @} */
509
510
511/** @name Bit search operations (thrown in with the binary ops).
512 * @{ */
513FNIEMAIMPLBINU16 iemAImpl_bsf_u16;
514FNIEMAIMPLBINU32 iemAImpl_bsf_u32;
515FNIEMAIMPLBINU64 iemAImpl_bsf_u64;
516FNIEMAIMPLBINU16 iemAImpl_bsr_u16;
517FNIEMAIMPLBINU32 iemAImpl_bsr_u32;
518FNIEMAIMPLBINU64 iemAImpl_bsr_u64;
519/** @} */
520
521/** @name Signed multiplication operations (thrown in with the binary ops).
522 * @{ */
523FNIEMAIMPLBINU16 iemAImpl_imul_two_u16;
524FNIEMAIMPLBINU32 iemAImpl_imul_two_u32;
525FNIEMAIMPLBINU64 iemAImpl_imul_two_u64;
526/** @} */
527
528/** @name Arithmetic assignment operations on bytes (unary).
529 * @{ */
530typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
531typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
532FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
533FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
534FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
535FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
536/** @} */
537
538/** @name Arithmetic assignment operations on words (unary).
539 * @{ */
540typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
541typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
542FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
543FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
544FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
545FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
546/** @} */
547
548/** @name Arithmetic assignment operations on double words (unary).
549 * @{ */
550typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
551typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
552FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
553FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
554FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
555FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
556/** @} */
557
558/** @name Arithmetic assignment operations on quad words (unary).
559 * @{ */
560typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
561typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
562FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
563FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
564FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
565FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
566/** @} */
567
568
569/** @name Shift operations on bytes (Group 2).
570 * @{ */
571typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU8,(uint8_t *pu8Dst, uint8_t cShift, uint32_t *pEFlags));
572typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
573FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8;
574FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8;
575FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8;
576FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8;
577FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8;
578FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8;
579FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8;
580/** @} */
581
582/** @name Shift operations on words (Group 2).
583 * @{ */
584typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU16,(uint16_t *pu16Dst, uint8_t cShift, uint32_t *pEFlags));
585typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
586FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16;
587FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16;
588FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16;
589FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16;
590FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16;
591FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16;
592FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16;
593/** @} */
594
595/** @name Shift operations on double words (Group 2).
596 * @{ */
597typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU32,(uint32_t *pu32Dst, uint8_t cShift, uint32_t *pEFlags));
598typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
599FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32;
600FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32;
601FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32;
602FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32;
603FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32;
604FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32;
605FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32;
606/** @} */
607
608/** @name Shift operations on words (Group 2).
609 * @{ */
610typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU64,(uint64_t *pu64Dst, uint8_t cShift, uint32_t *pEFlags));
611typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
612FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64;
613FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64;
614FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64;
615FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64;
616FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64;
617FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64;
618FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64;
619/** @} */
620
621/** @name Multiplication and division operations.
622 * @{ */
623typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
624typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
625FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_imul_u8;
626FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_idiv_u8;
627
628typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
629typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
630FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_imul_u16;
631FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_idiv_u16;
632
633typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
634typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
635FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_imul_u32;
636FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_idiv_u32;
637
638typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
639typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
640FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_imul_u64;
641FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_idiv_u64;
642/** @} */
643
644
645/** @name C instruction implementations for anything slightly complicated.
646 * @{ */
647
648/**
649 * For typedef'ing or declaring a C instruction implementation function taking
650 * no extra arguments.
651 *
652 * @param a_Name The name of the type.
653 */
654# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
655 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr))
656/**
657 * For defining a C instruction implementation function taking no extra
658 * arguments.
659 *
660 * @param a_Name The name of the function
661 */
662# define IEM_CIMPL_DEF_0(a_Name) \
663 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr))
664/**
665 * For calling a C instruction implementation function taking no extra
666 * arguments.
667 *
668 * This special call macro adds default arguments to the call and allow us to
669 * change these later.
670 *
671 * @param a_fn The name of the function.
672 */
673# define IEM_CIMPL_CALL_0(a_fn) a_fn(pIemCpu, cbInstr)
674
675/**
676 * For typedef'ing or declaring a C instruction implementation function taking
677 * one extra argument.
678 *
679 * @param a_Name The name of the type.
680 * @param a_Type0 The argument type.
681 * @param a_Arg0 The argument name.
682 */
683# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
684 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0))
685/**
686 * For defining a C instruction implementation function taking one extra
687 * argument.
688 *
689 * @param a_Name The name of the function
690 * @param a_Type0 The argument type.
691 * @param a_Arg0 The argument name.
692 */
693# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
694 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0))
695/**
696 * For calling a C instruction implementation function taking one extra
697 * argument.
698 *
699 * This special call macro adds default arguments to the call and allow us to
700 * change these later.
701 *
702 * @param a_fn The name of the function.
703 * @param a0 The name of the 1st argument.
704 */
705# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pIemCpu, cbInstr, (a0))
706
707/**
708 * For typedef'ing or declaring a C instruction implementation function taking
709 * two extra arguments.
710 *
711 * @param a_Name The name of the type.
712 * @param a_Type0 The type of the 1st argument
713 * @param a_Arg0 The name of the 1st argument.
714 * @param a_Type1 The type of the 2nd argument.
715 * @param a_Arg1 The name of the 2nd argument.
716 */
717# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
718 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
719/**
720 * For defining a C instruction implementation function taking two extra
721 * arguments.
722 *
723 * @param a_Name The name of the function.
724 * @param a_Type0 The type of the 1st argument
725 * @param a_Arg0 The name of the 1st argument.
726 * @param a_Type1 The type of the 2nd argument.
727 * @param a_Arg1 The name of the 2nd argument.
728 */
729# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
730 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
731/**
732 * For calling a C instruction implementation function taking two extra
733 * arguments.
734 *
735 * This special call macro adds default arguments to the call and allow us to
736 * change these later.
737 *
738 * @param a_fn The name of the function.
739 * @param a0 The name of the 1st argument.
740 * @param a1 The name of the 2nd argument.
741 */
742# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pIemCpu, cbInstr, (a0), (a1))
743
744/**
745 * For typedef'ing or declaring a C instruction implementation function taking
746 * three extra arguments.
747 *
748 * @param a_Name The name of the type.
749 * @param a_Type0 The type of the 1st argument
750 * @param a_Arg0 The name of the 1st argument.
751 * @param a_Type1 The type of the 2nd argument.
752 * @param a_Arg1 The name of the 2nd argument.
753 * @param a_Type2 The type of the 3rd argument.
754 * @param a_Arg2 The name of the 3rd argument.
755 */
756# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
757 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
758/**
759 * For defining a C instruction implementation function taking three extra
760 * arguments.
761 *
762 * @param a_Name The name of the function.
763 * @param a_Type0 The type of the 1st argument
764 * @param a_Arg0 The name of the 1st argument.
765 * @param a_Type1 The type of the 2nd argument.
766 * @param a_Arg1 The name of the 2nd argument.
767 * @param a_Type2 The type of the 3rd argument.
768 * @param a_Arg2 The name of the 3rd argument.
769 */
770# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
771 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
772/**
773 * For calling a C instruction implementation function taking three extra
774 * arguments.
775 *
776 * This special call macro adds default arguments to the call and allow us to
777 * change these later.
778 *
779 * @param a_fn The name of the function.
780 * @param a0 The name of the 1st argument.
781 * @param a1 The name of the 2nd argument.
782 * @param a2 The name of the 3rd argument.
783 */
784# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pIemCpu, cbInstr, (a0), (a1), (a2))
785
786
787/**
788 * For typedef'ing or declaring a C instruction implementation function taking
789 * four extra arguments.
790 *
791 * @param a_Name The name of the type.
792 * @param a_Type0 The type of the 1st argument
793 * @param a_Arg0 The name of the 1st argument.
794 * @param a_Type1 The type of the 2nd argument.
795 * @param a_Arg1 The name of the 2nd argument.
796 * @param a_Type2 The type of the 3rd argument.
797 * @param a_Arg2 The name of the 3rd argument.
798 * @param a_Type3 The type of the 4th argument.
799 * @param a_Arg3 The name of the 4th argument.
800 */
801# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
802 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
803/**
804 * For defining a C instruction implementation function taking four extra
805 * arguments.
806 *
807 * @param a_Name The name of the function.
808 * @param a_Type0 The type of the 1st argument
809 * @param a_Arg0 The name of the 1st argument.
810 * @param a_Type1 The type of the 2nd argument.
811 * @param a_Arg1 The name of the 2nd argument.
812 * @param a_Type2 The type of the 3rd argument.
813 * @param a_Arg2 The name of the 3rd argument.
814 * @param a_Type3 The type of the 4th argument.
815 * @param a_Arg3 The name of the 4th argument.
816 */
817# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, aArg3) \
818 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
819/**
820 * For calling a C instruction implementation function taking four extra
821 * arguments.
822 *
823 * This special call macro adds default arguments to the call and allow us to
824 * change these later.
825 *
826 * @param a_fn The name of the function.
827 * @param a0 The name of the 1st argument.
828 * @param a1 The name of the 2nd argument.
829 * @param a2 The name of the 3rd argument.
830 * @param a3 The name of the 4th argument.
831 */
832# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pIemCpu, cbInstr, (a0), (a1), (a2), (a3))
833
834
835/**
836 * For typedef'ing or declaring a C instruction implementation function taking
837 * five extra arguments.
838 *
839 * @param a_Name The name of the type.
840 * @param a_Type0 The type of the 1st argument
841 * @param a_Arg0 The name of the 1st argument.
842 * @param a_Type1 The type of the 2nd argument.
843 * @param a_Arg1 The name of the 2nd argument.
844 * @param a_Type2 The type of the 3rd argument.
845 * @param a_Arg2 The name of the 3rd argument.
846 * @param a_Type3 The type of the 4th argument.
847 * @param a_Arg3 The name of the 4th argument.
848 * @param a_Type4 The type of the 5th argument.
849 * @param a_Arg4 The name of the 5th argument.
850 */
851# define IEM_CIMPL_DECL_TYPE_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
852 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, \
853 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
854 a_Type3 a_Arg3, a_Type4 a_Arg4))
855/**
856 * For defining a C instruction implementation function taking five extra
857 * arguments.
858 *
859 * @param a_Name The name of the function.
860 * @param a_Type0 The type of the 1st argument
861 * @param a_Arg0 The name of the 1st argument.
862 * @param a_Type1 The type of the 2nd argument.
863 * @param a_Arg1 The name of the 2nd argument.
864 * @param a_Type2 The type of the 3rd argument.
865 * @param a_Arg2 The name of the 3rd argument.
866 * @param a_Type3 The type of the 4th argument.
867 * @param a_Arg3 The name of the 4th argument.
868 * @param a_Type4 The type of the 5th argument.
869 * @param a_Arg4 The name of the 5th argument.
870 */
871# define IEM_CIMPL_DEF_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
872 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, \
873 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
874 a_Type3 a_Arg3, a_Type4 a_Arg4))
875/**
876 * For calling a C instruction implementation function taking five extra
877 * arguments.
878 *
879 * This special call macro adds default arguments to the call and allow us to
880 * change these later.
881 *
882 * @param a_fn The name of the function.
883 * @param a0 The name of the 1st argument.
884 * @param a1 The name of the 2nd argument.
885 * @param a2 The name of the 3rd argument.
886 * @param a3 The name of the 4th argument.
887 * @param a4 The name of the 5th argument.
888 */
889# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pIemCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
890
891/** @} */
892
893
894/** @} */
895
896RT_C_DECLS_END
897
898#endif
899
900
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette