VirtualBox

Changeset 41731 in vbox


Ignore:
Timestamp:
Jun 14, 2012 11:41:13 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78539
Message:

DIS: Split up apvUserData, dropping the 3rd entry. 2nd entry (now pvUser2) is only used by CSAM. Reduces the DISCPUSTATE by another 8 bytes.

Location:
trunk
Files:
8 edited

Legend:

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

    r41730 r41731  
    382382/** @}  */
    383383
    384 /** @name Flags returned by DISQueryParamVal (DISQPVPARAMVAL::flags).
    385  * @{
    386  */
    387 #define DISQPV_FLAG_8                   UINT8_C(0x01)
    388 #define DISQPV_FLAG_16                  UINT8_C(0x02)
    389 #define DISQPV_FLAG_32                  UINT8_C(0x04)
    390 #define DISQPV_FLAG_64                  UINT8_C(0x08)
    391 #define DISQPV_FLAG_FARPTR16            UINT8_C(0x10)
    392 #define DISQPV_FLAG_FARPTR32            UINT8_C(0x20)
    393 /** @}  */
    394 
    395 /** @name Types returned by DISQueryParamVal (DISQPVPARAMVAL::flags).
    396  * @{ */
    397 #define DISQPV_TYPE_REGISTER            UINT8_C(1)
    398 #define DISQPV_TYPE_ADDRESS             UINT8_C(2)
    399 #define DISQPV_TYPE_IMMEDIATE           UINT8_C(3)
    400 /** @}  */
    401 
    402 typedef struct
    403 {
    404     union
    405     {
    406         uint8_t     val8;
    407         uint16_t    val16;
    408         uint32_t    val32;
    409         uint64_t    val64;
    410 
    411         struct
    412         {
    413             uint16_t sel;
    414             uint32_t offset;
    415         } farptr;
    416     } val;
    417 
    418     uint8_t         type;
    419     uint8_t         size;
    420     uint8_t         flags;
    421 } DISQPVPARAMVAL;
    422 /** Pointer to opcode parameter value. */
    423 typedef DISQPVPARAMVAL *PDISQPVPARAMVAL;
    424 
    425 /** Indicates which parameter DISQueryParamVal should operate on. */
    426 typedef enum DISQPVWHICH
    427 {
    428     DISQPVWHICH_DST = 1,
    429     DISQPVWHICH_SRC,
    430     DISQPVWHAT_32_BIT_HACK = 0x7fffffff
    431 } DISQPVWHICH;
    432 
    433384
    434385/**
     
    516467 *
    517468 * @param   pDisState       Pointer to the CPU state.  The primary user argument
    518  *                          can be retrived from DISCPUSTATE::apvUserData[0]. If
     469 *                          can be retrived from DISCPUSTATE::pvUser. If
    519470 *                          more is required these can be passed in the
    520471 *                          subsequent slots.
     
    540491typedef struct DISCPUSTATE
    541492{
    542     /* Because of apvUserData[1] and apvUserData[2], put the less frequently
    543        used bits at the top for now. (Might be better off in the middle?) */
     493    /* Because of pvUser2, put the less frequently used bits at the top for
     494       now. (Might be better off in the middle?) */
    544495    DISOPPARAM      param3;
    545496    DISOPPARAM      param2;
     
    628579    uint8_t         abInstr[16];
    629580    /* off: 0x0b0 (176) */
    630     /** User data slots for the read callback.  The first entry is used for the
    631      *  pvUser argument, the rest are up for grabs.
    632      * @remarks This must come last so that we can memset everything before this. */
    633     void           *apvUserData[3];
     581    /** User data supplied as an argument to the APIs. */
     582    void           *pvUser;
    634583#if ARCH_BITS == 32
    635     uint32_t        auPadding4[3];
     584    uint32_t        uPadding4;
     585#endif
     586    /** User data that can be set prior to calling the API.
     587     * @deprecated Please don't use this any more. */
     588    void           *pvUser2;
     589#if ARCH_BITS == 32
     590    uint32_t        uPadding5;
    636591#endif
    637592} DISCPUSTATE;
     
    655610
    656611DISDECL(int)        DISGetParamSize(PDISCPUSTATE pCpu, PDISOPPARAM pParam);
    657 DISDECL(DISSELREG) DISDetectSegReg(PDISCPUSTATE pCpu, PDISOPPARAM pParam);
     612DISDECL(DISSELREG)  DISDetectSegReg(PDISCPUSTATE pCpu, PDISOPPARAM pParam);
    658613DISDECL(uint8_t)    DISQuerySegPrefixByte(PDISCPUSTATE pCpu);
    659614
     615
     616
     617/** @name Flags returned by DISQueryParamVal (DISQPVPARAMVAL::flags).
     618 * @{
     619 */
     620#define DISQPV_FLAG_8                   UINT8_C(0x01)
     621#define DISQPV_FLAG_16                  UINT8_C(0x02)
     622#define DISQPV_FLAG_32                  UINT8_C(0x04)
     623#define DISQPV_FLAG_64                  UINT8_C(0x08)
     624#define DISQPV_FLAG_FARPTR16            UINT8_C(0x10)
     625#define DISQPV_FLAG_FARPTR32            UINT8_C(0x20)
     626/** @}  */
     627
     628/** @name Types returned by DISQueryParamVal (DISQPVPARAMVAL::flags).
     629 * @{ */
     630#define DISQPV_TYPE_REGISTER            UINT8_C(1)
     631#define DISQPV_TYPE_ADDRESS             UINT8_C(2)
     632#define DISQPV_TYPE_IMMEDIATE           UINT8_C(3)
     633/** @}  */
     634
     635typedef struct
     636{
     637    union
     638    {
     639        uint8_t     val8;
     640        uint16_t    val16;
     641        uint32_t    val32;
     642        uint64_t    val64;
     643
     644        struct
     645        {
     646            uint16_t sel;
     647            uint32_t offset;
     648        } farptr;
     649    } val;
     650
     651    uint8_t         type;
     652    uint8_t         size;
     653    uint8_t         flags;
     654} DISQPVPARAMVAL;
     655/** Pointer to opcode parameter value. */
     656typedef DISQPVPARAMVAL *PDISQPVPARAMVAL;
     657
     658/** Indicates which parameter DISQueryParamVal should operate on. */
     659typedef enum DISQPVWHICH
     660{
     661    DISQPVWHICH_DST = 1,
     662    DISQPVWHICH_SRC,
     663    DISQPVWHAT_32_BIT_HACK = 0x7fffffff
     664} DISQPVWHICH;
    660665DISDECL(int) DISQueryParamVal(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, PDISOPPARAM pParam, PDISQPVPARAMVAL pParamVal, DISQPVWHICH parmtype);
     666
    661667DISDECL(int) DISQueryParamRegPtr(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, PDISOPPARAM pParam, void **ppReg, size_t *pcbSize);
    662 
    663668DISDECL(int) DISFetchReg8(PCCPUMCTXCORE pCtx, unsigned reg8, uint8_t *pVal);
    664669DISDECL(int) DISFetchReg16(PCCPUMCTXCORE pCtx, unsigned reg16, uint16_t *pVal);
  • trunk/src/VBox/Disassembler/Disasm.cpp

    r41694 r41731  
    5858 * @param   pfnCallback     The byte fetcher callback.
    5959 * @param   pvUser          The user argument (found in
    60  *                          DISCPUSTATE::apvUserData[0]).
     60 *                          DISCPUSTATE::pvUser).
    6161 * @param   pCpu            Where to return the disassembled instruction.
    6262 * @param   pcbInstr        Where to store the size of the instruction. NULL is
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r41728 r41731  
    227227 * @param   enmCpuMode      The CPU mode. DISCPUMODE_32BIT, DISCPUMODE_16BIT, or DISCPUMODE_64BIT.
    228228 * @param   pfnReadBytes    Callback for reading instruction bytes.
    229  * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
     229 * @param   pvUser          User argument for the instruction reader. (Ends up in pvUser.)
    230230 * @param   pCpu            Pointer to cpu structure. Will be initialized.
    231231 * @param   pcbInstr        Where to store the size of the instruction.
     
    249249 * @param   enmCpuMode      The CPU mode. DISCPUMODE_32BIT, DISCPUMODE_16BIT, or DISCPUMODE_64BIT.
    250250 * @param   pfnReadBytes    Callback for reading instruction bytes.
    251  * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
     251 * @param   pvUser          User argument for the instruction reader. (Ends up in pvUser.)
    252252 * @param   pCpu            Pointer to cpu structure. Will be initialized.
    253253 * @param   pcbInstr        Where to store the size of the instruction.
     
    271271 * @param   pfnReadBytes    Callback for reading instruction bytes.
    272272 * @param   fFilter         Instruction type filter.
    273  * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
     273 * @param   pvUser          User argument for the instruction reader. (Ends up in pvUser.)
    274274 * @param   pCpu            Pointer to CPU structure. With the exception of
    275  *                          DISCPUSTATE::apvUserData[1] and
    276  *                          DISCPUSTATE::apvUserData[2], the structure will be
     275 *                          DISCPUSTATE::pvUser2, the structure will be
    277276 *                          completely initialized by this API, i.e. no input is
    278277 *                          taken from it.
     
    288287    /*
    289288     * Initialize the CPU state.
    290      * Note! The RT_BZERO make ASSUMPTIONS about the placement of apvUserData.
     289     * Note! The RT_BZERO make ASSUMPTIONS about the placement of pvUser2.
    291290     */
    292     RT_BZERO(pCpu, RT_OFFSETOF(DISCPUSTATE, apvUserData));
     291    RT_BZERO(pCpu, RT_OFFSETOF(DISCPUSTATE, pvUser2));
    293292
    294293    pCpu->mode              = enmCpuMode;
     
    312311    pCpu->rc                = VINF_SUCCESS;
    313312    pCpu->pfnReadBytes      = pfnReadBytes ? pfnReadBytes : disReadBytesDefault;
    314     pCpu->apvUserData[0]    = pvUser;
     313    pCpu->pvUser    = pvUser;
    315314
    316315    return disInstrWorker(pCpu, uInstrAddr, paOneByteMap, pcbInstr);
  • trunk/src/VBox/Runtime/testcase/tstLdr-3.cpp

    r41692 r41731  
    149149static DECLCALLBACK(int) MyReadBytes(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead)
    150150{
    151     memcpy(pbDst, (uint8_t const *)((uintptr_t)uSrcAddr + (uintptr_t)pDisState->apvUserData[0]), cbToRead);
     151    memcpy(pbDst, (uint8_t const *)((uintptr_t)uSrcAddr + (uintptr_t)pDisState->pvUser), cbToRead);
    152152    return VINF_SUCCESS;
    153153}
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r41729 r41731  
    286286static DECLCALLBACK(int) emReadBytes(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead)
    287287{
    288     PEMDISSTATE   pState = (PEMDISSTATE)pDisState->apvUserData[0];
     288    PEMDISSTATE   pState = (PEMDISSTATE)pDisState->pvUser;
    289289# ifndef IN_RING0
    290290    PVM           pVM    = pState->pVM;
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r41675 r41731  
    35293529static DECLCALLBACK(int) cpumR3DisasInstrRead(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead)
    35303530{
    3531     PCPUMDISASSTATE pState = (PCPUMDISASSTATE)pDisState->apvUserData[0];
     3531    PCPUMDISASSTATE pState = (PCPUMDISASSTATE)pDisState->pvUser;
    35323532    Assert(cbToRead > 0);
    35333533    for (;;)
  • trunk/src/VBox/VMM/VMMR3/CSAM.cpp

    r41727 r41731  
    728728static DECLCALLBACK(int) CSAMR3ReadBytes(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead)
    729729{
    730     PVM           pVM      = (PVM)pDisState->apvUserData[0];
    731     RTHCUINTPTR   pInstrHC = (RTHCUINTPTR)pDisState->apvUserData[1];
     730    PVM           pVM      = (PVM)pDisState->pvUser;
     731    RTHCUINTPTR   pInstrHC = (RTHCUINTPTR)pDisState->pvUser2;
    732732    RTGCUINTPTR32 pInstrGC = pDisState->uInstrAddr;
    733733    int           orgsize  = cbToRead;
     
    764764                               PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput)
    765765{
    766     (pCpu)->apvUserData[1] = InstrHC;
     766    pCpu->pvUser2 = InstrHC;
    767767#ifdef DEBUG
    768768    return DISInstrToStrEx(InstrGC, enmCpuMode, CSAMR3ReadBytes, pVM, DISOPTYPE_ALL,
  • trunk/src/VBox/VMM/VMMR3/PATM.cpp

    r41727 r41731  
    536536DECLCALLBACK(int) patmReadBytes(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead)
    537537{
    538     PATMDISASM   *pDisInfo = (PATMDISASM *)pDisState->apvUserData[0];
     538    PATMDISASM   *pDisInfo = (PATMDISASM *)pDisState->pvUser;
    539539    int           orgsize  = cbToRead;
    540540
Note: See TracChangeset for help on using the changeset viewer.

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