VirtualBox

Changeset 33146 in vbox


Ignore:
Timestamp:
Oct 15, 2010 10:34:58 AM (14 years ago)
Author:
vboxsync
Message:

wddm/3d: chromium hgsmi, host part + guest part debugging

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/VBoxCrOpenGLSvc.h

    r33116 r33146  
    3838#define SHCRGL_HOST_FN_SET_VM (7)
    3939#define SHCRGL_HOST_FN_SCREEN_CHANGED (8)
     40#ifdef VBOX_WITH_CRHGSMI
     41#define SHCRGL_HOST_FN_CRHGSMI_CMD (10)
     42#define SHCRGL_HOST_FN_CRHGSMI_CTL (11)
     43#endif
    4044/* crOpenGL guest functions */
    4145#define SHCRGL_GUEST_FN_WRITE       (2)
  • trunk/include/VBox/VBoxVideo.h

    r33048 r33146  
    10481048#pragma pack()
    10491049
     1050typedef uint64_t VBOXVIDEOOFFSET;
     1051
     1052#define VBOXVIDEOOFFSET_VOID ((VBOXVIDEOOFFSET)~0)
     1053
    10501054#ifdef VBOX_WITH_WDDM
    10511055# pragma pack(1)
     
    11001104    return (PVBOXSHGSMIHEADER)((uint8_t *)pvData - sizeof (VBOXSHGSMIHEADER));
    11011105}
    1102 
    1103 typedef uint64_t VBOXVIDEOOFFSET;
    1104 
    1105 #define VBOXVIDEOOFFSET_VOID ((VBOXVIDEOOFFSET)~0)
    11061106
    11071107typedef enum
     
    12371237
    12381238#define VBOXVDMACBUF_DR_TAIL(_pCmd, _t) ( (_t*)(((uint8_t*)(_pCmd)) + sizeof (VBOXVDMACBUF_DR)) )
     1239#define VBOXVDMACBUF_DR_FROM_TAIL(_pCmd) ( (VBOXVDMACBUF_DR*)(((uint8_t*)(_pCmd)) - sizeof (VBOXVDMACBUF_DR)) )
    12391240
    12401241typedef struct VBOXVDMACMD
     
    12481249#define VBOXVDMACMD_SIZE(_t) (VBOXVDMACMD_SIZE_FROMBODYSIZE(sizeof (_t)))
    12491250#define VBOXVDMACMD_BODY(_pCmd, _t) ( (_t*)(((uint8_t*)(_pCmd)) + VBOXVDMACMD_HEADER_SIZE()) )
     1251#define VBOXVDMACMD_FROM_BODY(_pCmd) ( (VBOXVDMACMD*)(((uint8_t*)(_pCmd)) - VBOXVDMACMD_HEADER_SIZE()) )
    12501252#define VBOXVDMACMD_BODY_FIELD_OFFSET(_ot, _t, _f) ( (_ot)( VBOXVDMACMD_BODY(0, uint8_t) + RT_OFFSETOF(_t, _f) ) )
    12511253
     
    12931295} VBOXVDMACMD_DMA_BPB_FILL, *PVBOXVDMACMD_DMA_BPB_FILL;
    12941296
     1297# pragma pack()
     1298#endif /* #ifdef VBOX_WITH_VDMA */
     1299
     1300#ifdef VBOX_WITH_CRHGSMI
     1301# pragma pack(1)
    12951302typedef struct VBOXVDMACMD_CHROMIUM_BUFFER
    12961303{
     
    13031310typedef struct VBOXVDMACMD_CHROMIUM_CMD
    13041311{
    1305     /* the number of buffers is specified in the VBOXVDMACMD::u32CmdSpecific*/
     1312    uint32_t cBuffers;
     1313    uint32_t u32Reserved;
    13061314    VBOXVDMACMD_CHROMIUM_BUFFER aBuffers[1];
    13071315} VBOXVDMACMD_CHROMIUM_CMD, *PVBOXVDMACMD_CHROMIUM_CMD;
    13081316
     1317typedef enum
     1318{
     1319    VBOXVDMACMD_CHROMIUM_CTL_TYPE_UNKNOWN = 0,
     1320    VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP,
     1321    VBOXVDMACMD_CHROMIUM_CTL_TYPE_SIZEHACK = 0xfffffffe
     1322} VBOXVDMACMD_CHROMIUM_CTL_TYPE;
     1323
     1324typedef struct VBOXVDMACMD_CHROMIUM_CTL
     1325{
     1326    VBOXVDMACMD_CHROMIUM_CTL_TYPE enmType;
     1327    uint32_t cbCmd;
     1328} VBOXVDMACMD_CHROMIUM_CTL, *PVBOXVDMACMD_CHROMIUM_CTL;
     1329
     1330typedef struct VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP
     1331{
     1332    VBOXVDMACMD_CHROMIUM_CTL Hdr;
     1333    union
     1334    {
     1335        void *pvRamBase;
     1336        uint64_t uAlignment;
     1337    };
     1338} VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP, *PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP;
    13091339# pragma pack()
    1310 #endif /* #ifdef VBOX_WITH_VDMA */
     1340#endif
    13111341
    13121342#ifdef VBOXVDMA_WITH_VBVA
  • trunk/include/VBox/hgcmsvc.h

    r29869 r33146  
    318318typedef VBOXHGCMSVCPARM *PVBOXHGCMSVCPARM;
    319319
     320#ifdef VBOX_WITH_CRHGSMI
     321typedef void * HGCMCVSHANDLE;
     322
     323typedef DECLCALLBACK(void) HGCMHOSTFASTCALLCB (int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
     324typedef HGCMHOSTFASTCALLCB *PHGCMHOSTFASTCALLCB;
     325#endif
     326
     327
    320328/** Service specific extension callback.
    321329 *  This callback is called by the service to perform service specific operation.
  • trunk/include/VBox/pdmifs.h

    r32983 r33146  
    595595typedef struct VBVAINFOVIEW *PVBVAINFOVIEW;
    596596typedef struct VBVAHOSTFLAGS *PVBVAHOSTFLAGS;
     597typedef struct VBOXVDMACMD_CHROMIUM_CMD *PVBOXVDMACMD_CHROMIUM_CMD; /* <- chromium [hgsmi] command */
     598typedef struct VBOXVDMACMD_CHROMIUM_CTL *PVBOXVDMACMD_CHROMIUM_CTL; /* <- chromium [hgsmi] command */
    597599
    598600/** Pointer to a display connector interface. */
     
    704706     */
    705707    DECLR3CALLBACKMEMBER(void, pfnVHWACommandProcess, (PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCmd));
     708
     709    /**
     710     * Process the guest chromium command.
     711     *
     712     * @param   pInterface          Pointer to this interface.
     713     * @param   pCmd                Video HW Acceleration Command to be processed.
     714     * @thread  The emulation thread.
     715     */
     716    DECLR3CALLBACKMEMBER(void, pfnCrHgsmiCommandProcess, (PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd));
     717
     718    /**
     719     * Process the guest chromium control command.
     720     *
     721     * @param   pInterface          Pointer to this interface.
     722     * @param   pCmd                Video HW Acceleration Command to be processed.
     723     * @thread  The emulation thread.
     724     */
     725    DECLR3CALLBACKMEMBER(void, pfnCrHgsmiControlProcess, (PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl));
     726
    706727
    707728    /**
     
    26992720    DECLR3CALLBACKMEMBER(int, pfnVHWACommandCompleteAsynch, (PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd));
    27002721
     2722    DECLR3CALLBACKMEMBER(int, pfnCrHgsmiCommandCompleteAsync, (PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc));
     2723
     2724    DECLR3CALLBACKMEMBER(int, pfnCrHgsmiControlCompleteAsync, (PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc));
    27012725} PDMIDISPLAYVBVACALLBACKS;
    27022726/** PDMIDISPLAYVBVACALLBACKS  */
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxCrHgsmi.cpp

    r33120 r33146  
    2626    if (!g_hVBoxCrHgsmiProvider)
    2727    {
    28         BOOL bRc = GetModuleHandleEx(0, "VBoxDispD3D", &g_hVBoxCrHgsmiProvider);
     28        BOOL bRc = GetModuleHandleEx(0, L"VBoxDispD3D", &g_hVBoxCrHgsmiProvider);
    2929//        g_hVBoxCrHgsmiProvider = GetModuleHandle(L"VBoxDispD3D");
    3030        if (bRc)
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiBase.h

    r33117 r33146  
    6969        }
    7070
    71         uint32_t iFirstPage = offLock >> 0x1000;
    72         uint32_t iAfterLastPage = (cbLock + 0xfff) >> 0x1000;
     71        uint32_t iFirstPage = offLock >> 12;
     72        uint32_t iAfterLastPage = (cbLock + 0xfff) >> 12;
    7373        uint32_t cPages = iAfterLastPage - iFirstPage;
    74         uint32_t cBufPages = pBuf->cbBuffer >> 0x1000;
     74        uint32_t cBufPages = pBuf->cbBuffer >> 12;
    7575        Assert(cPages <= (cBufPages));
    7676
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiDisp.cpp

    r33116 r33146  
    103103    cbBuf = VBOXWDDM_ROUNDBOUND(cbBuf, 0x1000);
    104104    Assert(cbBuf);
    105     uint32_t cPages = cbBuf >> 0x1000;
     105    uint32_t cPages = cbBuf >> 12;
    106106    Assert(cPages);
    107107
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.cpp

    r33116 r33146  
    103103    cbBuf = VBOXWDDM_ROUNDBOUND(cbBuf, 0x1000);
    104104    Assert(cbBuf);
    105     uint32_t cPages = cbBuf >> 0x1000;
     105    uint32_t cPages = cbBuf >> 12;
    106106    Assert(cPages);
    107107
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Makefile.kmk

    r33048 r33146  
    8484  VBoxVideoWddm_DEFS     += VBOX_WITH_VDMA
    8585 endif
     86 ifdef VBOX_WITH_CRHGSMI
     87  VBoxVideoWddm_DEFS     += VBOX_WITH_CRHGSMI
     88 endif
     89 
    8690 ifdef DEBUG_misha
    8791  VBoxVideoWddm_DEFS       += LOG_ENABLED
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r33116 r33146  
    15921592                            Assert(Status == STATUS_SUCCESS);
    15931593                            break;
     1594                        case VBOXUHGSMI_SYNCHOBJECT_TYPE_NONE:
     1595                            pAllocation->pSynchEvent = NULL;
     1596                            Status == STATUS_SUCCESS;
     1597                            break;
    15941598                        default:
    15951599                            drprintf((__FUNCTION__ ": ERROR: invalid synch info type(%d)\n", pAllocInfo->enmSynchType));
     
    21592163    PVBOXVDMACBUF_DR pDr = (PVBOXVDMACBUF_DR)pvContext;
    21602164    PVBOXVDMACMD pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    2161     UINT cBufs = pHdr->u32CmdSpecific;
    21622165    VBOXVDMACMD_CHROMIUM_CMD *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHROMIUM_CMD);
     2166    UINT cBufs = pBody->cBuffers;
    21632167    for (UINT i = 0; i < cBufs; ++i)
    21642168    {
     
    21792183                        FALSE);
    21802184                    break;
     2185                case VBOXUHGSMI_SYNCHOBJECT_TYPE_NONE:
     2186                    break;
    21812187                default:
    21822188                    Assert(0);
     
    21872193    vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    21882194}
    2189 
    21902195#endif
     2196
    21912197NTSTATUS
    21922198APIENTRY
     
    23792385            PVBOXVDMACMD pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    23802386            pHdr->enmType = VBOXVDMACMD_TYPE_CHROMIUM_CMD;
    2381             pHdr->u32CmdSpecific = pChromiumCmd->Base.u32CmdReserved;
     2387            pHdr->u32CmdSpecific = 0;
    23822388            VBOXVDMACMD_CHROMIUM_CMD *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHROMIUM_CMD);
     2389            pBody->cBuffers = pChromiumCmd->Base.u32CmdReserved;
    23832390            for (UINT i = 0; i < pChromiumCmd->Base.u32CmdReserved; ++i)
    23842391            {
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r33091 r33146  
    63576357    pThis->IPort.pfnSetRenderVRAM       = vgaPortSetRenderVRAM;
    63586358
    6359 #if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
     6359#if defined(VBOX_WITH_HGSMI)
     6360# if defined(VBOX_WITH_VIDEOHWACCEL)
    63606361    pThis->IVBVACallbacks.pfnVHWACommandCompleteAsynch = vbvaVHWACommandCompleteAsynch;
     6362# endif
     6363#if defined(VBOX_WITH_CRHGSMI)
     6364    pThis->IVBVACallbacks.pfnCrHgsmiCommandCompleteAsync = vboxVDMACrHgsmiCommandCompleteAsync;
     6365    pThis->IVBVACallbacks.pfnCrHgsmiControlCompleteAsync = vboxVDMACrHgsmiControlCompleteAsync;
     6366# endif
    63616367#endif
    63626368
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r33089 r33146  
    492492# endif
    493493
     494#ifdef VBOX_WITH_HGSMI
     495#define PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(_pcb) ( (PVGASTATE)((uint8_t *)(_pcb) - RT_OFFSETOF(VGASTATE, IVBVACallbacks)) )
     496#endif
     497
     498# ifdef VBOX_WITH_CRHGSMI
     499int vboxVDMACrHgsmiCommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc);
     500int vboxVDMACrHgsmiControlCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc);
     501# endif
     502
    494503int vboxVBVASaveStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
    495504int vboxVBVALoadStateExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version);
  • trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp

    r32877 r33146  
    12371237}
    12381238
    1239 #define PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(_pcb) ( (PVGASTATE)((uint8_t *)(_pcb) - RT_OFFSETOF(VGASTATE, IVBVACallbacks)) )
    1240 
    12411239int vbvaVHWACommandCompleteAsynch(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd)
    12421240{
  • trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp

    r32904 r33146  
    2020#include <iprt/thread.h>
    2121#include <iprt/mem.h>
     22#include <iprt/asm.h>
    2223
    2324#include "DevVGA.h"
     
    8687    VBOXVDMAPIPE_CMD_POOL CmdPool;
    8788} VBOXVDMAHOST, *PVBOXVDMAHOST;
     89
     90
     91#ifdef VBOX_WITH_CRHGSMI
     92
     93typedef DECLCALLBACK(void) FNVBOXVDMACRCTL_CALLBACK(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void* pvContext);
     94typedef FNVBOXVDMACRCTL_CALLBACK *PFNVBOXVDMACRCTL_CALLBACK;
     95
     96typedef struct VBOXVDMACMD_CHROMIUM_CTL_PRIVATE
     97{
     98    uint32_t cRefs;
     99    uint32_t rc;
     100    PFNVBOXVDMACRCTL_CALLBACK pfnCompletion;
     101    void *pvCompletion;
     102    VBOXVDMACMD_CHROMIUM_CTL Cmd;
     103} VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, *PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE;
     104
     105#define VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(_p) ((PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, Cmd)))
     106
     107static PVBOXVDMACMD_CHROMIUM_CTL vboxVDMACrCtlCreate(VBOXVDMACMD_CHROMIUM_CTL_TYPE enmCmd, uint32_t cbCmd)
     108{
     109    PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = (PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE)RTMemAllocZ(cbCmd + RT_OFFSETOF(VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, Cmd));
     110    Assert(pHdr);
     111    if (pHdr)
     112    {
     113        pHdr->cRefs = 1;
     114        pHdr->rc = VERR_NOT_IMPLEMENTED;
     115        pHdr->Cmd.enmType = enmCmd;
     116        pHdr->Cmd.cbCmd = cbCmd;
     117        return &pHdr->Cmd;
     118    }
     119
     120    return NULL;
     121}
     122
     123DECLINLINE(void) vboxVDMACrCtlRelease (PVBOXVDMACMD_CHROMIUM_CTL pCmd)
     124{
     125    PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd);
     126    uint32_t cRefs = ASMAtomicDecU32(&pHdr->cRefs);
     127    if(!cRefs)
     128    {
     129        RTMemFree(pHdr);
     130    }
     131}
     132
     133DECLINLINE(void) vboxVDMACrCtlRetain (PVBOXVDMACMD_CHROMIUM_CTL pCmd)
     134{
     135    PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd);
     136    ASMAtomicIncU32(&pHdr->cRefs);
     137}
     138
     139DECLINLINE(int) vboxVDMACrCtlGetRc (PVBOXVDMACMD_CHROMIUM_CTL pCmd)
     140{
     141    PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd);
     142    return pHdr->rc;
     143}
     144
     145static DECLCALLBACK(void) vboxVDMACrCtlCbSetEvent(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void* pvContext)
     146{
     147    RTSemEventSignal((RTSEMEVENT)pvContext);
     148}
     149
     150static DECLCALLBACK(void) vboxVDMACrCtlCbReleaseCmd(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void* pvContext)
     151{
     152    vboxVDMACrCtlRelease(pCmd);
     153}
     154
     155
     156static int vboxVDMACrCtlPostAsync (PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, PFNVBOXVDMACRCTL_CALLBACK pfnCompletion, void *pvCompletion)
     157{
     158    if (pVGAState->pDrv->pfnCrHgsmiControlProcess)
     159    {
     160        PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd);
     161        pHdr->pfnCompletion = pfnCompletion;
     162        pHdr->pvCompletion = pvCompletion;
     163        pVGAState->pDrv->pfnCrHgsmiControlProcess(pVGAState->pDrv, pCmd);
     164        return VINF_SUCCESS;
     165    }
     166#ifdef DEBUG_misha
     167    Assert(0);
     168#endif
     169    return VERR_NOT_SUPPORTED;
     170}
     171
     172static int vboxVDMACrCtlPost(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd)
     173{
     174    RTSEMEVENT hComplEvent;
     175    int rc = RTSemEventCreate(&hComplEvent);
     176    AssertRC(rc);
     177    if(RT_SUCCESS(rc))
     178    {
     179        rc = vboxVDMACrCtlPostAsync (pVGAState, pCmd, vboxVDMACrCtlCbSetEvent, (void*)hComplEvent);
     180#ifdef DEBUG_misha
     181        AssertRC(rc);
     182#endif
     183        if (RT_SUCCESS(rc))
     184        {
     185            rc = RTSemEventWaitNoResume(hComplEvent, RT_INDEFINITE_WAIT);
     186            AssertRC(rc);
     187            if(RT_SUCCESS(rc))
     188            {
     189                RTSemEventDestroy(hComplEvent);
     190            }
     191        }
     192        else
     193        {
     194            /* the command is completed */
     195            RTSemEventDestroy(hComplEvent);
     196        }
     197    }
     198    return rc;
     199}
     200
     201static int vboxVDMACrCtlHgsmiSetupAsync(struct VBOXVDMAHOST *pVdma)
     202{
     203    PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pCmd = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)vboxVDMACrCtlCreate(
     204            VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP, sizeof (*pCmd));
     205    if (pCmd)
     206    {
     207        PVGASTATE pVGAState = pVdma->pVGAState;
     208        pCmd->pvRamBase = pVGAState->vram_ptrR3;
     209        int rc = vboxVDMACrCtlPostAsync(pVGAState, &pCmd->Hdr, vboxVDMACrCtlCbReleaseCmd, NULL);
     210#ifdef DEBUG_misha
     211        AssertRC(rc);
     212#endif
     213#if 0
     214        if (RT_SUCCESS(rc))
     215        {
     216            rc = vboxVDMACrCtlGetRc(&pCmd->Hdr);
     217        }
     218        vboxVDMACrCtlRelease(&pCmd->Hdr);
     219#endif
     220        return rc;
     221    }
     222    return VERR_NO_MEMORY;
     223}
     224
     225/* check if this is external cmd to be passed to chromium backend */
     226static bool vboxVDMACmdCheckCrCmd(struct VBOXVDMAHOST *pVdma, PVBOXVDMACBUF_DR pCmd)
     227{
     228    PVBOXVDMACMD pDmaCmd;
     229    uint8_t * pvRam = pVdma->pVGAState->vram_ptrR3;
     230
     231    if (pCmd->fFlags & VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR)
     232        pDmaCmd = VBOXVDMACBUF_DR_TAIL(pCmd, VBOXVDMACMD);
     233    else
     234        pDmaCmd = NULL;
     235
     236    if (pDmaCmd)
     237    {
     238        uint32_t cbCmd = pCmd->cbBuf;
     239        Assert(cbCmd >= VBOXVDMACMD_HEADER_SIZE());
     240
     241        if (cbCmd >= VBOXVDMACMD_HEADER_SIZE())
     242        {
     243            if (pDmaCmd->enmType == VBOXVDMACMD_TYPE_CHROMIUM_CMD)
     244            {
     245                PVBOXVDMACMD_CHROMIUM_CMD pCrCmd = VBOXVDMACMD_BODY(pDmaCmd, VBOXVDMACMD_CHROMIUM_CMD);
     246                PVGASTATE pVGAState = pVdma->pVGAState;
     247                if (pVGAState->pDrv->pfnCrHgsmiCommandProcess)
     248                {
     249                    pVGAState->pDrv->pfnCrHgsmiCommandProcess(pVGAState->pDrv, pCrCmd);
     250                    return true;
     251                }
     252                else
     253                {
     254                    Assert(0);
     255                }
     256
     257                int tmpRc = VBoxSHGSMICommandComplete (pVdma->pHgsmi, pCmd);
     258                AssertRC(tmpRc);
     259//                uint32_t cBufs = pCrCmd->cBuffers;
     260//                for (uint32_t i = 0; i < cBufs; ++i)
     261//                {
     262//                    PVBOXVDMACMD_CHROMIUM_BUFFER pBuf = &pCrCmd->aBuffers[i];
     263//                    void *pvBuffer = pvRam + pBuf->offBuffer;
     264//                    uint32_t cbBuffer = pBuf->cbBuffer;
     265//                }
     266            }
     267        }
     268    }
     269    return false;
     270}
     271
     272int vboxVDMACrHgsmiCommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc)
     273{
     274    PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface);
     275    PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
     276    VBOXVDMACMD *pDmaHdr = VBOXVDMACMD_FROM_BODY(pCmd);
     277    VBOXVDMACBUF_DR *pDr = VBOXVDMACBUF_DR_FROM_TAIL(pDmaHdr);
     278    pDr->rc = rc;
     279
     280    Assert(pVGAState->fGuestCaps & VBVACAPS_COMPLETEGCMD_BY_IOREAD);
     281    rc = HGSMICompleteGuestCommand(pIns, pDr, true /* do Irq */);
     282    AssertRC(rc);
     283    return rc;
     284}
     285
     286int vboxVDMACrHgsmiControlCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc)
     287{
     288    PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface);
     289    PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pCmdPrivate = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd);
     290    pCmdPrivate->rc = rc;
     291    if (pCmdPrivate->pfnCompletion)
     292    {
     293        pCmdPrivate->pfnCompletion(pVGAState, pCmd, pCmdPrivate->pvCompletion);
     294    }
     295    return VINF_SUCCESS;
     296}
     297
     298#endif
     299
    88300
    89301/* to simplify things and to avoid extra backend if modifications we assume the VBOXVDMA_RECTL is the same as VBVACMDHDR */
     
    739951                    hgsmiListAppend(&pVdma->CmdPool.List, &pVdma->CmdPool.aCmds[i].Entry);
    740952                }
     953#if 0 //def VBOX_WITH_CRHGSMI
     954                int tmpRc = vboxVDMACrCtlHgsmiSetup(pVdma);
     955# ifdef DEBUG_misha
     956                AssertRC(tmpRc);
     957# endif
     958#endif
    741959                *ppVdma = pVdma;
    742960                return VINF_SUCCESS;
     
    7971015    {
    7981016        case VBOXVDMA_CTL_TYPE_ENABLE:
     1017        {
    7991018            pVdma->bEnabled = true;
    8001019            pCmd->i32Result = VINF_SUCCESS;
     1020#ifdef VBOX_WITH_CRHGSMI
     1021            /* @todo: use async completion to ensure we notify a status to guest */
     1022            int tmpRc = vboxVDMACrCtlHgsmiSetupAsync(pVdma);
     1023            AssertRC(tmpRc);
     1024#endif
     1025        }
    8011026            break;
    8021027        case VBOXVDMA_CTL_TYPE_DISABLE:
     
    8461071void vboxVDMACommand(struct VBOXVDMAHOST *pVdma, PVBOXVDMACBUF_DR pCmd)
    8471072{
     1073#ifdef VBOX_WITH_CRHGSMI
     1074    if (vboxVDMACmdCheckCrCmd(pVdma, pCmd))
     1075        return;
     1076#endif
     1077
    8481078    VBOXVDMACMD_SUBMIT_CONTEXT Context;
    8491079    Context.pVdma = pVdma;
  • trunk/src/VBox/Devices/Makefile.kmk

    r33037 r33146  
    350350        Graphics/DevVGA_VDMA.cpp
    351351endif
     352ifdef VBOX_WITH_CRHGSMI
     353 DevicesR3_DEFS        += VBOX_WITH_CRHGSMI
     354endif
     355
    352356ifdef VBOXWDDM_TEST_UHGSMI
    353357 DevicesR3_DEFS   += VBOXWDDM_TEST_UHGSMI
     
    588592  VBoxDDGC_DEFS        += VBOX_WITH_VDMA
    589593 endif
     594 ifdef VBOX_WITH_CRHGSMI
     595  VBoxDDGC_DEFS        += VBOX_WITH_CRHGSMI
     596 endif
    590597
    591598 ifdef VBOXWDDM_WITH_VBVA
     
    617624  VBoxDDGC_DEFS        += VBOX_WITH_VDMA
    618625 endif
     626 ifdef VBOX_WITH_CRHGSMI
     627  VBoxDDGC_DEFS        += VBOX_WITH_CRHGSMI
     628 endif
     629 
    619630 ifdef VBOXWDDM_WITH_VBVA
    620631  VBoxDDGC_DEFS         += VBOXWDDM_WITH_VBVA
     
    707718 VBoxDDR0_DEFS        += VBOX_WITH_VDMA
    708719endif
     720ifdef VBOX_WITH_CRHGSMI
     721 VBoxDDR0_DEFS        += VBOX_WITH_CRHGSMI
     722endif
     723
    709724ifdef VBOXWDDM_WITH_VBVA
    710725 VBoxDDR0_DEFS         += VBOXWDDM_WITH_VBVA
     
    756771 VBoxDDR0_DEFS         += VBOX_WITH_VDMA
    757772endif
     773ifdef VBOX_WITH_CRHGSMI
     774 VBoxDDR0_DEFS        += VBOX_WITH_CRHGSMI
     775endif
     776
    758777ifdef VBOXWDDM_WITH_VBVA
    759778 VBoxDDR0_DEFS        += VBOXWDDM_WITH_VBVA
  • trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk

    r32175 r33146  
    9090 VBoxSharedCrOpenGL_LIBS += \
    9191        $(LIB_XPCOM)
     92endif
     93ifdef VBOX_WITH_CRHGSMI
     94VBoxSharedCrOpenGL_DEFS += VBOX_WITH_CRHGSMI
    9295endif
    9396
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r32420 r33146  
    5353#endif /* RT_OS_WINDOWS */
    5454
     55#ifdef VBOX_WITH_CRHGSMI
     56#include <VBox/VBoxVideo.h>
     57#endif
     58
    5559#include <VBox/com/errorprint.h>
    5660
     
    5862static IConsole* g_pConsole = NULL;
    5963static PVM g_pVM = NULL;
     64#ifdef VBOX_WITH_CRHGSMI
     65static uint8_t* g_pvVRamBase;
     66#endif
    6067
    6168#ifndef RT_OS_WINDOWS
     
    450457}
    451458
     459#ifdef VBOX_WITH_CRHGSMI
     460static int vboxCrHgsmiCtl(PVBOXVDMACMD_CHROMIUM_CTL pCtl)
     461{
     462    int rc;
     463    switch (pCtl->enmType)
     464    {
     465        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP:
     466        {
     467            PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pSetup = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)pCtl;
     468            g_pvVRamBase = (uint8_t*)pSetup->pvRamBase;
     469            rc = VINF_SUCCESS;
     470        } break;
     471        default:
     472            Assert(0);
     473            rc = VERR_INVALID_PARAMETER;
     474    }
     475
     476    return rc;
     477}
     478
     479#define VBOXCRHGSMI_PTR(_off, _t) ((_t*)(g_pvVRamBase + (_off)))
     480static int vboxCrHgsmiCmd(PVBOXVDMACMD_CHROMIUM_CMD pCmd)
     481{
     482    int rc;
     483    uint32_t cBuffers = pCmd->cBuffers;
     484    uint32_t cParams;
     485
     486    if (!g_pvVRamBase)
     487    {
     488        Assert(0);
     489        return VERR_INVALID_STATE;
     490    }
     491
     492    if (!cBuffers)
     493    {
     494        Assert(0);
     495        return VERR_INVALID_PARAMETER;
     496    }
     497
     498    cParams = cBuffers-1;
     499
     500    CRVBOXHGSMIHDR *pHdr = VBOXCRHGSMI_PTR(pCmd->aBuffers[0].offBuffer, CRVBOXHGSMIHDR);
     501    uint32_t u32Function = pHdr->u32Function;
     502    uint32_t u32ClientID = pHdr->u32ClientID;
     503    /* now we compile HGCM params out of HGSMI
     504     * @todo: can we avoid this ? */
     505    switch (u32Function)
     506    {
     507
     508        case SHCRGL_GUEST_FN_WRITE:
     509        {
     510            Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n"));
     511
     512            CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr;
     513
     514            /* @todo: Verify  */
     515            if (cParams == 1)
     516            {
     517                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
     518                /* Fetch parameters. */
     519                uint8_t *pBuffer  = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);
     520                uint32_t cbBuffer = pBuf->cbBuffer;
     521
     522                /* Execute the function. */
     523                rc = crVBoxServerClientWrite(u32ClientID, pBuffer, cbBuffer);
     524                if (!RT_SUCCESS(rc))
     525                {
     526                    Assert(VERR_NOT_SUPPORTED==rc);
     527                    svcClientVersionUnsupported(0, 0);
     528                }
     529            }
     530            else
     531            {
     532                Assert(0);
     533                rc = VERR_INVALID_PARAMETER;
     534            }
     535            break;
     536        }
     537
     538        case SHCRGL_GUEST_FN_INJECT:
     539        {
     540            Log(("svcCall: SHCRGL_GUEST_FN_INJECT\n"));
     541
     542            CRVBOXHGSMIINJECT *pFnCmd = (CRVBOXHGSMIINJECT*)pHdr;
     543
     544            /* @todo: Verify  */
     545            if (cParams == 1)
     546            {
     547                /* Fetch parameters. */
     548                uint32_t u32InjectClientID = pFnCmd->u32ClientID;
     549                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
     550                uint8_t *pBuffer  = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);
     551                uint32_t cbBuffer = pBuf->cbBuffer;
     552
     553                /* Execute the function. */
     554                rc = crVBoxServerClientWrite(u32InjectClientID, pBuffer, cbBuffer);
     555                if (!RT_SUCCESS(rc))
     556                {
     557                    if (VERR_NOT_SUPPORTED==rc)
     558                    {
     559                        svcClientVersionUnsupported(0, 0);
     560                    }
     561                    else
     562                    {
     563                        crWarning("SHCRGL_GUEST_FN_INJECT failed to inject for %i from %i", u32InjectClientID, u32ClientID);
     564                    }
     565                }
     566            }
     567            else
     568            {
     569                Assert(0);
     570                rc = VERR_INVALID_PARAMETER;
     571            }
     572            break;
     573        }
     574
     575        case SHCRGL_GUEST_FN_READ:
     576        {
     577            Log(("svcCall: SHCRGL_GUEST_FN_READ\n"));
     578
     579            /* @todo: Verify  */
     580            if (cParams == 1)
     581            {
     582                CRVBOXHGSMIREAD *pFnCmd = (CRVBOXHGSMIREAD*)pHdr;
     583                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
     584                /* Fetch parameters. */
     585                uint8_t *pBuffer  = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);
     586                uint32_t cbBuffer = pBuf->cbBuffer;
     587
     588                /* Execute the function. */
     589                rc = crVBoxServerClientRead(u32ClientID, pBuffer, &cbBuffer);
     590
     591                if (RT_SUCCESS(rc))
     592                {
     593                    /* Update parameters.*/
     594//                    paParms[0].u.pointer.size = cbBuffer; //@todo guest doesn't see this change somehow?
     595                } else if (VERR_NOT_SUPPORTED==rc)
     596                {
     597                    svcClientVersionUnsupported(0, 0);
     598                }
     599
     600                /* Return the required buffer size always */
     601                pFnCmd->cbBuffer = cbBuffer;
     602            }
     603            else
     604            {
     605                Assert(0);
     606                rc = VERR_INVALID_PARAMETER;
     607            }
     608
     609            break;
     610        }
     611
     612        case SHCRGL_GUEST_FN_WRITE_READ:
     613        {
     614            Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n"));
     615
     616            /* @todo: Verify  */
     617            if (cParams == 2)
     618            {
     619                CRVBOXHGSMIWRITEREAD *pFnCmd = (CRVBOXHGSMIWRITEREAD*)pHdr;
     620                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
     621                VBOXVDMACMD_CHROMIUM_BUFFER *pWbBuf = &pCmd->aBuffers[2];
     622
     623                /* Fetch parameters. */
     624                uint8_t *pBuffer  = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);
     625                uint32_t cbBuffer = pBuf->cbBuffer;
     626
     627                uint8_t *pWriteback  = VBOXCRHGSMI_PTR(pWbBuf->offBuffer, uint8_t);
     628                uint32_t cbWriteback = pWbBuf->cbBuffer;
     629
     630                /* Execute the function. */
     631                rc = crVBoxServerClientWrite(u32ClientID, pBuffer, cbBuffer);
     632                if (!RT_SUCCESS(rc))
     633                {
     634                    Assert(VERR_NOT_SUPPORTED==rc);
     635                    svcClientVersionUnsupported(0, 0);
     636                }
     637
     638                rc = crVBoxServerClientRead(u32ClientID, pWriteback, &cbWriteback);
     639
     640//                if (RT_SUCCESS(rc))
     641//                {
     642//                    /* Update parameters.*/
     643//                    paParms[1].u.pointer.size = cbWriteback;
     644//                }
     645                /* Return the required buffer size always */
     646                pFnCmd->cbWriteback = cbWriteback;
     647            }
     648            else
     649            {
     650                Assert(0);
     651                rc = VERR_INVALID_PARAMETER;
     652            }
     653
     654            break;
     655        }
     656
     657        case SHCRGL_GUEST_FN_SET_VERSION:
     658        {
     659            Assert(0);
     660            rc = VERR_NOT_IMPLEMENTED;
     661            break;
     662        }
     663
     664        default:
     665        {
     666            Assert(0);
     667            rc = VERR_NOT_IMPLEMENTED;
     668        }
     669
     670    }
     671
     672    pHdr->result = rc;
     673
     674    return VINF_SUCCESS;
     675}
     676#endif
     677
    452678/*
    453679 * We differentiate between a function handler for the guest and one for the host.
     
    471697    switch (u32Function)
    472698    {
     699#ifdef VBOX_WITH_CRHGSMI
     700        case SHCRGL_HOST_FN_CRHGSMI_CMD:
     701        {
     702            Assert(cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR);
     703            if (cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR)
     704                rc = vboxCrHgsmiCmd((PVBOXVDMACMD_CHROMIUM_CMD)paParms[0].u.pointer.addr);
     705            else
     706                rc = VERR_INVALID_PARAMETER;
     707        } break;
     708        case SHCRGL_HOST_FN_CRHGSMI_CTL:
     709        {
     710            Assert(cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR);
     711            if (cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR)
     712                rc = vboxCrHgsmiCtl((PVBOXVDMACMD_CHROMIUM_CTL)paParms[0].u.pointer.addr);
     713            else
     714                rc = VERR_INVALID_PARAMETER;
     715        } break;
     716#endif
    473717        case SHCRGL_HOST_FN_SET_CONSOLE:
    474718        {
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r32928 r33146  
    28952895}
    28962896
     2897#ifdef VBOX_WITH_CRHGSMI
     2898void Display::setupCrHgsmiData(void)
     2899{
     2900    VMMDev *pVMMDev = mParent->getVMMDev();
     2901    Assert(pVMMDev);
     2902    int rc = VERR_GENERAL_FAILURE;
     2903    if (pVMMDev)
     2904    {
     2905        rc = pVMMDev->hgcmHostSvcHandleCreate("VBoxSharedCrOpenGL", &mhCrOglSvc);
     2906        AssertRC(rc);
     2907    }
     2908
     2909    if (RT_FAILURE(rc))
     2910    {
     2911        mhCrOglSvc = NULL;
     2912    }
     2913}
     2914
     2915void Display::destructCrHgsmiData(void)
     2916{
     2917    if (mhCrOglSvc)
     2918    {
     2919        VMMDev *pVMMDev = mParent->getVMMDev();
     2920        Assert(pVMMDev);
     2921        if (pVMMDev)
     2922        {
     2923            int rc = pVMMDev->hgcmHostSvcHandleDestroy(mhCrOglSvc);
     2924            AssertRC(rc);
     2925        }
     2926    }
     2927}
     2928#endif
     2929
    28972930/**
    28982931 *  Changes the current frame buffer. Called on EMT to avoid both
     
    34773510#endif
    34783511
     3512#ifdef VBOX_WITH_CRHGSMI
     3513void Display::handleCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam)
     3514{
     3515    mpDrv->pVBVACallbacks->pfnCrHgsmiCommandCompleteAsync(mpDrv->pVBVACallbacks, (PVBOXVDMACMD_CHROMIUM_CMD)pParam->u.pointer.addr, result);
     3516}
     3517
     3518void Display::handleCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam)
     3519{
     3520    mpDrv->pVBVACallbacks->pfnCrHgsmiControlCompleteAsync(mpDrv->pVBVACallbacks, (PVBOXVDMACMD_CHROMIUM_CTL)pParam->u.pointer.addr, result);
     3521}
     3522
     3523void Display::handleCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd)
     3524{
     3525    int rc = VERR_INVALID_FUNCTION;
     3526    VBOXHGCMSVCPARM parm;
     3527    parm.type = VBOX_HGCM_SVC_PARM_PTR;
     3528    parm.u.pointer.addr = pCmd;
     3529    parm.u.pointer.size = 0;
     3530
     3531    if (mhCrOglSvc)
     3532    {
     3533        VMMDev *pVMMDev = mParent->getVMMDev();
     3534        if (pVMMDev)
     3535        {
     3536            rc = pVMMDev->hgcmHostFastCallAsync(mhCrOglSvc, SHCRGL_HOST_FN_CRHGSMI_CMD, &parm, Display::displayCrHgsmiCommandCompletion, this);
     3537            AssertRC(rc);
     3538            if (RT_SUCCESS(rc))
     3539                return;
     3540        }
     3541        else
     3542            rc = VERR_INVALID_STATE;
     3543    }
     3544
     3545    /* we are here because something went wrong with command prosessing, complete it */
     3546    handleCrHgsmiCommandCompletion(rc, SHCRGL_HOST_FN_CRHGSMI_CMD, &parm);
     3547}
     3548
     3549void Display::handleCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl)
     3550{
     3551    int rc = VERR_INVALID_FUNCTION;
     3552    VBOXHGCMSVCPARM parm;
     3553    parm.type = VBOX_HGCM_SVC_PARM_PTR;
     3554    parm.u.pointer.addr = pCtl;
     3555    parm.u.pointer.size = 0;
     3556
     3557    if (mhCrOglSvc)
     3558    {
     3559        VMMDev *pVMMDev = mParent->getVMMDev();
     3560        if (pVMMDev)
     3561        {
     3562            rc = pVMMDev->hgcmHostFastCallAsync(mhCrOglSvc, SHCRGL_HOST_FN_CRHGSMI_CTL, &parm, Display::displayCrHgsmiControlCompletion, this);
     3563            AssertRC(rc);
     3564            if (RT_SUCCESS(rc))
     3565                return;
     3566        }
     3567        else
     3568            rc = VERR_INVALID_STATE;
     3569    }
     3570
     3571    /* we are here because something went wrong with command prosessing, complete it */
     3572    handleCrHgsmiControlCompletion(rc, SHCRGL_HOST_FN_CRHGSMI_CTL, &parm);
     3573}
     3574
     3575DECLCALLBACK(void) Display::displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd)
     3576{
     3577    PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
     3578
     3579    pDrv->pDisplay->handleCrHgsmiCommandProcess(pInterface, pCmd);
     3580}
     3581
     3582DECLCALLBACK(void) Display::displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd)
     3583{
     3584    PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
     3585
     3586    pDrv->pDisplay->handleCrHgsmiControlProcess(pInterface, pCmd);
     3587}
     3588
     3589DECLCALLBACK(void) Display::displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext)
     3590{
     3591    Display *pDisplay = (Display *)pvContext;
     3592    pDisplay->handleCrHgsmiCommandCompletion(result, u32Function, pParam);
     3593}
     3594
     3595DECLCALLBACK(void) Display::displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext)
     3596{
     3597    Display *pDisplay = (Display *)pvContext;
     3598    pDisplay->handleCrHgsmiControlCompletion(result, u32Function, pParam);
     3599}
     3600#endif
     3601
     3602
    34793603#ifdef VBOX_WITH_HGSMI
    34803604DECLCALLBACK(int) Display::displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags)
     
    38173941    {
    38183942        AutoWriteLock displayLock(pData->pDisplay COMMA_LOCKVAL_SRC_POS);
     3943#ifdef VBOX_WITH_CRHGSMI
     3944        pData->pDisplay->destructCrHgsmiData();
     3945#endif
    38193946        pData->pDisplay->mpDrv = NULL;
    38203947        pData->pDisplay->mpVMMDev = NULL;
     
    38633990    pData->IConnector.pfnVHWACommandProcess = Display::displayVHWACommandProcess;
    38643991#endif
     3992#ifdef VBOX_WITH_CRHGSMI
     3993    pData->IConnector.pfnCrHgsmiCommandProcess = Display::displayCrHgsmiCommandProcess;
     3994    pData->IConnector.pfnCrHgsmiControlProcess = Display::displayCrHgsmiControlProcess;
     3995#endif
    38653996#ifdef VBOX_WITH_HGSMI
    38663997    pData->IConnector.pfnVBVAEnable         = Display::displayVBVAEnable;
     
    38834014        return VERR_PDM_MISSING_INTERFACE_ABOVE;
    38844015    }
    3885 #if defined(VBOX_WITH_VIDEOHWACCEL)
     4016#if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_CRHGSMI)
    38864017    pData->pVBVACallbacks = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIDISPLAYVBVACALLBACKS);
    38874018    if (!pData->pVBVACallbacks)
     
    39134044     */
    39144045    pData->pUpPort->pfnSetRefreshRate(pData->pUpPort, 20);
     4046
     4047#ifdef VBOX_WITH_CRHGSMI
     4048    pData->pDisplay->setupCrHgsmiData();
     4049#endif
    39154050
    39164051    return VINF_SUCCESS;
  • trunk/src/VBox/Main/Makefile.kmk

    r33060 r33146  
    668668endif
    669669
     670ifdef VBOX_WITH_CRHGSMI
     671VBoxC_DEFS += VBOX_WITH_CRHGSMI
     672endif
     673
    670674ifdef VBOX_WITH_USB
    671675VBoxC_SOURCES += \
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r32851 r33146  
    766766    HGCMHostShutdown();
    767767}
     768
     769# ifdef VBOX_WITH_CRHGSMI
     770int VMMDev::hgcmHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc)
     771{
     772    if (!hgcmIsActive())
     773        return VERR_INVALID_STATE;
     774    return HGCMHostSvcHandleCreate(pszServiceName, phSvc);
     775}
     776
     777int VMMDev::hgcmHostSvcHandleDestroy (HGCMCVSHANDLE hSvc)
     778{
     779    if (!hgcmIsActive())
     780        return VERR_INVALID_STATE;
     781    return HGCMHostSvcHandleDestroy(hSvc);
     782}
     783
     784int VMMDev::hgcmHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
     785{
     786    if (!hgcmIsActive())
     787        return VERR_INVALID_STATE;
     788    return HGCMHostFastCallAsync(hSvc, function, pParm, pfnCompletion, pvCompletion);
     789}
     790# endif
    768791
    769792#endif /* HGCM */
  • trunk/src/VBox/Main/hgcm/HGCM.cpp

    r29071 r33146  
    151151
    152152        int HostCall (uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM *paParms);
     153
     154#ifdef VBOX_WITH_CRHGSMI
     155        int HostFastCallAsync (uint32_t u32Function, VBOXHGCMSVCPARM *pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion);
     156#endif
    153157
    154158        uint32_t SizeOfClient (void) { return m_fntable.cbClient; };
     
    347351#define SVC_MSG_REGEXT     (9)  /* pfnRegisterExtension */
    348352#define SVC_MSG_UNREGEXT   (10) /* pfnRegisterExtension */
     353#ifdef VBOX_WITH_CRHGSMI
     354# define SVC_MSG_HOSTFASTCALLASYNC (21) /* pfnHostCall */
     355#endif
    349356
    350357class HGCMMsgSvcLoad: public HGCMMsgCore
     
    435442};
    436443
     444#ifdef VBOX_WITH_CRHGSMI
     445class HGCMMsgHostFastCallAsyncSvc: public HGCMMsgCore
     446{
     447    public:
     448        /* function number */
     449        uint32_t u32Function;
     450        /* parameter */
     451        VBOXHGCMSVCPARM Param;
     452        /* completion info */
     453        PHGCMHOSTFASTCALLCB pfnCompletion;
     454        void *pvCompletion;
     455};
     456#endif
     457
    437458static HGCMMsgCore *hgcmMessageAllocSvc (uint32_t u32MsgId)
    438459{
    439460    switch (u32MsgId)
    440461    {
     462#ifdef VBOX_WITH_CRHGSMI
     463        case SVC_MSG_HOSTFASTCALLASYNC: return new HGCMMsgHostFastCallAsyncSvc ();
     464#endif
    441465        case SVC_MSG_LOAD:        return new HGCMMsgSvcLoad ();
    442466        case SVC_MSG_UNLOAD:      return new HGCMMsgSvcUnload ();
     
    483507        switch (u32MsgId)
    484508        {
     509#ifdef VBOX_WITH_CRHGSMI
     510            case SVC_MSG_HOSTFASTCALLASYNC:
     511            {
     512                HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pMsgCore;
     513
     514                LogFlowFunc(("SVC_MSG_HOSTFASTCALLASYNC u32Function = %d, pParm = %p\n", pMsg->u32Function, &pMsg->Param));
     515
     516                rc = pSvc->m_fntable.pfnHostCall (pSvc->m_fntable.pvService, pMsg->u32Function, 1, &pMsg->Param);
     517            } break;
     518#endif
    485519            case SVC_MSG_LOAD:
    486520            {
     
    15171551}
    15181552
     1553#ifdef VBOX_WITH_CRHGSMI
     1554static DECLCALLBACK(void) hgcmMsgFastCallCompletionCallback (int32_t result, HGCMMsgCore *pMsgCore)
     1555{
     1556    /* Call the VMMDev port interface to issue IRQ notification. */
     1557    LogFlow(("MAIN::hgcmMsgFastCallCompletionCallback: message %p\n", pMsgCore));
     1558
     1559    HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pMsgCore;
     1560    if (pMsg->pfnCompletion)
     1561    {
     1562        pMsg->pfnCompletion (result, pMsg->u32Function, &pMsg->Param, pMsg->pvCompletion);
     1563    }
     1564}
     1565
     1566int HGCMService::HostFastCallAsync (uint32_t u32Function, VBOXHGCMSVCPARM *pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
     1567{
     1568    LogFlowFunc(("%s u32Function = %d, pParm = %p\n",
     1569                 m_pszSvcName, u32Function, pParm));
     1570
     1571    HGCMMSGHANDLE hMsg = 0;
     1572    int rc = hgcmMsgAlloc (m_thread, &hMsg, SVC_MSG_HOSTFASTCALLASYNC, hgcmMessageAllocSvc);
     1573
     1574    if (RT_SUCCESS(rc))
     1575    {
     1576        HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)hgcmObjReference (hMsg, HGCMOBJ_MSG);
     1577        AssertRelease(pMsg);
     1578
     1579        pMsg->u32Function      = u32Function;
     1580        pMsg->Param = *pParm;
     1581        pMsg->pfnCompletion = pfnCompletion;
     1582        pMsg->pvCompletion = pvCompletion;
     1583
     1584        hgcmObjDereference (pMsg);
     1585
     1586        rc = hgcmMsgPost(hMsg, hgcmMsgFastCallCompletionCallback);
     1587    }
     1588
     1589    LogFlowFunc(("rc = %Rrc\n", rc));
     1590    return rc;
     1591}
     1592#endif
    15191593
    15201594/*
     
    15331607#define HGCM_MSG_REGEXT     (18)  /* Register a service extension. */
    15341608#define HGCM_MSG_UNREGEXT   (19)  /* Unregister a service extension. */
     1609#ifdef VBOX_WITH_CRHGSMI
     1610# define HGCM_MSG_SVCAQUIRE  (30)  /* Acquire a service handle (for fast host calls) */
     1611# define HGCM_MSG_SVCRELEASE (31)  /* Release a service */
     1612#endif
    15351613
    15361614class HGCMMsgMainConnect: public HGCMMsgHeader
     
    16071685};
    16081686
     1687#ifdef VBOX_WITH_CRHGSMI
     1688class HGCMMsgMainSvcAcquire: public HGCMMsgCore
     1689{
     1690    public:
     1691        /* Which service to call. */
     1692        const char *pszServiceName;
     1693        /* Returned service. */
     1694        HGCMService *pService;
     1695};
     1696
     1697class HGCMMsgMainSvcRelease: public HGCMMsgCore
     1698{
     1699    public:
     1700        /* Svc . */
     1701        HGCMService *pService;
     1702};
     1703#endif
     1704
     1705
    16091706static HGCMMsgCore *hgcmMainMessageAlloc (uint32_t u32MsgId)
    16101707{
     
    16211718        case HGCM_MSG_REGEXT:     return new HGCMMsgMainRegisterExtension ();
    16221719        case HGCM_MSG_UNREGEXT:   return new HGCMMsgMainUnregisterExtension ();
     1720#ifdef VBOX_WITH_CRHGSMI
     1721        case HGCM_MSG_SVCAQUIRE: return new HGCMMsgMainSvcAcquire();
     1722        case HGCM_MSG_SVCRELEASE: return new HGCMMsgMainSvcRelease();
     1723#endif
     1724
    16231725        default:
    16241726            AssertReleaseMsgFailed(("Msg id = %08X\n", u32MsgId));
     
    17291831                }
    17301832            } break;
     1833
     1834#ifdef VBOX_WITH_CRHGSMI
     1835            case HGCM_MSG_SVCAQUIRE:
     1836            {
     1837                HGCMMsgMainSvcAcquire *pMsg = (HGCMMsgMainSvcAcquire *)pMsgCore;
     1838
     1839                LogFlowFunc(("HGCM_MSG_SVCAQUIRE pszServiceName %s\n", pMsg->pszServiceName));
     1840
     1841                /* Resolve the service name to the pointer to service instance. */
     1842                HGCMService *pService;
     1843                rc = HGCMService::ResolveService (&pService, pMsg->pszServiceName);
     1844                if (RT_SUCCESS(rc))
     1845                {
     1846                    pMsg->pService = pService;
     1847                }
     1848            } break;
     1849
     1850            case HGCM_MSG_SVCRELEASE:
     1851            {
     1852                HGCMMsgMainSvcRelease *pMsg = (HGCMMsgMainSvcRelease *)pMsgCore;
     1853
     1854                LogFlowFunc(("HGCM_MSG_SVCARELEASE pService %p\n", pMsg->pService));
     1855
     1856                /* Resolve the service name to the pointer to service instance. */
     1857
     1858                pMsg->pService->ReleaseService ();
     1859
     1860                rc = VINF_SUCCESS;
     1861            } break;
     1862#endif
    17311863
    17321864            case HGCM_MSG_RESET:
     
    22012333}
    22022334
     2335#ifdef VBOX_WITH_CRHGSMI
     2336int HGCMHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc)
     2337{
     2338    LogFlowFunc(("name = %s\n", pszServiceName));
     2339
     2340    if (!pszServiceName)
     2341    {
     2342        return VERR_INVALID_PARAMETER;
     2343    }
     2344
     2345    if (!phSvc)
     2346    {
     2347        return VERR_INVALID_PARAMETER;
     2348    }
     2349
     2350    HGCMMSGHANDLE hMsg = 0;
     2351
     2352    /* Host calls go to main HGCM thread that resolves the service name to the
     2353     * service instance pointer and then, using the service pointer, forwards
     2354     * the message to the service thread.
     2355     * So it is slow but host calls are intended mostly for configuration and
     2356     * other non-time-critical functions.
     2357     */
     2358    int rc = hgcmMsgAlloc (g_hgcmThread, &hMsg, HGCM_MSG_SVCAQUIRE, hgcmMainMessageAlloc);
     2359
     2360    if (RT_SUCCESS(rc))
     2361    {
     2362        HGCMMsgMainSvcAcquire *pMsg = (HGCMMsgMainSvcAcquire *)hgcmObjReference (hMsg, HGCMOBJ_MSG);
     2363        AssertRelease(pMsg);
     2364
     2365        pMsg->pszServiceName = (char *)pszServiceName;
     2366        pMsg->pService = NULL;
     2367
     2368        rc = hgcmMsgSend (hMsg);
     2369        if (RT_SUCCESS(rc))
     2370        {
     2371            /* for simplicity just use a svc ptr as handle for now */
     2372            *phSvc = (HGCMCVSHANDLE)pMsg->pService;
     2373        }
     2374
     2375        hgcmObjDereference (pMsg);
     2376    }
     2377
     2378    LogFlowFunc(("rc = %Rrc\n", rc));
     2379    return rc;
     2380}
     2381
     2382int HGCMHostSvcHandleDestroy (HGCMCVSHANDLE hSvc)
     2383{
     2384    LogFlowFunc(("hSvc = %p\n", hSvc));
     2385
     2386    if (!hSvc)
     2387    {
     2388        return VERR_INVALID_PARAMETER;
     2389    }
     2390
     2391    HGCMMSGHANDLE hMsg = 0;
     2392
     2393    /* Host calls go to main HGCM thread that resolves the service name to the
     2394     * service instance pointer and then, using the service pointer, forwards
     2395     * the message to the service thread.
     2396     * So it is slow but host calls are intended mostly for configuration and
     2397     * other non-time-critical functions.
     2398     */
     2399    int rc = hgcmMsgAlloc (g_hgcmThread, &hMsg, HGCM_MSG_SVCRELEASE, hgcmMainMessageAlloc);
     2400
     2401    if (RT_SUCCESS(rc))
     2402    {
     2403        HGCMMsgMainSvcRelease *pMsg = (HGCMMsgMainSvcRelease *)hgcmObjReference (hMsg, HGCMOBJ_MSG);
     2404        AssertRelease(pMsg);
     2405
     2406        pMsg->pService = (HGCMService *)hSvc;
     2407
     2408        hgcmObjDereference (pMsg);
     2409
     2410        rc = hgcmMsgSend (hMsg);
     2411    }
     2412
     2413    LogFlowFunc(("rc = %Rrc\n", rc));
     2414    return rc;
     2415}
     2416
     2417int HGCMHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, VBOXHGCMSVCPARM *pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
     2418{
     2419    LogFlowFunc(("hSvc = %p, u32Function = %d, pParm = %p\n",
     2420            hSvc, function, pParm));
     2421
     2422    if (!hSvc)
     2423    {
     2424        return VERR_INVALID_PARAMETER;
     2425    }
     2426
     2427    HGCMService *pService = (HGCMService *)hSvc;
     2428    int rc = pService->HostFastCallAsync (function, pParm, pfnCompletion, pvCompletion);
     2429
     2430    LogFlowFunc(("rc = %Rrc\n", rc));
     2431    return rc;
     2432}
     2433#endif
     2434
    22032435int HGCMHostReset (void)
    22042436{
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r31958 r33146  
    127127    void handleVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
    128128#endif
     129#ifdef VBOX_WITH_CRHGSMI
     130    void handleCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd);
     131    void handleCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl);
     132
     133    void handleCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
     134    void handleCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
     135#endif
    129136    IFramebuffer *getFramebuffer()
    130137    {
     
    169176    void updateDisplayData(void);
    170177
     178#ifdef VBOX_WITH_CRHGSMI
     179    void setupCrHgsmiData(void);
     180    void destructCrHgsmiData(void);
     181#endif
     182
    171183    static DECLCALLBACK(int)   changeFramebuffer(Display *that, IFramebuffer *aFB, unsigned uScreenId);
    172184
     
    187199#endif
    188200
     201#ifdef VBOX_WITH_CRHGSMI
     202    static DECLCALLBACK(void)  displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd);
     203    static DECLCALLBACK(void)  displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl);
     204
     205    static DECLCALLBACK(void) displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
     206    static DECLCALLBACK(void) displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
     207#endif
     208
    189209#ifdef VBOX_WITH_HGSMI
    190210    static DECLCALLBACK(int)   displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags);
     
    237257    uint32_t   mcbVbvaPartial;
    238258
     259#ifdef VBOX_WITH_CRHGSMI
     260    /* for fast host hgcm calls */
     261    HGCMCVSHANDLE mhCrOglSvc;
     262#endif
     263
    239264    bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
    240265    void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
  • trunk/src/VBox/Main/include/VMMDev.h

    r29250 r33146  
    5151    int hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName);
    5252    int hgcmHostCall (const char *pszServiceName, uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms);
     53#ifdef VBOX_WITH_CRHGSMI
     54    int hgcmHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc);
     55    int hgcmHostSvcHandleDestroy (HGCMCVSHANDLE hSvc);
     56    int hgcmHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion);
     57#endif
    5358    void hgcmShutdown (void);
    5459
  • trunk/src/VBox/Main/include/hgcm/HGCM.h

    r28800 r33146  
    4949int HGCMHostCall (const char *pszServiceName, uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM aParms[]);
    5050
     51#ifdef VBOX_WITH_CRHGSMI
     52int HGCMHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc);
     53int HGCMHostSvcHandleDestroy (HGCMCVSHANDLE hSvc);
     54int HGCMHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion);
     55#endif
     56
    5157int HGCMHostSaveState (PSSMHANDLE pSSM);
    5258int HGCMHostLoadState (PSSMHANDLE pSSM);
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