1 | /** @file
|
---|
2 | * VirtualBox Video driver, common code - iprt and VirtualBox macros and
|
---|
3 | * definitions.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included in
|
---|
17 | * all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
23 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
25 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef ___VBox_Graphic_VBoxVideoIPRT_h
|
---|
29 | #define ___VBox_Graphic_VBoxVideoIPRT_h
|
---|
30 |
|
---|
31 | #include <asm/io.h>
|
---|
32 | #include <linux/string.h>
|
---|
33 | #include <linux/version.h>
|
---|
34 |
|
---|
35 | /** @name VirtualBox error macros
|
---|
36 | * @{ */
|
---|
37 |
|
---|
38 | #define VINF_SUCCESS 0
|
---|
39 | #define VERR_INVALID_PARAMETER (-2)
|
---|
40 | #define VERR_INVALID_POINTER (-6)
|
---|
41 | #define VERR_NO_MEMORY (-8)
|
---|
42 | #define VERR_NOT_IMPLEMENTED (-12)
|
---|
43 | #define VERR_INVALID_FUNCTION (-36)
|
---|
44 | #define VERR_NOT_SUPPORTED (-37)
|
---|
45 | #define VERR_TOO_MUCH_DATA (-42)
|
---|
46 | #define VERR_INVALID_STATE (-79)
|
---|
47 | #define VERR_OUT_OF_RESOURCES (-80)
|
---|
48 | #define VERR_ALREADY_EXISTS (-105)
|
---|
49 | #define VERR_INTERNAL_ERROR (-225)
|
---|
50 |
|
---|
51 | #define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS )
|
---|
52 | #define RT_SUCCESS(rc) ( likely(RT_SUCCESS_NP(rc)) )
|
---|
53 | #define RT_FAILURE(rc) ( unlikely(!RT_SUCCESS_NP(rc)) )
|
---|
54 |
|
---|
55 | /** @} */
|
---|
56 |
|
---|
57 | /** @name VirtualBox helper functions
|
---|
58 | * @{ */
|
---|
59 |
|
---|
60 | #define ASMCompilerBarrier() mb()
|
---|
61 |
|
---|
62 | /** @} */
|
---|
63 |
|
---|
64 | /** @name VirtualBox assertions
|
---|
65 | * @{ */
|
---|
66 |
|
---|
67 | #define Assert(a) WARN_ON_ONCE(!(a))
|
---|
68 | #define AssertPtr(a) WARN_ON_ONCE(!(a))
|
---|
69 | #define AssertReturnVoid(a) do { if (WARN_ON_ONCE(!(a))) return; } while(0)
|
---|
70 | #define AssertRC(a) WARN_ON_ONCE(RT_FAILURE(a))
|
---|
71 | #define AssertPtrNullReturnVoid(a) do {} while(0)
|
---|
72 | #define AssertPtrReturnVoid(a) do { if (WARN_ON_ONCE(!(a))) return; } while(0)
|
---|
73 |
|
---|
74 | extern int RTASSERTVAR[1];
|
---|
75 | #define AssertCompile(expr) \
|
---|
76 | extern int RTASSERTVAR[1] __attribute__((__unused__)), \
|
---|
77 | RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
|
---|
78 | #define AssertCompileSize(type, size) \
|
---|
79 | AssertCompile(sizeof(type) == (size))
|
---|
80 |
|
---|
81 | #define VALID_PTR(p) ((p) != NULL)
|
---|
82 |
|
---|
83 | /** @} */
|
---|
84 |
|
---|
85 | /** @name Port I/O helpers
|
---|
86 | * @{ */
|
---|
87 | /** Write an 8-bit value to an I/O port. */
|
---|
88 | #define VBVO_PORT_WRITE_U8(Port, Value) \
|
---|
89 | outb(Value, Port)
|
---|
90 | /** Write a 16-bit value to an I/O port. */
|
---|
91 | #define VBVO_PORT_WRITE_U16(Port, Value) \
|
---|
92 | outw(Value, Port)
|
---|
93 | /** Write a 32-bit value to an I/O port. */
|
---|
94 | #define VBVO_PORT_WRITE_U32(Port, Value) \
|
---|
95 | outl(Value, Port)
|
---|
96 | /** Read an 8-bit value from an I/O port. */
|
---|
97 | #define VBVO_PORT_READ_U8(Port) \
|
---|
98 | inb(Port)
|
---|
99 | /** Read a 16-bit value from an I/O port. */
|
---|
100 | #define VBVO_PORT_READ_U16(Port) \
|
---|
101 | inw(Port)
|
---|
102 | /** Read a 32-bit value from an I/O port. */
|
---|
103 | #define VBVO_PORT_READ_U32(Port) \
|
---|
104 | inl(Port)
|
---|
105 |
|
---|
106 | /** @} */
|
---|
107 |
|
---|
108 | /** @name types for VirtualBox OS-independent code
|
---|
109 | * @{ */
|
---|
110 |
|
---|
111 | typedef void RTRECT;
|
---|
112 |
|
---|
113 | #define UINT32_C(val) (val ## U)
|
---|
114 | #define UINT32_MAX UINT32_C(0xffffffff)
|
---|
115 |
|
---|
116 | /** @} */
|
---|
117 |
|
---|
118 | /** @name iprt/desc.h replacement macros
|
---|
119 | * @{ */
|
---|
120 |
|
---|
121 | #define RT_C_DECLS_BEGIN
|
---|
122 | #define RT_C_DECLS_END
|
---|
123 | #define DECLCALLBACK(type) type
|
---|
124 | #define DECLCALLBACKMEMBER(type, name) type (*name)
|
---|
125 | #define DECLHIDDEN(type) __attribute__((visibility("hidden"))) type
|
---|
126 | #define DECLINLINE(type) static __inline__ type
|
---|
127 | #define RT_BOOL(val) (!!(val))
|
---|
128 | #define RT_BIT BIT
|
---|
129 | #define _1K 0x00000400
|
---|
130 |
|
---|
131 | /** @} */
|
---|
132 |
|
---|
133 | #endif /* !___VBox_Graphic_VBoxVideoIPRT_h */
|
---|
134 |
|
---|