VirtualBox

Changeset 25062 in vbox


Ignore:
Timestamp:
Nov 27, 2009 7:24:14 PM (15 years ago)
Author:
vboxsync
Message:

HGSMI,DevVGA: Use the offset based heap for the hostHeap (resides in VRAM). New staved state version for DevVGA for indicating this change.

Location:
trunk
Files:
1 added
8 edited

Legend:

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

    r22652 r25062  
    153153typedef struct _HGSMIHEAP
    154154{
    155     RTHEAPSIMPLE  heap;            /* Heap instance. */
    156     HGSMIAREA     area;            /* Description. */
    157     int           cRefs;           /* Number of heap allocations. */
     155    union
     156    {
     157        RTHEAPSIMPLE  hPtr;         /**< Pointer based heap. */
     158        RTHEAPOFFSET  hOff;         /**< Offset based heap. */
     159    } u;
     160    HGSMIAREA     area;             /**< Description. */
     161    int           cRefs;            /**< Number of heap allocations. */
     162    bool          fOffsetBased;     /**< Set if offset based. */
    158163} HGSMIHEAP;
    159164#pragma pack()
     
    262267                    void *pvBase,
    263268                    HGSMISIZE cbArea,
    264                     HGSMIOFFSET offBase);
     269                    HGSMIOFFSET offBase,
     270                    bool fOffsetBased);
    265271
    266272int HGSMIHeapRelocate (HGSMIHEAP *pHeap,
    267                     void *pvBase,
    268                     uint32_t offHeapHandle,
    269                     uintptr_t offDelta,
    270                     HGSMISIZE cbArea,
    271                     HGSMIOFFSET offBase
    272                     );
     273                       void *pvBase,
     274                       uint32_t offHeapHandle,
     275                       uintptr_t offDelta,
     276                       HGSMISIZE cbArea,
     277                       HGSMIOFFSET offBase,
     278                       bool fOffsetBased);
    273279
    274280void HGSMIHeapSetupUnitialized (HGSMIHEAP *pHeap);
     
    296302DECLINLINE(HGSMIOFFSET) HGSMIHeapHandleLocationOffset(HGSMIHEAP *pHeap)
    297303{
    298     return pHeap->heap != NIL_RTHEAPSIMPLE ? (uint32_t)(pHeap->area.pu8Base - (uint8_t*)pHeap->heap) : HGSMIOFFSET_VOID;
     304    AssertCompile((uintptr_t)NIL_RTHEAPSIMPLE == (uintptr_t)NIL_RTHEAPOFFSET);
     305    return pHeap->u.hPtr != NIL_RTHEAPSIMPLE
     306        ? (HGSMIOFFSET)(pHeap->area.pu8Base - (uint8_t*)pHeap->u.hPtr)
     307        : HGSMIOFFSET_VOID;
    299308}
    300309
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c

    r22848 r25062  
    265265                                 (uint8_t *)ppdev->pjScreen + ppdev->layout.offDisplayInformation + sizeof (HGSMIHOSTFLAGS),
    266266                                 ppdev->layout.cbDisplayInformation - sizeof (HGSMIHOSTFLAGS),
    267                                  info.areaDisplay.offBase + ppdev->layout.offDisplayInformation + sizeof (HGSMIHOSTFLAGS));
     267                                 info.areaDisplay.offBase + ppdev->layout.offDisplayInformation + sizeof (HGSMIHOSTFLAGS),
     268                                 false /*fOffsetBased*/);
    268269
    269270        DISPDBG((0, "VBoxDISP::vboxInitVBoxVideo: offBase 0x%x\n",
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r24709 r25062  
    692692                                 PrimaryExtension->u.primary.pvAdapterInformation,
    693693                                 VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS),
    694                                  PrimaryExtension->u.primary.cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE);
     694                                 PrimaryExtension->u.primary.cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE,
     695                                 false /*fOffsetBased*/);
    695696
    696697            if (RT_FAILURE (rc))
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r24714 r25062  
    54535453
    54545454    if (    uVersion != VGA_SAVEDSTATE_VERSION
     5455        &&  uVersion != VGA_SAVEDSTATE_VERSION_HOST_HEAP
    54555456        &&  uVersion != VGA_SAVEDSTATE_VERSION_WITH_CONFIG
    54565457        &&  uVersion != VGA_SAVEDSTATE_VERSION_HGSMI
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r24926 r25062  
    4646
    4747#ifdef VBOX_WITH_HGSMI
    48 #include "HGSMI/HGSMIHost.h"
     48# include "HGSMI/HGSMIHost.h"
    4949#endif /* VBOX_WITH_HGSMI */
    50 
    51 #define VGA_SAVEDSTATE_VERSION              5
    52 #define VGA_SAVEDSTATE_VERSION_WITH_CONFIG  4
    53 #define VGA_SAVEDSTATE_VERSION_HGSMI        3
    54 #define VGA_SAVEDSTATE_VERSION_PRE_HGSMI    2
    55 #define VGA_SAVEDSTATE_VERSION_ANCIENT      1
     50#include "DevVGASavedState.h"
    5651
    5752#define MSR_COLOR_EMULATION 0x01
  • trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp

    r25050 r25062  
    7474
    7575#include "HGSMIHost.h"
    76 #include "VBox/HGSMI/HGSMIChannels.h"
    77 #include "VBox/HGSMI/HGSMIChSetup.h"
     76#include <VBox/HGSMI/HGSMIChannels.h>
     77#include <VBox/HGSMI/HGSMIChSetup.h>
    7878
    7979#include "HGSMIHostHlp.h"
     80#include "../DevVGASavedState.h"
    8081
    8182#ifdef DEBUG_sunlover
     
    371372            /* guest usually completes commands in the order it receives it
    372373             * if we're here this would typically means there is some cmd loss */
    373             Assert(0);
     374            AssertFailed();
    374375#endif
    375376
     
    10631064            if (pIns->hostHeap.cRefs)
    10641065            {
    1065                 Assert(0);
     1066                AssertFailed();
    10661067                /* It is possible to change the heap only if there is no pending allocations. */
    10671068                rc = VERR_ACCESS_DENIED;
     
    10701071            {
    10711072                rc = HGSMIHeapSetup (&pIns->hostHeap,
    1072                                         pIns->area.pu8Base+offHeap,
    1073                                         cbHeap,
    1074                                         offHeap);
     1073                                     pIns->area.pu8Base+offHeap,
     1074                                     cbHeap,
     1075                                     offHeap,
     1076                                     true /*fOffsetBased*/);
    10751077            }
    10761078
     
    11891191int HGSMIHostLoadStateExec (PHGSMIINSTANCE pIns, PSSMHANDLE pSSM, uint32_t u32Version)
    11901192{
    1191     if(u32Version < 3)
     1193    if(u32Version < VGA_SAVEDSTATE_VERSION_HGSMI)
    11921194        return VINF_SUCCESS;
    11931195
     
    12181220            Assert(!pIns->hostHeap.cRefs);
    12191221            pIns->hostHeap.cRefs = 0;
     1222
    12201223            rc = HGSMIHeapRelocate(&pIns->hostHeap,
    1221                                     pIns->area.pu8Base+offHeap,
    1222                                     off,
    1223                                     uintptr_t(pIns->area.pu8Base) - uintptr_t(oldMem),
    1224                                     cbHeap,
    1225                                     offHeap);
     1224                                   pIns->area.pu8Base+offHeap,
     1225                                   off,
     1226                                   uintptr_t(pIns->area.pu8Base) - uintptr_t(oldMem),
     1227                                   cbHeap,
     1228                                   offHeap,
     1229                                   u32Version > VGA_SAVEDSTATE_VERSION_HOST_HEAP);
    12261230
    12271231            hgsmiHostHeapUnlock (pIns);
     
    15261530
    15271531    rc = HGSMIHostChannelRegister (pIns,
    1528                                                                    HGSMI_CH_HGSMI,
    1529                                                                    hgsmiChannelHandler,
    1530                                                                    pIns,
    1531                                                                    &sOldChannelHandler);
     1532                                   HGSMI_CH_HGSMI,
     1533                                   hgsmiChannelHandler,
     1534                                   pIns,
     1535                                   &sOldChannelHandler);
    15321536
    15331537    if (RT_SUCCESS (rc))
  • trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h

    r22652 r25062  
    2222
    2323
    24 #ifndef __HGSMIHost_h__
    25 #define __HGSMIHost_h__
     24#ifndef ___HGSMIHost_h
     25#define ___HGSMIHost_h
    2626
    2727#include <VBox/vm.h>
     
    143143#endif
    144144
    145 #endif /* __HGSMIHost_h__*/
     145#endif /* !___HGSMIHost_h*/
     146
  • trunk/src/VBox/GuestHost/HGSMI/HGSMICommon.cpp

    r22652 r25062  
    155155    uint8_t *pu8Base = (uint8_t *)pvBase;
    156156
    157     if (  !pArea                                 /* Check that the area: */
    158         || cbArea < HGSMIBufferMinimumSize ()    /* Large enough. */
    159         || pu8Base + cbArea < pu8Base            /* No address space wrap. */
    160         || offBase > 0xFFFFFFFFU - cbArea        /* Area within the 32 bit space: offBase + cbMem <= 0xFFFFFFFF */
     157    if (  !pArea                                   /* Check that the area: */
     158        || cbArea < HGSMIBufferMinimumSize ()      /* Large enough. */
     159        || pu8Base + cbArea < pu8Base              /* No address space wrap. */
     160        || offBase > UINT32_C(0xFFFFFFFF) - cbArea /* Area within the 32 bit space: offBase + cbMem <= 0xFFFFFFFF */
    161161       )
    162162    {
     
    199199void HGSMIHeapSetupUnitialized (HGSMIHEAP *pHeap)
    200200{
    201     pHeap->heap            = NIL_RTHEAPSIMPLE;
     201    pHeap->u.hPtr = NIL_RTHEAPSIMPLE;
    202202    pHeap->cRefs = 0;
    203203    pHeap->area.cbArea = 0;
     
    205205    pHeap->area.offLast = HGSMIOFFSET_VOID;
    206206    pHeap->area.pu8Base = 0;
     207    pHeap->fOffsetBased = false;
    207208}
    208209
    209210bool HGSMIHeapIsItialized (HGSMIHEAP *pHeap)
    210211{
    211     return pHeap->heap != NIL_RTHEAPSIMPLE;
     212    return pHeap->u.hPtr != NIL_RTHEAPSIMPLE;
    212213}
    213214
    214215int HGSMIHeapRelocate (HGSMIHEAP *pHeap,
    215                     void *pvBase,
    216                     uint32_t offHeapHandle,
    217                     uintptr_t offDelta,
    218                     HGSMISIZE cbArea,
    219                     HGSMIOFFSET offBase
    220                     )
     216                       void *pvBase,
     217                       uint32_t offHeapHandle,
     218                       uintptr_t offDelta,
     219                       HGSMISIZE cbArea,
     220                       HGSMIOFFSET offBase,
     221                       bool fOffsetBased
     222                       )
    221223{
    222224    if (   !pHeap
     
    230232    if (RT_SUCCESS (rc))
    231233    {
    232         pHeap->heap = (RTHEAPSIMPLE)(((uint8_t*)pvBase) + offHeapHandle);
    233         rc = RTHeapSimpleRelocate (pHeap->heap, offDelta); AssertRC(rc);
     234        if (fOffsetBased)
     235            pHeap->u.hOff = (RTHEAPOFFSET)((uint8_t *)pvBase + offHeapHandle);
     236        else
     237        {
     238            pHeap->u.hPtr = (RTHEAPSIMPLE)((uint8_t *)pvBase + offHeapHandle);
     239            rc = RTHeapSimpleRelocate (pHeap->u.hPtr, offDelta); AssertRC(rc);
     240        }
    234241        if (RT_SUCCESS (rc))
    235242        {
    236243            pHeap->cRefs = 0;
     244            pHeap->fOffsetBased = fOffsetBased;
    237245        }
    238246        else
     
    248256                    void *pvBase,
    249257                    HGSMISIZE cbArea,
    250                     HGSMIOFFSET offBase)
     258                    HGSMIOFFSET offBase,
     259                    bool fOffsetBased)
    251260{
    252261    if (   !pHeap
     
    260269    if (RT_SUCCESS (rc))
    261270    {
    262         rc = RTHeapSimpleInit (&pHeap->heap, pvBase, cbArea);
     271        if (!fOffsetBased)
     272            rc = RTHeapSimpleInit (&pHeap->u.hPtr, pvBase, cbArea);
     273        else
     274            rc = RTHeapOffsetInit (&pHeap->u.hOff, pvBase, cbArea);
    263275
    264276        if (RT_SUCCESS (rc))
    265277        {
    266278            pHeap->cRefs = 0;
     279            pHeap->fOffsetBased = fOffsetBased;
    267280        }
    268281        else
     
    279292    if (pHeap)
    280293    {
    281         pHeap->heap = NIL_RTHEAPSIMPLE;
     294        pHeap->u.hPtr = NIL_RTHEAPSIMPLE;
    282295        HGSMIAreaClear (&pHeap->area);
    283296        pHeap->cRefs = 0;
     
    290303                      uint16_t u16ChannelInfo)
    291304{
    292     if (pHeap->heap == NIL_RTHEAPSIMPLE)
     305    if (pHeap->u.hPtr == NIL_RTHEAPSIMPLE)
    293306    {
    294307        return NULL;
     
    297310    size_t cbAlloc = HGSMIBufferRequiredSize (cbData);
    298311
    299     HGSMIBUFFERHEADER *pHeader = (HGSMIBUFFERHEADER *)RTHeapSimpleAlloc (pHeap->heap, cbAlloc, 0);
     312    HGSMIBUFFERHEADER *pHeader;
     313    if (!pHeap->fOffsetBased)
     314        pHeader = (HGSMIBUFFERHEADER *)RTHeapSimpleAlloc (pHeap->u.hPtr, cbAlloc, 0);
     315    else
     316        pHeader = (HGSMIBUFFERHEADER *)RTHeapOffsetAlloc (pHeap->u.hOff, cbAlloc, 0);
    300317
    301318    if (!pHeader)
     
    325342{
    326343    if (   pvData
    327         && pHeap->heap != NIL_RTHEAPSIMPLE)
     344        && pHeap->u.hPtr != NIL_RTHEAPSIMPLE)
    328345    {
    329346        HGSMIBUFFERHEADER *pHeader = HGSMIBufferHeaderFromData (pvData);
    330347
    331         RTHeapSimpleFree (pHeap->heap, pHeader);
     348        if (!pHeap->fOffsetBased)
     349            RTHeapSimpleFree (pHeap->u.hPtr, pHeader);
     350        else
     351            RTHeapOffsetFree (pHeap->u.hOff, pHeader);
    332352
    333353        --pHeap->cRefs;
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