HGSMIBase.cpp revision dc959f60f6d3e0cba86f7da4d39aa475913a7e10
/* $Id$ */
/** @file
* VirtualBox Video driver, common code - HGSMI initialisation and helper
* functions.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <VBox/VBoxVideoGuest.h>
#include <VBox/VBoxVideo.h>
#include <VBox/VBoxGuest.h>
/** Send completion notification to the host for the command located at offset
* @a offt into the host command buffer. */
{
}
/**
* Inform the host that a command has been handled.
*
* @param pCtx the context containing the heap to be used
* @param pvMem pointer into the heap as mapped in @a pCtx to the command to
* be completed
*/
void *pvMem)
{
if(offMem != HGSMIOFFSET_VOID)
{
}
}
/** Submit an incoming host command to the appropriate handler. */
{
if(RT_FAILURE(rc))
{
/* failure means the command was not submitted to the handler for some reason
* it's our responsibility to notify its completion in this case */
}
/* if the cmd succeeded it's responsibility of the callback to complete it */
}
/** Get the next command from the host. */
{
}
/** Get and handle the next command from the host. */
{
}
/** Drain the host command queue. */
{
{
return;
}
}
/** Detect whether HGSMI is supported by the host. */
RTDECL(bool) VBoxHGSMIIsSupported(void)
{
return (DispiId == VBE_DISPI_ID_HGSMI);
}
/**
* Allocate and initialise a command descriptor in the guest heap for a
* guest-to-host command.
*
* @returns pointer to the descriptor's command data buffer
* @param pCtx the context containing the heap to be used
* @param cbData the size of the command data to go into the descriptor
* @param u8Ch the HGSMI channel to be used, set to the descriptor
* @param u16Op the HGSMI command to be sent, set to the descriptor
*/
{
#ifdef VBOX_WDDM_MINIPORT
#else
#endif
}
/**
* Free a descriptor allocated by @a VBoxHGSMIBufferAlloc.
*
* @param pCtx the context containing the heap used
* @param pvBuffer the pointer returned by @a VBoxHGSMIBufferAlloc
*/
void *pvBuffer)
{
#ifdef VBOX_WDDM_MINIPORT
#else
#endif
}
/**
* Submit a command descriptor allocated by @a VBoxHGSMIBufferAlloc.
*
* @param pCtx the context containing the heap used
* @param pvBuffer the pointer returned by @a VBoxHGSMIBufferAlloc
*/
void *pvBuffer)
{
/* Initialize the buffer and get the offset for port IO. */
if (offBuffer != HGSMIOFFSET_VOID)
{
/* Submit the buffer to the host. */
return VINF_SUCCESS;
}
return VERR_INVALID_PARAMETER;
}
/** Inform the host of the location of the host flags in VRAM via an HGSMI
* command. */
{
int rc = VINF_SUCCESS;
/* Allocate the IO buffer. */
sizeof(HGSMIBUFFERLOCATION),
if (p)
{
/* Prepare data to be sent to the host. */
p->offLocation = offLocation;
p->cbLocation = sizeof(HGSMIHOSTFLAGS);
/* Free the IO buffer. */
VBoxHGSMIBufferFree(pCtx, p);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/** Notify the host of HGSMI-related guest capabilities via an HGSMI command.
*/
{
int rc = VINF_SUCCESS;
/* Allocate the IO buffer. */
sizeof(VBVACAPS), HGSMI_CH_VBVA,
if (pCaps)
{
/* Prepare data to be sent to the host. */
if (RT_SUCCESS(rc))
{
}
/* Free the IO buffer. */
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/** Tell the host about the location of the area of VRAM set aside for the host
* heap. */
{
VBVAINFOHEAP *p;
int rc = VINF_SUCCESS;
/* Allocate the IO buffer. */
sizeof (VBVAINFOHEAP), HGSMI_CH_VBVA,
if (p)
{
/* Prepare data to be sent to the host. */
p->u32HeapOffset = u32AreaOffset;
p->u32HeapSize = u32AreaSize;
/* Free the IO buffer. */
VBoxHGSMIBufferFree(pCtx, p);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/**
* Get the information needed to map the basic communication structures in
* device memory into our address space. All pointer parameters are optional.
*
* @param cbVRAM how much video RAM is allocated to the device
* @param poffVRAMBaseMapping where to save the offset from the start of the
* device VRAM of the whole area to map
* @param pcbMapping where to save the mapping size
* @param poffGuestHeapMemory where to save the offset into the mapped area
* of the guest heap backing memory
* @param pcbGuestHeapMemory where to save the size of the guest heap
* backing memory
* @param poffHostFlags where to save the offset into the mapped area
* of the host flags
*/
{
if (poffVRAMBaseMapping)
if (pcbMapping)
if (poffGuestHeapMemory)
*poffGuestHeapMemory = 0;
if (pcbGuestHeapMemory)
- sizeof(HGSMIHOSTFLAGS);
if (poffHostFlags)
- sizeof(HGSMIHOSTFLAGS);
}
/**
* Set up the HGSMI guest-to-host command context.
* @returns iprt status value
* @param pCtx the context to set up
* @param pvGuestHeapMemory a pointer to the mapped backing memory for
* the guest heap
* @param cbGuestHeapMemory the size of the backing memory area
* @param offVRAMGuestHeapMemory the offset of the memory pointed to by
* @a pvGuestHeapMemory within the video RAM
*/
void *pvGuestHeapMemory,
{
/** @todo should we be using a fixed ISA port value here? */
#ifdef VBOX_WDDM_MINIPORT
false /*fOffsetBased*/);
#else
false /*fOffsetBased*/);
#endif
}
/**
* Get the information needed to map the area used by the host to send back
* requests.
*
* @param pCtx the context containing the heap to use
* @param cbVRAM how much video RAM is allocated to the device
* @param offVRAMBaseMapping the offset of the basic communication structures
* into the guest's VRAM
* @param poffVRAMHostArea where to store the offset into VRAM of the host
* heap area
* @param pcbHostArea where to store the size of the host heap area
*/
{
if (cbHostArea != 0)
{
/** @todo what is the idea of this? */
{
}
if (cbHostArea > cbHostAreaMaxSize)
{
}
/* Round up to 4096 bytes. */
}
LogFunc(("offVRAMHostArea = 0x%08X, cbHostArea = 0x%08X\n",
}
/**
* 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
*/
void *pvBaseMapping,
void *pvHostAreaMapping,
{
/** @todo should we really be using a fixed ISA port value here? */
}
/**
* Tell the host about the ways it can use to communicate back to us via an
* HGSMI command
*
* @returns iprt status value
* @param pCtx the context containing the heap to use
* @param offVRAMFlagsLocation where we wish the host to place its flags
* relative to the start of the VRAM
* @param fCaps additions HGSMI capabilities the guest
* supports
* @param offVRAMHostArea offset into VRAM of the host heap area
* @param cbHostArea size in bytes of the host heap area
*/
{
Log(("VBoxVideo::vboxSetupAdapterInfo\n"));
/* setup the flags first to ensure they are initialized by the time the
* host heap is ready */
{
/* Inform about caps */
}
if (RT_SUCCESS (rc))
{
/* Report the host heap location. */
}
return rc;
}
/**
* Query the host for an HGSMI configuration parameter via an HGSMI command.
* @returns iprt status value
* @param pCtx the context containing the heap used
* @param u32Index the index of the parameter to query,
* @see VBVACONF32::u32Index
* @param pulValue where to store the value of the parameter on success
*/
{
int rc = VINF_SUCCESS;
VBVACONF32 *p;
/* Allocate the IO buffer. */
sizeof(VBVACONF32), HGSMI_CH_VBVA,
if (p)
{
/* Prepare data to be sent to the host. */
p->u32Value = 0;
if (RT_SUCCESS(rc))
{
}
/* Free the IO buffer. */
VBoxHGSMIBufferFree(pCtx, p);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/**
* Pass the host a new mouse pointer shape via an HGSMI command.
*
* @returns success or failure
* @todo why not return an iprt status code?
* @param fFlags cursor flags, @see VMMDevReqMousePointer::fFlags
* @param cHotX horizontal position of the hot spot
* @param cHotY vertical position of the hot spot
* @param cWidth width in pixels of the cursor
* @param cHeight height in pixels of the cursor
* @param pPixels pixel data, @see VMMDevReqMousePointer for the format
* @param cbLength size in bytes of the pixel data
*/
{
int rc = VINF_SUCCESS;
if (fFlags & VBOX_MOUSE_POINTER_SHAPE)
{
/* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) */
/* If shape is supplied, then always create the pointer visible.
* See comments in 'vboxUpdatePointerShape'
*/
}
{
LogFunc(("calculated pointer data size is too big (%d bytes, limit %d)\n",
return false;
}
/* Allocate the IO buffer. */
sizeof(VBVAMOUSEPOINTERSHAPE)
+ cbData,
if (p)
{
/* Prepare data to be sent to the host. */
/* Will be updated by the host. */
p->i32Result = VINF_SUCCESS;
/* We have our custom flags in the field */
if (p->fu32Flags & VBOX_MOUSE_POINTER_SHAPE)
/* Copy the actual pointer data. */
if (RT_SUCCESS(rc))
/* Free the IO buffer. */
VBoxHGSMIBufferFree(pCtx, p);
}
else
rc = VERR_NO_MEMORY;
return RT_SUCCESS(rc);
}
/** @todo Mouse pointer position to be read from VMMDev memory, address of the memory region
* can be queried from VMMDev via an IOCTL. This VMMDev memory region will contain
* host information which is needed by the guest.
*
* Reading will not cause a switch to the host.
*
* Have to take into account:
* * synchronization: host must write to the memory only from EMT,
* large structures must be read under flag, which tells the host
* that the guest is currently reading the memory (OWNER flag?).
* * guest writes: may be allocate a page for the host info and make
* the page readonly for the guest.
* * the information should be available only for additions drivers.
* * VMMDev additions driver will inform the host which version of the info it expects,
* host must support all versions.
*
*/