int HGSMIHeapSetup (HGSMIHEAP *pHeap, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, bool fOffsetBased) { if ( !pHeap || !pvBase) { return VERR_INVALID_PARAMETER; } int rc = HGSMIAreaInitialize (&pHeap->area, pvBase, cbArea, offBase); if (RT_SUCCESS (rc)) { if (!fOffsetBased) rc = RTHeapSimpleInit (&pHeap->u.hPtr, pvBase, cbArea); else rc = RTHeapOffsetInit (&pHeap->u.hOff, pvBase, cbArea); if (RT_SUCCESS (rc)) { pHeap->cRefs = 0; pHeap->fOffsetBased = fOffsetBased; } else { HGSMIAreaClear (&pHeap->area); } } return rc; }
/** * Initialise the host context structure. * * @param pCtx the context structure to initialise * @param pvBaseMapping where the basic HGSMI structures are mapped at * @param offHostFlags the offset of the host flags into the basic HGSMI * structures * @param pvHostAreaMapping where the area for the host heap is mapped at * @param offVRAMHostArea offset of the host heap area into VRAM * @param cbHostArea size in bytes of the host heap area */ RTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx, void *pvBaseMapping, uint32_t offHostFlags, void *pvHostAreaMapping, uint32_t offVRAMHostArea, uint32_t cbHostArea) { uint8_t *pu8HostFlags = ((uint8_t *)pvBaseMapping) + offHostFlags; pCtx->pfHostFlags = (HGSMIHOSTFLAGS *)pu8HostFlags; /** @todo should we really be using a fixed ISA port value here? */ pCtx->port = (RTIOPORT)VGA_PORT_HGSMI_HOST; HGSMIAreaInitialize(&pCtx->areaCtx, pvHostAreaMapping, cbHostArea, offVRAMHostArea); }
int HGSMIHeapSetup(HGSMIHEAP *pHeap, void *pvBase, HGSMISIZE cbArea, HGSMIOFFSET offBase, const HGSMIENV *pEnv) { AssertPtrReturn(pHeap, VERR_INVALID_PARAMETER); AssertPtrReturn(pvBase, VERR_INVALID_PARAMETER); int rc = HGSMIAreaInitialize(&pHeap->area, pvBase, cbArea, offBase); if (RT_SUCCESS(rc)) { rc = HGSMIMAInit(&pHeap->ma, &pHeap->area, NULL, 0, 0, pEnv); if (RT_FAILURE(rc)) { HGSMIAreaClear(&pHeap->area); } } return rc; }
int HGSMIHeapRelocate (HGSMIHEAP *pHeap, void *pvBase, uint32_t offHeapHandle, uintptr_t offDelta, HGSMISIZE cbArea, HGSMIOFFSET offBase, bool fOffsetBased ) { if ( !pHeap || !pvBase) { return VERR_INVALID_PARAMETER; } int rc = HGSMIAreaInitialize (&pHeap->area, pvBase, cbArea, offBase); if (RT_SUCCESS (rc)) { if (fOffsetBased) pHeap->u.hOff = (RTHEAPOFFSET)((uint8_t *)pvBase + offHeapHandle); else { pHeap->u.hPtr = (RTHEAPSIMPLE)((uint8_t *)pvBase + offHeapHandle); rc = RTHeapSimpleRelocate (pHeap->u.hPtr, offDelta); AssertRC(rc); } if (RT_SUCCESS (rc)) { pHeap->cRefs = 0; pHeap->fOffsetBased = fOffsetBased; } else { HGSMIAreaClear (&pHeap->area); } } return rc; }
/* Called for IOCTL_VIDEO_MAP_VIDEO_MEMORY. * Maps FrameBuffer and video RAM to a caller's virtual adress space. */ BOOLEAN VBoxMPMapVideoMemory(PVBOXMP_DEVEXT pExt, PVIDEO_MEMORY pRequestedAddress, PVIDEO_MEMORY_INFORMATION pMapInfo, PSTATUS_BLOCK pStatus) { PHYSICAL_ADDRESS framebuffer; ULONG inIoSpace = 0; LOGF(("framebuffer offset %#x", pExt->ulFrameBufferOffset)); framebuffer.QuadPart = VBoxCommonFromDeviceExt(pExt)->phVRAM.QuadPart + pExt->ulFrameBufferOffset; pMapInfo->VideoRamBase = pRequestedAddress->RequestedVirtualAddress; VBOXMPIOCTL_HIDE(pRequestedAddress); pMapInfo->VideoRamLength = pExt->pPrimary->u.primary.ulMaxFrameBufferSize; pStatus->Status = VideoPortMapMemory(pExt, framebuffer, &pMapInfo->VideoRamLength, &inIoSpace, &pMapInfo->VideoRamBase); if (NO_ERROR == pStatus->Status) { pMapInfo->FrameBufferBase = (PUCHAR)pMapInfo->VideoRamBase; pMapInfo->FrameBufferLength = VBoxMPXpdmCurrentVideoMode(pExt)->VisScreenHeight* VBoxMPXpdmCurrentVideoMode(pExt)->ScreenStride; pStatus->Information = sizeof(VIDEO_MEMORY_INFORMATION); /* Save the new framebuffer size */ pExt->ulFrameBufferSize = pMapInfo->FrameBufferLength; HGSMIAreaInitialize(&pExt->areaDisplay, pMapInfo->FrameBufferBase, pMapInfo->FrameBufferLength, pExt->ulFrameBufferOffset); } VBOXMPIOCTL_UNHIDE(); LOGF_LEAVE(); return NO_ERROR == pStatus->Status; }