1 | /* $Id: VBoxMPMisc.h 51260 2014-05-15 15:35:56Z 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 pDeviceExtension, 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 pDeviceExtension, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, POINT * pPos);
|
---|
95 | NTSTATUS vboxWddmRegQueryVideoGuidString(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
96 |
|
---|
97 | NTSTATUS vboxWddmRegQueryDrvKeyName(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
98 |
|
---|
99 | NTSTATUS vboxWddmRegOpenKeyEx(OUT PHANDLE phKey, IN HANDLE hRootKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
|
---|
100 | NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
|
---|
101 | NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword);
|
---|
102 | NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, IN DWORD val);
|
---|
103 |
|
---|
104 | NTSTATUS vboxWddmRegDrvFlagsSet(PVBOXMP_DEVEXT pDevExt, DWORD fVal);
|
---|
105 | DWORD vboxWddmRegDrvFlagsGet(PVBOXMP_DEVEXT pDevExt, DWORD fDefault);
|
---|
106 |
|
---|
107 | UNICODE_STRING* vboxWddmVGuidGet(PVBOXMP_DEVEXT pDevExt);
|
---|
108 | VOID vboxWddmVGuidFree(PVBOXMP_DEVEXT pDevExt);
|
---|
109 |
|
---|
110 | #define VBOXWDDM_MM_VOID 0xffffffffUL
|
---|
111 |
|
---|
112 | typedef struct VBOXWDDM_MM
|
---|
113 | {
|
---|
114 | RTL_BITMAP BitMap;
|
---|
115 | UINT cPages;
|
---|
116 | UINT cAllocs;
|
---|
117 | PULONG pBuffer;
|
---|
118 | } VBOXWDDM_MM, *PVBOXWDDM_MM;
|
---|
119 |
|
---|
120 | NTSTATUS vboxMmInit(PVBOXWDDM_MM pMm, UINT cPages);
|
---|
121 | ULONG vboxMmAlloc(PVBOXWDDM_MM pMm, UINT cPages);
|
---|
122 | VOID vboxMmFree(PVBOXWDDM_MM pMm, UINT iPage, UINT cPages);
|
---|
123 | NTSTATUS vboxMmTerm(PVBOXWDDM_MM pMm);
|
---|
124 |
|
---|
125 | typedef struct VBOXVIDEOCM_ALLOC_MGR
|
---|
126 | {
|
---|
127 | /* synch lock */
|
---|
128 | FAST_MUTEX Mutex;
|
---|
129 | VBOXWDDM_HTABLE AllocTable;
|
---|
130 | VBOXWDDM_MM Mm;
|
---|
131 | // PHYSICAL_ADDRESS PhData;
|
---|
132 | uint8_t *pvData;
|
---|
133 | uint32_t offData;
|
---|
134 | uint32_t cbData;
|
---|
135 | } VBOXVIDEOCM_ALLOC_MGR, *PVBOXVIDEOCM_ALLOC_MGR;
|
---|
136 |
|
---|
137 | typedef struct VBOXVIDEOCM_ALLOC_CONTEXT
|
---|
138 | {
|
---|
139 | PVBOXVIDEOCM_ALLOC_MGR pMgr;
|
---|
140 | /* synch lock */
|
---|
141 | FAST_MUTEX Mutex;
|
---|
142 | VBOXWDDM_HTABLE AllocTable;
|
---|
143 | } VBOXVIDEOCM_ALLOC_CONTEXT, *PVBOXVIDEOCM_ALLOC_CONTEXT;
|
---|
144 |
|
---|
145 | NTSTATUS vboxVideoAMgrCreate(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr, uint32_t offData, uint32_t cbData);
|
---|
146 | NTSTATUS vboxVideoAMgrDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr);
|
---|
147 |
|
---|
148 | NTSTATUS vboxVideoAMgrCtxCreate(PVBOXVIDEOCM_ALLOC_MGR pMgr, PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
|
---|
149 | NTSTATUS vboxVideoAMgrCtxDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
|
---|
150 |
|
---|
151 | NTSTATUS vboxVideoAMgrCtxAllocCreate(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, PVBOXVIDEOCM_UM_ALLOC pUmAlloc);
|
---|
152 | NTSTATUS vboxVideoAMgrCtxAllocDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, VBOXDISP_KMHANDLE hSesionHandle);
|
---|
153 |
|
---|
154 | #ifdef VBOX_WITH_CRHGSMI
|
---|
155 | NTSTATUS vboxVideoAMgrCtxAllocSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_CONTEXT pContext, UINT cBuffers, VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *paBuffers);
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | VOID vboxWddmSleep(uint32_t u32Val);
|
---|
159 | VOID vboxWddmCounterU32Wait(uint32_t volatile * pu32, uint32_t u32Val);
|
---|
160 |
|
---|
161 | NTSTATUS vboxUmdDumpBuf(PVBOXDISPIFESCAPE_DBGDUMPBUF pBuf, uint32_t cbBuffer);
|
---|
162 |
|
---|
163 | #if 0
|
---|
164 | /* wine shrc handle -> allocation map */
|
---|
165 | VOID vboxShRcTreeInit(PVBOXMP_DEVEXT pDevExt);
|
---|
166 | VOID vboxShRcTreeTerm(PVBOXMP_DEVEXT pDevExt);
|
---|
167 | BOOLEAN vboxShRcTreePut(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
168 | PVBOXWDDM_ALLOCATION vboxShRcTreeGet(PVBOXMP_DEVEXT pDevExt, HANDLE hSharedRc);
|
---|
169 | BOOLEAN vboxShRcTreeRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | NTSTATUS vboxWddmDrvCfgInit(PUNICODE_STRING pRegStr);
|
---|
173 |
|
---|
174 | #ifdef VBOX_VDMA_WITH_WATCHDOG
|
---|
175 | NTSTATUS vboxWddmWdInit(PVBOXMP_DEVEXT pDevExt);
|
---|
176 | NTSTATUS vboxWddmWdTerm(PVBOXMP_DEVEXT pDevExt);
|
---|
177 | #endif
|
---|
178 |
|
---|
179 | NTSTATUS VBoxWddmSlEnableVSyncNotification(PVBOXMP_DEVEXT pDevExt, BOOLEAN fEnable);
|
---|
180 | NTSTATUS VBoxWddmSlGetScanLine(PVBOXMP_DEVEXT pDevExt, DXGKARG_GETSCANLINE *pSl);
|
---|
181 | NTSTATUS VBoxWddmSlInit(PVBOXMP_DEVEXT pDevExt);
|
---|
182 | NTSTATUS VBoxWddmSlTerm(PVBOXMP_DEVEXT pDevExt);
|
---|
183 |
|
---|
184 | #ifdef VBOX_WDDM_WIN8
|
---|
185 | void vboxWddmDiInitDefault(DXGK_DISPLAY_INFORMATION *pInfo, PHYSICAL_ADDRESS PhAddr, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId);
|
---|
186 | void vboxWddmDiToAllocData(PVBOXMP_DEVEXT pDevExt, const DXGK_DISPLAY_INFORMATION *pInfo, struct VBOXWDDM_ALLOC_DATA *pAllocData);
|
---|
187 | void vboxWddmDmAdjustDefaultVramLocations(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID ModifiedVidPnSourceId, struct VBOXWDDM_SOURCE *paSources);
|
---|
188 | #endif
|
---|
189 |
|
---|
190 | NTSTATUS vboxWddmChildStatusConnect(PVBOXMP_DEVEXT pDevExt, uint32_t iChild, BOOLEAN fConnect);
|
---|
191 |
|
---|
192 | #endif /* #ifndef ___VBoxMPMisc_h__ */
|
---|