VirtualBox

source: vbox/trunk/include/VBox/VMMDevTesting.h@ 105225

Last change on this file since 105225 was 104070, checked in by vboxsync, 8 months ago

VMMDev: Add a magic tail dword following the data made available by VMMDEV_TESTING_CMD_QUERY_CFG. This can be used to verify that the query was successful. bugref:9898

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

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