1 | /* $Id: VBoxMPMisc.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox WDDM Miniport driver
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPMisc_h
|
---|
19 | #define GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPMisc_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "../../common/VBoxVideoTools.h"
|
---|
25 |
|
---|
26 | DECLINLINE(void) vboxVideoLeDetach(LIST_ENTRY *pList, LIST_ENTRY *pDstList)
|
---|
27 | {
|
---|
28 | if (IsListEmpty(pList))
|
---|
29 | {
|
---|
30 | InitializeListHead(pDstList);
|
---|
31 | }
|
---|
32 | else
|
---|
33 | {
|
---|
34 | *pDstList = *pList;
|
---|
35 | Assert(pDstList->Flink->Blink == pList);
|
---|
36 | Assert(pDstList->Blink->Flink == pList);
|
---|
37 | /* pDstList->Flink & pDstList->Blink point to the "real| entries, never to pList
|
---|
38 | * since we've checked IsListEmpty(pList) above */
|
---|
39 | pDstList->Flink->Blink = pDstList;
|
---|
40 | pDstList->Blink->Flink = pDstList;
|
---|
41 | InitializeListHead(pList);
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | typedef uint32_t VBOXWDDM_HANDLE;
|
---|
46 | #define VBOXWDDM_HANDLE_INVALID 0UL
|
---|
47 |
|
---|
48 | typedef struct VBOXWDDM_HTABLE
|
---|
49 | {
|
---|
50 | uint32_t cData;
|
---|
51 | uint32_t iNext2Search;
|
---|
52 | uint32_t cSize;
|
---|
53 | PVOID *paData;
|
---|
54 | } VBOXWDDM_HTABLE, *PVBOXWDDM_HTABLE;
|
---|
55 |
|
---|
56 | typedef struct VBOXWDDM_HTABLE_ITERATOR
|
---|
57 | {
|
---|
58 | PVBOXWDDM_HTABLE pTbl;
|
---|
59 | uint32_t iCur;
|
---|
60 | uint32_t cLeft;
|
---|
61 | } VBOXWDDM_HTABLE_ITERATOR, *PVBOXWDDM_HTABLE_ITERATOR;
|
---|
62 |
|
---|
63 | VOID vboxWddmHTableIterInit(PVBOXWDDM_HTABLE pTbl, PVBOXWDDM_HTABLE_ITERATOR pIter);
|
---|
64 | PVOID vboxWddmHTableIterNext(PVBOXWDDM_HTABLE_ITERATOR pIter, VBOXWDDM_HANDLE *phHandle);
|
---|
65 | BOOL vboxWddmHTableIterHasNext(PVBOXWDDM_HTABLE_ITERATOR pIter);
|
---|
66 | PVOID vboxWddmHTableIterRemoveCur(PVBOXWDDM_HTABLE_ITERATOR pIter);
|
---|
67 | NTSTATUS vboxWddmHTableCreate(PVBOXWDDM_HTABLE pTbl, uint32_t cSize);
|
---|
68 | VOID vboxWddmHTableDestroy(PVBOXWDDM_HTABLE pTbl);
|
---|
69 | NTSTATUS vboxWddmHTableRealloc(PVBOXWDDM_HTABLE pTbl, uint32_t cNewSize);
|
---|
70 | VBOXWDDM_HANDLE vboxWddmHTablePut(PVBOXWDDM_HTABLE pTbl, PVOID pvData);
|
---|
71 | PVOID vboxWddmHTableRemove(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
|
---|
72 | PVOID vboxWddmHTableGet(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
|
---|
73 |
|
---|
74 | NTSTATUS vboxWddmRegQueryDisplaySettingsKeyName(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
|
---|
75 | ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
76 | NTSTATUS vboxWddmRegOpenDisplaySettingsKey(IN PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, OUT PHANDLE phKey);
|
---|
77 | NTSTATUS vboxWddmRegDisplaySettingsQueryRelX(HANDLE hKey, int * pResult);
|
---|
78 | NTSTATUS vboxWddmRegDisplaySettingsQueryRelY(HANDLE hKey, int * pResult);
|
---|
79 | NTSTATUS vboxWddmDisplaySettingsQueryPos(IN PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, POINT * pPos);
|
---|
80 | void vboxWddmDisplaySettingsCheckPos(IN PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId);
|
---|
81 | NTSTATUS vboxWddmRegQueryVideoGuidString(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
82 |
|
---|
83 | NTSTATUS vboxWddmRegQueryDrvKeyName(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
84 |
|
---|
85 | NTSTATUS vboxWddmRegOpenKeyEx(OUT PHANDLE phKey, IN HANDLE hRootKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
|
---|
86 | NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
|
---|
87 | NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword);
|
---|
88 | NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, IN DWORD val);
|
---|
89 |
|
---|
90 | NTSTATUS vboxWddmRegDrvFlagsSet(PVBOXMP_DEVEXT pDevExt, DWORD fVal);
|
---|
91 | DWORD vboxWddmRegDrvFlagsGet(PVBOXMP_DEVEXT pDevExt, DWORD fDefault);
|
---|
92 |
|
---|
93 | UNICODE_STRING* vboxWddmVGuidGet(PVBOXMP_DEVEXT pDevExt);
|
---|
94 | VOID vboxWddmVGuidFree(PVBOXMP_DEVEXT pDevExt);
|
---|
95 |
|
---|
96 | #define VBOXWDDM_MM_VOID 0xffffffffUL
|
---|
97 |
|
---|
98 | typedef struct VBOXWDDM_MM
|
---|
99 | {
|
---|
100 | RTL_BITMAP BitMap;
|
---|
101 | UINT cPages;
|
---|
102 | UINT cAllocs;
|
---|
103 | PULONG pBuffer;
|
---|
104 | } VBOXWDDM_MM, *PVBOXWDDM_MM;
|
---|
105 |
|
---|
106 | NTSTATUS vboxMmInit(PVBOXWDDM_MM pMm, UINT cPages);
|
---|
107 | ULONG vboxMmAlloc(PVBOXWDDM_MM pMm, UINT cPages);
|
---|
108 | VOID vboxMmFree(PVBOXWDDM_MM pMm, UINT iPage, UINT cPages);
|
---|
109 | NTSTATUS vboxMmTerm(PVBOXWDDM_MM pMm);
|
---|
110 |
|
---|
111 | typedef struct VBOXVIDEOCM_ALLOC_MGR
|
---|
112 | {
|
---|
113 | /* synch lock */
|
---|
114 | FAST_MUTEX Mutex;
|
---|
115 | VBOXWDDM_HTABLE AllocTable;
|
---|
116 | VBOXWDDM_MM Mm;
|
---|
117 | // PHYSICAL_ADDRESS PhData;
|
---|
118 | uint8_t *pvData;
|
---|
119 | uint32_t offData;
|
---|
120 | uint32_t cbData;
|
---|
121 | } VBOXVIDEOCM_ALLOC_MGR, *PVBOXVIDEOCM_ALLOC_MGR;
|
---|
122 |
|
---|
123 | typedef struct VBOXVIDEOCM_ALLOC_CONTEXT
|
---|
124 | {
|
---|
125 | PVBOXVIDEOCM_ALLOC_MGR pMgr;
|
---|
126 | /* synch lock */
|
---|
127 | FAST_MUTEX Mutex;
|
---|
128 | VBOXWDDM_HTABLE AllocTable;
|
---|
129 | } VBOXVIDEOCM_ALLOC_CONTEXT, *PVBOXVIDEOCM_ALLOC_CONTEXT;
|
---|
130 |
|
---|
131 | NTSTATUS vboxVideoAMgrCreate(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr, uint32_t offData, uint32_t cbData);
|
---|
132 | NTSTATUS vboxVideoAMgrDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr);
|
---|
133 |
|
---|
134 | NTSTATUS vboxVideoAMgrCtxCreate(PVBOXVIDEOCM_ALLOC_MGR pMgr, PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
|
---|
135 | NTSTATUS vboxVideoAMgrCtxDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
|
---|
136 |
|
---|
137 | NTSTATUS vboxVideoAMgrCtxAllocCreate(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, PVBOXVIDEOCM_UM_ALLOC pUmAlloc);
|
---|
138 | NTSTATUS vboxVideoAMgrCtxAllocDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, VBOXDISP_KMHANDLE hSesionHandle);
|
---|
139 |
|
---|
140 | VOID vboxWddmSleep(uint32_t u32Val);
|
---|
141 | VOID vboxWddmCounterU32Wait(uint32_t volatile * pu32, uint32_t u32Val);
|
---|
142 |
|
---|
143 | NTSTATUS vboxUmdDumpBuf(PVBOXDISPIFESCAPE_DBGDUMPBUF pBuf, uint32_t cbBuffer);
|
---|
144 |
|
---|
145 | #if 0
|
---|
146 | /* wine shrc handle -> allocation map */
|
---|
147 | VOID vboxShRcTreeInit(PVBOXMP_DEVEXT pDevExt);
|
---|
148 | VOID vboxShRcTreeTerm(PVBOXMP_DEVEXT pDevExt);
|
---|
149 | BOOLEAN vboxShRcTreePut(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
150 | PVBOXWDDM_ALLOCATION vboxShRcTreeGet(PVBOXMP_DEVEXT pDevExt, HANDLE hSharedRc);
|
---|
151 | BOOLEAN vboxShRcTreeRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | NTSTATUS vboxWddmDrvCfgInit(PUNICODE_STRING pRegStr);
|
---|
155 |
|
---|
156 | NTSTATUS VBoxWddmSlEnableVSyncNotification(PVBOXMP_DEVEXT pDevExt, BOOLEAN fEnable);
|
---|
157 | NTSTATUS VBoxWddmSlGetScanLine(PVBOXMP_DEVEXT pDevExt, DXGKARG_GETSCANLINE *pSl);
|
---|
158 | NTSTATUS VBoxWddmSlInit(PVBOXMP_DEVEXT pDevExt);
|
---|
159 | NTSTATUS VBoxWddmSlTerm(PVBOXMP_DEVEXT pDevExt);
|
---|
160 |
|
---|
161 | void vboxWddmDiInitDefault(DXGK_DISPLAY_INFORMATION *pInfo, PHYSICAL_ADDRESS PhAddr, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId);
|
---|
162 | void vboxWddmDiToAllocData(PVBOXMP_DEVEXT pDevExt, const DXGK_DISPLAY_INFORMATION *pInfo, struct VBOXWDDM_ALLOC_DATA *pAllocData);
|
---|
163 | void vboxWddmDmSetupDefaultVramLocation(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID ModifiedVidPnSourceId, struct VBOXWDDM_SOURCE *paSources);
|
---|
164 |
|
---|
165 | char const *vboxWddmAllocTypeString(PVBOXWDDM_ALLOCATION pAlloc);
|
---|
166 |
|
---|
167 | #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPMisc_h */
|
---|