1 | /* $Id: VMMDevTesting.h 93754 2022-02-15 14:29:56Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Testing Extensions.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2022 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 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef VBOX_INCLUDED_VMMDevTesting_h
|
---|
28 | #define VBOX_INCLUDED_VMMDevTesting_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <VBox/types.h>
|
---|
34 |
|
---|
35 |
|
---|
36 | /** @defgroup grp_vmmdev_testing VMM Device Testing
|
---|
37 | * @ingroup grp_vmmdev
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /** The base address of the MMIO range used for testing.
|
---|
42 | * @remarks This used to be at 0x101000 but moved to 0xdf000 so that it would
|
---|
43 | * work better with prototype NEM code. This also means enabling A20
|
---|
44 | * is not a requirement. */
|
---|
45 | #define VMMDEV_TESTING_MMIO_BASE UINT32_C(0x000df000)
|
---|
46 | /** The size of the MMIO range used for testing. */
|
---|
47 | #define VMMDEV_TESTING_MMIO_SIZE UINT32_C(0x00001000)
|
---|
48 |
|
---|
49 | /** MMIO offset: The NOP register - 1248 RW. */
|
---|
50 | #define VMMDEV_TESTING_MMIO_OFF_NOP (0x000)
|
---|
51 | /** MMIO offset: The go-to-ring-3-NOP register - 1248 RW. */
|
---|
52 | #define VMMDEV_TESTING_MMIO_OFF_NOP_R3 (0x008)
|
---|
53 | /** MMIO offset: The readback registers - 64 bytes of read/write "memory". */
|
---|
54 | #define VMMDEV_TESTING_MMIO_OFF_READBACK (0x040)
|
---|
55 | /** MMIO offset: Readback register view that always goes to ring-3. */
|
---|
56 | #define VMMDEV_TESTING_MMIO_OFF_READBACK_R3 (0x080)
|
---|
57 | /** The size of the MMIO readback registers. */
|
---|
58 | #define VMMDEV_TESTING_READBACK_SIZE (0x40)
|
---|
59 |
|
---|
60 | /** Default address of VMMDEV_TESTING_MMIO_OFF_NOP. */
|
---|
61 | #define VMMDEV_TESTING_MMIO_NOP (VMMDEV_TESTING_MMIO_BASE + VMMDEV_TESTING_MMIO_OFF_NOP)
|
---|
62 | /** Default address of VMMDEV_TESTING_MMIO_OFF_NOP_R3. */
|
---|
63 | #define VMMDEV_TESTING_MMIO_NOP_R3 (VMMDEV_TESTING_MMIO_BASE + VMMDEV_TESTING_MMIO_OFF_NOP_R3)
|
---|
64 | /** Default address of VMMDEV_TESTING_MMIO_OFF_READBACK. */
|
---|
65 | #define VMMDEV_TESTING_MMIO_READBACK (VMMDEV_TESTING_MMIO_BASE + VMMDEV_TESTING_MMIO_OFF_READBACK)
|
---|
66 | /** Default address of VMMDEV_TESTING_MMIO_OFF_READBACK_R3. */
|
---|
67 | #define VMMDEV_TESTING_MMIO_READBACK_R3 (VMMDEV_TESTING_MMIO_BASE + VMMDEV_TESTING_MMIO_OFF_READBACK_R3)
|
---|
68 |
|
---|
69 | /** The real mode selector to use. */
|
---|
70 | #define VMMDEV_TESTING_MMIO_RM_SEL 0xdf00
|
---|
71 | /** Calculate the real mode offset of a MMIO register. */
|
---|
72 | #define VMMDEV_TESTING_MMIO_RM_OFF(val) ((val) - VMMDEV_TESTING_MMIO_BASE)
|
---|
73 | /** Calculate the real mode offset of a MMIO register offset. */
|
---|
74 | #define VMMDEV_TESTING_MMIO_RM_OFF2(off) (off)
|
---|
75 |
|
---|
76 | /** The base port of the I/O range used for testing. */
|
---|
77 | #define VMMDEV_TESTING_IOPORT_BASE 0x0510
|
---|
78 | /** The number of I/O ports reserved for testing. */
|
---|
79 | #define VMMDEV_TESTING_IOPORT_COUNT 0x0010
|
---|
80 | /** The NOP I/O port - 1,2,4 RW. */
|
---|
81 | #define VMMDEV_TESTING_IOPORT_NOP (VMMDEV_TESTING_IOPORT_BASE + 0)
|
---|
82 | /** The low nanosecond timestamp - 4 RO. */
|
---|
83 | #define VMMDEV_TESTING_IOPORT_TS_LOW (VMMDEV_TESTING_IOPORT_BASE + 1)
|
---|
84 | /** The high nanosecond timestamp - 4 RO. Read this after the low one! */
|
---|
85 | #define VMMDEV_TESTING_IOPORT_TS_HIGH (VMMDEV_TESTING_IOPORT_BASE + 2)
|
---|
86 | /** Command register usually used for preparing the data register - 4/2 WO. */
|
---|
87 | #define VMMDEV_TESTING_IOPORT_CMD (VMMDEV_TESTING_IOPORT_BASE + 3)
|
---|
88 | /** Data register which use depends on the current command - 1s, 4 WO. */
|
---|
89 | #define VMMDEV_TESTING_IOPORT_DATA (VMMDEV_TESTING_IOPORT_BASE + 4)
|
---|
90 | /** The go-to-ring-3-NOP I/O port - 1,2,4 RW. */
|
---|
91 | #define VMMDEV_TESTING_IOPORT_NOP_R3 (VMMDEV_TESTING_IOPORT_BASE + 5)
|
---|
92 | /** Take the VMMDev lock in arrival context and return - 1,2,4 RW.
|
---|
93 | * Writing configures counter action by a thread taking the lock to trigger
|
---|
94 | * contention:
|
---|
95 | * - bits 15:0: Number of microseconds thread should hold lock.
|
---|
96 | * - bits 31:16: Number of microseconds thread should wait before locking
|
---|
97 | * again. */
|
---|
98 | #define VMMDEV_TESTING_IOPORT_LOCKED_LO (VMMDEV_TESTING_IOPORT_BASE + 6)
|
---|
99 | /** Take the VMMDev lock in arrival context and return - 1,2,4 RW.
|
---|
100 | * Writing configures counter action by a thread taking the lock to trigger
|
---|
101 | * contention:
|
---|
102 | * - bits 19:0: Number of kilo (1024) ticks the EMT should hold lock.
|
---|
103 | * - bits 25:20: Reserved, must be zero.
|
---|
104 | * - bit 26: Thread takes lock in shared mode when set, exclusive when clear.
|
---|
105 | * - bit 27: EMT takes lock in shared mode when set, exclusive when clear.
|
---|
106 | * - bit 28: Use read/write critical section when set, device section if clear.
|
---|
107 | * - bit 29: EMT passes VINF_SUCCESS as rcBusy when set.
|
---|
108 | * - bit 30: Makes thread poke all EMTs before release lock.
|
---|
109 | * - bit 31: Enables the thread. */
|
---|
110 | #define VMMDEV_TESTING_IOPORT_LOCKED_HI (VMMDEV_TESTING_IOPORT_BASE + 7)
|
---|
111 |
|
---|
112 | /** @name Commands.
|
---|
113 | * @{ */
|
---|
114 | /** Initialize test, sending name (zero terminated string). (RTTestCreate) */
|
---|
115 | #define VMMDEV_TESTING_CMD_INIT UINT32_C(0xcab1e000)
|
---|
116 | /** Test done, sending 32-bit total error count with it. (RTTestSummaryAndDestroy) */
|
---|
117 | #define VMMDEV_TESTING_CMD_TERM UINT32_C(0xcab1e001)
|
---|
118 | /** Start a new sub-test, sending name (zero terminated string). (RTTestSub) */
|
---|
119 | #define VMMDEV_TESTING_CMD_SUB_NEW UINT32_C(0xcab1e002)
|
---|
120 | /** Sub-test is done, sending 32-bit error count for it. (RTTestDone) */
|
---|
121 | #define VMMDEV_TESTING_CMD_SUB_DONE UINT32_C(0xcab1e003)
|
---|
122 | /** Report a failure, sending reason (zero terminated string). (RTTestFailed) */
|
---|
123 | #define VMMDEV_TESTING_CMD_FAILED UINT32_C(0xcab1e004)
|
---|
124 | /** Report a value, sending the 64-bit value (2x4), the 32-bit unit (4), and
|
---|
125 | * finally the name (zero terminated string). (RTTestValue) */
|
---|
126 | #define VMMDEV_TESTING_CMD_VALUE UINT32_C(0xcab1e005)
|
---|
127 | /** Report a failure, sending reason (zero terminated string). (RTTestSkipped) */
|
---|
128 | #define VMMDEV_TESTING_CMD_SKIPPED UINT32_C(0xcab1e006)
|
---|
129 | /** Report a value found in a VMM register, sending a string on the form
|
---|
130 | * "value-name:register-name". */
|
---|
131 | #define VMMDEV_TESTING_CMD_VALUE_REG UINT32_C(0xcab1e007)
|
---|
132 | /** Print string, sending a string including newline. (RTTestPrintf) */
|
---|
133 | #define VMMDEV_TESTING_CMD_PRINT UINT32_C(0xcab1e008)
|
---|
134 | /** Query a config value, sending a 16-bit word (VMMDEV_TESTING_CFG_XXX) to the
|
---|
135 | * DATA port and reading back the result. */
|
---|
136 | #define VMMDEV_TESTING_CMD_QUERY_CFG UINT32_C(0xcab1e009)
|
---|
137 |
|
---|
138 | /** The magic part of the command. */
|
---|
139 | #define VMMDEV_TESTING_CMD_MAGIC UINT32_C(0xcab1e000)
|
---|
140 | /** The magic part of the command. */
|
---|
141 | #define VMMDEV_TESTING_CMD_MAGIC_MASK UINT32_C(0xffffff00)
|
---|
142 | /** The magic high word automatically supplied to 16-bit CMD writes. */
|
---|
143 | #define VMMDEV_TESTING_CMD_MAGIC_HI_WORD UINT32_C(0xcab10000)
|
---|
144 | /** @} */
|
---|
145 |
|
---|
146 | /** @name Value units
|
---|
147 | * @note Same as RTTESTUNIT, see rules here for adding new units.
|
---|
148 | * @{ */
|
---|
149 | #define VMMDEV_TESTING_UNIT_PCT UINT8_C(0x01) /**< Percentage. */
|
---|
150 | #define VMMDEV_TESTING_UNIT_BYTES UINT8_C(0x02) /**< Bytes. */
|
---|
151 | #define VMMDEV_TESTING_UNIT_BYTES_PER_SEC UINT8_C(0x03) /**< Bytes per second. */
|
---|
152 | #define VMMDEV_TESTING_UNIT_KILOBYTES UINT8_C(0x04) /**< Kilobytes. */
|
---|
153 | #define VMMDEV_TESTING_UNIT_KILOBYTES_PER_SEC UINT8_C(0x05) /**< Kilobytes per second. */
|
---|
154 | #define VMMDEV_TESTING_UNIT_MEGABYTES UINT8_C(0x06) /**< Megabytes. */
|
---|
155 | #define VMMDEV_TESTING_UNIT_MEGABYTES_PER_SEC UINT8_C(0x07) /**< Megabytes per second. */
|
---|
156 | #define VMMDEV_TESTING_UNIT_PACKETS UINT8_C(0x08) /**< Packets. */
|
---|
157 | #define VMMDEV_TESTING_UNIT_PACKETS_PER_SEC UINT8_C(0x09) /**< Packets per second. */
|
---|
158 | #define VMMDEV_TESTING_UNIT_FRAMES UINT8_C(0x0a) /**< Frames. */
|
---|
159 | #define VMMDEV_TESTING_UNIT_FRAMES_PER_SEC UINT8_C(0x0b) /**< Frames per second. */
|
---|
160 | #define VMMDEV_TESTING_UNIT_OCCURRENCES UINT8_C(0x0c) /**< Occurrences. */
|
---|
161 | #define VMMDEV_TESTING_UNIT_OCCURRENCES_PER_SEC UINT8_C(0x0d) /**< Occurrences per second. */
|
---|
162 | #define VMMDEV_TESTING_UNIT_CALLS UINT8_C(0x0e) /**< Calls. */
|
---|
163 | #define VMMDEV_TESTING_UNIT_CALLS_PER_SEC UINT8_C(0x0f) /**< Calls per second. */
|
---|
164 | #define VMMDEV_TESTING_UNIT_ROUND_TRIP UINT8_C(0x10) /**< Round trips. */
|
---|
165 | #define VMMDEV_TESTING_UNIT_SECS UINT8_C(0x11) /**< Seconds. */
|
---|
166 | #define VMMDEV_TESTING_UNIT_MS UINT8_C(0x12) /**< Milliseconds. */
|
---|
167 | #define VMMDEV_TESTING_UNIT_NS UINT8_C(0x13) /**< Nanoseconds. */
|
---|
168 | #define VMMDEV_TESTING_UNIT_NS_PER_CALL UINT8_C(0x14) /**< Nanoseconds per call. */
|
---|
169 | #define VMMDEV_TESTING_UNIT_NS_PER_FRAME UINT8_C(0x15) /**< Nanoseconds per frame. */
|
---|
170 | #define VMMDEV_TESTING_UNIT_NS_PER_OCCURRENCE UINT8_C(0x16) /**< Nanoseconds per occurrence. */
|
---|
171 | #define VMMDEV_TESTING_UNIT_NS_PER_PACKET UINT8_C(0x17) /**< Nanoseconds per frame. */
|
---|
172 | #define VMMDEV_TESTING_UNIT_NS_PER_ROUND_TRIP UINT8_C(0x18) /**< Nanoseconds per round trip. */
|
---|
173 | #define VMMDEV_TESTING_UNIT_INSTRS UINT8_C(0x19) /**< Instructions. */
|
---|
174 | #define VMMDEV_TESTING_UNIT_INSTRS_PER_SEC UINT8_C(0x1a) /**< Instructions per second. */
|
---|
175 | #define VMMDEV_TESTING_UNIT_NONE UINT8_C(0x1b) /**< No unit. */
|
---|
176 | #define VMMDEV_TESTING_UNIT_PP1K UINT8_C(0x1c) /**< Parts per thousand (10^-3). */
|
---|
177 | #define VMMDEV_TESTING_UNIT_PP10K UINT8_C(0x1d) /**< Parts per ten thousand (10^-4). */
|
---|
178 | #define VMMDEV_TESTING_UNIT_PPM UINT8_C(0x1e) /**< Parts per million (10^-6). */
|
---|
179 | #define VMMDEV_TESTING_UNIT_PPB UINT8_C(0x1f) /**< Parts per billion (10^-9). */
|
---|
180 | #define VMMDEV_TESTING_UNIT_TICKS UINT8_C(0x20) /**< CPU ticks. */
|
---|
181 | #define VMMDEV_TESTING_UNIT_TICKS_PER_CALL UINT8_C(0x21) /**< CPU ticks per call. */
|
---|
182 | #define VMMDEV_TESTING_UNIT_TICKS_PER_OCCURENCE UINT8_C(0x22) /**< CPU ticks per occurence. */
|
---|
183 | #define VMMDEV_TESTING_UNIT_PAGES UINT8_C(0x23) /**< Page count. */
|
---|
184 | #define VMMDEV_TESTING_UNIT_PAGES_PER_SEC UINT8_C(0x24) /**< Pages per second. */
|
---|
185 | #define VMMDEV_TESTING_UNIT_TICKS_PER_PAGE UINT8_C(0x25) /**< CPU ticks per page. */
|
---|
186 | #define VMMDEV_TESTING_UNIT_NS_PER_PAGE UINT8_C(0x26) /**< Nanoseconds per page. */
|
---|
187 | #define VMMDEV_TESTING_UNIT_PS UINT8_C(0x27) /**< Picoseconds. */
|
---|
188 | #define VMMDEV_TESTING_UNIT_PS_PER_CALL UINT8_C(0x28) /**< Picoseconds per call. */
|
---|
189 | #define VMMDEV_TESTING_UNIT_PS_PER_FRAME UINT8_C(0x29) /**< Picoseconds per frame. */
|
---|
190 | #define VMMDEV_TESTING_UNIT_PS_PER_OCCURRENCE UINT8_C(0x2a) /**< Picoseconds per occurrence. */
|
---|
191 | #define VMMDEV_TESTING_UNIT_PS_PER_PACKET UINT8_C(0x2b) /**< Picoseconds per frame. */
|
---|
192 | #define VMMDEV_TESTING_UNIT_PS_PER_ROUND_TRIP UINT8_C(0x2c) /**< Picoseconds per round trip. */
|
---|
193 | #define VMMDEV_TESTING_UNIT_PS_PER_PAGE UINT8_C(0x2d) /**< Picoseconds per page. */
|
---|
194 | /** @} */
|
---|
195 |
|
---|
196 | /** What the NOP accesses returns. */
|
---|
197 | #define VMMDEV_TESTING_NOP_RET UINT32_C(0x64726962) /* bird */
|
---|
198 |
|
---|
199 | /** @name Low and High Locking Control Dwords
|
---|
200 | * @{ */
|
---|
201 | /** Low Locking Control: Thread lock hold interval in microseconds. */
|
---|
202 | #define VMMDEV_TESTING_LOCKED_LO_HOLD_MASK UINT32_C(0x0000ffff)
|
---|
203 | /** Low Locking Control: Thread wait time in microseconds between locking
|
---|
204 | * attempts. */
|
---|
205 | #define VMMDEV_TESTING_LOCKED_LO_WAIT_MASK UINT32_C(0xffff0000)
|
---|
206 | /** Low Locking Control: Thread wait time shift count. */
|
---|
207 | #define VMMDEV_TESTING_LOCKED_LO_WAIT_SHIFT 16
|
---|
208 | /** High Locking Control: Kilo (1024) ticks the EMT should hold the lock. */
|
---|
209 | #define VMMDEV_TESTING_LOCKED_HI_TICKS_MASK UINT32_C(0x000fffff)
|
---|
210 | /** High Locking Control: Must be zero. */
|
---|
211 | #define VMMDEV_TESTING_LOCKED_HI_MBZ_MASK UINT32_C(0x03f00000)
|
---|
212 | /** High Locking Control: Thread takes lock in shared mode when set, exclusive
|
---|
213 | * when clear. */
|
---|
214 | #define VMMDEV_TESTING_LOCKED_HI_THREAD_SHARED UINT32_C(0x04000000)
|
---|
215 | /** High Locking Control: EMT takes lock in shared mode when set, exclusive
|
---|
216 | * when clear. */
|
---|
217 | #define VMMDEV_TESTING_LOCKED_HI_EMT_SHARED UINT32_C(0x08000000)
|
---|
218 | /** High Locking Control: Use read/write critical section instead of regular. */
|
---|
219 | #define VMMDEV_TESTING_LOCKED_HI_TYPE_RW UINT32_C(0x10000000)
|
---|
220 | /** High Locking Control: EMT takes lock with rcBusy set to VINF_SUCCESS. */
|
---|
221 | #define VMMDEV_TESTING_LOCKED_HI_BUSY_SUCCESS UINT32_C(0x20000000)
|
---|
222 | /** High Locking Control: Thread pokes EMTs before releasing lock. */
|
---|
223 | #define VMMDEV_TESTING_LOCKED_HI_POKE UINT32_C(0x40000000)
|
---|
224 | /** High Locking Control: Thread enabled. */
|
---|
225 | #define VMMDEV_TESTING_LOCKED_HI_ENABLED UINT32_C(0x80000000)
|
---|
226 | /** @} */
|
---|
227 |
|
---|
228 | /** @name VMMDEV_TESTING_CFG_XXX - Configuration values that can be queried.
|
---|
229 | * @{ */
|
---|
230 | /** Generic 32-bit value \#0 - testcase defined meaning. */
|
---|
231 | #define VMMDEV_TESTING_CFG_DWORD0 UINT16_C(0x0000)
|
---|
232 | /** Generic 32-bit value \#1 - testcase defined meaning. */
|
---|
233 | #define VMMDEV_TESTING_CFG_DWORD1 UINT16_C(0x0001)
|
---|
234 | /** Generic 32-bit value \#2 - testcase defined meaning. */
|
---|
235 | #define VMMDEV_TESTING_CFG_DWORD2 UINT16_C(0x0002)
|
---|
236 | /** Generic 32-bit value \#3 - testcase defined meaning. */
|
---|
237 | #define VMMDEV_TESTING_CFG_DWORD3 UINT16_C(0x0003)
|
---|
238 | /** Generic 32-bit value \#4 - testcase defined meaning. */
|
---|
239 | #define VMMDEV_TESTING_CFG_DWORD4 UINT16_C(0x0004)
|
---|
240 | /** Generic 32-bit value \#5 - testcase defined meaning. */
|
---|
241 | #define VMMDEV_TESTING_CFG_DWORD5 UINT16_C(0x0005)
|
---|
242 | /** Generic 32-bit value \#6 - testcase defined meaning. */
|
---|
243 | #define VMMDEV_TESTING_CFG_DWORD6 UINT16_C(0x0006)
|
---|
244 | /** Generic 32-bit value \#7 - testcase defined meaning. */
|
---|
245 | #define VMMDEV_TESTING_CFG_DWORD7 UINT16_C(0x0007)
|
---|
246 | /** Generic 32-bit value \#8 - testcase defined meaning. */
|
---|
247 | #define VMMDEV_TESTING_CFG_DWORD8 UINT16_C(0x0008)
|
---|
248 | /** Generic 32-bit value \#9 - testcase defined meaning. */
|
---|
249 | #define VMMDEV_TESTING_CFG_DWORD9 UINT16_C(0x0009)
|
---|
250 |
|
---|
251 | /** Boolean (8-bit): Running in NEM on Linux? */
|
---|
252 | #define VMMDEV_TESTING_CFG_IS_NEM_LINUX UINT16_C(0x0100)
|
---|
253 | /** Boolean (8-bit): Running in NEM on Windows? */
|
---|
254 | #define VMMDEV_TESTING_CFG_IS_NEM_WINDOWS UINT16_C(0x0101)
|
---|
255 | /** Boolean (8-bit): Running in NEM on Darwin? */
|
---|
256 | #define VMMDEV_TESTING_CFG_IS_NEM_DARWIN UINT16_C(0x0102)
|
---|
257 | /** @} */
|
---|
258 |
|
---|
259 | /** @} */
|
---|
260 |
|
---|
261 | #endif /* !VBOX_INCLUDED_VMMDevTesting_h */
|
---|
262 |
|
---|