1 | /* $Id: VBoxMPUtils.h 36867 2011-04-28 07:27:03Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox Miniport common utils header
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2011 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 VBOXMPUTILS_H
|
---|
20 | #define VBOXMPUTILS_H
|
---|
21 |
|
---|
22 | /*Sanity check*/
|
---|
23 | #if defined(VBOX_XPDM_MINIPORT)==defined(VBOX_WDDM_MINIPORT)
|
---|
24 | #error One of the VBOX_XPDM_MINIPORT or VBOX_WDDM_MINIPORT should be defined!
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #include <iprt/cdefs.h>
|
---|
28 | #define LOG_GROUP LOG_GROUP_DRV_MINIPORT
|
---|
29 | #include <VBox/log.h>
|
---|
30 | #define VBOX_VIDEO_LOG_NAME "VBoxMP"
|
---|
31 | #include "common/VBoxVideoLog.h"
|
---|
32 | #include <iprt/err.h>
|
---|
33 | #include <iprt/assert.h>
|
---|
34 |
|
---|
35 | RT_C_DECLS_BEGIN
|
---|
36 | #ifdef VBOX_XPDM_MINIPORT
|
---|
37 | # include <dderror.h>
|
---|
38 | # include <devioctl.h>
|
---|
39 | #else
|
---|
40 | # ifdef PAGE_SIZE
|
---|
41 | # undef PAGE_SIZE
|
---|
42 | # endif
|
---|
43 | # ifdef PAGE_SHIFT
|
---|
44 | # undef PAGE_SHIFT
|
---|
45 | # endif
|
---|
46 | # define VBOX_WITH_WORKAROUND_MISSING_PACK
|
---|
47 | # if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
|
---|
48 | # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
|
---|
49 | # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
|
---|
50 | # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
|
---|
51 | # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
|
---|
52 | # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
|
---|
53 | # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
|
---|
54 | # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
|
---|
55 | # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
|
---|
56 | # pragma warning(disable : 4163)
|
---|
57 | # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
|
---|
58 | # pragma warning(disable : 4103)
|
---|
59 | # endif
|
---|
60 | # include <ntddk.h>
|
---|
61 | # pragma warning(default : 4163)
|
---|
62 | # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
|
---|
63 | # pragma pack()
|
---|
64 | # pragma warning(default : 4103)
|
---|
65 | # endif
|
---|
66 | # undef _InterlockedExchange
|
---|
67 | # undef _InterlockedExchangeAdd
|
---|
68 | # undef _InterlockedCompareExchange
|
---|
69 | # undef _InterlockedAddLargeStatistic
|
---|
70 | # undef _interlockedbittestandset
|
---|
71 | # undef _interlockedbittestandreset
|
---|
72 | # undef _interlockedbittestandset64
|
---|
73 | # undef _interlockedbittestandreset64
|
---|
74 | # else
|
---|
75 | # include <ntddk.h>
|
---|
76 | # endif
|
---|
77 | # include <dispmprt.h>
|
---|
78 | # include <ntddvdeo.h>
|
---|
79 | # include <dderror.h>
|
---|
80 | #endif
|
---|
81 | RT_C_DECLS_END
|
---|
82 |
|
---|
83 | /*Windows version identifier*/
|
---|
84 | typedef enum
|
---|
85 | {
|
---|
86 | UNKNOWN_WINVERSION = 0,
|
---|
87 | WINNT4 = 1,
|
---|
88 | WIN2K = 2,
|
---|
89 | WINXP = 3,
|
---|
90 | WINVISTA = 4,
|
---|
91 | WIN7 = 5
|
---|
92 | } vboxWinVersion_t;
|
---|
93 |
|
---|
94 | RT_C_DECLS_BEGIN
|
---|
95 | vboxWinVersion_t VBoxQueryWinVersion();
|
---|
96 | uint32_t VBoxGetHeightReduction();
|
---|
97 | bool VBoxLikesVideoMode(uint32_t display, uint32_t width, uint32_t height, uint32_t bpp);
|
---|
98 | bool VBoxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId);
|
---|
99 | bool VBoxQueryHostWantsAbsolute();
|
---|
100 | bool VBoxQueryPointerPos(uint16_t *pPosX, uint16_t *pPosY);
|
---|
101 | RT_C_DECLS_END
|
---|
102 |
|
---|
103 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES 4*_1M
|
---|
104 |
|
---|
105 | #define VBOXMP_WARN_VPS(_vps) \
|
---|
106 | if ((_vps) != NO_ERROR) \
|
---|
107 | { \
|
---|
108 | WARN(("vps(%#x)!=NO_ERROR")); \
|
---|
109 | }
|
---|
110 |
|
---|
111 | #define VBOXMP_CHECK_VPS_BREAK(_vps) \
|
---|
112 | if ((_vps) != NO_ERROR) \
|
---|
113 | { \
|
---|
114 | break; \
|
---|
115 | }
|
---|
116 |
|
---|
117 | #ifdef DEBUG_misha
|
---|
118 | /* specifies whether the vboxVDbgBreakF should break in the debugger
|
---|
119 | * windbg seems to have some issues when there is a lot ( >~50) of sw breakpoints defined
|
---|
120 | * to simplify things we just insert breaks for the case of intensive debugging WDDM driver*/
|
---|
121 | extern bool g_bVBoxVDbgBreakF;
|
---|
122 | extern bool g_bVBoxVDbgBreakFv;
|
---|
123 | #define vboxVDbgBreakF() do { if (g_bVBoxVDbgBreakF) AssertBreakpoint(); } while (0)
|
---|
124 | #define vboxVDbgBreakFv() do { if (g_bVBoxVDbgBreakFv) AssertBreakpoint(); } while (0)
|
---|
125 | #else
|
---|
126 | #define vboxVDbgBreakF() do { } while (0)
|
---|
127 | #define vboxVDbgBreakFv() do { } while (0)
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | #endif /*VBOXMPUTILS_H*/
|
---|