1 | /** @file
|
---|
2 | * VirtualBox Video driver, common code - iprt and VirtualBox macros and definitions.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2017 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ___VBox_Graphics_VBoxVideoIPRT_h
|
---|
18 | #define ___VBox_Graphics_VBoxVideoIPRT_h
|
---|
19 |
|
---|
20 | #ifndef RT_OS_OS2
|
---|
21 | # include <iprt/asm.h>
|
---|
22 | # include <iprt/string.h>
|
---|
23 | #endif
|
---|
24 | #include <iprt/assert.h>
|
---|
25 | #include <iprt/cdefs.h>
|
---|
26 | #include <iprt/err.h>
|
---|
27 | #include <iprt/list.h>
|
---|
28 | #include <iprt/stdarg.h>
|
---|
29 | #include <iprt/stdint.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 |
|
---|
32 | #if !defined VBOX_XPDM_MINIPORT && !defined VBOX_GUESTR3XORGMOD && !defined RT_OS_OS2
|
---|
33 | # include <iprt/asm-amd64-x86.h>
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #ifdef VBOX_XPDM_MINIPORT
|
---|
37 | # include <iprt/nt/miniport.h>
|
---|
38 | # include <ntddvdeo.h> /* sdk, clean */
|
---|
39 | # include <iprt/nt/Video.h>
|
---|
40 | #elif defined VBOX_GUESTR3XORGMOD
|
---|
41 | # include <compiler.h>
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | /** @name Port I/O helpers
|
---|
45 | * @{ */
|
---|
46 |
|
---|
47 | #ifdef VBOX_XPDM_MINIPORT
|
---|
48 |
|
---|
49 | /** Write an 8-bit value to an I/O port. */
|
---|
50 | # define VBVO_PORT_WRITE_U8(Port, Value) \
|
---|
51 | VideoPortWritePortUchar((PUCHAR)Port, Value)
|
---|
52 | /** Write a 16-bit value to an I/O port. */
|
---|
53 | # define VBVO_PORT_WRITE_U16(Port, Value) \
|
---|
54 | VideoPortWritePortUshort((PUSHORT)Port, Value)
|
---|
55 | /** Write a 32-bit value to an I/O port. */
|
---|
56 | # define VBVO_PORT_WRITE_U32(Port, Value) \
|
---|
57 | VideoPortWritePortUlong((PULONG)Port, Value)
|
---|
58 | /** Read an 8-bit value from an I/O port. */
|
---|
59 | # define VBVO_PORT_READ_U8(Port) \
|
---|
60 | VideoPortReadPortUchar((PUCHAR)Port)
|
---|
61 | /** Read a 16-bit value from an I/O port. */
|
---|
62 | # define VBVO_PORT_READ_U16(Port) \
|
---|
63 | VideoPortReadPortUshort((PUSHORT)Port)
|
---|
64 | /** Read a 32-bit value from an I/O port. */
|
---|
65 | # define VBVO_PORT_READ_U32(Port) \
|
---|
66 | VideoPortReadPortUlong((PULONG)Port)
|
---|
67 |
|
---|
68 | #elif defined(VBOX_GUESTR3XORGMOD)
|
---|
69 |
|
---|
70 | /** Write an 8-bit value to an I/O port. */
|
---|
71 | # define VBVO_PORT_WRITE_U8(Port, Value) \
|
---|
72 | outb(Port, Value)
|
---|
73 | /** Write a 16-bit value to an I/O port. */
|
---|
74 | # define VBVO_PORT_WRITE_U16(Port, Value) \
|
---|
75 | outw(Port, Value)
|
---|
76 | /** Write a 32-bit value to an I/O port. */
|
---|
77 | # define VBVO_PORT_WRITE_U32(Port, Value) \
|
---|
78 | outl(Port, Value)
|
---|
79 | /** Read an 8-bit value from an I/O port. */
|
---|
80 | # define VBVO_PORT_READ_U8(Port) \
|
---|
81 | inb(Port)
|
---|
82 | /** Read a 16-bit value from an I/O port. */
|
---|
83 | # define VBVO_PORT_READ_U16(Port) \
|
---|
84 | inw(Port)
|
---|
85 | /** Read a 32-bit value from an I/O port. */
|
---|
86 | # define VBVO_PORT_READ_U32(Port) \
|
---|
87 | inl(Port)
|
---|
88 |
|
---|
89 | #else /** @todo make these explicit */
|
---|
90 |
|
---|
91 | /** Write an 8-bit value to an I/O port. */
|
---|
92 | # define VBVO_PORT_WRITE_U8(Port, Value) \
|
---|
93 | ASMOutU8(Port, Value)
|
---|
94 | /** Write a 16-bit value to an I/O port. */
|
---|
95 | # define VBVO_PORT_WRITE_U16(Port, Value) \
|
---|
96 | ASMOutU16(Port, Value)
|
---|
97 | /** Write a 32-bit value to an I/O port. */
|
---|
98 | # define VBVO_PORT_WRITE_U32(Port, Value) \
|
---|
99 | ASMOutU32(Port, Value)
|
---|
100 | /** Read an 8-bit value from an I/O port. */
|
---|
101 | # define VBVO_PORT_READ_U8(Port) \
|
---|
102 | ASMInU8(Port)
|
---|
103 | /** Read a 16-bit value from an I/O port. */
|
---|
104 | # define VBVO_PORT_READ_U16(Port) \
|
---|
105 | ASMInU16(Port)
|
---|
106 | /** Read a 32-bit value from an I/O port. */
|
---|
107 | # define VBVO_PORT_READ_U32(Port) \
|
---|
108 | ASMInU32(Port)
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | /** @} */
|
---|
112 |
|
---|
113 | #endif
|
---|
114 |
|
---|