VirtualBox

Changeset 50482 in vbox


Ignore:
Timestamp:
Feb 17, 2014 3:23:05 PM (11 years ago)
Author:
vboxsync
Message:

Build HGSMI memory allocator (unused)

Location:
trunk
Files:
12 edited

Legend:

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

    r50420 r50482  
    3535#include <VBox/HGSMI/HGSMIDefs.h>
    3636#include <VBox/HGSMI/HGSMIChannels.h>
     37#include <VBox/HGSMI/HGSMIMemAlloc.h>
    3738
    3839/*
     
    7172 */
    7273
     74/* Heap types. */
     75#define HGSMI_HEAP_TYPE_NULL    0 /* Heap not initialized. */
     76#define HGSMI_HEAP_TYPE_POINTER 1 /* RTHEAPSIMPLE. Obsolete. */
     77#define HGSMI_HEAP_TYPE_OFFSET  2 /* RTHEAPOFFSET. Obsolete. */
     78#define HGSMI_HEAP_TYPE_MA      3 /* Memory allocator. */
     79
    7380#pragma pack(1)
    74 typedef struct _HGSMIHEAP
     81typedef struct HGSMIHEAP
    7582{
    7683    union
    7784    {
    78         RTHEAPSIMPLE  hPtr;         /**< Pointer based heap. */
    79         RTHEAPOFFSET  hOff;         /**< Offset based heap. */
     85        HGSMIMADATA   ma;           /* Memory Allocator */
     86        RTHEAPSIMPLE  hPtr;         /* Pointer based heap. */
     87        RTHEAPOFFSET  hOff;         /* Offset based heap. */
    8088    } u;
    81     HGSMIAREA     area;             /**< Description. */
    82     int           cRefs;            /**< Number of heap allocations. */
    83     bool          fOffsetBased;     /**< Set if offset based. */
     89    HGSMIAREA     area;             /* Description. */
     90    int           cRefs;            /* Number of heap allocations. */
     91    uint32_t      u32HeapType;      /* HGSMI_HEAP_TYPE_* */
    8492} HGSMIHEAP;
    8593#pragma pack()
     
    145153}
    146154
    147 DECLINLINE(HGSMIOFFSET) HGSMIPointerToOffset (const HGSMIAREA *pArea,
    148                                               const HGSMIBUFFERHEADER *pHeader)
    149 {
    150     return pArea->offBase + (HGSMIOFFSET)((uint8_t *)pHeader - pArea->pu8Base);
    151 }
    152 
    153 DECLINLINE(HGSMIBUFFERHEADER *) HGSMIOffsetToPointer (const HGSMIAREA *pArea,
    154                                                       HGSMIOFFSET offBuffer)
    155 {
    156     return (HGSMIBUFFERHEADER *)(pArea->pu8Base + (offBuffer - pArea->offBase));
     155DECLINLINE(HGSMIOFFSET) HGSMIPointerToOffset(const HGSMIAREA *pArea,
     156                                             const void *pv)
     157{
     158    return pArea->offBase + (HGSMIOFFSET)((uint8_t *)pv - pArea->pu8Base);
     159}
     160
     161DECLINLINE(void *) HGSMIOffsetToPointer(const HGSMIAREA *pArea,
     162                                        HGSMIOFFSET offBuffer)
     163{
     164    return pArea->pu8Base + (offBuffer - pArea->offBase);
    157165}
    158166
    159167DECLINLINE(uint8_t *) HGSMIBufferDataFromOffset (const HGSMIAREA *pArea, HGSMIOFFSET offBuffer)
    160168{
    161     HGSMIBUFFERHEADER *pHeader = HGSMIOffsetToPointer (pArea, offBuffer);
     169    HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIOffsetToPointer(pArea, offBuffer);
    162170    Assert(pHeader);
    163171    if(pHeader)
     
    168176DECLINLINE(uint8_t *) HGSMIBufferDataAndChInfoFromOffset (const HGSMIAREA *pArea, HGSMIOFFSET offBuffer, uint16_t * pChInfo)
    169177{
    170     HGSMIBUFFERHEADER *pHeader = HGSMIOffsetToPointer (pArea, offBuffer);
     178    HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIOffsetToPointer (pArea, offBuffer);
    171179    Assert(pHeader);
    172180    if(pHeader)
     
    191199void HGSMIAreaClear (HGSMIAREA *pArea);
    192200
    193 DECLINLINE(bool) HGSMIAreaContainsOffset(HGSMIAREA *pArea, HGSMIOFFSET offSet)
    194 {
    195     return pArea->offBase <= offSet && pArea->offBase + pArea->cbArea > offSet;
     201DECLINLINE(bool) HGSMIAreaContainsOffset(const HGSMIAREA *pArea, HGSMIOFFSET off)
     202{
     203    return off >= pArea->offBase && off - pArea->offBase < pArea->cbArea;
     204}
     205
     206DECLINLINE(bool) HGSMIAreaContainsPointer(const HGSMIAREA *pArea, const void *pv)
     207{
     208    return (uintptr_t)pv >= (uintptr_t)pArea->pu8Base && (uintptr_t)pv - (uintptr_t)pArea->pu8Base < pArea->cbArea;
    196209}
    197210
     
    203216
    204217int HGSMIHeapSetup (HGSMIHEAP *pHeap,
     218                    uint32_t u32HeapType,
    205219                    void *pvBase,
    206220                    HGSMISIZE cbArea,
    207221                    HGSMIOFFSET offBase,
    208                     bool fOffsetBased);
     222                    const HGSMIENV *pEnv);
    209223
    210224int HGSMIHeapRelocate (HGSMIHEAP *pHeap,
     225                       uint32_t u32HeapType,
    211226                       void *pvBase,
    212227                       uint32_t offHeapHandle,
     
    214229                       HGSMISIZE cbArea,
    215230                       HGSMIOFFSET offBase,
    216                        bool fOffsetBased);
    217 
    218 void HGSMIHeapSetupUnitialized (HGSMIHEAP *pHeap);
    219 bool HGSMIHeapIsItialized (HGSMIHEAP *pHeap);
     231                       const HGSMIENV *pEnv);
     232
     233void HGSMIHeapSetupUninitialized (HGSMIHEAP *pHeap);
    220234
    221235void HGSMIHeapDestroy (HGSMIHEAP *pHeap);
  • trunk/include/VBox/HGSMI/HGSMIDefs.h

    r50420 r50482  
    109109#define HGSMI_NUMBER_OF_CHANNELS 0x100
    110110
     111typedef struct HGSMIENV
     112{
     113    /* Environment context pointer. */
     114    void *pvEnv;
     115
     116    /* Allocate system memory. */
     117    DECLCALLBACKMEMBER(void *, pfnAlloc)(void *pvEnv, HGSMISIZE cb);
     118
     119    /* Free system memory. */
     120    DECLCALLBACKMEMBER(void, pfnFree)(void *pvEnv, void *pv);
     121} HGSMIENV;
     122
    111123#endif /* !___VBox_HGSMI_HGSMIDefs_h */
  • trunk/include/VBox/VBoxVideoGuest.h

    r45003 r50482  
    226226                                            void *pvGuestHeapMemory,
    227227                                            uint32_t cbGuestHeapMemory,
    228                                             uint32_t offVRAMGuestHeapMemory);
     228                                            uint32_t offVRAMGuestHeapMemory,
     229                                            const HGSMIENV *pEnv);
    229230RTDECL(void)     VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
    230231                                             uint32_t cbVRAM,
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/xpdm/VBoxDispVBVA.cpp

    r37423 r50482  
    300300#endif /* VBOX_VBVA_ADJUST_RECT */
    301301
     302static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb)
     303{
     304    NOREF(pvEnv);
     305    return EngAllocMem(0, cb, 0);
     306}
     307
     308static DECLCALLBACK(void) hgsmiEnvFree(void *pvEnv, void *pv)
     309{
     310    NOREF(pvEnv);
     311    EngFreeMem(pv);
     312}
     313
     314static HGSMIENV g_hgsmiEnvDisp =
     315{
     316    NULL,
     317    hgsmiEnvAlloc,
     318    hgsmiEnvFree
     319};
     320
    302321int VBoxDispVBVAInit(PVBOXDISPDEV pDev)
    303322{
     
    406425
    407426        rc = HGSMIHeapSetup(&pDev->hgsmi.ctx.heapCtx,
     427                            HGSMI_HEAP_TYPE_POINTER,
    408428                            (uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offDisplayInfo+sizeof(HGSMIHOSTFLAGS),
    409429                            pDev->layout.cbDisplayInfo-sizeof(HGSMIHOSTFLAGS),
    410430                            info.areaDisplay.offBase+pDev->layout.offDisplayInfo+sizeof(HGSMIHOSTFLAGS),
    411                             false /*fOffsetBased*/);
     431                            &g_hgsmiEnvDisp);
    412432
    413433        if (RT_SUCCESS(rc))
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPHGSMI.cpp

    r44529 r50482  
    2020#include "VBoxMPCommon.h"
    2121#include <VBox/VMMDev.h>
     22#include <iprt/alloc.h>
     23
     24static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb)
     25{
     26    NOREF(pvEnv);
     27    return RTMemAlloc(cb);
     28}
     29
     30static DECLCALLBACK(void) hgsmiEnvFree(void *pvEnv, void *pv)
     31{
     32    NOREF(pvEnv);
     33    RTMemFree(pv);
     34}
     35
     36static HGSMIENV g_hgsmiEnvMP =
     37{
     38    NULL,
     39    hgsmiEnvAlloc,
     40    hgsmiEnvFree
     41};
    2242
    2343/**
     
    6888                                            cbGuestHeapMemory,
    6989                                              offVRAMBaseMapping
    70                                             + offGuestHeapMemory);
     90                                            + offGuestHeapMemory,
     91                                            &g_hgsmiEnvMP);
    7192
    7293            if (RT_FAILURE(rc))
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.cpp

    r44529 r50482  
    186186}
    187187
    188 int VBoxSHGSMIInit(PVBOXSHGSMI pHeap, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, bool fOffsetBased)
     188int VBoxSHGSMIInit(PVBOXSHGSMI pHeap, uint32_t u32HeapType, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase,
     189                   const HGSMIENV *pEnv)
    189190{
    190191    KeInitializeSpinLock(&pHeap->HeapLock);
    191     return HGSMIHeapSetup(&pHeap->Heap, pvBase, cbArea, offBase, fOffsetBased);
     192    return HGSMIHeapSetup(&pHeap->Heap, u32HeapType, pvBase, cbArea, offBase, pEnv);
    192193}
    193194
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPShgsmi.h

    r46757 r50482  
    6161}
    6262
    63 int VBoxSHGSMIInit(PVBOXSHGSMI pHeap, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, bool fOffsetBased);
     63int VBoxSHGSMIInit(PVBOXSHGSMI pHeap, uint32_t u32HeapType, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, const HGSMIENV *pEnv);
    6464void VBoxSHGSMITerm(PVBOXSHGSMI pHeap);
    6565void* VBoxSHGSMIHeapAlloc(PVBOXSHGSMI pHeap, HGSMISIZE cbData, uint8_t u8Channel, uint16_t u16ChannelInfo);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp

    r49244 r50482  
    14511451#endif
    14521452
     1453static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb)
     1454{
     1455    NOREF(pvEnv);
     1456    return RTMemAlloc(cb);
     1457}
     1458
     1459static DECLCALLBACK(void) hgsmiEnvFree(void *pvEnv, void *pv)
     1460{
     1461    NOREF(pvEnv);
     1462    RTMemFree(pv);
     1463}
     1464
     1465static HGSMIENV g_hgsmiEnvVdma =
     1466{
     1467    NULL,
     1468    hgsmiEnvAlloc,
     1469    hgsmiEnvFree
     1470};
     1471
    14531472/* create a DMACommand buffer */
    14541473int vboxVdmaCreate(PVBOXMP_DEVEXT pDevExt, VBOXVDMAINFO *pInfo
     
    14861505        /* Setup a HGSMI heap within the adapter information area. */
    14871506        rc = VBoxSHGSMIInit(&pInfo->CmdHeap,
     1507                             HGSMI_HEAP_TYPE_POINTER,
    14881508                             pvBuffer,
    14891509                             cbBuffer,
    14901510                             offBuffer,
    1491                              false /*fOffsetBased*/);
     1511                             &g_hgsmiEnvVdma);
    14921512        Assert(RT_SUCCESS(rc));
    14931513        if(RT_SUCCESS(rc))
  • trunk/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp

    r44528 r50482  
    320320                                       void *pvGuestHeapMemory,
    321321                                       uint32_t cbGuestHeapMemory,
    322                                        uint32_t offVRAMGuestHeapMemory)
     322                                       uint32_t offVRAMGuestHeapMemory,
     323                                       const HGSMIENV *pEnv)
    323324{
    324325    /** @todo should we be using a fixed ISA port value here? */
    325326    pCtx->port = (RTIOPORT)VGA_PORT_HGSMI_GUEST;
    326327#ifdef VBOX_WDDM_MINIPORT
    327     return VBoxSHGSMIInit(&pCtx->heapCtx, pvGuestHeapMemory,
    328                           cbGuestHeapMemory, offVRAMGuestHeapMemory,
    329                           false /*fOffsetBased*/);
     328    return VBoxSHGSMIInit(&pCtx->heapCtx, HGSMI_HEAP_TYPE_POINTER, pvGuestHeapMemory,
     329                          cbGuestHeapMemory, offVRAMGuestHeapMemory, pEnv);
    330330#else
    331     return HGSMIHeapSetup(&pCtx->heapCtx, pvGuestHeapMemory,
    332                           cbGuestHeapMemory, offVRAMGuestHeapMemory,
    333                           false /*fOffsetBased*/);
     331    return HGSMIHeapSetup(&pCtx->heapCtx, HGSMI_HEAP_TYPE_POINTER, pvGuestHeapMemory,
     332                          cbGuestHeapMemory, offVRAMGuestHeapMemory, pEnv);
    334333#endif
    335334}
  • trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp

    r50078 r50482  
    11131113}
    11141114
     1115static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb)
     1116{
     1117    NOREF(pvEnv);
     1118    return RTMemAlloc(cb);
     1119}
     1120
     1121static DECLCALLBACK(void) hgsmiEnvFree(void *pvEnv, void *pv)
     1122{
     1123    NOREF(pvEnv);
     1124    RTMemFree(pv);
     1125}
     1126
     1127static HGSMIENV g_hgsmiEnv =
     1128{
     1129    NULL,
     1130    hgsmiEnvAlloc,
     1131    hgsmiEnvFree
     1132};
     1133
    11151134int HGSMISetupHostHeap (PHGSMIINSTANCE pIns,
    11161135                        HGSMIOFFSET    offHeap,
     
    11441163            {
    11451164                rc = HGSMIHeapSetup (&pIns->hostHeap,
     1165                                     HGSMI_HEAP_TYPE_OFFSET,
    11461166                                     pIns->area.pu8Base+offHeap,
    11471167                                     cbHeap,
    11481168                                     offHeap,
    1149                                      true /*fOffsetBased*/);
     1169                                     &g_hgsmiEnv);
    11501170            }
    11511171
     
    13761396
    13771397            rc = HGSMIHeapRelocate(&pIns->hostHeap,
     1398                                   u32Version > VGA_SAVEDSTATE_VERSION_HOST_HEAP?
     1399                                       HGSMI_HEAP_TYPE_OFFSET:
     1400                                       HGSMI_HEAP_TYPE_POINTER,
    13781401                                   pIns->area.pu8Base+offHeap,
    13791402                                   off,
     
    13811404                                   cbHeap,
    13821405                                   offHeap,
    1383                                    u32Version > VGA_SAVEDSTATE_VERSION_HOST_HEAP);
     1406                                   &g_hgsmiEnv);
    13841407
    13851408            hgsmiHostHeapUnlock (pIns);
     
    16811704        pIns->pszName        = VALID_PTR(pszName)? pszName: "";
    16821705
    1683         HGSMIHeapSetupUnitialized (&pIns->hostHeap);
     1706        HGSMIHeapSetupUninitialized(&pIns->hostHeap);
    16841707
    16851708        pIns->pfnNotifyGuest = pfnNotifyGuest;
     
    17251748#endif
    17261749
    1727     HGSMIHeapSetupUnitialized (&pIns->hostHeap);
     1750    HGSMIHeapSetupUninitialized(&pIns->hostHeap);
    17281751
    17291752    return flags;
  • trunk/src/VBox/GuestHost/HGSMI/HGSMICommon.cpp

    r44528 r50482  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    189189}
    190190
    191 void HGSMIHeapSetupUnitialized (HGSMIHEAP *pHeap)
    192 {
    193     pHeap->u.hPtr = NIL_RTHEAPSIMPLE;
    194     pHeap->cRefs = 0;
    195     pHeap->area.cbArea = 0;
    196     pHeap->area.offBase = HGSMIOFFSET_VOID;
    197     pHeap->area.offLast = HGSMIOFFSET_VOID;
    198     pHeap->area.pu8Base = 0;
    199     pHeap->fOffsetBased = false;
    200 }
    201 
    202 bool HGSMIHeapIsItialized (HGSMIHEAP *pHeap)
    203 {
    204     return pHeap->u.hPtr != NIL_RTHEAPSIMPLE;
     191void HGSMIHeapSetupUninitialized(HGSMIHEAP *pHeap)
     192{
     193    RT_ZERO(*pHeap);
     194    pHeap->u32HeapType = HGSMI_HEAP_TYPE_NULL;
    205195}
    206196
    207197int HGSMIHeapRelocate (HGSMIHEAP *pHeap,
     198                       uint32_t u32HeapType,
    208199                       void *pvBase,
    209200                       uint32_t offHeapHandle,
     
    211202                       HGSMISIZE cbArea,
    212203                       HGSMIOFFSET offBase,
    213                        bool fOffsetBased
    214                        )
     204                       const HGSMIENV *pEnv)
    215205{
    216206    if (   !pHeap
     
    224214    if (RT_SUCCESS (rc))
    225215    {
    226         if (fOffsetBased)
     216        if (u32HeapType == HGSMI_HEAP_TYPE_MA)
     217        {
     218            /* @todo rc = HGSMIMAInit(&pHeap->u.ma, &pHeap->area, NULL, 0, 0, pEnv); */
     219            rc = VERR_NOT_IMPLEMENTED;
     220        }
     221        else if (u32HeapType == HGSMI_HEAP_TYPE_OFFSET)
     222        {
    227223            pHeap->u.hOff = (RTHEAPOFFSET)((uint8_t *)pvBase + offHeapHandle);
    228         else
     224        }
     225        else if (u32HeapType == HGSMI_HEAP_TYPE_POINTER)
    229226        {
    230227            pHeap->u.hPtr = (RTHEAPSIMPLE)((uint8_t *)pvBase + offHeapHandle);
    231228            rc = RTHeapSimpleRelocate (pHeap->u.hPtr, offDelta); AssertRC(rc);
    232229        }
    233         if (RT_SUCCESS (rc))
     230        else
     231        {
     232            rc = VERR_NOT_SUPPORTED;
     233        }
     234
     235        if (RT_SUCCESS(rc))
    234236        {
    235237            pHeap->cRefs = 0;
    236             pHeap->fOffsetBased = fOffsetBased;
     238            pHeap->u32HeapType = u32HeapType;
    237239        }
    238240        else
     
    246248
    247249int HGSMIHeapSetup (HGSMIHEAP *pHeap,
     250                    uint32_t u32HeapType,
    248251                    void *pvBase,
    249252                    HGSMISIZE cbArea,
    250253                    HGSMIOFFSET offBase,
    251                     bool fOffsetBased)
     254                    const HGSMIENV *pEnv)
    252255{
    253256    if (   !pHeap
     
    261264    if (RT_SUCCESS (rc))
    262265    {
    263         if (!fOffsetBased)
     266        if (u32HeapType == HGSMI_HEAP_TYPE_MA)
     267        {
     268            rc = HGSMIMAInit(&pHeap->u.ma, &pHeap->area, NULL, 0, 0, pEnv);
     269        }
     270        else if (u32HeapType == HGSMI_HEAP_TYPE_POINTER)
     271        {
    264272            rc = RTHeapSimpleInit (&pHeap->u.hPtr, pvBase, cbArea);
     273        }
     274        else if (u32HeapType == HGSMI_HEAP_TYPE_OFFSET)
     275        {
     276            rc = RTHeapOffsetInit (&pHeap->u.hOff, pvBase, cbArea);
     277        }
    265278        else
    266             rc = RTHeapOffsetInit (&pHeap->u.hOff, pvBase, cbArea);
     279        {
     280            rc = VERR_NOT_SUPPORTED;
     281        }
    267282
    268283        if (RT_SUCCESS (rc))
    269284        {
    270285            pHeap->cRefs = 0;
    271             pHeap->fOffsetBased = fOffsetBased;
     286            pHeap->u32HeapType = u32HeapType;
    272287        }
    273288        else
     
    284299    if (pHeap)
    285300    {
     301        if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_MA)
     302        {
     303            HGSMIMAUninit(&pHeap->u.ma);
     304        }
    286305        Assert(!pHeap->cRefs);
    287         pHeap->u.hPtr = NIL_RTHEAPSIMPLE;
    288         HGSMIAreaClear (&pHeap->area);
    289         pHeap->cRefs = 0;
     306        HGSMIHeapSetupUninitialized(pHeap);
    290307    }
    291308}
     
    296313                      uint16_t u16ChannelInfo)
    297314{
    298     if (pHeap->u.hPtr == NIL_RTHEAPSIMPLE)
    299     {
    300         return NULL;
    301     }
    302 
    303     size_t cbAlloc = HGSMIBufferRequiredSize (cbData);
     315    HGSMISIZE cbAlloc = HGSMIBufferRequiredSize (cbData);
    304316
    305317    HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIHeapBufferAlloc (pHeap, cbAlloc);
     
    326338{
    327339    if (   pvData
    328         && pHeap->u.hPtr != NIL_RTHEAPSIMPLE)
     340        && pHeap->u32HeapType != HGSMI_HEAP_TYPE_NULL)
    329341    {
    330342        HGSMIBUFFERHEADER *pHeader = HGSMIBufferHeaderFromData (pvData);
     
    336348void* HGSMIHeapBufferAlloc (HGSMIHEAP *pHeap, HGSMISIZE cbBuffer)
    337349{
    338     void* pvBuf;
    339     if (!pHeap->fOffsetBased)
     350    void* pvBuf = NULL;
     351    if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_MA)
     352    {
     353        pvBuf = HGSMIMAAlloc(&pHeap->u.ma, cbBuffer);
     354    }
     355    else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_POINTER)
     356    {
    340357        pvBuf = RTHeapSimpleAlloc (pHeap->u.hPtr, cbBuffer, 0);
    341     else
     358    }
     359    else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_OFFSET)
     360    {
    342361        pvBuf = RTHeapOffsetAlloc (pHeap->u.hOff, cbBuffer, 0);
    343 
    344     if (!pvBuf)
    345         return NULL;
    346 
    347     ++pHeap->cRefs;
     362    }
     363
     364    if (pvBuf)
     365    {
     366        ++pHeap->cRefs;
     367    }
     368
    348369    return pvBuf;
    349370}
    350371
    351372void HGSMIHeapBufferFree(HGSMIHEAP *pHeap,
    352                     void *pvBuf)
    353 {
    354     if (!pHeap->fOffsetBased)
     373                         void *pvBuf)
     374{
     375    if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_MA)
     376    {
     377        HGSMIMAFree(&pHeap->u.ma, pvBuf);
     378    }
     379    else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_POINTER)
     380    {
    355381        RTHeapSimpleFree (pHeap->u.hPtr, pvBuf);
    356     else
     382    }
     383    else if (pHeap->u32HeapType == HGSMI_HEAP_TYPE_OFFSET)
     384    {
    357385        RTHeapOffsetFree (pHeap->u.hOff, pvBuf);
     386    }
    358387
    359388    --pHeap->cRefs;
     
    377406    }
    378407
    379     const HGSMIBUFFERHEADER *pHeader = HGSMIOffsetToPointer (pArea, offBuffer);
     408    const HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)HGSMIOffsetToPointer (pArea, offBuffer);
    380409
    381410    /* Quick check of the data size, it should be less than the maximum
  • trunk/src/VBox/GuestHost/HGSMI/Makefile.kmk

    r41477 r50482  
    3030HGSMIGuestR0Lib_DEFS         =
    3131HGSMIGuestR0Lib_SOURCES      = \
    32         HGSMICommon.cpp
     32        HGSMICommon.cpp \
     33        HGSMIMemAlloc.cpp
    3334endif
    3435
     
    4041HGSMIHostR3Lib_DEFS          =
    4142HGSMIHostR3Lib_SOURCES       = \
    42         HGSMICommon.cpp
     43        HGSMICommon.cpp \
     44        HGSMIMemAlloc.cpp
    4345
    4446include $(FILE_KBUILD_SUB_FOOTER)
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