VirtualBox

Changeset 55421 in vbox for trunk/include


Ignore:
Timestamp:
Apr 24, 2015 12:00:21 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99763
Message:

HGSMI: cleanup, logging, comments, move legacy host heap support from common code to the host code.

File:
1 edited

Legend:

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

    r55342 r55421  
    7272 */
    7373
    74 /* Heap types. */
    75 #define HGSMI_HEAP_TYPE_NULL    0 /* Heap not initialized. */
    76 #define HGSMI_HEAP_TYPE_POINTER 1 /* Deprecated. RTHEAPSIMPLE. */
    77 #define HGSMI_HEAP_TYPE_OFFSET  2 /* Deprecated. RTHEAPOFFSET. */
    78 #define HGSMI_HEAP_TYPE_MA      3 /* Memory allocator. */
    79 
    8074#pragma pack(1)
    8175typedef struct HGSMIHEAP
    8276{
    83     union
    84     {
    85         HGSMIMADATA   ma;           /* Memory Allocator */
    86         RTHEAPSIMPLE  hPtr;         /* Pointer based heap. */
    87         RTHEAPOFFSET  hOff;         /* Offset based heap. */
    88     } u;
    89     HGSMIAREA     area;             /* Description. */
    90     int           cRefs;            /* Number of heap allocations. */
    91     uint32_t      u32HeapType;      /* HGSMI_HEAP_TYPE_* */
     77    HGSMIAREA area; /* Description. */
     78    HGSMIMADATA ma; /* Memory allocator */
    9279} HGSMIHEAP;
    9380#pragma pack()
     
    180167}
    181168
    182 DECLINLINE(uint8_t *) HGSMIBufferDataFromOffset (const HGSMIAREA *pArea, HGSMIOFFSET offBuffer)
    183 {
    184     HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIOffsetToPointer(pArea, offBuffer);
    185     Assert(pHeader);
    186     if(pHeader)
    187         return HGSMIBufferData(pHeader);
    188     return NULL;
     169DECLINLINE(uint8_t *) HGSMIBufferDataFromOffset(const HGSMIAREA *pArea,
     170                                                HGSMIOFFSET offBuffer)
     171{
     172    void *pvBuffer = HGSMIOffsetToPointer(pArea, offBuffer);
     173    return HGSMIBufferDataFromPtr(pvBuffer);
     174}
     175
     176DECLINLINE(HGSMIOFFSET) HGSMIBufferOffsetFromData(const HGSMIAREA *pArea,
     177                                                  void *pvData)
     178{
     179    HGSMIBUFFERHEADER *pHeader = HGSMIBufferHeaderFromData(pvData);
     180    return HGSMIPointerToOffset(pArea, pHeader);
    189181}
    190182
     
    228220                                         uint16_t u16ChannelInfo);
    229221
     222DECLINLINE(const HGSMIAREA *) HGSMIHeapArea(HGSMIHEAP *pHeap)
     223{
     224    return &pHeap->area;
     225}
     226
    230227int HGSMIHeapSetup (HGSMIHEAP *pHeap,
    231                     uint32_t u32HeapType,
    232228                    void *pvBase,
    233229                    HGSMISIZE cbArea,
     
    235231                    const HGSMIENV *pEnv);
    236232
    237 int HGSMIHeapRelocate (HGSMIHEAP *pHeap,
    238                        uint32_t u32HeapType,
    239                        void *pvBase,
    240                        uint32_t offHeapHandle,
    241                        uintptr_t offDelta,
    242                        HGSMISIZE cbArea,
    243                        HGSMIOFFSET offBase);
    244 
    245 int HGSMIHeapRestoreMA(HGSMIHEAP *pHeap,
    246                        void *pvBase,
    247                        HGSMISIZE cbArea,
    248                        HGSMIOFFSET offBase,
    249                        uint32_t cBlocks,
    250                        HGSMIOFFSET *paDescriptors,
    251                        HGSMISIZE cbMaxBlock,
    252                        HGSMIENV *pEnv);
    253 
    254 void HGSMIHeapSetupUninitialized (HGSMIHEAP *pHeap);
    255 
    256233void HGSMIHeapDestroy (HGSMIHEAP *pHeap);
    257234
     
    267244                      uint16_t u16ChannelInfo);
    268245
    269 HGSMIOFFSET HGSMIHeapBufferOffset (HGSMIHEAP *pHeap,
    270                                    void *pvData);
     246DECLINLINE(HGSMIOFFSET) HGSMIHeapBufferOffset(HGSMIHEAP *pHeap, void *pvData)
     247{
     248    return HGSMIBufferOffsetFromData(HGSMIHeapArea(pHeap), pvData);
     249}
    271250
    272251void HGSMIHeapFree (HGSMIHEAP *pHeap,
     
    275254DECLINLINE(HGSMIOFFSET) HGSMIHeapOffset(HGSMIHEAP *pHeap)
    276255{
    277     return pHeap->area.offBase;
    278 }
    279 
    280 #ifdef IN_RING3
    281 /* Needed for heap relocation: offset of the heap handle relative to the start of heap area. */
    282 DECLINLINE(HGSMIOFFSET) HGSMIHeapHandleLocationOffset(HGSMIHEAP *pHeap)
    283 {
    284     HGSMIOFFSET offHeapHandle;
    285     if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_POINTER)
    286     {
    287         offHeapHandle = (HGSMIOFFSET)((uintptr_t)pHeap->u.hPtr - (uintptr_t)pHeap->area.pu8Base);
    288     }
    289     else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_OFFSET)
    290     {
    291         offHeapHandle = (HGSMIOFFSET)((uintptr_t)pHeap->u.hOff - (uintptr_t)pHeap->area.pu8Base);
    292     }
    293     else
    294     {
    295         offHeapHandle = HGSMIOFFSET_VOID;
    296     }
    297     return offHeapHandle;
    298 }
    299 #endif /* IN_RING3 */
     256    return HGSMIHeapArea(pHeap)->offBase;
     257}
    300258
    301259DECLINLINE(HGSMISIZE) HGSMIHeapSize(HGSMIHEAP *pHeap)
    302260{
    303     return pHeap->area.cbArea;
     261    return HGSMIHeapArea(pHeap)->cbArea;
    304262}
    305263
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