VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/VBoxVideoIPRT.h@ 66940

最後變更 在這個檔案從66940是 66707,由 vboxsync 提交於 8 年 前

bugref:8524: Additions/linux: play nicely with distribution-installed Additions
Fix an inverted Assert to WARN_ON mapping and convert all WARN_ON calls to WARN_ON_ONCE to avoid flooding the system log if an assertion triggers often.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.8 KB
 
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_VBoxVideoIPRT_h
29#define ___VBox_VBoxVideoIPRT_h
30
31#include <asm/atomic.h>
32#include <asm/io.h>
33#include <iprt/cdefs.h>
34#include <iprt/list.h>
35#include <iprt/stdarg.h>
36#include <iprt/stdint.h>
37
38#include <linux/string.h>
39
40/** @name VirtualBox error macros
41 * @{ */
42
43#define VINF_SUCCESS 0
44#define VERR_INVALID_PARAMETER (-2)
45#define VERR_INVALID_POINTER (-6)
46#define VERR_NO_MEMORY (-8)
47#define VERR_NOT_IMPLEMENTED (-12)
48#define VERR_INVALID_FUNCTION (-36)
49#define VERR_NOT_SUPPORTED (-37)
50#define VERR_TOO_MUCH_DATA (-42)
51#define VERR_INVALID_STATE (-79)
52#define VERR_OUT_OF_RESOURCES (-80)
53#define VERR_ALREADY_EXISTS (-105)
54#define VERR_INTERNAL_ERROR (-225)
55
56#define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS )
57#define RT_SUCCESS(rc) ( likely(RT_SUCCESS_NP(rc)) )
58#define RT_FAILURE(rc) ( unlikely(!RT_SUCCESS_NP(rc)) )
59
60/** @} */
61
62/** @name VirtualBox helper functions
63 * @{ */
64
65#define RT_ZERO(x) memset(&(x), 0, sizeof(x))
66#define ASMAtomicCmpXchgBool(b, new_val, old_val) \
67 (cmpxchg(b, old_val, new_val) == old_val)
68#define ASMAtomicWriteBool(b, val) xchg(b, val)
69#define ASMCompilerBarrier() mb()
70
71/** @} */
72
73/** @name VirtualBox assertions
74 * @{ */
75
76#define Assert(a) WARN_ON_ONCE(!(a))
77#define AssertPtr(a) WARN_ON_ONCE(!(a))
78#define AssertReturnVoid(a) do { if (WARN_ON_ONCE(!(a))) return; } while(0)
79#define AssertRC(a) WARN_ON_ONCE(RT_FAILURE(a))
80#define AssertPtrNullReturnVoid(a) do {} while(0)
81#define AssertPtrReturnVoid(a) do { if (WARN_ON_ONCE(!(a))) return; } while(0)
82
83extern int RTASSERTVAR[1];
84#define AssertCompile(expr) \
85 extern int RTASSERTVAR[1] __attribute__((__unused__)), \
86 RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
87#define AssertCompileSize(type, size) \
88 AssertCompile(sizeof(type) == (size))
89
90/** @} */
91
92/** @name Port I/O helpers
93 * @{ */
94/** Write an 8-bit value to an I/O port. */
95#define VBVO_PORT_WRITE_U8(Port, Value) \
96 outb(Value, Port)
97/** Write a 16-bit value to an I/O port. */
98#define VBVO_PORT_WRITE_U16(Port, Value) \
99 outw(Value, Port)
100/** Write a 32-bit value to an I/O port. */
101#define VBVO_PORT_WRITE_U32(Port, Value) \
102 outl(Value, Port)
103/** Read an 8-bit value from an I/O port. */
104#define VBVO_PORT_READ_U8(Port) \
105 inb(Port)
106/** Read a 16-bit value from an I/O port. */
107#define VBVO_PORT_READ_U16(Port) \
108 inw(Port)
109/** Read a 32-bit value from an I/O port. */
110#define VBVO_PORT_READ_U32(Port) \
111 inl(Port)
112
113/** @} */
114
115#endif /* ___VBox_VBoxVideoIPRT_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette