您的位置:首页 > 其它

Virtualbox WDDM之DxgkDdiStartDevice

2015-10-26 10:57 316 查看
1. 参数校验,

2. DxgkCbGetDeviceInformation
https://msdn.microsoft.com/en-us/library/windows/hardware/ff559511(v=vs.85).aspx
The DxgkCbGetDeviceInformation function
gets information, including the registry path and a list of translated resources, about a specified display adapter.

3. DxgkCbGetDeviceInformation失败,返回DxgkCbGetDeviceInformation
error

NTSTATUS DxgkDdiStartDevice(
IN CONST PVOID  MiniportDeviceContext,
IN PDXGK_START_INFO  DxgkStartInfo,
IN PDXGKRNL_INTERFACE  DxgkInterface,
OUT PULONG  NumberOfVideoPresentSources,
OUT PULONG  NumberOfChildren
)
{
/* The DxgkDdiStartDevice function should be made pageable. */
PAGED_CODE();

NTSTATUS Status;

dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", MiniportDeviceContext));

if ( ARGUMENT_PRESENT(MiniportDeviceContext) &&
ARGUMENT_PRESENT(DxgkInterface) &&
ARGUMENT_PRESENT(DxgkStartInfo) &&
ARGUMENT_PRESENT(NumberOfVideoPresentSources),
ARGUMENT_PRESENT(NumberOfChildren)
)
{
PDEVICE_EXTENSION pContext = (PDEVICE_EXTENSION)MiniportDeviceContext;

/* Save DeviceHandle and function pointers supplied by the DXGKRNL_INTERFACE structure passed to DxgkInterface. */
memcpy(&pContext->u.primary.DxgkInterface, DxgkInterface, sizeof(DXGKRNL_INTERFACE));

/* Allocate a DXGK_DEVICE_INFO structure, and call DxgkCbGetDeviceInformation to fill in the members of that structure, which include the registry path, the PDO, and a list of translated resources for the display adapter represented by MiniportDeviceContext. Save selected members (ones that the display miniport driver will need later)
* of the DXGK_DEVICE_INFO structure in the context block represented by MiniportDeviceContext. */
DXGK_DEVICE_INFO DeviceInfo;
Status = pContext->u.primary.DxgkInterface.DxgkCbGetDeviceInformation (pContext->u.primary.DxgkInterface.DeviceHandle, &DeviceInfo);
if(Status == STATUS_SUCCESS)
{
ULONG AdapterMemorySize;
Status = vboxWddmPickResources(pContext, &DeviceInfo, &AdapterMemorySize);
if(Status == STATUS_SUCCESS)
{
/* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
VbglInit ();

/* Guest supports only HGSMI, the old VBVA via VMMDev is not supported. Old
* code will be ifdef'ed and later removed.
* The host will however support both old and new interface to keep compatibility
* with old guest additions.
*/
VBoxSetupDisplaysHGSMI(pContext, AdapterMemorySize);
if ((pContext)->u.primary.bHGSMI)
{
drprintf(("VBoxVideoWddm: using HGSMI\n"));
*NumberOfVideoPresentSources = pContext->u.primary.cDisplays;
*NumberOfChildren = pContext->u.primary.cDisplays;
dprintf(("VBoxVideoWddm: sources(%d), children(%d)\n", *NumberOfVideoPresentSources, *NumberOfChildren));
}
else
{
drprintf(("VBoxVideoWddm: HGSMI failed to initialize, returning err\n"));
/* @todo: report a better status */
Status = STATUS_UNSUCCESSFUL;
}
}
else
{
drprintf(("VBoxVideoWddm:: vboxWddmPickResources failed Status(0x%x), returning err\n", Status));
Status = STATUS_UNSUCCESSFUL;
}
}
else
{
drprintf(("VBoxVideoWddm: DxgkCbGetDeviceInformation failed Status(0x%x), returning err\n", Status));
}
}
else
{
drprintf(("VBoxVideoWddm: invalid parameter, returning err\n"));
Status = STATUS_INVALID_PARAMETER;
}

dfprintf(("<== "__FUNCTION__ ", status(0x%x)\n", Status));

return Status;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: