VirtualBox

Changeset 69940 in vbox for trunk/src/VBox/Devices/Graphics


Ignore:
Timestamp:
Dec 5, 2017 5:40:55 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119437
Message:

Devices/Graphics: VMSVGA: helpers for initialization and destruction of VMSVGAR3STATE structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r69922 r69940  
    49484948
    49494949/**
     4950 * Destructs PVMSVGAR3STATE structure.
     4951 *
     4952 * @param   pThis          The VGA instance.
     4953 * @param   pSVGAState     Pointer to the structure. It is not deallocated.
     4954 */
     4955static void vmsvgaR3StateDestruct(PVGASTATE pThis, PVMSVGAR3STATE pSVGAState)
     4956{
     4957#ifndef VMSVGA_USE_EMT_HALT_CODE
     4958    if (pSVGAState->hBusyDelayedEmts != NIL_RTSEMEVENTMULTI)
     4959    {
     4960        RTSemEventMultiDestroy(pSVGAState->hBusyDelayedEmts);
     4961        pSVGAState->hBusyDelayedEmts = NIL_RTSEMEVENT;
     4962    }
     4963#endif
     4964
     4965    if (pSVGAState->Cursor.fActive)
     4966    {
     4967        RTMemFree(pSVGAState->Cursor.pData);
     4968        pSVGAState->Cursor.pData = NULL;
     4969        pSVGAState->Cursor.fActive = false;
     4970    }
     4971
     4972    if (pSVGAState->paGMR)
     4973    {
     4974        for (unsigned i = 0; i < pThis->svga.cGMR; ++i)
     4975            if (pSVGAState->paGMR[i].paDesc)
     4976                RTMemFree(pSVGAState->paGMR[i].paDesc);
     4977
     4978        RTMemFree(pSVGAState->paGMR);
     4979        pSVGAState->paGMR = NULL;
     4980    }
     4981}
     4982
     4983/**
     4984 * Constructs PVMSVGAR3STATE structure.
     4985 *
     4986 * @returns VBox status code.
     4987 * @param   pThis          The VGA instance.
     4988 * @param   pSVGAState     Pointer to the structure. It is already allocated.
     4989 */
     4990static int vmsvgaR3StateConstruct(PVGASTATE pThis, PVMSVGAR3STATE pSVGAState)
     4991{
     4992    int rc = VINF_SUCCESS;
     4993    RT_ZERO(*pSVGAState);
     4994
     4995    pSVGAState->paGMR = (PGMR)RTMemAllocZ(pThis->svga.cGMR * sizeof(GMR));
     4996    AssertReturn(pSVGAState->paGMR, VERR_NO_MEMORY);
     4997
     4998#ifndef VMSVGA_USE_EMT_HALT_CODE
     4999    /* Create semaphore for delaying EMTs wait for the FIFO to stop being busy. */
     5000    rc = RTSemEventMultiCreate(&pSVGAState->hBusyDelayedEmts);
     5001    AssertRCReturn(rc, rc);
     5002#endif
     5003
     5004    return rc;
     5005}
     5006
     5007/**
    49505008 * Resets the SVGA hardware state
    49515009 *
     
    49645022    Log(("vmsvgaReset\n"));
    49655023
    4966 
    49675024    /* Reset the FIFO processing as well as the 3d state (if we have one). */
    49685025    pThis->svga.pFIFOR3[SVGA_FIFO_NEXT_CMD] = pThis->svga.pFIFOR3[SVGA_FIFO_STOP] = 0; /** @todo should probably let the FIFO thread do this ... */
     
    49725029    pThis->svga.cScratchRegion = VMSVGA_SCRATCH_SIZE;
    49735030    RT_ZERO(pThis->svga.au32ScratchRegion);
    4974     RT_ZERO(*pThis->svga.pSvgaR3State);
     5031
     5032    vmsvgaR3StateDestruct(pThis, pThis->svga.pSvgaR3State);
     5033    vmsvgaR3StateConstruct(pThis, pThis->svga.pSvgaR3State);
     5034
    49755035    RT_BZERO(pThis->svga.pbVgaFrameBufferR3, VMSVGA_VGA_FB_BACKUP_SIZE);
    49765036
     
    50265086     * Destroy the special SVGA state.
    50275087     */
    5028     PVMSVGAR3STATE pSVGAState = pThis->svga.pSvgaR3State;
    5029     if (pSVGAState)
    5030     {
    5031 # ifndef VMSVGA_USE_EMT_HALT_CODE
    5032         if (pSVGAState->hBusyDelayedEmts != NIL_RTSEMEVENTMULTI)
    5033         {
    5034             RTSemEventMultiDestroy(pSVGAState->hBusyDelayedEmts);
    5035             pSVGAState->hBusyDelayedEmts = NIL_RTSEMEVENT;
    5036         }
    5037 # endif
    5038         if (pSVGAState->Cursor.fActive)
    5039             RTMemFree(pSVGAState->Cursor.pData);
    5040 
    5041         if (pSVGAState->paGMR)
    5042         {
    5043             for (unsigned i = 0; i < pThis->svga.cGMR; ++i)
    5044                 if (pSVGAState->paGMR[i].paDesc)
    5045                     RTMemFree(pSVGAState->paGMR[i].paDesc);
    5046 
    5047             RTMemFree(pSVGAState->paGMR);
    5048             pSVGAState->paGMR = NULL;
    5049         }
    5050 
    5051         RTMemFree(pSVGAState);
     5088    if (pThis->svga.pSvgaR3State)
     5089    {
     5090        vmsvgaR3StateDestruct(pThis, pThis->svga.pSvgaR3State);
     5091
     5092        RTMemFree(pThis->svga.pSvgaR3State);
    50525093        pThis->svga.pSvgaR3State = NULL;
    50535094    }
     
    50915132    memset(pThis->svga.au32ScratchRegion, 0, sizeof(pThis->svga.au32ScratchRegion));
    50925133
    5093     pThis->svga.pSvgaR3State = (PVMSVGAR3STATE)RTMemAllocZ(sizeof(VMSVGAR3STATE));
    5094     AssertReturn(pThis->svga.pSvgaR3State, VERR_NO_MEMORY);
    5095     pSVGAState = pThis->svga.pSvgaR3State;
    5096 
    50975134    pThis->svga.cGMR = VMSVGA_MAX_GMR_IDS;
    5098     pSVGAState->paGMR = (PGMR)RTMemAllocZ(pThis->svga.cGMR * sizeof(GMR));
    5099     AssertReturn(pSVGAState->paGMR, VERR_NO_MEMORY);
    51005135
    51015136    /* Necessary for creating a backup of the text mode frame buffer when switching into svga mode. */
     
    51215156    }
    51225157
    5123 # ifndef VMSVGA_USE_EMT_HALT_CODE
    5124     /* Create semaphore for delaying EMTs wait for the FIFO to stop being busy. */
    5125     rc = RTSemEventMultiCreate(&pSVGAState->hBusyDelayedEmts);
    5126     AssertRCReturn(rc, rc);
    5127 # endif
     5158    pThis->svga.pSvgaR3State = (PVMSVGAR3STATE)RTMemAlloc(sizeof(VMSVGAR3STATE));
     5159    AssertReturn(pThis->svga.pSvgaR3State, VERR_NO_MEMORY);
     5160
     5161    rc = vmsvgaR3StateConstruct(pThis, pThis->svga.pSvgaR3State);
     5162    AssertMsgRCReturn(rc, ("Failed to create pSvgaR3State.\n"), rc);
     5163
     5164    pSVGAState = pThis->svga.pSvgaR3State;
    51285165
    51295166    /* Register caps. */
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