HGSMIBase.cpp revision 74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * VirtualBox Video driver, common code - HGSMI initialisation and helper
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * functions.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Copyright (C) 2006-2010 Oracle Corporation
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * available from http://www.virtualbox.org. This file is free software;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * you can redistribute it and/or modify it under the terms of the GNU
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * General Public License (GPL) as published by the Free Software
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Send completion notification to the host for the command located at offset
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @a offt into the host command buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic void HGSMINotifyHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx, HGSMIOFFSET offt)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Inform the host that a command has been handled.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap to be used
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvMem pointer into the heap as mapped in @a pCtx to the command to
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * be completed
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync HGSMIBUFFERHEADER *pHdr = HGSMIBufferHeaderFromData(pvMem);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync HGSMIOFFSET offMem = HGSMIPointerToOffset(&pCtx->areaCtx, pHdr);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Submit an incoming host command to the appropriate handler. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic void hgsmiHostCmdProcess(PHGSMIHOSTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync int rc = HGSMIBufferProcess(&pCtx->areaCtx, &pCtx->channels, offBuffer);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* failure means the command was not submitted to the handler for some reason
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * it's our responsibility to notify its completion in this case */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* if the cmd succeeded it's responsibility of the callback to complete it */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Get the next command from the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic HGSMIOFFSET hgsmiGetHostBuffer(PHGSMIHOSTCOMMANDCONTEXT pCtx)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Get and handle the next command from the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic void hgsmiHostCommandQueryProcess(PHGSMIHOSTCOMMANDCONTEXT pCtx)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Drain the host command queue. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync while (pCtx->pfHostFlags->u32HostFlags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync if (!ASMAtomicCmpXchgBool(&pCtx->fHostCmdProcessing, true, false))
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync ASMAtomicWriteBool(&pCtx->fHostCmdProcessing, false);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Detect whether HGSMI is supported by the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Allocate and initialise a command descriptor in the guest heap for a
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * guest-to-host command.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @returns pointer to the descriptor's command data buffer
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap to be used
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbData the size of the command data to go into the descriptor
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param u8Ch the HGSMI channel to be used, set to the descriptor
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param u16Op the HGSMI command to be sent, set to the descriptor
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* @todo: add synchronization */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync return HGSMIHeapAlloc (&pCtx->heapCtx, cbData, u8Ch, u16Op);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Free a descriptor allocated by @a VBoxHGSMIBufferAlloc.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap used
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvBuffer the pointer returned by @a VBoxHGSMIBufferAlloc
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* @todo: add synchronization */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Submit a command descriptor allocated by @a VBoxHGSMIBufferAlloc.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap used
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvBuffer the pointer returned by @a VBoxHGSMIBufferAlloc
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Initialize the buffer and get the offset for port IO. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&pCtx->heapCtx, pvBuffer);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Submit the buffer to the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Query the host for an HGSMI configuration parameter via an HGSMI command.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic int vboxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx, uint32_t u32Index,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Allocate the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Prepare data to be sent to the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Free the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Inform the host of the location of the host flags in VRAM via an HGSMI
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * command. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic int vboxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Allocate the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync p = (HGSMIBUFFERLOCATION *)HGSMIHeapAlloc(&pCtx->heapCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Prepare data to be sent to the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Free the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Notify the host of HGSMI-related guest capabilities via an HGSMI command.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic int vboxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Allocate the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Prepare data to be sent to the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Free the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** Tell the host about the location of the area of VRAM set aside for the host
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncstatic int vboxHGSMIReportHostArea(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Allocate the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Prepare data to be sent to the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Free the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Tell the host about how VRAM is divided up between each screen via an HGSMI
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * command. It is acceptable to specifiy identical data for each screen if
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * they share a single framebuffer.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @todo confirm that that really is acceptable
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @returns iprt status code, either VERR_NO_MEMORY or the status returned by
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @a pfnFill
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap to use
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param u32Count the number of screens we are activating
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pfnFill a callback which initialises the VBVAINFOVIEW structures
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * for all screens
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvData context data for @a pfnFill
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Issue the screen info command. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync void *p = VBoxHGSMIBufferAlloc(pCtx, sizeof(VBVAINFOVIEW) * u32Count,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Get the information needed to map the basic communication structures in
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * device memory into our address space.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbVRAM how much video RAM is allocated to the device
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param poffVRAMBaseMapping where to save the offset from the start of the
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * device VRAM of the whole area to map
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pcbMapping where to save the mapping size
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param poffGuestHeapMemory where to save the offset into the mapped area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * of the guest heap backing memory
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pcbGuestHeapMemory where to save the size of the guest heap
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * backing memory
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param poffHostFlags where to save the offset into the mapped area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * of the host flags
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync *poffVRAMBaseMapping = cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync *pcbGuestHeapMemory = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync *poffHostFlags = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Set up the HGSMI guest-to-host command context.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @returns iprt status value
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context to set up
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvGuestHeapMemory a pointer to the mapped backing memory for
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * the guest heap
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbGuestHeapMemory the size of the backing memory area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param offVRAMGuestHeapMemory the offset of the memory pointed to by
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @a pvGuestHeapMemory within the video RAM
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /** @todo should we be using a fixed ISA port value here? */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync return HGSMIHeapSetup(&pCtx->heapCtx, pvGuestHeapMemory,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync false /*fOffsetBased*/);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Get the information needed to map the area used by the host to send back
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * requests.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap to use
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbVRAM how much video RAM is allocated to the device
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param offVRAMBaseMapping the offset of the basic communication structures
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * into the guest's VRAM
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param poffVRAMHostArea where to store the offset into VRAM of the host
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * heap area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pcbHostArea where to store the size of the host heap area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync uint32_t offVRAMHostArea = offVRAMBaseMapping, cbHostArea = 0;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync vboxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbHostArea);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /** @todo what is the idea of this? */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync if (cbHostAreaMaxSize >= VBVA_ADAPTER_INFORMATION_SIZE)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync cbHostAreaMaxSize -= VBVA_ADAPTER_INFORMATION_SIZE;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Round up to 4096 bytes. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync LogFunc(("offVRAMHostArea = 0x%08X, cbHostArea = 0x%08X\n",
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Initialise the host context structure.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context structure to initialise
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvBaseMapping where the basic HGSMI structures are mapped at
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param offHostFlags the offset of the host flags into the basic HGSMI
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * structures
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pvHostAreaMapping where the area for the host heap is mapped at
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param offVRAMHostArea offset of the host heap area into VRAM
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbHostArea size in bytes of the host heap area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync uint8_t *pu8HostFlags = ((uint8_t *)pvBaseMapping) + offHostFlags;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync pCtx->pfHostFlags = (HGSMIHOSTFLAGS *)pu8HostFlags;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /** @todo should we really be using a fixed ISA port value here? */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync HGSMIAreaInitialize(&pCtx->areaCtx, pvHostAreaMapping, cbHostArea,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Tell the host about the ways it can use to communicate back to us via an
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * HGSMI command
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @returns iprt status value
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap to use
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param offVRAMFlagsLocation where we wish the host to place its flags
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * relative to the start of the VRAM
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param fCaps additions HGSMI capabilities the guest
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param offVRAMHostArea offset into VRAM of the host heap area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbHostArea size in bytes of the host heap area
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* setup the flags first to ensure they are initialized by the time the
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * host heap is ready */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync int rc = vboxHGSMIReportFlagsLocation(pCtx, offVRAMFlagsLocation);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Inform about caps */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Report the host heap location. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync rc = vboxHGSMIReportHostArea(pCtx, offVRAMHostArea, cbHostArea);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync Log(("VBoxVideo::vboxSetupAdapterInfo finished rc = %d\n", rc));
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Gets the count of virtual monitors attached to the guest via an HGSMI
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @returns the right count on success or 1 on failure.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pCtx the context containing the heap to use
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Query the configured number of displays. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync vboxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_MONITOR_COUNT, &cDisplays);
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync if (cDisplays == 0 || cDisplays > VBOX_VIDEO_MAX_SCREENS)
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Host reported some bad value. Continue in the 1 screen mode. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Pass the host a new mouse pointer shape via an HGSMI command.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @returns success or failure
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @todo why not return an iprt status code?
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param fFlags cursor flags, @see VMMDevReqMousePointer::fFlags
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cHotX horizontal position of the hot spot
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cHotY vertical position of the hot spot
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cWidth width in pixels of the cursor
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cHeight height in pixels of the cursor
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param pPixels pixel data, @see VMMDevReqMousePointer for the format
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * @param cbLength size in bytes of the pixel data
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsyncRTDECL(bool) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* If shape is supplied, then always create the pointer visible.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * See comments in 'vboxUpdatePointerShape'
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync LogFunc(("cbData %d, %dx%d\n", cbData, cWidth, cHeight));
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync LogFunc(("calculated pointer data size is too big (%d bytes, limit %d)\n",
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync return false;
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Allocate the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync p = (VBVAMOUSEPOINTERSHAPE *)HGSMIHeapAlloc(&pCtx->heapCtx,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Prepare data to be sent to the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Will be updated by the host. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* We have our custom flags in the field */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Copy the actual pointer data. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync /* Free the IO buffer. */
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync/** @todo Mouse pointer position to be read from VMMDev memory, address of the memory region
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * can be queried from VMMDev via an IOCTL. This VMMDev memory region will contain
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * host information which is needed by the guest.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Reading will not cause a switch to the host.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * Have to take into account:
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * * synchronization: host must write to the memory only from EMT,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * large structures must be read under flag, which tells the host
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * that the guest is currently reading the memory (OWNER flag?).
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * * guest writes: may be allocate a page for the host info and make
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * the page readonly for the guest.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * * the information should be available only for additions drivers.
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * * VMMDev additions driver will inform the host which version of the info it expects,
74fdb8a41a8fdc04e44a1ecaeefb70ed9a7a1e47vboxsync * host must support all versions.