Based on a patch by Sandy Stutsman <sstutsma@xxxxxxxxxx> Signed-off-by: Sameeh Jubran <sameeh@xxxxxxxxxx> --- qxldod/QxlDod.cpp | 473 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 261 insertions(+), 212 deletions(-) diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp index 07b6fed..ddcbe26 100755 --- a/qxldod/QxlDod.cpp +++ b/qxldod/QxlDod.cpp @@ -3,7 +3,7 @@ #include "qxl_windows.h" #pragma code_seg(push) -#pragma code_seg() +#pragma code_seg("PAGE") #define WIN_QXL_INT_MASK ((QXL_INTERRUPT_DISPLAY) | \ (QXL_INTERRUPT_CURSOR) | \ @@ -55,6 +55,7 @@ QxlDod::QxlDod(_In_ DEVICE_OBJECT* pPhysicalDeviceObject) : m_pPhysicalDevice(pP m_MonitorPowerState(PowerDeviceD0), m_AdapterPowerState(PowerDeviceD0) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s\n", __FUNCTION__)); *((UINT*)&m_Flags) = 0; RtlZeroMemory(&m_DxgkInterface, sizeof(m_DxgkInterface)); @@ -237,6 +238,7 @@ DbgDevicePowerString( __in DEVICE_POWER_STATE Type ) { + PAGED_CODE(); switch (Type) { case PowerDeviceUnspecified: @@ -261,6 +263,7 @@ DbgPowerActionString( __in POWER_ACTION Type ) { + PAGED_CODE(); switch (Type) { case PowerActionNone: @@ -1461,7 +1464,7 @@ NTSTATUS QxlDod::CommitVidPn(_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn) CommitVidPnExit: - NTSTATUS TempStatus; + NTSTATUS TempStatus(STATUS_SUCCESS); UNREFERENCED_PARAMETER(TempStatus); if ((pVidPnSourceModeSetInterface != NULL) && @@ -1651,7 +1654,7 @@ NTSTATUS QxlDod::UpdateActiveVidPnPresentPath(_In_ CONST DXGKARG_UPDATEACTIVEVID // // Non-Paged Code // -#pragma code_seg(push) +#pragma code_seg(push) //Non-Paged Code #pragma code_seg() VOID QxlDod::DpcRoutine(VOID) @@ -1822,7 +1825,7 @@ NTSTATUS QxlDod::WriteHWInfoStr(_In_ HANDLE DevInstRegKeyHandle, _In_ PCWSTR psz return Status; } -NTSTATUS QxlDod::RegisterHWInfo(ULONG Id) +NTSTATUS QxlDod::RegisterHWInfo(_In_ ULONG Id) { PAGED_CODE(); @@ -1955,7 +1958,7 @@ NTSTATUS QxlDod::ReadConfiguration() // // Non-Paged Code // -#pragma code_seg(push) +#pragma code_seg(push) //Non-Paged #pragma code_seg() D3DDDI_VIDEO_PRESENT_SOURCE_ID QxlDod::FindSourceForTarget(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId, BOOLEAN DefaultToZero) { @@ -1970,123 +1973,41 @@ D3DDDI_VIDEO_PRESENT_SOURCE_ID QxlDod::FindSourceForTarget(D3DDDI_VIDEO_PRESENT_ return DefaultToZero ? 0 : D3DDDI_ID_UNINITIALIZED; } - -#pragma code_seg(pop) // End Non-Paged Code - -// -// Frame buffer map/unmap -// - -NTSTATUS -MapFrameBuffer( - _In_ PHYSICAL_ADDRESS PhysicalAddress, - _In_ ULONG Length, - _Outptr_result_bytebuffer_(Length) VOID** VirtualAddress) + +VOID GetPitches(_In_ CONST BLT_INFO* pBltInfo, _Out_ LONG* pPixelPitch, _Out_ LONG* pRowPitch) { - PAGED_CODE(); - - // - // Check for parameters - // - if ((PhysicalAddress.QuadPart == (ULONGLONG)0) || - (Length == 0) || - (VirtualAddress == NULL)) + switch (pBltInfo->Rotation) { + case D3DKMDT_VPPR_IDENTITY: { - DbgPrint(TRACE_LEVEL_ERROR, ("One of PhysicalAddress.QuadPart (0x%I64x), Length (%lu), VirtualAddress (%p) is NULL or 0\n", - PhysicalAddress.QuadPart, Length, VirtualAddress)); - return STATUS_INVALID_PARAMETER; + *pPixelPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE); + *pRowPitch = pBltInfo->Pitch; + return; } - - *VirtualAddress = MmMapIoSpace(PhysicalAddress, - Length, - MmWriteCombined); - if (*VirtualAddress == NULL) + case D3DKMDT_VPPR_ROTATE90: { - // The underlying call to MmMapIoSpace failed. This may be because, MmWriteCombined - // isn't supported, so try again with MmNonCached - - *VirtualAddress = MmMapIoSpace(PhysicalAddress, - Length, - MmNonCached); - if (*VirtualAddress == NULL) - { - DbgPrint(TRACE_LEVEL_ERROR, ("MmMapIoSpace returned a NULL buffer when trying to allocate %lu bytes", Length)); - return STATUS_NO_MEMORY; - } + *pPixelPitch = -((LONG) pBltInfo->Pitch); + *pRowPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE); + return; } - - return STATUS_SUCCESS; -} - -NTSTATUS -UnmapFrameBuffer( - _In_reads_bytes_(Length) VOID* VirtualAddress, - _In_ ULONG Length) -{ - PAGED_CODE(); - - - // - // Check for parameters - // - if ((VirtualAddress == NULL) && (Length == 0)) + case D3DKMDT_VPPR_ROTATE180: { - // Allow this function to be called when there's no work to do, and treat as successful - return STATUS_SUCCESS; + *pPixelPitch = -((LONG) pBltInfo->BitsPerPel / BITS_PER_BYTE); + *pRowPitch = -((LONG) pBltInfo->Pitch); + return; } - else if ((VirtualAddress == NULL) || (Length == 0)) + case D3DKMDT_VPPR_ROTATE270: { - DbgPrint(TRACE_LEVEL_ERROR, ("Only one of Length (%lu), VirtualAddress (%p) is NULL or 0", - Length, VirtualAddress)); - return STATUS_INVALID_PARAMETER; + *pPixelPitch = pBltInfo->Pitch; + *pRowPitch = -((LONG) pBltInfo->BitsPerPel / BITS_PER_BYTE); + return; } - - MmUnmapIoSpace(VirtualAddress, - Length); - - return STATUS_SUCCESS; -} - - - - -// HW specific code - -VOID GetPitches(_In_ CONST BLT_INFO* pBltInfo, _Out_ LONG* pPixelPitch, _Out_ LONG* pRowPitch) -{ - switch (pBltInfo->Rotation) + default: { - case D3DKMDT_VPPR_IDENTITY: - { - *pPixelPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE); - *pRowPitch = pBltInfo->Pitch; - return; - } - case D3DKMDT_VPPR_ROTATE90: - { - *pPixelPitch = -((LONG)pBltInfo->Pitch); - *pRowPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE); - return; - } - case D3DKMDT_VPPR_ROTATE180: - { - *pPixelPitch = -((LONG)pBltInfo->BitsPerPel / BITS_PER_BYTE); - *pRowPitch = -((LONG)pBltInfo->Pitch); - return; - } - case D3DKMDT_VPPR_ROTATE270: - { - *pPixelPitch = pBltInfo->Pitch; - *pRowPitch = -((LONG)pBltInfo->BitsPerPel / BITS_PER_BYTE); - return; - } - default: - { - QXL_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation); - *pPixelPitch = 0; - *pRowPitch = 0; - return; - } + QXL_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation); + *pPixelPitch = 0; + *pRowPitch = 0; + return; + } } } @@ -2096,61 +2017,60 @@ BYTE* GetRowStart(_In_ CONST BLT_INFO* pBltInfo, CONST RECT* pRect) LONG OffLeft = pRect->left + pBltInfo->Offset.x; LONG OffTop = pRect->top + pBltInfo->Offset.y; LONG BytesPerPixel = (pBltInfo->BitsPerPel / BITS_PER_BYTE); - switch (pBltInfo->Rotation) + switch (pBltInfo->Rotation) { + case D3DKMDT_VPPR_IDENTITY: { - case D3DKMDT_VPPR_IDENTITY: - { - pRet = ((BYTE*)pBltInfo->pBits + - OffTop * pBltInfo->Pitch + - OffLeft * BytesPerPixel); - break; - } - case D3DKMDT_VPPR_ROTATE90: - { - pRet = ((BYTE*)pBltInfo->pBits + - (pBltInfo->Height - 1 - OffLeft) * pBltInfo->Pitch + - OffTop * BytesPerPixel); - break; - } - case D3DKMDT_VPPR_ROTATE180: - { - pRet = ((BYTE*)pBltInfo->pBits + - (pBltInfo->Height - 1 - OffTop) * pBltInfo->Pitch + - (pBltInfo->Width - 1 - OffLeft) * BytesPerPixel); - break; - } - case D3DKMDT_VPPR_ROTATE270: - { - pRet = ((BYTE*)pBltInfo->pBits + - OffLeft * pBltInfo->Pitch + - (pBltInfo->Width - 1 - OffTop) * BytesPerPixel); - break; - } - default: - { - QXL_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation); - break; - } + pRet = ((BYTE*) pBltInfo->pBits + + OffTop * pBltInfo->Pitch + + OffLeft * BytesPerPixel); + break; + } + case D3DKMDT_VPPR_ROTATE90: + { + pRet = ((BYTE*) pBltInfo->pBits + + (pBltInfo->Height - 1 - OffLeft) * pBltInfo->Pitch + + OffTop * BytesPerPixel); + break; + } + case D3DKMDT_VPPR_ROTATE180: + { + pRet = ((BYTE*) pBltInfo->pBits + + (pBltInfo->Height - 1 - OffTop) * pBltInfo->Pitch + + (pBltInfo->Width - 1 - OffLeft) * BytesPerPixel); + break; + } + case D3DKMDT_VPPR_ROTATE270: + { + pRet = ((BYTE*) pBltInfo->pBits + + OffLeft * pBltInfo->Pitch + + (pBltInfo->Width - 1 - OffTop) * BytesPerPixel); + break; + } + default: + { + QXL_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation); + break; + } } return pRet; } /****************************Internal*Routine******************************\ - * CopyBitsGeneric - * - * - * Blt function which can handle a rotated dst/src, offset rects in dst/src - * and bpp combinations of: - * dst | src - * 32 | 32 // For identity rotation this is much faster in CopyBits32_32 - * 32 | 24 - * 32 | 16 - * 24 | 32 - * 16 | 32 - * 8 | 32 - * 24 | 24 // untested - * +* CopyBitsGeneric +* +* +* Blt function which can handle a rotated dst/src, offset rects in dst/src +* and bpp combinations of: +* dst | src +* 32 | 32 // For identity rotation this is much faster in CopyBits32_32 +* 32 | 24 +* 32 | 16 +* 24 | 32 +* 16 | 32 +* 8 | 32 +* 24 | 24 // untested +* \**************************************************************************/ VOID CopyBitsGeneric( @@ -2164,13 +2084,12 @@ VOID CopyBitsGeneric( LONG SrcPixelPitch = 0; LONG SrcRowPitch = 0; - DbgPrint(TRACE_LEVEL_VERBOSE , ("---> %s NumRects = %d Dst = %p Src = %p\n", __FUNCTION__, NumRects, pDst->pBits, pSrc->pBits)); + DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s NumRects = %d Dst = %p Src = %p\n", __FUNCTION__, NumRects, pDst->pBits, pSrc->pBits)); GetPitches(pDst, &DstPixelPitch, &DstRowPitch); GetPitches(pSrc, &SrcPixelPitch, &SrcRowPitch); - for (UINT iRect = 0; iRect < NumRects; iRect++) - { + for (UINT iRect = 0; iRect < NumRects; iRect++) { CONST RECT* pRect = &pRects[iRect]; NT_ASSERT(pRect->right >= pRect->left); @@ -2182,57 +2101,47 @@ VOID CopyBitsGeneric( BYTE* pDstRow = GetRowStart(pDst, pRect); CONST BYTE* pSrcRow = GetRowStart(pSrc, pRect); - for (UINT y=0; y < NumRows; y++) - { + for (UINT y = 0; y < NumRows; y++) { BYTE* pDstPixel = pDstRow; CONST BYTE* pSrcPixel = pSrcRow; - for (UINT x=0; x < NumPixels; x++) - { + for (UINT x = 0; x < NumPixels; x++) { if ((pDst->BitsPerPel == 24) || - (pSrc->BitsPerPel == 24)) - { + (pSrc->BitsPerPel == 24)) { pDstPixel[0] = pSrcPixel[0]; pDstPixel[1] = pSrcPixel[1]; pDstPixel[2] = pSrcPixel[2]; // pPixel[3] is the alpha channel and is ignored for whichever of Src/Dst is 32bpp } - else if (pDst->BitsPerPel == 32) - { - if (pSrc->BitsPerPel == 32) - { - UINT32* pDstPixelAs32 = (UINT32*)pDstPixel; - UINT32* pSrcPixelAs32 = (UINT32*)pSrcPixel; + else if (pDst->BitsPerPel == 32) { + if (pSrc->BitsPerPel == 32) { + UINT32* pDstPixelAs32 = (UINT32*) pDstPixel; + UINT32* pSrcPixelAs32 = (UINT32*) pSrcPixel; *pDstPixelAs32 = *pSrcPixelAs32; } - else if (pSrc->BitsPerPel == 16) - { - UINT32* pDstPixelAs32 = (UINT32*)pDstPixel; - UINT16* pSrcPixelAs16 = (UINT16*)pSrcPixel; + else if (pSrc->BitsPerPel == 16) { + UINT32* pDstPixelAs32 = (UINT32*) pDstPixel; + UINT16* pSrcPixelAs16 = (UINT16*) pSrcPixel; *pDstPixelAs32 = CONVERT_16BPP_TO_32BPP(*pSrcPixelAs16); } - else - { + else { // Invalid pSrc->BitsPerPel on a pDst->BitsPerPel of 32 NT_ASSERT(FALSE); } } - else if (pDst->BitsPerPel == 16) - { + else if (pDst->BitsPerPel == 16) { NT_ASSERT(pSrc->BitsPerPel == 32); - UINT16* pDstPixelAs16 = (UINT16*)pDstPixel; + UINT16* pDstPixelAs16 = (UINT16*) pDstPixel; *pDstPixelAs16 = CONVERT_32BPP_TO_16BPP(pSrcPixel); } - else if (pDst->BitsPerPel == 8) - { + else if (pDst->BitsPerPel == 8) { NT_ASSERT(pSrc->BitsPerPel == 32); *pDstPixel = CONVERT_32BPP_TO_8BPP(pSrcPixel); } - else - { + else { // Invalid pDst->BitsPerPel NT_ASSERT(FALSE); } @@ -2260,8 +2169,7 @@ VOID CopyBits32_32( DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); - for (UINT iRect = 0; iRect < NumRects; iRect++) - { + for (UINT iRect = 0; iRect < NumRects; iRect++) { CONST RECT* pRect = &pRects[iRect]; NT_ASSERT(pRect->right >= pRect->left); @@ -2270,15 +2178,14 @@ VOID CopyBits32_32( UINT NumPixels = pRect->right - pRect->left; UINT NumRows = pRect->bottom - pRect->top; UINT BytesToCopy = NumPixels * 4; - BYTE* pStartDst = ((BYTE*)pDst->pBits + - (pRect->top + pDst->Offset.y) * pDst->Pitch + - (pRect->left + pDst->Offset.x) * 4); - CONST BYTE* pStartSrc = ((BYTE*)pSrc->pBits + - (pRect->top + pSrc->Offset.y) * pSrc->Pitch + - (pRect->left + pSrc->Offset.x) * 4); - - for (UINT i = 0; i < NumRows; ++i) - { + BYTE* pStartDst = ((BYTE*) pDst->pBits + + (pRect->top + pDst->Offset.y) * pDst->Pitch + + (pRect->left + pDst->Offset.x) * 4); + CONST BYTE* pStartSrc = ((BYTE*) pSrc->pBits + + (pRect->top + pSrc->Offset.y) * pSrc->Pitch + + (pRect->left + pSrc->Offset.x) * 4); + + for (UINT i = 0; i < NumRows; ++i) { RtlCopyMemory(pStartDst, pStartSrc, BytesToCopy); pStartDst += pDst->Pitch; pStartSrc += pSrc->Pitch; @@ -2288,7 +2195,7 @@ VOID CopyBits32_32( } -VOID BltBits ( +VOID BltBits( BLT_INFO* pDst, CONST BLT_INFO* pSrc, UINT NumRects, @@ -2298,30 +2205,102 @@ VOID BltBits ( // This usage is redundant in the sample driver since it is already being used for MmProbeAndLockPages. However, it is very important // to have this in place and to make sure developers don't miss it, it is in these two locations. DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); - __try - { + __try { if (pDst->BitsPerPel == 32 && pSrc->BitsPerPel == 32 && pDst->Rotation == D3DKMDT_VPPR_IDENTITY && - pSrc->Rotation == D3DKMDT_VPPR_IDENTITY) - { + pSrc->Rotation == D3DKMDT_VPPR_IDENTITY) { // This is by far the most common copy function being called CopyBits32_32(pDst, pSrc, NumRects, pRects); } - else - { + else { CopyBitsGeneric(pDst, pSrc, NumRects, pRects); } } - #pragma prefast(suppress: __WARNING_EXCEPTIONEXECUTEHANDLER, "try/except is only able to protect against user-mode errors and these are the only errors we try to catch here"); - __except(EXCEPTION_EXECUTE_HANDLER) +#pragma prefast(suppress: __WARNING_EXCEPTIONEXECUTEHANDLER, "try/except is only able to protect against user-mode errors and these are the only errors we try to catch here"); + __except (EXCEPTION_EXECUTE_HANDLER) { DbgPrint(TRACE_LEVEL_ERROR, ("Either dst (0x%I64x) or src (0x%I64x) bits encountered exception during access.\n", pDst->pBits, pSrc->pBits)); } } +// +// Frame buffer map/unmap +// + +NTSTATUS +MapFrameBuffer( + _In_ PHYSICAL_ADDRESS PhysicalAddress, + _In_ ULONG Length, + _Outptr_result_bytebuffer_(Length) VOID** VirtualAddress) +{ + PAGED_CODE(); + + // + // Check for parameters + // + if ((PhysicalAddress.QuadPart == (ULONGLONG)0) || + (Length == 0) || + (VirtualAddress == NULL)) + { + DbgPrint(TRACE_LEVEL_ERROR, ("One of PhysicalAddress.QuadPart (0x%I64x), Length (%lu), VirtualAddress (%p) is NULL or 0\n", + PhysicalAddress.QuadPart, Length, VirtualAddress)); + return STATUS_INVALID_PARAMETER; + } + + *VirtualAddress = MmMapIoSpaceEx(PhysicalAddress, + Length, + PAGE_WRITECOMBINE | PAGE_READWRITE); + if (*VirtualAddress == NULL) + { + // The underlying call to MmMapIoSpace failed. This may be because, MmWriteCombined + // isn't supported, so try again with MmNonCached + + *VirtualAddress = MmMapIoSpaceEx(PhysicalAddress, + Length, + (ULONG) (PAGE_NOCACHE | PAGE_READWRITE)); + if (*VirtualAddress == NULL) + { + DbgPrint(TRACE_LEVEL_ERROR, ("MmMapIoSpace returned a NULL buffer when trying to allocate %lu bytes", Length)); + return STATUS_NO_MEMORY; + } + } + + return STATUS_SUCCESS; +} + +NTSTATUS +UnmapFrameBuffer( + _In_reads_bytes_(Length) VOID* VirtualAddress, + _In_ ULONG Length) +{ + PAGED_CODE(); + + + // + // Check for parameters + // + if ((VirtualAddress == NULL) && (Length == 0)) + { + // Allow this function to be called when there's no work to do, and treat as successful + return STATUS_SUCCESS; + } + else if ((VirtualAddress == NULL) || (Length == 0)) + { + DbgPrint(TRACE_LEVEL_ERROR, ("Only one of Length (%lu), VirtualAddress (%p) is NULL or 0", + Length, VirtualAddress)); + return STATUS_INVALID_PARAMETER; + } + + MmUnmapIoSpace(VirtualAddress, + Length); + + return STATUS_SUCCESS; +} + VgaDevice::VgaDevice(_In_ QxlDod* pQxlDod) : HwDeviceInterface(pQxlDod) { + PAGED_CODE(); m_pQxlDod = pQxlDod; m_ModeInfo = NULL; m_ModeCount = 0; @@ -2333,6 +2312,7 @@ VgaDevice::VgaDevice(_In_ QxlDod* pQxlDod) : HwDeviceInterface(pQxlDod) VgaDevice::~VgaDevice(void) { + PAGED_CODE(); HWClose(); delete [] reinterpret_cast<BYTE*>(m_ModeInfo); delete [] reinterpret_cast<BYTE*>(m_ModeNumbers); @@ -2573,6 +2553,7 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo) NTSTATUS VgaDevice::QueryCurrentMode(PVIDEO_MODE RequestedMode) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__)); NTSTATUS Status = STATUS_SUCCESS; UNREFERENCED_PARAMETER(RequestedMode); @@ -2582,6 +2563,8 @@ NTSTATUS VgaDevice::QueryCurrentMode(PVIDEO_MODE RequestedMode) NTSTATUS VgaDevice::SetCurrentMode(ULONG Mode) { + PAGED_CODE(); + NTSTATUS Status = STATUS_SUCCESS; DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s Mode = %x\n", __FUNCTION__, Mode)); X86BIOS_REGISTERS regs = {0}; @@ -2598,6 +2581,8 @@ NTSTATUS VgaDevice::SetCurrentMode(ULONG Mode) NTSTATUS VgaDevice::GetCurrentMode(ULONG* pMode) { + PAGED_CODE(); + NTSTATUS Status = STATUS_SUCCESS; DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s\n", __FUNCTION__)); X86BIOS_REGISTERS regs = {0}; @@ -2614,6 +2599,8 @@ NTSTATUS VgaDevice::GetCurrentMode(ULONG* pMode) NTSTATUS VgaDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo) { + PAGED_CODE(); + DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); UNREFERENCED_PARAMETER(pResList); UNREFERENCED_PARAMETER(pDispInfo); @@ -2623,13 +2610,17 @@ NTSTATUS VgaDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* NTSTATUS VgaDevice::HWClose(void) { + PAGED_CODE(); + DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__)); return STATUS_SUCCESS; } -NTSTATUS VgaDevice::SetPowerState(_In_ DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo) +NTSTATUS VgaDevice::SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo) { + PAGED_CODE(); + DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s\n", __FUNCTION__)); X86BIOS_REGISTERS regs = {0}; @@ -2921,18 +2912,21 @@ VOID VgaDevice::ResetDevice(VOID) NTSTATUS VgaDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape) { + PAGED_CODE(); UNREFERENCED_PARAMETER(pSetPointerShape); return STATUS_NOT_SUPPORTED; } NTSTATUS VgaDevice::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition) { + PAGED_CODE(); UNREFERENCED_PARAMETER(pSetPointerPosition); return STATUS_SUCCESS; } NTSTATUS VgaDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscap) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__)); return STATUS_NOT_IMPLEMENTED; @@ -2940,6 +2934,7 @@ NTSTATUS VgaDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscap) QxlDevice::QxlDevice(_In_ QxlDod* pQxlDod) : HwDeviceInterface(pQxlDod) { + PAGED_CODE(); m_pQxlDod = pQxlDod; m_ModeInfo = NULL; m_ModeCount = 0; @@ -2953,6 +2948,7 @@ QxlDevice::QxlDevice(_In_ QxlDod* pQxlDod) : HwDeviceInterface(pQxlDod) QxlDevice::~QxlDevice(void) { + PAGED_CODE(); HWClose(); delete [] reinterpret_cast<BYTE*>(m_ModeInfo); delete [] reinterpret_cast<BYTE*>(m_ModeNumbers); @@ -3126,6 +3122,7 @@ NTSTATUS QxlDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo) NTSTATUS QxlDevice::QueryCurrentMode(PVIDEO_MODE RequestedMode) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__)); NTSTATUS Status = STATUS_SUCCESS; UNREFERENCED_PARAMETER(RequestedMode); @@ -3162,8 +3159,9 @@ NTSTATUS QxlDevice::GetCurrentMode(ULONG* pMode) return Status; } -NTSTATUS QxlDevice::SetPowerState(_In_ DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo) +NTSTATUS QxlDevice::SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); switch (DevicePowerState) { @@ -3179,6 +3177,7 @@ NTSTATUS QxlDevice::SetPowerState(_In_ DEVICE_POWER_STATE DevicePowerState, DXGK NTSTATUS QxlDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); PDXGKRNL_INTERFACE pDxgkInterface = m_pQxlDod->GetDxgkInterface(); UINT pci_range = QXL_RAM_RANGE_INDEX; @@ -3326,6 +3325,7 @@ NTSTATUS QxlDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* NTSTATUS QxlDevice::QxlInit(DXGK_DISPLAY_INFORMATION* pDispInfo) { + PAGED_CODE(); NTSTATUS Status = STATUS_SUCCESS; if (!InitMemSlots()) { @@ -3353,11 +3353,13 @@ NTSTATUS QxlDevice::QxlInit(DXGK_DISPLAY_INFORMATION* pDispInfo) void QxlDevice::QxlClose() { + PAGED_CODE(); DestroyMemSlots(); } void QxlDevice::UnmapMemory(void) { + PAGED_CODE(); PDXGKRNL_INTERFACE pDxgkInterface = m_pQxlDod->GetDxgkInterface(); if (m_IoMapped && m_IoBase) { @@ -3385,6 +3387,7 @@ void QxlDevice::UnmapMemory(void) BOOL QxlDevice::InitMemSlots(void) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); m_NumMemSlots = m_RomHdr->slots_end; m_SlotGenBits = m_RomHdr->slot_gen_bits; @@ -3404,6 +3407,7 @@ BOOL QxlDevice::InitMemSlots(void) void QxlDevice::DestroyMemSlots(void) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); delete [] reinterpret_cast<BYTE*>(m_MemSlots); m_MemSlots = NULL; @@ -3435,6 +3439,7 @@ void QxlDevice::CreatePrimarySurface(PVIDEO_MODE_INFORMATION pModeInfo) void QxlDevice::DestroyPrimarySurface(void) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); // AsyncIo(QXL_IO_DESTROY_PRIMARY_ASYNC, 0); SyncIo(QXL_IO_DESTROY_PRIMARY, 0); @@ -3443,6 +3448,7 @@ void QxlDevice::DestroyPrimarySurface(void) _inline QXLPHYSICAL QxlDevice::PA(PVOID virt, UINT8 slot_id) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__)); MemSlot *pSlot = &m_MemSlots[slot_id];; return pSlot->high_bits | ((UINT64)virt - pSlot->start_virt_addr); @@ -3450,6 +3456,7 @@ _inline QXLPHYSICAL QxlDevice::PA(PVOID virt, UINT8 slot_id) _inline UINT64 QxlDevice::VA(QXLPHYSICAL paddr, UINT8 slot_id) { + PAGED_CODE(); UINT64 virt; MemSlot *pSlot = &m_MemSlots[slot_id];; @@ -3462,6 +3469,7 @@ _inline UINT64 QxlDevice::VA(QXLPHYSICAL paddr, UINT8 slot_id) void QxlDevice::SetupHWSlot(UINT8 Idx, MemSlot *pSlot) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); m_RamHdr->mem_slot.mem_start = pSlot->start_phys_addr; m_RamHdr->mem_slot.mem_end = pSlot->end_phys_addr; @@ -3471,6 +3479,7 @@ void QxlDevice::SetupHWSlot(UINT8 Idx, MemSlot *pSlot) BOOL QxlDevice::CreateEvents() { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); KeInitializeEvent(&m_DisplayEvent, SynchronizationEvent, @@ -3492,6 +3501,7 @@ BOOL QxlDevice::CreateEvents() BOOL QxlDevice::CreateRings() { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); m_CommandRing = &(m_RamHdr->cmd_ring); m_CursorRing = &(m_RamHdr->cursor_ring); @@ -3502,6 +3512,7 @@ BOOL QxlDevice::CreateRings() void QxlDevice::AsyncIo(UCHAR Port, UCHAR Value) { + PAGED_CODE(); LARGE_INTEGER timeout; BOOLEAN locked = FALSE; locked = WaitForObject(&m_IoLock, NULL); @@ -3513,6 +3524,7 @@ void QxlDevice::AsyncIo(UCHAR Port, UCHAR Value) void QxlDevice::SyncIo(UCHAR Port, UCHAR Value) { + PAGED_CODE(); BOOLEAN locked = FALSE; locked = WaitForObject(&m_IoLock, NULL); WRITE_PORT_UCHAR(m_IoBase + Port, Value); @@ -3521,6 +3533,7 @@ void QxlDevice::SyncIo(UCHAR Port, UCHAR Value) UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend) { + PAGED_CODE(); UINT64 high_bits; MemSlot *pSlot; UINT8 slot_index; @@ -3546,6 +3559,7 @@ UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 va BOOL QxlDevice::CreateMemSlots(void) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s 3\n", __FUNCTION__)); UINT64 len = m_RomHdr->surface0_area_size + m_RomHdr->num_pages * PAGE_SIZE; m_MainMemSlot = SetupMemSlot(0, @@ -3585,6 +3599,7 @@ void QxlDevice::InitMonitorConfig(void) void QxlDevice::InitMspace(UINT32 mspace_type, UINT8 *start, size_t capacity) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s type = %d, start = %p, capacity = %d\n", __FUNCTION__, mspace_type, start, capacity)); m_MSInfo[mspace_type]._mspace = create_mspace_with_base(start, capacity, 0, this); m_MSInfo[mspace_type].mspace_start = start; @@ -3784,6 +3799,7 @@ QxlDevice::ExecutePresentDisplayOnly( void QxlDevice::WaitForReleaseRing(void) { + PAGED_CODE(); int wait; DbgPrint(TRACE_LEVEL_VERBOSE, ("--->%s\n", __FUNCTION__)); @@ -3816,6 +3832,7 @@ void QxlDevice::WaitForReleaseRing(void) void QxlDevice::FlushReleaseRing() { + PAGED_CODE(); UINT64 output; int notify; int num_to_release = 50; @@ -3847,6 +3864,7 @@ void QxlDevice::FlushReleaseRing() void QxlDevice::EmptyReleaseRing() { + PAGED_CODE(); BOOLEAN locked = FALSE; locked = WaitForObject(&m_MemLock, NULL); while (m_FreeOutputs || !SPICE_RING_IS_EMPTY(m_ReleaseRing)) { @@ -3857,6 +3875,7 @@ void QxlDevice::EmptyReleaseRing() UINT64 QxlDevice::ReleaseOutput(UINT64 output_id) { + PAGED_CODE(); QXLOutput *output = (QXLOutput *)output_id; Resource **now; Resource **end; @@ -3876,6 +3895,7 @@ UINT64 QxlDevice::ReleaseOutput(UINT64 output_id) void *QxlDevice::AllocMem(UINT32 mspace_type, size_t size, BOOL force) { + PAGED_CODE(); PVOID ptr; BOOLEAN locked = FALSE; @@ -3924,6 +3944,7 @@ void *QxlDevice::AllocMem(UINT32 mspace_type, size_t size, BOOL force) void QxlDevice::FreeMem(UINT32 mspace_type, void *ptr) { + PAGED_CODE(); ASSERT(m_MSInfo[mspace_type]._mspace); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -3944,6 +3965,7 @@ void QxlDevice::FreeMem(UINT32 mspace_type, void *ptr) QXLDrawable *QxlDevice::GetDrawable() { + PAGED_CODE(); QXLOutput *output; output = (QXLOutput *)AllocMem(MSPACE_TYPE_DEVRAM, sizeof(QXLOutput) + sizeof(QXLDrawable), TRUE); @@ -3956,6 +3978,7 @@ QXLDrawable *QxlDevice::GetDrawable() QXLCursorCmd *QxlDevice::CursorCmd() { + PAGED_CODE(); QXLCursorCmd *cursor_cmd; QXLOutput *output; @@ -3971,6 +3994,7 @@ QXLCursorCmd *QxlDevice::CursorCmd() BOOL QxlDevice::SetClip(const RECT *clip, QXLDrawable *drawable) { + PAGED_CODE(); Resource *rects_res; if (clip == NULL) { @@ -4000,12 +4024,14 @@ BOOL QxlDevice::SetClip(const RECT *clip, QXLDrawable *drawable) void QxlDevice::AddRes(QXLOutput *output, Resource *res) { + PAGED_CODE(); res->refs++; output->resources[output->num_res++] = res; } void QxlDevice::DrawableAddRes(QXLDrawable *drawable, Resource *res) { + PAGED_CODE(); QXLOutput *output; output = (QXLOutput *)((UINT8 *)drawable - sizeof(QXLOutput)); @@ -4014,6 +4040,7 @@ void QxlDevice::DrawableAddRes(QXLDrawable *drawable, Resource *res) void QxlDevice::CursorCmdAddRes(QXLCursorCmd *cmd, Resource *res) { + PAGED_CODE(); QXLOutput *output; output = (QXLOutput *)((UINT8 *)cmd - sizeof(QXLOutput)); @@ -4022,6 +4049,7 @@ void QxlDevice::CursorCmdAddRes(QXLCursorCmd *cmd, Resource *res) void QxlDevice::FreeClipRectsEx(Resource *res) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__)); QxlDevice* pqxl = (QxlDevice*)res->ptr; pqxl->FreeClipRects(res); @@ -4029,6 +4057,7 @@ void QxlDevice::FreeClipRectsEx(Resource *res) void QxlDevice::FreeClipRects(Resource *res) { + PAGED_CODE(); QXLPHYSICAL chunk_phys; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4044,6 +4073,7 @@ void QxlDevice::FreeClipRects(Resource *res) void QxlDevice::FreeBitmapImageEx(Resource *res) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__)); QxlDevice* pqxl = (QxlDevice*)res->ptr; pqxl->FreeBitmapImage(res); @@ -4051,6 +4081,7 @@ void QxlDevice::FreeBitmapImageEx(Resource *res) void QxlDevice::FreeBitmapImage(Resource *res) { + PAGED_CODE(); InternalImage *internal; QXLPHYSICAL chunk_phys; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4070,6 +4101,7 @@ void QxlDevice::FreeBitmapImage(Resource *res) void QxlDevice::FreeCursorEx(Resource *res) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__)); QxlDevice* pqxl = (QxlDevice*)res->ptr; pqxl->FreeCursor(res); @@ -4077,6 +4109,7 @@ void QxlDevice::FreeCursorEx(Resource *res) void QxlDevice::FreeCursor(Resource *res) { + PAGED_CODE(); QXLPHYSICAL chunk_phys; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4093,6 +4126,7 @@ void QxlDevice::FreeCursor(Resource *res) QXLDrawable *QxlDevice::Drawable(UINT8 type, CONST RECT *area, CONST RECT *clip, UINT32 surface_id) { + PAGED_CODE(); QXLDrawable *drawable; ASSERT(area); @@ -4118,7 +4152,9 @@ QXLDrawable *QxlDevice::Drawable(UINT8 type, CONST RECT *area, CONST RECT *clip, return drawable; } -void QxlDevice::PushDrawable(QXLDrawable *drawable) { +void QxlDevice::PushDrawable(QXLDrawable *drawable) +{ + PAGED_CODE(); QXLCommand *cmd; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4135,6 +4171,7 @@ void QxlDevice::PushDrawable(QXLDrawable *drawable) { void QxlDevice::PushCursorCmd(QXLCursorCmd *cursor_cmd) { + PAGED_CODE(); QXLCommand *cmd; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4156,6 +4193,7 @@ VOID QxlDevice::SetImageId(InternalImage *internal, LONG height, UINT8 format, UINT32 key) { + PAGED_CODE(); UINT32 image_info = IMAGE_HASH_INIT_VAL(width, height, format); if (cache_me) { @@ -4175,6 +4213,7 @@ VOID QxlDevice::BltBits ( UINT NumRects, _In_reads_(NumRects) CONST RECT *pRects) { + PAGED_CODE(); QXLDrawable *drawable; Resource *image_res; InternalImage *internal; @@ -4272,6 +4311,7 @@ VOID QxlDevice::PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr, UINT8 **end_ptr, UINT8 *src, int size, size_t alloc_size, uint32_t alignment) { + PAGED_CODE(); QXLDataChunk *chunk = *chunk_ptr; UINT8 *now = *now_ptr; UINT8 *end = *end_ptr; @@ -4336,6 +4376,7 @@ VOID QxlDevice::BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod) NTSTATUS QxlDevice::HWClose(void) { + PAGED_CODE(); QxlClose(); UnmapMemory(); return STATUS_SUCCESS; @@ -4343,6 +4384,7 @@ NTSTATUS QxlDevice::HWClose(void) NTSTATUS QxlDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s flag = %x\n", __FUNCTION__, pSetPointerShape->Flags.Value)); DbgPrint(TRACE_LEVEL_INFORMATION, ("<--> %s flag = %d pitch = %d, pixels = %p, id = %d, w = %d, h = %d, x = %d, y = %d\n", __FUNCTION__, pSetPointerShape->Flags.Value, @@ -4424,6 +4466,7 @@ NTSTATUS QxlDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPoi NTSTATUS QxlDevice::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition) { + PAGED_CODE(); DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); DbgPrint(TRACE_LEVEL_INFORMATION, ("<--> %s flag = %d id = %d, x = %d, y = %d\n", __FUNCTION__, pSetPointerPosition->Flags.Value, @@ -4543,6 +4586,7 @@ NTSTATUS QxlDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape) VOID QxlDevice::WaitForCmdRing() { + PAGED_CODE(); int wait; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4559,6 +4603,7 @@ VOID QxlDevice::WaitForCmdRing() VOID QxlDevice::PushCmd() { + PAGED_CODE(); int notify; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); SPICE_RING_PUSH(m_CommandRing, notify); @@ -4570,6 +4615,7 @@ VOID QxlDevice::PushCmd() VOID QxlDevice::WaitForCursorRing(VOID) { + PAGED_CODE(); int wait; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); @@ -4592,6 +4638,7 @@ VOID QxlDevice::WaitForCursorRing(VOID) VOID QxlDevice::PushCursor(VOID) { + PAGED_CODE(); int notify; DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__)); SPICE_RING_PUSH(m_CursorRing, notify); @@ -4665,7 +4712,7 @@ VOID QxlDevice::UpdateArea(CONST RECT* area, UINT32 surface_id) DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__)); } -BOOLEAN QxlDevice:: DpcCallbackEx(PVOID ptr) +BOOLEAN QxlDevice::DpcCallbackEx(PVOID ptr) { DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__)); PDPC_CB_CONTEXT ctx = (PDPC_CB_CONTEXT) ptr; @@ -4710,6 +4757,7 @@ D3DDDIFORMAT PixelFormatFromBPP(UINT BPP) UINT SpiceFromPixelFormat(D3DDDIFORMAT Format) { + PAGED_CODE(); switch (Format) { case D3DDDIFMT_UNKNOWN: @@ -4721,3 +4769,4 @@ UINT SpiceFromPixelFormat(D3DDDIFORMAT Format) default: QXL_LOG_ASSERTION1("Unknown D3DDDIFORMAT 0x%I64x", Format); return 0; } } +#pragma code_seg(pop) \ No newline at end of file -- 2.7.0.windows.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel