VirtualBox

Changeset 41692 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jun 13, 2012 7:32:54 PM (13 years ago)
Author:
vboxsync
Message:

DIS: Reducing the DISCPUMODE even more (200 bytes now) and making it have the same layout in all contexts. This is useful since it's used several places in the VM structure. Also a bunch of other cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dis.h

    r41690 r41692  
    2727#define ___VBox_dis_h
    2828
    29 #include <VBox/cdefs.h>
    3029#include <VBox/types.h>
    3130#include <VBox/disopcode.h>
     31#include <iprt/assert.h>
    3232
    3333
     
    390390 * Operand Parameter.
    391391 */
    392 typedef struct OP_PARAMETER
     392typedef struct DISOPPARAM
    393393{
    394394    uint64_t        parval;
     
    410410    union
    411411    {
    412         uint32_t    reg_gen;
     412        uint8_t     reg_gen;
    413413        /** ST(0) - ST(7) */
    414         uint32_t    reg_fp;
     414        uint8_t     reg_fp;
    415415        /** MMX0 - MMX7 */
    416         uint32_t    reg_mmx;
     416        uint8_t     reg_mmx;
    417417        /** XMM0 - XMM7 */
    418         uint32_t    reg_xmm;
    419         /** {ES, CS, SS, DS, FS, GS} */
    420         DIS_SELREG  reg_seg;
     418        uint8_t     reg_xmm;
     419        /** {ES, CS, SS, DS, FS, GS} (DIS_SELREG). */
     420        uint8_t     reg_seg;
    421421        /** TR0-TR7 (?) */
    422         uint32_t    reg_test;
     422        uint8_t     reg_test;
    423423        /** CR0-CR4 */
    424         uint32_t    reg_ctrl;
     424        uint8_t     reg_ctrl;
    425425        /** DR0-DR7 */
    426         uint32_t    reg_dbg;
     426        uint8_t     reg_dbg;
    427427    } base;
    428428    union
    429429    {
    430         uint32_t    reg_gen;
     430        uint8_t     reg_gen;
    431431    } index;
    432432
     
    435435    /** Parameter size. */
    436436    uint8_t         cb;
    437 } OP_PARAMETER;
     437} DISOPPARAM;
     438AssertCompileSize(DISOPPARAM, 32);
    438439/** Pointer to opcode parameter. */
    439 typedef OP_PARAMETER *POP_PARAMETER;
     440typedef DISOPPARAM *PDISOPPARAM;
    440441/** Pointer to opcode parameter. */
    441 typedef const OP_PARAMETER *PCOP_PARAMETER;
     442typedef const DISOPPARAM *PCOP_PARAMETER;
    442443
    443444
     
    462463/** Parser callback.
    463464 * @remark no DECLCALLBACK() here because it's considered to be internal (really, I'm too lazy to update all the functions). */
    464 typedef unsigned FNDISPARSE(RTUINTPTR pu8CodeBlock, PCDISOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
     465typedef unsigned FNDISPARSE(RTUINTPTR pu8CodeBlock, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu);
    465466typedef FNDISPARSE *PFNDISPARSE;
     467typedef PFNDISPARSE const *PCPFNDISPARSE;
    466468
    467469typedef struct DISCPUSTATE
    468470{
    469     /** Global setting. */
    470     DISCPUMODE      mode;
    471 
    472     /** Per instruction prefix settings. */
    473     uint32_t        prefix;  /**< @todo change to uint8_t */
    474     /** segment prefix value. */
    475     DIS_SELREG      enmPrefixSeg;
    476     /** rex prefix value (64 bits only */
    477     uint32_t        prefix_rex; /**< @todo change to uint8_t */
    478     /** addressing mode (16 or 32 bits). (CPUMODE_*) */
    479     DISCPUMODE      addrmode;
    480     /** operand mode (16 or 32 bits). (CPUMODE_*) */
    481     DISCPUMODE      opmode;
    482 
    483     OP_PARAMETER    param1;
    484     OP_PARAMETER    param2;
    485     OP_PARAMETER    param3;
    486 
    487     /** ModRM fields. */
     471    /* Because of apvUserData[1] and apvUserData[2], put the less frequently
     472       used bits at the top for now.  (Might be better off in the middle?) */
     473    DISOPPARAM      param3;
     474    DISOPPARAM      param2;
     475    DISOPPARAM      param1;
     476
     477    /* off: 0x060 (96) */
     478    /** ModRM fields. */               
    488479    union
    489480    {
     
    498489        unsigned            u;
    499490    } ModRM;
    500 
    501491    /** SIB fields. */
    502492    union
     
    512502        unsigned            u;
    513503    } SIB;
    514     int32_t         i32SibDisp;
    515 
     504    int32_t         i32SibDisp;         
     505
     506    /* off: 0x06c (108) */
     507    /** The CPU mode (DISCPUMODE). */
     508    uint8_t         mode;               
     509    /** The addressing mode (DISCPUMODE). */
     510    uint8_t         addrmode;
     511    /** The operand mode (DISCPUMODE). */
     512    uint8_t         opmode;
     513    /** Per instruction prefix settings. */
     514    uint8_t         prefix; 
     515    /* off: 0x070 (112) */
     516    /** REX prefix value (64 bits only). */
     517    uint8_t         prefix_rex;         
     518    /** Segment prefix value (DIS_SELREG). */
     519    uint8_t         idxSegPrefix;
     520    /** Last prefix byte (for SSE2 extension tables). */
     521    uint8_t         lastprefix;
     522    /** First opcode byte of instruction. */
     523    uint8_t         opcode;
     524    /* off: 0x074 (116) */
     525    /** The size of the prefix bytes. */
     526    uint8_t         cbPrefix;           
    516527    /** The instruction size. */
    517     uint32_t        opsize;
     528    uint8_t         opsize;
     529    uint8_t         abUnused[2];
     530    /* off: 0x078 (120) */
     531    /** Return code set by a worker function like the opcode bytes readers. */
     532    int32_t         rc;
     533    /** Internal: instruction filter */
     534    uint32_t        fFilter;
     535    /* off: 0x080 (128) */
     536    /** Internal: pointer to disassembly function table */
     537    PCPFNDISPARSE   pfnDisasmFnTable;
     538#if ARCH_BITS == 32
     539    uint32_t        uPtrPadding1;
     540#endif
     541    /** Pointer to the current instruction. */
     542    PCDISOPCODE     pCurInstr;
     543#if ARCH_BITS == 32
     544    uint32_t        uPtrPadding2;
     545#endif
     546    /* off: 0x090 (144) */
    518547    /** The address of the instruction. */
    519548    RTUINTPTR       uInstrAddr;
    520     /** The size of the prefix bytes. */
    521     uint8_t         cbPrefix;
    522 
    523     /** First opcode byte of instruction. */
    524     uint8_t         opcode;
    525     /** Last prefix byte (for SSE2 extension tables). */
    526     uint8_t         lastprefix;
     549    /* off: 0x098 (152) */
     550    /** Optional read function */
     551    PFNDISREADBYTES pfnReadBytes;
     552#if ARCH_BITS == 32
     553    uint32_t        uPadding3;
     554#endif
     555    /* off: 0x0a0 (160) */
    527556    /** The instruction bytes. */
    528557    uint8_t         abInstr[16];
    529 
    530     /** Internal: pointer to disassembly function table */
    531     PFNDISPARSE    *pfnDisasmFnTable;
    532     /** Internal: instruction filter */
    533     uint32_t        fFilter;
    534     /** Return code set by a worker function like the opcode bytes readers. */
    535     int32_t         rc;
    536 
    537     /** Pointer to the current instruction. */
    538     PCDISOPCODE     pCurInstr;
    539 #ifndef DIS_CORE_ONLY
    540     /** Opcode format string for current instruction. */
    541     const char      *pszOpcode;
    542 #endif
    543 
    544     /** Optional read function */
    545     PFNDISREADBYTES pfnReadBytes;
     558    /* off: 0x0b0 (176) */
    546559    /** User data slots for the read callback.  The first entry is used for the
    547560     *  pvUser argument, the rest are up for grabs.
    548561     * @remarks This must come last so that we can memset everything before this. */
    549562    void           *apvUserData[3];
     563#if ARCH_BITS == 32
     564    uint32_t        auPadding4[3];
     565#endif
    550566} DISCPUSTATE;
    551567
     
    568584    uint16_t    param2;
    569585    uint16_t    param3;
    570 
    571586    uint32_t    optype;
    572587} DISOPCODE;
     
    589604                       PDISCPUSTATE pCpu, uint32_t *pcbInstr);
    590605
    591 DISDECL(int)        DISGetParamSize(PDISCPUSTATE pCpu, POP_PARAMETER pParam);
    592 DISDECL(DIS_SELREG) DISDetectSegReg(PDISCPUSTATE pCpu, POP_PARAMETER pParam);
     606DISDECL(int)        DISGetParamSize(PDISCPUSTATE pCpu, PDISOPPARAM pParam);
     607DISDECL(DIS_SELREG) DISDetectSegReg(PDISCPUSTATE pCpu, PDISOPPARAM pParam);
    593608DISDECL(uint8_t)    DISQuerySegPrefixByte(PDISCPUSTATE pCpu);
    594609
    595 DISDECL(int) DISQueryParamVal(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, POP_PARAMETER pParam, POP_PARAMVAL pParamVal, PARAM_TYPE parmtype);
    596 DISDECL(int) DISQueryParamRegPtr(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, POP_PARAMETER pParam, void **ppReg, size_t *pcbSize);
     610DISDECL(int) DISQueryParamVal(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, PDISOPPARAM pParam, POP_PARAMVAL pParamVal, PARAM_TYPE parmtype);
     611DISDECL(int) DISQueryParamRegPtr(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, PDISOPPARAM pParam, void **ppReg, size_t *pcbSize);
    597612
    598613DISDECL(int) DISFetchReg8(PCCPUMCTXCORE pCtx, unsigned reg8, uint8_t *pVal);
Note: See TracChangeset for help on using the changeset viewer.

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