1 | /* $Id: VBoxMPUtils.h 76563 2019-01-01 03:53:56Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Miniport common utils header
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2019 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_common_VBoxMPUtils_h
|
---|
19 | #define GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_common_VBoxMPUtils_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /*Sanity check*/
|
---|
25 | #if defined(VBOX_XPDM_MINIPORT) == defined(VBOX_WDDM_MINIPORT)
|
---|
26 | # error One of the VBOX_XPDM_MINIPORT or VBOX_WDDM_MINIPORT should be defined!
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #define LOG_GROUP LOG_GROUP_DRV_MINIPORT
|
---|
31 | #include <VBox/log.h>
|
---|
32 |
|
---|
33 | #define VBOX_VIDEO_LOG_NAME "VBoxMP"
|
---|
34 | #ifdef VBOX_WDDM_MINIPORT
|
---|
35 | # ifndef VBOX_WDDM_MINIPORT_WITH_FLOW_LOGGING
|
---|
36 | # define VBOX_VIDEO_LOGFLOW_LOGGER(_m) do {} while (0)
|
---|
37 | # endif
|
---|
38 | #endif
|
---|
39 | #include "common/VBoxVideoLog.h"
|
---|
40 |
|
---|
41 | #include <iprt/err.h>
|
---|
42 | #include <iprt/assert.h>
|
---|
43 |
|
---|
44 | #ifdef VBOX_XPDM_MINIPORT
|
---|
45 | # include <dderror.h>
|
---|
46 | # include <devioctl.h>
|
---|
47 | #else
|
---|
48 | # undef PAGE_SIZE
|
---|
49 | # undef PAGE_SHIFT
|
---|
50 | # include <iprt/nt/ntddk.h>
|
---|
51 | # include <iprt/nt/dispmprt.h>
|
---|
52 | # include <ntddvdeo.h>
|
---|
53 | # include <dderror.h>
|
---|
54 | #endif
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 | /*Windows version identifier*/
|
---|
59 | typedef enum
|
---|
60 | {
|
---|
61 | WINVERSION_UNKNOWN = 0,
|
---|
62 | WINVERSION_NT4 = 1,
|
---|
63 | WINVERSION_2K = 2,
|
---|
64 | WINVERSION_XP = 3,
|
---|
65 | WINVERSION_VISTA = 4,
|
---|
66 | WINVERSION_7 = 5,
|
---|
67 | WINVERSION_8 = 6,
|
---|
68 | WINVERSION_81 = 7,
|
---|
69 | WINVERSION_10 = 8
|
---|
70 | } vboxWinVersion_t;
|
---|
71 |
|
---|
72 | RT_C_DECLS_BEGIN
|
---|
73 | vboxWinVersion_t VBoxQueryWinVersion(uint32_t *pbuild);
|
---|
74 | uint32_t VBoxGetHeightReduction(void);
|
---|
75 | bool VBoxLikesVideoMode(uint32_t display, uint32_t width, uint32_t height, uint32_t bpp);
|
---|
76 | bool VBoxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId);
|
---|
77 | bool VBoxQueryHostWantsAbsolute(void);
|
---|
78 | bool VBoxQueryPointerPos(uint16_t *pPosX, uint16_t *pPosY);
|
---|
79 | RT_C_DECLS_END
|
---|
80 |
|
---|
81 |
|
---|
82 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (4*_1M)
|
---|
83 |
|
---|
84 | #define VBOXMP_WARN_VPS_NOBP(_vps) \
|
---|
85 | if ((_vps) != NO_ERROR) \
|
---|
86 | { \
|
---|
87 | WARN_NOBP(("vps(%#x)!=NO_ERROR", _vps)); \
|
---|
88 | } else do { } while (0)
|
---|
89 |
|
---|
90 | #define VBOXMP_WARN_VPS(_vps) \
|
---|
91 | if ((_vps) != NO_ERROR) \
|
---|
92 | { \
|
---|
93 | WARN(("vps(%#x)!=NO_ERROR", _vps)); \
|
---|
94 | } else do { } while (0)
|
---|
95 |
|
---|
96 |
|
---|
97 | #define VBOXMP_CHECK_VPS_BREAK(_vps) \
|
---|
98 | if ((_vps) != NO_ERROR) \
|
---|
99 | { \
|
---|
100 | break; \
|
---|
101 | } else do { } while (0)
|
---|
102 |
|
---|
103 |
|
---|
104 | #ifdef DEBUG_misha
|
---|
105 | /* specifies whether the vboxVDbgBreakF should break in the debugger
|
---|
106 | * windbg seems to have some issues when there is a lot ( >~50) of sw breakpoints defined
|
---|
107 | * to simplify things we just insert breaks for the case of intensive debugging WDDM driver*/
|
---|
108 | extern int g_bVBoxVDbgBreakF;
|
---|
109 | extern int g_bVBoxVDbgBreakFv;
|
---|
110 | # define vboxVDbgBreakF() do { if (g_bVBoxVDbgBreakF) AssertBreakpoint(); } while (0)
|
---|
111 | # define vboxVDbgBreakFv() do { if (g_bVBoxVDbgBreakFv) AssertBreakpoint(); } while (0)
|
---|
112 | #else
|
---|
113 | # define vboxVDbgBreakF() do { } while (0)
|
---|
114 | # define vboxVDbgBreakFv() do { } while (0)
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_common_VBoxMPUtils_h */
|
---|
118 |
|
---|