1 | /* $Id: tstVBInsTstR3.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Instruction Test Environment - IPRT ring-3 driver.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2024 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 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #include <iprt/mem.h>
|
---|
33 | #include <iprt/string.h>
|
---|
34 | #include <iprt/test.h>
|
---|
35 |
|
---|
36 | #ifdef RT_OS_WINDOWS
|
---|
37 | # define NO_LOW_MEM
|
---|
38 | #elif defined(RT_OS_OS2) || defined(RT_OS_HAIKU)
|
---|
39 | # define NO_LOW_MEM
|
---|
40 | #else
|
---|
41 | # include <sys/mman.h>
|
---|
42 | #endif
|
---|
43 |
|
---|
44 |
|
---|
45 | /*********************************************************************************************************************************
|
---|
46 | * Structures and Typedefs *
|
---|
47 | *********************************************************************************************************************************/
|
---|
48 | #if HC_ARCH_BITS == 64
|
---|
49 | typedef uint64_t VBINSTSTREG;
|
---|
50 | #else
|
---|
51 | typedef uint32_t VBINSTSTREG;
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | /*********************************************************************************************************************************
|
---|
56 | * Global Variables *
|
---|
57 | *********************************************************************************************************************************/
|
---|
58 | RTTEST g_hTest;
|
---|
59 |
|
---|
60 |
|
---|
61 | RT_C_DECLS_BEGIN
|
---|
62 | extern void *g_pvLow16Mem4K;
|
---|
63 | extern void *g_pvLow32Mem4K;
|
---|
64 | DECLASM(void) TestInstrMain(void);
|
---|
65 |
|
---|
66 | DECLEXPORT(void) VBInsTstFailure(const char *pszMessage);
|
---|
67 | DECLEXPORT(void) VBInsTstFailure1(const char *pszFmt, VBINSTSTREG uArg1);
|
---|
68 | DECLEXPORT(void) VBInsTstFailure2(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2);
|
---|
69 | DECLEXPORT(void) VBInsTstFailure3(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3);
|
---|
70 | DECLEXPORT(void) VBInsTstFailure4(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3, VBINSTSTREG uArg4);
|
---|
71 | RT_C_DECLS_END
|
---|
72 |
|
---|
73 |
|
---|
74 | DECLEXPORT(void) VBInsTstFailure(const char *pszMessage)
|
---|
75 | {
|
---|
76 | RTTestFailed(g_hTest, "%s", pszMessage);
|
---|
77 | }
|
---|
78 |
|
---|
79 | DECLEXPORT(void) VBInsTstFailure1(const char *pszFmt, VBINSTSTREG uArg1)
|
---|
80 | {
|
---|
81 | RTTestFailed(g_hTest, pszFmt, uArg1);
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | DECLEXPORT(void) VBInsTstFailure2(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2)
|
---|
86 | {
|
---|
87 | RTTestFailed(g_hTest, pszFmt, uArg1, uArg2);
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | DECLEXPORT(void) VBInsTstFailure3(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3)
|
---|
92 | {
|
---|
93 | RTTestFailed(g_hTest, pszFmt, uArg1, uArg2, uArg3);
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | DECLEXPORT(void) VBInsTstFailure4(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3, VBINSTSTREG uArg4)
|
---|
98 | {
|
---|
99 | RTTestFailed(g_hTest, pszFmt, uArg1, uArg2, uArg3, uArg4);
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | int main()
|
---|
106 | {
|
---|
107 | RTEXITCODE rcExit = RTTestInitAndCreate("VBInsTstR3", &g_hTest);
|
---|
108 | if (rcExit != RTEXITCODE_SUCCESS)
|
---|
109 | return rcExit;
|
---|
110 | RTTestBanner(g_hTest);
|
---|
111 |
|
---|
112 | int rc = RTMemAllocEx(_4K, 0, RTMEMALLOCEX_FLAGS_16BIT_REACH, &g_pvLow16Mem4K);
|
---|
113 | if (RT_FAILURE(rc))
|
---|
114 | {
|
---|
115 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Could not allocate low 16-bit memory (%Rrc)\n", rc);
|
---|
116 | g_pvLow16Mem4K = NULL;
|
---|
117 | }
|
---|
118 |
|
---|
119 | rc = RTMemAllocEx(_4K, 0, RTMEMALLOCEX_FLAGS_32BIT_REACH, &g_pvLow32Mem4K);
|
---|
120 | if (RT_FAILURE(rc))
|
---|
121 | {
|
---|
122 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Could not allocate low 32-bit memory (%Rrc)\n", rc);
|
---|
123 | g_pvLow32Mem4K = NULL;
|
---|
124 | }
|
---|
125 |
|
---|
126 | TestInstrMain();
|
---|
127 |
|
---|
128 | return RTTestSummaryAndDestroy(g_hTest);
|
---|
129 | }
|
---|
130 |
|
---|