1 | /* $Id: bs3kit.h 72133 2018-05-06 23:55:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - structures, symbols, macros and stuff.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2017 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 ___bs3kit_h
|
---|
28 | #define ___bs3kit_h
|
---|
29 |
|
---|
30 | #ifndef DOXYGEN_RUNNING
|
---|
31 | # undef IN_RING0
|
---|
32 | # define IN_RING0
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #define RT_NO_STRICT /* Don't drag in IPRT assertion code in inline code we may use (asm.h). */
|
---|
36 | #include <iprt/cdefs.h>
|
---|
37 | #include <iprt/types.h>
|
---|
38 |
|
---|
39 | #ifndef DOXYGEN_RUNNING
|
---|
40 | # undef IN_RING0
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * Make asm.h and friend compatible with our 64-bit assembly config (ASM_CALL64_MSC).
|
---|
45 | */
|
---|
46 | #if defined(__GNUC__) && ARCH_BITS == 64
|
---|
47 | # undef DECLASM
|
---|
48 | # ifdef __cplusplus
|
---|
49 | # define DECLASM(type) extern "C" type BS3_CALL
|
---|
50 | # else
|
---|
51 | # define DECLASM(type) type BS3_CALL
|
---|
52 | # endif
|
---|
53 | #endif
|
---|
54 |
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * Work around ms_abi trouble in the gcc camp (gcc bugzilla #50818).
|
---|
58 | * ASSUMES all va_lists are in functions with
|
---|
59 | */
|
---|
60 | #if defined(__GNUC__) && ARCH_BITS == 64
|
---|
61 | # undef va_list
|
---|
62 | # undef va_start
|
---|
63 | # undef va_end
|
---|
64 | # undef va_copy
|
---|
65 | # define va_list __builtin_ms_va_list
|
---|
66 | # define va_start(a_Va, a_Arg) __builtin_ms_va_start(a_Va, a_Arg)
|
---|
67 | # define va_end(a_Va) __builtin_ms_va_end(a_Va)
|
---|
68 | # define va_copy(a_DstVa, a_SrcVa) __builtin_ms_va_copy(a_DstVa, a_SrcVa)
|
---|
69 | #endif
|
---|
70 |
|
---|
71 |
|
---|
72 | /** @def BS3_USE_ALT_16BIT_TEXT_SEG
|
---|
73 | * @ingroup grp_bs3kit
|
---|
74 | * Combines the BS3_USE_RM_TEXT_SEG, BS3_USE_X0_TEXT_SEG, and
|
---|
75 | * BS3_USE_X1_TEXT_SEG indicators into a single one.
|
---|
76 | */
|
---|
77 | #if defined(BS3_USE_RM_TEXT_SEG) || defined(BS3_USE_X0_TEXT_SEG) || defined(BS3_USE_X1_TEXT_SEG) || defined(DOXYGEN_RUNNING)
|
---|
78 | # define BS3_USE_ALT_16BIT_TEXT_SEG
|
---|
79 | #else
|
---|
80 | # undef BS3_USE_ALT_16BIT_TEXT_SEG
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | /** @def BS3_USE_X0_TEXT_SEG
|
---|
84 | * @ingroup grp_bs3kit
|
---|
85 | * Emit 16-bit code to the BS3X0TEXT16 segment - ignored for 32-bit and 64-bit.
|
---|
86 | *
|
---|
87 | * Calling directly into the BS3X0TEXT16 segment is only possible in real-mode
|
---|
88 | * and v8086 mode. In protected mode the real far pointer have to be converted
|
---|
89 | * to a protected mode pointer that uses BS3_SEL_X0TEXT16_CS, Bs3TestDoModes and
|
---|
90 | * associates does this automatically.
|
---|
91 | */
|
---|
92 | #ifdef DOXYGEN_RUNNING
|
---|
93 | # define BS3_USE_X0_TEXT_SEG
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | /** @def BS3_USE_X1_TEXT_SEG
|
---|
97 | * @ingroup grp_bs3kit
|
---|
98 | * Emit 16-bit code to the BS3X1TEXT16 segment - ignored for 32-bit and 64-bit.
|
---|
99 | *
|
---|
100 | * Calling directly into the BS3X1TEXT16 segment is only possible in real-mode
|
---|
101 | * and v8086 mode. In protected mode the real far pointer have to be converted
|
---|
102 | * to a protected mode pointer that uses BS3_SEL_X1TEXT16_CS, Bs3TestDoModes and
|
---|
103 | * associates does this automatically.
|
---|
104 | */
|
---|
105 | #ifdef DOXYGEN_RUNNING
|
---|
106 | # define BS3_USE_X1_TEXT_SEG
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | /** @def BS3_USE_RM_TEXT_SEG
|
---|
110 | * @ingroup grp_bs3kit
|
---|
111 | * Emit 16-bit code to the BS3RMTEXT16 segment - ignored for 32-bit and 64-bit.
|
---|
112 | *
|
---|
113 | * This segment is normally used for real-mode only code, though
|
---|
114 | * BS3_SEL_RMTEXT16_CS can be used to call it from protected mode. Unlike the
|
---|
115 | * BS3X0TEXT16 and BS3X1TEXT16 segments which are empty by default, this segment
|
---|
116 | * is used by common BS3Kit code.
|
---|
117 | */
|
---|
118 | #ifdef DOXYGEN_RUNNING
|
---|
119 | # define BS3_USE_X0_TEXT_SEG
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | /** @def BS3_MODEL_FAR_CODE
|
---|
123 | * @ingroup grp_bs3kit
|
---|
124 | * Default compiler model indicates far code.
|
---|
125 | */
|
---|
126 | #ifdef DOXYGEN_RUNNING
|
---|
127 | # define BS3_MODEL_FAR_CODE
|
---|
128 | #elif !defined(BS3_MODEL_FAR_CODE) && (defined(__LARGE__) || defined(__MEDIUM__) || defined(__HUGE__)) && ARCH_BITS == 16
|
---|
129 | # define BS3_MODEL_FAR_CODE
|
---|
130 | #endif
|
---|
131 |
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * We normally don't want the noreturn / aborts attributes as they mess up stack traces.
|
---|
135 | *
|
---|
136 | * Note! pragma aux <fnname> aborts can only be used with functions
|
---|
137 | * implemented in C and functions that does not have parameters.
|
---|
138 | */
|
---|
139 | #define BS3_KIT_WITH_NO_RETURN
|
---|
140 | #ifndef BS3_KIT_WITH_NO_RETURN
|
---|
141 | # undef DECL_NO_RETURN
|
---|
142 | # define DECL_NO_RETURN(type) type
|
---|
143 | #endif
|
---|
144 |
|
---|
145 |
|
---|
146 | /*
|
---|
147 | * We may want to reuse some IPRT code in the common name space, so we
|
---|
148 | * redefine the RT_MANGLER to work like BS3_CMN_NM. (We cannot use
|
---|
149 | * BS3_CMN_NM yet, as we need to include IPRT headers with function
|
---|
150 | * declarations before we can define it. Thus the duplciate effort.)
|
---|
151 | */
|
---|
152 | #if ARCH_BITS == 16
|
---|
153 | # undef RTCALL
|
---|
154 | # if defined(BS3_USE_ALT_16BIT_TEXT_SEG)
|
---|
155 | # define RTCALL __cdecl __far
|
---|
156 | # define RT_MANGLER(a_Name) RT_CONCAT(a_Name,_f16)
|
---|
157 | # else
|
---|
158 | # define RTCALL __cdecl __near
|
---|
159 | # define RT_MANGLER(a_Name) RT_CONCAT(a_Name,_c16)
|
---|
160 | # endif
|
---|
161 | #else
|
---|
162 | # define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
|
---|
163 | #endif
|
---|
164 | #include <iprt/mangling.h>
|
---|
165 | #include <iprt/x86.h>
|
---|
166 | #include <iprt/err.h>
|
---|
167 |
|
---|
168 | /*
|
---|
169 | * Include data symbol mangling (function mangling/mapping must be done
|
---|
170 | * after the protypes).
|
---|
171 | */
|
---|
172 | #include "bs3kit-mangling-data.h"
|
---|
173 |
|
---|
174 |
|
---|
175 |
|
---|
176 | RT_C_DECLS_BEGIN
|
---|
177 |
|
---|
178 | /** @defgroup grp_bs3kit BS3Kit - Boot Sector Kit \#3
|
---|
179 | *
|
---|
180 | * The BS3Kit is a framework for bare metal floppy/usb image tests,
|
---|
181 | * see the @ref pg_bs3kit "doc page" for more.
|
---|
182 | *
|
---|
183 | * @{ */
|
---|
184 |
|
---|
185 | /** @name Execution modes.
|
---|
186 | * @{ */
|
---|
187 | #define BS3_MODE_INVALID UINT8_C(0x00)
|
---|
188 | #define BS3_MODE_RM UINT8_C(0x01) /**< real mode. */
|
---|
189 | #define BS3_MODE_PE16 UINT8_C(0x11) /**< 16-bit protected mode kernel+tss, running 16-bit code, unpaged. */
|
---|
190 | #define BS3_MODE_PE16_32 UINT8_C(0x12) /**< 16-bit protected mode kernel+tss, running 32-bit code, unpaged. */
|
---|
191 | #define BS3_MODE_PE16_V86 UINT8_C(0x18) /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
|
---|
192 | #define BS3_MODE_PE32 UINT8_C(0x22) /**< 32-bit protected mode kernel+tss, running 32-bit code, unpaged. */
|
---|
193 | #define BS3_MODE_PE32_16 UINT8_C(0x21) /**< 32-bit protected mode kernel+tss, running 16-bit code, unpaged. */
|
---|
194 | #define BS3_MODE_PEV86 UINT8_C(0x28) /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
|
---|
195 | #define BS3_MODE_PP16 UINT8_C(0x31) /**< 16-bit protected mode kernel+tss, running 16-bit code, paged. */
|
---|
196 | #define BS3_MODE_PP16_32 UINT8_C(0x32) /**< 16-bit protected mode kernel+tss, running 32-bit code, paged. */
|
---|
197 | #define BS3_MODE_PP16_V86 UINT8_C(0x38) /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
|
---|
198 | #define BS3_MODE_PP32 UINT8_C(0x42) /**< 32-bit protected mode kernel+tss, running 32-bit code, paged. */
|
---|
199 | #define BS3_MODE_PP32_16 UINT8_C(0x41) /**< 32-bit protected mode kernel+tss, running 16-bit code, paged. */
|
---|
200 | #define BS3_MODE_PPV86 UINT8_C(0x48) /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
|
---|
201 | #define BS3_MODE_PAE16 UINT8_C(0x51) /**< 16-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
|
---|
202 | #define BS3_MODE_PAE16_32 UINT8_C(0x52) /**< 16-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
|
---|
203 | #define BS3_MODE_PAE16_V86 UINT8_C(0x58) /**< 16-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging. */
|
---|
204 | #define BS3_MODE_PAE32 UINT8_C(0x62) /**< 32-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
|
---|
205 | #define BS3_MODE_PAE32_16 UINT8_C(0x61) /**< 32-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
|
---|
206 | #define BS3_MODE_PAEV86 UINT8_C(0x68) /**< 32-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging. */
|
---|
207 | #define BS3_MODE_LM16 UINT8_C(0x71) /**< 16-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
208 | #define BS3_MODE_LM32 UINT8_C(0x72) /**< 32-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
209 | #define BS3_MODE_LM64 UINT8_C(0x74) /**< 64-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
210 |
|
---|
211 | #define BS3_MODE_CODE_MASK UINT8_C(0x0f) /**< Running code mask. */
|
---|
212 | #define BS3_MODE_CODE_16 UINT8_C(0x01) /**< Running 16-bit code. */
|
---|
213 | #define BS3_MODE_CODE_32 UINT8_C(0x02) /**< Running 32-bit code. */
|
---|
214 | #define BS3_MODE_CODE_64 UINT8_C(0x04) /**< Running 64-bit code. */
|
---|
215 | #define BS3_MODE_CODE_V86 UINT8_C(0x08) /**< Running 16-bit virtual 8086 code. */
|
---|
216 |
|
---|
217 | #define BS3_MODE_SYS_MASK UINT8_C(0xf0) /**< kernel+tss mask. */
|
---|
218 | #define BS3_MODE_SYS_RM UINT8_C(0x00) /**< Real mode kernel+tss. */
|
---|
219 | #define BS3_MODE_SYS_PE16 UINT8_C(0x10) /**< 16-bit protected mode kernel+tss. */
|
---|
220 | #define BS3_MODE_SYS_PE32 UINT8_C(0x20) /**< 32-bit protected mode kernel+tss. */
|
---|
221 | #define BS3_MODE_SYS_PP16 UINT8_C(0x30) /**< 16-bit paged protected mode kernel+tss. */
|
---|
222 | #define BS3_MODE_SYS_PP32 UINT8_C(0x40) /**< 32-bit paged protected mode kernel+tss. */
|
---|
223 | #define BS3_MODE_SYS_PAE16 UINT8_C(0x50) /**< 16-bit PAE paged protected mode kernel+tss. */
|
---|
224 | #define BS3_MODE_SYS_PAE32 UINT8_C(0x60) /**< 32-bit PAE paged protected mode kernel+tss. */
|
---|
225 | #define BS3_MODE_SYS_LM UINT8_C(0x70) /**< 64-bit (paged) long mode protected mode kernel+tss. */
|
---|
226 |
|
---|
227 | /** Whether the mode has paging enabled. */
|
---|
228 | #define BS3_MODE_IS_PAGED(a_fMode) ((a_fMode) >= BS3_MODE_PP16)
|
---|
229 | /** Whether the mode has legacy paging enabled (legacy as opposed to PAE or
|
---|
230 | * long mode). */
|
---|
231 | #define BS3_MODE_IS_LEGACY_PAGING(a_fMode) ((a_fMode) >= BS3_MODE_PP16 && (a_fMode) < BS3_MODE_PAE16)
|
---|
232 |
|
---|
233 | /** Whether the mode is running v8086 code. */
|
---|
234 | #define BS3_MODE_IS_V86(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86)
|
---|
235 | /** Whether the we're executing in real mode or v8086 mode. */
|
---|
236 | #define BS3_MODE_IS_RM_OR_V86(a_fMode) ((a_fMode) == BS3_MODE_RM || BS3_MODE_IS_V86(a_fMode))
|
---|
237 | /** Whether the mode is running 16-bit code, except v8086. */
|
---|
238 | #define BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16)
|
---|
239 | /** Whether the mode is running 16-bit code (includes v8086). */
|
---|
240 | #define BS3_MODE_IS_16BIT_CODE(a_fMode) (BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode) || BS3_MODE_IS_V86(a_fMode))
|
---|
241 | /** Whether the mode is running 32-bit code. */
|
---|
242 | #define BS3_MODE_IS_32BIT_CODE(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32)
|
---|
243 | /** Whether the mode is running 64-bit code. */
|
---|
244 | #define BS3_MODE_IS_64BIT_CODE(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64)
|
---|
245 |
|
---|
246 | /** Whether the system is in real mode. */
|
---|
247 | #define BS3_MODE_IS_RM_SYS(a_fMode) (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM)
|
---|
248 | /** Whether the system is some 16-bit mode that isn't real mode. */
|
---|
249 | #define BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode) ( ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16 \
|
---|
250 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16 \
|
---|
251 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16)
|
---|
252 | /** Whether the system is some 16-bit mode (includes real mode). */
|
---|
253 | #define BS3_MODE_IS_16BIT_SYS(a_fMode) (BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode) || BS3_MODE_IS_RM_SYS(a_fMode))
|
---|
254 | /** Whether the system is some 32-bit mode. */
|
---|
255 | #define BS3_MODE_IS_32BIT_SYS(a_fMode) ( ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32 \
|
---|
256 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32 \
|
---|
257 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32)
|
---|
258 | /** Whether the system is long mode. */
|
---|
259 | #define BS3_MODE_IS_64BIT_SYS(a_fMode) (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM)
|
---|
260 |
|
---|
261 | /** Whether the system is in protected mode (with or without paging).
|
---|
262 | * @note Long mode is not included. */
|
---|
263 | #define BS3_MODE_IS_PM_SYS(a_fMode) ((a_fMode) >= BS3_MODE_SYS_PE16 && (a_fMode) < BS3_MODE_SYS_LM)
|
---|
264 |
|
---|
265 | /** @todo testcase: How would long-mode handle a 16-bit TSS loaded prior to the switch? (mainly stack switching wise) Hopefully, it will tripple fault, right? */
|
---|
266 | /** @} */
|
---|
267 |
|
---|
268 |
|
---|
269 | /** @name BS3_ADDR_XXX - Static Memory Allocation
|
---|
270 | * @{ */
|
---|
271 | /** The flat load address for the code after the bootsector. */
|
---|
272 | #define BS3_ADDR_LOAD 0x10000
|
---|
273 | /** Where we save the boot registers during init.
|
---|
274 | * Located right before the code. */
|
---|
275 | #define BS3_ADDR_REG_SAVE (BS3_ADDR_LOAD - sizeof(BS3REGCTX) - 8)
|
---|
276 | /** Where the stack starts (initial RSP value).
|
---|
277 | * Located 16 bytes (assumed by boot sector) before the saved registers.
|
---|
278 | * SS.BASE=0. The size is a little short of 32KB */
|
---|
279 | #define BS3_ADDR_STACK (BS3_ADDR_REG_SAVE - 16)
|
---|
280 | /** The ring-0 stack (8KB) for ring transitions. */
|
---|
281 | #define BS3_ADDR_STACK_R0 0x06000
|
---|
282 | /** The ring-1 stack (8KB) for ring transitions. */
|
---|
283 | #define BS3_ADDR_STACK_R1 0x04000
|
---|
284 | /** The ring-2 stack (8KB) for ring transitions. */
|
---|
285 | #define BS3_ADDR_STACK_R2 0x02000
|
---|
286 | /** IST1 ring-0 stack for long mode (4KB), used for double faults elsewhere. */
|
---|
287 | #define BS3_ADDR_STACK_R0_IST1 0x09000
|
---|
288 | /** IST2 ring-0 stack for long mode (3KB), used for spare 0 stack elsewhere. */
|
---|
289 | #define BS3_ADDR_STACK_R0_IST2 0x08000
|
---|
290 | /** IST3 ring-0 stack for long mode (1KB). */
|
---|
291 | #define BS3_ADDR_STACK_R0_IST3 0x07400
|
---|
292 | /** IST4 ring-0 stack for long mode (1KB), used for spare 1 stack elsewhere. */
|
---|
293 | #define BS3_ADDR_STACK_R0_IST4 0x07000
|
---|
294 | /** IST5 ring-0 stack for long mode (1KB). */
|
---|
295 | #define BS3_ADDR_STACK_R0_IST5 0x06c00
|
---|
296 | /** IST6 ring-0 stack for long mode (1KB). */
|
---|
297 | #define BS3_ADDR_STACK_R0_IST6 0x06800
|
---|
298 | /** IST7 ring-0 stack for long mode (1KB). */
|
---|
299 | #define BS3_ADDR_STACK_R0_IST7 0x06400
|
---|
300 |
|
---|
301 | /** The base address of the BS3TEXT16 segment (same as BS3_LOAD_ADDR).
|
---|
302 | * @sa BS3_SEL_TEXT16 */
|
---|
303 | #define BS3_ADDR_BS3TEXT16 0x10000
|
---|
304 | /** The base address of the BS3SYSTEM16 segment.
|
---|
305 | * @sa BS3_SEL_SYSTEM16 */
|
---|
306 | #define BS3_ADDR_BS3SYSTEM16 0x20000
|
---|
307 | /** The base address of the BS3DATA16/BS3KIT_GRPNM_DATA16 segment.
|
---|
308 | * @sa BS3_SEL_DATA16 */
|
---|
309 | #define BS3_ADDR_BS3DATA16 0x29000
|
---|
310 | /** @} */
|
---|
311 |
|
---|
312 | /** @name BS3_SEL_XXX - GDT selector assignments.
|
---|
313 | *
|
---|
314 | * The real mode segment numbers for BS16TEXT, BS16DATA and BS16SYSTEM are
|
---|
315 | * present in the GDT, this allows the 16-bit C/C++ and assembly code to
|
---|
316 | * continue using the real mode segment values in ring-0 protected mode.
|
---|
317 | *
|
---|
318 | * The three segments have fixed locations:
|
---|
319 | * | segment | flat address | real mode segment |
|
---|
320 | * | ----------- | ------------ | ----------------- |
|
---|
321 | * | BS3TEXT16 | 0x00010000 | 1000h |
|
---|
322 | * | BS3SYSTEM16 | 0x00020000 | 2000h |
|
---|
323 | * | BS3DATA16 | 0x00029000 | 2900h |
|
---|
324 | *
|
---|
325 | * This means that we've got a lot of GDT space to play around with.
|
---|
326 | *
|
---|
327 | * @{ */
|
---|
328 | #define BS3_SEL_LDT 0x0010 /**< The LDT selector for Bs3Ldt. */
|
---|
329 | #define BS3_SEL_TSS16 0x0020 /**< The 16-bit TSS selector. */
|
---|
330 | #define BS3_SEL_TSS16_DF 0x0028 /**< The 16-bit TSS selector for double faults. */
|
---|
331 | #define BS3_SEL_TSS16_SPARE0 0x0030 /**< The 16-bit TSS selector for testing. */
|
---|
332 | #define BS3_SEL_TSS16_SPARE1 0x0038 /**< The 16-bit TSS selector for testing. */
|
---|
333 | #define BS3_SEL_TSS32 0x0040 /**< The 32-bit TSS selector. */
|
---|
334 | #define BS3_SEL_TSS32_DF 0x0048 /**< The 32-bit TSS selector for double faults. */
|
---|
335 | #define BS3_SEL_TSS32_SPARE0 0x0050 /**< The 32-bit TSS selector for testing. */
|
---|
336 | #define BS3_SEL_TSS32_SPARE1 0x0058 /**< The 32-bit TSS selector for testing. */
|
---|
337 | #define BS3_SEL_TSS32_IOBP_IRB 0x0060 /**< The 32-bit TSS selector with I/O permission and interrupt redirection bitmaps. */
|
---|
338 | #define BS3_SEL_TSS32_IRB 0x0068 /**< The 32-bit TSS selector with only interrupt redirection bitmap (IOPB stripped by limit). */
|
---|
339 | #define BS3_SEL_TSS64 0x0070 /**< The 64-bit TSS selector. */
|
---|
340 | #define BS3_SEL_TSS64_SPARE0 0x0080 /**< The 64-bit TSS selector. */
|
---|
341 | #define BS3_SEL_TSS64_SPARE1 0x0090 /**< The 64-bit TSS selector. */
|
---|
342 | #define BS3_SEL_TSS64_IOBP 0x00a0 /**< The 64-bit TSS selector. */
|
---|
343 |
|
---|
344 | #define BS3_SEL_RMTEXT16_CS 0x00e0 /**< Conforming code selector for accessing the BS3RMTEXT16 segment. Runtime config. */
|
---|
345 | #define BS3_SEL_X0TEXT16_CS 0x00e8 /**< Conforming code selector for accessing the BS3X0TEXT16 segment. Runtime config. */
|
---|
346 | #define BS3_SEL_X1TEXT16_CS 0x00f0 /**< Conforming code selector for accessing the BS3X1TEXT16 segment. Runtime config. */
|
---|
347 | #define BS3_SEL_VMMDEV_MMIO16 0x00f8 /**< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code. */
|
---|
348 |
|
---|
349 | /** Checks if @a uSel is in the BS3_SEL_RX_XXX range. */
|
---|
350 | #define BS3_SEL_IS_IN_RING_RANGE(uSel) ( (unsigned)(uSel - BS3_SEL_R0_FIRST) < (unsigned)(4 << BS3_SEL_RING_SHIFT) )
|
---|
351 | #define BS3_SEL_RING_SHIFT 8 /**< For the formula: BS3_SEL_R0_XXX + ((cs & 3) << BS3_SEL_RING_SHIFT) */
|
---|
352 | #define BS3_SEL_RING_SUB_MASK 0x00f8 /**< Mask for getting the sub-selector. For use with BS3_SEL_R*_FIRST. */
|
---|
353 |
|
---|
354 | /** Checks if @a uSel is in the BS3_SEL_R0_XXX range. */
|
---|
355 | #define BS3_SEL_IS_IN_R0_RANGE(uSel) ( (unsigned)(uSel - BS3_SEL_R0_FIRST) < (unsigned)(1 << BS3_SEL_RING_SHIFT) )
|
---|
356 | #define BS3_SEL_R0_FIRST 0x0100 /**< The first selector in the ring-0 block. */
|
---|
357 | #define BS3_SEL_R0_CS16 0x0100 /**< ring-0: 16-bit code selector, base 0x10000. */
|
---|
358 | #define BS3_SEL_R0_DS16 0x0108 /**< ring-0: 16-bit data selector, base 0x23000. */
|
---|
359 | #define BS3_SEL_R0_SS16 0x0110 /**< ring-0: 16-bit stack selector, base 0x00000. */
|
---|
360 | #define BS3_SEL_R0_CS32 0x0118 /**< ring-0: 32-bit flat code selector. */
|
---|
361 | #define BS3_SEL_R0_DS32 0x0120 /**< ring-0: 32-bit flat data selector. */
|
---|
362 | #define BS3_SEL_R0_SS32 0x0128 /**< ring-0: 32-bit flat stack selector. */
|
---|
363 | #define BS3_SEL_R0_CS64 0x0130 /**< ring-0: 64-bit flat code selector. */
|
---|
364 | #define BS3_SEL_R0_DS64 0x0138 /**< ring-0: 64-bit flat data & stack selector. */
|
---|
365 | #define BS3_SEL_R0_CS16_EO 0x0140 /**< ring-0: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
366 | #define BS3_SEL_R0_CS16_CNF 0x0148 /**< ring-0: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
367 | #define BS3_SEL_R0_CS16_CNF_EO 0x0150 /**< ring-0: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
368 | #define BS3_SEL_R0_CS32_EO 0x0158 /**< ring-0: 32-bit execute-only code selector, not accessed, flat. */
|
---|
369 | #define BS3_SEL_R0_CS32_CNF 0x0160 /**< ring-0: 32-bit conforming code selector, not accessed, flat. */
|
---|
370 | #define BS3_SEL_R0_CS32_CNF_EO 0x0168 /**< ring-0: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
371 | #define BS3_SEL_R0_CS64_EO 0x0170 /**< ring-0: 64-bit execute-only code selector, not accessed, flat. */
|
---|
372 | #define BS3_SEL_R0_CS64_CNF 0x0178 /**< ring-0: 64-bit conforming code selector, not accessed, flat. */
|
---|
373 | #define BS3_SEL_R0_CS64_CNF_EO 0x0180 /**< ring-0: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
374 |
|
---|
375 | #define BS3_SEL_R1_FIRST 0x0200 /**< The first selector in the ring-1 block. */
|
---|
376 | #define BS3_SEL_R1_CS16 0x0200 /**< ring-1: 16-bit code selector, base 0x10000. */
|
---|
377 | #define BS3_SEL_R1_DS16 0x0208 /**< ring-1: 16-bit data selector, base 0x23000. */
|
---|
378 | #define BS3_SEL_R1_SS16 0x0210 /**< ring-1: 16-bit stack selector, base 0x00000. */
|
---|
379 | #define BS3_SEL_R1_CS32 0x0218 /**< ring-1: 32-bit flat code selector. */
|
---|
380 | #define BS3_SEL_R1_DS32 0x0220 /**< ring-1: 32-bit flat data selector. */
|
---|
381 | #define BS3_SEL_R1_SS32 0x0228 /**< ring-1: 32-bit flat stack selector. */
|
---|
382 | #define BS3_SEL_R1_CS64 0x0230 /**< ring-1: 64-bit flat code selector. */
|
---|
383 | #define BS3_SEL_R1_DS64 0x0238 /**< ring-1: 64-bit flat data & stack selector. */
|
---|
384 | #define BS3_SEL_R1_CS16_EO 0x0240 /**< ring-1: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
385 | #define BS3_SEL_R1_CS16_CNF 0x0248 /**< ring-1: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
386 | #define BS3_SEL_R1_CS16_CNF_EO 0x0250 /**< ring-1: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
387 | #define BS3_SEL_R1_CS32_EO 0x0258 /**< ring-1: 32-bit execute-only code selector, not accessed, flat. */
|
---|
388 | #define BS3_SEL_R1_CS32_CNF 0x0260 /**< ring-1: 32-bit conforming code selector, not accessed, flat. */
|
---|
389 | #define BS3_SEL_R1_CS32_CNF_EO 0x0268 /**< ring-1: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
390 | #define BS3_SEL_R1_CS64_EO 0x0270 /**< ring-1: 64-bit execute-only code selector, not accessed, flat. */
|
---|
391 | #define BS3_SEL_R1_CS64_CNF 0x0278 /**< ring-1: 64-bit conforming code selector, not accessed, flat. */
|
---|
392 | #define BS3_SEL_R1_CS64_CNF_EO 0x0280 /**< ring-1: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
393 |
|
---|
394 | #define BS3_SEL_R2_FIRST 0x0300 /**< The first selector in the ring-2 block. */
|
---|
395 | #define BS3_SEL_R2_CS16 0x0300 /**< ring-2: 16-bit code selector, base 0x10000. */
|
---|
396 | #define BS3_SEL_R2_DS16 0x0308 /**< ring-2: 16-bit data selector, base 0x23000. */
|
---|
397 | #define BS3_SEL_R2_SS16 0x0310 /**< ring-2: 16-bit stack selector, base 0x00000. */
|
---|
398 | #define BS3_SEL_R2_CS32 0x0318 /**< ring-2: 32-bit flat code selector. */
|
---|
399 | #define BS3_SEL_R2_DS32 0x0320 /**< ring-2: 32-bit flat data selector. */
|
---|
400 | #define BS3_SEL_R2_SS32 0x0328 /**< ring-2: 32-bit flat stack selector. */
|
---|
401 | #define BS3_SEL_R2_CS64 0x0330 /**< ring-2: 64-bit flat code selector. */
|
---|
402 | #define BS3_SEL_R2_DS64 0x0338 /**< ring-2: 64-bit flat data & stack selector. */
|
---|
403 | #define BS3_SEL_R2_CS16_EO 0x0340 /**< ring-2: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
404 | #define BS3_SEL_R2_CS16_CNF 0x0348 /**< ring-2: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
405 | #define BS3_SEL_R2_CS16_CNF_EO 0x0350 /**< ring-2: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
406 | #define BS3_SEL_R2_CS32_EO 0x0358 /**< ring-2: 32-bit execute-only code selector, not accessed, flat. */
|
---|
407 | #define BS3_SEL_R2_CS32_CNF 0x0360 /**< ring-2: 32-bit conforming code selector, not accessed, flat. */
|
---|
408 | #define BS3_SEL_R2_CS32_CNF_EO 0x0368 /**< ring-2: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
409 | #define BS3_SEL_R2_CS64_EO 0x0370 /**< ring-2: 64-bit execute-only code selector, not accessed, flat. */
|
---|
410 | #define BS3_SEL_R2_CS64_CNF 0x0378 /**< ring-2: 64-bit conforming code selector, not accessed, flat. */
|
---|
411 | #define BS3_SEL_R2_CS64_CNF_EO 0x0380 /**< ring-2: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
412 |
|
---|
413 | #define BS3_SEL_R3_FIRST 0x0400 /**< The first selector in the ring-3 block. */
|
---|
414 | #define BS3_SEL_R3_CS16 0x0400 /**< ring-3: 16-bit code selector, base 0x10000. */
|
---|
415 | #define BS3_SEL_R3_DS16 0x0408 /**< ring-3: 16-bit data selector, base 0x23000. */
|
---|
416 | #define BS3_SEL_R3_SS16 0x0410 /**< ring-3: 16-bit stack selector, base 0x00000. */
|
---|
417 | #define BS3_SEL_R3_CS32 0x0418 /**< ring-3: 32-bit flat code selector. */
|
---|
418 | #define BS3_SEL_R3_DS32 0x0420 /**< ring-3: 32-bit flat data selector. */
|
---|
419 | #define BS3_SEL_R3_SS32 0x0428 /**< ring-3: 32-bit flat stack selector. */
|
---|
420 | #define BS3_SEL_R3_CS64 0x0430 /**< ring-3: 64-bit flat code selector. */
|
---|
421 | #define BS3_SEL_R3_DS64 0x0438 /**< ring-3: 64-bit flat data & stack selector. */
|
---|
422 | #define BS3_SEL_R3_CS16_EO 0x0440 /**< ring-3: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
423 | #define BS3_SEL_R3_CS16_CNF 0x0448 /**< ring-3: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
424 | #define BS3_SEL_R3_CS16_CNF_EO 0x0450 /**< ring-3: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
425 | #define BS3_SEL_R3_CS32_EO 0x0458 /**< ring-3: 32-bit execute-only code selector, not accessed, flat. */
|
---|
426 | #define BS3_SEL_R3_CS32_CNF 0x0460 /**< ring-3: 32-bit conforming code selector, not accessed, flat. */
|
---|
427 | #define BS3_SEL_R3_CS32_CNF_EO 0x0468 /**< ring-3: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
428 | #define BS3_SEL_R3_CS64_EO 0x0470 /**< ring-3: 64-bit execute-only code selector, not accessed, flat. */
|
---|
429 | #define BS3_SEL_R3_CS64_CNF 0x0478 /**< ring-3: 64-bit conforming code selector, not accessed, flat. */
|
---|
430 | #define BS3_SEL_R3_CS64_CNF_EO 0x0480 /**< ring-3: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
431 |
|
---|
432 | #define BS3_SEL_R3_LAST 0x04f8 /**< ring-3: Last of the BS3_SEL_RX_XXX range. */
|
---|
433 |
|
---|
434 | #define BS3_SEL_SPARE_FIRST 0x0500 /**< The first selector in the spare block */
|
---|
435 | #define BS3_SEL_SPARE_00 0x0500 /**< Spare selector number 00h. */
|
---|
436 | #define BS3_SEL_SPARE_01 0x0508 /**< Spare selector number 01h. */
|
---|
437 | #define BS3_SEL_SPARE_02 0x0510 /**< Spare selector number 02h. */
|
---|
438 | #define BS3_SEL_SPARE_03 0x0518 /**< Spare selector number 03h. */
|
---|
439 | #define BS3_SEL_SPARE_04 0x0520 /**< Spare selector number 04h. */
|
---|
440 | #define BS3_SEL_SPARE_05 0x0528 /**< Spare selector number 05h. */
|
---|
441 | #define BS3_SEL_SPARE_06 0x0530 /**< Spare selector number 06h. */
|
---|
442 | #define BS3_SEL_SPARE_07 0x0538 /**< Spare selector number 07h. */
|
---|
443 | #define BS3_SEL_SPARE_08 0x0540 /**< Spare selector number 08h. */
|
---|
444 | #define BS3_SEL_SPARE_09 0x0548 /**< Spare selector number 09h. */
|
---|
445 | #define BS3_SEL_SPARE_0a 0x0550 /**< Spare selector number 0ah. */
|
---|
446 | #define BS3_SEL_SPARE_0b 0x0558 /**< Spare selector number 0bh. */
|
---|
447 | #define BS3_SEL_SPARE_0c 0x0560 /**< Spare selector number 0ch. */
|
---|
448 | #define BS3_SEL_SPARE_0d 0x0568 /**< Spare selector number 0dh. */
|
---|
449 | #define BS3_SEL_SPARE_0e 0x0570 /**< Spare selector number 0eh. */
|
---|
450 | #define BS3_SEL_SPARE_0f 0x0578 /**< Spare selector number 0fh. */
|
---|
451 | #define BS3_SEL_SPARE_10 0x0580 /**< Spare selector number 10h. */
|
---|
452 | #define BS3_SEL_SPARE_11 0x0588 /**< Spare selector number 11h. */
|
---|
453 | #define BS3_SEL_SPARE_12 0x0590 /**< Spare selector number 12h. */
|
---|
454 | #define BS3_SEL_SPARE_13 0x0598 /**< Spare selector number 13h. */
|
---|
455 | #define BS3_SEL_SPARE_14 0x05a0 /**< Spare selector number 14h. */
|
---|
456 | #define BS3_SEL_SPARE_15 0x05a8 /**< Spare selector number 15h. */
|
---|
457 | #define BS3_SEL_SPARE_16 0x05b0 /**< Spare selector number 16h. */
|
---|
458 | #define BS3_SEL_SPARE_17 0x05b8 /**< Spare selector number 17h. */
|
---|
459 | #define BS3_SEL_SPARE_18 0x05c0 /**< Spare selector number 18h. */
|
---|
460 | #define BS3_SEL_SPARE_19 0x05c8 /**< Spare selector number 19h. */
|
---|
461 | #define BS3_SEL_SPARE_1a 0x05d0 /**< Spare selector number 1ah. */
|
---|
462 | #define BS3_SEL_SPARE_1b 0x05d8 /**< Spare selector number 1bh. */
|
---|
463 | #define BS3_SEL_SPARE_1c 0x05e0 /**< Spare selector number 1ch. */
|
---|
464 | #define BS3_SEL_SPARE_1d 0x05e8 /**< Spare selector number 1dh. */
|
---|
465 | #define BS3_SEL_SPARE_1e 0x05f0 /**< Spare selector number 1eh. */
|
---|
466 | #define BS3_SEL_SPARE_1f 0x05f8 /**< Spare selector number 1fh. */
|
---|
467 |
|
---|
468 | #define BS3_SEL_TILED 0x0600 /**< 16-bit data tiling: First - base=0x00000000, limit=64KB, DPL=3. */
|
---|
469 | #define BS3_SEL_TILED_LAST 0x0df8 /**< 16-bit data tiling: Last - base=0x00ff0000, limit=64KB, DPL=3. */
|
---|
470 | #define BS3_SEL_TILED_AREA_SIZE 0x001000000 /**< 16-bit data tiling: Size of addressable area, in bytes. (16 MB) */
|
---|
471 |
|
---|
472 | #define BS3_SEL_FREE_PART1 0x0e00 /**< Free selector space - part \#1. */
|
---|
473 | #define BS3_SEL_FREE_PART1_LAST 0x0ff8 /**< Free selector space - part \#1, last entry. */
|
---|
474 |
|
---|
475 | #define BS3_SEL_TEXT16 0x1000 /**< The BS3TEXT16 selector. */
|
---|
476 |
|
---|
477 | #define BS3_SEL_FREE_PART2 0x1008 /**< Free selector space - part \#2. */
|
---|
478 | #define BS3_SEL_FREE_PART2_LAST 0x17f8 /**< Free selector space - part \#2, last entry. */
|
---|
479 |
|
---|
480 | #define BS3_SEL_TILED_R0 0x1800 /**< 16-bit data/stack tiling: First - base=0x00000000, limit=64KB, DPL=0. */
|
---|
481 | #define BS3_SEL_TILED_R0_LAST 0x1ff8 /**< 16-bit data/stack tiling: Last - base=0x00ff0000, limit=64KB, DPL=0. */
|
---|
482 |
|
---|
483 | #define BS3_SEL_SYSTEM16 0x2000 /**< The BS3SYSTEM16 selector. */
|
---|
484 |
|
---|
485 | #define BS3_SEL_FREE_PART3 0x2008 /**< Free selector space - part \#3. */
|
---|
486 | #define BS3_SEL_FREE_PART3_LAST 0x28f8 /**< Free selector space - part \#3, last entry. */
|
---|
487 |
|
---|
488 | #define BS3_SEL_DATA16 0x2900 /**< The BS3DATA16/BS3KIT_GRPNM_DATA16 selector. */
|
---|
489 |
|
---|
490 | #define BS3_SEL_FREE_PART4 0x2908 /**< Free selector space - part \#4. */
|
---|
491 | #define BS3_SEL_FREE_PART4_LAST 0x2f98 /**< Free selector space - part \#4, last entry. */
|
---|
492 |
|
---|
493 | #define BS3_SEL_PRE_TEST_PAGE_08 0x2fa0 /**< Selector located 8 selectors before the test page. */
|
---|
494 | #define BS3_SEL_PRE_TEST_PAGE_07 0x2fa8 /**< Selector located 7 selectors before the test page. */
|
---|
495 | #define BS3_SEL_PRE_TEST_PAGE_06 0x2fb0 /**< Selector located 6 selectors before the test page. */
|
---|
496 | #define BS3_SEL_PRE_TEST_PAGE_05 0x2fb8 /**< Selector located 5 selectors before the test page. */
|
---|
497 | #define BS3_SEL_PRE_TEST_PAGE_04 0x2fc0 /**< Selector located 4 selectors before the test page. */
|
---|
498 | #define BS3_SEL_PRE_TEST_PAGE_03 0x2fc8 /**< Selector located 3 selectors before the test page. */
|
---|
499 | #define BS3_SEL_PRE_TEST_PAGE_02 0x2fd0 /**< Selector located 2 selectors before the test page. */
|
---|
500 | #define BS3_SEL_PRE_TEST_PAGE_01 0x2fd8 /**< Selector located 1 selector before the test page. */
|
---|
501 | #define BS3_SEL_TEST_PAGE 0x2fe0 /**< Start of the test page intended for playing around with paging and GDT. */
|
---|
502 | #define BS3_SEL_TEST_PAGE_00 0x2fe0 /**< Test page selector number 00h (convenience). */
|
---|
503 | #define BS3_SEL_TEST_PAGE_01 0x2fe8 /**< Test page selector number 01h (convenience). */
|
---|
504 | #define BS3_SEL_TEST_PAGE_02 0x2ff0 /**< Test page selector number 02h (convenience). */
|
---|
505 | #define BS3_SEL_TEST_PAGE_03 0x2ff8 /**< Test page selector number 03h (convenience). */
|
---|
506 | #define BS3_SEL_TEST_PAGE_04 0x3000 /**< Test page selector number 04h (convenience). */
|
---|
507 | #define BS3_SEL_TEST_PAGE_05 0x3008 /**< Test page selector number 05h (convenience). */
|
---|
508 | #define BS3_SEL_TEST_PAGE_06 0x3010 /**< Test page selector number 06h (convenience). */
|
---|
509 | #define BS3_SEL_TEST_PAGE_07 0x3018 /**< Test page selector number 07h (convenience). */
|
---|
510 | #define BS3_SEL_TEST_PAGE_LAST 0x3fd0 /**< The last selector in the spare page. */
|
---|
511 |
|
---|
512 | #define BS3_SEL_GDT_LIMIT 0x3fd8 /**< The GDT limit. */
|
---|
513 | /** @} */
|
---|
514 |
|
---|
515 |
|
---|
516 | /** @def BS3_FAR
|
---|
517 | * For indicating far pointers in 16-bit code.
|
---|
518 | * Does nothing in 32-bit and 64-bit code. */
|
---|
519 | /** @def BS3_NEAR
|
---|
520 | * For indicating near pointers in 16-bit code.
|
---|
521 | * Does nothing in 32-bit and 64-bit code. */
|
---|
522 | /** @def BS3_FAR_CODE
|
---|
523 | * For indicating far 16-bit functions.
|
---|
524 | * Does nothing in 32-bit and 64-bit code. */
|
---|
525 | /** @def BS3_NEAR_CODE
|
---|
526 | * For indicating near 16-bit functions.
|
---|
527 | * Does nothing in 32-bit and 64-bit code. */
|
---|
528 | /** @def BS3_FAR_DATA
|
---|
529 | * For indicating far 16-bit external data, i.e. in a segment other than DATA16.
|
---|
530 | * Does nothing in 32-bit and 64-bit code. */
|
---|
531 | #ifdef M_I86
|
---|
532 | # define BS3_FAR __far
|
---|
533 | # define BS3_NEAR __near
|
---|
534 | # define BS3_FAR_CODE __far
|
---|
535 | # define BS3_NEAR_CODE __near
|
---|
536 | # define BS3_FAR_DATA __far
|
---|
537 | #else
|
---|
538 | # define BS3_FAR
|
---|
539 | # define BS3_NEAR
|
---|
540 | # define BS3_FAR_CODE
|
---|
541 | # define BS3_NEAR_CODE
|
---|
542 | # define BS3_FAR_DATA
|
---|
543 | #endif
|
---|
544 |
|
---|
545 | #if ARCH_BITS == 16 || defined(DOXYGEN_RUNNING)
|
---|
546 | /** @def BS3_FP_SEG
|
---|
547 | * Get the selector (segment) part of a far pointer.
|
---|
548 | *
|
---|
549 | * @returns selector.
|
---|
550 | * @param a_pv Far pointer.
|
---|
551 | */
|
---|
552 | # define BS3_FP_SEG(a_pv) ((uint16_t)(__segment)(void BS3_FAR *)(a_pv))
|
---|
553 | /** @def BS3_FP_OFF
|
---|
554 | * Get the segment offset part of a far pointer.
|
---|
555 | *
|
---|
556 | * For sake of convenience, this works like a uintptr_t cast in 32-bit and
|
---|
557 | * 64-bit code.
|
---|
558 | *
|
---|
559 | * @returns offset.
|
---|
560 | * @param a_pv Far pointer.
|
---|
561 | */
|
---|
562 | # define BS3_FP_OFF(a_pv) ((uint16_t)(void __near *)(a_pv))
|
---|
563 | /** @def BS3_FP_MAKE
|
---|
564 | * Create a far pointer.
|
---|
565 | *
|
---|
566 | * @returns Far pointer.
|
---|
567 | * @param a_uSeg The selector/segment.
|
---|
568 | * @param a_off The offset into the segment.
|
---|
569 | */
|
---|
570 | # define BS3_FP_MAKE(a_uSeg, a_off) (((__segment)(a_uSeg)) :> ((void __near *)(a_off)))
|
---|
571 | #else
|
---|
572 | # define BS3_FP_OFF(a_pv) ((uintptr_t)(a_pv))
|
---|
573 | #endif
|
---|
574 |
|
---|
575 | /** @def BS3_MAKE_PROT_R0PTR_FROM_FLAT
|
---|
576 | * Creates a protected mode pointer from a flat address.
|
---|
577 | *
|
---|
578 | * For sake of convenience, this macro also works in 32-bit and 64-bit mode,
|
---|
579 | * only there it doesn't return a far pointer but a flat point.
|
---|
580 | *
|
---|
581 | * @returns far void pointer if 16-bit code, near/flat void pointer in 32-bit
|
---|
582 | * and 64-bit.
|
---|
583 | * @param a_uFlat Flat address in the first 16MB. */
|
---|
584 | #if ARCH_BITS == 16
|
---|
585 | # define BS3_MAKE_PROT_R0PTR_FROM_FLAT(a_uFlat) \
|
---|
586 | BS3_FP_MAKE(((uint16_t)(a_uFlat >> 16) << 3) + BS3_SEL_TILED, (uint16_t)(a_uFlat))
|
---|
587 | #else
|
---|
588 | # define BS3_MAKE_PROT_R0PTR_FROM_FLAT(a_uFlat) ((void *)(uintptr_t)(a_uFlat))
|
---|
589 | #endif
|
---|
590 |
|
---|
591 | /** @def BS3_MAKE_PROT_R0PTR_FROM_REAL
|
---|
592 | * Creates a protected mode pointer from a far real mode address.
|
---|
593 | *
|
---|
594 | * For sake of convenience, this macro also works in 32-bit and 64-bit mode,
|
---|
595 | * only there it doesn't return a far pointer but a flat point.
|
---|
596 | *
|
---|
597 | * @returns far void pointer if 16-bit code, near/flat void pointer in 32-bit
|
---|
598 | * and 64-bit.
|
---|
599 | * @param a_uSeg The selector/segment.
|
---|
600 | * @param a_off The offset into the segment.
|
---|
601 | */
|
---|
602 | #if ARCH_BITS == 16
|
---|
603 | # define BS3_MAKE_PROT_R0PTR_FROM_REAL(a_uSeg, a_off) BS3_MAKE_PROT_R0PTR_FROM_FLAT(((uint32_t)(a_uSeg) << 4) + (uint16_t)(a_off))
|
---|
604 | #else
|
---|
605 | # define BS3_MAKE_PROT_R0PTR_FROM_REAL(a_uSeg, a_off) ( (void *)(uintptr_t)(((uint32_t)(a_uSeg) << 4) + (uint16_t)(a_off)) )
|
---|
606 | #endif
|
---|
607 |
|
---|
608 |
|
---|
609 | /** @def BS3_CALL
|
---|
610 | * The calling convension used by BS3 functions. */
|
---|
611 | #if ARCH_BITS != 64
|
---|
612 | # define BS3_CALL __cdecl
|
---|
613 | #elif !defined(_MSC_VER)
|
---|
614 | # define BS3_CALL __attribute__((__ms_abi__))
|
---|
615 | #else
|
---|
616 | # define BS3_CALL
|
---|
617 | #endif
|
---|
618 |
|
---|
619 | /** @def IN_BS3KIT
|
---|
620 | * Indicates that we're in the same link job as the BS3Kit code. */
|
---|
621 | #ifdef DOXYGEN_RUNNING
|
---|
622 | # define IN_BS3KIT
|
---|
623 | #endif
|
---|
624 |
|
---|
625 | /** @def BS3_DECL
|
---|
626 | * Declares a BS3Kit function with default far/near.
|
---|
627 | *
|
---|
628 | * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
|
---|
629 | *
|
---|
630 | * @param a_Type The return type. */
|
---|
631 | #if ARCH_BITS != 16 || !defined(BS3_USE_ALT_16BIT_TEXT_SEG)
|
---|
632 | # define BS3_DECL(a_Type) BS3_DECL_NEAR(a_Type)
|
---|
633 | #else
|
---|
634 | # define BS3_DECL(a_Type) BS3_DECL_FAR(a_Type)
|
---|
635 | #endif
|
---|
636 |
|
---|
637 | /** @def BS3_DECL_NEAR
|
---|
638 | * Declares a BS3Kit function, always near everywhere.
|
---|
639 | *
|
---|
640 | * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
|
---|
641 | *
|
---|
642 | * @param a_Type The return type. */
|
---|
643 | #ifdef IN_BS3KIT
|
---|
644 | # define BS3_DECL_NEAR(a_Type) DECLEXPORT(a_Type) BS3_NEAR_CODE BS3_CALL
|
---|
645 | #else
|
---|
646 | # define BS3_DECL_NEAR(a_Type) DECLIMPORT(a_Type) BS3_NEAR_CODE BS3_CALL
|
---|
647 | #endif
|
---|
648 |
|
---|
649 | /** @def BS3_DECL_FAR
|
---|
650 | * Declares a BS3Kit function, far 16-bit, otherwise near.
|
---|
651 | *
|
---|
652 | * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
|
---|
653 | *
|
---|
654 | * @param a_Type The return type. */
|
---|
655 | #ifdef IN_BS3KIT
|
---|
656 | # define BS3_DECL_FAR(a_Type) DECLEXPORT(a_Type) BS3_FAR_CODE BS3_CALL
|
---|
657 | #else
|
---|
658 | # define BS3_DECL_FAR(a_Type) DECLIMPORT(a_Type) BS3_FAR_CODE BS3_CALL
|
---|
659 | #endif
|
---|
660 |
|
---|
661 | /** @def BS3_DECL_CALLBACK
|
---|
662 | * Declares a BS3Kit callback function (typically static).
|
---|
663 | *
|
---|
664 | * @param a_Type The return type. */
|
---|
665 | #ifdef IN_BS3KIT
|
---|
666 | # define BS3_DECL_CALLBACK(a_Type) a_Type BS3_FAR_CODE BS3_CALL
|
---|
667 | #else
|
---|
668 | # define BS3_DECL_CALLBACK(a_Type) a_Type BS3_FAR_CODE BS3_CALL
|
---|
669 | #endif
|
---|
670 |
|
---|
671 | /** @def BS3_DECL_NEAR_CALLBACK
|
---|
672 | * Declares a near BS3Kit callback function (typically static).
|
---|
673 | *
|
---|
674 | * 16-bit users must be in CGROUP16!
|
---|
675 | *
|
---|
676 | * @param a_Type The return type. */
|
---|
677 | #ifdef IN_BS3KIT
|
---|
678 | # define BS3_DECL_NEAR_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL
|
---|
679 | #else
|
---|
680 | # define BS3_DECL_NEAR_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL
|
---|
681 | #endif
|
---|
682 |
|
---|
683 | /**
|
---|
684 | * Constructs a common name.
|
---|
685 | *
|
---|
686 | * Example: BS3_CMN_NM(Bs3Shutdown)
|
---|
687 | *
|
---|
688 | * @param a_Name The name of the function or global variable.
|
---|
689 | */
|
---|
690 | #define BS3_CMN_NM(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
|
---|
691 |
|
---|
692 | /**
|
---|
693 | * Constructs a common function name, far in 16-bit code.
|
---|
694 | *
|
---|
695 | * Example: BS3_CMN_FAR_NM(Bs3Shutdown)
|
---|
696 | *
|
---|
697 | * @param a_Name The name of the function.
|
---|
698 | */
|
---|
699 | #if ARCH_BITS == 16
|
---|
700 | # define BS3_CMN_FAR_NM(a_Name) RT_CONCAT(a_Name,_f16)
|
---|
701 | #else
|
---|
702 | # define BS3_CMN_FAR_NM(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
|
---|
703 | #endif
|
---|
704 |
|
---|
705 | /**
|
---|
706 | * Constructs a common function name, far or near as defined by the source.
|
---|
707 | *
|
---|
708 | * Which to use in 16-bit mode is defined by BS3_USE_ALT_16BIT_TEXT_SEG. In
|
---|
709 | * 32-bit and 64-bit mode there are no far symbols, only near ones.
|
---|
710 | *
|
---|
711 | * Example: BS3_CMN_FN_NM(Bs3Shutdown)
|
---|
712 | *
|
---|
713 | * @param a_Name The name of the function.
|
---|
714 | */
|
---|
715 | #if ARCH_BITS != 16 || !defined(BS3_USE_ALT_16BIT_TEXT_SEG)
|
---|
716 | # define BS3_CMN_FN_NM(a_Name) BS3_CMN_NM(a_Name)
|
---|
717 | #else
|
---|
718 | # define BS3_CMN_FN_NM(a_Name) BS3_CMN_FAR_NM(a_Name)
|
---|
719 | #endif
|
---|
720 |
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * Constructs a data name.
|
---|
724 | *
|
---|
725 | * This glosses over the underscore prefix usage of our 16-bit, 32-bit and
|
---|
726 | * 64-bit compilers.
|
---|
727 | *
|
---|
728 | * Example: @code{.c}
|
---|
729 | * \#define Bs3Gdt BS3_DATA_NM(Bs3Gdt)
|
---|
730 | * extern X86DESC BS3_FAR_DATA Bs3Gdt
|
---|
731 | * @endcode
|
---|
732 | *
|
---|
733 | * @param a_Name The name of the global variable.
|
---|
734 | * @remarks Mainly used in bs3kit-mangling.h, internal headers and templates.
|
---|
735 | */
|
---|
736 | //converter does this now//#if ARCH_BITS == 64
|
---|
737 | //converter does this now//# define BS3_DATA_NM(a_Name) RT_CONCAT(_,a_Name)
|
---|
738 | //converter does this now//#else
|
---|
739 | # define BS3_DATA_NM(a_Name) a_Name
|
---|
740 | //converter does this now//#endif
|
---|
741 |
|
---|
742 | /**
|
---|
743 | * Template for creating a pointer union type.
|
---|
744 | * @param a_BaseName The base type name.
|
---|
745 | * @param a_Modifiers The type modifier.
|
---|
746 | */
|
---|
747 | #define BS3_PTR_UNION_TEMPLATE(a_BaseName, a_Modifiers) \
|
---|
748 | typedef union a_BaseName \
|
---|
749 | { \
|
---|
750 | /** Pointer into the void. */ \
|
---|
751 | a_Modifiers void BS3_FAR *pv; \
|
---|
752 | /** As a signed integer. */ \
|
---|
753 | intptr_t i; \
|
---|
754 | /** As an unsigned integer. */ \
|
---|
755 | uintptr_t u; \
|
---|
756 | /** Pointer to char value. */ \
|
---|
757 | a_Modifiers char BS3_FAR *pch; \
|
---|
758 | /** Pointer to char value. */ \
|
---|
759 | a_Modifiers unsigned char BS3_FAR *puch; \
|
---|
760 | /** Pointer to a int value. */ \
|
---|
761 | a_Modifiers int BS3_FAR *pi; \
|
---|
762 | /** Pointer to a unsigned int value. */ \
|
---|
763 | a_Modifiers unsigned int BS3_FAR *pu; \
|
---|
764 | /** Pointer to a long value. */ \
|
---|
765 | a_Modifiers long BS3_FAR *pl; \
|
---|
766 | /** Pointer to a long value. */ \
|
---|
767 | a_Modifiers unsigned long BS3_FAR *pul; \
|
---|
768 | /** Pointer to a memory size value. */ \
|
---|
769 | a_Modifiers size_t BS3_FAR *pcb; \
|
---|
770 | /** Pointer to a byte value. */ \
|
---|
771 | a_Modifiers uint8_t BS3_FAR *pb; \
|
---|
772 | /** Pointer to a 8-bit unsigned value. */ \
|
---|
773 | a_Modifiers uint8_t BS3_FAR *pu8; \
|
---|
774 | /** Pointer to a 16-bit unsigned value. */ \
|
---|
775 | a_Modifiers uint16_t BS3_FAR *pu16; \
|
---|
776 | /** Pointer to a 32-bit unsigned value. */ \
|
---|
777 | a_Modifiers uint32_t BS3_FAR *pu32; \
|
---|
778 | /** Pointer to a 64-bit unsigned value. */ \
|
---|
779 | a_Modifiers uint64_t BS3_FAR *pu64; \
|
---|
780 | /** Pointer to a UTF-16 character. */ \
|
---|
781 | a_Modifiers RTUTF16 BS3_FAR *pwc; \
|
---|
782 | /** Pointer to a UUID character. */ \
|
---|
783 | a_Modifiers RTUUID BS3_FAR *pUuid; \
|
---|
784 | } a_BaseName; \
|
---|
785 | /** Pointer to a pointer union. */ \
|
---|
786 | typedef a_BaseName *RT_CONCAT(P,a_BaseName)
|
---|
787 | BS3_PTR_UNION_TEMPLATE(BS3PTRUNION, RT_NOTHING);
|
---|
788 | BS3_PTR_UNION_TEMPLATE(BS3CPTRUNION, const);
|
---|
789 | BS3_PTR_UNION_TEMPLATE(BS3VPTRUNION, volatile);
|
---|
790 | BS3_PTR_UNION_TEMPLATE(BS3CVPTRUNION, const volatile);
|
---|
791 |
|
---|
792 | /** Generic far function type. */
|
---|
793 | typedef BS3_DECL_FAR(void) FNBS3FAR(void);
|
---|
794 | /** Generic far function pointer type. */
|
---|
795 | typedef FNBS3FAR *FPFNBS3FAR;
|
---|
796 |
|
---|
797 | /** Generic near function type. */
|
---|
798 | typedef BS3_DECL_NEAR(void) FNBS3NEAR(void);
|
---|
799 | /** Generic near function pointer type. */
|
---|
800 | typedef FNBS3NEAR *PFNBS3NEAR;
|
---|
801 |
|
---|
802 | /** Generic far 16:16 function pointer type for address conversion functions. */
|
---|
803 | #if ARCH_BITS == 16
|
---|
804 | typedef FPFNBS3FAR PFNBS3FARADDRCONV;
|
---|
805 | #else
|
---|
806 | typedef uint32_t PFNBS3FARADDRCONV;
|
---|
807 | #endif
|
---|
808 |
|
---|
809 | /** The system call vector. */
|
---|
810 | #define BS3_TRAP_SYSCALL UINT8_C(0x20)
|
---|
811 |
|
---|
812 | /** @name System call numbers (ax).
|
---|
813 | * Paramenters are generally passed in registers specific to each system call,
|
---|
814 | * however cx:xSI is used for passing a pointer parameter.
|
---|
815 | * @{ */
|
---|
816 | /** Print char (cl). */
|
---|
817 | #define BS3_SYSCALL_PRINT_CHR UINT16_C(0x0001)
|
---|
818 | /** Print string (pointer in cx:xSI, length in dx). */
|
---|
819 | #define BS3_SYSCALL_PRINT_STR UINT16_C(0x0002)
|
---|
820 | /** Switch to ring-0. */
|
---|
821 | #define BS3_SYSCALL_TO_RING0 UINT16_C(0x0003)
|
---|
822 | /** Switch to ring-1. */
|
---|
823 | #define BS3_SYSCALL_TO_RING1 UINT16_C(0x0004)
|
---|
824 | /** Switch to ring-2. */
|
---|
825 | #define BS3_SYSCALL_TO_RING2 UINT16_C(0x0005)
|
---|
826 | /** Switch to ring-3. */
|
---|
827 | #define BS3_SYSCALL_TO_RING3 UINT16_C(0x0006)
|
---|
828 | /** Restore context (pointer in cx:xSI, flags in dx). */
|
---|
829 | #define BS3_SYSCALL_RESTORE_CTX UINT16_C(0x0007)
|
---|
830 | /** Set DRx register (value in ESI, register number in dl). */
|
---|
831 | #define BS3_SYSCALL_SET_DRX UINT16_C(0x0008)
|
---|
832 | /** Get DRx register (register number in dl, value returned in ax:dx). */
|
---|
833 | #define BS3_SYSCALL_GET_DRX UINT16_C(0x0009)
|
---|
834 | /** Set CRx register (value in ESI, register number in dl). */
|
---|
835 | #define BS3_SYSCALL_SET_CRX UINT16_C(0x000a)
|
---|
836 | /** Get CRx register (register number in dl, value returned in ax:dx). */
|
---|
837 | #define BS3_SYSCALL_GET_CRX UINT16_C(0x000b)
|
---|
838 | /** @} */
|
---|
839 |
|
---|
840 |
|
---|
841 |
|
---|
842 | /** @defgroup grp_bs3kit_system System Structures
|
---|
843 | * @{ */
|
---|
844 | /** The GDT, indexed by BS3_SEL_XXX shifted by 3. */
|
---|
845 | extern X86DESC BS3_FAR_DATA Bs3Gdt[(BS3_SEL_GDT_LIMIT + 1) / 8];
|
---|
846 |
|
---|
847 | extern X86DESC64 BS3_FAR_DATA Bs3Gdt_Ldt; /**< @see BS3_SEL_LDT */
|
---|
848 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss16; /**< @see BS3_SEL_TSS16 */
|
---|
849 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss16DoubleFault; /**< @see BS3_SEL_TSS16_DF */
|
---|
850 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss16Spare0; /**< @see BS3_SEL_TSS16_SPARE0 */
|
---|
851 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss16Spare1; /**< @see BS3_SEL_TSS16_SPARE1 */
|
---|
852 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss32; /**< @see BS3_SEL_TSS32 */
|
---|
853 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss32DoubleFault; /**< @see BS3_SEL_TSS32_DF */
|
---|
854 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss32Spare0; /**< @see BS3_SEL_TSS32_SPARE0 */
|
---|
855 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss32Spare1; /**< @see BS3_SEL_TSS32_SPARE1 */
|
---|
856 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss32IobpIntRedirBm; /**< @see BS3_SEL_TSS32_IOBP_IRB */
|
---|
857 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss32IntRedirBm; /**< @see BS3_SEL_TSS32_IRB */
|
---|
858 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss64; /**< @see BS3_SEL_TSS64 */
|
---|
859 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss64Spare0; /**< @see BS3_SEL_TSS64_SPARE0 */
|
---|
860 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss64Spare1; /**< @see BS3_SEL_TSS64_SPARE1 */
|
---|
861 | extern X86DESC BS3_FAR_DATA Bs3Gdte_Tss64Iobp; /**< @see BS3_SEL_TSS64_IOBP */
|
---|
862 | extern X86DESC BS3_FAR_DATA Bs3Gdte_RMTEXT16_CS; /**< @see BS3_SEL_RMTEXT16_CS */
|
---|
863 | extern X86DESC BS3_FAR_DATA Bs3Gdte_X0TEXT16_CS; /**< @see BS3_SEL_X0TEXT16_CS */
|
---|
864 | extern X86DESC BS3_FAR_DATA Bs3Gdte_X1TEXT16_CS; /**< @see BS3_SEL_X1TEXT16_CS */
|
---|
865 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_MMIO16; /**< @see BS3_SEL_VMMDEV_MMIO16 */
|
---|
866 |
|
---|
867 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_First; /**< @see BS3_SEL_R0_FIRST */
|
---|
868 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS16; /**< @see BS3_SEL_R0_CS16 */
|
---|
869 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_DS16; /**< @see BS3_SEL_R0_DS16 */
|
---|
870 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_SS16; /**< @see BS3_SEL_R0_SS16 */
|
---|
871 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS32; /**< @see BS3_SEL_R0_CS32 */
|
---|
872 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_DS32; /**< @see BS3_SEL_R0_DS32 */
|
---|
873 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_SS32; /**< @see BS3_SEL_R0_SS32 */
|
---|
874 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS64; /**< @see BS3_SEL_R0_CS64 */
|
---|
875 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_DS64; /**< @see BS3_SEL_R0_DS64 */
|
---|
876 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS16_EO; /**< @see BS3_SEL_R0_CS16_EO */
|
---|
877 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS16_CNF; /**< @see BS3_SEL_R0_CS16_CNF */
|
---|
878 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS16_CND_EO; /**< @see BS3_SEL_R0_CS16_CNF_EO */
|
---|
879 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS32_EO; /**< @see BS3_SEL_R0_CS32_EO */
|
---|
880 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS32_CNF; /**< @see BS3_SEL_R0_CS32_CNF */
|
---|
881 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS32_CNF_EO; /**< @see BS3_SEL_R0_CS32_CNF_EO */
|
---|
882 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS64_EO; /**< @see BS3_SEL_R0_CS64_EO */
|
---|
883 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS64_CNF; /**< @see BS3_SEL_R0_CS64_CNF */
|
---|
884 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R0_CS64_CNF_EO; /**< @see BS3_SEL_R0_CS64_CNF_EO */
|
---|
885 |
|
---|
886 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_First; /**< @see BS3_SEL_R1_FIRST */
|
---|
887 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS16; /**< @see BS3_SEL_R1_CS16 */
|
---|
888 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_DS16; /**< @see BS3_SEL_R1_DS16 */
|
---|
889 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_SS16; /**< @see BS3_SEL_R1_SS16 */
|
---|
890 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS32; /**< @see BS3_SEL_R1_CS32 */
|
---|
891 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_DS32; /**< @see BS3_SEL_R1_DS32 */
|
---|
892 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_SS32; /**< @see BS3_SEL_R1_SS32 */
|
---|
893 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS64; /**< @see BS3_SEL_R1_CS64 */
|
---|
894 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_DS64; /**< @see BS3_SEL_R1_DS64 */
|
---|
895 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS16_EO; /**< @see BS3_SEL_R1_CS16_EO */
|
---|
896 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS16_CNF; /**< @see BS3_SEL_R1_CS16_CNF */
|
---|
897 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS16_CND_EO; /**< @see BS3_SEL_R1_CS16_CNF_EO */
|
---|
898 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS32_EO; /**< @see BS3_SEL_R1_CS32_EO */
|
---|
899 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS32_CNF; /**< @see BS3_SEL_R1_CS32_CNF */
|
---|
900 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS32_CNF_EO; /**< @see BS3_SEL_R1_CS32_CNF_EO */
|
---|
901 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS64_EO; /**< @see BS3_SEL_R1_CS64_EO */
|
---|
902 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS64_CNF; /**< @see BS3_SEL_R1_CS64_CNF */
|
---|
903 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R1_CS64_CNF_EO; /**< @see BS3_SEL_R1_CS64_CNF_EO */
|
---|
904 |
|
---|
905 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_First; /**< @see BS3_SEL_R2_FIRST */
|
---|
906 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS16; /**< @see BS3_SEL_R2_CS16 */
|
---|
907 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_DS16; /**< @see BS3_SEL_R2_DS16 */
|
---|
908 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_SS16; /**< @see BS3_SEL_R2_SS16 */
|
---|
909 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS32; /**< @see BS3_SEL_R2_CS32 */
|
---|
910 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_DS32; /**< @see BS3_SEL_R2_DS32 */
|
---|
911 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_SS32; /**< @see BS3_SEL_R2_SS32 */
|
---|
912 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS64; /**< @see BS3_SEL_R2_CS64 */
|
---|
913 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_DS64; /**< @see BS3_SEL_R2_DS64 */
|
---|
914 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS16_EO; /**< @see BS3_SEL_R2_CS16_EO */
|
---|
915 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS16_CNF; /**< @see BS3_SEL_R2_CS16_CNF */
|
---|
916 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS16_CND_EO; /**< @see BS3_SEL_R2_CS16_CNF_EO */
|
---|
917 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS32_EO; /**< @see BS3_SEL_R2_CS32_EO */
|
---|
918 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS32_CNF; /**< @see BS3_SEL_R2_CS32_CNF */
|
---|
919 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS32_CNF_EO; /**< @see BS3_SEL_R2_CS32_CNF_EO */
|
---|
920 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS64_EO; /**< @see BS3_SEL_R2_CS64_EO */
|
---|
921 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS64_CNF; /**< @see BS3_SEL_R2_CS64_CNF */
|
---|
922 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R2_CS64_CNF_EO; /**< @see BS3_SEL_R2_CS64_CNF_EO */
|
---|
923 |
|
---|
924 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_First; /**< @see BS3_SEL_R3_FIRST */
|
---|
925 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS16; /**< @see BS3_SEL_R3_CS16 */
|
---|
926 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_DS16; /**< @see BS3_SEL_R3_DS16 */
|
---|
927 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_SS16; /**< @see BS3_SEL_R3_SS16 */
|
---|
928 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS32; /**< @see BS3_SEL_R3_CS32 */
|
---|
929 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_DS32; /**< @see BS3_SEL_R3_DS32 */
|
---|
930 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_SS32; /**< @see BS3_SEL_R3_SS32 */
|
---|
931 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS64; /**< @see BS3_SEL_R3_CS64 */
|
---|
932 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_DS64; /**< @see BS3_SEL_R3_DS64 */
|
---|
933 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS16_EO; /**< @see BS3_SEL_R3_CS16_EO */
|
---|
934 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS16_CNF; /**< @see BS3_SEL_R3_CS16_CNF */
|
---|
935 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS16_CND_EO; /**< @see BS3_SEL_R3_CS16_CNF_EO */
|
---|
936 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS32_EO; /**< @see BS3_SEL_R3_CS32_EO */
|
---|
937 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS32_CNF; /**< @see BS3_SEL_R3_CS32_CNF */
|
---|
938 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS32_CNF_EO; /**< @see BS3_SEL_R3_CS32_CNF_EO */
|
---|
939 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS64_EO; /**< @see BS3_SEL_R3_CS64_EO */
|
---|
940 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS64_CNF; /**< @see BS3_SEL_R3_CS64_CNF */
|
---|
941 | extern X86DESC BS3_FAR_DATA Bs3Gdte_R3_CS64_CNF_EO; /**< @see BS3_SEL_R3_CS64_CNF_EO */
|
---|
942 |
|
---|
943 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare00; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_00 */
|
---|
944 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare01; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_01 */
|
---|
945 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare02; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_02 */
|
---|
946 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare03; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_03 */
|
---|
947 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare04; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_04 */
|
---|
948 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare05; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_05 */
|
---|
949 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare06; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_06 */
|
---|
950 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare07; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_07 */
|
---|
951 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare08; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_08 */
|
---|
952 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare09; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_09 */
|
---|
953 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare0a; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0a */
|
---|
954 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare0b; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0b */
|
---|
955 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare0c; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0c */
|
---|
956 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare0d; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0d */
|
---|
957 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare0e; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0e */
|
---|
958 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare0f; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0f */
|
---|
959 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare10; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_10 */
|
---|
960 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare11; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_11 */
|
---|
961 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare12; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_12 */
|
---|
962 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare13; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_13 */
|
---|
963 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare14; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_14 */
|
---|
964 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare15; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_15 */
|
---|
965 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare16; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_16 */
|
---|
966 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare17; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_17 */
|
---|
967 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare18; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_18 */
|
---|
968 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare19; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_19 */
|
---|
969 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare1a; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1a */
|
---|
970 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare1b; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1b */
|
---|
971 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare1c; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1c */
|
---|
972 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare1d; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1d */
|
---|
973 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare1e; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1e */
|
---|
974 | extern X86DESC BS3_FAR_DATA Bs3GdteSpare1f; /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1f */
|
---|
975 |
|
---|
976 | /** GDTs setting up the tiled 16-bit access to the first 16 MBs of memory.
|
---|
977 | * @see BS3_SEL_TILED, BS3_SEL_TILED_LAST, BS3_SEL_TILED_AREA_SIZE */
|
---|
978 | extern X86DESC BS3_FAR_DATA Bs3GdteTiled[256];
|
---|
979 | /** Free GDTes, part \#1. */
|
---|
980 | extern X86DESC BS3_FAR_DATA Bs3GdteFreePart1[64];
|
---|
981 | /** The BS3TEXT16/BS3CLASS16CODE GDT entry. @see BS3_SEL_TEXT16 */
|
---|
982 | extern X86DESC BS3_FAR_DATA Bs3Gdte_CODE16;
|
---|
983 | /** Free GDTes, part \#2. */
|
---|
984 | extern X86DESC BS3_FAR_DATA Bs3GdteFreePart2[511];
|
---|
985 | /** The BS3SYSTEM16 GDT entry. */
|
---|
986 | extern X86DESC BS3_FAR_DATA Bs3Gdte_SYSTEM16;
|
---|
987 | /** Free GDTes, part \#3. */
|
---|
988 | extern X86DESC BS3_FAR_DATA Bs3GdteFreePart3[223];
|
---|
989 | /** The BS3DATA16/BS3KIT_GRPNM_DATA16 GDT entry. */
|
---|
990 | extern X86DESC BS3_FAR_DATA Bs3Gdte_DATA16;
|
---|
991 |
|
---|
992 | /** Free GDTes, part \#4. */
|
---|
993 | extern X86DESC BS3_FAR_DATA Bs3GdteFreePart4[211];
|
---|
994 |
|
---|
995 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage08; /**< GDT entry 8 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_08 */
|
---|
996 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage07; /**< GDT entry 7 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_07 */
|
---|
997 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage06; /**< GDT entry 6 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_06 */
|
---|
998 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage05; /**< GDT entry 5 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_05 */
|
---|
999 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage04; /**< GDT entry 4 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_04 */
|
---|
1000 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage03; /**< GDT entry 3 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_03 */
|
---|
1001 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage02; /**< GDT entry 2 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_02 */
|
---|
1002 | extern X86DESC BS3_FAR_DATA Bs3GdtePreTestPage01; /**< GDT entry 1 selectors prior to the test page, testcase resource. @see BS3_SEL_PRE_TEST_PAGE_01 */
|
---|
1003 | /** Array of GDT entries starting on a page boundrary and filling (almost) the
|
---|
1004 | * whole page. This is for playing with paging and GDT usage.
|
---|
1005 | * @see BS3_SEL_TEST_PAGE */
|
---|
1006 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage[2043];
|
---|
1007 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage00; /**< GDT entry 0 on the test page (convenience). @see BS3_SEL_TEST_PAGE_00 */
|
---|
1008 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage01; /**< GDT entry 1 on the test page (convenience). @see BS3_SEL_TEST_PAGE_01 */
|
---|
1009 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage02; /**< GDT entry 2 on the test page (convenience). @see BS3_SEL_TEST_PAGE_02 */
|
---|
1010 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage03; /**< GDT entry 3 on the test page (convenience). @see BS3_SEL_TEST_PAGE_03 */
|
---|
1011 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage04; /**< GDT entry 4 on the test page (convenience). @see BS3_SEL_TEST_PAGE_04 */
|
---|
1012 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage05; /**< GDT entry 5 on the test page (convenience). @see BS3_SEL_TEST_PAGE_05 */
|
---|
1013 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage06; /**< GDT entry 6 on the test page (convenience). @see BS3_SEL_TEST_PAGE_06 */
|
---|
1014 | extern X86DESC BS3_FAR_DATA Bs3GdteTestPage07; /**< GDT entry 7 on the test page (convenience). @see BS3_SEL_TEST_PAGE_07 */
|
---|
1015 |
|
---|
1016 | /** The end of the GDT (exclusive - contains eye-catcher string). */
|
---|
1017 | extern X86DESC BS3_FAR_DATA Bs3GdtEnd;
|
---|
1018 |
|
---|
1019 | /** The default 16-bit TSS. */
|
---|
1020 | extern X86TSS16 BS3_FAR_DATA Bs3Tss16;
|
---|
1021 | extern X86TSS16 BS3_FAR_DATA Bs3Tss16DoubleFault;
|
---|
1022 | extern X86TSS16 BS3_FAR_DATA Bs3Tss16Spare0;
|
---|
1023 | extern X86TSS16 BS3_FAR_DATA Bs3Tss16Spare1;
|
---|
1024 | /** The default 32-bit TSS. */
|
---|
1025 | extern X86TSS32 BS3_FAR_DATA Bs3Tss32;
|
---|
1026 | extern X86TSS32 BS3_FAR_DATA Bs3Tss32DoubleFault;
|
---|
1027 | extern X86TSS32 BS3_FAR_DATA Bs3Tss32Spare0;
|
---|
1028 | extern X86TSS32 BS3_FAR_DATA Bs3Tss32Spare1;
|
---|
1029 | /** The default 64-bit TSS. */
|
---|
1030 | extern X86TSS64 BS3_FAR_DATA Bs3Tss64;
|
---|
1031 | extern X86TSS64 BS3_FAR_DATA Bs3Tss64Spare0;
|
---|
1032 | extern X86TSS64 BS3_FAR_DATA Bs3Tss64Spare1;
|
---|
1033 | extern X86TSS64 BS3_FAR_DATA Bs3Tss64WithIopb;
|
---|
1034 | extern X86TSS32 BS3_FAR_DATA Bs3Tss32WithIopb;
|
---|
1035 | /** Interrupt redirection bitmap used by Bs3Tss32WithIopb. */
|
---|
1036 | extern uint8_t BS3_FAR_DATA Bs3SharedIntRedirBm[32];
|
---|
1037 | /** I/O permission bitmap used by Bs3Tss32WithIopb and Bs3Tss64WithIopb. */
|
---|
1038 | extern uint8_t BS3_FAR_DATA Bs3SharedIobp[8192+2];
|
---|
1039 | /** End of the I/O permission bitmap (exclusive). */
|
---|
1040 | extern uint8_t BS3_FAR_DATA Bs3SharedIobpEnd;
|
---|
1041 | /** 16-bit IDT. */
|
---|
1042 | extern X86DESC BS3_FAR_DATA Bs3Idt16[256];
|
---|
1043 | /** 32-bit IDT. */
|
---|
1044 | extern X86DESC BS3_FAR_DATA Bs3Idt32[256];
|
---|
1045 | /** 64-bit IDT. */
|
---|
1046 | extern X86DESC64 BS3_FAR_DATA Bs3Idt64[256];
|
---|
1047 | /** Structure for the LIDT instruction for loading the 16-bit IDT. */
|
---|
1048 | extern X86XDTR64 BS3_FAR_DATA Bs3Lidt_Idt16;
|
---|
1049 | /** Structure for the LIDT instruction for loading the 32-bit IDT. */
|
---|
1050 | extern X86XDTR64 BS3_FAR_DATA Bs3Lidt_Idt32;
|
---|
1051 | /** Structure for the LIDT instruction for loading the 64-bit IDT. */
|
---|
1052 | extern X86XDTR64 BS3_FAR_DATA Bs3Lidt_Idt64;
|
---|
1053 | /** Structure for the LIDT instruction for loading the real mode interrupt
|
---|
1054 | * vector table. */
|
---|
1055 | extern X86XDTR64 BS3_FAR_DATA Bs3Lidt_Ivt;
|
---|
1056 | /** Structure for the LGDT instruction for loading the current GDT. */
|
---|
1057 | extern X86XDTR64 BS3_FAR_DATA Bs3Lgdt_Gdt;
|
---|
1058 | /** Structure for the LGDT instruction for loading the default GDT. */
|
---|
1059 | extern X86XDTR64 BS3_FAR_DATA Bs3LgdtDef_Gdt;
|
---|
1060 | /** The LDT (all entries are empty, fill in for testing). */
|
---|
1061 | extern X86DESC BS3_FAR_DATA Bs3Ldt[116];
|
---|
1062 | /** The end of the LDT (exclusive). */
|
---|
1063 | extern X86DESC BS3_FAR_DATA Bs3LdtEnd;
|
---|
1064 |
|
---|
1065 | /** @} */
|
---|
1066 |
|
---|
1067 |
|
---|
1068 | /** @name Segment start and end markers, sizes.
|
---|
1069 | * @{ */
|
---|
1070 | /** Start of the BS3TEXT16 segment. */
|
---|
1071 | extern uint8_t BS3_FAR_DATA Bs3Text16_StartOfSegment;
|
---|
1072 | /** End of the BS3TEXT16 segment. */
|
---|
1073 | extern uint8_t BS3_FAR_DATA Bs3Text16_EndOfSegment;
|
---|
1074 | /** The size of the BS3TEXT16 segment. */
|
---|
1075 | extern uint16_t BS3_FAR_DATA Bs3Text16_Size;
|
---|
1076 |
|
---|
1077 | /** Start of the BS3SYSTEM16 segment. */
|
---|
1078 | extern uint8_t BS3_FAR_DATA Bs3System16_StartOfSegment;
|
---|
1079 | /** End of the BS3SYSTEM16 segment. */
|
---|
1080 | extern uint8_t BS3_FAR_DATA Bs3System16_EndOfSegment;
|
---|
1081 |
|
---|
1082 | /** Start of the BS3DATA16/BS3KIT_GRPNM_DATA16 segment. */
|
---|
1083 | extern uint8_t BS3_FAR_DATA Bs3Data16_StartOfSegment;
|
---|
1084 | /** End of the BS3DATA16/BS3KIT_GRPNM_DATA16 segment. */
|
---|
1085 | extern uint8_t BS3_FAR_DATA Bs3Data16_EndOfSegment;
|
---|
1086 |
|
---|
1087 | /** Start of the BS3RMTEXT16 segment. */
|
---|
1088 | extern uint8_t BS3_FAR_DATA Bs3RmText16_StartOfSegment;
|
---|
1089 | /** End of the BS3RMTEXT16 segment. */
|
---|
1090 | extern uint8_t BS3_FAR_DATA Bs3RmText16_EndOfSegment;
|
---|
1091 | /** The size of the BS3RMTEXT16 segment. */
|
---|
1092 | extern uint16_t BS3_FAR_DATA Bs3RmText16_Size;
|
---|
1093 | /** The flat start address of the BS3X0TEXT16 segment. */
|
---|
1094 | extern uint32_t BS3_FAR_DATA Bs3RmText16_FlatAddr;
|
---|
1095 |
|
---|
1096 | /** Start of the BS3X0TEXT16 segment. */
|
---|
1097 | extern uint8_t BS3_FAR_DATA Bs3X0Text16_StartOfSegment;
|
---|
1098 | /** End of the BS3X0TEXT16 segment. */
|
---|
1099 | extern uint8_t BS3_FAR_DATA Bs3X0Text16_EndOfSegment;
|
---|
1100 | /** The size of the BS3X0TEXT16 segment. */
|
---|
1101 | extern uint16_t BS3_FAR_DATA Bs3X0Text16_Size;
|
---|
1102 | /** The flat start address of the BS3X0TEXT16 segment. */
|
---|
1103 | extern uint32_t BS3_FAR_DATA Bs3X0Text16_FlatAddr;
|
---|
1104 |
|
---|
1105 | /** Start of the BS3X1TEXT16 segment. */
|
---|
1106 | extern uint8_t BS3_FAR_DATA Bs3X1Text16_StartOfSegment;
|
---|
1107 | /** End of the BS3X1TEXT16 segment. */
|
---|
1108 | extern uint8_t BS3_FAR_DATA Bs3X1Text16_EndOfSegment;
|
---|
1109 | /** The size of the BS3X1TEXT16 segment. */
|
---|
1110 | extern uint16_t BS3_FAR_DATA Bs3X1Text16_Size;
|
---|
1111 | /** The flat start address of the BS3X1TEXT16 segment. */
|
---|
1112 | extern uint32_t BS3_FAR_DATA Bs3X1Text16_FlatAddr;
|
---|
1113 |
|
---|
1114 | /** Start of the BS3TEXT32 segment. */
|
---|
1115 | extern uint8_t BS3_FAR_DATA Bs3Text32_StartOfSegment;
|
---|
1116 | /** Start of the BS3TEXT32 segment. */
|
---|
1117 | extern uint8_t BS3_FAR_DATA Bs3Text32_EndOfSegment;
|
---|
1118 |
|
---|
1119 | /** Start of the BS3DATA32 segment. */
|
---|
1120 | extern uint8_t BS3_FAR_DATA Bs3Data32_StartOfSegment;
|
---|
1121 | /** Start of the BS3DATA32 segment. */
|
---|
1122 | extern uint8_t BS3_FAR_DATA Bs3Data32_EndOfSegment;
|
---|
1123 |
|
---|
1124 | /** Start of the BS3TEXT64 segment. */
|
---|
1125 | extern uint8_t BS3_FAR_DATA Bs3Text64_StartOfSegment;
|
---|
1126 | /** Start of the BS3TEXT64 segment. */
|
---|
1127 | extern uint8_t BS3_FAR_DATA Bs3Text64_EndOfSegment;
|
---|
1128 |
|
---|
1129 | /** Start of the BS3DATA64 segment. */
|
---|
1130 | extern uint8_t BS3_FAR_DATA Bs3Data64_StartOfSegment;
|
---|
1131 | /** Start of the BS3DATA64 segment. */
|
---|
1132 | extern uint8_t BS3_FAR_DATA Bs3Data64_EndOfSegment;
|
---|
1133 |
|
---|
1134 | /** The size of the Data16, Text32, Text64, Data32 and Data64 blob. */
|
---|
1135 | extern uint32_t BS3_FAR_DATA Bs3Data16Thru64Text32And64_TotalSize;
|
---|
1136 | /** The total image size (from Text16 thu Data64). */
|
---|
1137 | extern uint32_t BS3_FAR_DATA Bs3TotalImageSize;
|
---|
1138 | /** @} */
|
---|
1139 |
|
---|
1140 |
|
---|
1141 | /** Lower case hex digits. */
|
---|
1142 | extern char const g_achBs3HexDigits[16+1];
|
---|
1143 | /** Upper case hex digits. */
|
---|
1144 | extern char const g_achBs3HexDigitsUpper[16+1];
|
---|
1145 |
|
---|
1146 |
|
---|
1147 | /** The current mode (BS3_MODE_XXX) of CPU \#0. */
|
---|
1148 | extern uint8_t g_bBs3CurrentMode;
|
---|
1149 |
|
---|
1150 | /** Hint for 16-bit trap handlers regarding the high word of EIP. */
|
---|
1151 | extern uint32_t g_uBs3TrapEipHint;
|
---|
1152 |
|
---|
1153 | /** Set to disable special V8086 \#GP and \#UD handling in Bs3TrapDefaultHandler.
|
---|
1154 | * This is useful for getting */
|
---|
1155 | extern bool volatile g_fBs3TrapNoV86Assist;
|
---|
1156 |
|
---|
1157 | /** Copy of the original real-mode interrupt vector table. */
|
---|
1158 | extern RTFAR16 g_aBs3RmIvtOriginal[256];
|
---|
1159 |
|
---|
1160 |
|
---|
1161 | #ifdef __WATCOMC__
|
---|
1162 | /**
|
---|
1163 | * Executes the SMSW instruction and returns the value.
|
---|
1164 | *
|
---|
1165 | * @returns Machine status word.
|
---|
1166 | */
|
---|
1167 | uint16_t Bs3AsmSmsw(void);
|
---|
1168 | # pragma aux Bs3AsmSmsw = \
|
---|
1169 | ".286" \
|
---|
1170 | "smsw ax" \
|
---|
1171 | value [ax] modify exact [ax] nomemory;
|
---|
1172 | #endif
|
---|
1173 |
|
---|
1174 |
|
---|
1175 | /** @defgroup bs3kit_cross_ptr Cross Context Pointer Type
|
---|
1176 | *
|
---|
1177 | * The cross context pointer type is
|
---|
1178 | *
|
---|
1179 | * @{ */
|
---|
1180 |
|
---|
1181 | /**
|
---|
1182 | * Cross context pointer base type.
|
---|
1183 | */
|
---|
1184 | typedef union BS3XPTR
|
---|
1185 | {
|
---|
1186 | /** The flat pointer. */
|
---|
1187 | uint32_t uFlat;
|
---|
1188 | /** 16-bit view. */
|
---|
1189 | struct
|
---|
1190 | {
|
---|
1191 | uint16_t uLow;
|
---|
1192 | uint16_t uHigh;
|
---|
1193 | } u;
|
---|
1194 | #if ARCH_BITS == 16
|
---|
1195 | /** 16-bit near pointer. */
|
---|
1196 | void __near *pvNear;
|
---|
1197 | #elif ARCH_BITS == 32
|
---|
1198 | /** 32-bit pointer. */
|
---|
1199 | void *pvRaw;
|
---|
1200 | #endif
|
---|
1201 | } BS3XPTR;
|
---|
1202 | AssertCompileSize(BS3XPTR, 4);
|
---|
1203 |
|
---|
1204 |
|
---|
1205 | /** @def BS3_XPTR_DEF_INTERNAL
|
---|
1206 | * Internal worker.
|
---|
1207 | *
|
---|
1208 | * @param a_Scope RT_NOTHING if structure or global, static or extern
|
---|
1209 | * otherwise.
|
---|
1210 | * @param a_Type The type we're pointing to.
|
---|
1211 | * @param a_Name The member or variable name.
|
---|
1212 | * @internal
|
---|
1213 | */
|
---|
1214 | #if ARCH_BITS == 16
|
---|
1215 | # define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
|
---|
1216 | a_Scope union \
|
---|
1217 | { \
|
---|
1218 | BS3XPTR XPtr; \
|
---|
1219 | a_Type __near *pNearTyped; \
|
---|
1220 | } a_Name
|
---|
1221 | #elif ARCH_BITS == 32
|
---|
1222 | # define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
|
---|
1223 | a_Scope union \
|
---|
1224 | { \
|
---|
1225 | BS3XPTR XPtr; \
|
---|
1226 | a_Type *pTyped; \
|
---|
1227 | } a_Name
|
---|
1228 | #elif ARCH_BITS == 64
|
---|
1229 | # define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
|
---|
1230 | a_Scope union \
|
---|
1231 | { \
|
---|
1232 | BS3XPTR XPtr; \
|
---|
1233 | } a_Name
|
---|
1234 | #else
|
---|
1235 | # error "ARCH_BITS"
|
---|
1236 | #endif
|
---|
1237 |
|
---|
1238 | /** @def BS3_XPTR_MEMBER
|
---|
1239 | * Defines a pointer member that can be shared by all CPU modes.
|
---|
1240 | *
|
---|
1241 | * @param a_Type The type we're pointing to.
|
---|
1242 | * @param a_Name The member or variable name.
|
---|
1243 | */
|
---|
1244 | #define BS3_XPTR_MEMBER(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name)
|
---|
1245 |
|
---|
1246 | /** @def BS3_XPTR_AUTO
|
---|
1247 | * Defines a pointer static variable for working with an XPTR.
|
---|
1248 | *
|
---|
1249 | * This is typically used to convert flat pointers into context specific
|
---|
1250 | * pointers.
|
---|
1251 | *
|
---|
1252 | * @param a_Type The type we're pointing to.
|
---|
1253 | * @param a_Name The member or variable name.
|
---|
1254 | */
|
---|
1255 | #define BS3_XPTR_AUTO(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name)
|
---|
1256 |
|
---|
1257 | /** @def BS3_XPTR_SET_FLAT
|
---|
1258 | * Sets a cross context pointer.
|
---|
1259 | *
|
---|
1260 | * @param a_Type The type we're pointing to.
|
---|
1261 | * @param a_Name The member or variable name.
|
---|
1262 | * @param a_uFlatPtr The flat pointer value to assign. If the x-pointer is
|
---|
1263 | * used in real mode, this must be less than 1MB.
|
---|
1264 | * Otherwise the limit is 16MB (due to selector tiling).
|
---|
1265 | */
|
---|
1266 | #define BS3_XPTR_SET_FLAT(a_Type, a_Name, a_uFlatPtr) \
|
---|
1267 | do { a_Name.XPtr.uFlat = (a_uFlatPtr); } while (0)
|
---|
1268 |
|
---|
1269 | /** @def BS3_XPTR_GET_FLAT
|
---|
1270 | * Gets the flat address of a cross context pointer.
|
---|
1271 | *
|
---|
1272 | * @returns 32-bit flat pointer.
|
---|
1273 | * @param a_Type The type we're pointing to.
|
---|
1274 | * @param a_Name The member or variable name.
|
---|
1275 | */
|
---|
1276 | #define BS3_XPTR_GET_FLAT(a_Type, a_Name) (a_Name.XPtr.uFlat)
|
---|
1277 |
|
---|
1278 | /** @def BS3_XPTR_GET_FLAT_LOW
|
---|
1279 | * Gets the low 16 bits of the flat address.
|
---|
1280 | *
|
---|
1281 | * @returns Low 16 bits of the flat pointer.
|
---|
1282 | * @param a_Type The type we're pointing to.
|
---|
1283 | * @param a_Name The member or variable name.
|
---|
1284 | */
|
---|
1285 | #define BS3_XPTR_GET_FLAT_LOW(a_Type, a_Name) (a_Name.XPtr.u.uLow)
|
---|
1286 |
|
---|
1287 |
|
---|
1288 | #if ARCH_BITS == 16
|
---|
1289 |
|
---|
1290 | /**
|
---|
1291 | * Gets the current ring number.
|
---|
1292 | * @returns Ring number.
|
---|
1293 | */
|
---|
1294 | DECLINLINE(uint16_t) Bs3Sel16GetCurRing(void);
|
---|
1295 | # pragma aux Bs3Sel16GetCurRing = \
|
---|
1296 | "mov ax, ss" \
|
---|
1297 | "and ax, 3" \
|
---|
1298 | value [ax] modify exact [ax] nomemory;
|
---|
1299 |
|
---|
1300 | /**
|
---|
1301 | * Converts the high word of a flat pointer into a 16-bit selector.
|
---|
1302 | *
|
---|
1303 | * This makes use of the tiled area. It also handles real mode.
|
---|
1304 | *
|
---|
1305 | * @returns Segment selector value.
|
---|
1306 | * @param uHigh The high part of flat pointer.
|
---|
1307 | * @sa BS3_XPTR_GET, BS3_XPTR_SET
|
---|
1308 | */
|
---|
1309 | DECLINLINE(__segment) Bs3Sel16HighFlatPtrToSelector(uint16_t uHigh)
|
---|
1310 | {
|
---|
1311 | if (!BS3_MODE_IS_RM_OR_V86(g_bBs3CurrentMode))
|
---|
1312 | return (__segment)(((uHigh << 3) + BS3_SEL_TILED) | Bs3Sel16GetCurRing());
|
---|
1313 | return (__segment)(uHigh << 12);
|
---|
1314 | }
|
---|
1315 |
|
---|
1316 | #endif /* ARCH_BITS == 16 */
|
---|
1317 |
|
---|
1318 | /** @def BS3_XPTR_GET
|
---|
1319 | * Gets the current context pointer value.
|
---|
1320 | *
|
---|
1321 | * @returns Usable pointer.
|
---|
1322 | * @param a_Type The type we're pointing to.
|
---|
1323 | * @param a_Name The member or variable name.
|
---|
1324 | */
|
---|
1325 | #if ARCH_BITS == 16
|
---|
1326 | # define BS3_XPTR_GET(a_Type, a_Name) \
|
---|
1327 | ((a_Type BS3_FAR *)BS3_FP_MAKE(Bs3Sel16HighFlatPtrToSelector((a_Name).XPtr.u.uHigh), (a_Name).pNearTyped))
|
---|
1328 | #elif ARCH_BITS == 32
|
---|
1329 | # define BS3_XPTR_GET(a_Type, a_Name) ((a_Name).pTyped)
|
---|
1330 | #elif ARCH_BITS == 64
|
---|
1331 | # define BS3_XPTR_GET(a_Type, a_Name) ((a_Type *)(uintptr_t)(a_Name).XPtr.uFlat)
|
---|
1332 | #else
|
---|
1333 | # error "ARCH_BITS"
|
---|
1334 | #endif
|
---|
1335 |
|
---|
1336 | /** @def BS3_XPTR_SET
|
---|
1337 | * Gets the current context pointer value.
|
---|
1338 | *
|
---|
1339 | * @returns Usable pointer.
|
---|
1340 | * @param a_Type The type we're pointing to.
|
---|
1341 | * @param a_Name The member or variable name.
|
---|
1342 | * @param a_pValue The new pointer value, current context pointer.
|
---|
1343 | */
|
---|
1344 | #if ARCH_BITS == 16
|
---|
1345 | # define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
|
---|
1346 | do { \
|
---|
1347 | a_Type BS3_FAR *pTypeCheck = (a_pValue); \
|
---|
1348 | if (BS3_MODE_IS_RM_OR_V86(g_bBs3CurrentMode)) \
|
---|
1349 | (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \
|
---|
1350 | else \
|
---|
1351 | { \
|
---|
1352 | (a_Name).XPtr.u.uLow = BS3_FP_OFF(pTypeCheck); \
|
---|
1353 | (a_Name).XPtr.u.uHigh = ((BS3_FP_SEG(pTypeCheck) & UINT16_C(0xfff8)) - BS3_SEL_TILED) >> 3; \
|
---|
1354 | } \
|
---|
1355 | } while (0)
|
---|
1356 | #elif ARCH_BITS == 32
|
---|
1357 | # define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
|
---|
1358 | do { (a_Name).pTyped = (a_pValue); } while (0)
|
---|
1359 | #elif ARCH_BITS == 64
|
---|
1360 | # define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
|
---|
1361 | do { \
|
---|
1362 | a_Type *pTypeCheck = (a_pValue); \
|
---|
1363 | (a_Name).XPtr.uFlat = (uint32_t)(uintptr_t)pTypeCheck; \
|
---|
1364 | } while (0)
|
---|
1365 | #else
|
---|
1366 | # error "ARCH_BITS"
|
---|
1367 | #endif
|
---|
1368 |
|
---|
1369 |
|
---|
1370 | /** @def BS3_XPTR_IS_NULL
|
---|
1371 | * Checks if the cross context pointer is NULL.
|
---|
1372 | *
|
---|
1373 | * @returns true if NULL, false if not.
|
---|
1374 | * @param a_Type The type we're pointing to.
|
---|
1375 | * @param a_Name The member or variable name.
|
---|
1376 | */
|
---|
1377 | #define BS3_XPTR_IS_NULL(a_Type, a_Name) ((a_Name).XPtr.uFlat == 0)
|
---|
1378 |
|
---|
1379 | /**
|
---|
1380 | * Gets a working pointer from a flat address.
|
---|
1381 | *
|
---|
1382 | * @returns Current context pointer.
|
---|
1383 | * @param uFlatPtr The flat address to convert (32-bit or 64-bit).
|
---|
1384 | */
|
---|
1385 | DECLINLINE(void BS3_FAR *) Bs3XptrFlatToCurrent(RTCCUINTXREG uFlatPtr)
|
---|
1386 | {
|
---|
1387 | BS3_XPTR_AUTO(void, pTmp);
|
---|
1388 | BS3_XPTR_SET_FLAT(void, pTmp, uFlatPtr);
|
---|
1389 | return BS3_XPTR_GET(void, pTmp);
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | /** @} */
|
---|
1393 |
|
---|
1394 |
|
---|
1395 |
|
---|
1396 | /** @defgroup grp_bs3kit_cmn Common Functions and Data
|
---|
1397 | *
|
---|
1398 | * The common functions comes in three variations: 16-bit, 32-bit and 64-bit.
|
---|
1399 | * Templated code uses the #BS3_CMN_NM macro to mangle the name according to the
|
---|
1400 | * desired
|
---|
1401 | *
|
---|
1402 | * @{
|
---|
1403 | */
|
---|
1404 |
|
---|
1405 | /** @def BS3_CMN_PROTO_INT
|
---|
1406 | * Internal macro for prototyping all the variations of a common function.
|
---|
1407 | * @param a_RetType The return type.
|
---|
1408 | * @param a_Name The function basename.
|
---|
1409 | * @param a_Params The parameter list (in parentheses).
|
---|
1410 | * @sa BS3_CMN_PROTO_STUB, BS3_CMN_PROTO_NOSB
|
---|
1411 | */
|
---|
1412 | #if ARCH_BITS == 16
|
---|
1413 | # ifndef BS3_USE_ALT_16BIT_TEXT_SEG
|
---|
1414 | # define BS3_CMN_PROTO_INT(a_RetType, a_Name, a_Params) \
|
---|
1415 | BS3_DECL_NEAR(a_RetType) BS3_CMN_NM(a_Name) a_Params; \
|
---|
1416 | BS3_DECL_FAR(a_RetType) BS3_CMN_FAR_NM(a_Name) a_Params
|
---|
1417 | # else
|
---|
1418 | # define BS3_CMN_PROTO_INT(a_RetType, a_Name, a_Params) \
|
---|
1419 | BS3_DECL_FAR(a_RetType) BS3_CMN_FAR_NM(a_Name) a_Params
|
---|
1420 | # endif
|
---|
1421 | #else
|
---|
1422 | # define BS3_CMN_PROTO_INT(a_RetType, a_Name, a_Params) \
|
---|
1423 | BS3_DECL_NEAR(a_RetType) BS3_CMN_NM(a_Name) a_Params
|
---|
1424 | #endif
|
---|
1425 |
|
---|
1426 | /** @def BS3_CMN_PROTO_STUB
|
---|
1427 | * Macro for prototyping all the variations of a common function with automatic
|
---|
1428 | * near -> far stub.
|
---|
1429 | *
|
---|
1430 | * @param a_RetType The return type.
|
---|
1431 | * @param a_Name The function basename.
|
---|
1432 | * @param a_Params The parameter list (in parentheses).
|
---|
1433 | * @sa BS3_CMN_PROTO_NOSB
|
---|
1434 | */
|
---|
1435 | #define BS3_CMN_PROTO_STUB(a_RetType, a_Name, a_Params) BS3_CMN_PROTO_INT(a_RetType, a_Name, a_Params)
|
---|
1436 |
|
---|
1437 | /** @def BS3_CMN_PROTO_NOSB
|
---|
1438 | * Macro for prototyping all the variations of a common function without any
|
---|
1439 | * near > far stub.
|
---|
1440 | *
|
---|
1441 | * @param a_RetType The return type.
|
---|
1442 | * @param a_Name The function basename.
|
---|
1443 | * @param a_Params The parameter list (in parentheses).
|
---|
1444 | * @sa BS3_CMN_PROTO_STUB
|
---|
1445 | */
|
---|
1446 | #define BS3_CMN_PROTO_NOSB(a_RetType, a_Name, a_Params) BS3_CMN_PROTO_INT(a_RetType, a_Name, a_Params)
|
---|
1447 |
|
---|
1448 | /** @def BS3_CMN_PROTO_FARSTUB
|
---|
1449 | * Macro for prototyping all the variations of a common function with automatic
|
---|
1450 | * far -> near stub.
|
---|
1451 | *
|
---|
1452 | * @param a_cbParam16 The size of the 16-bit parameter list in bytes.
|
---|
1453 | * @param a_RetType The return type.
|
---|
1454 | * @param a_Name The function basename.
|
---|
1455 | * @param a_Params The parameter list (in parentheses).
|
---|
1456 | * @sa BS3_CMN_PROTO_STUB
|
---|
1457 | */
|
---|
1458 | #define BS3_CMN_PROTO_FARSTUB(a_cbParam16, a_RetType, a_Name, a_Params) BS3_CMN_PROTO_INT(a_RetType, a_Name, a_Params)
|
---|
1459 |
|
---|
1460 |
|
---|
1461 | /** @def BS3_CMN_DEF
|
---|
1462 | * Macro for defining a common function.
|
---|
1463 | *
|
---|
1464 | * This makes 16-bit common function far, while 32-bit and 64-bit are near.
|
---|
1465 | *
|
---|
1466 | * @param a_RetType The return type.
|
---|
1467 | * @param a_Name The function basename.
|
---|
1468 | * @param a_Params The parameter list (in parentheses).
|
---|
1469 | */
|
---|
1470 | #if ARCH_BITS == 16
|
---|
1471 | # define BS3_CMN_DEF(a_RetType, a_Name, a_Params) \
|
---|
1472 | BS3_DECL_FAR(a_RetType) BS3_CMN_FAR_NM(a_Name) a_Params
|
---|
1473 | #else
|
---|
1474 | # define BS3_CMN_DEF(a_RetType, a_Name, a_Params) \
|
---|
1475 | BS3_DECL_NEAR(a_RetType) BS3_CMN_NM(a_Name) a_Params
|
---|
1476 | #endif
|
---|
1477 |
|
---|
1478 | /** @def BS3_ASSERT
|
---|
1479 | * Assert that an expression is true.
|
---|
1480 | *
|
---|
1481 | * Calls Bs3Panic if false and it's a strict build. Does nothing in
|
---|
1482 | * non-strict builds. */
|
---|
1483 | #ifdef BS3_STRICT
|
---|
1484 | # define BS3_ASSERT(a_Expr) do { if (!!(a_Expr)) { /* likely */ } else { Bs3Panic(); } } while (0) /**< @todo later */
|
---|
1485 | #else
|
---|
1486 | # define BS3_ASSERT(a_Expr) do { } while (0)
|
---|
1487 | #endif
|
---|
1488 |
|
---|
1489 | /**
|
---|
1490 | * Panic, never return.
|
---|
1491 | *
|
---|
1492 | * The current implementation will only halt the CPU.
|
---|
1493 | */
|
---|
1494 | BS3_CMN_PROTO_NOSB(DECL_NO_RETURN(void), Bs3Panic,(void));
|
---|
1495 | #if !defined(BS3_KIT_WITH_NO_RETURN) && defined(__WATCOMC__)
|
---|
1496 | # pragma aux Bs3Panic_c16 __aborts
|
---|
1497 | # pragma aux Bs3Panic_f16 __aborts
|
---|
1498 | # pragma aux Bs3Panic_c32 __aborts
|
---|
1499 | #endif
|
---|
1500 |
|
---|
1501 |
|
---|
1502 | /**
|
---|
1503 | * Translate a mode into a string.
|
---|
1504 | *
|
---|
1505 | * @returns Pointer to read-only mode name string.
|
---|
1506 | * @param bMode The mode value (BS3_MODE_XXX).
|
---|
1507 | */
|
---|
1508 | BS3_CMN_PROTO_STUB(const char BS3_FAR *, Bs3GetModeName,(uint8_t bMode));
|
---|
1509 |
|
---|
1510 | /**
|
---|
1511 | * Translate a mode into a short lower case string.
|
---|
1512 | *
|
---|
1513 | * @returns Pointer to read-only short mode name string.
|
---|
1514 | * @param bMode The mode value (BS3_MODE_XXX).
|
---|
1515 | */
|
---|
1516 | BS3_CMN_PROTO_STUB(const char BS3_FAR *, Bs3GetModeNameShortLower,(uint8_t bMode));
|
---|
1517 |
|
---|
1518 | /** CPU vendors. */
|
---|
1519 | typedef enum BS3CPUVENDOR
|
---|
1520 | {
|
---|
1521 | BS3CPUVENDOR_INVALID = 0,
|
---|
1522 | BS3CPUVENDOR_INTEL,
|
---|
1523 | BS3CPUVENDOR_AMD,
|
---|
1524 | BS3CPUVENDOR_VIA,
|
---|
1525 | BS3CPUVENDOR_CYRIX,
|
---|
1526 | BS3CPUVENDOR_UNKNOWN,
|
---|
1527 | BS3CPUVENDOR_END
|
---|
1528 | } BS3CPUVENDOR;
|
---|
1529 |
|
---|
1530 | /**
|
---|
1531 | * Tries to detect the CPU vendor.
|
---|
1532 | *
|
---|
1533 | * @returns CPU vendor.
|
---|
1534 | */
|
---|
1535 | BS3_CMN_PROTO_STUB(BS3CPUVENDOR, Bs3GetCpuVendor,(void));
|
---|
1536 |
|
---|
1537 | /**
|
---|
1538 | * Shutdown the system, never returns.
|
---|
1539 | *
|
---|
1540 | * This currently only works for VMs. When running on real systems it will
|
---|
1541 | * just halt the CPU.
|
---|
1542 | */
|
---|
1543 | BS3_CMN_PROTO_NOSB(void, Bs3Shutdown,(void));
|
---|
1544 |
|
---|
1545 | /**
|
---|
1546 | * Prints a 32-bit unsigned value as decimal to the screen.
|
---|
1547 | *
|
---|
1548 | * @param uValue The 32-bit value.
|
---|
1549 | */
|
---|
1550 | BS3_CMN_PROTO_NOSB(void, Bs3PrintU32,(uint32_t uValue));
|
---|
1551 |
|
---|
1552 | /**
|
---|
1553 | * Prints a 32-bit unsigned value as hex to the screen.
|
---|
1554 | *
|
---|
1555 | * @param uValue The 32-bit value.
|
---|
1556 | */
|
---|
1557 | BS3_CMN_PROTO_NOSB(void, Bs3PrintX32,(uint32_t uValue));
|
---|
1558 |
|
---|
1559 | /**
|
---|
1560 | * Formats and prints a string to the screen.
|
---|
1561 | *
|
---|
1562 | * See #Bs3StrFormatV for supported format types.
|
---|
1563 | *
|
---|
1564 | * @param pszFormat The format string.
|
---|
1565 | * @param ... Format arguments.
|
---|
1566 | */
|
---|
1567 | BS3_CMN_PROTO_STUB(size_t, Bs3Printf,(const char BS3_FAR *pszFormat, ...));
|
---|
1568 |
|
---|
1569 | /**
|
---|
1570 | * Formats and prints a string to the screen, va_list version.
|
---|
1571 | *
|
---|
1572 | * See #Bs3StrFormatV for supported format types.
|
---|
1573 | *
|
---|
1574 | * @param pszFormat The format string.
|
---|
1575 | * @param va Format arguments.
|
---|
1576 | */
|
---|
1577 | BS3_CMN_PROTO_STUB(size_t, Bs3PrintfV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
1578 |
|
---|
1579 | /**
|
---|
1580 | * Prints a string to the screen.
|
---|
1581 | *
|
---|
1582 | * @param pszString The string to print.
|
---|
1583 | */
|
---|
1584 | BS3_CMN_PROTO_STUB(void, Bs3PrintStr,(const char BS3_FAR *pszString));
|
---|
1585 |
|
---|
1586 | /**
|
---|
1587 | * Prints a string to the screen.
|
---|
1588 | *
|
---|
1589 | * @param pszString The string to print. Any terminator charss will be printed.
|
---|
1590 | * @param cchString The exact number of characters to print.
|
---|
1591 | */
|
---|
1592 | BS3_CMN_PROTO_NOSB(void, Bs3PrintStrN,(const char BS3_FAR *pszString, size_t cchString));
|
---|
1593 |
|
---|
1594 | /**
|
---|
1595 | * Prints a char to the screen.
|
---|
1596 | *
|
---|
1597 | * @param ch The character to print.
|
---|
1598 | */
|
---|
1599 | BS3_CMN_PROTO_NOSB(void, Bs3PrintChr,(char ch));
|
---|
1600 |
|
---|
1601 |
|
---|
1602 | /**
|
---|
1603 | * An output function for #Bs3StrFormatV.
|
---|
1604 | *
|
---|
1605 | * @returns Number of characters written.
|
---|
1606 | * @param ch The character to write. Zero in the final call.
|
---|
1607 | * @param pvUser User argument supplied to #Bs3StrFormatV.
|
---|
1608 | */
|
---|
1609 | typedef BS3_DECL_CALLBACK(size_t) FNBS3STRFORMATOUTPUT(char ch, void BS3_FAR *pvUser);
|
---|
1610 | /** Pointer to an output function for #Bs3StrFormatV. */
|
---|
1611 | typedef FNBS3STRFORMATOUTPUT *PFNBS3STRFORMATOUTPUT;
|
---|
1612 |
|
---|
1613 | /**
|
---|
1614 | * Formats a string, sending the output to @a pfnOutput.
|
---|
1615 | *
|
---|
1616 | * Supported types:
|
---|
1617 | * - %RI8, %RI16, %RI32, %RI64
|
---|
1618 | * - %RU8, %RU16, %RU32, %RU64
|
---|
1619 | * - %RX8, %RX16, %RX32, %RX64
|
---|
1620 | * - %i, %d
|
---|
1621 | * - %u
|
---|
1622 | * - %x
|
---|
1623 | * - %c
|
---|
1624 | * - %p (far pointer)
|
---|
1625 | * - %s (far pointer)
|
---|
1626 | *
|
---|
1627 | * @returns Sum of @a pfnOutput return values.
|
---|
1628 | * @param pszFormat The format string.
|
---|
1629 | * @param va Format arguments.
|
---|
1630 | * @param pfnOutput The output function.
|
---|
1631 | * @param pvUser The user argument for the output function.
|
---|
1632 | */
|
---|
1633 | BS3_CMN_PROTO_STUB(size_t, Bs3StrFormatV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va,
|
---|
1634 | PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser));
|
---|
1635 |
|
---|
1636 | /**
|
---|
1637 | * Formats a string into a buffer.
|
---|
1638 | *
|
---|
1639 | * See #Bs3StrFormatV for supported format types.
|
---|
1640 | *
|
---|
1641 | * @returns The length of the formatted string (excluding terminator).
|
---|
1642 | * This will be higher or equal to @c cbBuf in case of an overflow.
|
---|
1643 | * @param pszBuf The output buffer.
|
---|
1644 | * @param cbBuf The size of the output buffer.
|
---|
1645 | * @param pszFormat The format string.
|
---|
1646 | * @param va Format arguments.
|
---|
1647 | */
|
---|
1648 | BS3_CMN_PROTO_STUB(size_t, Bs3StrPrintfV,(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
1649 |
|
---|
1650 | /**
|
---|
1651 | * Formats a string into a buffer.
|
---|
1652 | *
|
---|
1653 | * See #Bs3StrFormatV for supported format types.
|
---|
1654 | *
|
---|
1655 | * @returns The length of the formatted string (excluding terminator).
|
---|
1656 | * This will be higher or equal to @c cbBuf in case of an overflow.
|
---|
1657 | * @param pszBuf The output buffer.
|
---|
1658 | * @param cbBuf The size of the output buffer.
|
---|
1659 | * @param pszFormat The format string.
|
---|
1660 | * @param ... Format arguments.
|
---|
1661 | */
|
---|
1662 | BS3_CMN_PROTO_STUB(size_t, Bs3StrPrintf,(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...));
|
---|
1663 |
|
---|
1664 |
|
---|
1665 | /**
|
---|
1666 | * Finds the length of a zero terminated string.
|
---|
1667 | *
|
---|
1668 | * @returns String length in chars/bytes.
|
---|
1669 | * @param pszString The string to examine.
|
---|
1670 | */
|
---|
1671 | BS3_CMN_PROTO_STUB(size_t, Bs3StrLen,(const char BS3_FAR *pszString));
|
---|
1672 |
|
---|
1673 | /**
|
---|
1674 | * Finds the length of a zero terminated string, but with a max length.
|
---|
1675 | *
|
---|
1676 | * @returns String length in chars/bytes, or @a cchMax if no zero-terminator
|
---|
1677 | * was found before we reached the limit.
|
---|
1678 | * @param pszString The string to examine.
|
---|
1679 | * @param cchMax The max length to examine.
|
---|
1680 | */
|
---|
1681 | BS3_CMN_PROTO_STUB(size_t, Bs3StrNLen,(const char BS3_FAR *pszString, size_t cchMax));
|
---|
1682 |
|
---|
1683 | /**
|
---|
1684 | * CRT style unsafe strcpy.
|
---|
1685 | *
|
---|
1686 | * @returns pszDst.
|
---|
1687 | * @param pszDst The destination buffer. Must be large enough to
|
---|
1688 | * hold the source string.
|
---|
1689 | * @param pszSrc The source string.
|
---|
1690 | */
|
---|
1691 | BS3_CMN_PROTO_STUB(char BS3_FAR *, Bs3StrCpy,(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc));
|
---|
1692 |
|
---|
1693 | /**
|
---|
1694 | * CRT style memcpy.
|
---|
1695 | *
|
---|
1696 | * @returns pvDst
|
---|
1697 | * @param pvDst The destination buffer.
|
---|
1698 | * @param pvSrc The source buffer.
|
---|
1699 | * @param cbToCopy The number of bytes to copy.
|
---|
1700 | */
|
---|
1701 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemCpy,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy));
|
---|
1702 |
|
---|
1703 | /**
|
---|
1704 | * GNU (?) style mempcpy.
|
---|
1705 | *
|
---|
1706 | * @returns pvDst + cbCopy
|
---|
1707 | * @param pvDst The destination buffer.
|
---|
1708 | * @param pvSrc The source buffer.
|
---|
1709 | * @param cbToCopy The number of bytes to copy.
|
---|
1710 | */
|
---|
1711 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemPCpy,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy));
|
---|
1712 |
|
---|
1713 | /**
|
---|
1714 | * CRT style memmove (overlapping buffers is fine).
|
---|
1715 | *
|
---|
1716 | * @returns pvDst
|
---|
1717 | * @param pvDst The destination buffer.
|
---|
1718 | * @param pvSrc The source buffer.
|
---|
1719 | * @param cbToCopy The number of bytes to copy.
|
---|
1720 | */
|
---|
1721 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemMove,(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy));
|
---|
1722 |
|
---|
1723 | /**
|
---|
1724 | * BSD style bzero.
|
---|
1725 | *
|
---|
1726 | * @param pvDst The buffer to be zeroed.
|
---|
1727 | * @param cbDst The number of bytes to zero.
|
---|
1728 | */
|
---|
1729 | BS3_CMN_PROTO_NOSB(void, Bs3MemZero,(void BS3_FAR *pvDst, size_t cbDst));
|
---|
1730 |
|
---|
1731 | /**
|
---|
1732 | * CRT style memset.
|
---|
1733 | *
|
---|
1734 | * @param pvDst The buffer to be fill.
|
---|
1735 | * @param bFiller The filler byte.
|
---|
1736 | * @param cbDst The number of bytes to fill.
|
---|
1737 | */
|
---|
1738 | BS3_CMN_PROTO_NOSB(void, Bs3MemSet,(void BS3_FAR *pvDst, uint8_t bFiller, size_t cbDst));
|
---|
1739 |
|
---|
1740 | /**
|
---|
1741 | * CRT style memchr.
|
---|
1742 | *
|
---|
1743 | * @param pvHaystack The memory to scan for @a bNeedle.
|
---|
1744 | * @param bNeedle The byte to search for.
|
---|
1745 | * @param cbHaystack The amount of memory to search.
|
---|
1746 | */
|
---|
1747 | BS3_CMN_PROTO_NOSB(void BS3_FAR *, Bs3MemChr,(void const BS3_FAR *pvHaystack, uint8_t bNeedle, size_t cbHaystack));
|
---|
1748 |
|
---|
1749 | /**
|
---|
1750 | * CRT style memcmp.
|
---|
1751 | *
|
---|
1752 | * @returns 0 if equal. Negative if the left side is 'smaller' than the right
|
---|
1753 | * side, and positive in the other case.
|
---|
1754 | * @param pv1 The left hand memory.
|
---|
1755 | * @param pv2 The right hand memory.
|
---|
1756 | * @param cb The number of bytes to compare.
|
---|
1757 | */
|
---|
1758 | BS3_CMN_PROTO_NOSB(int, Bs3MemCmp,(void const BS3_FAR *pv1, void const BS3_FAR *pv2, size_t cb));
|
---|
1759 |
|
---|
1760 | BS3_CMN_PROTO_STUB(void, Bs3UInt64Div,(RTUINT64U uDividend, RTUINT64U uDivisor, RTUINT64U BS3_FAR *paQuotientReminder));
|
---|
1761 | BS3_CMN_PROTO_STUB(void, Bs3UInt32Div,(RTUINT32U uDividend, RTUINT32U uDivisor, RTUINT32U BS3_FAR *paQuotientReminder));
|
---|
1762 |
|
---|
1763 |
|
---|
1764 | /**
|
---|
1765 | * Converts a protected mode 32-bit far pointer to a 32-bit flat address.
|
---|
1766 | *
|
---|
1767 | * @returns 32-bit flat address.
|
---|
1768 | * @param off The segment offset.
|
---|
1769 | * @param uSel The protected mode segment selector.
|
---|
1770 | */
|
---|
1771 | BS3_CMN_PROTO_STUB(uint32_t, Bs3SelProtFar32ToFlat32,(uint32_t off, uint16_t uSel));
|
---|
1772 |
|
---|
1773 | /**
|
---|
1774 | * Converts a current mode 32-bit far pointer to a 32-bit flat address.
|
---|
1775 | *
|
---|
1776 | * @returns 32-bit flat address.
|
---|
1777 | * @param off The segment offset.
|
---|
1778 | * @param uSel The current mode segment selector.
|
---|
1779 | */
|
---|
1780 | BS3_CMN_PROTO_STUB(uint32_t, Bs3SelFar32ToFlat32,(uint32_t off, uint16_t uSel));
|
---|
1781 |
|
---|
1782 | /**
|
---|
1783 | * Wrapper around Bs3SelFar32ToFlat32 that makes it easier to use in tight
|
---|
1784 | * assembly spots.
|
---|
1785 | *
|
---|
1786 | * @returns 32-bit flat address.
|
---|
1787 | * @param off The segment offset.
|
---|
1788 | * @param uSel The current mode segment selector.
|
---|
1789 | * @remarks All register are preserved, except return.
|
---|
1790 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1791 | */
|
---|
1792 | BS3_CMN_PROTO_FARSTUB(6, uint32_t, Bs3SelFar32ToFlat32NoClobber,(uint32_t off, uint16_t uSel));
|
---|
1793 |
|
---|
1794 | /**
|
---|
1795 | * Converts a real mode code segment to a protected mode code segment selector.
|
---|
1796 | *
|
---|
1797 | * @returns protected mode segment selector.
|
---|
1798 | * @param uRealSeg Real mode code segment.
|
---|
1799 | * @remarks All register are preserved, except return and parameter.
|
---|
1800 | */
|
---|
1801 | BS3_CMN_PROTO_NOSB(uint16_t, Bs3SelRealModeCodeToProtMode,(uint16_t uRealSeg));
|
---|
1802 |
|
---|
1803 | /**
|
---|
1804 | * Converts a real mode code segment to a protected mode code segment selector.
|
---|
1805 | *
|
---|
1806 | * @returns protected mode segment selector.
|
---|
1807 | * @param uProtSel Real mode code segment.
|
---|
1808 | * @remarks All register are preserved, except return and parameter.
|
---|
1809 | */
|
---|
1810 | BS3_CMN_PROTO_NOSB(uint16_t, Bs3SelProtModeCodeToRealMode,(uint16_t uProtSel));
|
---|
1811 |
|
---|
1812 | /**
|
---|
1813 | * Converts a flat code address to a real mode segment and offset.
|
---|
1814 | *
|
---|
1815 | * @returns Far real mode address (high 16-bit is segment, low is offset).
|
---|
1816 | * @param uFlatAddr Flat code address.
|
---|
1817 | * @remarks All register are preserved, except return and parameter.
|
---|
1818 | */
|
---|
1819 | BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatCodeToRealMode,(uint32_t uFlatAddr));
|
---|
1820 |
|
---|
1821 | /**
|
---|
1822 | * Converts a flat code address to a protected mode 16-bit far pointer (ring-0).
|
---|
1823 | *
|
---|
1824 | * @returns Far 16-bit protected mode address (high 16-bit is segment selector,
|
---|
1825 | * low is segment offset).
|
---|
1826 | * @param uFlatAddr Flat code address.
|
---|
1827 | * @remarks All register are preserved, except return and parameter.
|
---|
1828 | */
|
---|
1829 | BS3_CMN_PROTO_NOSB(uint32_t, Bs3SelFlatCodeToProtFar16,(uint32_t uFlatAddr));
|
---|
1830 |
|
---|
1831 | /**
|
---|
1832 | * Converts a far 16:16 real mode (code) address to a flat address.
|
---|
1833 | *
|
---|
1834 | * @returns 32-bit flat address.
|
---|
1835 | * @param uFar1616 Far real mode address (high 16-bit is segment, low
|
---|
1836 | * is offset).
|
---|
1837 | * @remarks All register are preserved, except return.
|
---|
1838 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1839 | * @remarks Exactly the same as Bs3SelRealModeDataToFlat, except for param.
|
---|
1840 | */
|
---|
1841 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelRealModeCodeToFlat,(PFNBS3FARADDRCONV uFar1616));
|
---|
1842 |
|
---|
1843 | /**
|
---|
1844 | * Converts a flat data address to a real mode segment and offset.
|
---|
1845 | *
|
---|
1846 | * @returns Far real mode address (high 16-bit is segment, low is offset)
|
---|
1847 | * @param uFlatAddr Flat code address.
|
---|
1848 | * @remarks All register are preserved, except return.
|
---|
1849 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1850 | */
|
---|
1851 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelFlatDataToRealMode,(uint32_t uFlatAddr));
|
---|
1852 |
|
---|
1853 | /**
|
---|
1854 | * Converts a flat data address to a real mode segment and offset.
|
---|
1855 | *
|
---|
1856 | * @returns Far 16-bit protected mode address (high 16-bit is segment selector,
|
---|
1857 | * low is segment offset).
|
---|
1858 | * @param uFlatAddr Flat code address.
|
---|
1859 | * @remarks All register are preserved, except return.
|
---|
1860 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1861 | */
|
---|
1862 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelFlatDataToProtFar16,(uint32_t uFlatAddr));
|
---|
1863 |
|
---|
1864 | /**
|
---|
1865 | * Converts a far 16:16 data address to a real mode segment and offset.
|
---|
1866 | *
|
---|
1867 | * @returns Far real mode address (high 16-bit is segment, low is offset)
|
---|
1868 | * @param uFar1616 Far 16-bit protected mode address (high 16-bit is
|
---|
1869 | * segment selector, low is segment offset).
|
---|
1870 | * @remarks All register are preserved, except return.
|
---|
1871 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1872 | */
|
---|
1873 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelProtFar16DataToRealMode,(uint32_t uFar1616));
|
---|
1874 |
|
---|
1875 | /**
|
---|
1876 | * Converts a far 16:16 real mode address to a 16-bit protected mode address.
|
---|
1877 | *
|
---|
1878 | * @returns Far real mode address (high 16-bit is segment, low is offset)
|
---|
1879 | * @param uFar1616 Far real mode address (high 16-bit is segment, low
|
---|
1880 | * is offset).
|
---|
1881 | * @remarks All register are preserved, except return.
|
---|
1882 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1883 | */
|
---|
1884 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelRealModeDataToProtFar16,(uint32_t uFar1616));
|
---|
1885 |
|
---|
1886 | /**
|
---|
1887 | * Converts a far 16:16 data address to a flat 32-bit address.
|
---|
1888 | *
|
---|
1889 | * @returns 32-bit flat address.
|
---|
1890 | * @param uFar1616 Far 16-bit protected mode address (high 16-bit is
|
---|
1891 | * segment selector, low is segment offset).
|
---|
1892 | * @remarks All register are preserved, except return.
|
---|
1893 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1894 | */
|
---|
1895 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelProtFar16DataToFlat,(uint32_t uFar1616));
|
---|
1896 |
|
---|
1897 | /**
|
---|
1898 | * Converts a far 16:16 real mode address to a flat address.
|
---|
1899 | *
|
---|
1900 | * @returns 32-bit flat address.
|
---|
1901 | * @param uFar1616 Far real mode address (high 16-bit is segment, low
|
---|
1902 | * is offset).
|
---|
1903 | * @remarks All register are preserved, except return.
|
---|
1904 | * @remarks No 20h scratch space required in 64-bit mode.
|
---|
1905 | */
|
---|
1906 | BS3_CMN_PROTO_FARSTUB(4, uint32_t, Bs3SelRealModeDataToFlat,(uint32_t uFar1616));
|
---|
1907 |
|
---|
1908 | /**
|
---|
1909 | * Gets a flat address from a working poitner.
|
---|
1910 | *
|
---|
1911 | * @returns flat address (32-bit or 64-bit).
|
---|
1912 | * @param pv Current context pointer.
|
---|
1913 | */
|
---|
1914 | DECLINLINE(RTCCUINTXREG) Bs3SelPtrToFlat(void BS3_FAR *pv)
|
---|
1915 | {
|
---|
1916 | #if ARCH_BITS == 16
|
---|
1917 | return BS3_CMN_FN_NM(Bs3SelFar32ToFlat32)(BS3_FP_OFF(pv), BS3_FP_SEG(pv));
|
---|
1918 | #else
|
---|
1919 | return (uintptr_t)pv;
|
---|
1920 | #endif
|
---|
1921 | }
|
---|
1922 |
|
---|
1923 | /**
|
---|
1924 | * Sets up a 16-bit read-write data selector with ring-3 access and 64KB limit.
|
---|
1925 | *
|
---|
1926 | * @param pDesc Pointer to the descriptor table entry.
|
---|
1927 | * @param uBaseAddr The base address of the descriptor.
|
---|
1928 | */
|
---|
1929 | BS3_CMN_PROTO_STUB(void, Bs3SelSetup16BitData,(X86DESC BS3_FAR *pDesc, uint32_t uBaseAddr));
|
---|
1930 |
|
---|
1931 | /**
|
---|
1932 | * Sets up a 16-bit execute-read selector with a 64KB limit.
|
---|
1933 | *
|
---|
1934 | * @param pDesc Pointer to the descriptor table entry.
|
---|
1935 | * @param uBaseAddr The base address of the descriptor.
|
---|
1936 | * @param bDpl The descriptor privilege level.
|
---|
1937 | */
|
---|
1938 | BS3_CMN_PROTO_STUB(void, Bs3SelSetup16BitCode,(X86DESC BS3_FAR *pDesc, uint32_t uBaseAddr, uint8_t bDpl));
|
---|
1939 |
|
---|
1940 |
|
---|
1941 | /**
|
---|
1942 | * Slab control structure list head.
|
---|
1943 | *
|
---|
1944 | * The slabs on the list must all have the same chunk size.
|
---|
1945 | */
|
---|
1946 | typedef struct BS3SLABHEAD
|
---|
1947 | {
|
---|
1948 | /** Pointer to the first slab. */
|
---|
1949 | BS3_XPTR_MEMBER(struct BS3SLABCTL, pFirst);
|
---|
1950 | /** The allocation chunk size. */
|
---|
1951 | uint16_t cbChunk;
|
---|
1952 | /** Number of slabs in the list. */
|
---|
1953 | uint16_t cSlabs;
|
---|
1954 | /** Number of chunks in the list. */
|
---|
1955 | uint32_t cChunks;
|
---|
1956 | /** Number of free chunks. */
|
---|
1957 | uint32_t cFreeChunks;
|
---|
1958 | } BS3SLABHEAD;
|
---|
1959 | AssertCompileSize(BS3SLABHEAD, 16);
|
---|
1960 | /** Pointer to a slab list head. */
|
---|
1961 | typedef BS3SLABHEAD BS3_FAR *PBS3SLABHEAD;
|
---|
1962 |
|
---|
1963 | /**
|
---|
1964 | * Allocation slab control structure.
|
---|
1965 | *
|
---|
1966 | * This may live at the start of the slab for 4KB slabs, while in a separate
|
---|
1967 | * static location for the larger ones.
|
---|
1968 | */
|
---|
1969 | typedef struct BS3SLABCTL
|
---|
1970 | {
|
---|
1971 | /** Pointer to the next slab control structure in this list. */
|
---|
1972 | BS3_XPTR_MEMBER(struct BS3SLABCTL, pNext);
|
---|
1973 | /** Pointer to the slab list head. */
|
---|
1974 | BS3_XPTR_MEMBER(BS3SLABHEAD, pHead);
|
---|
1975 | /** The base address of the slab. */
|
---|
1976 | BS3_XPTR_MEMBER(uint8_t, pbStart);
|
---|
1977 | /** Number of chunks in this slab. */
|
---|
1978 | uint16_t cChunks;
|
---|
1979 | /** Number of currently free chunks. */
|
---|
1980 | uint16_t cFreeChunks;
|
---|
1981 | /** The chunk size. */
|
---|
1982 | uint16_t cbChunk;
|
---|
1983 | /** The shift count corresponding to cbChunk.
|
---|
1984 | * This is for turning a chunk number into a byte offset and vice versa. */
|
---|
1985 | uint16_t cChunkShift;
|
---|
1986 | /** Bitmap where set bits indicates allocated blocks (variable size,
|
---|
1987 | * multiple of 4). */
|
---|
1988 | uint8_t bmAllocated[4];
|
---|
1989 | } BS3SLABCTL;
|
---|
1990 | /** Pointer to a bs3kit slab control structure. */
|
---|
1991 | typedef BS3SLABCTL BS3_FAR *PBS3SLABCTL;
|
---|
1992 |
|
---|
1993 | /** The chunks must all be in the same 16-bit segment tile. */
|
---|
1994 | #define BS3_SLAB_ALLOC_F_SAME_TILE UINT16_C(0x0001)
|
---|
1995 |
|
---|
1996 | /**
|
---|
1997 | * Initializes a slab.
|
---|
1998 | *
|
---|
1999 | * @param pSlabCtl The slab control structure to initialize.
|
---|
2000 | * @param cbSlabCtl The size of the slab control structure.
|
---|
2001 | * @param uFlatSlabPtr The base address of the slab.
|
---|
2002 | * @param cbSlab The size of the slab.
|
---|
2003 | * @param cbChunk The chunk size.
|
---|
2004 | */
|
---|
2005 | BS3_CMN_PROTO_STUB(void, Bs3SlabInit,(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr,
|
---|
2006 | uint32_t cbSlab, uint16_t cbChunk));
|
---|
2007 |
|
---|
2008 | /**
|
---|
2009 | * Allocates one chunk from a slab.
|
---|
2010 | *
|
---|
2011 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
2012 | * @param pSlabCtl The slab constrol structure to allocate from.
|
---|
2013 | */
|
---|
2014 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3SlabAlloc,(PBS3SLABCTL pSlabCtl));
|
---|
2015 |
|
---|
2016 | /**
|
---|
2017 | * Allocates one or more chunks rom a slab.
|
---|
2018 | *
|
---|
2019 | * @returns Pointer to the request number of chunks on success, NULL if we're
|
---|
2020 | * out of chunks.
|
---|
2021 | * @param pSlabCtl The slab constrol structure to allocate from.
|
---|
2022 | * @param cChunks The number of contiguous chunks we want.
|
---|
2023 | * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX
|
---|
2024 | */
|
---|
2025 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3SlabAllocEx,(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags));
|
---|
2026 |
|
---|
2027 | /**
|
---|
2028 | * Frees one or more chunks from a slab.
|
---|
2029 | *
|
---|
2030 | * @returns Number of chunks actually freed. When correctly used, this will
|
---|
2031 | * match the @a cChunks parameter, of course.
|
---|
2032 | * @param pSlabCtl The slab constrol structure to free from.
|
---|
2033 | * @param uFlatChunkPtr The flat address of the chunks to free.
|
---|
2034 | * @param cChunks The number of contiguous chunks to free.
|
---|
2035 | */
|
---|
2036 | BS3_CMN_PROTO_STUB(uint16_t, Bs3SlabFree,(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks));
|
---|
2037 |
|
---|
2038 |
|
---|
2039 | /**
|
---|
2040 | * Initializes the given slab list head.
|
---|
2041 | *
|
---|
2042 | * @param pHead The slab list head.
|
---|
2043 | * @param cbChunk The chunk size.
|
---|
2044 | */
|
---|
2045 | BS3_CMN_PROTO_STUB(void, Bs3SlabListInit,(PBS3SLABHEAD pHead, uint16_t cbChunk));
|
---|
2046 |
|
---|
2047 | /**
|
---|
2048 | * Adds an initialized slab control structure to the list.
|
---|
2049 | *
|
---|
2050 | * @param pHead The slab list head to add it to.
|
---|
2051 | * @param pSlabCtl The slab control structure to add.
|
---|
2052 | */
|
---|
2053 | BS3_CMN_PROTO_STUB(void, Bs3SlabListAdd,(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl));
|
---|
2054 |
|
---|
2055 | /**
|
---|
2056 | * Allocates one chunk.
|
---|
2057 | *
|
---|
2058 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
2059 | * @param pHead The slab list to allocate from.
|
---|
2060 | */
|
---|
2061 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3SlabListAlloc,(PBS3SLABHEAD pHead));
|
---|
2062 |
|
---|
2063 | /**
|
---|
2064 | * Allocates one or more chunks.
|
---|
2065 | *
|
---|
2066 | * @returns Pointer to the request number of chunks on success, NULL if we're
|
---|
2067 | * out of chunks.
|
---|
2068 | * @param pHead The slab list to allocate from.
|
---|
2069 | * @param cChunks The number of contiguous chunks we want.
|
---|
2070 | * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX
|
---|
2071 | */
|
---|
2072 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3SlabListAllocEx,(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags));
|
---|
2073 |
|
---|
2074 | /**
|
---|
2075 | * Frees one or more chunks from a slab list.
|
---|
2076 | *
|
---|
2077 | * @param pHead The slab list to allocate from.
|
---|
2078 | * @param pvChunks Pointer to the first chunk to free.
|
---|
2079 | * @param cChunks The number of contiguous chunks to free.
|
---|
2080 | */
|
---|
2081 | BS3_CMN_PROTO_STUB(void, Bs3SlabListFree,(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks));
|
---|
2082 |
|
---|
2083 | /**
|
---|
2084 | * Allocation addressing constraints.
|
---|
2085 | */
|
---|
2086 | typedef enum BS3MEMKIND
|
---|
2087 | {
|
---|
2088 | /** Invalid zero type. */
|
---|
2089 | BS3MEMKIND_INVALID = 0,
|
---|
2090 | /** Real mode addressable memory. */
|
---|
2091 | BS3MEMKIND_REAL,
|
---|
2092 | /** Memory addressable using the 16-bit protected mode tiling. */
|
---|
2093 | BS3MEMKIND_TILED,
|
---|
2094 | /** Memory addressable using 32-bit flat addressing. */
|
---|
2095 | BS3MEMKIND_FLAT32,
|
---|
2096 | /** Memory addressable using 64-bit flat addressing. */
|
---|
2097 | BS3MEMKIND_FLAT64,
|
---|
2098 | /** End of valid types. */
|
---|
2099 | BS3MEMKIND_END,
|
---|
2100 | } BS3MEMKIND;
|
---|
2101 |
|
---|
2102 | /**
|
---|
2103 | * Allocates low memory.
|
---|
2104 | *
|
---|
2105 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
2106 | * @param enmKind The kind of addressing constraints imposed on the
|
---|
2107 | * allocation.
|
---|
2108 | * @param cb How much to allocate. Must be 4KB or less.
|
---|
2109 | */
|
---|
2110 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemAlloc,(BS3MEMKIND enmKind, size_t cb));
|
---|
2111 |
|
---|
2112 | /**
|
---|
2113 | * Allocates zero'ed memory.
|
---|
2114 | *
|
---|
2115 | * @param enmKind The kind of addressing constraints imposed on the
|
---|
2116 | * allocation.
|
---|
2117 | * @param cb How much to allocate. Must be 4KB or less.
|
---|
2118 | */
|
---|
2119 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemAllocZ,(BS3MEMKIND enmKind, size_t cb));
|
---|
2120 |
|
---|
2121 | /**
|
---|
2122 | * Frees memory.
|
---|
2123 | *
|
---|
2124 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
2125 | * @param pv The memory to free (returned by #Bs3MemAlloc).
|
---|
2126 | * @param cb The size of the allocation.
|
---|
2127 | */
|
---|
2128 | BS3_CMN_PROTO_STUB(void, Bs3MemFree,(void BS3_FAR *pv, size_t cb));
|
---|
2129 |
|
---|
2130 | /**
|
---|
2131 | * Allocates a page with non-present pages on each side.
|
---|
2132 | *
|
---|
2133 | * @returns Pointer to the usable page. NULL on failure. Use
|
---|
2134 | * Bs3MemGuardedTestPageFree to free the allocation.
|
---|
2135 | * @param enmKind The kind of addressing constraints imposed on the
|
---|
2136 | * allocation.
|
---|
2137 | */
|
---|
2138 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemGuardedTestPageAlloc,(BS3MEMKIND enmKind));
|
---|
2139 |
|
---|
2140 | /**
|
---|
2141 | * Allocates a page with pages on each side to the @a fPte specification.
|
---|
2142 | *
|
---|
2143 | * @returns Pointer to the usable page. NULL on failure. Use
|
---|
2144 | * Bs3MemGuardedTestPageFree to free the allocation.
|
---|
2145 | * @param enmKind The kind of addressing constraints imposed on the
|
---|
2146 | * allocation.
|
---|
2147 | * @param fPte The page table entry specification for the guard pages.
|
---|
2148 | */
|
---|
2149 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3MemGuardedTestPageAllocEx,(BS3MEMKIND enmKind, uint64_t fPte));
|
---|
2150 |
|
---|
2151 | /**
|
---|
2152 | * Frees guarded page allocated by Bs3MemGuardedTestPageAlloc or
|
---|
2153 | * Bs3MemGuardedTestPageAllocEx.
|
---|
2154 | *
|
---|
2155 | * @param pvGuardedPage Pointer returned by Bs3MemGuardedTestPageAlloc or
|
---|
2156 | * Bs3MemGuardedTestPageAllocEx. NULL is ignored.
|
---|
2157 | */
|
---|
2158 | BS3_CMN_PROTO_STUB(void, Bs3MemGuardedTestPageFree,(void BS3_FAR *pvGuardedPage));
|
---|
2159 |
|
---|
2160 | /**
|
---|
2161 | * Print all heap info.
|
---|
2162 | */
|
---|
2163 | BS3_CMN_PROTO_STUB(void, Bs3MemPrintInfo, (void));
|
---|
2164 |
|
---|
2165 | /** Highes RAM byte below 4G. */
|
---|
2166 | extern uint32_t g_uBs3EndOfRamBelow4G;
|
---|
2167 |
|
---|
2168 |
|
---|
2169 | /**
|
---|
2170 | * Enables the A20 gate.
|
---|
2171 | */
|
---|
2172 | BS3_CMN_PROTO_NOSB(void, Bs3A20Enable,(void));
|
---|
2173 |
|
---|
2174 | /**
|
---|
2175 | * Enables the A20 gate via the keyboard controller
|
---|
2176 | */
|
---|
2177 | BS3_CMN_PROTO_NOSB(void, Bs3A20EnableViaKbd,(void));
|
---|
2178 |
|
---|
2179 | /**
|
---|
2180 | * Enables the A20 gate via the PS/2 control port A.
|
---|
2181 | */
|
---|
2182 | BS3_CMN_PROTO_NOSB(void, Bs3A20EnableViaPortA,(void));
|
---|
2183 |
|
---|
2184 | /**
|
---|
2185 | * Disables the A20 gate.
|
---|
2186 | */
|
---|
2187 | BS3_CMN_PROTO_NOSB(void, Bs3A20Disable,(void));
|
---|
2188 |
|
---|
2189 | /**
|
---|
2190 | * Disables the A20 gate via the keyboard controller
|
---|
2191 | */
|
---|
2192 | BS3_CMN_PROTO_NOSB(void, Bs3A20DisableViaKbd,(void));
|
---|
2193 |
|
---|
2194 | /**
|
---|
2195 | * Disables the A20 gate via the PS/2 control port A.
|
---|
2196 | */
|
---|
2197 | BS3_CMN_PROTO_NOSB(void, Bs3A20DisableViaPortA,(void));
|
---|
2198 |
|
---|
2199 |
|
---|
2200 | /**
|
---|
2201 | * Initializes root page tables for page protected mode (PP16, PP32).
|
---|
2202 | *
|
---|
2203 | * @returns IPRT status code.
|
---|
2204 | * @remarks Must not be called in real-mode!
|
---|
2205 | */
|
---|
2206 | BS3_CMN_PROTO_STUB(int, Bs3PagingInitRootForPP,(void));
|
---|
2207 |
|
---|
2208 | /**
|
---|
2209 | * Initializes root page tables for PAE page protected mode (PAE16, PAE32).
|
---|
2210 | *
|
---|
2211 | * @returns IPRT status code.
|
---|
2212 | * @remarks The default long mode page tables depends on the PAE ones.
|
---|
2213 | * @remarks Must not be called in real-mode!
|
---|
2214 | */
|
---|
2215 | BS3_CMN_PROTO_STUB(int, Bs3PagingInitRootForPAE,(void));
|
---|
2216 |
|
---|
2217 | /**
|
---|
2218 | * Initializes root page tables for long mode (LM16, LM32, LM64).
|
---|
2219 | *
|
---|
2220 | * @returns IPRT status code.
|
---|
2221 | * @remarks The default long mode page tables depends on the PAE ones.
|
---|
2222 | * @remarks Must not be called in real-mode!
|
---|
2223 | */
|
---|
2224 | BS3_CMN_PROTO_STUB(int, Bs3PagingInitRootForLM,(void));
|
---|
2225 |
|
---|
2226 | /**
|
---|
2227 | * Modifies the page table protection of an address range.
|
---|
2228 | *
|
---|
2229 | * This only works on the lowest level of the page tables in the current mode.
|
---|
2230 | *
|
---|
2231 | * Since we generally use the largest pages available when setting up the
|
---|
2232 | * initial page tables, this function will usually have to allocate and create
|
---|
2233 | * more tables. This may fail if we're low on memory.
|
---|
2234 | *
|
---|
2235 | * @returns IPRT status code.
|
---|
2236 | * @param uFlat The flat address of the first page in the range (rounded
|
---|
2237 | * down nearest page boundrary).
|
---|
2238 | * @param cb The range size from @a pv (rounded up to nearest page boundrary).
|
---|
2239 | * @param fSet Mask of zero or more X86_PTE_XXX values to set for the range.
|
---|
2240 | * @param fClear Mask of zero or more X86_PTE_XXX values to clear for the range.
|
---|
2241 | */
|
---|
2242 | BS3_CMN_PROTO_STUB(int, Bs3PagingProtect,(uint64_t uFlat, uint64_t cb, uint64_t fSet, uint64_t fClear));
|
---|
2243 |
|
---|
2244 | /**
|
---|
2245 | * Modifies the page table protection of an address range.
|
---|
2246 | *
|
---|
2247 | * This only works on the lowest level of the page tables in the current mode.
|
---|
2248 | *
|
---|
2249 | * Since we generally use the largest pages available when setting up the
|
---|
2250 | * initial page tables, this function will usually have to allocate and create
|
---|
2251 | * more tables. This may fail if we're low on memory.
|
---|
2252 | *
|
---|
2253 | * @returns IPRT status code.
|
---|
2254 | * @param pv The address of the first page in the range (rounded
|
---|
2255 | * down nearest page boundrary).
|
---|
2256 | * @param cb The range size from @a pv (rounded up to nearest page boundrary).
|
---|
2257 | * @param fSet Mask of zero or more X86_PTE_XXX values to set for the range.
|
---|
2258 | * @param fClear Mask of zero or more X86_PTE_XXX values to clear for the range.
|
---|
2259 | */
|
---|
2260 | BS3_CMN_PROTO_STUB(int, Bs3PagingProtectPtr,(void BS3_FAR *pv, size_t cb, uint64_t fSet, uint64_t fClear));
|
---|
2261 |
|
---|
2262 | /**
|
---|
2263 | * Aliases (maps) one or more contiguous physical pages to a virtual range.
|
---|
2264 | *
|
---|
2265 | * @returns VBox status code.
|
---|
2266 | * @retval VERR_INVALID_PARAMETER if we're in legacy paging mode and @a uDst or
|
---|
2267 | * @a uPhysToAlias are not compatible with legacy paging.
|
---|
2268 | * @retval VERR_OUT_OF_RANGE if we cannot traverse the page tables in this mode
|
---|
2269 | * (typically real mode or v86, maybe 16-bit PE).
|
---|
2270 | * @retval VERR_NO_MEMORY if we cannot allocate page tables for splitting up
|
---|
2271 | * the necessary large pages. No aliasing was performed.
|
---|
2272 | *
|
---|
2273 | * @param uDst The virtual address to map it at. Rounded down
|
---|
2274 | * to the nearest page (@a cbHowMuch is adjusted
|
---|
2275 | * up).
|
---|
2276 | * @param uPhysToAlias The physical address of the first page in the
|
---|
2277 | * (contiguous) range to map. Chopped down to
|
---|
2278 | * nearest page boundrary (@a cbHowMuch is not
|
---|
2279 | * adjusted).
|
---|
2280 | * @param cbHowMuch How much to map. Rounded up to nearest page.
|
---|
2281 | * @param fPte The PTE flags.
|
---|
2282 | */
|
---|
2283 | BS3_CMN_PROTO_STUB(int, Bs3PagingAlias,(uint64_t uDst, uint64_t uPhysToAlias, uint32_t cbHowMuch, uint64_t fPte));
|
---|
2284 |
|
---|
2285 | /**
|
---|
2286 | * Unaliases memory, i.e. restores the 1:1 mapping.
|
---|
2287 | *
|
---|
2288 | * @returns VBox status code. Cannot fail if @a uDst and @a cbHowMuch specify
|
---|
2289 | * the range of a successful Bs3PagingAlias call, however it may run
|
---|
2290 | * out of memory if it's breaking new ground.
|
---|
2291 | *
|
---|
2292 | * @param uDst The virtual address to restore to 1:1 mapping.
|
---|
2293 | * Rounded down to the nearest page (@a cbHowMuch
|
---|
2294 | * is adjusted up).
|
---|
2295 | * @param cbHowMuch How much to restore. Rounded up to nearest page.
|
---|
2296 | */
|
---|
2297 | BS3_CMN_PROTO_STUB(int, Bs3PagingUnalias,(uint64_t uDst, uint32_t cbHowMuch));
|
---|
2298 |
|
---|
2299 | /**
|
---|
2300 | * Get the pointer to the PTE for the given address.
|
---|
2301 | *
|
---|
2302 | * @returns Pointer to the PTE.
|
---|
2303 | * @param uFlat The flat address of the page which PTE we want.
|
---|
2304 | * @param prc Where to return additional error info. Optional.
|
---|
2305 | */
|
---|
2306 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3PagingGetPte,(uint64_t uFlat, int *prc));
|
---|
2307 |
|
---|
2308 | /**
|
---|
2309 | * Paging information for an address.
|
---|
2310 | */
|
---|
2311 | typedef struct BS3PAGINGINFO4ADDR
|
---|
2312 | {
|
---|
2313 | /** The depth of the system's paging mode.
|
---|
2314 | * This is always 2 for legacy, 3 for PAE and 4 for long mode. */
|
---|
2315 | uint8_t cEntries;
|
---|
2316 | /** The size of the page structures (the entires). */
|
---|
2317 | uint8_t cbEntry;
|
---|
2318 | /** Flags defined for future fun, currently zero. */
|
---|
2319 | uint16_t fFlags;
|
---|
2320 | /** Union display different view on the entry pointers. */
|
---|
2321 | union
|
---|
2322 | {
|
---|
2323 | /** Pointer to the page structure entries, starting with the PTE as 0.
|
---|
2324 | * If large pages are involved, the first entry will be NULL (first two if 1GB
|
---|
2325 | * page). Same if the address is invalid on a higher level. */
|
---|
2326 | uint8_t BS3_FAR *apbEntries[4];
|
---|
2327 | /** Alternative view for legacy mode. */
|
---|
2328 | struct
|
---|
2329 | {
|
---|
2330 | X86PTE BS3_FAR *pPte;
|
---|
2331 | X86PDE BS3_FAR *pPde;
|
---|
2332 | void *pvUnused2;
|
---|
2333 | void *pvUnused3;
|
---|
2334 | } Legacy;
|
---|
2335 | /** Alternative view for PAE and Long mode. */
|
---|
2336 | struct
|
---|
2337 | {
|
---|
2338 | X86PTEPAE BS3_FAR *pPte;
|
---|
2339 | X86PDEPAE BS3_FAR *pPde;
|
---|
2340 | X86PDPE BS3_FAR *pPdpe;
|
---|
2341 | X86PML4E BS3_FAR *pPml4e;
|
---|
2342 | } Pae;
|
---|
2343 | } u;
|
---|
2344 | } BS3PAGINGINFO4ADDR;
|
---|
2345 | /** Pointer to paging information for and address. */
|
---|
2346 | typedef BS3PAGINGINFO4ADDR BS3_FAR *PBS3PAGINGINFO4ADDR;
|
---|
2347 |
|
---|
2348 | /**
|
---|
2349 | * Queries paging information about the given virtual address.
|
---|
2350 | *
|
---|
2351 | * @returns VBox status code.
|
---|
2352 | * @param uFlat The flat address to query information about.
|
---|
2353 | * @param pPgInfo Where to return the information.
|
---|
2354 | */
|
---|
2355 | BS3_CMN_PROTO_STUB(int, Bs3PagingQueryAddressInfo,(uint64_t uFlat, PBS3PAGINGINFO4ADDR pPgInfo));
|
---|
2356 |
|
---|
2357 |
|
---|
2358 | /** The physical / flat address of the buffer backing the canonical traps.
|
---|
2359 | * This buffer is spread equally on each side of the 64-bit non-canonical
|
---|
2360 | * address divide. Non-64-bit code can use this to setup trick shots and
|
---|
2361 | * inspect their results. */
|
---|
2362 | extern uint32_t g_uBs3PagingCanonicalTrapsAddr;
|
---|
2363 | /** The size of the buffer at g_uPagingCanonicalTraps (both sides). */
|
---|
2364 | extern uint16_t g_cbBs3PagingCanonicalTraps;
|
---|
2365 | /** The size of one trap buffer (low or high).
|
---|
2366 | * This is g_cbBs3PagingCanonicalTraps divided by two. */
|
---|
2367 | extern uint16_t g_cbBs3PagingOneCanonicalTrap;
|
---|
2368 |
|
---|
2369 | /**
|
---|
2370 | * Sets up the 64-bit canonical address space trap buffers, if neceessary.
|
---|
2371 | *
|
---|
2372 | * @returns Pointer to the buffers (i.e. the first page of the low one) on
|
---|
2373 | * success. NULL on failure.
|
---|
2374 | */
|
---|
2375 | BS3_CMN_PROTO_STUB(void BS3_FAR *, Bs3PagingSetupCanonicalTraps,(void));
|
---|
2376 |
|
---|
2377 | /**
|
---|
2378 | * Waits for the keyboard controller to become ready.
|
---|
2379 | */
|
---|
2380 | BS3_CMN_PROTO_NOSB(void, Bs3KbdWait,(void));
|
---|
2381 |
|
---|
2382 | /**
|
---|
2383 | * Sends a read command to the keyboard controller and gets the result.
|
---|
2384 | *
|
---|
2385 | * The caller is responsible for making sure the keyboard controller is ready
|
---|
2386 | * for a command (call #Bs3KbdWait if unsure).
|
---|
2387 | *
|
---|
2388 | * @returns The value read is returned (in al).
|
---|
2389 | * @param bCmd The read command.
|
---|
2390 | */
|
---|
2391 | BS3_CMN_PROTO_NOSB(uint8_t, Bs3KbdRead,(uint8_t bCmd));
|
---|
2392 |
|
---|
2393 | /**
|
---|
2394 | * Sends a write command to the keyboard controller and then sends the data.
|
---|
2395 | *
|
---|
2396 | * The caller is responsible for making sure the keyboard controller is ready
|
---|
2397 | * for a command (call #Bs3KbdWait if unsure).
|
---|
2398 | *
|
---|
2399 | * @param bCmd The write command.
|
---|
2400 | * @param bData The data to write.
|
---|
2401 | */
|
---|
2402 | BS3_CMN_PROTO_NOSB(void, Bs3KbdWrite,(uint8_t bCmd, uint8_t bData));
|
---|
2403 |
|
---|
2404 |
|
---|
2405 | /**
|
---|
2406 | * Configures the PIC, once only.
|
---|
2407 | *
|
---|
2408 | * Subsequent calls to this function will not do anything.
|
---|
2409 | *
|
---|
2410 | * The PIC will be programmed to use IDT/IVT vectors 0x70 thru 0x7f, auto
|
---|
2411 | * end-of-interrupt, and all IRQs masked. The individual PIC users will have to
|
---|
2412 | * use #Bs3PicUpdateMask unmask their IRQ once they've got all the handlers
|
---|
2413 | * installed.
|
---|
2414 | */
|
---|
2415 | BS3_CMN_PROTO_STUB(void, Bs3PicSetup,(void));
|
---|
2416 |
|
---|
2417 | /**
|
---|
2418 | * Updates the PIC masks.
|
---|
2419 | *
|
---|
2420 | * @returns The new mask - master in low, slave in high byte.
|
---|
2421 | * @param fAndMask Things to keep as-is. Master in low, slave in high byte.
|
---|
2422 | * @param fOrMask Things to start masking. Ditto wrt bytes.
|
---|
2423 | */
|
---|
2424 | BS3_CMN_PROTO_STUB(uint16_t, Bs3PicUpdateMask,(uint16_t fAndMask, uint16_t fOrMask));
|
---|
2425 |
|
---|
2426 | /**
|
---|
2427 | * Disables all IRQs on the PIC.
|
---|
2428 | */
|
---|
2429 | BS3_CMN_PROTO_STUB(void, Bs3PicMaskAll,(void));
|
---|
2430 |
|
---|
2431 |
|
---|
2432 | /**
|
---|
2433 | * Sets up the PIT for periodic callback.
|
---|
2434 | *
|
---|
2435 | * @param cHzDesired The desired Hz. Zero means max interval length
|
---|
2436 | * (18.2Hz). Plase check the various PIT globals for
|
---|
2437 | * the actual interval length.
|
---|
2438 | */
|
---|
2439 | BS3_CMN_PROTO_STUB(void, Bs3PitSetupAndEnablePeriodTimer,(uint16_t cHzDesired));
|
---|
2440 |
|
---|
2441 | /**
|
---|
2442 | * Disables the PIT if active.
|
---|
2443 | */
|
---|
2444 | BS3_CMN_PROTO_STUB(void, Bs3PitDisable,(void));
|
---|
2445 |
|
---|
2446 | /** Nano seconds (approx) since last the PIT timer was started. */
|
---|
2447 | extern uint64_t volatile g_cBs3PitNs;
|
---|
2448 | /** Milliseconds seconds (very approx) since last the PIT timer was started. */
|
---|
2449 | extern uint64_t volatile g_cBs3PitMs;
|
---|
2450 | /** Number of ticks since last the PIT timer was started. */
|
---|
2451 | extern uint32_t volatile g_cBs3PitTicks;
|
---|
2452 | /** The current interval in nanon seconds. */
|
---|
2453 | extern uint32_t g_cBs3PitIntervalNs;
|
---|
2454 | /** The current interval in milliseconds (approximately).
|
---|
2455 | * This is 0 if not yet started (used for checking the state internally). */
|
---|
2456 | extern uint16_t volatile g_cBs3PitIntervalMs;
|
---|
2457 | /** The current PIT frequency (approximately). 0 if not yet started. */
|
---|
2458 | extern uint16_t g_cBs3PitIntervalHz;
|
---|
2459 |
|
---|
2460 |
|
---|
2461 | /**
|
---|
2462 | * Call 16-bit prot mode function from v8086 mode.
|
---|
2463 | *
|
---|
2464 | * This switches from v8086 mode to 16-bit protected mode (code) and executed
|
---|
2465 | * @a fpfnCall with @a cbParams bytes of parameters pushed on the stack.
|
---|
2466 | * Afterwards it switches back to v8086 mode and returns a 16-bit status code.
|
---|
2467 | *
|
---|
2468 | * @returns 16-bit status code if the function returned anything.
|
---|
2469 | * @param fpfnCall Far real mode pointer to the function to call.
|
---|
2470 | * @param cbParams The size of the parameter list, in bytes.
|
---|
2471 | * @param ... The parameters.
|
---|
2472 | * @sa Bs3SwitchTo32BitAndCallC
|
---|
2473 | */
|
---|
2474 | BS3_CMN_PROTO_STUB(int, Bs3SwitchFromV86To16BitAndCallC,(FPFNBS3FAR fpfnCall, unsigned cbParams, ...));
|
---|
2475 |
|
---|
2476 |
|
---|
2477 | /**
|
---|
2478 | * BS3 integer register.
|
---|
2479 | */
|
---|
2480 | typedef union BS3REG
|
---|
2481 | {
|
---|
2482 | /** 8-bit unsigned integer. */
|
---|
2483 | uint8_t u8;
|
---|
2484 | /** 16-bit unsigned integer. */
|
---|
2485 | uint16_t u16;
|
---|
2486 | /** 32-bit unsigned integer. */
|
---|
2487 | uint32_t u32;
|
---|
2488 | /** 64-bit unsigned integer. */
|
---|
2489 | uint64_t u64;
|
---|
2490 | /** Full unsigned integer. */
|
---|
2491 | uint64_t u;
|
---|
2492 | /** High/low byte view. */
|
---|
2493 | struct
|
---|
2494 | {
|
---|
2495 | uint8_t bLo;
|
---|
2496 | uint8_t bHi;
|
---|
2497 | } b;
|
---|
2498 | /** 8-bit view. */
|
---|
2499 | uint8_t au8[8];
|
---|
2500 | /** 16-bit view. */
|
---|
2501 | uint16_t au16[4];
|
---|
2502 | /** 32-bit view. */
|
---|
2503 | uint32_t au32[2];
|
---|
2504 | } BS3REG;
|
---|
2505 | /** Pointer to an integer register. */
|
---|
2506 | typedef BS3REG BS3_FAR *PBS3REG;
|
---|
2507 | /** Pointer to a const integer register. */
|
---|
2508 | typedef BS3REG const BS3_FAR *PCBS3REG;
|
---|
2509 |
|
---|
2510 | /**
|
---|
2511 | * Register context (without FPU).
|
---|
2512 | */
|
---|
2513 | typedef struct BS3REGCTX
|
---|
2514 | {
|
---|
2515 | BS3REG rax; /**< 0x00 */
|
---|
2516 | BS3REG rcx; /**< 0x08 */
|
---|
2517 | BS3REG rdx; /**< 0x10 */
|
---|
2518 | BS3REG rbx; /**< 0x18 */
|
---|
2519 | BS3REG rsp; /**< 0x20 */
|
---|
2520 | BS3REG rbp; /**< 0x28 */
|
---|
2521 | BS3REG rsi; /**< 0x30 */
|
---|
2522 | BS3REG rdi; /**< 0x38 */
|
---|
2523 | BS3REG r8; /**< 0x40 */
|
---|
2524 | BS3REG r9; /**< 0x48 */
|
---|
2525 | BS3REG r10; /**< 0x50 */
|
---|
2526 | BS3REG r11; /**< 0x58 */
|
---|
2527 | BS3REG r12; /**< 0x60 */
|
---|
2528 | BS3REG r13; /**< 0x68 */
|
---|
2529 | BS3REG r14; /**< 0x70 */
|
---|
2530 | BS3REG r15; /**< 0x78 */
|
---|
2531 | BS3REG rflags; /**< 0x80 */
|
---|
2532 | BS3REG rip; /**< 0x88 */
|
---|
2533 | uint16_t cs; /**< 0x90 */
|
---|
2534 | uint16_t ds; /**< 0x92 */
|
---|
2535 | uint16_t es; /**< 0x94 */
|
---|
2536 | uint16_t fs; /**< 0x96 */
|
---|
2537 | uint16_t gs; /**< 0x98 */
|
---|
2538 | uint16_t ss; /**< 0x9a */
|
---|
2539 | uint16_t tr; /**< 0x9c */
|
---|
2540 | uint16_t ldtr; /**< 0x9e */
|
---|
2541 | uint8_t bMode; /**< 0xa0: BS3_MODE_XXX. */
|
---|
2542 | uint8_t bCpl; /**< 0xa1: 0-3, 0 is used for real mode. */
|
---|
2543 | uint8_t fbFlags; /**< 0xa2: BS3REG_CTX_F_XXX */
|
---|
2544 | uint8_t abPadding[5]; /**< 0xa3 */
|
---|
2545 | BS3REG cr0; /**< 0xa8 */
|
---|
2546 | BS3REG cr2; /**< 0xb0 */
|
---|
2547 | BS3REG cr3; /**< 0xb8 */
|
---|
2548 | BS3REG cr4; /**< 0xc0 */
|
---|
2549 | uint64_t uUnused; /**< 0xc8 */
|
---|
2550 | } BS3REGCTX;
|
---|
2551 | AssertCompileSize(BS3REGCTX, 0xd0);
|
---|
2552 | /** Pointer to a register context. */
|
---|
2553 | typedef BS3REGCTX BS3_FAR *PBS3REGCTX;
|
---|
2554 | /** Pointer to a const register context. */
|
---|
2555 | typedef BS3REGCTX const BS3_FAR *PCBS3REGCTX;
|
---|
2556 |
|
---|
2557 | /** @name BS3REG_CTX_F_XXX - BS3REGCTX::fbFlags masks.
|
---|
2558 | * @{ */
|
---|
2559 | /** The CR0 is MSW (only low 16-bit). */
|
---|
2560 | #define BS3REG_CTX_F_NO_CR0_IS_MSW UINT8_C(0x01)
|
---|
2561 | /** No CR2 and CR3 values. Not in CPL 0 or CPU too old for CR2 & CR3. */
|
---|
2562 | #define BS3REG_CTX_F_NO_CR2_CR3 UINT8_C(0x02)
|
---|
2563 | /** No CR4 value. The CPU is too old for CR4. */
|
---|
2564 | #define BS3REG_CTX_F_NO_CR4 UINT8_C(0x04)
|
---|
2565 | /** No TR and LDTR values. Context gathered in real mode or v8086 mode. */
|
---|
2566 | #define BS3REG_CTX_F_NO_TR_LDTR UINT8_C(0x08)
|
---|
2567 | /** The context doesn't have valid values for AMD64 GPR extensions. */
|
---|
2568 | #define BS3REG_CTX_F_NO_AMD64 UINT8_C(0x10)
|
---|
2569 | /** @} */
|
---|
2570 |
|
---|
2571 | /**
|
---|
2572 | * Saves the current register context.
|
---|
2573 | *
|
---|
2574 | * @param pRegCtx Where to store the register context.
|
---|
2575 | */
|
---|
2576 | BS3_CMN_PROTO_NOSB(void, Bs3RegCtxSave,(PBS3REGCTX pRegCtx));
|
---|
2577 |
|
---|
2578 | /**
|
---|
2579 | * Switch to the specified CPU bitcount, reserve additional stack and save the
|
---|
2580 | * CPU context.
|
---|
2581 | *
|
---|
2582 | * This is for writing more flexible test drivers that can test more than the
|
---|
2583 | * CPU bitcount (16-bit, 32-bit, 64-bit, and virtual 8086) of the driver itself.
|
---|
2584 | * For instance a 32-bit driver can do V86 and 16-bit testing, thus saving more
|
---|
2585 | * precious and problematic 16-bit code.
|
---|
2586 | *
|
---|
2587 | * @param pRegCtx Where to store the register context.
|
---|
2588 | * @param bBitMode Bit mode to switch to, BS3_MODE_CODE_XXX. Only
|
---|
2589 | * BS3_MODE_CODE_MASK is used, other bits are ignored
|
---|
2590 | * to make it possible to pass a full mode value.
|
---|
2591 | * @param cbExtraStack Number of bytes of additional stack to allocate.
|
---|
2592 | */
|
---|
2593 | BS3_CMN_PROTO_FARSTUB(8, void, Bs3RegCtxSaveEx,(PBS3REGCTX pRegCtx, uint8_t bBitMode, uint16_t cbExtraStack));
|
---|
2594 |
|
---|
2595 | /**
|
---|
2596 | * Transforms a register context to a different ring.
|
---|
2597 | *
|
---|
2598 | * @param pRegCtx The register context.
|
---|
2599 | * @param bRing The target ring (0..3).
|
---|
2600 | */
|
---|
2601 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxConvertToRingX,(PBS3REGCTX pRegCtx, uint8_t bRing));
|
---|
2602 |
|
---|
2603 | /**
|
---|
2604 | * Restores a register context.
|
---|
2605 | *
|
---|
2606 | * @param pRegCtx The register context to be restored and resumed.
|
---|
2607 | * @param fFlags BS3REGCTXRESTORE_F_XXX.
|
---|
2608 | *
|
---|
2609 | * @remarks Will switch to ring-0.
|
---|
2610 | * @remarks Does not return.
|
---|
2611 | */
|
---|
2612 | BS3_CMN_PROTO_NOSB(DECL_NO_RETURN(void), Bs3RegCtxRestore,(PCBS3REGCTX pRegCtx, uint16_t fFlags));
|
---|
2613 | #if !defined(BS3_KIT_WITH_NO_RETURN) && defined(__WATCOMC__)
|
---|
2614 | # pragma aux Bs3RegCtxRestore_c16 "_Bs3RegCtxRestore_aborts_c16" __aborts
|
---|
2615 | # pragma aux Bs3RegCtxRestore_f16 "_Bs3RegCtxRestore_aborts_f16" __aborts
|
---|
2616 | # pragma aux Bs3RegCtxRestore_c32 "_Bs3RegCtxRestore_aborts_c32" __aborts
|
---|
2617 | #endif
|
---|
2618 |
|
---|
2619 | /** @name Flags for Bs3RegCtxRestore
|
---|
2620 | * @{ */
|
---|
2621 | /** Skip restoring the CRx registers. */
|
---|
2622 | #define BS3REGCTXRESTORE_F_SKIP_CRX UINT16_C(0x0001)
|
---|
2623 | /** Sets g_fBs3TrapNoV86Assist. */
|
---|
2624 | #define BS3REGCTXRESTORE_F_NO_V86_ASSIST UINT16_C(0x0002)
|
---|
2625 | /** @} */
|
---|
2626 |
|
---|
2627 | /**
|
---|
2628 | * Prints the register context.
|
---|
2629 | *
|
---|
2630 | * @param pRegCtx The register context to be printed.
|
---|
2631 | */
|
---|
2632 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxPrint,(PCBS3REGCTX pRegCtx));
|
---|
2633 |
|
---|
2634 | /**
|
---|
2635 | * Sets a GPR and segment register to point at the same location as @a uFlat.
|
---|
2636 | *
|
---|
2637 | * @param pRegCtx The register context.
|
---|
2638 | * @param pGpr The general purpose register to set (points within
|
---|
2639 | * @a pRegCtx).
|
---|
2640 | * @param pSel The selector register (points within @a pRegCtx).
|
---|
2641 | * @param uFlat Flat location address.
|
---|
2642 | */
|
---|
2643 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetGrpSegFromFlat,(PBS3REGCTX pRegCtx, PBS3REG pGpr, PRTSEL pSel, RTCCUINTXREG uFlat));
|
---|
2644 |
|
---|
2645 | /**
|
---|
2646 | * Sets a GPR and segment register to point at the same location as @a ovPtr.
|
---|
2647 | *
|
---|
2648 | * @param pRegCtx The register context.
|
---|
2649 | * @param pGpr The general purpose register to set (points within
|
---|
2650 | * @a pRegCtx).
|
---|
2651 | * @param pSel The selector register (points within @a pRegCtx).
|
---|
2652 | * @param pvPtr Current context pointer.
|
---|
2653 | */
|
---|
2654 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetGrpSegFromCurPtr,(PBS3REGCTX pRegCtx, PBS3REG pGpr, PRTSEL pSel, void BS3_FAR *pvPtr));
|
---|
2655 |
|
---|
2656 | /**
|
---|
2657 | * Sets a GPR and DS to point at the same location as @a ovPtr.
|
---|
2658 | *
|
---|
2659 | * @param pRegCtx The register context.
|
---|
2660 | * @param pGpr The general purpose register to set (points within
|
---|
2661 | * @a pRegCtx).
|
---|
2662 | * @param pvPtr Current context pointer.
|
---|
2663 | */
|
---|
2664 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetGrpDsFromCurPtr,(PBS3REGCTX pRegCtx, PBS3REG pGpr, void BS3_FAR *pvPtr));
|
---|
2665 |
|
---|
2666 | /**
|
---|
2667 | * Sets CS:RIP to point at the same piece of code as @a uFlatCode.
|
---|
2668 | *
|
---|
2669 | * @param pRegCtx The register context.
|
---|
2670 | * @param uFlatCode Flat code pointer
|
---|
2671 | * @sa Bs3RegCtxSetRipCsFromLnkPtr, Bs3RegCtxSetRipCsFromCurPtr
|
---|
2672 | */
|
---|
2673 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetRipCsFromFlat,(PBS3REGCTX pRegCtx, RTCCUINTXREG uFlatCode));
|
---|
2674 |
|
---|
2675 | /**
|
---|
2676 | * Sets CS:RIP to point at the same piece of code as @a pfnCode.
|
---|
2677 | *
|
---|
2678 | * The 16-bit edition of this function expects a far 16:16 address as written by
|
---|
2679 | * the linker (i.e. real mode).
|
---|
2680 | *
|
---|
2681 | * @param pRegCtx The register context.
|
---|
2682 | * @param pfnCode Pointer to the code. In 32-bit and 64-bit mode this is a
|
---|
2683 | * flat address, while in 16-bit it's a far 16:16 address
|
---|
2684 | * as fixed up by the linker (real mode selector). This
|
---|
2685 | * address is converted to match the mode of the context.
|
---|
2686 | * @sa Bs3RegCtxSetRipCsFromCurPtr, Bs3RegCtxSetRipCsFromFlat
|
---|
2687 | */
|
---|
2688 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetRipCsFromLnkPtr,(PBS3REGCTX pRegCtx, FPFNBS3FAR pfnCode));
|
---|
2689 |
|
---|
2690 | /**
|
---|
2691 | * Sets CS:RIP to point at the same piece of code as @a pfnCode.
|
---|
2692 | *
|
---|
2693 | * @param pRegCtx The register context.
|
---|
2694 | * @param pfnCode Pointer to the code. Current mode pointer.
|
---|
2695 | * @sa Bs3RegCtxSetRipCsFromLnkPtr, Bs3RegCtxSetRipCsFromFlat
|
---|
2696 | */
|
---|
2697 | BS3_CMN_PROTO_STUB(void, Bs3RegCtxSetRipCsFromCurPtr,(PBS3REGCTX pRegCtx, FPFNBS3FAR pfnCode));
|
---|
2698 |
|
---|
2699 |
|
---|
2700 | /**
|
---|
2701 | * The method to be used to save and restore the extended context.
|
---|
2702 | */
|
---|
2703 | typedef enum BS3EXTCTXMETHOD
|
---|
2704 | {
|
---|
2705 | BS3EXTCTXMETHOD_INVALID = 0,
|
---|
2706 | BS3EXTCTXMETHOD_ANCIENT, /**< Ancient fnsave/frstor format. */
|
---|
2707 | BS3EXTCTXMETHOD_FXSAVE, /**< fxsave/fxrstor format. */
|
---|
2708 | BS3EXTCTXMETHOD_XSAVE, /**< xsave/xrstor format. */
|
---|
2709 | BS3EXTCTXMETHOD_END,
|
---|
2710 | } BS3EXTCTXMETHOD;
|
---|
2711 |
|
---|
2712 |
|
---|
2713 | /**
|
---|
2714 | * Extended CPU context (FPU, SSE, AVX, ++).
|
---|
2715 | *
|
---|
2716 | * @remarks Also in bs3kit.inc
|
---|
2717 | */
|
---|
2718 | typedef struct BS3EXTCTX
|
---|
2719 | {
|
---|
2720 | /** Dummy/magic value. */
|
---|
2721 | uint16_t u16Magic;
|
---|
2722 | /** The size of the structure. */
|
---|
2723 | uint16_t cb;
|
---|
2724 | /** The method used to save and restore the context (BS3EXTCTXMETHOD). */
|
---|
2725 | uint8_t enmMethod;
|
---|
2726 | uint8_t abPadding0[3];
|
---|
2727 | /** Nominal XSAVE_C_XXX. */
|
---|
2728 | uint64_t fXcr0Nominal;
|
---|
2729 | /** The saved XCR0 mask (restored after xrstor). */
|
---|
2730 | uint64_t fXcr0Saved;
|
---|
2731 |
|
---|
2732 | /** Explicit alignment padding. */
|
---|
2733 | uint8_t abPadding[64 - 2 - 2 - 1 - 3 - 8 - 8];
|
---|
2734 |
|
---|
2735 | /** The context, variable size (see above).
|
---|
2736 | * This must be aligned on a 64 byte boundrary. */
|
---|
2737 | union
|
---|
2738 | {
|
---|
2739 | /** fnsave/frstor. */
|
---|
2740 | X86FPUSTATE Ancient;
|
---|
2741 | /** fxsave/fxrstor */
|
---|
2742 | X86FXSTATE x87;
|
---|
2743 | /** xsave/xrstor */
|
---|
2744 | X86XSAVEAREA x;
|
---|
2745 | /** Byte array view. */
|
---|
2746 | uint8_t ab[sizeof(X86XSAVEAREA)];
|
---|
2747 | } Ctx;
|
---|
2748 | } BS3EXTCTX;
|
---|
2749 | AssertCompileMemberAlignment(BS3EXTCTX, Ctx, 64);
|
---|
2750 | /** Pointer to an extended CPU context. */
|
---|
2751 | typedef BS3EXTCTX BS3_FAR *PBS3EXTCTX;
|
---|
2752 | /** Pointer to a const extended CPU context. */
|
---|
2753 | typedef BS3EXTCTX const BS3_FAR *PCBS3EXTCTX;
|
---|
2754 |
|
---|
2755 | /** Magic value for BS3EXTCTX. */
|
---|
2756 | #define BS3EXTCTX_MAGIC UINT16_C(0x1980)
|
---|
2757 |
|
---|
2758 | /**
|
---|
2759 | * Allocates and initializes the extended CPU context structure.
|
---|
2760 | *
|
---|
2761 | * @returns The new extended CPU context structure.
|
---|
2762 | * @param enmKind The kind of allocation to make.
|
---|
2763 | */
|
---|
2764 | BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxAlloc,(BS3MEMKIND enmKind));
|
---|
2765 |
|
---|
2766 | /**
|
---|
2767 | * Frees an extended CPU context structure.
|
---|
2768 | *
|
---|
2769 | * @param pExtCtx The extended CPU context (returned by
|
---|
2770 | * Bs3ExtCtxAlloc).
|
---|
2771 | */
|
---|
2772 | BS3_CMN_PROTO_STUB(void, Bs3ExtCtxFree,(PBS3EXTCTX pExtCtx));
|
---|
2773 |
|
---|
2774 | /**
|
---|
2775 | * Get the size required for a BS3EXTCTX structure.
|
---|
2776 | *
|
---|
2777 | * @returns size in bytes of the whole structure.
|
---|
2778 | * @param pfFlags Where to return flags for Bs3ExtCtxInit.
|
---|
2779 | * @note Use Bs3ExtCtxAlloc when possible.
|
---|
2780 | */
|
---|
2781 | BS3_CMN_PROTO_STUB(uint16_t, Bs3ExtCtxGetSize,(uint64_t *pfFlags));
|
---|
2782 |
|
---|
2783 | /**
|
---|
2784 | * Initializes the extended CPU context structure.
|
---|
2785 | * @returns pExtCtx
|
---|
2786 | * @param pExtCtx The extended CPU context.
|
---|
2787 | * @param cbExtCtx The size of the @a pExtCtx allocation.
|
---|
2788 | * @param fFlags XSAVE_C_XXX flags.
|
---|
2789 | */
|
---|
2790 | BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxInit,(PBS3EXTCTX pExtCtx, uint16_t cbExtCtx, uint64_t fFlags));
|
---|
2791 |
|
---|
2792 | /**
|
---|
2793 | * Saves the extended CPU state to the given structure.
|
---|
2794 | *
|
---|
2795 | * @param pExtCtx The extended CPU context.
|
---|
2796 | * @remarks All GPRs preserved.
|
---|
2797 | */
|
---|
2798 | BS3_CMN_PROTO_FARSTUB(4, void, Bs3ExtCtxSave,(PBS3EXTCTX pExtCtx));
|
---|
2799 |
|
---|
2800 | /**
|
---|
2801 | * Restores the extended CPU state from the given structure.
|
---|
2802 | *
|
---|
2803 | * @param pExtCtx The extended CPU context.
|
---|
2804 | * @remarks All GPRs preserved.
|
---|
2805 | */
|
---|
2806 | BS3_CMN_PROTO_FARSTUB(4, void, Bs3ExtCtxRestore,(PBS3EXTCTX pExtCtx));
|
---|
2807 |
|
---|
2808 | /**
|
---|
2809 | * Copies the state from one context to another.
|
---|
2810 | *
|
---|
2811 | * @returns pDst
|
---|
2812 | * @param pDst The destination extended CPU context.
|
---|
2813 | * @param pSrc The source extended CPU context.
|
---|
2814 | */
|
---|
2815 | BS3_CMN_PROTO_STUB(PBS3EXTCTX, Bs3ExtCtxCopy,(PBS3EXTCTX pDst, PCBS3EXTCTX pSrc));
|
---|
2816 |
|
---|
2817 |
|
---|
2818 | /** @name Debug register accessors for V8086 mode (works everwhere).
|
---|
2819 | * @{ */
|
---|
2820 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDr0,(void));
|
---|
2821 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDr1,(void));
|
---|
2822 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDr2,(void));
|
---|
2823 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDr3,(void));
|
---|
2824 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDr6,(void));
|
---|
2825 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDr7,(void));
|
---|
2826 |
|
---|
2827 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDr0,(RTCCUINTXREG uValue));
|
---|
2828 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDr1,(RTCCUINTXREG uValue));
|
---|
2829 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDr2,(RTCCUINTXREG uValue));
|
---|
2830 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDr3,(RTCCUINTXREG uValue));
|
---|
2831 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDr6,(RTCCUINTXREG uValue));
|
---|
2832 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDr7,(RTCCUINTXREG uValue));
|
---|
2833 |
|
---|
2834 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetDrX,(uint8_t iReg));
|
---|
2835 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetDrX,(uint8_t iReg, RTCCUINTXREG uValue));
|
---|
2836 | /** @} */
|
---|
2837 |
|
---|
2838 |
|
---|
2839 | /** @name Control register accessors for V8086 mode (works everwhere).
|
---|
2840 | * @{ */
|
---|
2841 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetCr0,(void));
|
---|
2842 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetCr2,(void));
|
---|
2843 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetCr3,(void));
|
---|
2844 | BS3_CMN_PROTO_NOSB(RTCCUINTXREG, Bs3RegGetCr4,(void));
|
---|
2845 |
|
---|
2846 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetCr0,(RTCCUINTXREG uValue));
|
---|
2847 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetCr2,(RTCCUINTXREG uValue));
|
---|
2848 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetCr3,(RTCCUINTXREG uValue));
|
---|
2849 | BS3_CMN_PROTO_NOSB(void, Bs3RegSetCr4,(RTCCUINTXREG uValue));
|
---|
2850 | /** @} */
|
---|
2851 |
|
---|
2852 |
|
---|
2853 | /**
|
---|
2854 | * Trap frame.
|
---|
2855 | */
|
---|
2856 | typedef struct BS3TRAPFRAME
|
---|
2857 | {
|
---|
2858 | /** 0x00: Exception/interrupt number. */
|
---|
2859 | uint8_t bXcpt;
|
---|
2860 | /** 0x01: The size of the IRET frame. */
|
---|
2861 | uint8_t cbIretFrame;
|
---|
2862 | /** 0x02: The handler CS. */
|
---|
2863 | uint16_t uHandlerCs;
|
---|
2864 | /** 0x04: The handler SS. */
|
---|
2865 | uint16_t uHandlerSs;
|
---|
2866 | /** 0x06: Explicit alignment. */
|
---|
2867 | uint16_t usAlignment;
|
---|
2868 | /** 0x08: The handler RSP (pointer to the iret frame, skipping ErrCd). */
|
---|
2869 | uint64_t uHandlerRsp;
|
---|
2870 | /** 0x10: The handler RFLAGS value. */
|
---|
2871 | uint64_t fHandlerRfl;
|
---|
2872 | /** 0x18: The error code (if applicable). */
|
---|
2873 | uint64_t uErrCd;
|
---|
2874 | /** 0x20: The register context. */
|
---|
2875 | BS3REGCTX Ctx;
|
---|
2876 | } BS3TRAPFRAME;
|
---|
2877 | AssertCompileSize(BS3TRAPFRAME, 0x20 + 0xd0);
|
---|
2878 | /** Pointer to a trap frame. */
|
---|
2879 | typedef BS3TRAPFRAME BS3_FAR *PBS3TRAPFRAME;
|
---|
2880 | /** Pointer to a const trap frame. */
|
---|
2881 | typedef BS3TRAPFRAME const BS3_FAR *PCBS3TRAPFRAME;
|
---|
2882 |
|
---|
2883 |
|
---|
2884 | /**
|
---|
2885 | * Re-initializes the trap handling for the current mode.
|
---|
2886 | *
|
---|
2887 | * Useful after a test that messes with the IDT/IVT.
|
---|
2888 | *
|
---|
2889 | * @sa Bs3TrapInit
|
---|
2890 | */
|
---|
2891 | BS3_CMN_PROTO_STUB(void, Bs3TrapReInit,(void));
|
---|
2892 |
|
---|
2893 | /**
|
---|
2894 | * Initializes real mode and v8086 trap handling.
|
---|
2895 | *
|
---|
2896 | * @remarks Does not install RM/V86 trap handling, just initializes the
|
---|
2897 | * structures.
|
---|
2898 | */
|
---|
2899 | BS3_CMN_PROTO_STUB(void, Bs3TrapRmV86Init,(void));
|
---|
2900 |
|
---|
2901 | /**
|
---|
2902 | * Initializes real mode and v8086 trap handling, extended version.
|
---|
2903 | *
|
---|
2904 | * @param f386Plus Set if the CPU is 80386 or later and
|
---|
2905 | * extended registers should be saved. Once initialized
|
---|
2906 | * with this parameter set to @a true, the effect cannot be
|
---|
2907 | * reversed.
|
---|
2908 | *
|
---|
2909 | * @remarks Does not install RM/V86 trap handling, just initializes the
|
---|
2910 | * structures.
|
---|
2911 | */
|
---|
2912 | BS3_CMN_PROTO_STUB(void, Bs3TrapRmV86InitEx,(bool f386Plus));
|
---|
2913 |
|
---|
2914 | /**
|
---|
2915 | * Initializes 16-bit (protected mode) trap handling.
|
---|
2916 | *
|
---|
2917 | * @remarks Does not install 16-bit trap handling, just initializes the
|
---|
2918 | * structures.
|
---|
2919 | */
|
---|
2920 | BS3_CMN_PROTO_STUB(void, Bs3Trap16Init,(void));
|
---|
2921 |
|
---|
2922 | /**
|
---|
2923 | * Initializes 16-bit (protected mode) trap handling, extended version.
|
---|
2924 | *
|
---|
2925 | * @param f386Plus Set if the CPU is 80386 or later and
|
---|
2926 | * extended registers should be saved. Once initialized
|
---|
2927 | * with this parameter set to @a true, the effect cannot be
|
---|
2928 | * reversed.
|
---|
2929 | *
|
---|
2930 | * @remarks Does not install 16-bit trap handling, just initializes the
|
---|
2931 | * structures.
|
---|
2932 | */
|
---|
2933 | BS3_CMN_PROTO_STUB(void, Bs3Trap16InitEx,(bool f386Plus));
|
---|
2934 |
|
---|
2935 | /**
|
---|
2936 | * Initializes 32-bit trap handling.
|
---|
2937 | *
|
---|
2938 | * @remarks Does not install 32-bit trap handling, just initializes the
|
---|
2939 | * structures.
|
---|
2940 | */
|
---|
2941 | BS3_CMN_PROTO_STUB(void, Bs3Trap32Init,(void));
|
---|
2942 |
|
---|
2943 | /**
|
---|
2944 | * Initializes 64-bit trap handling
|
---|
2945 | *
|
---|
2946 | * @remarks Does not install 64-bit trap handling, just initializes the
|
---|
2947 | * structures.
|
---|
2948 | */
|
---|
2949 | BS3_CMN_PROTO_STUB(void, Bs3Trap64Init,(void));
|
---|
2950 |
|
---|
2951 | /**
|
---|
2952 | * Modifies the real-mode / V86 IVT entry specified by @a iIvt.
|
---|
2953 | *
|
---|
2954 | * @param iIvt The index of the IDT entry to set.
|
---|
2955 | * @param uSeg The handler real-mode segment.
|
---|
2956 | * @param off The handler offset.
|
---|
2957 | */
|
---|
2958 | BS3_CMN_PROTO_STUB(void, Bs3TrapRmV86SetGate,(uint8_t iIvt, uint16_t uSeg, uint16_t off));
|
---|
2959 |
|
---|
2960 | /**
|
---|
2961 | * Modifies the 16-bit IDT entry (protected mode) specified by @a iIdt.
|
---|
2962 | *
|
---|
2963 | * @param iIdt The index of the IDT entry to set.
|
---|
2964 | * @param bType The gate type (X86_SEL_TYPE_SYS_XXX).
|
---|
2965 | * @param bDpl The DPL.
|
---|
2966 | * @param uSel The handler selector.
|
---|
2967 | * @param off The handler offset (if applicable).
|
---|
2968 | * @param cParams The parameter count (for call gates).
|
---|
2969 | */
|
---|
2970 | BS3_CMN_PROTO_STUB(void, Bs3Trap16SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl,
|
---|
2971 | uint16_t uSel, uint16_t off, uint8_t cParams));
|
---|
2972 |
|
---|
2973 | /** The address of Bs3Trap16GenericEntries.
|
---|
2974 | * Bs3Trap16GenericEntries is an array of interrupt/trap/whatever entry
|
---|
2975 | * points, 8 bytes each, that will create a register frame and call the generic
|
---|
2976 | * C compatible trap handlers. */
|
---|
2977 | extern uint32_t g_Bs3Trap16GenericEntriesFlatAddr;
|
---|
2978 |
|
---|
2979 | /**
|
---|
2980 | * Modifies the 32-bit IDT entry specified by @a iIdt.
|
---|
2981 | *
|
---|
2982 | * @param iIdt The index of the IDT entry to set.
|
---|
2983 | * @param bType The gate type (X86_SEL_TYPE_SYS_XXX).
|
---|
2984 | * @param bDpl The DPL.
|
---|
2985 | * @param uSel The handler selector.
|
---|
2986 | * @param off The handler offset (if applicable).
|
---|
2987 | * @param cParams The parameter count (for call gates).
|
---|
2988 | */
|
---|
2989 | BS3_CMN_PROTO_STUB(void, Bs3Trap32SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl,
|
---|
2990 | uint16_t uSel, uint32_t off, uint8_t cParams));
|
---|
2991 |
|
---|
2992 | /** The address of Bs3Trap32GenericEntries.
|
---|
2993 | * Bs3Trap32GenericEntries is an array of interrupt/trap/whatever entry
|
---|
2994 | * points, 10 bytes each, that will create a register frame and call the generic
|
---|
2995 | * C compatible trap handlers. */
|
---|
2996 | extern uint32_t g_Bs3Trap32GenericEntriesFlatAddr;
|
---|
2997 |
|
---|
2998 | /**
|
---|
2999 | * Modifies the 64-bit IDT entry specified by @a iIdt.
|
---|
3000 | *
|
---|
3001 | * @param iIdt The index of the IDT entry to set.
|
---|
3002 | * @param bType The gate type (X86_SEL_TYPE_SYS_XXX).
|
---|
3003 | * @param bDpl The DPL.
|
---|
3004 | * @param uSel The handler selector.
|
---|
3005 | * @param off The handler offset (if applicable).
|
---|
3006 | * @param bIst The interrupt stack to use.
|
---|
3007 | */
|
---|
3008 | BS3_CMN_PROTO_STUB(void, Bs3Trap64SetGate,(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst));
|
---|
3009 |
|
---|
3010 | /** The address of Bs3Trap64GenericEntries.
|
---|
3011 | * Bs3Trap64GenericEntries is an array of interrupt/trap/whatever entry
|
---|
3012 | * points, 8 bytes each, that will create a register frame and call the generic
|
---|
3013 | * C compatible trap handlers. */
|
---|
3014 | extern uint32_t g_Bs3Trap64GenericEntriesFlatAddr;
|
---|
3015 |
|
---|
3016 | /**
|
---|
3017 | * Adjusts the DPL the IDT entry specified by @a iIdt.
|
---|
3018 | *
|
---|
3019 | * The change is applied to the 16-bit, 32-bit and 64-bit IDTs.
|
---|
3020 | *
|
---|
3021 | * @returns Old DPL (from 64-bit IDT).
|
---|
3022 | * @param iIdt The index of the IDT and IVT entry to set.
|
---|
3023 | * @param bDpl The DPL.
|
---|
3024 | */
|
---|
3025 | BS3_CMN_PROTO_STUB(uint8_t, Bs3TrapSetDpl,(uint8_t iIdt, uint8_t bDpl));
|
---|
3026 |
|
---|
3027 | /**
|
---|
3028 | * C-style trap handler.
|
---|
3029 | *
|
---|
3030 | * The caller will resume the context in @a pTrapFrame upon return.
|
---|
3031 | *
|
---|
3032 | * @param pTrapFrame The trap frame. Registers can be modified.
|
---|
3033 | * @note The 16-bit versions must be in CGROUP16!
|
---|
3034 | */
|
---|
3035 | typedef BS3_DECL_NEAR_CALLBACK(void) FNBS3TRAPHANDLER(PBS3TRAPFRAME pTrapFrame);
|
---|
3036 | /** Pointer to a trap handler (current template context). */
|
---|
3037 | typedef FNBS3TRAPHANDLER *PFNBS3TRAPHANDLER;
|
---|
3038 |
|
---|
3039 | #if ARCH_BITS == 16
|
---|
3040 | /** @copydoc FNBS3TRAPHANDLER */
|
---|
3041 | typedef FNBS3FAR FNBS3TRAPHANDLER32;
|
---|
3042 | /** @copydoc FNBS3TRAPHANDLER */
|
---|
3043 | typedef FNBS3FAR FNBS3TRAPHANDLER64;
|
---|
3044 | #else
|
---|
3045 | /** @copydoc FNBS3TRAPHANDLER */
|
---|
3046 | typedef FNBS3TRAPHANDLER FNBS3TRAPHANDLER32;
|
---|
3047 | /** @copydoc FNBS3TRAPHANDLER */
|
---|
3048 | typedef FNBS3TRAPHANDLER FNBS3TRAPHANDLER64;
|
---|
3049 | #endif
|
---|
3050 | /** @copydoc PFNBS3TRAPHANDLER */
|
---|
3051 | typedef FNBS3TRAPHANDLER32 *PFNBS3TRAPHANDLER32;
|
---|
3052 | /** @copydoc PFNBS3TRAPHANDLER */
|
---|
3053 | typedef FNBS3TRAPHANDLER64 *PFNBS3TRAPHANDLER64;
|
---|
3054 |
|
---|
3055 |
|
---|
3056 | /**
|
---|
3057 | * C-style trap handler, near 16-bit (CGROUP16).
|
---|
3058 | *
|
---|
3059 | * The caller will resume the context in @a pTrapFrame upon return.
|
---|
3060 | *
|
---|
3061 | * @param pTrapFrame The trap frame. Registers can be modified.
|
---|
3062 | */
|
---|
3063 | typedef BS3_DECL_NEAR_CALLBACK(void) FNBS3TRAPHANDLER16(PBS3TRAPFRAME pTrapFrame);
|
---|
3064 | /** Pointer to a trap handler (current template context). */
|
---|
3065 | typedef FNBS3TRAPHANDLER16 *PFNBS3TRAPHANDLER16;
|
---|
3066 |
|
---|
3067 | /**
|
---|
3068 | * C-style trap handler, near 16-bit (CGROUP16).
|
---|
3069 | *
|
---|
3070 | * The caller will resume the context in @a pTrapFrame upon return.
|
---|
3071 | *
|
---|
3072 | * @param pTrapFrame The trap frame. Registers can be modified.
|
---|
3073 | */
|
---|
3074 | typedef BS3_DECL_CALLBACK(void) FNBS3TRAPHANDLER3264(PBS3TRAPFRAME pTrapFrame);
|
---|
3075 | /** Pointer to a trap handler (current template context). */
|
---|
3076 | typedef FNBS3TRAPHANDLER3264 *FPFNBS3TRAPHANDLER3264;
|
---|
3077 |
|
---|
3078 |
|
---|
3079 | /**
|
---|
3080 | * Sets a trap handler (C/C++/assembly) for the current bitcount.
|
---|
3081 | *
|
---|
3082 | * @returns Previous handler.
|
---|
3083 | * @param iIdt The index of the IDT entry to set.
|
---|
3084 | * @param pfnHandler Pointer to the handler.
|
---|
3085 | * @sa Bs3TrapSetHandlerEx
|
---|
3086 | */
|
---|
3087 | BS3_CMN_PROTO_STUB(PFNBS3TRAPHANDLER, Bs3TrapSetHandler,(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler));
|
---|
3088 |
|
---|
3089 | /**
|
---|
3090 | * Sets a trap handler (C/C++/assembly) for all the bitcounts.
|
---|
3091 | *
|
---|
3092 | * @param iIdt The index of the IDT and IVT entry to set.
|
---|
3093 | * @param pfnHandler16 Pointer to the 16-bit handler. (Assumes linker addresses.)
|
---|
3094 | * @param pfnHandler32 Pointer to the 32-bit handler. (Assumes linker addresses.)
|
---|
3095 | * @param pfnHandler64 Pointer to the 64-bit handler. (Assumes linker addresses.)
|
---|
3096 | * @sa Bs3TrapSetHandler
|
---|
3097 | */
|
---|
3098 | BS3_CMN_PROTO_STUB(void, Bs3TrapSetHandlerEx,(uint8_t iIdt, PFNBS3TRAPHANDLER16 pfnHandler16,
|
---|
3099 | PFNBS3TRAPHANDLER32 pfnHandler32, PFNBS3TRAPHANDLER64 pfnHandler64));
|
---|
3100 |
|
---|
3101 | /**
|
---|
3102 | * Default C/C++ trap handler.
|
---|
3103 | *
|
---|
3104 | * This will check trap record and panic if no match was found.
|
---|
3105 | *
|
---|
3106 | * @param pTrapFrame Trap frame of the trap to handle.
|
---|
3107 | */
|
---|
3108 | BS3_CMN_PROTO_STUB(void, Bs3TrapDefaultHandler,(PBS3TRAPFRAME pTrapFrame));
|
---|
3109 |
|
---|
3110 | /**
|
---|
3111 | * Prints the trap frame (to screen).
|
---|
3112 | * @param pTrapFrame Trap frame to print.
|
---|
3113 | */
|
---|
3114 | BS3_CMN_PROTO_STUB(void, Bs3TrapPrintFrame,(PCBS3TRAPFRAME pTrapFrame));
|
---|
3115 |
|
---|
3116 | /**
|
---|
3117 | * Sets up a long jump from a trap handler.
|
---|
3118 | *
|
---|
3119 | * The long jump will only be performed onced, but will catch any kind of trap,
|
---|
3120 | * fault, interrupt or irq.
|
---|
3121 | *
|
---|
3122 | * @retval true on the initial call.
|
---|
3123 | * @retval false on trap return.
|
---|
3124 | * @param pTrapFrame Where to store the trap information when
|
---|
3125 | * returning @c false.
|
---|
3126 | * @sa #Bs3TrapUnsetJmp
|
---|
3127 | */
|
---|
3128 | BS3_CMN_PROTO_NOSB(DECL_RETURNS_TWICE(bool),Bs3TrapSetJmp,(PBS3TRAPFRAME pTrapFrame));
|
---|
3129 |
|
---|
3130 | /**
|
---|
3131 | * Combination of #Bs3TrapSetJmp and #Bs3RegCtxRestore.
|
---|
3132 | *
|
---|
3133 | * @param pCtxRestore The context to restore.
|
---|
3134 | * @param pTrapFrame Where to store the trap information.
|
---|
3135 | */
|
---|
3136 | BS3_CMN_PROTO_STUB(void, Bs3TrapSetJmpAndRestore,(PCBS3REGCTX pCtxRestore, PBS3TRAPFRAME pTrapFrame));
|
---|
3137 |
|
---|
3138 | /**
|
---|
3139 | * Disables a previous #Bs3TrapSetJmp call.
|
---|
3140 | */
|
---|
3141 | BS3_CMN_PROTO_STUB(void, Bs3TrapUnsetJmp,(void));
|
---|
3142 |
|
---|
3143 |
|
---|
3144 | /**
|
---|
3145 | * The current test step.
|
---|
3146 | */
|
---|
3147 | extern uint16_t g_usBs3TestStep;
|
---|
3148 |
|
---|
3149 | /**
|
---|
3150 | * Equivalent to RTTestCreate + RTTestBanner.
|
---|
3151 | *
|
---|
3152 | * @param pszTest The test name.
|
---|
3153 | */
|
---|
3154 | BS3_CMN_PROTO_STUB(void, Bs3TestInit,(const char BS3_FAR *pszTest));
|
---|
3155 |
|
---|
3156 |
|
---|
3157 | /**
|
---|
3158 | * Equivalent to RTTestSummaryAndDestroy.
|
---|
3159 | */
|
---|
3160 | BS3_CMN_PROTO_STUB(void, Bs3TestTerm,(void));
|
---|
3161 |
|
---|
3162 | /**
|
---|
3163 | * Equivalent to RTTestISub.
|
---|
3164 | */
|
---|
3165 | BS3_CMN_PROTO_STUB(void, Bs3TestSub,(const char BS3_FAR *pszSubTest));
|
---|
3166 |
|
---|
3167 | /**
|
---|
3168 | * Equivalent to RTTestIFailedF.
|
---|
3169 | */
|
---|
3170 | BS3_CMN_PROTO_STUB(void, Bs3TestSubF,(const char BS3_FAR *pszFormat, ...));
|
---|
3171 |
|
---|
3172 | /**
|
---|
3173 | * Equivalent to RTTestISubV.
|
---|
3174 | */
|
---|
3175 | BS3_CMN_PROTO_STUB(void, Bs3TestSubV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
3176 |
|
---|
3177 | /**
|
---|
3178 | * Equivalent to RTTestISubDone.
|
---|
3179 | */
|
---|
3180 | BS3_CMN_PROTO_STUB(void, Bs3TestSubDone,(void));
|
---|
3181 |
|
---|
3182 | /**
|
---|
3183 | * Equivalent to RTTestSubErrorCount.
|
---|
3184 | */
|
---|
3185 | BS3_CMN_PROTO_STUB(uint16_t, Bs3TestSubErrorCount,(void));
|
---|
3186 |
|
---|
3187 | /**
|
---|
3188 | * Equivalent to RTTestIPrintf with RTTESTLVL_ALWAYS.
|
---|
3189 | *
|
---|
3190 | * @param pszFormat What to print, format string. Explicit newline char.
|
---|
3191 | * @param ... String format arguments.
|
---|
3192 | */
|
---|
3193 | BS3_CMN_PROTO_STUB(void, Bs3TestPrintf,(const char BS3_FAR *pszFormat, ...));
|
---|
3194 |
|
---|
3195 | /**
|
---|
3196 | * Equivalent to RTTestIPrintfV with RTTESTLVL_ALWAYS.
|
---|
3197 | *
|
---|
3198 | * @param pszFormat What to print, format string. Explicit newline char.
|
---|
3199 | * @param va String format arguments.
|
---|
3200 | */
|
---|
3201 | BS3_CMN_PROTO_STUB(void, Bs3TestPrintfV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
3202 |
|
---|
3203 | /**
|
---|
3204 | * Same as Bs3TestPrintf, except no guest screen echo.
|
---|
3205 | *
|
---|
3206 | * @param pszFormat What to print, format string. Explicit newline char.
|
---|
3207 | * @param ... String format arguments.
|
---|
3208 | */
|
---|
3209 | BS3_CMN_PROTO_STUB(void, Bs3TestHostPrintf,(const char BS3_FAR *pszFormat, ...));
|
---|
3210 |
|
---|
3211 | /**
|
---|
3212 | * Same as Bs3TestPrintfV, except no guest screen echo.
|
---|
3213 | *
|
---|
3214 | * @param pszFormat What to print, format string. Explicit newline char.
|
---|
3215 | * @param va String format arguments.
|
---|
3216 | */
|
---|
3217 | BS3_CMN_PROTO_STUB(void, Bs3TestHostPrintfV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
3218 |
|
---|
3219 | /**
|
---|
3220 | * Equivalent to RTTestIFailed.
|
---|
3221 | * @returns false.
|
---|
3222 | */
|
---|
3223 | BS3_CMN_PROTO_STUB(bool, Bs3TestFailed,(const char BS3_FAR *pszMessage));
|
---|
3224 |
|
---|
3225 | /**
|
---|
3226 | * Equivalent to RTTestIFailedF.
|
---|
3227 | * @returns false.
|
---|
3228 | */
|
---|
3229 | BS3_CMN_PROTO_STUB(bool, Bs3TestFailedF,(const char BS3_FAR *pszFormat, ...));
|
---|
3230 |
|
---|
3231 | /**
|
---|
3232 | * Equivalent to RTTestIFailedV.
|
---|
3233 | * @returns false.
|
---|
3234 | */
|
---|
3235 | BS3_CMN_PROTO_STUB(bool, Bs3TestFailedV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
3236 |
|
---|
3237 | /**
|
---|
3238 | * Equivalent to RTTestISkipped.
|
---|
3239 | *
|
---|
3240 | * @param pszWhy Optional reason why it's being skipped.
|
---|
3241 | */
|
---|
3242 | BS3_CMN_PROTO_STUB(void, Bs3TestSkipped,(const char BS3_FAR *pszWhy));
|
---|
3243 |
|
---|
3244 | /**
|
---|
3245 | * Equivalent to RTTestISkippedF.
|
---|
3246 | *
|
---|
3247 | * @param pszFormat Optional reason why it's being skipped.
|
---|
3248 | * @param ... Format arguments.
|
---|
3249 | */
|
---|
3250 | BS3_CMN_PROTO_STUB(void, Bs3TestSkippedF,(const char BS3_FAR *pszFormat, ...));
|
---|
3251 |
|
---|
3252 | /**
|
---|
3253 | * Equivalent to RTTestISkippedV.
|
---|
3254 | *
|
---|
3255 | * @param pszFormat Optional reason why it's being skipped.
|
---|
3256 | * @param va Format arguments.
|
---|
3257 | */
|
---|
3258 | BS3_CMN_PROTO_STUB(void, Bs3TestSkippedV,(const char BS3_FAR *pszFormat, va_list BS3_FAR va));
|
---|
3259 |
|
---|
3260 | /**
|
---|
3261 | * Compares two register contexts, with PC and SP adjustments.
|
---|
3262 | *
|
---|
3263 | * Differences will be reported as test failures.
|
---|
3264 | *
|
---|
3265 | * @returns true if equal, false if not.
|
---|
3266 | * @param pActualCtx The actual register context.
|
---|
3267 | * @param pExpectedCtx Expected register context.
|
---|
3268 | * @param cbPcAdjust Program counter adjustment (applied to @a pExpectedCtx).
|
---|
3269 | * @param cbSpAdjust Stack pointer adjustment (applied to @a pExpectedCtx).
|
---|
3270 | * @param fExtraEfl Extra EFLAGS to OR into @a pExepctedCtx.
|
---|
3271 | * @param pszMode CPU mode or some other helpful text.
|
---|
3272 | * @param idTestStep Test step identifier.
|
---|
3273 | */
|
---|
3274 | BS3_CMN_PROTO_STUB(bool, Bs3TestCheckRegCtxEx,(PCBS3REGCTX pActualCtx, PCBS3REGCTX pExpectedCtx, uint16_t cbPcAdjust,
|
---|
3275 | int16_t cbSpAdjust, uint32_t fExtraEfl, const char *pszMode, uint16_t idTestStep));
|
---|
3276 |
|
---|
3277 | /**
|
---|
3278 | * Performs the testing for the given mode.
|
---|
3279 | *
|
---|
3280 | * This is called with the CPU already switch to that mode.
|
---|
3281 | *
|
---|
3282 | * @returns 0 on success or directly Bs3TestFailed calls, non-zero to indicate
|
---|
3283 | * where the test when wrong. Special value BS3TESTDOMODE_SKIPPED
|
---|
3284 | * should be returned to indicate that the test has been skipped.
|
---|
3285 | * @param bMode The current CPU mode.
|
---|
3286 | */
|
---|
3287 | typedef BS3_DECL_CALLBACK(uint8_t) FNBS3TESTDOMODE(uint8_t bMode);
|
---|
3288 | /** Pointer (far) to a test (for 32-bit and 64-bit code, will be flatten). */
|
---|
3289 | typedef FNBS3TESTDOMODE *PFNBS3TESTDOMODE;
|
---|
3290 |
|
---|
3291 | /** Special FNBS3TESTDOMODE return code for indicating a skipped mode test. */
|
---|
3292 | #define BS3TESTDOMODE_SKIPPED UINT8_MAX
|
---|
3293 |
|
---|
3294 | /**
|
---|
3295 | * Mode sub-test entry.
|
---|
3296 | *
|
---|
3297 | * This can only be passed around to functions with the same bit count, as it
|
---|
3298 | * contains function pointers. In 16-bit mode, the 16-bit pointers are near and
|
---|
3299 | * implies BS3TEXT16, whereas the 32-bit and 64-bit pointers are far real mode
|
---|
3300 | * addresses that will be converted to flat address prior to calling them.
|
---|
3301 | * Similarly, in 32-bit and 64-bit the addresses are all flat and the 16-bit
|
---|
3302 | * ones will be converted to BS3TEXT16 based addresses prior to calling.
|
---|
3303 | */
|
---|
3304 | typedef struct BS3TESTMODEENTRY
|
---|
3305 | {
|
---|
3306 | /** The sub-test name to be passed to Bs3TestSub if not NULL. */
|
---|
3307 | const char * BS3_FAR pszSubTest;
|
---|
3308 |
|
---|
3309 | PFNBS3TESTDOMODE pfnDoRM;
|
---|
3310 |
|
---|
3311 | PFNBS3TESTDOMODE pfnDoPE16;
|
---|
3312 | PFNBS3TESTDOMODE pfnDoPE16_32;
|
---|
3313 | PFNBS3TESTDOMODE pfnDoPE16_V86;
|
---|
3314 | PFNBS3TESTDOMODE pfnDoPE32;
|
---|
3315 | PFNBS3TESTDOMODE pfnDoPE32_16;
|
---|
3316 | PFNBS3TESTDOMODE pfnDoPEV86;
|
---|
3317 |
|
---|
3318 | PFNBS3TESTDOMODE pfnDoPP16;
|
---|
3319 | PFNBS3TESTDOMODE pfnDoPP16_32;
|
---|
3320 | PFNBS3TESTDOMODE pfnDoPP16_V86;
|
---|
3321 | PFNBS3TESTDOMODE pfnDoPP32;
|
---|
3322 | PFNBS3TESTDOMODE pfnDoPP32_16;
|
---|
3323 | PFNBS3TESTDOMODE pfnDoPPV86;
|
---|
3324 |
|
---|
3325 | PFNBS3TESTDOMODE pfnDoPAE16;
|
---|
3326 | PFNBS3TESTDOMODE pfnDoPAE16_32;
|
---|
3327 | PFNBS3TESTDOMODE pfnDoPAE16_V86;
|
---|
3328 | PFNBS3TESTDOMODE pfnDoPAE32;
|
---|
3329 | PFNBS3TESTDOMODE pfnDoPAE32_16;
|
---|
3330 | PFNBS3TESTDOMODE pfnDoPAEV86;
|
---|
3331 |
|
---|
3332 | PFNBS3TESTDOMODE pfnDoLM16;
|
---|
3333 | PFNBS3TESTDOMODE pfnDoLM32;
|
---|
3334 | PFNBS3TESTDOMODE pfnDoLM64;
|
---|
3335 |
|
---|
3336 | } BS3TESTMODEENTRY;
|
---|
3337 | /** Pointer to a mode sub-test entry. */
|
---|
3338 | typedef BS3TESTMODEENTRY const *PCBS3TESTMODEENTRY;
|
---|
3339 |
|
---|
3340 | /** @def BS3TESTMODEENTRY_CMN
|
---|
3341 | * Produces a BS3TESTMODEENTRY initializer for common (c16,c32,c64) test
|
---|
3342 | * functions. */
|
---|
3343 | #define BS3TESTMODEENTRY_CMN(a_szTest, a_BaseNm) \
|
---|
3344 | { /*pszSubTest =*/ a_szTest, \
|
---|
3345 | /*RM*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3346 | /*PE16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3347 | /*PE16_32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3348 | /*PE16_V86*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3349 | /*PE32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3350 | /*PE32_16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3351 | /*PEV86*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3352 | /*PP16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3353 | /*PP16_32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3354 | /*PP16_V86*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3355 | /*PP32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3356 | /*PP32_16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3357 | /*PPV86*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3358 | /*PAE16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3359 | /*PAE16_32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3360 | /*PAE16_V86*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3361 | /*PAE32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3362 | /*PAE32_16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3363 | /*PAEV86*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3364 | /*LM16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3365 | /*LM32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3366 | /*LM64*/ RT_CONCAT(a_BaseNm, _c64), \
|
---|
3367 | }
|
---|
3368 |
|
---|
3369 | /** @def BS3TESTMODE_PROTOTYPES_CMN
|
---|
3370 | * A set of standard protypes to go with #BS3TESTMODEENTRY_CMN. */
|
---|
3371 | #define BS3TESTMODE_PROTOTYPES_CMN(a_BaseNm) \
|
---|
3372 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c16); \
|
---|
3373 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c32); \
|
---|
3374 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c64)
|
---|
3375 |
|
---|
3376 | /** @def BS3TESTMODEENTRY_CMN_64
|
---|
3377 | * Produces a BS3TESTMODEENTRY initializer for common 64-bit test functions. */
|
---|
3378 | #define BS3TESTMODEENTRY_CMN_64(a_szTest, a_BaseNm) \
|
---|
3379 | { /*pszSubTest =*/ a_szTest, \
|
---|
3380 | /*RM*/ NULL, \
|
---|
3381 | /*PE16*/ NULL, \
|
---|
3382 | /*PE16_32*/ NULL, \
|
---|
3383 | /*PE16_V86*/ NULL, \
|
---|
3384 | /*PE32*/ NULL, \
|
---|
3385 | /*PE32_16*/ NULL, \
|
---|
3386 | /*PEV86*/ NULL, \
|
---|
3387 | /*PP16*/ NULL, \
|
---|
3388 | /*PP16_32*/ NULL, \
|
---|
3389 | /*PP16_V86*/ NULL, \
|
---|
3390 | /*PP32*/ NULL, \
|
---|
3391 | /*PP32_16*/ NULL, \
|
---|
3392 | /*PPV86*/ NULL, \
|
---|
3393 | /*PAE16*/ NULL, \
|
---|
3394 | /*PAE16_32*/ NULL, \
|
---|
3395 | /*PAE16_V86*/ NULL, \
|
---|
3396 | /*PAE32*/ NULL, \
|
---|
3397 | /*PAE32_16*/ NULL, \
|
---|
3398 | /*PAEV86*/ NULL, \
|
---|
3399 | /*LM16*/ NULL, \
|
---|
3400 | /*LM32*/ NULL, \
|
---|
3401 | /*LM64*/ RT_CONCAT(a_BaseNm, _c64), \
|
---|
3402 | }
|
---|
3403 |
|
---|
3404 | /** @def BS3TESTMODE_PROTOTYPES_CMN
|
---|
3405 | * Standard protype to go with #BS3TESTMODEENTRY_CMN_64. */
|
---|
3406 | #define BS3TESTMODE_PROTOTYPES_CMN_64(a_BaseNm) \
|
---|
3407 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c64)
|
---|
3408 |
|
---|
3409 | /** @def BS3TESTMODEENTRY_MODE
|
---|
3410 | * Produces a BS3TESTMODEENTRY initializer for a full set of mode test
|
---|
3411 | * functions. */
|
---|
3412 | #define BS3TESTMODEENTRY_MODE(a_szTest, a_BaseNm) \
|
---|
3413 | { /*pszSubTest =*/ a_szTest, \
|
---|
3414 | /*RM*/ RT_CONCAT(a_BaseNm, _rm), \
|
---|
3415 | /*PE16*/ RT_CONCAT(a_BaseNm, _pe16), \
|
---|
3416 | /*PE16_32*/ RT_CONCAT(a_BaseNm, _pe16_32), \
|
---|
3417 | /*PE16_V86*/ RT_CONCAT(a_BaseNm, _pe16_v86), \
|
---|
3418 | /*PE32*/ RT_CONCAT(a_BaseNm, _pe32), \
|
---|
3419 | /*PE32_16*/ RT_CONCAT(a_BaseNm, _pe32_16), \
|
---|
3420 | /*PEV86*/ RT_CONCAT(a_BaseNm, _pev86), \
|
---|
3421 | /*PP16*/ RT_CONCAT(a_BaseNm, _pp16), \
|
---|
3422 | /*PP16_32*/ RT_CONCAT(a_BaseNm, _pp16_32), \
|
---|
3423 | /*PP16_V86*/ RT_CONCAT(a_BaseNm, _pp16_v86), \
|
---|
3424 | /*PP32*/ RT_CONCAT(a_BaseNm, _pp32), \
|
---|
3425 | /*PP32_16*/ RT_CONCAT(a_BaseNm, _pp32_16), \
|
---|
3426 | /*PPV86*/ RT_CONCAT(a_BaseNm, _ppv86), \
|
---|
3427 | /*PAE16*/ RT_CONCAT(a_BaseNm, _pae16), \
|
---|
3428 | /*PAE16_32*/ RT_CONCAT(a_BaseNm, _pae16_32), \
|
---|
3429 | /*PAE16_V86*/ RT_CONCAT(a_BaseNm, _pae16_v86), \
|
---|
3430 | /*PAE32*/ RT_CONCAT(a_BaseNm, _pae32), \
|
---|
3431 | /*PAE32_16*/ RT_CONCAT(a_BaseNm, _pae32_16), \
|
---|
3432 | /*PAEV86*/ RT_CONCAT(a_BaseNm, _paev86), \
|
---|
3433 | /*LM16*/ RT_CONCAT(a_BaseNm, _lm16), \
|
---|
3434 | /*LM32*/ RT_CONCAT(a_BaseNm, _lm32), \
|
---|
3435 | /*LM64*/ RT_CONCAT(a_BaseNm, _lm64), \
|
---|
3436 | }
|
---|
3437 |
|
---|
3438 | /** @def BS3TESTMODE_PROTOTYPES_MODE
|
---|
3439 | * A set of standard protypes to go with #BS3TESTMODEENTRY_MODE. */
|
---|
3440 | #define BS3TESTMODE_PROTOTYPES_MODE(a_BaseNm) \
|
---|
3441 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _rm); \
|
---|
3442 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe16); \
|
---|
3443 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe16_32); \
|
---|
3444 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe16_v86); \
|
---|
3445 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe32); \
|
---|
3446 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe32_16); \
|
---|
3447 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pev86); \
|
---|
3448 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp16); \
|
---|
3449 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp16_32); \
|
---|
3450 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp16_v86); \
|
---|
3451 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp32); \
|
---|
3452 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp32_16); \
|
---|
3453 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _ppv86); \
|
---|
3454 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae16); \
|
---|
3455 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae16_32); \
|
---|
3456 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae16_v86); \
|
---|
3457 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae32); \
|
---|
3458 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae32_16); \
|
---|
3459 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _paev86); \
|
---|
3460 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _lm16); \
|
---|
3461 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _lm32); \
|
---|
3462 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _lm64)
|
---|
3463 |
|
---|
3464 |
|
---|
3465 | /**
|
---|
3466 | * Mode sub-test entry, max bit-count driven
|
---|
3467 | *
|
---|
3468 | * This is an alternative to BS3TESTMODEENTRY where a few workers (test drivers)
|
---|
3469 | * does all the work, using faster 32-bit and 64-bit code where possible. This
|
---|
3470 | * avoids executing workers in V8086 mode. It allows for modifying and checking
|
---|
3471 | * 64-bit register content when testing LM16 and LM32.
|
---|
3472 | *
|
---|
3473 | * The 16-bit workers are only used for real mode and 16-bit protected mode.
|
---|
3474 | * So, the 16-bit version of the code template can be stripped of anything
|
---|
3475 | * related to paging and/or v8086, saving code space.
|
---|
3476 | */
|
---|
3477 | typedef struct BS3TESTMODEBYMAXENTRY
|
---|
3478 | {
|
---|
3479 | /** The sub-test name to be passed to Bs3TestSub if not NULL. */
|
---|
3480 | const char * BS3_FAR pszSubTest;
|
---|
3481 |
|
---|
3482 | PFNBS3TESTDOMODE pfnDoRM;
|
---|
3483 | PFNBS3TESTDOMODE pfnDoPE16;
|
---|
3484 | PFNBS3TESTDOMODE pfnDoPE16_32;
|
---|
3485 | PFNBS3TESTDOMODE pfnDoPE32;
|
---|
3486 | PFNBS3TESTDOMODE pfnDoPP16_32;
|
---|
3487 | PFNBS3TESTDOMODE pfnDoPP32;
|
---|
3488 | PFNBS3TESTDOMODE pfnDoPAE16_32;
|
---|
3489 | PFNBS3TESTDOMODE pfnDoPAE32;
|
---|
3490 | PFNBS3TESTDOMODE pfnDoLM64;
|
---|
3491 |
|
---|
3492 | bool fDoRM : 1;
|
---|
3493 |
|
---|
3494 | bool fDoPE16 : 1;
|
---|
3495 | bool fDoPE16_32 : 1;
|
---|
3496 | bool fDoPE16_V86 : 1;
|
---|
3497 | bool fDoPE32 : 1;
|
---|
3498 | bool fDoPE32_16 : 1;
|
---|
3499 | bool fDoPEV86 : 1;
|
---|
3500 |
|
---|
3501 | bool fDoPP16 : 1;
|
---|
3502 | bool fDoPP16_32 : 1;
|
---|
3503 | bool fDoPP16_V86 : 1;
|
---|
3504 | bool fDoPP32 : 1;
|
---|
3505 | bool fDoPP32_16 : 1;
|
---|
3506 | bool fDoPPV86 : 1;
|
---|
3507 |
|
---|
3508 | bool fDoPAE16 : 1;
|
---|
3509 | bool fDoPAE16_32 : 1;
|
---|
3510 | bool fDoPAE16_V86 : 1;
|
---|
3511 | bool fDoPAE32 : 1;
|
---|
3512 | bool fDoPAE32_16 : 1;
|
---|
3513 | bool fDoPAEV86 : 1;
|
---|
3514 |
|
---|
3515 | bool fDoLM16 : 1;
|
---|
3516 | bool fDoLM32 : 1;
|
---|
3517 | bool fDoLM64 : 1;
|
---|
3518 |
|
---|
3519 | } BS3TESTMODEBYMAXENTRY;
|
---|
3520 | /** Pointer to a mode-by-max sub-test entry. */
|
---|
3521 | typedef BS3TESTMODEBYMAXENTRY const *PCBS3TESTMODEBYMAXENTRY;
|
---|
3522 |
|
---|
3523 | /** @def BS3TESTMODEBYMAXENTRY_CMN
|
---|
3524 | * Produces a BS3TESTMODEBYMAXENTRY initializer for common (c16,c32,c64) test
|
---|
3525 | * functions. */
|
---|
3526 | #define BS3TESTMODEBYMAXENTRY_CMN(a_szTest, a_BaseNm) \
|
---|
3527 | { /*pszSubTest =*/ a_szTest, \
|
---|
3528 | /*RM*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3529 | /*PE16*/ RT_CONCAT(a_BaseNm, _c16), \
|
---|
3530 | /*PE16_32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3531 | /*PE32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3532 | /*PP16_32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3533 | /*PP32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3534 | /*PAE16_32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3535 | /*PAE32*/ RT_CONCAT(a_BaseNm, _c32), \
|
---|
3536 | /*LM64*/ RT_CONCAT(a_BaseNm, _c64), \
|
---|
3537 | /*fDoRM*/ true, \
|
---|
3538 | /*fDoPE16*/ true, \
|
---|
3539 | /*fDoPE16_32*/ true, \
|
---|
3540 | /*fDoPE16_V86*/ true, \
|
---|
3541 | /*fDoPE32*/ true, \
|
---|
3542 | /*fDoPE32_16*/ true, \
|
---|
3543 | /*fDoPEV86*/ true, \
|
---|
3544 | /*fDoPP16*/ true, \
|
---|
3545 | /*fDoPP16_32*/ true, \
|
---|
3546 | /*fDoPP16_V86*/ true, \
|
---|
3547 | /*fDoPP32*/ true, \
|
---|
3548 | /*fDoPP32_16*/ true, \
|
---|
3549 | /*fDoPPV86*/ true, \
|
---|
3550 | /*fDoPAE16*/ true, \
|
---|
3551 | /*fDoPAE16_32*/ true, \
|
---|
3552 | /*fDoPAE16_V86*/ true, \
|
---|
3553 | /*fDoPAE32*/ true, \
|
---|
3554 | /*fDoPAE32_16*/ true, \
|
---|
3555 | /*fDoPAEV86*/ true, \
|
---|
3556 | /*fDoLM16*/ true, \
|
---|
3557 | /*fDoLM32*/ true, \
|
---|
3558 | /*fDoLM64*/ true, \
|
---|
3559 | }
|
---|
3560 |
|
---|
3561 | /** @def BS3TESTMODEBYMAX_PROTOTYPES_CMN
|
---|
3562 | * A set of standard protypes to go with #BS3TESTMODEBYMAXENTRY_CMN. */
|
---|
3563 | #define BS3TESTMODEBYMAX_PROTOTYPES_CMN(a_BaseNm) \
|
---|
3564 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c16); \
|
---|
3565 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c32); \
|
---|
3566 | FNBS3TESTDOMODE /*BS3_FAR_CODE*/ RT_CONCAT(a_BaseNm, _c64)
|
---|
3567 |
|
---|
3568 |
|
---|
3569 | /** @def BS3TESTMODEBYMAXENTRY_MODE
|
---|
3570 | * Produces a BS3TESTMODEBYMAXENTRY initializer for a full set of mode test
|
---|
3571 | * functions. */
|
---|
3572 | #define BS3TESTMODEBYMAXENTRY_MODE(a_szTest, a_BaseNm) \
|
---|
3573 | { /*pszSubTest =*/ a_szTest, \
|
---|
3574 | /*RM*/ RT_CONCAT(a_BaseNm, _rm), \
|
---|
3575 | /*PE16*/ RT_CONCAT(a_BaseNm, _pe16), \
|
---|
3576 | /*PE16_32*/ RT_CONCAT(a_BaseNm, _pe16_32), \
|
---|
3577 | /*PE32*/ RT_CONCAT(a_BaseNm, _pe32), \
|
---|
3578 | /*PP16_32*/ RT_CONCAT(a_BaseNm, _pp16_32), \
|
---|
3579 | /*PP32*/ RT_CONCAT(a_BaseNm, _pp32), \
|
---|
3580 | /*PAE16_32*/ RT_CONCAT(a_BaseNm, _pae16_32), \
|
---|
3581 | /*PAE32*/ RT_CONCAT(a_BaseNm, _pae32), \
|
---|
3582 | /*LM64*/ RT_CONCAT(a_BaseNm, _lm64), \
|
---|
3583 | /*fDoRM*/ true, \
|
---|
3584 | /*fDoPE16*/ true, \
|
---|
3585 | /*fDoPE16_32*/ true, \
|
---|
3586 | /*fDoPE16_V86*/ true, \
|
---|
3587 | /*fDoPE32*/ true, \
|
---|
3588 | /*fDoPE32_16*/ true, \
|
---|
3589 | /*fDoPEV86*/ true, \
|
---|
3590 | /*fDoPP16*/ true, \
|
---|
3591 | /*fDoPP16_32*/ true, \
|
---|
3592 | /*fDoPP16_V86*/ true, \
|
---|
3593 | /*fDoPP32*/ true, \
|
---|
3594 | /*fDoPP32_16*/ true, \
|
---|
3595 | /*fDoPPV86*/ true, \
|
---|
3596 | /*fDoPAE16*/ true, \
|
---|
3597 | /*fDoPAE16_32*/ true, \
|
---|
3598 | /*fDoPAE16_V86*/ true, \
|
---|
3599 | /*fDoPAE32*/ true, \
|
---|
3600 | /*fDoPAE32_16*/ true, \
|
---|
3601 | /*fDoPAEV86*/ true, \
|
---|
3602 | /*fDoLM16*/ true, \
|
---|
3603 | /*fDoLM32*/ true, \
|
---|
3604 | /*fDoLM64*/ true, \
|
---|
3605 | }
|
---|
3606 |
|
---|
3607 | /** @def BS3TESTMODEBYMAX_PROTOTYPES_MODE
|
---|
3608 | * A set of standard protypes to go with #BS3TESTMODEBYMAXENTRY_MODE. */
|
---|
3609 | #define BS3TESTMODEBYMAX_PROTOTYPES_MODE(a_BaseNm) \
|
---|
3610 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _rm); \
|
---|
3611 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe16); \
|
---|
3612 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe16_32); \
|
---|
3613 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pe32); \
|
---|
3614 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp16_32); \
|
---|
3615 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pp32); \
|
---|
3616 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae16_32); \
|
---|
3617 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _pae32); \
|
---|
3618 | FNBS3TESTDOMODE RT_CONCAT(a_BaseNm, _lm64)
|
---|
3619 |
|
---|
3620 |
|
---|
3621 | /**
|
---|
3622 | * One worker drives all modes.
|
---|
3623 | *
|
---|
3624 | * This is an alternative to BS3TESTMODEENTRY where one worker, typically
|
---|
3625 | * 16-bit, does all the test driver work. It's called repeatedly from all
|
---|
3626 | * the modes being tested.
|
---|
3627 | */
|
---|
3628 | typedef struct BS3TESTMODEBYONEENTRY
|
---|
3629 | {
|
---|
3630 | const char * BS3_FAR pszSubTest;
|
---|
3631 | PFNBS3TESTDOMODE pfnWorker;
|
---|
3632 | /** BS3TESTMODEBYONEENTRY_F_XXX. */
|
---|
3633 | uint32_t fFlags;
|
---|
3634 | } BS3TESTMODEBYONEENTRY;
|
---|
3635 | /** Pointer to a mode-by-one sub-test entry. */
|
---|
3636 | typedef BS3TESTMODEBYONEENTRY const *PCBS3TESTMODEBYONEENTRY;
|
---|
3637 |
|
---|
3638 | /** @name BS3TESTMODEBYONEENTRY_F_XXX - flags.
|
---|
3639 | * @{ */
|
---|
3640 | /** Only test modes that has paging enabled. */
|
---|
3641 | #define BS3TESTMODEBYONEENTRY_F_ONLY_PAGING RT_BIT_32(0)
|
---|
3642 | /** @} */
|
---|
3643 |
|
---|
3644 |
|
---|
3645 | /**
|
---|
3646 | * Sets the full GDTR register.
|
---|
3647 | *
|
---|
3648 | * @param cbLimit The limit.
|
---|
3649 | * @param uBase The base address - 24, 32 or 64 bit depending on the
|
---|
3650 | * CPU mode.
|
---|
3651 | */
|
---|
3652 | BS3_CMN_PROTO_NOSB(void, Bs3UtilSetFullGdtr,(uint16_t cbLimit, uint64_t uBase));
|
---|
3653 |
|
---|
3654 | /**
|
---|
3655 | * Sets the full IDTR register.
|
---|
3656 | *
|
---|
3657 | * @param cbLimit The limit.
|
---|
3658 | * @param uBase The base address - 24, 32 or 64 bit depending on the
|
---|
3659 | * CPU mode.
|
---|
3660 | */
|
---|
3661 | BS3_CMN_PROTO_NOSB(void, Bs3UtilSetFullIdtr,(uint16_t cbLimit, uint64_t uBase));
|
---|
3662 |
|
---|
3663 |
|
---|
3664 | /** @} */
|
---|
3665 |
|
---|
3666 |
|
---|
3667 | /**
|
---|
3668 | * Initializes all of boot sector kit \#3.
|
---|
3669 | */
|
---|
3670 | BS3_DECL(void) Bs3InitAll_rm(void);
|
---|
3671 |
|
---|
3672 | /**
|
---|
3673 | * Initializes the REAL and TILED memory pools.
|
---|
3674 | *
|
---|
3675 | * For proper operation on OLDer CPUs, call #Bs3CpuDetect_mmm first.
|
---|
3676 | */
|
---|
3677 | BS3_DECL_FAR(void) Bs3InitMemory_rm_far(void);
|
---|
3678 |
|
---|
3679 | /**
|
---|
3680 | * Initialized the X0TEXT16 and X1TEXT16 GDT entries.
|
---|
3681 | */
|
---|
3682 | BS3_DECL_FAR(void) Bs3InitGdt_rm_far(void);
|
---|
3683 |
|
---|
3684 |
|
---|
3685 |
|
---|
3686 | /** @defgroup grp_bs3kit_mode Mode Specific Functions and Data
|
---|
3687 | *
|
---|
3688 | * The mode specific functions come in bit count variations and CPU mode
|
---|
3689 | * variations. The bs3kit-template-header.h/mac defines the BS3_NM macro to
|
---|
3690 | * mangle a function or variable name according to the target CPU mode. In
|
---|
3691 | * non-templated code, it's common to spell the name out in full.
|
---|
3692 | *
|
---|
3693 | * @{
|
---|
3694 | */
|
---|
3695 |
|
---|
3696 |
|
---|
3697 | /** @def BS3_MODE_PROTO_INT
|
---|
3698 | * Internal macro for emitting prototypes for mode functions.
|
---|
3699 | *
|
---|
3700 | * @param a_RetType The return type.
|
---|
3701 | * @param a_Name The function basename.
|
---|
3702 | * @param a_Params The parameter list (in parentheses).
|
---|
3703 | * @sa BS3_MODE_PROTO_STUB, BS3_MODE_PROTO_NOSB
|
---|
3704 | */
|
---|
3705 | #define BS3_MODE_PROTO_INT(a_RetType, a_Name, a_Params) \
|
---|
3706 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_rm) a_Params; \
|
---|
3707 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pe16) a_Params; \
|
---|
3708 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pe16_32) a_Params; \
|
---|
3709 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pe16_v86) a_Params; \
|
---|
3710 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pe32) a_Params; \
|
---|
3711 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pe32_16) a_Params; \
|
---|
3712 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pev86) a_Params; \
|
---|
3713 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pp16) a_Params; \
|
---|
3714 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pp16_32) a_Params; \
|
---|
3715 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pp16_v86) a_Params; \
|
---|
3716 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pp32) a_Params; \
|
---|
3717 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pp32_16) a_Params; \
|
---|
3718 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_ppv86) a_Params; \
|
---|
3719 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pae16) a_Params; \
|
---|
3720 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pae16_32) a_Params; \
|
---|
3721 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pae16_v86) a_Params; \
|
---|
3722 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pae32) a_Params; \
|
---|
3723 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_pae32_16) a_Params; \
|
---|
3724 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_paev86) a_Params; \
|
---|
3725 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_lm16) a_Params; \
|
---|
3726 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_lm32) a_Params; \
|
---|
3727 | BS3_DECL_NEAR(a_RetType) RT_CONCAT(a_Name,_lm64) a_Params; \
|
---|
3728 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_rm_far) a_Params; \
|
---|
3729 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pe16_far) a_Params; \
|
---|
3730 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pe16_v86_far) a_Params; \
|
---|
3731 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pe32_16_far) a_Params; \
|
---|
3732 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pev86_far) a_Params; \
|
---|
3733 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pp16_far) a_Params; \
|
---|
3734 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pp16_v86_far) a_Params; \
|
---|
3735 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pp32_16_far) a_Params; \
|
---|
3736 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_ppv86_far) a_Params; \
|
---|
3737 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pae16_far) a_Params; \
|
---|
3738 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pae16_v86_far)a_Params; \
|
---|
3739 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_pae32_16_far) a_Params; \
|
---|
3740 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_paev86_far) a_Params; \
|
---|
3741 | BS3_DECL_FAR(a_RetType) RT_CONCAT(a_Name,_lm16_far) a_Params
|
---|
3742 |
|
---|
3743 | /** @def BS3_MODE_PROTO_STUB
|
---|
3744 | * Macro for prototyping all the variations of a mod function with automatic
|
---|
3745 | * near -> far stub.
|
---|
3746 | *
|
---|
3747 | * @param a_RetType The return type.
|
---|
3748 | * @param a_Name The function basename.
|
---|
3749 | * @param a_Params The parameter list (in parentheses).
|
---|
3750 | * @sa BS3_MODE_PROTO_STUB, BS3_MODE_PROTO_NOSB
|
---|
3751 | */
|
---|
3752 | #define BS3_MODE_PROTO_STUB(a_RetType, a_Name, a_Params) BS3_MODE_PROTO_INT(a_RetType, a_Name, a_Params)
|
---|
3753 |
|
---|
3754 | /** @def BS3_MODE_PROTO_STUB
|
---|
3755 | * Macro for prototyping all the variations of a mod function without any
|
---|
3756 | * near -> far stub.
|
---|
3757 | *
|
---|
3758 | * @param a_RetType The return type.
|
---|
3759 | * @param a_Name The function basename.
|
---|
3760 | * @param a_Params The parameter list (in parentheses).
|
---|
3761 | * @sa BS3_MODE_PROTO_STUB, BS3_MODE_PROTO_NOSB
|
---|
3762 | */
|
---|
3763 | #define BS3_MODE_PROTO_NOSB(a_RetType, a_Name, a_Params) BS3_MODE_PROTO_INT(a_RetType, a_Name, a_Params)
|
---|
3764 |
|
---|
3765 |
|
---|
3766 | /**
|
---|
3767 | * Macro for reducing typing.
|
---|
3768 | *
|
---|
3769 | * Doxygen knows how to expand this, well, kind of.
|
---|
3770 | *
|
---|
3771 | * @remarks Variables instantiated in assembly code should define two labels,
|
---|
3772 | * with and without leading underscore. Variables instantiated from
|
---|
3773 | * C/C++ code doesn't need to as the object file convert does this for
|
---|
3774 | * 64-bit object files.
|
---|
3775 | */
|
---|
3776 | #define BS3_MODE_EXPAND_EXTERN_DATA16(a_VarType, a_VarName, a_Suffix) \
|
---|
3777 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_rm) a_Suffix; \
|
---|
3778 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pe16) a_Suffix; \
|
---|
3779 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pe16_32) a_Suffix; \
|
---|
3780 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pe16_v86) a_Suffix; \
|
---|
3781 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pe32) a_Suffix; \
|
---|
3782 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pe32_16) a_Suffix; \
|
---|
3783 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pev86) a_Suffix; \
|
---|
3784 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pp16) a_Suffix; \
|
---|
3785 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pp16_32) a_Suffix; \
|
---|
3786 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pp16_v86) a_Suffix; \
|
---|
3787 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pp32) a_Suffix; \
|
---|
3788 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pp32_16) a_Suffix; \
|
---|
3789 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_ppv86) a_Suffix; \
|
---|
3790 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pae16) a_Suffix; \
|
---|
3791 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pae16_32) a_Suffix; \
|
---|
3792 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pae16_v86)a_Suffix; \
|
---|
3793 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pae32) a_Suffix; \
|
---|
3794 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_pae32_16) a_Suffix; \
|
---|
3795 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_paev86) a_Suffix; \
|
---|
3796 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_lm16) a_Suffix; \
|
---|
3797 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_lm32) a_Suffix; \
|
---|
3798 | extern a_VarType BS3_FAR_DATA RT_CONCAT(a_VarName,_lm64) a_Suffix
|
---|
3799 |
|
---|
3800 |
|
---|
3801 | /** The TMPL_MODE_STR value for each mode.
|
---|
3802 | * These are all in DATA16 so they can be accessed from any code. */
|
---|
3803 | BS3_MODE_EXPAND_EXTERN_DATA16(const char, g_szBs3ModeName, []);
|
---|
3804 | /** The TMPL_MODE_LNAME value for each mode.
|
---|
3805 | * These are all in DATA16 so they can be accessed from any code. */
|
---|
3806 | BS3_MODE_EXPAND_EXTERN_DATA16(const char, g_szBs3ModeNameShortLower, []);
|
---|
3807 |
|
---|
3808 |
|
---|
3809 | /**
|
---|
3810 | * Basic CPU detection.
|
---|
3811 | *
|
---|
3812 | * This sets the #g_uBs3CpuDetected global variable to the return value.
|
---|
3813 | *
|
---|
3814 | * @returns BS3CPU_XXX value with the BS3CPU_F_CPUID flag set depending on
|
---|
3815 | * capabilities.
|
---|
3816 | */
|
---|
3817 | BS3_MODE_PROTO_NOSB(uint8_t, Bs3CpuDetect,(void));
|
---|
3818 |
|
---|
3819 | /** @name BS3CPU_XXX - CPU detected by BS3CpuDetect_c16() and friends.
|
---|
3820 | * @{ */
|
---|
3821 | #define BS3CPU_8086 UINT16_C(0x0001) /**< Both 8086 and 8088. */
|
---|
3822 | #define BS3CPU_V20 UINT16_C(0x0002) /**< Both NEC V20, V30 and relatives. */
|
---|
3823 | #define BS3CPU_80186 UINT16_C(0x0003) /**< Both 80186 and 80188. */
|
---|
3824 | #define BS3CPU_80286 UINT16_C(0x0004)
|
---|
3825 | #define BS3CPU_80386 UINT16_C(0x0005)
|
---|
3826 | #define BS3CPU_80486 UINT16_C(0x0006)
|
---|
3827 | #define BS3CPU_Pentium UINT16_C(0x0007)
|
---|
3828 | #define BS3CPU_PPro UINT16_C(0x0008)
|
---|
3829 | #define BS3CPU_PProOrNewer UINT16_C(0x0009)
|
---|
3830 | /** CPU type mask. This is a full byte so it's possible to use byte access
|
---|
3831 | * without and AND'ing to get the type value. */
|
---|
3832 | #define BS3CPU_TYPE_MASK UINT16_C(0x00ff)
|
---|
3833 | /** Flag indicating that the CPUID instruction is supported by the CPU. */
|
---|
3834 | #define BS3CPU_F_CPUID UINT16_C(0x0100)
|
---|
3835 | /** Flag indicating that extend CPUID leaves are available (at least two). */
|
---|
3836 | #define BS3CPU_F_CPUID_EXT_LEAVES UINT16_C(0x0200)
|
---|
3837 | /** Flag indicating that the CPU supports PAE. */
|
---|
3838 | #define BS3CPU_F_PAE UINT16_C(0x0400)
|
---|
3839 | /** Flag indicating that the CPU supports the page size extension (4MB pages). */
|
---|
3840 | #define BS3CPU_F_PSE UINT16_C(0x0800)
|
---|
3841 | /** Flag indicating that the CPU supports long mode. */
|
---|
3842 | #define BS3CPU_F_LONG_MODE UINT16_C(0x1000)
|
---|
3843 | /** Flag indicating that the CPU supports NX. */
|
---|
3844 | #define BS3CPU_F_NX UINT16_C(0x2000)
|
---|
3845 | /** @} */
|
---|
3846 |
|
---|
3847 | /** The return value of #Bs3CpuDetect_mmm. (Initial value is BS3CPU_TYPE_MASK.) */
|
---|
3848 | extern uint16_t g_uBs3CpuDetected;
|
---|
3849 |
|
---|
3850 | /**
|
---|
3851 | * Call 32-bit prot mode C function.
|
---|
3852 | *
|
---|
3853 | * This switches to 32-bit mode and calls the 32-bit @a fpfnCall C code with @a
|
---|
3854 | * cbParams on the stack, then returns in the original mode. When called in
|
---|
3855 | * real mode, this will switch to PE32.
|
---|
3856 | *
|
---|
3857 | * @returns 32-bit status code if the function returned anything.
|
---|
3858 | * @param fpfnCall Address of the 32-bit C function to call. When
|
---|
3859 | * called from 16-bit code, this is a far real mode
|
---|
3860 | * function pointer, i.e. as fixed up by the linker.
|
---|
3861 | * In 32-bit and 64-bit code, this is a flat address.
|
---|
3862 | * @param cbParams The size of the parameter list, in bytes.
|
---|
3863 | * @param ... The parameters.
|
---|
3864 | * @sa Bs3SwitchFromV86To16BitAndCallC
|
---|
3865 | *
|
---|
3866 | * @remarks WARNING! This probably doesn't work in 64-bit mode yet.
|
---|
3867 | * Only tested for 16-bit real mode.
|
---|
3868 | */
|
---|
3869 | BS3_MODE_PROTO_STUB(int32_t, Bs3SwitchTo32BitAndCallC,(FPFNBS3FAR fpfnCall, unsigned cbParams, ...));
|
---|
3870 |
|
---|
3871 | /**
|
---|
3872 | * Initializes trap handling for the current system.
|
---|
3873 | *
|
---|
3874 | * Calls the appropriate Bs3Trap16Init, Bs3Trap32Init or Bs3Trap64Init function.
|
---|
3875 | */
|
---|
3876 | BS3_MODE_PROTO_STUB(void, Bs3TrapInit,(void));
|
---|
3877 |
|
---|
3878 | /**
|
---|
3879 | * Executes the array of tests in every possibly mode.
|
---|
3880 | *
|
---|
3881 | * @param paEntries The mode sub-test entries.
|
---|
3882 | * @param cEntries The number of sub-test entries.
|
---|
3883 | */
|
---|
3884 | BS3_MODE_PROTO_NOSB(void, Bs3TestDoModes,(PCBS3TESTMODEENTRY paEntries, size_t cEntries));
|
---|
3885 |
|
---|
3886 | /**
|
---|
3887 | * Executes the array of tests in every possibly mode, unified driver.
|
---|
3888 | *
|
---|
3889 | * This requires much less code space than Bs3TestDoModes as there is only one
|
---|
3890 | * instace of each sub-test driver code, instead of 3 (cmn) or 22 (per-mode)
|
---|
3891 | * copies.
|
---|
3892 | *
|
---|
3893 | * @param paEntries The mode sub-test-by-one entries.
|
---|
3894 | * @param cEntries The number of sub-test-by-one entries.
|
---|
3895 | * @param fFlags Reserved for the future, MBZ.
|
---|
3896 | */
|
---|
3897 | BS3_MODE_PROTO_NOSB(void, Bs3TestDoModesByOne,(PCBS3TESTMODEBYONEENTRY paEntries, size_t cEntries, uint32_t fFlags));
|
---|
3898 |
|
---|
3899 | /**
|
---|
3900 | * Executes the array of tests in every possibly mode, using the max bit-count
|
---|
3901 | * worker for each.
|
---|
3902 | *
|
---|
3903 | * @param paEntries The mode sub-test entries.
|
---|
3904 | * @param cEntries The number of sub-test entries.
|
---|
3905 | */
|
---|
3906 | BS3_MODE_PROTO_NOSB(void, Bs3TestDoModesByMax,(PCBS3TESTMODEBYMAXENTRY paEntries, size_t cEntries));
|
---|
3907 |
|
---|
3908 |
|
---|
3909 | /** @} */
|
---|
3910 |
|
---|
3911 | /** @} */
|
---|
3912 |
|
---|
3913 | RT_C_DECLS_END
|
---|
3914 |
|
---|
3915 |
|
---|
3916 | /*
|
---|
3917 | * Include default function symbol mangling.
|
---|
3918 | */
|
---|
3919 | #include "bs3kit-mangling-code.h"
|
---|
3920 |
|
---|
3921 | /*
|
---|
3922 | * Change 16-bit text segment if requested.
|
---|
3923 | */
|
---|
3924 | #if defined(BS3_USE_ALT_16BIT_TEXT_SEG) && ARCH_BITS == 16 && !defined(BS3_DONT_CHANGE_TEXT_SEG)
|
---|
3925 | # if (defined(BS3_USE_RM_TEXT_SEG) + defined(BS3_USE_X0_TEXT_SEG) + defined(BS3_USE_X1_TEXT_SEG)) != 1
|
---|
3926 | # error "Cannot set more than one alternative 16-bit text segment!"
|
---|
3927 | # elif defined(BS3_USE_RM_TEXT_SEG)
|
---|
3928 | # pragma code_seg("BS3RMTEXT16", "BS3CLASS16RMCODE")
|
---|
3929 | # elif defined(BS3_USE_X0_TEXT_SEG)
|
---|
3930 | # pragma code_seg("BS3X0TEXT16", "BS3CLASS16X0CODE")
|
---|
3931 | # elif defined(BS3_USE_X1_TEXT_SEG)
|
---|
3932 | # pragma code_seg("BS3X1TEXT16", "BS3CLASS16X1CODE")
|
---|
3933 | # else
|
---|
3934 | # error "Huh? Which alternative text segment did you want again?"
|
---|
3935 | # endif
|
---|
3936 | #endif
|
---|
3937 |
|
---|
3938 | #endif
|
---|
3939 |
|
---|