VirtualBox

Ignore:
Timestamp:
May 3, 2011 1:54:06 PM (14 years ago)
Author:
vboxsync
Message:

PGMPAGE: Use bitfields.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r36934 r36935  
    693693    /** The physical address and the Page ID. */
    694694    RTHCPHYS    HCPhysAndPageID;
    695 #define PGMPAGE_USE_MORE_BITFIELDS
    696 #ifndef PGMPAGE_USE_MORE_BITFIELDS
    697     /** Combination of:
    698      *  - [0-7]: u2HandlerPhysStateY - the physical handler state
    699      *    (PGM_PAGE_HNDL_PHYS_STATE_*).
    700      *  - [8-9]: u2HandlerVirtStateY - the virtual handler state
    701      *    (PGM_PAGE_HNDL_VIRT_STATE_*).
    702      *  - [10]:  fFTDirtyY - indicator of dirty page for fault tolerance tracking.
    703      *  - [13-14]: u2PDEType  - paging structure needed to map the page (PGM_PAGE_PDE_TYPE_*)
    704      *  - [15]:  fWrittenToY - flag indicating that a write monitored page was
    705      *    written to when set.
    706      *  - [11-13]: 3 unused bits.
    707      * @remarks Warning! All accesses to the bits are hardcoded.
    708      *
    709      * @todo    Change this to a union with both bitfields, u8 and u accessors.
    710      *          That'll help deal with some of the hardcoded accesses.
    711      *
    712      * @todo    Include uStateY and uTypeY as well so it becomes 32-bit.  This
    713      *          will make it possible to turn some of the 16-bit accesses into
    714      *          32-bit ones, which may be efficient (stalls).
    715      */
    716     union
    717     {
    718         struct
    719         {
    720             uint16_t    u16MiscY;
    721             /** The page state.
    722              * Only 3 bits are really needed for this. */
    723             uint16_t    uStateY   : 3;
    724             /** The page type (PGMPAGETYPE).
    725              * Only 3 bits are really needed for this. */
    726             uint16_t    uTypeY    : 3;
    727             /** PTE index for usage tracking (page pool). */
    728             uint16_t    u10PteIdx : 10;
    729         } bit;
    730 
    731         /** 32-bit integer view. */
    732         uint32_t    u;
    733         /** 16-bit view. */
    734         uint16_t    au16[2];
    735         /** 8-bit view. */
    736         uint8_t     au8[4];
    737     } u1;
    738 #else
    739695    union
    740696    {
     
    745701             *  (PGM_PAGE_HNDL_PHYS_STATE_*). */
    746702            uint32_t    u2HandlerPhysStateY : 8;
     703            /*uint32_t    u6Reserved  : 6;*/
    747704            /** 9:8   - The physical handler state
    748705             *  (PGM_PAGE_HNDL_VIRT_STATE_*). */
     
    750707            /** 10    - Indicator of dirty page for fault tolerance
    751708             *  tracking. */
    752             uint32_t    fFTDirtyY  : 1;
     709            uint32_t    fFTDirtyY   : 1;
    753710            /** 12:11 - Currently unused. */
    754711            uint32_t    u2Unused2   : 2;
     
    773730        uint8_t     au8[4];
    774731    } u1;
    775 #endif
    776732    /** Usage tracking (page pool). */
    777733    uint16_t    u16TrackingY;
     
    993949 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    994950 */
    995 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    996951#define PGM_PAGE_CLEAR_WRITTEN_TO(a_pPage)      do { (a_pPage)->u1.bit.fWrittenToY = 0; } while (0)
    997 #else
    998 #define PGM_PAGE_CLEAR_WRITTEN_TO(a_pPage)      do { (a_pPage)->u1.au8[1] &= UINT8_C(0x7f); } while (0)
    999 #endif
    1000952
    1001953/**
     
    1004956 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    1005957 */
    1006 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    1007958#define PGM_PAGE_IS_WRITTEN_TO(a_pPage)         ( (a_pPage)->u1.bit.fWrittenToY )
    1008 #else
    1009 #define PGM_PAGE_IS_WRITTEN_TO(a_pPage)         ( !!((a_pPage)->u1.au8[1] & UINT8_C(0x80)) )
    1010 #endif
    1011959
    1012960/**
     
    1014962 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    1015963 */
    1016 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    1017964#define PGM_PAGE_SET_FT_DIRTY(a_pPage)          do { (a_pPage)->u1.bit.fFTDirtyY = 1; } while (0)
    1018 #else
    1019 #define PGM_PAGE_SET_FT_DIRTY(a_pPage)          do { (a_pPage)->u1.au8[1] |= UINT8_C(0x04); } while (0)
    1020 #endif
    1021965
    1022966/**
     
    1024968 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    1025969 */
    1026 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    1027970#define PGM_PAGE_CLEAR_FT_DIRTY(a_pPage)        do { (a_pPage)->u1.bit.fFTDirtyY = 0; } while (0)
    1028 #else
    1029 #define PGM_PAGE_CLEAR_FT_DIRTY(a_pPage)        do { (a_pPage)->u1.au8[1] &= UINT8_C(0xfb); } while (0)
    1030 #endif
    1031971
    1032972/**
     
    1035975 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    1036976 */
    1037 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    1038977#define PGM_PAGE_IS_FT_DIRTY(a_pPage)           ( (a_pPage)->u1.bit.fFTDirtyY )
    1039 #else
    1040 #define PGM_PAGE_IS_FT_DIRTY(a_pPage)           ( !!((a_pPage)->u1.au8[1] & UINT8_C(0x04)) )
    1041 #endif
    1042978
    1043979
     
    1060996 * @param   a_uType     PGM_PAGE_PDE_TYPE_*.
    1061997 */
    1062 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    1063998#define PGM_PAGE_SET_PDE_TYPE(a_pPage, a_uType) \
    1064999    do { (a_pPage)->u1.bit.u2PDETypeY = (a_uType); } while (0)
    1065 #else
    1066 #define PGM_PAGE_SET_PDE_TYPE(a_pPage, a_uType) \
    1067     do { \
    1068         (a_pPage)->u1.au8[1] = ((a_pPage)->u1.au8[1] & UINT8_C(0x9f)) \
    1069                              | (((a_uType)           & UINT8_C(0x03)) << 5); \
    1070     } while (0)
    1071 #endif
    10721000
    10731001/**
     
    10761004 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    10771005 */
    1078 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    10791006#define PGM_PAGE_GET_PDE_TYPE(a_pPage)          ( (a_pPage)->u1.bit.u2PDETypeY )
    1080 #else
    1081 #define PGM_PAGE_GET_PDE_TYPE(a_pPage)          ( ((a_pPage)->u1.au8[1] & UINT8_C(0x60)) >> 5)
    1082 #endif
    10831007
    10841008/** Enabled optimized access handler tests.
     
    11091033 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    11101034 */
    1111 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    11121035#define PGM_PAGE_GET_HNDL_PHYS_STATE(a_pPage)   ( (a_pPage)->u1.bit.u2HandlerPhysStateY )
    1113 #else
    1114 #define PGM_PAGE_GET_HNDL_PHYS_STATE(a_pPage)   ( (a_pPage)->u1.au8[0] )
    1115 #endif
    11161036
    11171037/**
     
    11201040 * @param   a_uState    The new state value.
    11211041 */
    1122 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    11231042#define PGM_PAGE_SET_HNDL_PHYS_STATE(a_pPage, a_uState) \
    11241043    do { (a_pPage)->u1.bit.u2HandlerPhysStateY = (a_uState); } while (0)
    1125 #else
    1126 #define PGM_PAGE_SET_HNDL_PHYS_STATE(a_pPage, a_uState) \
    1127     do { (a_pPage)->u1.au8[0] = (a_uState); } while (0)
    1128 #endif
    11291044
    11301045/**
     
    11641079 * @param   a_pPage     Pointer to the physical guest page tracking structure.
    11651080 */
    1166 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    11671081#define PGM_PAGE_GET_HNDL_VIRT_STATE(a_pPage)   ( (a_pPage)->u1.bit.u2HandlerVirtStateY )
    1168 #else
    1169 #define PGM_PAGE_GET_HNDL_VIRT_STATE(a_pPage)   ((uint8_t)( (a_pPage)->u1.au8[1] & UINT8_C(0x03) ))
    1170 #endif
    11711082
    11721083/**
     
    11751086 * @param   a_uState    The new state value.
    11761087 */
    1177 #ifdef PGMPAGE_USE_MORE_BITFIELDS
    11781088#define PGM_PAGE_SET_HNDL_VIRT_STATE(a_pPage, a_uState) \
    11791089    do { (a_pPage)->u1.bit.u2HandlerVirtStateY = (a_uState); } while (0)
    1180 #else
    1181 #define PGM_PAGE_SET_HNDL_VIRT_STATE(a_pPage, a_uState) \
    1182     do { \
    1183         (a_pPage)->u1.au8[1] = ((a_pPage)->u1.au8[1] & UINT8_C(0xfc)) \
    1184                              | ((a_uState)           & UINT8_C(0x03)); \
    1185     } while (0)
    1186 #endif
    11871090
    11881091/**
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