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