1 | /* $Id: bs3kit.h 59879 2016-03-01 07:05:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - structures, symbols, macros and stuff.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2015 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 | # define IN_RING0
|
---|
32 | #endif
|
---|
33 | #include <iprt/cdefs.h>
|
---|
34 | #include <iprt/types.h>
|
---|
35 | #ifndef DOXYGEN_RUNNING
|
---|
36 | # undef IN_RING0
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | /*
|
---|
40 | * We may want to reuse some IPRT code in the common name space, so we
|
---|
41 | * redefine the RT_MANGLER to work like BS3_CMN_NM. (We cannot use
|
---|
42 | * BS3_CMN_NM yet, as we need to include IPRT headers with function
|
---|
43 | * declarations before we can define it. Thus the duplciate effort.)
|
---|
44 | */
|
---|
45 | #define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
|
---|
46 | #include <iprt/mangling.h>
|
---|
47 | #include <iprt/x86.h>
|
---|
48 | #include <iprt/err.h>
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 | RT_C_DECLS_BEGIN
|
---|
53 |
|
---|
54 | /** @defgroup grp_bs3kit BS3Kit
|
---|
55 | * @{ */
|
---|
56 |
|
---|
57 | /** @name Execution modes.
|
---|
58 | * @{ */
|
---|
59 | #define BS3_MODE_INVALID UINT8_C(0x00)
|
---|
60 | #define BS3_MODE_RM UINT8_C(0x01) /**< real mode. */
|
---|
61 | #define BS3_MODE_PE16 UINT8_C(0x11) /**< 16-bit protected mode kernel+tss, running 16-bit code, unpaged. */
|
---|
62 | #define BS3_MODE_PE16_32 UINT8_C(0x12) /**< 16-bit protected mode kernel+tss, running 32-bit code, unpaged. */
|
---|
63 | #define BS3_MODE_PE16_V86 UINT8_C(0x13) /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
|
---|
64 | #define BS3_MODE_PE32 UINT8_C(0x22) /**< 32-bit protected mode kernel+tss, running 32-bit code, unpaged. */
|
---|
65 | #define BS3_MODE_PE32_16 UINT8_C(0x21) /**< 32-bit protected mode kernel+tss, running 16-bit code, unpaged. */
|
---|
66 | #define BS3_MODE_PEV86 UINT8_C(0x23) /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
|
---|
67 | #define BS3_MODE_PP16 UINT8_C(0x31) /**< 16-bit protected mode kernel+tss, running 16-bit code, paged. */
|
---|
68 | #define BS3_MODE_PP16_32 UINT8_C(0x32) /**< 16-bit protected mode kernel+tss, running 32-bit code, paged. */
|
---|
69 | #define BS3_MODE_PP16_V86 UINT8_C(0x33) /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
|
---|
70 | #define BS3_MODE_PP32 UINT8_C(0x42) /**< 32-bit protected mode kernel+tss, running 32-bit code, paged. */
|
---|
71 | #define BS3_MODE_PP32_16 UINT8_C(0x41) /**< 32-bit protected mode kernel+tss, running 16-bit code, paged. */
|
---|
72 | #define BS3_MODE_PPV86 UINT8_C(0x43) /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
|
---|
73 | #define BS3_MODE_PAE16 UINT8_C(0x51) /**< 16-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
|
---|
74 | #define BS3_MODE_PAE16_32 UINT8_C(0x52) /**< 16-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
|
---|
75 | #define BS3_MODE_PAE16_V86 UINT8_C(0x53) /**< 16-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging. */
|
---|
76 | #define BS3_MODE_PAE32 UINT8_C(0x62) /**< 32-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
|
---|
77 | #define BS3_MODE_PAE32_16 UINT8_C(0x61) /**< 32-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
|
---|
78 | #define BS3_MODE_PAEV86 UINT8_C(0x63) /**< 32-bit protected mode kernel+tss, running virtual 8086 mode, PAE paging. */
|
---|
79 | #define BS3_MODE_LM16 UINT8_C(0x71) /**< 16-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
80 | #define BS3_MODE_LM32 UINT8_C(0x72) /**< 32-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
81 | #define BS3_MODE_LM64 UINT8_C(0x74) /**< 64-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
82 |
|
---|
83 | #define BS3_MODE_CODE_MASK UINT8_C(0x0f) /**< Running code mask. */
|
---|
84 | #define BS3_MODE_CODE_16 UINT8_C(0x01) /**< Running 16-bit code. */
|
---|
85 | #define BS3_MODE_CODE_32 UINT8_C(0x02) /**< Running 32-bit code. */
|
---|
86 | #define BS3_MODE_CODE_V86 UINT8_C(0x03) /**< Running 16-bit virtual 8086 code. */
|
---|
87 | #define BS3_MODE_CODE_64 UINT8_C(0x04) /**< Running 64-bit code. */
|
---|
88 |
|
---|
89 | #define BS3_MODE_SYS_MASK UINT8_C(0xf0) /**< kernel+tss mask. */
|
---|
90 | #define BS3_MODE_SYS_RM UINT8_C(0x00) /**< Real mode kernel+tss. */
|
---|
91 | #define BS3_MODE_SYS_PE16 UINT8_C(0x10) /**< 16-bit protected mode kernel+tss. */
|
---|
92 | #define BS3_MODE_SYS_PE32 UINT8_C(0x20) /**< 32-bit protected mode kernel+tss. */
|
---|
93 | #define BS3_MODE_SYS_PP16 UINT8_C(0x30) /**< 16-bit paged protected mode kernel+tss. */
|
---|
94 | #define BS3_MODE_SYS_PP32 UINT8_C(0x40) /**< 32-bit paged protected mode kernel+tss. */
|
---|
95 | #define BS3_MODE_SYS_PAE16 UINT8_C(0x50) /**< 16-bit PAE paged protected mode kernel+tss. */
|
---|
96 | #define BS3_MODE_SYS_PAE32 UINT8_C(0x60) /**< 32-bit PAE paged protected mode kernel+tss. */
|
---|
97 | #define BS3_MODE_SYS_LM UINT8_C(0x70) /**< 64-bit (paged) long mode protected mode kernel+tss. */
|
---|
98 |
|
---|
99 | /** Whether the mode has paging enabled. */
|
---|
100 | #define BS3_MODE_IS_PAGED(a_fMode) ((a_fMode) >= BS3_MODE_PP16)
|
---|
101 |
|
---|
102 | /** Whether the mode is running v8086 code. */
|
---|
103 | #define BS3_MODE_IS_V86(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86)
|
---|
104 | /** Whether the we're executing in real mode or v8086 mode. */
|
---|
105 | #define BS3_MODE_IS_RM_OR_V86(a_fMode) ((a_fMode) == BS3_MODE_RM || BS3_MODE_IS_V86(a_fMode))
|
---|
106 | /** Whether the mode is running 16-bit code, except v8086. */
|
---|
107 | #define BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16)
|
---|
108 | /** Whether the mode is running 16-bit code (includes v8086). */
|
---|
109 | #define BS3_MODE_IS_16BIT_CODE(a_fMode) (BS3_MODE_IS_16BIT_CODE_NO_V86(a_fMode) || BS3_MODE_IS_V86(a_fMode))
|
---|
110 | /** Whether the mode is running 32-bit code. */
|
---|
111 | #define BS3_MODE_IS_32BIT_CODE(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32)
|
---|
112 | /** Whether the mode is running 64-bit code. */
|
---|
113 | #define BS3_MODE_IS_64BIT_CODE(a_fMode) (((a_fMode) & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64)
|
---|
114 |
|
---|
115 | /** Whether the system is in real mode. */
|
---|
116 | #define BS3_MODE_IS_RM_SYS(a_fMode) (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM)
|
---|
117 | /** Whether the system is some 16-bit mode that isn't real mode. */
|
---|
118 | #define BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode) ( ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16 \
|
---|
119 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16 \
|
---|
120 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16)
|
---|
121 | /** Whether the system is some 16-bit mode (includes real mode). */
|
---|
122 | #define BS3_MODE_IS_16BIT_SYS(a_fMode) (BS3_MODE_IS_16BIT_SYS_NO_RM(a_fMode) || BS3_MODE_IS_RM_SYS(a_fMode))
|
---|
123 | /** Whether the system is some 32-bit mode. */
|
---|
124 | #define BS3_MODE_IS_32BIT_SYS(a_fMode) ( ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32 \
|
---|
125 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32 \
|
---|
126 | || ((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32)
|
---|
127 | /** Whether the system is long mode. */
|
---|
128 | #define BS3_MODE_IS_64BIT_SYS(a_fMode) (((a_fMode) & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM)
|
---|
129 |
|
---|
130 | /** @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? */
|
---|
131 | /** @} */
|
---|
132 |
|
---|
133 |
|
---|
134 | /** @name BS3_ADDR_XXX - Static Memory Allocation
|
---|
135 | * @{ */
|
---|
136 | /** The flat load address for the code after the bootsector. */
|
---|
137 | #define BS3_ADDR_LOAD 0x10000
|
---|
138 | /** Where we save the boot registers during init.
|
---|
139 | * Located right before the code. */
|
---|
140 | #define BS3_ADDR_REG_SAVE (BS3_ADDR_LOAD - sizeof(BS3REGS) - 8)
|
---|
141 | /** Where the stack starts (initial RSP value).
|
---|
142 | * Located 16 bytes (assumed by boot sector) before the saved registers.
|
---|
143 | * SS.BASE=0. The size is a little short of 32KB */
|
---|
144 | #define BS3_ADDR_STACK (BS3_ADDR_REG_SAVE - 16)
|
---|
145 | /** The ring-0 stack (8KB) for ring transitions. */
|
---|
146 | #define BS3_ADDR_STACK_R0 0x06000
|
---|
147 | /** The ring-1 stack (8KB) for ring transitions. */
|
---|
148 | #define BS3_ADDR_STACK_R1 0x04000
|
---|
149 | /** The ring-2 stack (8KB) for ring transitions. */
|
---|
150 | #define BS3_ADDR_STACK_R2 0x02000
|
---|
151 | /** IST1 ring-0 stack for long mode (4KB), used for double faults elsewhere. */
|
---|
152 | #define BS3_ADDR_STACK_R0_IST1 0x09000
|
---|
153 | /** IST2 ring-0 stack for long mode (3KB), used for spare 0 stack elsewhere. */
|
---|
154 | #define BS3_ADDR_STACK_R0_IST2 0x08000
|
---|
155 | /** IST3 ring-0 stack for long mode (1KB). */
|
---|
156 | #define BS3_ADDR_STACK_R0_IST3 0x07400
|
---|
157 | /** IST4 ring-0 stack for long mode (1KB), used for spare 1 stack elsewhere. */
|
---|
158 | #define BS3_ADDR_STACK_R0_IST4 0x07000
|
---|
159 | /** IST5 ring-0 stack for long mode (1KB). */
|
---|
160 | #define BS3_ADDR_STACK_R0_IST5 0x06c00
|
---|
161 | /** IST6 ring-0 stack for long mode (1KB). */
|
---|
162 | #define BS3_ADDR_STACK_R0_IST6 0x06800
|
---|
163 | /** IST7 ring-0 stack for long mode (1KB). */
|
---|
164 | #define BS3_ADDR_STACK_R0_IST7 0x06400
|
---|
165 |
|
---|
166 | /** The base address of the BS3TEXT16 segment (same as BS3_LOAD_ADDR).
|
---|
167 | * @sa BS3_SEL_TEXT16 */
|
---|
168 | #define BS3_ADDR_BS3TEXT16 0x10000
|
---|
169 | /** The base address of the BS3SYSTEM16 segment.
|
---|
170 | * @sa BS3_SEL_SYSTEM16 */
|
---|
171 | #define BS3_ADDR_BS3SYSTEM16 0x20000
|
---|
172 | /** The base address of the BS3DATA16 segment.
|
---|
173 | * @sa BS3_SEL_DATA16 */
|
---|
174 | #define BS3_ADDR_BS3DATA16 0x27000
|
---|
175 | /** @} */
|
---|
176 |
|
---|
177 | /** @name BS3_SEL_XXX - GDT selector assignments.
|
---|
178 | *
|
---|
179 | * The real mode segment numbers for BS16TEXT, BS16DATA and BS16SYSTEM are
|
---|
180 | * present in the GDT, this allows the 16-bit C/C++ and assembly code to
|
---|
181 | * continue using the real mode segment values in ring-0 protected mode.
|
---|
182 | *
|
---|
183 | * The three segments have fixed locations:
|
---|
184 | * | segment | flat address | real mode segment |
|
---|
185 | * | ----------- | ------------ | ----------------- |
|
---|
186 | * | BS3TEXT16 | 0x00010000 | 1000h |
|
---|
187 | * | BS3SYSTEM16 | 0x00020000 | 2000h |
|
---|
188 | * | BS3DATA16 | 0x00027000 | 2700h |
|
---|
189 | *
|
---|
190 | * This means that we've got a lot of GDT space to play around with.
|
---|
191 | *
|
---|
192 | * @{ */
|
---|
193 | #define BS3_SEL_LDT 0x0010 /**< The LDT selector for Bs3Ldt. */
|
---|
194 | #define BS3_SEL_TSS16 0x0020 /**< The 16-bit TSS selector. */
|
---|
195 | #define BS3_SEL_TSS16_DF 0x0028 /**< The 16-bit TSS selector for double faults. */
|
---|
196 | #define BS3_SEL_TSS16_SPARE0 0x0030 /**< The 16-bit TSS selector for testing. */
|
---|
197 | #define BS3_SEL_TSS16_SPARE1 0x0038 /**< The 16-bit TSS selector for testing. */
|
---|
198 | #define BS3_SEL_TSS32 0x0040 /**< The 32-bit TSS selector. */
|
---|
199 | #define BS3_SEL_TSS32_DF 0x0048 /**< The 32-bit TSS selector for double faults. */
|
---|
200 | #define BS3_SEL_TSS32_SPARE0 0x0050 /**< The 32-bit TSS selector for testing. */
|
---|
201 | #define BS3_SEL_TSS32_SPARE1 0x0058 /**< The 32-bit TSS selector for testing. */
|
---|
202 | #define BS3_SEL_TSS32_IOBP_IRB 0x0060 /**< The 32-bit TSS selector with I/O permission and interrupt redirection bitmaps. */
|
---|
203 | #define BS3_SEL_TSS32_IRB 0x0068 /**< The 32-bit TSS selector with only interrupt redirection bitmap (IOPB stripped by limit). */
|
---|
204 | #define BS3_SEL_TSS64 0x0070 /**< The 64-bit TSS selector. */
|
---|
205 | #define BS3_SEL_TSS64_SPARE0 0x0080 /**< The 64-bit TSS selector. */
|
---|
206 | #define BS3_SEL_TSS64_SPARE1 0x0090 /**< The 64-bit TSS selector. */
|
---|
207 | #define BS3_SEL_TSS64_IOBP 0x00a0 /**< The 64-bit TSS selector. */
|
---|
208 |
|
---|
209 | #define BS3_SEL_VMMDEV_MMIO16 0x00f8 /**< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code. */
|
---|
210 |
|
---|
211 | #define BS3_SEL_RING_SHIFT 8 /**< For the formula: BS3_SEL_R0_XXX + ((cs & 3) << BS3_SEL_RING_SHIFT) */
|
---|
212 |
|
---|
213 | #define BS3_SEL_R0_FIRST 0x0100 /**< The first selector in the ring-0 block. */
|
---|
214 | #define BS3_SEL_R0_CS16 0x0100 /**< ring-0: 16-bit code selector, base 0x10000. */
|
---|
215 | #define BS3_SEL_R0_DS16 0x0108 /**< ring-0: 16-bit data selector, base 0x23000. */
|
---|
216 | #define BS3_SEL_R0_SS16 0x0110 /**< ring-0: 16-bit stack selector, base 0x00000. */
|
---|
217 | #define BS3_SEL_R0_CS32 0x0118 /**< ring-0: 32-bit flat code selector. */
|
---|
218 | #define BS3_SEL_R0_DS32 0x0120 /**< ring-0: 32-bit flat data selector. */
|
---|
219 | #define BS3_SEL_R0_SS32 0x0128 /**< ring-0: 32-bit flat stack selector. */
|
---|
220 | #define BS3_SEL_R0_CS64 0x0130 /**< ring-0: 64-bit flat code selector. */
|
---|
221 | #define BS3_SEL_R0_DS64 0x0138 /**< ring-0: 64-bit flat data & stack selector. */
|
---|
222 | #define BS3_SEL_R0_CS16_EO 0x0140 /**< ring-0: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
223 | #define BS3_SEL_R0_CS16_CNF 0x0148 /**< ring-0: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
224 | #define BS3_SEL_R0_CS16_CNF_EO 0x0150 /**< ring-0: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
225 | #define BS3_SEL_R0_CS32_EO 0x0158 /**< ring-0: 32-bit execute-only code selector, not accessed, flat. */
|
---|
226 | #define BS3_SEL_R0_CS32_CNF 0x0160 /**< ring-0: 32-bit conforming code selector, not accessed, flat. */
|
---|
227 | #define BS3_SEL_R0_CS32_CNF_EO 0x0168 /**< ring-0: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
228 | #define BS3_SEL_R0_CS64_EO 0x0170 /**< ring-0: 64-bit execute-only code selector, not accessed, flat. */
|
---|
229 | #define BS3_SEL_R0_CS64_CNF 0x0178 /**< ring-0: 64-bit conforming code selector, not accessed, flat. */
|
---|
230 | #define BS3_SEL_R0_CS64_CNF_EO 0x0180 /**< ring-0: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
231 |
|
---|
232 | #define BS3_SEL_R1_FIRST 0x0200 /**< The first selector in the ring-1 block. */
|
---|
233 | #define BS3_SEL_R1_CS16 0x0200 /**< ring-1: 16-bit code selector, base 0x10000. */
|
---|
234 | #define BS3_SEL_R1_DS16 0x0208 /**< ring-1: 16-bit data selector, base 0x23000. */
|
---|
235 | #define BS3_SEL_R1_SS16 0x0210 /**< ring-1: 16-bit stack selector, base 0x00000. */
|
---|
236 | #define BS3_SEL_R1_CS32 0x0218 /**< ring-1: 32-bit flat code selector. */
|
---|
237 | #define BS3_SEL_R1_DS32 0x0220 /**< ring-1: 32-bit flat data selector. */
|
---|
238 | #define BS3_SEL_R1_SS32 0x0228 /**< ring-1: 32-bit flat stack selector. */
|
---|
239 | #define BS3_SEL_R1_CS64 0x0230 /**< ring-1: 64-bit flat code selector. */
|
---|
240 | #define BS3_SEL_R1_DS64 0x0238 /**< ring-1: 64-bit flat data & stack selector. */
|
---|
241 | #define BS3_SEL_R1_CS16_EO 0x0240 /**< ring-1: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
242 | #define BS3_SEL_R1_CS16_CNF 0x0248 /**< ring-1: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
243 | #define BS3_SEL_R1_CS16_CNF_EO 0x0250 /**< ring-1: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
244 | #define BS3_SEL_R1_CS32_EO 0x0258 /**< ring-1: 32-bit execute-only code selector, not accessed, flat. */
|
---|
245 | #define BS3_SEL_R1_CS32_CNF 0x0260 /**< ring-1: 32-bit conforming code selector, not accessed, flat. */
|
---|
246 | #define BS3_SEL_R1_CS32_CNF_EO 0x0268 /**< ring-1: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
247 | #define BS3_SEL_R1_CS64_EO 0x0270 /**< ring-1: 64-bit execute-only code selector, not accessed, flat. */
|
---|
248 | #define BS3_SEL_R1_CS64_CNF 0x0278 /**< ring-1: 64-bit conforming code selector, not accessed, flat. */
|
---|
249 | #define BS3_SEL_R1_CS64_CNF_EO 0x0280 /**< ring-1: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
250 |
|
---|
251 | #define BS3_SEL_R2_FIRST 0x0300 /**< The first selector in the ring-2 block. */
|
---|
252 | #define BS3_SEL_R2_CS16 0x0300 /**< ring-2: 16-bit code selector, base 0x10000. */
|
---|
253 | #define BS3_SEL_R2_DS16 0x0308 /**< ring-2: 16-bit data selector, base 0x23000. */
|
---|
254 | #define BS3_SEL_R2_SS16 0x0310 /**< ring-2: 16-bit stack selector, base 0x00000. */
|
---|
255 | #define BS3_SEL_R2_CS32 0x0318 /**< ring-2: 32-bit flat code selector. */
|
---|
256 | #define BS3_SEL_R2_DS32 0x0320 /**< ring-2: 32-bit flat data selector. */
|
---|
257 | #define BS3_SEL_R2_SS32 0x0328 /**< ring-2: 32-bit flat stack selector. */
|
---|
258 | #define BS3_SEL_R2_CS64 0x0330 /**< ring-2: 64-bit flat code selector. */
|
---|
259 | #define BS3_SEL_R2_DS64 0x0338 /**< ring-2: 64-bit flat data & stack selector. */
|
---|
260 | #define BS3_SEL_R2_CS16_EO 0x0340 /**< ring-2: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
261 | #define BS3_SEL_R2_CS16_CNF 0x0348 /**< ring-2: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
262 | #define BS3_SEL_R2_CS16_CNF_EO 0x0350 /**< ring-2: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
263 | #define BS3_SEL_R2_CS32_EO 0x0358 /**< ring-2: 32-bit execute-only code selector, not accessed, flat. */
|
---|
264 | #define BS3_SEL_R2_CS32_CNF 0x0360 /**< ring-2: 32-bit conforming code selector, not accessed, flat. */
|
---|
265 | #define BS3_SEL_R2_CS32_CNF_EO 0x0368 /**< ring-2: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
266 | #define BS3_SEL_R2_CS64_EO 0x0370 /**< ring-2: 64-bit execute-only code selector, not accessed, flat. */
|
---|
267 | #define BS3_SEL_R2_CS64_CNF 0x0378 /**< ring-2: 64-bit conforming code selector, not accessed, flat. */
|
---|
268 | #define BS3_SEL_R2_CS64_CNF_EO 0x0380 /**< ring-2: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
269 |
|
---|
270 | #define BS3_SEL_R3_FIRST 0x0400 /**< The first selector in the ring-3 block. */
|
---|
271 | #define BS3_SEL_R3_CS16 0x0400 /**< ring-3: 16-bit code selector, base 0x10000. */
|
---|
272 | #define BS3_SEL_R3_DS16 0x0408 /**< ring-3: 16-bit data selector, base 0x23000. */
|
---|
273 | #define BS3_SEL_R3_SS16 0x0410 /**< ring-3: 16-bit stack selector, base 0x00000. */
|
---|
274 | #define BS3_SEL_R3_CS32 0x0418 /**< ring-3: 32-bit flat code selector. */
|
---|
275 | #define BS3_SEL_R3_DS32 0x0420 /**< ring-3: 32-bit flat data selector. */
|
---|
276 | #define BS3_SEL_R3_SS32 0x0428 /**< ring-3: 32-bit flat stack selector. */
|
---|
277 | #define BS3_SEL_R3_CS64 0x0430 /**< ring-3: 64-bit flat code selector. */
|
---|
278 | #define BS3_SEL_R3_DS64 0x0438 /**< ring-3: 64-bit flat data & stack selector. */
|
---|
279 | #define BS3_SEL_R3_CS16_EO 0x0440 /**< ring-3: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
280 | #define BS3_SEL_R3_CS16_CNF 0x0448 /**< ring-3: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
281 | #define BS3_SEL_R3_CS16_CNF_EO 0x0450 /**< ring-3: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
282 | #define BS3_SEL_R3_CS32_EO 0x0458 /**< ring-3: 32-bit execute-only code selector, not accessed, flat. */
|
---|
283 | #define BS3_SEL_R3_CS32_CNF 0x0460 /**< ring-3: 32-bit conforming code selector, not accessed, flat. */
|
---|
284 | #define BS3_SEL_R3_CS32_CNF_EO 0x0468 /**< ring-3: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
285 | #define BS3_SEL_R3_CS64_EO 0x0470 /**< ring-3: 64-bit execute-only code selector, not accessed, flat. */
|
---|
286 | #define BS3_SEL_R3_CS64_CNF 0x0478 /**< ring-3: 64-bit conforming code selector, not accessed, flat. */
|
---|
287 | #define BS3_SEL_R3_CS64_CNF_EO 0x0480 /**< ring-3: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
288 |
|
---|
289 | #define BS3_SEL_SPARE_FIRST 0x0500 /**< The first selector in the spare block */
|
---|
290 | #define BS3_SEL_SPARE_00 0x0500 /**< Spare selector number 00h. */
|
---|
291 | #define BS3_SEL_SPARE_01 0x0508 /**< Spare selector number 01h. */
|
---|
292 | #define BS3_SEL_SPARE_02 0x0510 /**< Spare selector number 02h. */
|
---|
293 | #define BS3_SEL_SPARE_03 0x0518 /**< Spare selector number 03h. */
|
---|
294 | #define BS3_SEL_SPARE_04 0x0520 /**< Spare selector number 04h. */
|
---|
295 | #define BS3_SEL_SPARE_05 0x0528 /**< Spare selector number 05h. */
|
---|
296 | #define BS3_SEL_SPARE_06 0x0530 /**< Spare selector number 06h. */
|
---|
297 | #define BS3_SEL_SPARE_07 0x0538 /**< Spare selector number 07h. */
|
---|
298 | #define BS3_SEL_SPARE_08 0x0540 /**< Spare selector number 08h. */
|
---|
299 | #define BS3_SEL_SPARE_09 0x0548 /**< Spare selector number 09h. */
|
---|
300 | #define BS3_SEL_SPARE_0a 0x0550 /**< Spare selector number 0ah. */
|
---|
301 | #define BS3_SEL_SPARE_0b 0x0558 /**< Spare selector number 0bh. */
|
---|
302 | #define BS3_SEL_SPARE_0c 0x0560 /**< Spare selector number 0ch. */
|
---|
303 | #define BS3_SEL_SPARE_0d 0x0568 /**< Spare selector number 0dh. */
|
---|
304 | #define BS3_SEL_SPARE_0e 0x0570 /**< Spare selector number 0eh. */
|
---|
305 | #define BS3_SEL_SPARE_0f 0x0578 /**< Spare selector number 0fh. */
|
---|
306 | #define BS3_SEL_SPARE_10 0x0580 /**< Spare selector number 10h. */
|
---|
307 | #define BS3_SEL_SPARE_11 0x0588 /**< Spare selector number 11h. */
|
---|
308 | #define BS3_SEL_SPARE_12 0x0590 /**< Spare selector number 12h. */
|
---|
309 | #define BS3_SEL_SPARE_13 0x0598 /**< Spare selector number 13h. */
|
---|
310 | #define BS3_SEL_SPARE_14 0x05a0 /**< Spare selector number 14h. */
|
---|
311 | #define BS3_SEL_SPARE_15 0x05a8 /**< Spare selector number 15h. */
|
---|
312 | #define BS3_SEL_SPARE_16 0x05b0 /**< Spare selector number 16h. */
|
---|
313 | #define BS3_SEL_SPARE_17 0x05b8 /**< Spare selector number 17h. */
|
---|
314 | #define BS3_SEL_SPARE_18 0x05c0 /**< Spare selector number 18h. */
|
---|
315 | #define BS3_SEL_SPARE_19 0x05c8 /**< Spare selector number 19h. */
|
---|
316 | #define BS3_SEL_SPARE_1a 0x05d0 /**< Spare selector number 1ah. */
|
---|
317 | #define BS3_SEL_SPARE_1b 0x05d8 /**< Spare selector number 1bh. */
|
---|
318 | #define BS3_SEL_SPARE_1c 0x05e0 /**< Spare selector number 1ch. */
|
---|
319 | #define BS3_SEL_SPARE_1d 0x05e8 /**< Spare selector number 1dh. */
|
---|
320 | #define BS3_SEL_SPARE_1e 0x05f0 /**< Spare selector number 1eh. */
|
---|
321 | #define BS3_SEL_SPARE_1f 0x05f8 /**< Spare selector number 1fh. */
|
---|
322 |
|
---|
323 | #define BS3_SEL_TILED 0x0600 /**< 16-bit data tiling: First - base=0x00000000, limit=64KB. */
|
---|
324 | #define BS3_SEL_TILED_LAST 0x0df8 /**< 16-bit data tiling: Last - base=0x00ff0000, limit=64KB. */
|
---|
325 | #define BS3_SEL_TILED_AREA_SIZE 0x001000000 /**< 16-bit data tiling: Size of addressable area, in bytes. (16 MB) */
|
---|
326 |
|
---|
327 | #define BS3_SEL_FREE_PART1 0x0e00 /**< Free selector space - part \#1. */
|
---|
328 | #define BS3_SEL_FREE_PART1_LAST 0x0ff8 /**< Free selector space - part \#1, last entry. */
|
---|
329 |
|
---|
330 | #define BS3_SEL_TEXT16 0x1000 /**< The BS3TEXT16 selector. */
|
---|
331 |
|
---|
332 | #define BS3_SEL_FREE_PART2 0x1008 /**< Free selector space - part \#2. */
|
---|
333 | #define BS3_SEL_FREE_PART2_LAST 0x1ff8 /**< Free selector space - part \#2, last entry. */
|
---|
334 |
|
---|
335 | #define BS3_SEL_SYSTEM16 0x2000 /**< The BS3SYSTEM16 selector. */
|
---|
336 |
|
---|
337 | #define BS3_SEL_FREE_PART3 0x2008 /**< Free selector space - part \#3. */
|
---|
338 | #define BS3_SEL_FREE_PART3_LAST 0x26f8 /**< Free selector space - part \#3, last entry. */
|
---|
339 |
|
---|
340 | #define BS3_SEL_DATA16 0x2700 /**< The BS3DATA16 selector. */
|
---|
341 |
|
---|
342 | #define BS3_SEL_GDT_LIMIT 0x2707 /**< The GDT limit. */
|
---|
343 | /** @} */
|
---|
344 |
|
---|
345 |
|
---|
346 | /** @def BS3_FAR
|
---|
347 | * For indicating far pointers in 16-bit code.
|
---|
348 | * Does nothing in 32-bit and 64-bit code. */
|
---|
349 | /** @def BS3_NEAR
|
---|
350 | * For indicating near pointers in 16-bit code.
|
---|
351 | * Does nothing in 32-bit and 64-bit code. */
|
---|
352 | /** @def BS3_FAR_CODE
|
---|
353 | * For indicating far 16-bit functions.
|
---|
354 | * Does nothing in 32-bit and 64-bit code. */
|
---|
355 | /** @def BS3_NEAR_CODE
|
---|
356 | * For indicating near 16-bit functions.
|
---|
357 | * Does nothing in 32-bit and 64-bit code. */
|
---|
358 | /** @def BS3_FAR_DATA
|
---|
359 | * For indicating far 16-bit external data, i.e. in a segment other than DATA16.
|
---|
360 | * Does nothing in 32-bit and 64-bit code. */
|
---|
361 | #ifdef M_I86
|
---|
362 | # define BS3_FAR __far
|
---|
363 | # define BS3_NEAR __near
|
---|
364 | # define BS3_FAR_CODE __far
|
---|
365 | # define BS3_NEAR_CODE __near
|
---|
366 | # define BS3_FAR_DATA __far
|
---|
367 | #else
|
---|
368 | # define BS3_FAR
|
---|
369 | # define BS3_NEAR
|
---|
370 | # define BS3_FAR_CODE
|
---|
371 | # define BS3_NEAR_CODE
|
---|
372 | # define BS3_FAR_DATA
|
---|
373 | #endif
|
---|
374 |
|
---|
375 | #if ARCH_BITS == 16 || defined(DOXYGEN_RUNNING)
|
---|
376 | /** @def BS3_FP_SEG
|
---|
377 | * Get the selector (segment) part of a far pointer.
|
---|
378 | * @returns selector.
|
---|
379 | * @param a_pv Far pointer.
|
---|
380 | */
|
---|
381 | # define BS3_FP_SEG(a_pv) ((uint16_t)(__segment)(void BS3_FAR *)(a_pv))
|
---|
382 | /** @def BS3_FP_OFF
|
---|
383 | * Get the segment offset part of a far pointer.
|
---|
384 | * @returns offset.
|
---|
385 | * @param a_pv Far pointer.
|
---|
386 | */
|
---|
387 | # define BS3_FP_OFF(a_pv) ((uint16_t)(void __near *)(a_pv))
|
---|
388 | /** @def BS3_FP_MAKE
|
---|
389 | * Create a far pointer.
|
---|
390 | * @returns selector.
|
---|
391 | * @param a_pv Far pointer.
|
---|
392 | */
|
---|
393 | # define BS3_FP_MAKE(a_uSeg, a_off) (((__segment)(a_uSeg)) :> ((void __near *)(a_off)))
|
---|
394 | #endif
|
---|
395 |
|
---|
396 | /** @def BS3_CALL
|
---|
397 | * The calling convension used by BS3 functions. */
|
---|
398 | #if ARCH_BITS != 64
|
---|
399 | # define BS3_CALL __cdecl
|
---|
400 | #elif !defined(_MSC_VER)
|
---|
401 | # define BS3_CALL __attribute__((__ms_abi__))
|
---|
402 | #else
|
---|
403 | # define BS3_CALL
|
---|
404 | #endif
|
---|
405 |
|
---|
406 | /** @def IN_BS3KIT
|
---|
407 | * Indicates that we're in the same link job as the BS3Kit code. */
|
---|
408 | #ifdef DOXYGEN_RUNNING
|
---|
409 | # define IN_BS3KIT
|
---|
410 | #endif
|
---|
411 |
|
---|
412 | /** @def BS3_DECL
|
---|
413 | * Declares a BS3Kit function.
|
---|
414 | *
|
---|
415 | * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
|
---|
416 | *
|
---|
417 | * @param a_Type The return type. */
|
---|
418 | #ifdef IN_BS3KIT
|
---|
419 | # define BS3_DECL(a_Type) DECLEXPORT(a_Type) BS3_NEAR_CODE BS3_CALL
|
---|
420 | #else
|
---|
421 | # define BS3_DECL(a_Type) DECLIMPORT(a_Type) BS3_NEAR_CODE BS3_CALL
|
---|
422 | #endif
|
---|
423 |
|
---|
424 | /** @def BS3_DECL_CALLBACK
|
---|
425 | * Declares a BS3Kit callback function (typically static).
|
---|
426 | *
|
---|
427 | * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
|
---|
428 | *
|
---|
429 | * @param a_Type The return type. */
|
---|
430 | #ifdef IN_BS3KIT
|
---|
431 | # define BS3_DECL_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL
|
---|
432 | #else
|
---|
433 | # define BS3_DECL_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL
|
---|
434 | #endif
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * Constructs a common name.
|
---|
438 | *
|
---|
439 | * Example: BS3_CMN_NM(Bs3Shutdown)
|
---|
440 | *
|
---|
441 | * @param a_Name The name of the function or global variable.
|
---|
442 | */
|
---|
443 | #define BS3_CMN_NM(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Constructs a data name.
|
---|
447 | *
|
---|
448 | * Example: extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdt)
|
---|
449 | *
|
---|
450 | * @param a_Name The name of the global variable.
|
---|
451 | */
|
---|
452 | #if ARCH_BITS == 64
|
---|
453 | # define BS3_DATA_NM(a_Name) RT_CONCAT(_,a_Name)
|
---|
454 | #else
|
---|
455 | # define BS3_DATA_NM(a_Name) a_Name
|
---|
456 | #endif
|
---|
457 |
|
---|
458 | /** @def BS3_MSC64_FIXUP_HACK
|
---|
459 | * Used to avoid IMAGE_REL_AMD64_ADDR32NB fixups where the compiler tries to
|
---|
460 | * make use of __ImageBase as a base pointer instead of emitting rip relative
|
---|
461 | * accesses. Happens when there are a bunch of global data accesses in the same
|
---|
462 | * function, probably to save space.
|
---|
463 | *
|
---|
464 | * The volatile variable in the lambda fixes it.
|
---|
465 | */
|
---|
466 | #if _MSC_VER && ARCH_BITS == 64
|
---|
467 | # define BS3_MSC64_FIXUP_HACK(a_BaseType, a_Data) \
|
---|
468 | ([]() -> a_BaseType * \
|
---|
469 | { \
|
---|
470 | a_BaseType * volatile x = a_Data; \
|
---|
471 | return x; \
|
---|
472 | }())
|
---|
473 |
|
---|
474 | #else
|
---|
475 | # define BS3_MSC64_FIXUP_HACK(a_BaseType, a_Data) (a_Data)
|
---|
476 | #endif
|
---|
477 |
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Template for createing a pointer union type.
|
---|
481 | * @param a_BaseName The base type name.
|
---|
482 | * @param a_Modifier The type modifier.
|
---|
483 | */
|
---|
484 | #define BS3_PTR_UNION_TEMPLATE(a_BaseName, a_Modifiers) \
|
---|
485 | typedef union a_BaseName \
|
---|
486 | { \
|
---|
487 | /** Pointer into the void. */ \
|
---|
488 | a_Modifiers void BS3_FAR *pv; \
|
---|
489 | /** As a signed integer. */ \
|
---|
490 | intptr_t i; \
|
---|
491 | /** As an unsigned integer. */ \
|
---|
492 | uintptr_t u; \
|
---|
493 | /** Pointer to char value. */ \
|
---|
494 | a_Modifiers char BS3_FAR *pch; \
|
---|
495 | /** Pointer to char value. */ \
|
---|
496 | a_Modifiers unsigned char BS3_FAR *puch; \
|
---|
497 | /** Pointer to a int value. */ \
|
---|
498 | a_Modifiers int BS3_FAR *pi; \
|
---|
499 | /** Pointer to a unsigned int value. */ \
|
---|
500 | a_Modifiers unsigned int BS3_FAR *pu; \
|
---|
501 | /** Pointer to a long value. */ \
|
---|
502 | a_Modifiers long BS3_FAR *pl; \
|
---|
503 | /** Pointer to a long value. */ \
|
---|
504 | a_Modifiers unsigned long BS3_FAR *pul; \
|
---|
505 | /** Pointer to a memory size value. */ \
|
---|
506 | a_Modifiers size_t BS3_FAR *pcb; \
|
---|
507 | /** Pointer to a byte value. */ \
|
---|
508 | a_Modifiers uint8_t BS3_FAR *pb; \
|
---|
509 | /** Pointer to a 8-bit unsigned value. */ \
|
---|
510 | a_Modifiers uint8_t BS3_FAR *pu8; \
|
---|
511 | /** Pointer to a 16-bit unsigned value. */ \
|
---|
512 | a_Modifiers uint16_t BS3_FAR *pu16; \
|
---|
513 | /** Pointer to a 32-bit unsigned value. */ \
|
---|
514 | a_Modifiers uint32_t BS3_FAR *pu32; \
|
---|
515 | /** Pointer to a 64-bit unsigned value. */ \
|
---|
516 | a_Modifiers uint64_t BS3_FAR *pu64; \
|
---|
517 | /** Pointer to a UTF-16 character. */ \
|
---|
518 | a_Modifiers RTUTF16 BS3_FAR *pwc; \
|
---|
519 | /** Pointer to a UUID character. */ \
|
---|
520 | a_Modifiers RTUUID BS3_FAR *pUuid; \
|
---|
521 | } a_BaseName; \
|
---|
522 | /** Pointer to a pointer union. */ \
|
---|
523 | typedef a_BaseName *RT_CONCAT(P,a_BaseName)
|
---|
524 | BS3_PTR_UNION_TEMPLATE(BS3PTRUNION, RT_NOTHING);
|
---|
525 | BS3_PTR_UNION_TEMPLATE(BS3CPTRUNION, const);
|
---|
526 | BS3_PTR_UNION_TEMPLATE(BS3VPTRUNION, volatile);
|
---|
527 | BS3_PTR_UNION_TEMPLATE(BS3CVPTRUNION, const volatile);
|
---|
528 |
|
---|
529 |
|
---|
530 | /** The system call vector. */
|
---|
531 | #define BS3_TRAP_SYSCALL UINT8_C(0x20)
|
---|
532 |
|
---|
533 | /** @name System call numbers (ax).
|
---|
534 | * Paramenters are generally passed in registers specific to each system call.
|
---|
535 | * @{ */
|
---|
536 | /** Print char (cl). */
|
---|
537 | #define BS3_SYSCALL_PRINT_CHR UINT16_C(0x0001)
|
---|
538 | /** Print string (pointer in ds:[e]si, length in cx). */
|
---|
539 | #define BS3_SYSCALL_PRINT_STR UINT16_C(0x0002)
|
---|
540 | /** Switch to ring-0. */
|
---|
541 | #define BS3_SYSCALL_TO_RING0 UINT16_C(0x0003)
|
---|
542 | /** Switch to ring-1. */
|
---|
543 | #define BS3_SYSCALL_TO_RING1 UINT16_C(0x0004)
|
---|
544 | /** Switch to ring-2. */
|
---|
545 | #define BS3_SYSCALL_TO_RING2 UINT16_C(0x0005)
|
---|
546 | /** Switch to ring-3. */
|
---|
547 | #define BS3_SYSCALL_TO_RING3 UINT16_C(0x0006)
|
---|
548 | /** @} */
|
---|
549 |
|
---|
550 |
|
---|
551 |
|
---|
552 | /** @defgroup grp_bs3kit_system System structures
|
---|
553 | * @{ */
|
---|
554 | /** The GDT, indexed by BS3_SEL_XXX shifted by 3. */
|
---|
555 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdt)[(BS3_SEL_GDT_LIMIT + 1) / 8];
|
---|
556 |
|
---|
557 | extern X86DESC64 BS3_FAR_DATA BS3_DATA_NM(Bs3Gdt_Ldt); /**< @see BS3_SEL_LDT */
|
---|
558 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss16); /**< @see BS3_SEL_TSS16 */
|
---|
559 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss16DoubleFault); /**< @see BS3_SEL_TSS16_DF */
|
---|
560 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss16Spare0); /**< @see BS3_SEL_TSS16_SPARE0 */
|
---|
561 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss16Spare1); /**< @see BS3_SEL_TSS16_SPARE1 */
|
---|
562 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss32); /**< @see BS3_SEL_TSS32 */
|
---|
563 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss32DoubleFault); /**< @see BS3_SEL_TSS32_DF */
|
---|
564 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss32Spare0); /**< @see BS3_SEL_TSS32_SPARE0 */
|
---|
565 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss32Spare1); /**< @see BS3_SEL_TSS32_SPARE1 */
|
---|
566 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss32IobpIntRedirBm); /**< @see BS3_SEL_TSS32_IOBP_IRB */
|
---|
567 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss32IntRedirBm); /**< @see BS3_SEL_TSS32_IRB */
|
---|
568 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss64); /**< @see BS3_SEL_TSS64 */
|
---|
569 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss64Spare0); /**< @see BS3_SEL_TSS64_SPARE0 */
|
---|
570 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss64Spare1); /**< @see BS3_SEL_TSS64_SPARE1 */
|
---|
571 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_Tss64Iobp); /**< @see BS3_SEL_TSS64_IOBP */
|
---|
572 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_MMIO16); /**< @see BS3_SEL_VMMDEV_MMIO16 */
|
---|
573 |
|
---|
574 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_First); /**< @see BS3_SEL_R0_FIRST */
|
---|
575 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS16); /**< @see BS3_SEL_R0_CS16 */
|
---|
576 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_DS16); /**< @see BS3_SEL_R0_DS16 */
|
---|
577 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_SS16); /**< @see BS3_SEL_R0_SS16 */
|
---|
578 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS32); /**< @see BS3_SEL_R0_CS32 */
|
---|
579 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_DS32); /**< @see BS3_SEL_R0_DS32 */
|
---|
580 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_SS32); /**< @see BS3_SEL_R0_SS32 */
|
---|
581 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS64); /**< @see BS3_SEL_R0_CS64 */
|
---|
582 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_DS64); /**< @see BS3_SEL_R0_DS64 */
|
---|
583 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS16_EO); /**< @see BS3_SEL_R0_CS16_EO */
|
---|
584 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS16_CNF); /**< @see BS3_SEL_R0_CS16_CNF */
|
---|
585 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS16_CND_EO); /**< @see BS3_SEL_R0_CS16_CNF_EO */
|
---|
586 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS32_EO); /**< @see BS3_SEL_R0_CS32_EO */
|
---|
587 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF); /**< @see BS3_SEL_R0_CS32_CNF */
|
---|
588 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF_EO); /**< @see BS3_SEL_R0_CS32_CNF_EO */
|
---|
589 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS64_EO); /**< @see BS3_SEL_R0_CS64_EO */
|
---|
590 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF); /**< @see BS3_SEL_R0_CS64_CNF */
|
---|
591 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF_EO); /**< @see BS3_SEL_R0_CS64_CNF_EO */
|
---|
592 |
|
---|
593 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_First); /**< @see BS3_SEL_R1_FIRST */
|
---|
594 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS16); /**< @see BS3_SEL_R1_CS16 */
|
---|
595 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_DS16); /**< @see BS3_SEL_R1_DS16 */
|
---|
596 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_SS16); /**< @see BS3_SEL_R1_SS16 */
|
---|
597 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS32); /**< @see BS3_SEL_R1_CS32 */
|
---|
598 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_DS32); /**< @see BS3_SEL_R1_DS32 */
|
---|
599 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_SS32); /**< @see BS3_SEL_R1_SS32 */
|
---|
600 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS64); /**< @see BS3_SEL_R1_CS64 */
|
---|
601 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_DS64); /**< @see BS3_SEL_R1_DS64 */
|
---|
602 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS16_EO); /**< @see BS3_SEL_R1_CS16_EO */
|
---|
603 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS16_CNF); /**< @see BS3_SEL_R1_CS16_CNF */
|
---|
604 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS16_CND_EO); /**< @see BS3_SEL_R1_CS16_CNF_EO */
|
---|
605 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS32_EO); /**< @see BS3_SEL_R1_CS32_EO */
|
---|
606 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF); /**< @see BS3_SEL_R1_CS32_CNF */
|
---|
607 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF_EO); /**< @see BS3_SEL_R1_CS32_CNF_EO */
|
---|
608 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS64_EO); /**< @see BS3_SEL_R1_CS64_EO */
|
---|
609 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF); /**< @see BS3_SEL_R1_CS64_CNF */
|
---|
610 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF_EO); /**< @see BS3_SEL_R1_CS64_CNF_EO */
|
---|
611 |
|
---|
612 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_First); /**< @see BS3_SEL_R2_FIRST */
|
---|
613 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS16); /**< @see BS3_SEL_R2_CS16 */
|
---|
614 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_DS16); /**< @see BS3_SEL_R2_DS16 */
|
---|
615 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_SS16); /**< @see BS3_SEL_R2_SS16 */
|
---|
616 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS32); /**< @see BS3_SEL_R2_CS32 */
|
---|
617 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_DS32); /**< @see BS3_SEL_R2_DS32 */
|
---|
618 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_SS32); /**< @see BS3_SEL_R2_SS32 */
|
---|
619 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS64); /**< @see BS3_SEL_R2_CS64 */
|
---|
620 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_DS64); /**< @see BS3_SEL_R2_DS64 */
|
---|
621 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS16_EO); /**< @see BS3_SEL_R2_CS16_EO */
|
---|
622 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS16_CNF); /**< @see BS3_SEL_R2_CS16_CNF */
|
---|
623 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS16_CND_EO); /**< @see BS3_SEL_R2_CS16_CNF_EO */
|
---|
624 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS32_EO); /**< @see BS3_SEL_R2_CS32_EO */
|
---|
625 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF); /**< @see BS3_SEL_R2_CS32_CNF */
|
---|
626 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF_EO); /**< @see BS3_SEL_R2_CS32_CNF_EO */
|
---|
627 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS64_EO); /**< @see BS3_SEL_R2_CS64_EO */
|
---|
628 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF); /**< @see BS3_SEL_R2_CS64_CNF */
|
---|
629 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF_EO); /**< @see BS3_SEL_R2_CS64_CNF_EO */
|
---|
630 |
|
---|
631 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_First); /**< @see BS3_SEL_R3_FIRST */
|
---|
632 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS16); /**< @see BS3_SEL_R3_CS16 */
|
---|
633 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_DS16); /**< @see BS3_SEL_R3_DS16 */
|
---|
634 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_SS16); /**< @see BS3_SEL_R3_SS16 */
|
---|
635 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS32); /**< @see BS3_SEL_R3_CS32 */
|
---|
636 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_DS32); /**< @see BS3_SEL_R3_DS32 */
|
---|
637 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_SS32); /**< @see BS3_SEL_R3_SS32 */
|
---|
638 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS64); /**< @see BS3_SEL_R3_CS64 */
|
---|
639 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_DS64); /**< @see BS3_SEL_R3_DS64 */
|
---|
640 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS16_EO); /**< @see BS3_SEL_R3_CS16_EO */
|
---|
641 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS16_CNF); /**< @see BS3_SEL_R3_CS16_CNF */
|
---|
642 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS16_CND_EO); /**< @see BS3_SEL_R3_CS16_CNF_EO */
|
---|
643 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS32_EO); /**< @see BS3_SEL_R3_CS32_EO */
|
---|
644 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF); /**< @see BS3_SEL_R3_CS32_CNF */
|
---|
645 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF_EO); /**< @see BS3_SEL_R3_CS32_CNF_EO */
|
---|
646 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS64_EO); /**< @see BS3_SEL_R3_CS64_EO */
|
---|
647 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF); /**< @see BS3_SEL_R3_CS64_CNF */
|
---|
648 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF_EO); /**< @see BS3_SEL_R3_CS64_CNF_EO */
|
---|
649 |
|
---|
650 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare00); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_00 */
|
---|
651 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare01); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_01 */
|
---|
652 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare02); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_02 */
|
---|
653 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare03); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_03 */
|
---|
654 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare04); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_04 */
|
---|
655 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare05); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_05 */
|
---|
656 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare06); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_06 */
|
---|
657 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare07); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_07 */
|
---|
658 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare08); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_08 */
|
---|
659 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare09); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_09 */
|
---|
660 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare0a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0a */
|
---|
661 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare0b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0b */
|
---|
662 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare0c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0c */
|
---|
663 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare0d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0d */
|
---|
664 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare0e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0e */
|
---|
665 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare0f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0f */
|
---|
666 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare10); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_10 */
|
---|
667 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare11); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_11 */
|
---|
668 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare12); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_12 */
|
---|
669 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare13); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_13 */
|
---|
670 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare14); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_14 */
|
---|
671 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare15); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_15 */
|
---|
672 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare16); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_16 */
|
---|
673 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare17); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_17 */
|
---|
674 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare18); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_18 */
|
---|
675 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare19); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_19 */
|
---|
676 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare1a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1a */
|
---|
677 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare1b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1b */
|
---|
678 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare1c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1c */
|
---|
679 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare1d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1d */
|
---|
680 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare1e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1e */
|
---|
681 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteSpare1f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1f */
|
---|
682 |
|
---|
683 | /** GDTs setting up the tiled 16-bit access to the first 16 MBs of memory.
|
---|
684 | * @see BS3_SEL_TILED, BS3_SEL_TILED_LAST, BS3_SEL_TILED_AREA_SIZE */
|
---|
685 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteTiled)[256];
|
---|
686 | /** Free GDTes, part \#1. */
|
---|
687 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart1)[64];
|
---|
688 | /** The BS3CODE16 GDT entry. @see BS3_SEL_TEXT16 */
|
---|
689 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_CODE16);
|
---|
690 | /** Free GDTes, part \#2. */
|
---|
691 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart2)[511];
|
---|
692 | /** The BS3SYSTEM16 GDT entry. */
|
---|
693 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_SYSTEM16);
|
---|
694 | /** Free GDTes, part \#3. */
|
---|
695 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdteFreePart3)[223];
|
---|
696 | /** The BS3DATA16 GDT entry. */
|
---|
697 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Gdte_DATA16);
|
---|
698 | /** The end of the GDT (exclusive). */
|
---|
699 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3GdtEnd);
|
---|
700 |
|
---|
701 | /** The default 16-bit TSS. */
|
---|
702 | extern X86TSS16 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss16);
|
---|
703 | extern X86TSS16 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss16DoubleFault);
|
---|
704 | extern X86TSS16 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss16Spare0);
|
---|
705 | extern X86TSS16 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss16Spare1);
|
---|
706 | /** The default 32-bit TSS. */
|
---|
707 | extern X86TSS32 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss32);
|
---|
708 | extern X86TSS32 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss32DoubleFault);
|
---|
709 | extern X86TSS32 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss32Spare0);
|
---|
710 | extern X86TSS32 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss32Spare1);
|
---|
711 | /** The default 64-bit TSS. */
|
---|
712 | extern X86TSS64 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss64);
|
---|
713 | extern X86TSS64 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss64Spare0);
|
---|
714 | extern X86TSS64 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss64Spare1);
|
---|
715 | extern X86TSS64 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss64WithIopb);
|
---|
716 | extern X86TSS32 BS3_FAR_DATA BS3_DATA_NM(Bs3Tss32WithIopb);
|
---|
717 | /** Interrupt redirection bitmap used by Bs3Tss32WithIopb. */
|
---|
718 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3SharedIntRedirBm)[32];
|
---|
719 | /** I/O permission bitmap used by Bs3Tss32WithIopb and Bs3Tss64WithIopb. */
|
---|
720 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3SharedIobp)[8192+2];
|
---|
721 | /** End of the I/O permission bitmap (exclusive). */
|
---|
722 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3SharedIobpEnd);
|
---|
723 | /** 16-bit IDT. */
|
---|
724 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Idt16)[256];
|
---|
725 | /** 32-bit IDT. */
|
---|
726 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Idt32)[256];
|
---|
727 | /** 64-bit IDT. */
|
---|
728 | extern X86DESC64 BS3_FAR_DATA BS3_DATA_NM(Bs3Idt64)[256];
|
---|
729 | /** Structure for the LIDT instruction for loading the 16-bit IDT. */
|
---|
730 | extern X86XDTR64 BS3_FAR_DATA BS3_DATA_NM(Bs3Lidt_Idt16);
|
---|
731 | /** Structure for the LIDT instruction for loading the 32-bit IDT. */
|
---|
732 | extern X86XDTR64 BS3_FAR_DATA BS3_DATA_NM(Bs3Lidt_Idt32);
|
---|
733 | /** Structure for the LIDT instruction for loading the 64-bit IDT. */
|
---|
734 | extern X86XDTR64 BS3_FAR_DATA BS3_DATA_NM(Bs3Lidt_Idt64);
|
---|
735 | /** Structure for the LIDT instruction for loading the real mode interrupt
|
---|
736 | * vector table.. */
|
---|
737 | extern X86XDTR64 BS3_FAR_DATA BS3_DATA_NM(Bs3Lidt_Ivt);
|
---|
738 | /** Structure for the LGDT instruction for loading the GDT. */
|
---|
739 | extern X86XDTR64 BS3_FAR_DATA BS3_DATA_NM(Bs3Lgdt_Gdt);
|
---|
740 | /** The LDT (all entries are empty, fill in for testing). */
|
---|
741 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3Ldt)[118];
|
---|
742 | /** The end of the LDT (exclusive). */
|
---|
743 | extern X86DESC BS3_FAR_DATA BS3_DATA_NM(Bs3LdtEnd);
|
---|
744 |
|
---|
745 | /** @} */
|
---|
746 |
|
---|
747 |
|
---|
748 | /** @name Segment start and end markers, sizes.
|
---|
749 | * @{ */
|
---|
750 | /** Start of the BS3TEXT16 segment. */
|
---|
751 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text16_StartOfSegment);
|
---|
752 | /** End of the BS3TEXT16 segment. */
|
---|
753 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text16_EndOfSegment);
|
---|
754 | /** The size of the BS3TEXT16 segment. */
|
---|
755 | extern uint16_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text16_Size);
|
---|
756 |
|
---|
757 | /** Start of the BS3SYSTEM16 segment. */
|
---|
758 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3System16_StartOfSegment);
|
---|
759 | /** End of the BS3SYSTEM16 segment. */
|
---|
760 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3System16_EndOfSegment);
|
---|
761 |
|
---|
762 | /** Start of the BS3DATA16 segment. */
|
---|
763 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data16_StartOfSegment);
|
---|
764 | /** End of the BS3DATA16 segment. */
|
---|
765 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data16_EndOfSegment);
|
---|
766 |
|
---|
767 | /** Start of the BS3TEXT32 segment. */
|
---|
768 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text32_StartOfSegment);
|
---|
769 | /** Start of the BS3TEXT32 segment. */
|
---|
770 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text32_EndOfSegment);
|
---|
771 |
|
---|
772 | /** Start of the BS3DATA32 segment. */
|
---|
773 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data32_StartOfSegment);
|
---|
774 | /** Start of the BS3DATA32 segment. */
|
---|
775 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data32_EndOfSegment);
|
---|
776 |
|
---|
777 | /** Start of the BS3TEXT64 segment. */
|
---|
778 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text64_StartOfSegment);
|
---|
779 | /** Start of the BS3TEXT64 segment. */
|
---|
780 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Text64_EndOfSegment);
|
---|
781 |
|
---|
782 | /** Start of the BS3DATA64 segment. */
|
---|
783 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data64_StartOfSegment);
|
---|
784 | /** Start of the BS3DATA64 segment. */
|
---|
785 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data64_EndOfSegment);
|
---|
786 |
|
---|
787 | /** The size of the Data16, Text32, Text64, Data32 and Data64 blob. */
|
---|
788 | extern uint32_t BS3_FAR_DATA BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize);
|
---|
789 | /** The total image size (from Text16 thu Data64). */
|
---|
790 | extern uint32_t BS3_FAR_DATA BS3_DATA_NM(Bs3TotalImageSize);
|
---|
791 | /** @} */
|
---|
792 |
|
---|
793 |
|
---|
794 | /** Lower case hex digits. */
|
---|
795 | extern char const BS3_DATA_NM(g_achBs3HexDigits)[16+1];
|
---|
796 | /** Upper case hex digits. */
|
---|
797 | extern char const BS3_DATA_NM(g_achBs3HexDigitsUpper)[16+1];
|
---|
798 |
|
---|
799 |
|
---|
800 | /** The current mode (BS3_MODE_XXX) of CPU \#0. */
|
---|
801 | extern uint8_t BS3_FAR_DATA BS3_DATA_NM(g_bBs3CurrentMode);
|
---|
802 |
|
---|
803 |
|
---|
804 | #ifdef __WATCOMC__
|
---|
805 | /**
|
---|
806 | * Executes the SMSW instruction and returns the value.
|
---|
807 | *
|
---|
808 | * @returns Machine status word.
|
---|
809 | */
|
---|
810 | uint16_t Bs3AsmSmsw(void);
|
---|
811 | # pragma aux Bs3AsmSmsw = \
|
---|
812 | ".286" \
|
---|
813 | "smsw ax" \
|
---|
814 | value [ax] modify exact [ax] nomemory;
|
---|
815 | #endif
|
---|
816 |
|
---|
817 |
|
---|
818 | /** @def BS3_IS_PROTECTED_MODE
|
---|
819 | * @returns true if protected mode, false if not. */
|
---|
820 | #if ARCH_BITS != 16
|
---|
821 | # define BS3_IS_PROTECTED_MODE() (true)
|
---|
822 | #else
|
---|
823 | # if 1
|
---|
824 | # define BS3_IS_PROTECTED_MODE() (!BS3_MODE_IS_RM_SYS(BS3_DATA_NM(g_bBs3CurrentMode)))
|
---|
825 | # else
|
---|
826 | # define BS3_IS_PROTECTED_MODE() (Bs3AsmSmsw() & 1 /*PE*/)
|
---|
827 | # endif
|
---|
828 | #endif
|
---|
829 |
|
---|
830 |
|
---|
831 | /** @defgroup bs3kit_cross_ptr Cross context pointer type
|
---|
832 | *
|
---|
833 | * The cross context pointer type is
|
---|
834 | *
|
---|
835 | * @{ */
|
---|
836 |
|
---|
837 | /**
|
---|
838 | * Cross context pointer base type.
|
---|
839 | */
|
---|
840 | #pragma pack(4)
|
---|
841 | typedef union BS3XPTR
|
---|
842 | {
|
---|
843 | /** The flat pointer. */
|
---|
844 | uint32_t uFlat;
|
---|
845 | /** 16-bit view. */
|
---|
846 | struct
|
---|
847 | {
|
---|
848 | uint16_t uLow;
|
---|
849 | uint16_t uHigh;
|
---|
850 | } u;
|
---|
851 | #if ARCH_BITS == 16
|
---|
852 | /** 16-bit near pointer. */
|
---|
853 | void __near *pvNear;
|
---|
854 | #elif ARCH_BITS == 32
|
---|
855 | /** 32-bit pointer. */
|
---|
856 | void *pvRaw;
|
---|
857 | #endif
|
---|
858 | } BS3XPTR;
|
---|
859 | #pragma pack()
|
---|
860 |
|
---|
861 |
|
---|
862 | /** @def BS3_XPTR_DEF_INTERNAL
|
---|
863 | * Internal worker.
|
---|
864 | *
|
---|
865 | * @param a_Scope RT_NOTHING if structure or global, static or extern
|
---|
866 | * otherwise.
|
---|
867 | * @param a_Type The type we're pointing to.
|
---|
868 | * @param a_Name The member or variable name.
|
---|
869 | * @internal
|
---|
870 | */
|
---|
871 | #if ARCH_BITS == 16
|
---|
872 | # define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
|
---|
873 | a_Scope union \
|
---|
874 | { \
|
---|
875 | BS3XPTR XPtr; \
|
---|
876 | a_Type __near *pNearTyped; \
|
---|
877 | } a_Name
|
---|
878 | #elif ARCH_BITS == 32
|
---|
879 | # define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
|
---|
880 | a_Scope union \
|
---|
881 | { \
|
---|
882 | BS3XPTR XPtr; \
|
---|
883 | a_Type *pTyped; \
|
---|
884 | } a_Name
|
---|
885 | #elif ARCH_BITS == 64
|
---|
886 | # define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
|
---|
887 | a_Scope union \
|
---|
888 | { \
|
---|
889 | BS3XPTR XPtr; \
|
---|
890 | a_Type *pTyped; \
|
---|
891 | } a_Name
|
---|
892 | #else
|
---|
893 | # error "ARCH_BITS"
|
---|
894 | #endif
|
---|
895 |
|
---|
896 | /** @def BS3_XPTR_DEF_MEMBER
|
---|
897 | * Defines a pointer member that can be shared by all CPU modes.
|
---|
898 | *
|
---|
899 | * @param a_Type The type we're pointing to.
|
---|
900 | * @param a_Name The member or variable name.
|
---|
901 | */
|
---|
902 | #define BS3_XPTR_MEMBER(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name)
|
---|
903 |
|
---|
904 | /** @def BS3_XPTR_DEF_AUTO
|
---|
905 | * Defines a pointer static variable for working with an XPTR.
|
---|
906 | *
|
---|
907 | * This is typically used to convert flat pointers into context specific
|
---|
908 | * pointers.
|
---|
909 | *
|
---|
910 | * @param a_Type The type we're pointing to.
|
---|
911 | * @param a_Name The member or variable name.
|
---|
912 | */
|
---|
913 | #define BS3_XPTR_AUTO(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name)
|
---|
914 |
|
---|
915 | /** @def BS3_XPTR_SET
|
---|
916 | * Sets a cross context pointer.
|
---|
917 | *
|
---|
918 | * @param a_Type The type we're pointing to.
|
---|
919 | * @param a_Name The member or variable name.
|
---|
920 | * @param a_uFlatPtr The flat pointer value to assign. If the x-pointer is
|
---|
921 | * used in real mode, this must be less than 1MB.
|
---|
922 | * Otherwise the limit is 16MB (due to selector tiling).
|
---|
923 | */
|
---|
924 | #define BS3_XPTR_SET_FLAT(a_Type, a_Name, a_uFlatPtr) \
|
---|
925 | do { a_Name.XPtr.uFlat = (a_uFlatPtr); } while (0)
|
---|
926 |
|
---|
927 | /** @def BS3_XPTR_GET_FLAT
|
---|
928 | * Gets the flat address of a cross context pointer.
|
---|
929 | *
|
---|
930 | * @returns 32-bit flat pointer.
|
---|
931 | * @param a_Type The type we're pointing to.
|
---|
932 | * @param a_Name The member or variable name.
|
---|
933 | */
|
---|
934 | #define BS3_XPTR_GET_FLAT(a_Type, a_Name) (a_Name.XPtr.uFlat)
|
---|
935 |
|
---|
936 | /** @def BS3_XPTR_GET_FLAT_LOW
|
---|
937 | * Gets the low 16 bits of the flat address.
|
---|
938 | *
|
---|
939 | * @returns Low 16 bits of the flat pointer.
|
---|
940 | * @param a_Type The type we're pointing to.
|
---|
941 | * @param a_Name The member or variable name.
|
---|
942 | */
|
---|
943 | #define BS3_XPTR_GET_FLAT_LOW(a_Type, a_Name) (a_Name.XPtr.u.uLow)
|
---|
944 |
|
---|
945 |
|
---|
946 | #if ARCH_BITS == 16
|
---|
947 |
|
---|
948 | /**
|
---|
949 | * Gets the current ring number.
|
---|
950 | * @returns Ring number.
|
---|
951 | */
|
---|
952 | DECLINLINE(uint16_t) Bs3Sel16GetCurRing(void);
|
---|
953 | # pragma aux Bs3Sel16GetCurRing = \
|
---|
954 | "mov ax, ss" \
|
---|
955 | "and ax, 3" \
|
---|
956 | value [ax] modify exact [ax] nomemory;
|
---|
957 |
|
---|
958 | /**
|
---|
959 | * Converts the high word of a flat pointer into a 16-bit selector.
|
---|
960 | *
|
---|
961 | * This makes use of the tiled area. It also handles real mode.
|
---|
962 | *
|
---|
963 | * @returns Segment selector value.
|
---|
964 | * @param uHigh The high part of flat pointer.
|
---|
965 | * @sa BS3_XPTR_GET, BS3_XPTR_SET
|
---|
966 | */
|
---|
967 | DECLINLINE(__segment) Bs3Sel16HighFlatPtrToSelector(uint16_t uHigh)
|
---|
968 | {
|
---|
969 | if (BS3_IS_PROTECTED_MODE())
|
---|
970 | return (__segment)(((uHigh << 3) + BS3_SEL_TILED) | Bs3Sel16GetCurRing());
|
---|
971 | return (__segment)(uHigh << 12);
|
---|
972 | }
|
---|
973 |
|
---|
974 | #endif /* ARCH_BITS == 16*/
|
---|
975 |
|
---|
976 | /** @def BS3_XPTR_GET
|
---|
977 | * Gets the current context pointer value.
|
---|
978 | *
|
---|
979 | * @returns Usable pointer.
|
---|
980 | * @param a_Type The type we're pointing to.
|
---|
981 | * @param a_Name The member or variable name.
|
---|
982 | */
|
---|
983 | #if ARCH_BITS == 16
|
---|
984 | # define BS3_XPTR_GET(a_Type, a_Name) \
|
---|
985 | ((a_Type BS3_FAR *)BS3_FP_MAKE(Bs3Sel16HighFlatPtrToSelector((a_Name).XPtr.u.uHigh), (a_Name).pNearTyped))
|
---|
986 | #elif ARCH_BITS == 32
|
---|
987 | # define BS3_XPTR_GET(a_Type, a_Name) ((a_Name).pTyped)
|
---|
988 | #elif ARCH_BITS == 64
|
---|
989 | # define BS3_XPTR_GET(a_Type, a_Name) ((a_Type *)(uintptr_t)(a_Name).XPtr.uFlat)
|
---|
990 | #else
|
---|
991 | # error "ARCH_BITS"
|
---|
992 | #endif
|
---|
993 |
|
---|
994 | /** @def BS3_XPTR_SET
|
---|
995 | * Gets the current context pointer value.
|
---|
996 | *
|
---|
997 | * @returns Usable pointer.
|
---|
998 | * @param a_Type The type we're pointing to.
|
---|
999 | * @param a_Name The member or variable name.
|
---|
1000 | * @param a_pValue The new pointer value, current context pointer.
|
---|
1001 | */
|
---|
1002 | #if ARCH_BITS == 16
|
---|
1003 | # define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
|
---|
1004 | do { \
|
---|
1005 | a_Type BS3_FAR *pTypeCheck = (a_pValue); \
|
---|
1006 | if (BS3_IS_PROTECTED_MODE()) \
|
---|
1007 | { \
|
---|
1008 | (a_Name).XPtr.u.uLow = BS3_FP_OFF(pTypeCheck); \
|
---|
1009 | (a_Name).XPtr.u.uHigh = ((BS3_FP_SEG(pTypeCheck) & UINT16_C(0xfff8)) - BS3_SEL_TILED) >> 3; \
|
---|
1010 | } \
|
---|
1011 | else \
|
---|
1012 | (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \
|
---|
1013 | } while (0)
|
---|
1014 | #elif ARCH_BITS == 32
|
---|
1015 | # define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
|
---|
1016 | do { (a_Name).pTyped = (a_pValue); } while (0)
|
---|
1017 | #elif ARCH_BITS == 64
|
---|
1018 | # define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
|
---|
1019 | do { \
|
---|
1020 | a_Type *pTypeCheck = (a_pValue); \
|
---|
1021 | (a_Name).XPtr.uFlat = (uint32_t)(uintptr_t)pTypeCheck; \
|
---|
1022 | } while (0)
|
---|
1023 | #else
|
---|
1024 | # error "ARCH_BITS"
|
---|
1025 | #endif
|
---|
1026 |
|
---|
1027 |
|
---|
1028 | /** @def BS3_XPTR_IS_NULL
|
---|
1029 | * Checks if the cross context pointer is NULL.
|
---|
1030 | *
|
---|
1031 | * @returns true if NULL, false if not.
|
---|
1032 | * @param a_Type The type we're pointing to.
|
---|
1033 | * @param a_Name The member or variable name.
|
---|
1034 | */
|
---|
1035 | #define BS3_XPTR_IS_NULL(a_Type, a_Name) ((a_Name).XPtr.uFlat == 0)
|
---|
1036 | /** @} */
|
---|
1037 |
|
---|
1038 |
|
---|
1039 |
|
---|
1040 | /** @defgroup grp_bs3kit_cmn Common Functions and Data
|
---|
1041 | *
|
---|
1042 | * The common functions comes in three variations: 16-bit, 32-bit and 64-bit.
|
---|
1043 | * Templated code uses the #BS3_CMN_NM macro to mangle the name according to the
|
---|
1044 | * desired
|
---|
1045 | *
|
---|
1046 | * @{
|
---|
1047 | */
|
---|
1048 |
|
---|
1049 | #ifdef BS3_STRICT
|
---|
1050 | # define BS3_ASSERT(a_Expr) do { if (!!(a_Expr)) { /* likely */ } else { Bs3Panic(); } } while (0) /**< @todo later */
|
---|
1051 | #else
|
---|
1052 | # define BS3_ASSERT(a_Expr) do { } while (0)
|
---|
1053 | #endif
|
---|
1054 |
|
---|
1055 | /**
|
---|
1056 | * Panic, never return.
|
---|
1057 | *
|
---|
1058 | * The current implementation will only halt the CPU.
|
---|
1059 | */
|
---|
1060 | BS3_DECL(void) Bs3Panic_c16(void);
|
---|
1061 | BS3_DECL(void) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16 */
|
---|
1062 | BS3_DECL(void) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16 */
|
---|
1063 | #define Bs3Panic BS3_CMN_NM(Bs3Panic) /**< Selects #Bs3Panic_c16, #Bs3Panic_c32 or #Bs3Panic_c64. */
|
---|
1064 |
|
---|
1065 | /**
|
---|
1066 | * Shutdown the system, never returns.
|
---|
1067 | *
|
---|
1068 | * This currently only works for VMs. When running on real systems it will
|
---|
1069 | * just halt the CPU.
|
---|
1070 | */
|
---|
1071 | BS3_DECL(void) Bs3Shutdown_c16(void);
|
---|
1072 | BS3_DECL(void) Bs3Shutdown_c32(void); /**< @copydoc Bs3Shutdown_c16 */
|
---|
1073 | BS3_DECL(void) Bs3Shutdown_c64(void); /**< @copydoc Bs3Shutdown_c16 */
|
---|
1074 | #define Bs3Shutdown BS3_CMN_NM(Bs3Shutdown) /**< Selects #Bs3Shutdown_c16, #Bs3Shutdown_c32 or #Bs3Shutdown_c64. */
|
---|
1075 |
|
---|
1076 | /**
|
---|
1077 | * Prints a 32-bit unsigned value as decimal to the screen.
|
---|
1078 | *
|
---|
1079 | * @param uValue The 32-bit value.
|
---|
1080 | */
|
---|
1081 | BS3_DECL(void) Bs3PrintU32_c16(uint32_t uValue);
|
---|
1082 | BS3_DECL(void) Bs3PrintU32_c32(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
|
---|
1083 | BS3_DECL(void) Bs3PrintU32_c64(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
|
---|
1084 | #define Bs3PrintU32 BS3_CMN_NM(Bs3PrintU32) /**< Selects #Bs3PrintU32_c16, #Bs3PrintU32_c32 or #Bs3PrintU32_c64. */
|
---|
1085 |
|
---|
1086 | /**
|
---|
1087 | * Prints a 32-bit unsigned value as hex to the screen.
|
---|
1088 | *
|
---|
1089 | * @param uValue The 32-bit value.
|
---|
1090 | */
|
---|
1091 | BS3_DECL(void) Bs3PrintX32_c16(uint32_t uValue);
|
---|
1092 | BS3_DECL(void) Bs3PrintX32_c32(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */
|
---|
1093 | BS3_DECL(void) Bs3PrintX32_c64(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */
|
---|
1094 | #define Bs3PrintX32 BS3_CMN_NM(Bs3PrintX32) /**< Selects #Bs3PrintX32_c16, #Bs3PrintX32_c32 or #Bs3PrintX32_c64. */
|
---|
1095 |
|
---|
1096 | /**
|
---|
1097 | * Formats and prints a string to the screen.
|
---|
1098 | *
|
---|
1099 | * See #Bs3StrFormatV_c16 for supported format types.
|
---|
1100 | *
|
---|
1101 | * @param pszFormat The format string.
|
---|
1102 | * @param ... Format arguments.
|
---|
1103 | */
|
---|
1104 | BS3_DECL(size_t) Bs3Printf_c16(const char BS3_FAR *pszFormat, ...);
|
---|
1105 | BS3_DECL(size_t) Bs3Printf_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3Printf_c16 */
|
---|
1106 | BS3_DECL(size_t) Bs3Printf_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3Printf_c16 */
|
---|
1107 | #define Bs3Printf BS3_CMN_NM(Bs3Printf) /**< Selects #Bs3Printf_c16, #Bs3Printf_c32 or #Bs3Printf_c64. */
|
---|
1108 |
|
---|
1109 | /**
|
---|
1110 | * Formats and prints a string to the screen, va_list version.
|
---|
1111 | *
|
---|
1112 | * See #Bs3Format_c16 for supported format types.
|
---|
1113 | *
|
---|
1114 | * @param pszFormat The format string.
|
---|
1115 | * @param va Format arguments.
|
---|
1116 | */
|
---|
1117 | BS3_DECL(size_t) Bs3PrintfV_c16(const char BS3_FAR *pszFormat, va_list va);
|
---|
1118 | BS3_DECL(size_t) Bs3PrintfV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3PrintfV_c16 */
|
---|
1119 | BS3_DECL(size_t) Bs3PrintfV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3PrintfV_c16 */
|
---|
1120 | #define Bs3PrintfV BS3_CMN_NM(Bs3PrintfV) /**< Selects #Bs3PrintfV_c16, #Bs3PrintfV_c32 or #Bs3PrintfV_c64. */
|
---|
1121 |
|
---|
1122 | /**
|
---|
1123 | * Prints a string to the screen.
|
---|
1124 | *
|
---|
1125 | * @param pszString The string to print.
|
---|
1126 | */
|
---|
1127 | BS3_DECL(void) Bs3PrintStr_c16(const char BS3_FAR *pszString);
|
---|
1128 | BS3_DECL(void) Bs3PrintStr_c32(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
|
---|
1129 | BS3_DECL(void) Bs3PrintStr_c64(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
|
---|
1130 | #define Bs3PrintStr BS3_CMN_NM(Bs3PrintStr) /**< Selects #Bs3PrintStr_c16, #Bs3PrintStr_c32 or #Bs3PrintStr_c64. */
|
---|
1131 |
|
---|
1132 | /**
|
---|
1133 | * Prints a char to the screen.
|
---|
1134 | *
|
---|
1135 | * @param ch The character to print.
|
---|
1136 | */
|
---|
1137 | BS3_DECL(void) Bs3PrintChr_c16(char ch);
|
---|
1138 | BS3_DECL(void) Bs3PrintChr_c32(char ch); /**< @copydoc Bs3PrintChr_c16 */
|
---|
1139 | BS3_DECL(void) Bs3PrintChr_c64(char ch); /**< @copydoc Bs3PrintChr_c16 */
|
---|
1140 | #define Bs3PrintChr BS3_CMN_NM(Bs3PrintChr) /**< Selects #Bs3PrintChr_c16, #Bs3PrintChr_c32 or #Bs3PrintChr_c64. */
|
---|
1141 |
|
---|
1142 |
|
---|
1143 | /**
|
---|
1144 | * An output function for #Bs3StrFormatV.
|
---|
1145 | *
|
---|
1146 | * @returns Number of characters written.
|
---|
1147 | * @param ch The character to write. Zero in the final call.
|
---|
1148 | * @param pvUser User argument supplied to #Bs3StrFormatV.
|
---|
1149 | */
|
---|
1150 | typedef BS3_DECL_CALLBACK(size_t) FNBS3STRFORMATOUTPUT(char ch, void BS3_FAR *pvUser);
|
---|
1151 | /** Pointer to an output function for #Bs3StrFormatV. */
|
---|
1152 | typedef FNBS3STRFORMATOUTPUT *PFNBS3STRFORMATOUTPUT;
|
---|
1153 |
|
---|
1154 | /**
|
---|
1155 | * Formats a string, sending the output to @a pfnOutput.
|
---|
1156 | *
|
---|
1157 | * Supported types:
|
---|
1158 | * - %RI8, %RI16, %RI32, %RI64
|
---|
1159 | * - %RU8, %RU16, %RU32, %RU64
|
---|
1160 | * - %RX8, %RX16, %RX32, %RX64
|
---|
1161 | * - %i, %d
|
---|
1162 | * - %u
|
---|
1163 | * - %x
|
---|
1164 | * - %c
|
---|
1165 | * - %p (far pointer)
|
---|
1166 | * - %s (far pointer)
|
---|
1167 | *
|
---|
1168 | * @returns Sum of @a pfnOutput return values.
|
---|
1169 | * @param pszFormat The format string.
|
---|
1170 | * @param va Format arguments.
|
---|
1171 | * @param pfnOutput The output function.
|
---|
1172 | * @param pvUser The user argument for the output function.
|
---|
1173 | */
|
---|
1174 | BS3_DECL(size_t) Bs3StrFormatV_c16(const char BS3_FAR *pszFormat, va_list va,
|
---|
1175 | PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
|
---|
1176 | /** @copydoc Bs3StrFormatV_c16 */
|
---|
1177 | BS3_DECL(size_t) Bs3StrFormatV_c32(const char BS3_FAR *pszFormat, va_list va,
|
---|
1178 | PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
|
---|
1179 | /** @copydoc Bs3StrFormatV_c16 */
|
---|
1180 | BS3_DECL(size_t) Bs3StrFormatV_c64(const char BS3_FAR *pszFormat, va_list va,
|
---|
1181 | PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
|
---|
1182 | #define Bs3StrFormatV BS3_CMN_NM(Bs3StrFormatV) /**< Selects #Bs3StrFormatV_c16, #Bs3StrFormatV_c32 or #Bs3StrFormatV_c64. */
|
---|
1183 |
|
---|
1184 | /**
|
---|
1185 | * Formats a string into a buffer.
|
---|
1186 | *
|
---|
1187 | * See #Bs3Format_c16 for supported format types.
|
---|
1188 | *
|
---|
1189 | * @returns The length of the formatted string (excluding terminator).
|
---|
1190 | * This will be higher or equal to @c cbBuf in case of an overflow.
|
---|
1191 | * @param pszBuf The output buffer.
|
---|
1192 | * @param cbBuf The size of the output buffer.
|
---|
1193 | * @param pszFormat The format string.
|
---|
1194 | * @param va Format arguments.
|
---|
1195 | */
|
---|
1196 | BS3_DECL(size_t) Bs3StrPrintfV_c16(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
|
---|
1197 | /** @copydoc Bs3StrPrintfV_c16 */
|
---|
1198 | BS3_DECL(size_t) Bs3StrPrintfV_c32(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
|
---|
1199 | /** @copydoc Bs3StrPrintfV_c16 */
|
---|
1200 | BS3_DECL(size_t) Bs3StrPrintfV_c64(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
|
---|
1201 | #define Bs3StrPrintfV BS3_CMN_NM(Bs3StrPrintfV) /**< Selects #Bs3StrPrintfV_c16, #Bs3StrPrintfV_c32 or #Bs3StrPrintfV_c64. */
|
---|
1202 |
|
---|
1203 | /**
|
---|
1204 | * Formats a string into a buffer.
|
---|
1205 | *
|
---|
1206 | * See #Bs3Format_c16 for supported format types.
|
---|
1207 | *
|
---|
1208 | * @returns The length of the formatted string (excluding terminator).
|
---|
1209 | * This will be higher or equal to @c cbBuf in case of an overflow.
|
---|
1210 | * @param pszBuf The output buffer.
|
---|
1211 | * @param cbBuf The size of the output buffer.
|
---|
1212 | * @param pszFormat The format string.
|
---|
1213 | * @param ... Format arguments.
|
---|
1214 | */
|
---|
1215 | BS3_DECL(size_t) Bs3StrPrintf_c16(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
|
---|
1216 | /** @copydoc Bs3StrPrintf_c16 */
|
---|
1217 | BS3_DECL(size_t) Bs3StrPrintf_c32(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
|
---|
1218 | /** @copydoc Bs3StrPrintf_c16 */
|
---|
1219 | BS3_DECL(size_t) Bs3StrPrintf_c64(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
|
---|
1220 | #define Bs3StrPrintf BS3_CMN_NM(Bs3StrPrintf) /**< Selects #Bs3StrPrintf_c16, #Bs3StrPrintf_c32 or #Bs3StrPrintf_c64. */
|
---|
1221 |
|
---|
1222 |
|
---|
1223 | /**
|
---|
1224 | * Finds the length of a zero terminated string.
|
---|
1225 | *
|
---|
1226 | * @returns String length in chars/bytes.
|
---|
1227 | * @param pszString The string to examine.
|
---|
1228 | */
|
---|
1229 | BS3_DECL(size_t) Bs3StrLen_c16(const char BS3_FAR *pszString);
|
---|
1230 | BS3_DECL(size_t) Bs3StrLen_c32(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
|
---|
1231 | BS3_DECL(size_t) Bs3StrLen_c64(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
|
---|
1232 | #define Bs3StrLen BS3_CMN_NM(Bs3StrLen) /**< Selects #Bs3StrLen_c16, #Bs3StrLen_c32 or #Bs3StrLen_c64. */
|
---|
1233 |
|
---|
1234 | /**
|
---|
1235 | * Finds the length of a zero terminated string, but with a max length.
|
---|
1236 | *
|
---|
1237 | * @returns String length in chars/bytes, or @a cchMax if no zero-terminator
|
---|
1238 | * was found before we reached the limit.
|
---|
1239 | * @param pszString The string to examine.
|
---|
1240 | * @param cchMax The max length to examine.
|
---|
1241 | */
|
---|
1242 | BS3_DECL(size_t) Bs3StrNLen_c16(const char BS3_FAR *pszString, size_t cchMax);
|
---|
1243 | BS3_DECL(size_t) Bs3StrNLen_c32(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
|
---|
1244 | BS3_DECL(size_t) Bs3StrNLen_c64(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
|
---|
1245 | #define Bs3StrNLen BS3_CMN_NM(Bs3StrNLen) /**< Selects #Bs3StrNLen_c16, #Bs3StrNLen_c32 or #Bs3StrNLen_c64. */
|
---|
1246 |
|
---|
1247 | /**
|
---|
1248 | * CRT style unsafe strcpy.
|
---|
1249 | *
|
---|
1250 | * @returns pszDst.
|
---|
1251 | * @param pszDst The destination buffer. Must be large enough to
|
---|
1252 | * hold the source string.
|
---|
1253 | * @param pszSrc The source string.
|
---|
1254 | */
|
---|
1255 | BS3_DECL(char BS3_FAR *) Bs3StrCpy_c16(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc);
|
---|
1256 | BS3_DECL(char BS3_FAR *) Bs3StrCpy_c32(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
|
---|
1257 | BS3_DECL(char BS3_FAR *) Bs3StrCpy_c64(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
|
---|
1258 | #define Bs3StrCpy BS3_CMN_NM(Bs3StrCpy) /**< Selects #Bs3StrCpy_c16, #Bs3StrCpy_c32 or #Bs3StrCpy_c64. */
|
---|
1259 |
|
---|
1260 | /**
|
---|
1261 | * CRT style memcpy.
|
---|
1262 | *
|
---|
1263 | * @returns pvDst
|
---|
1264 | * @param pvDst The destination buffer.
|
---|
1265 | * @param pvSrc The source buffer.
|
---|
1266 | * @param cbCopy The number of bytes to copy.
|
---|
1267 | */
|
---|
1268 | BS3_DECL(void BS3_FAR *) Bs3MemCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
|
---|
1269 | BS3_DECL(void BS3_FAR *) Bs3MemCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
|
---|
1270 | BS3_DECL(void BS3_FAR *) Bs3MemCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
|
---|
1271 | #define Bs3MemCpy BS3_CMN_NM(Bs3MemCpy) /**< Selects #Bs3MemCpy_c16, #Bs3MemCpy_c32 or #Bs3MemCpy_c64. */
|
---|
1272 |
|
---|
1273 | /**
|
---|
1274 | * GNU (?) style mempcpy.
|
---|
1275 | *
|
---|
1276 | * @returns pvDst + cbCopy
|
---|
1277 | * @param pvDst The destination buffer.
|
---|
1278 | * @param pvSrc The source buffer.
|
---|
1279 | * @param cbCopy The number of bytes to copy.
|
---|
1280 | */
|
---|
1281 | BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
|
---|
1282 | BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
|
---|
1283 | BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
|
---|
1284 | #define Bs3MemPCpy BS3_CMN_NM(Bs3MemPCpy) /**< Selects #Bs3MemPCpy_c16, #Bs3MemPCpy_c32 or #Bs3MemPCpy_c64. */
|
---|
1285 |
|
---|
1286 | /**
|
---|
1287 | * CRT style memmove (overlapping buffers is fine).
|
---|
1288 | *
|
---|
1289 | * @returns pvDst
|
---|
1290 | * @param pvDst The destination buffer.
|
---|
1291 | * @param pvSrc The source buffer.
|
---|
1292 | * @param cbCopy The number of bytes to copy.
|
---|
1293 | */
|
---|
1294 | BS3_DECL(void BS3_FAR *) Bs3MemMove_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
|
---|
1295 | BS3_DECL(void BS3_FAR *) Bs3MemMove_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
|
---|
1296 | BS3_DECL(void BS3_FAR *) Bs3MemMove_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
|
---|
1297 | #define Bs3MemMove BS3_CMN_NM(Bs3MemMove) /**< Selects #Bs3MemMove_c16, #Bs3MemMove_c32 or #Bs3MemMove_c64. */
|
---|
1298 |
|
---|
1299 | /**
|
---|
1300 | * BSD style bzero.
|
---|
1301 | *
|
---|
1302 | * @param pvDst The buffer to be zeroed.
|
---|
1303 | * @param cbDst The number of bytes to zero.
|
---|
1304 | */
|
---|
1305 | BS3_DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);
|
---|
1306 | BS3_DECL(void) Bs3MemZero_c32(void BS3_FAR *pvDst, size_t cbDst); /** @copydoc Bs3MemZero_c16 */
|
---|
1307 | BS3_DECL(void) Bs3MemZero_c64(void BS3_FAR *pvDst, size_t cbDst); /** @copydoc Bs3MemZero_c16 */
|
---|
1308 | #define Bs3MemZero BS3_CMN_NM(Bs3MemZero) /**< Selects #Bs3MemZero_c16, #Bs3MemZero_c32 or #Bs3MemZero_c64. */
|
---|
1309 |
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | /**
|
---|
1313 | * Equivalent to RTTestCreate + RTTestBanner.
|
---|
1314 | *
|
---|
1315 | * @param pszTest The test name.
|
---|
1316 | */
|
---|
1317 | BS3_DECL(void) Bs3TestInit_c16(const char BS3_FAR *pszTest);
|
---|
1318 | BS3_DECL(void) Bs3TestInit_c32(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
|
---|
1319 | BS3_DECL(void) Bs3TestInit_c64(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
|
---|
1320 | #define Bs3TestInit BS3_CMN_NM(Bs3TestInit) /**< Selects #Bs3TestInit_c16, #Bs3TestInit_c32 or #Bs3TestInit_c64. */
|
---|
1321 |
|
---|
1322 |
|
---|
1323 | /**
|
---|
1324 | * Equivalent to RTTestSummaryAndDestroy.
|
---|
1325 | */
|
---|
1326 | BS3_DECL(void) Bs3TestTerm_c16(void);
|
---|
1327 | BS3_DECL(void) Bs3TestTerm_c32(void); /**< @copydoc Bs3TestTerm_c16 */
|
---|
1328 | BS3_DECL(void) Bs3TestTerm_c64(void); /**< @copydoc Bs3TestTerm_c16 */
|
---|
1329 | #define Bs3TestTerm BS3_CMN_NM(Bs3TestTerm) /**< Selects #Bs3TestTerm_c16, #Bs3TestTerm_c32 or #Bs3TestTerm_c64. */
|
---|
1330 |
|
---|
1331 | /**
|
---|
1332 | * Equivalent to RTTestISub.
|
---|
1333 | */
|
---|
1334 | BS3_DECL(void) Bs3TestSub_c16(const char BS3_FAR *pszSubTest);
|
---|
1335 | BS3_DECL(void) Bs3TestSub_c32(const char BS3_FAR *pszSubTest); /**< @copydoc Bs3TestSub_c16 */
|
---|
1336 | BS3_DECL(void) Bs3TestSub_c64(const char BS3_FAR *pszSubTest); /**< @copydoc Bs3TestSub_c16 */
|
---|
1337 | #define Bs3TestSub BS3_CMN_NM(Bs3TestSub) /**< Selects #Bs3TestSub_c16, #Bs3TestSub_c32 or #Bs3TestSub_c64. */
|
---|
1338 |
|
---|
1339 | /**
|
---|
1340 | * Equivalent to RTTestIFailedF.
|
---|
1341 | */
|
---|
1342 | BS3_DECL(void) Bs3TestSubF_c16(const char BS3_FAR *pszFormat, ...);
|
---|
1343 | BS3_DECL(void) Bs3TestSubF_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSubF_c16 */
|
---|
1344 | BS3_DECL(void) Bs3TestSubF_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSubF_c16 */
|
---|
1345 | #define Bs3TestSubF BS3_CMN_NM(Bs3TestSubF) /**< Selects #Bs3TestSubF_c16, #Bs3TestSubF_c32 or #Bs3TestSubF_c64. */
|
---|
1346 |
|
---|
1347 | /**
|
---|
1348 | * Equivalent to RTTestISubV.
|
---|
1349 | */
|
---|
1350 | BS3_DECL(void) Bs3TestSubV_c16(const char BS3_FAR *pszFormat, va_list va);
|
---|
1351 | BS3_DECL(void) Bs3TestSubV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSubV_c16 */
|
---|
1352 | BS3_DECL(void) Bs3TestSubV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSubV_c16 */
|
---|
1353 | #define Bs3TestSubV BS3_CMN_NM(Bs3TestSubV) /**< Selects #Bs3TestSubV_c16, #Bs3TestSubV_c32 or #Bs3TestSubV_c64. */
|
---|
1354 |
|
---|
1355 | /**
|
---|
1356 | * Equivalent to RTTestISubDone.
|
---|
1357 | */
|
---|
1358 | BS3_DECL(void) Bs3TestSubDone_c16(void);
|
---|
1359 | BS3_DECL(void) Bs3TestSubDone_c32(void); /**< @copydoc Bs3TestSubDone_c16 */
|
---|
1360 | BS3_DECL(void) Bs3TestSubDone_c64(void); /**< @copydoc Bs3TestSubDone_c16 */
|
---|
1361 | #define Bs3TestSubDone BS3_CMN_NM(Bs3TestSubDone) /**< Selects #Bs3TestSubDone_c16, #Bs3TestSubDone_c32 or #Bs3TestSubDone_c64. */
|
---|
1362 |
|
---|
1363 | /**
|
---|
1364 | * Equivalent to RTTestSubErrorCount.
|
---|
1365 | */
|
---|
1366 | BS3_DECL(uint16_t) Bs3TestSubErrorCount_c16(void);
|
---|
1367 | BS3_DECL(uint16_t) Bs3TestSubErrorCount_c32(void); /**< @copydoc Bs3TestSubErrorCount_c16 */
|
---|
1368 | BS3_DECL(uint16_t) Bs3TestSubErrorCount_c64(void); /**< @copydoc Bs3TestSubErrorCount_c16 */
|
---|
1369 | #define Bs3TestSubErrorCount BS3_CMN_NM(Bs3TestSubErrorCount) /**< Selects #Bs3TestSubErrorCount_c16, #Bs3TestSubErrorCount_c32 or #Bs3TestSubErrorCount_c64. */
|
---|
1370 |
|
---|
1371 | /**
|
---|
1372 | * Equivalent to RTTestIFailed.
|
---|
1373 | */
|
---|
1374 | BS3_DECL(void) Bs3TestFailed_c16(const char BS3_FAR *pszMessage);
|
---|
1375 | BS3_DECL(void) Bs3TestFailed_c32(const char BS3_FAR *pszMessage); /**< @copydoc Bs3TestFailed_c16 */
|
---|
1376 | BS3_DECL(void) Bs3TestFailed_c64(const char BS3_FAR *pszMessage); /**< @copydoc Bs3TestFailed_c16 */
|
---|
1377 | #define Bs3TestFailed BS3_CMN_NM(Bs3TestFailed) /**< Selects #Bs3TestFailed_c16, #Bs3TestFailed_c32 or #Bs3TestFailed_c64. */
|
---|
1378 |
|
---|
1379 | /**
|
---|
1380 | * Equivalent to RTTestIFailedF.
|
---|
1381 | */
|
---|
1382 | BS3_DECL(void) Bs3TestFailedF_c16(const char BS3_FAR *pszFormat, ...);
|
---|
1383 | BS3_DECL(void) Bs3TestFailedF_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestFailedF_c16 */
|
---|
1384 | BS3_DECL(void) Bs3TestFailedF_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestFailedF_c16 */
|
---|
1385 | #define Bs3TestFailedF BS3_CMN_NM(Bs3TestFailedF) /**< Selects #Bs3TestFailedF_c16, #Bs3TestFailedF_c32 or #Bs3TestFailedF_c64. */
|
---|
1386 |
|
---|
1387 | /**
|
---|
1388 | * Equivalent to RTTestIFailedV.
|
---|
1389 | */
|
---|
1390 | BS3_DECL(void) Bs3TestFailedV_c16(const char BS3_FAR *pszFormat, va_list va);
|
---|
1391 | BS3_DECL(void) Bs3TestFailedV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestFailedV_c16 */
|
---|
1392 | BS3_DECL(void) Bs3TestFailedV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestFailedV_c16 */
|
---|
1393 | #define Bs3TestFailedV BS3_CMN_NM(Bs3TestFailedV) /**< Selects #Bs3TestFailedV_c16, #Bs3TestFailedV_c32 or #Bs3TestFailedV_c64. */
|
---|
1394 |
|
---|
1395 | /**
|
---|
1396 | * Equivalent to RTTestISkipped.
|
---|
1397 | *
|
---|
1398 | * @param pszWhy Optional reason why it's being skipped.
|
---|
1399 | */
|
---|
1400 | BS3_DECL(void) Bs3TestSkipped_c16(const char BS3_FAR *pszWhy);
|
---|
1401 | BS3_DECL(void) Bs3TestSkipped_c32(const char BS3_FAR *pszWhy); /**< @copydoc Bs3TestSkipped_c16 */
|
---|
1402 | BS3_DECL(void) Bs3TestSkipped_c64(const char BS3_FAR *pszWhy); /**< @copydoc Bs3TestSkipped_c16 */
|
---|
1403 | #define Bs3TestSkipped BS3_CMN_NM(Bs3TestSkipped) /**< Selects #Bs3TestSkipped_c16, #Bs3TestSkipped_c32 or #Bs3TestSkipped_c64. */
|
---|
1404 |
|
---|
1405 | /**
|
---|
1406 | * Equivalent to RTTestISkippedF.
|
---|
1407 | *
|
---|
1408 | * @param pszFormat Optional reason why it's being skipped.
|
---|
1409 | * @param ... Format arguments.
|
---|
1410 | */
|
---|
1411 | BS3_DECL(void) Bs3TestSkippedF_c16(const char BS3_FAR *pszFormat, ...);
|
---|
1412 | BS3_DECL(void) Bs3TestSkippedF_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSkippedF_c16 */
|
---|
1413 | BS3_DECL(void) Bs3TestSkippedF_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3TestSkippedF_c16 */
|
---|
1414 | #define Bs3TestSkippedF BS3_CMN_NM(Bs3TestSkippedF) /**< Selects #Bs3TestSkippedF_c16, #Bs3TestSkippedF_c32 or #Bs3TestSkippedF_c64. */
|
---|
1415 |
|
---|
1416 | /**
|
---|
1417 | * Equivalent to RTTestISkippedV.
|
---|
1418 | *
|
---|
1419 | * @param pszFormat Optional reason why it's being skipped.
|
---|
1420 | * @param va Format arguments.
|
---|
1421 | */
|
---|
1422 | BS3_DECL(void) Bs3TestSkippedV_c16(const char BS3_FAR *pszFormat, va_list va);
|
---|
1423 | BS3_DECL(void) Bs3TestSkippedV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSkippedV_c16 */
|
---|
1424 | BS3_DECL(void) Bs3TestSkippedV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3TestSkippedV_c16 */
|
---|
1425 | #define Bs3TestSkippedV BS3_CMN_NM(Bs3TestSkippedV) /**< Selects #Bs3TestSkippedV_c16, #Bs3TestSkippedV_c32 or #Bs3TestSkippedV_c64. */
|
---|
1426 |
|
---|
1427 |
|
---|
1428 | /**
|
---|
1429 | * Performs the testing for the given mode.
|
---|
1430 | *
|
---|
1431 | * This is called with the CPU already switch to that mode.
|
---|
1432 | *
|
---|
1433 | * @returns 0 on success or directly Bs3TestFailed calls, non-zero to indicate
|
---|
1434 | * where the test when wrong.
|
---|
1435 | * @param bMode The current CPU mode.
|
---|
1436 | */
|
---|
1437 | typedef BS3_DECL_CALLBACK(uint8_t) FNBS3TESTDOMODE(uint8_t bMode);
|
---|
1438 | /** Near pointer to a test (for 16-bit code). */
|
---|
1439 | typedef FNBS3TESTDOMODE *PFNBS3TESTDOMODE;
|
---|
1440 | /** Far pointer to a test (for 32-bit and 64-bit code, will be flatten). */
|
---|
1441 | typedef FNBS3TESTDOMODE BS3_FAR_CODE *FPFNBS3TESTDOMODE;
|
---|
1442 |
|
---|
1443 | /**
|
---|
1444 | * Mode sub-test entry.
|
---|
1445 | *
|
---|
1446 | * This can only be passed around to functions with the same bit count, as it
|
---|
1447 | * contains function pointers. In 16-bit mode, the 16-bit pointers are near and
|
---|
1448 | * implies BS3TEXT16, whereas the 32-bit and 64-bit pointers are far real mode
|
---|
1449 | * addresses that will be converted to flat address prior to calling them.
|
---|
1450 | * Similarly, in 32-bit and 64-bit the addresses are all flat and the 16-bit
|
---|
1451 | * ones will be converted to BS3TEXT16 based addresses prior to calling.
|
---|
1452 | */
|
---|
1453 | typedef struct BS3TESTMODEENTRY
|
---|
1454 | {
|
---|
1455 | const char * BS3_FAR pszSubTest;
|
---|
1456 |
|
---|
1457 | PFNBS3TESTDOMODE pfnDoRM;
|
---|
1458 |
|
---|
1459 | PFNBS3TESTDOMODE pfnDoPE16;
|
---|
1460 | FPFNBS3TESTDOMODE pfnDoPE16_32;
|
---|
1461 | PFNBS3TESTDOMODE pfnDoPE16_V86;
|
---|
1462 | FPFNBS3TESTDOMODE pfnDoPE32;
|
---|
1463 | PFNBS3TESTDOMODE pfnDoPE32_16;
|
---|
1464 | PFNBS3TESTDOMODE pfnDoPEV86;
|
---|
1465 |
|
---|
1466 | PFNBS3TESTDOMODE pfnDoPP16;
|
---|
1467 | FPFNBS3TESTDOMODE pfnDoPP16_32;
|
---|
1468 | PFNBS3TESTDOMODE pfnDoPP16_V86;
|
---|
1469 | FPFNBS3TESTDOMODE pfnDoPP32;
|
---|
1470 | PFNBS3TESTDOMODE pfnDoPP32_16;
|
---|
1471 | PFNBS3TESTDOMODE pfnDoPPV86;
|
---|
1472 |
|
---|
1473 | PFNBS3TESTDOMODE pfnDoPAE16;
|
---|
1474 | FPFNBS3TESTDOMODE pfnDoPAE16_32;
|
---|
1475 | PFNBS3TESTDOMODE pfnDoPAE16_V86;
|
---|
1476 | FPFNBS3TESTDOMODE pfnDoPAE32;
|
---|
1477 | PFNBS3TESTDOMODE pfnDoPAE32_16;
|
---|
1478 | PFNBS3TESTDOMODE pfnDoPAEV86;
|
---|
1479 |
|
---|
1480 | PFNBS3TESTDOMODE pfnDoLM16;
|
---|
1481 | FPFNBS3TESTDOMODE pfnDoLM32;
|
---|
1482 | FPFNBS3TESTDOMODE pfnDoLM64;
|
---|
1483 |
|
---|
1484 | } BS3TESTMODEENTRY;
|
---|
1485 | /** Pointer to a mode sub-test entry. */
|
---|
1486 | typedef BS3TESTMODEENTRY const *PCBS3TESTMODEENTRY;
|
---|
1487 |
|
---|
1488 |
|
---|
1489 | /**
|
---|
1490 | * Slab control structure list head.
|
---|
1491 | *
|
---|
1492 | * The slabs on the list must all have the same chunk size.
|
---|
1493 | */
|
---|
1494 | typedef struct BS3SLABHEAD
|
---|
1495 | {
|
---|
1496 | /** Pointer to the first slab. */
|
---|
1497 | BS3_XPTR_MEMBER(struct BS3SLABCTL, pFirst);
|
---|
1498 | /** The allocation chunk size. */
|
---|
1499 | uint16_t cbChunk;
|
---|
1500 | /** Number of slabs in the list. */
|
---|
1501 | uint16_t cSlabs;
|
---|
1502 | /** Number of chunks in the list. */
|
---|
1503 | uint32_t cChunks;
|
---|
1504 | /** Number of free chunks. */
|
---|
1505 | uint32_t cFreeChunks;
|
---|
1506 | } BS3SLABHEAD;
|
---|
1507 | /** Pointer to a slab list head. */
|
---|
1508 | typedef BS3SLABHEAD BS3_FAR *PBS3SLABHEAD;
|
---|
1509 |
|
---|
1510 | /**
|
---|
1511 | * Allocation slab control structure.
|
---|
1512 | *
|
---|
1513 | * This may live at the start of the slab for 4KB slabs, while in a separate
|
---|
1514 | * static location for the larger ones.
|
---|
1515 | */
|
---|
1516 | typedef struct BS3SLABCTL
|
---|
1517 | {
|
---|
1518 | /** Pointer to the next slab control structure in this list. */
|
---|
1519 | BS3_XPTR_MEMBER(struct BS3SLABCTL, pNext);
|
---|
1520 | /** Pointer to the slab list head. */
|
---|
1521 | BS3_XPTR_MEMBER(BS3SLABHEAD, pHead);
|
---|
1522 | /** The base address of the slab. */
|
---|
1523 | BS3_XPTR_MEMBER(uint8_t, pbStart);
|
---|
1524 | /** Number of chunks in this slab. */
|
---|
1525 | uint16_t cChunks;
|
---|
1526 | /** Number of currently free chunks. */
|
---|
1527 | uint16_t cFreeChunks;
|
---|
1528 | /** The chunk size. */
|
---|
1529 | uint16_t cbChunk;
|
---|
1530 | /** The shift count corresponding to cbChunk.
|
---|
1531 | * This is for turning a chunk number into a byte offset and vice versa. */
|
---|
1532 | uint16_t cChunkShift;
|
---|
1533 | /** Bitmap where set bits indicates allocated blocks (variable size,
|
---|
1534 | * multiple of 4). */
|
---|
1535 | uint8_t bmAllocated[4];
|
---|
1536 | } BS3SLABCTL;
|
---|
1537 | /** Pointer to a bs3kit slab control structure. */
|
---|
1538 | typedef BS3SLABCTL BS3_FAR *PBS3SLABCTL;
|
---|
1539 |
|
---|
1540 | /** The chunks must all be in the same 16-bit segment tile. */
|
---|
1541 | #define BS3_SLAB_ALLOC_F_SAME_TILE UINT16_C(0x0001)
|
---|
1542 |
|
---|
1543 | /**
|
---|
1544 | * Initializes a slab.
|
---|
1545 | *
|
---|
1546 | * @param pSlabCtl The slab control structure to initialize.
|
---|
1547 | * @param cbSlabCtl The size of the slab control structure.
|
---|
1548 | * @param uFlatSlabPtr The base address of the slab.
|
---|
1549 | * @param cbSlab The size of the slab.
|
---|
1550 | * @param cbChunk The chunk size.
|
---|
1551 | */
|
---|
1552 | BS3_DECL(void) Bs3SlabInit_c16(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
|
---|
1553 | /** @copydoc Bs3SlabInit_c16 */
|
---|
1554 | BS3_DECL(void) Bs3SlabInit_c32(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
|
---|
1555 | /** @copydoc Bs3SlabInit_c16 */
|
---|
1556 | BS3_DECL(void) Bs3SlabInit_c64(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
|
---|
1557 | #define Bs3SlabInit BS3_CMN_NM(Bs3SlabInit) /**< Selects #Bs3SlabInit_c16, #Bs3SlabInit_c32 or #Bs3SlabInit_c64. */
|
---|
1558 |
|
---|
1559 | /**
|
---|
1560 | * Allocates one chunk from a slab.
|
---|
1561 | *
|
---|
1562 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
1563 | * @param pSlabCtl The slab constrol structure to allocate from.
|
---|
1564 | */
|
---|
1565 | BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c16(PBS3SLABCTL pSlabCtl);
|
---|
1566 | BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c32(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */
|
---|
1567 | BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c64(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */
|
---|
1568 | #define Bs3SlabAlloc BS3_CMN_NM(Bs3SlabAlloc) /**< Selects #Bs3SlabAlloc_c16, #Bs3SlabAlloc_c32 or #Bs3SlabAlloc_c64. */
|
---|
1569 |
|
---|
1570 | /**
|
---|
1571 | * Allocates one or more chunks rom a slab.
|
---|
1572 | *
|
---|
1573 | * @returns Pointer to the request number of chunks on success, NULL if we're
|
---|
1574 | * out of chunks.
|
---|
1575 | * @param pSlabCtl The slab constrol structure to allocate from.
|
---|
1576 | * @param cChunks The number of contiguous chunks we want.
|
---|
1577 | * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX
|
---|
1578 | */
|
---|
1579 | BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c16(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags);
|
---|
1580 | BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c32(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */
|
---|
1581 | BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c64(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */
|
---|
1582 | #define Bs3SlabAllocEx BS3_CMN_NM(Bs3SlabAllocEx) /**< Selects #Bs3SlabAllocEx_c16, #Bs3SlabAllocEx_c32 or #Bs3SlabAllocEx_c64. */
|
---|
1583 |
|
---|
1584 | /**
|
---|
1585 | * Frees one or more chunks from a slab.
|
---|
1586 | *
|
---|
1587 | * @returns Number of chunks actually freed. When correctly used, this will
|
---|
1588 | * match the @a cChunks parameter, of course.
|
---|
1589 | * @param pSlabCtl The slab constrol structure to free from.
|
---|
1590 | * @param uFlatChunkPtr The flat address of the chunks to free.
|
---|
1591 | * @param cChunks The number of contiguous chunks to free.
|
---|
1592 | */
|
---|
1593 | BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks);
|
---|
1594 | BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
|
---|
1595 | BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
|
---|
1596 | #define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */
|
---|
1597 |
|
---|
1598 |
|
---|
1599 | /**
|
---|
1600 | * Initializes the given slab list head.
|
---|
1601 | *
|
---|
1602 | * @param pHead The slab list head.
|
---|
1603 | * @param cbChunk The chunk size.
|
---|
1604 | */
|
---|
1605 | BS3_DECL(void) Bs3SlabListInit_c16(PBS3SLABHEAD pHead, uint16_t cbChunk);
|
---|
1606 | BS3_DECL(void) Bs3SlabListInit_c32(PBS3SLABHEAD pHead, uint16_t cbChunk); /**< @copydoc Bs3SlabListInit_c16 */
|
---|
1607 | BS3_DECL(void) Bs3SlabListInit_c64(PBS3SLABHEAD pHead, uint16_t cbChunk); /**< @copydoc Bs3SlabListInit_c16 */
|
---|
1608 | #define Bs3SlabListInit BS3_CMN_NM(Bs3SlabListInit) /**< Selects #Bs3SlabListInit_c16, #Bs3SlabListInit_c32 or #Bs3SlabListInit_c64. */
|
---|
1609 |
|
---|
1610 | /**
|
---|
1611 | * Adds an initialized slab control structure to the list.
|
---|
1612 | *
|
---|
1613 | * @param pHead The slab list head to add it to.
|
---|
1614 | * @param pSlabCtl The slab control structure to add.
|
---|
1615 | */
|
---|
1616 | BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
|
---|
1617 | /** @copydoc Bs3SlabListAdd_c16 */
|
---|
1618 | BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
|
---|
1619 | /** @copydoc Bs3SlabListAdd_c16 */
|
---|
1620 | BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
|
---|
1621 | #define Bs3SlabListAdd BS3_CMN_NM(Bs3SlabListAdd) /**< Selects #Bs3SlabListAdd_c16, #Bs3SlabListAdd_c32 or #Bs3SlabListAdd_c64. */
|
---|
1622 |
|
---|
1623 | /**
|
---|
1624 | * Allocates one chunk.
|
---|
1625 | *
|
---|
1626 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
1627 | * @param pHead The slab list to allocate from.
|
---|
1628 | */
|
---|
1629 | BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c16(PBS3SLABHEAD pHead);
|
---|
1630 | BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c32(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */
|
---|
1631 | BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c64(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */
|
---|
1632 | #define Bs3SlabListAlloc BS3_CMN_NM(Bs3SlabListAlloc) /**< Selects #Bs3SlabListAlloc_c16, #Bs3SlabListAlloc_c32 or #Bs3SlabListAlloc_c64. */
|
---|
1633 |
|
---|
1634 | /**
|
---|
1635 | * Allocates one or more chunks.
|
---|
1636 | *
|
---|
1637 | * @returns Pointer to the request number of chunks on success, NULL if we're
|
---|
1638 | * out of chunks.
|
---|
1639 | * @param pHead The slab list to allocate from.
|
---|
1640 | * @param cChunks The number of contiguous chunks we want.
|
---|
1641 | * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX
|
---|
1642 | */
|
---|
1643 | BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c16(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags);
|
---|
1644 | BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c32(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */
|
---|
1645 | BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c64(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */
|
---|
1646 | #define Bs3SlabListAllocEx BS3_CMN_NM(Bs3SlabListAllocEx) /**< Selects #Bs3SlabListAllocEx_c16, #Bs3SlabListAllocEx_c32 or #Bs3SlabListAllocEx_c64. */
|
---|
1647 |
|
---|
1648 | /**
|
---|
1649 | * Frees one or more chunks from a slab list.
|
---|
1650 | *
|
---|
1651 | * @param pHead The slab list to allocate from.
|
---|
1652 | * @param pvChunks Pointer to the first chunk to free.
|
---|
1653 | * @param cChunks The number of contiguous chunks to free.
|
---|
1654 | */
|
---|
1655 | BS3_DECL(void) Bs3SlabListFree_c16(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks);
|
---|
1656 | BS3_DECL(void) Bs3SlabListFree_c32(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks); /**< @copydoc Bs3SlabListFree_c16 */
|
---|
1657 | BS3_DECL(void) Bs3SlabListFree_c64(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks); /**< @copydoc Bs3SlabListFree_c16 */
|
---|
1658 | #define Bs3SlabListFree BS3_CMN_NM(Bs3SlabListFree) /**< Selects #Bs3SlabListFree_c16, #Bs3SlabListFree_c32 or #Bs3SlabListFree_c64. */
|
---|
1659 |
|
---|
1660 | /**
|
---|
1661 | * Allocation addressing constraints.
|
---|
1662 | */
|
---|
1663 | typedef enum BS3MEMKIND
|
---|
1664 | {
|
---|
1665 | /** Invalid zero type. */
|
---|
1666 | BS3MEMKIND_INVALID = 0,
|
---|
1667 | /** Real mode addressable memory. */
|
---|
1668 | BS3MEMKIND_REAL,
|
---|
1669 | /** Memory addressable using the 16-bit protected mode tiling. */
|
---|
1670 | BS3MEMKIND_TILED,
|
---|
1671 | /** Memory addressable using 32-bit flat addressing. */
|
---|
1672 | BS3MEMKIND_FLAT32,
|
---|
1673 | /** Memory addressable using 64-bit flat addressing. */
|
---|
1674 | BS3MEMKIND_FLAT64,
|
---|
1675 | /** End of valid types. */
|
---|
1676 | BS3MEMKIND_END,
|
---|
1677 | } BS3MEMKIND;
|
---|
1678 |
|
---|
1679 | /**
|
---|
1680 | * Allocates low memory.
|
---|
1681 | *
|
---|
1682 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
1683 | * @param enmKind The kind of addressing constraints imposed on the
|
---|
1684 | * allocation.
|
---|
1685 | * @param cb How much to allocate. Must be 4KB or less.
|
---|
1686 | */
|
---|
1687 | BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c16(BS3MEMKIND enmKind, size_t cb);
|
---|
1688 | BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c32(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAlloc_c16 */
|
---|
1689 | BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c64(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAlloc_c16 */
|
---|
1690 | #define Bs3MemAlloc BS3_CMN_NM(Bs3MemAlloc) /**< Selects #Bs3MemAlloc_c16, #Bs3MemAlloc_c32 or #Bs3MemAlloc_c64. */
|
---|
1691 |
|
---|
1692 | /**
|
---|
1693 | * Allocates zero'ed memory.
|
---|
1694 | *
|
---|
1695 | * @param enmKind The kind of addressing constraints imposed on the
|
---|
1696 | * allocation.
|
---|
1697 | * @param cb How much to allocate. Must be 4KB or less.
|
---|
1698 | */
|
---|
1699 | BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c16(BS3MEMKIND enmKind, size_t cb);
|
---|
1700 | BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c32(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAllocZ_c16 */
|
---|
1701 | BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c64(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAllocZ_c16 */
|
---|
1702 | #define Bs3MemAllocZ BS3_CMN_NM(Bs3MemAllocZ) /**< Selects #Bs3MemAllocZ_c16, #Bs3MemAllocZ_c32 or #Bs3MemAllocZ_c64. */
|
---|
1703 |
|
---|
1704 | /**
|
---|
1705 | * Frees memory.
|
---|
1706 | *
|
---|
1707 | * @returns Pointer to a chunk on success, NULL if we're out of chunks.
|
---|
1708 | * @param pv The memory to free (returned by #Bs3MemAlloc).
|
---|
1709 | * @param cb The size of the allocation.
|
---|
1710 | */
|
---|
1711 | BS3_DECL(void) Bs3MemFree_c16(void BS3_FAR *pv, size_t cb);
|
---|
1712 | BS3_DECL(void) Bs3MemFree_c32(void BS3_FAR *pv, size_t cb); /**< @copydoc Bs3MemFree_c16 */
|
---|
1713 | BS3_DECL(void) Bs3MemFree_c64(void BS3_FAR *pv, size_t cb); /**< @copydoc Bs3MemFree_c16 */
|
---|
1714 | #define Bs3MemFree BS3_CMN_NM(Bs3MemFree) /**< Selects #Bs3MemFree_c16, #Bs3MemFree_c32 or #Bs3MemFree_c64. */
|
---|
1715 |
|
---|
1716 |
|
---|
1717 | /**
|
---|
1718 | * Enables the A20 gate.
|
---|
1719 | */
|
---|
1720 | BS3_DECL(void) Bs3A20Enable_c16(void);
|
---|
1721 | BS3_DECL(void) Bs3A20Enable_c32(void); /**< @copydoc Bs3A20Enable_c16 */
|
---|
1722 | BS3_DECL(void) Bs3A20Enable_c64(void); /**< @copydoc Bs3A20Enable_c16 */
|
---|
1723 | #define Bs3A20Enable BS3_CMN_NM(Bs3A20Enable) /**< Selects #Bs3A20Enable_c16, #Bs3A20Enable_c32 or #Bs3A20Enable_c64. */
|
---|
1724 |
|
---|
1725 | /**
|
---|
1726 | * Enables the A20 gate via the keyboard controller
|
---|
1727 | */
|
---|
1728 | BS3_DECL(void) Bs3A20EnableViaKbd_c16(void);
|
---|
1729 | BS3_DECL(void) Bs3A20EnableViaKbd_c32(void); /**< @copydoc Bs3A20EnableViaKbd_c16 */
|
---|
1730 | BS3_DECL(void) Bs3A20EnableViaKbd_c64(void); /**< @copydoc Bs3A20EnableViaKbd_c16 */
|
---|
1731 | #define Bs3A20EnableViaKbd BS3_CMN_NM(Bs3A20EnableViaKbd) /**< Selects #Bs3A20EnableViaKbd_c16, #Bs3A20EnableViaKbd_c32 or #Bs3A20EnableViaKbd_c64. */
|
---|
1732 |
|
---|
1733 | /**
|
---|
1734 | * Enables the A20 gate via the PS/2 control port A.
|
---|
1735 | */
|
---|
1736 | BS3_DECL(void) Bs3A20EnableViaPortA_c16(void);
|
---|
1737 | BS3_DECL(void) Bs3A20EnableViaPortA_c32(void); /**< @copydoc Bs3A20EnableViaPortA_c16 */
|
---|
1738 | BS3_DECL(void) Bs3A20EnableViaPortA_c64(void); /**< @copydoc Bs3A20EnableViaPortA_c16 */
|
---|
1739 | #define Bs3A20EnableViaPortA BS3_CMN_NM(Bs3A20EnableViaPortA) /**< Selects #Bs3A20EnableViaPortA_c16, #Bs3A20EnableViaPortA_c32 or #Bs3A20EnableViaPortA_c64. */
|
---|
1740 |
|
---|
1741 | /**
|
---|
1742 | * Disables the A20 gate.
|
---|
1743 | */
|
---|
1744 | BS3_DECL(void) Bs3A20Disable_c16(void);
|
---|
1745 | BS3_DECL(void) Bs3A20Disable_c32(void); /**< @copydoc Bs3A20Disable_c16 */
|
---|
1746 | BS3_DECL(void) Bs3A20Disable_c64(void); /**< @copydoc Bs3A20Disable_c16 */
|
---|
1747 | #define Bs3A20Disable BS3_CMN_NM(Bs3A20Disable) /**< Selects #Bs3A20Disable_c16, #Bs3A20Disable_c32 or #Bs3A20Disable_c64. */
|
---|
1748 |
|
---|
1749 | /**
|
---|
1750 | * Disables the A20 gate via the keyboard controller
|
---|
1751 | */
|
---|
1752 | BS3_DECL(void) Bs3A20DisableViaKbd_c16(void);
|
---|
1753 | BS3_DECL(void) Bs3A20DisableViaKbd_c32(void); /**< @copydoc Bs3A20DisableViaKbd_c16 */
|
---|
1754 | BS3_DECL(void) Bs3A20DisableViaKbd_c64(void); /**< @copydoc Bs3A20DisableViaKbd_c16 */
|
---|
1755 | #define Bs3A20DisableViaKbd BS3_CMN_NM(Bs3A20DisableViaKbd) /**< Selects #Bs3A20DisableViaKbd_c16, #Bs3A20DisableViaKbd_c32 or #Bs3A20DisableViaKbd_c64. */
|
---|
1756 |
|
---|
1757 | /**
|
---|
1758 | * Disables the A20 gate via the PS/2 control port A.
|
---|
1759 | */
|
---|
1760 | BS3_DECL(void) Bs3A20DisableViaPortA_c16(void);
|
---|
1761 | BS3_DECL(void) Bs3A20DisableViaPortA_c32(void); /**< @copydoc Bs3A20DisableViaPortA_c16 */
|
---|
1762 | BS3_DECL(void) Bs3A20DisableViaPortA_c64(void); /**< @copydoc Bs3A20DisableViaPortA_c16 */
|
---|
1763 | #define Bs3A20DisableViaPortA BS3_CMN_NM(Bs3A20DisableViaPortA) /**< Selects #Bs3A20DisableViaPortA_c16, #Bs3A20DisableViaPortA_c32 or #Bs3A20DisableViaPortA_c64. */
|
---|
1764 |
|
---|
1765 |
|
---|
1766 | /**
|
---|
1767 | * Initializes root page tables for page protected mode (PP16, PP32).
|
---|
1768 | *
|
---|
1769 | * @returns IPRT status code.
|
---|
1770 | * @remarks Must not be called in real-mode!
|
---|
1771 | */
|
---|
1772 | BS3_DECL(int) Bs3PagingInitRootForPP_c16(void);
|
---|
1773 | BS3_DECL(int) Bs3PagingInitRootForPP_c32(void); /**< @copydoc Bs3PagingInitRootForPP_c16 */
|
---|
1774 | BS3_DECL(int) Bs3PagingInitRootForPP_c64(void); /**< @copydoc Bs3PagingInitRootForPP_c16 */
|
---|
1775 | #define Bs3PagingInitRootForPP BS3_CMN_NM(Bs3PagingInitRootForPP) /**< Selects #Bs3PagingInitRootForPP_c16, #Bs3PagingInitRootForPP_c32 or #Bs3PagingInitRootForPP_c64. */
|
---|
1776 |
|
---|
1777 | /**
|
---|
1778 | * Initializes root page tables for PAE page protected mode (PAE16, PAE32).
|
---|
1779 | *
|
---|
1780 | * @returns IPRT status code.
|
---|
1781 | * @remarks The default long mode page tables depends on the PAE ones.
|
---|
1782 | * @remarks Must not be called in real-mode!
|
---|
1783 | */
|
---|
1784 | BS3_DECL(int) Bs3PagingInitRootForPAE_c16(void);
|
---|
1785 | BS3_DECL(int) Bs3PagingInitRootForPAE_c32(void); /**< @copydoc Bs3PagingInitRootForPAE_c16 */
|
---|
1786 | BS3_DECL(int) Bs3PagingInitRootForPAE_c64(void); /**< @copydoc Bs3PagingInitRootForPAE_c16 */
|
---|
1787 | #define Bs3PagingInitRootForPAE BS3_CMN_NM(Bs3PagingInitRootForPAE) /**< Selects #Bs3PagingInitRootForPAE_c16, #Bs3PagingInitRootForPAE_c32 or #Bs3PagingInitRootForPAE_c64. */
|
---|
1788 |
|
---|
1789 | /**
|
---|
1790 | * Initializes root page tables for long mode (LM16, LM32, LM64).
|
---|
1791 | *
|
---|
1792 | * @returns IPRT status code.
|
---|
1793 | * @remarks The default long mode page tables depends on the PAE ones.
|
---|
1794 | * @remarks Must not be called in real-mode!
|
---|
1795 | */
|
---|
1796 | BS3_DECL(int) Bs3PagingInitRootForLM_c16(void);
|
---|
1797 | BS3_DECL(int) Bs3PagingInitRootForLM_c32(void); /**< @copydoc Bs3PagingInitRootForLM_c16 */
|
---|
1798 | BS3_DECL(int) Bs3PagingInitRootForLM_c64(void); /**< @copydoc Bs3PagingInitRootForLM_c16 */
|
---|
1799 | #define Bs3PagingInitRootForLM BS3_CMN_NM(Bs3PagingInitRootForLM) /**< Selects #Bs3PagingInitRootForLM_c16, #Bs3PagingInitRootForLM_c32 or #Bs3PagingInitRootForLM_c64. */
|
---|
1800 |
|
---|
1801 |
|
---|
1802 | /**
|
---|
1803 | * Waits for the keyboard controller to become ready.
|
---|
1804 | */
|
---|
1805 | BS3_DECL(void) Bs3KbdWait_c16(void);
|
---|
1806 | BS3_DECL(void) Bs3KbdWait_c32(void); /**< @copydoc Bs3KbdWait_c16 */
|
---|
1807 | BS3_DECL(void) Bs3KbdWait_c64(void); /**< @copydoc Bs3KbdWait_c16 */
|
---|
1808 | #define Bs3KbdWait BS3_CMN_NM(Bs3KbdWait) /**< Selects #Bs3KbdWait_c16, #Bs3KbdWait_c32 or #Bs3KbdWait_c64. */
|
---|
1809 |
|
---|
1810 | /**
|
---|
1811 | * Sends a read command to the keyboard controller and gets the result.
|
---|
1812 | *
|
---|
1813 | * The caller is responsible for making sure the keyboard controller is ready
|
---|
1814 | * for a command (call #Bs3KbdWait if unsure).
|
---|
1815 | *
|
---|
1816 | * @returns The value read is returned (in al).
|
---|
1817 | * @param bCmd The read command.
|
---|
1818 | */
|
---|
1819 | BS3_DECL(uint8_t) Bs3KbdRead_c16(uint8_t bCmd);
|
---|
1820 | BS3_DECL(uint8_t) Bs3KbdRead_c32(uint8_t bCmd); /**< @copydoc Bs3KbdRead_c16 */
|
---|
1821 | BS3_DECL(uint8_t) Bs3KbdRead_c64(uint8_t bCmd); /**< @copydoc Bs3KbdRead_c16 */
|
---|
1822 | #define Bs3KbdRead BS3_CMN_NM(Bs3KbdRead) /**< Selects #Bs3KbdRead_c16, #Bs3KbdRead_c32 or #Bs3KbdRead_c64. */
|
---|
1823 |
|
---|
1824 | /**
|
---|
1825 | * Sends a write command to the keyboard controller and then sends the data.
|
---|
1826 | *
|
---|
1827 | * The caller is responsible for making sure the keyboard controller is ready
|
---|
1828 | * for a command (call #Bs3KbdWait if unsure).
|
---|
1829 | *
|
---|
1830 | * @param bCmd The write command.
|
---|
1831 | * @param bData The data to write.
|
---|
1832 | */
|
---|
1833 | BS3_DECL(void) Bs3KbdWrite_c16(uint8_t bCmd, uint8_t bData);
|
---|
1834 | BS3_DECL(void) Bs3KbdWrite_c32(uint8_t bCmd, uint8_t bData); /**< @copydoc Bs3KbdWrite_c16 */
|
---|
1835 | BS3_DECL(void) Bs3KbdWrite_c64(uint8_t bCmd, uint8_t bData); /**< @copydoc Bs3KbdWrite_c16 */
|
---|
1836 | #define Bs3KbdWrite BS3_CMN_NM(Bs3KbdWrite) /**< Selects #Bs3KbdWrite_c16, #Bs3KbdWrite_c32 or #Bs3KbdWrite_c64. */
|
---|
1837 |
|
---|
1838 |
|
---|
1839 | /**
|
---|
1840 | * BS3 integer register.
|
---|
1841 | */
|
---|
1842 | typedef union BS3REG
|
---|
1843 | {
|
---|
1844 | /** 8-bit unsigned integer. */
|
---|
1845 | uint8_t u8;
|
---|
1846 | /** 16-bit unsigned integer. */
|
---|
1847 | uint16_t u16;
|
---|
1848 | /** 32-bit unsigned integer. */
|
---|
1849 | uint32_t u32;
|
---|
1850 | /** 64-bit unsigned integer. */
|
---|
1851 | uint64_t u64;
|
---|
1852 | /** Full unsigned integer. */
|
---|
1853 | uint64_t u;
|
---|
1854 | /** High/low byte view. */
|
---|
1855 | struct
|
---|
1856 | {
|
---|
1857 | uint8_t bLo;
|
---|
1858 | uint8_t bHi;
|
---|
1859 | } b;
|
---|
1860 | /** 8-bit view. */
|
---|
1861 | uint8_t au8[8];
|
---|
1862 | /** 16-bit view. */
|
---|
1863 | uint16_t au16[4];
|
---|
1864 | /** 32-bit view. */
|
---|
1865 | uint32_t au32[2];
|
---|
1866 | } BS3REG;
|
---|
1867 | /** Pointer to an integer register. */
|
---|
1868 | typedef BS3REG BS3_FAR *PBS3REG;
|
---|
1869 | /** Pointer to a const integer register. */
|
---|
1870 | typedef BS3REG const BS3_FAR *PCBS3REG;
|
---|
1871 |
|
---|
1872 | /**
|
---|
1873 | * Register context (without FPU).
|
---|
1874 | */
|
---|
1875 | typedef struct BS3REGCTX
|
---|
1876 | {
|
---|
1877 | BS3REG rax;
|
---|
1878 | BS3REG rcx;
|
---|
1879 | BS3REG rdx;
|
---|
1880 | BS3REG rbx;
|
---|
1881 | BS3REG rsp;
|
---|
1882 | BS3REG rbp;
|
---|
1883 | BS3REG rsi;
|
---|
1884 | BS3REG rdi;
|
---|
1885 | BS3REG r8;
|
---|
1886 | BS3REG r9;
|
---|
1887 | BS3REG r10;
|
---|
1888 | BS3REG r11;
|
---|
1889 | BS3REG r12;
|
---|
1890 | BS3REG r13;
|
---|
1891 | BS3REG r14;
|
---|
1892 | BS3REG r15;
|
---|
1893 | BS3REG rflags;
|
---|
1894 | BS3REG rip;
|
---|
1895 | uint16_t cs;
|
---|
1896 | uint16_t ds;
|
---|
1897 | uint16_t es;
|
---|
1898 | uint16_t fs;
|
---|
1899 | uint16_t gs;
|
---|
1900 | uint16_t ss;
|
---|
1901 | uint16_t tr;
|
---|
1902 | uint16_t ldtr;
|
---|
1903 | uint8_t cBits;
|
---|
1904 | uint8_t abPadding[7];
|
---|
1905 | BS3REG cr0;
|
---|
1906 | BS3REG cr2;
|
---|
1907 | BS3REG cr3;
|
---|
1908 | BS3REG cr4;
|
---|
1909 | } BS3REGCTX;
|
---|
1910 | /** Pointer to a register context. */
|
---|
1911 | typedef BS3REGCTX BS3_FAR *PBS3REGCTX;
|
---|
1912 | /** Pointer to a const register context. */
|
---|
1913 | typedef BS3REGCTX const BS3_FAR *PCBS3REGCTX;
|
---|
1914 |
|
---|
1915 |
|
---|
1916 | /**
|
---|
1917 | * Trap frame.
|
---|
1918 | */
|
---|
1919 | typedef struct BS3TRAPFRAME
|
---|
1920 | {
|
---|
1921 | /** Exception/interrupt number. */
|
---|
1922 | uint8_t bXcpt;
|
---|
1923 | /** Explicit alignment. */
|
---|
1924 | uint8_t bAlignment;
|
---|
1925 | /** The handler CS. */
|
---|
1926 | uint16_t uHandlerCc;
|
---|
1927 | /** The handler SS. */
|
---|
1928 | uint16_t uHandlerSs;
|
---|
1929 | /** The handler RSP (top of iret frame). */
|
---|
1930 | uint64_t uHandlerRsp;
|
---|
1931 | /** The handler RFLAGS value. */
|
---|
1932 | uint64_t fHandlerRfl;
|
---|
1933 | /** The error code (if applicable). */
|
---|
1934 | uint64_t uErrCd;
|
---|
1935 | /** The register context. */
|
---|
1936 | BS3REGCTX Ctx;
|
---|
1937 | } BS3TRAPFRAME;
|
---|
1938 | /** Pointer to a trap frame. */
|
---|
1939 | typedef BS3TRAPFRAME BS3_FAR *PBS3TRAPFRAME;
|
---|
1940 | /** Pointer to a const trap frame. */
|
---|
1941 | typedef BS3TRAPFRAME const BS3_FAR *PCBS3TRAPFRAME;
|
---|
1942 |
|
---|
1943 | /**
|
---|
1944 | * Resumes execution of a 32-bit trap frame.
|
---|
1945 | *
|
---|
1946 | * @param pTrapFrame Trap frame to resume.
|
---|
1947 | * @param fFlags Flags, BS3TRAPRESUME_F_XXX.
|
---|
1948 | */
|
---|
1949 | BS3_DECL(void) Bs3Trap32ResumeFrame_c32(BS3TRAPFRAME BS3_FAR *pTrapFrame, uint16_t fFlags);
|
---|
1950 | #define Bs3Trap32ResumeFrame BS3_CMN_NM(Bs3Trap32ResumeFrame) /**< Selects Bs3Trap32ResumeFrame_c16 (not implemented), #Bs3Trap32ResumeFrame_c32 or Bs3Trap32ResumeFrame_c64 (not implemented). */
|
---|
1951 |
|
---|
1952 | /** Skip restoring the CRx registers. */
|
---|
1953 | #define BS3TRAPRESUME_F_SKIP_CRX UINT16_C(0x0001)
|
---|
1954 |
|
---|
1955 | /**
|
---|
1956 | * Initializes 16-bit (protected mode) trap handling.
|
---|
1957 | *
|
---|
1958 | * @remarks Does not install 16-bit trap handling, just initializes the
|
---|
1959 | * structures.
|
---|
1960 | */
|
---|
1961 | BS3_DECL(void) Bs3Trap16Init_c16(void);
|
---|
1962 | BS3_DECL(void) Bs3Trap16Init_c32(void); /**< @copydoc Bs3Trap16Init_c16 */
|
---|
1963 | BS3_DECL(void) Bs3Trap16Init_c64(void); /**< @copydoc Bs3Trap16Init_c16 */
|
---|
1964 | #define Bs3Trap16Init BS3_CMN_NM(Bs3Trap16Init) /**< Selects #Bs3Trap16Init_c16, #Bs3Trap16Init_c32 or #Bs3Trap16Init_c64. */
|
---|
1965 |
|
---|
1966 | /**
|
---|
1967 | * Initializes 32-bit trap handling.
|
---|
1968 | *
|
---|
1969 | * @remarks Does not install 32-bit trap handling, just initializes the
|
---|
1970 | * structures.
|
---|
1971 | */
|
---|
1972 | BS3_DECL(void) Bs3Trap32Init_c16(void);
|
---|
1973 | BS3_DECL(void) Bs3Trap32Init_c32(void); /**< @copydoc Bs3Trap32Init_c16 */
|
---|
1974 | BS3_DECL(void) Bs3Trap32Init_c64(void); /**< @copydoc Bs3Trap32Init_c16 */
|
---|
1975 | #define Bs3Trap32Init BS3_CMN_NM(Bs3Trap32Init) /**< Selects #Bs3Trap32Init_c16, #Bs3Trap32Init_c32 or #Bs3Trap32Init_c64. */
|
---|
1976 |
|
---|
1977 | /**
|
---|
1978 | * Initializes 64-bit trap handling
|
---|
1979 | *
|
---|
1980 | * @remarks Does not install 64-bit trap handling, just initializes the
|
---|
1981 | * structures.
|
---|
1982 | */
|
---|
1983 | BS3_DECL(void) Bs3Trap64Init_c16(void);
|
---|
1984 | BS3_DECL(void) Bs3Trap64Init_c32(void); /**< @copydoc Bs3Trap64Init_c16 */
|
---|
1985 | BS3_DECL(void) Bs3Trap64Init_c64(void); /**< @copydoc Bs3Trap64Init_c16 */
|
---|
1986 | #define Bs3Trap64Init BS3_CMN_NM(Bs3Trap64Init) /**< Selects #Bs3Trap64Init_c16, #Bs3Trap64Init_c32 or #Bs3Trap64Init_c64. */
|
---|
1987 |
|
---|
1988 | /**
|
---|
1989 | * Modifies the 16-bit IDT entry (protected mode) specified by @a iIdt.
|
---|
1990 | *
|
---|
1991 | * @param iIdt The index of the IDT entry to set.
|
---|
1992 | * @param bType The gate type (X86_SEL_TYPE_SYS_XXX).
|
---|
1993 | * @param bDpl The DPL.
|
---|
1994 | * @param uSel The handler selector.
|
---|
1995 | * @param off The handler offset (if applicable).
|
---|
1996 | * @param cParams The parameter count (for call gates).
|
---|
1997 | */
|
---|
1998 | BS3_DECL(void) Bs3Trap16SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams);
|
---|
1999 | BS3_DECL(void) Bs3Trap16SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */
|
---|
2000 | BS3_DECL(void) Bs3Trap16SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint16_t off, uint8_t cParams); /**< @copydoc Bs3Trap16SetGate_c16 */
|
---|
2001 | #define Bs3Trap16SetGate BS3_CMN_NM(Bs3Trap16SetGate) /**< Selects #Bs3Trap16SetGate_c16, #Bs3Trap16SetGate_c32 or #Bs3Trap16SetGate_c64. */
|
---|
2002 |
|
---|
2003 | /** The address of Bs3Trap16GenericEntries.
|
---|
2004 | * Bs3Trap16GenericEntries is an array of interrupt/trap/whatever entry
|
---|
2005 | * points, 8 bytes each, that will create a register frame and call the generic
|
---|
2006 | * C compatible trap handlers. */
|
---|
2007 | extern uint32_t BS3_DATA_NM(g_Bs3Trap16GenericEntriesFlatAddr);
|
---|
2008 |
|
---|
2009 | /**
|
---|
2010 | * Modifies the 32-bit IDT entry specified by @a iIdt.
|
---|
2011 | *
|
---|
2012 | * @param iIdt The index of the IDT entry to set.
|
---|
2013 | * @param bType The gate type (X86_SEL_TYPE_SYS_XXX).
|
---|
2014 | * @param bDpl The DPL.
|
---|
2015 | * @param uSel The handler selector.
|
---|
2016 | * @param off The handler offset (if applicable).
|
---|
2017 | * @param cParams The parameter count (for call gates).
|
---|
2018 | */
|
---|
2019 | BS3_DECL(void) Bs3Trap32SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams);
|
---|
2020 | BS3_DECL(void) Bs3Trap32SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */
|
---|
2021 | BS3_DECL(void) Bs3Trap32SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint32_t off, uint8_t cParams); /**< @copydoc Bs3Trap32SetGate_c16 */
|
---|
2022 | #define Bs3Trap32SetGate BS3_CMN_NM(Bs3Trap32SetGate) /**< Selects #Bs3Trap32SetGate_c16, #Bs3Trap32SetGate_c32 or #Bs3Trap32SetGate_c64. */
|
---|
2023 |
|
---|
2024 | /** The address of Bs3Trap32GenericEntries.
|
---|
2025 | * Bs3Trap32GenericEntries is an array of interrupt/trap/whatever entry
|
---|
2026 | * points, 8 bytes each, that will create a register frame and call the generic
|
---|
2027 | * C compatible trap handlers. */
|
---|
2028 | extern uint32_t BS3_DATA_NM(g_Bs3Trap32GenericEntriesFlatAddr);
|
---|
2029 |
|
---|
2030 | /**
|
---|
2031 | * Modifies the 64-bit IDT entry specified by @a iIdt.
|
---|
2032 | *
|
---|
2033 | * @param iIdt The index of the IDT entry to set.
|
---|
2034 | * @param bType The gate type (X86_SEL_TYPE_SYS_XXX).
|
---|
2035 | * @param bDpl The DPL.
|
---|
2036 | * @param uSel The handler selector.
|
---|
2037 | * @param off The handler offset (if applicable).
|
---|
2038 | * @param bIst The interrupt stack to use.
|
---|
2039 | */
|
---|
2040 | BS3_DECL(void) Bs3Trap64SetGate_c16(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst);
|
---|
2041 | BS3_DECL(void) Bs3Trap64SetGate_c32(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */
|
---|
2042 | BS3_DECL(void) Bs3Trap64SetGate_c64(uint8_t iIdt, uint8_t bType, uint8_t bDpl, uint16_t uSel, uint64_t off, uint8_t bIst); /**< @copydoc Bs3Trap64SetGate_c16 */
|
---|
2043 | #define Bs3Trap64SetGate BS3_CMN_NM(Bs3Trap64SetGate) /**< Selects #Bs3Trap64SetGate_c16, #Bs3Trap64SetGate_c32 or #Bs3Trap64SetGate_c64. */
|
---|
2044 |
|
---|
2045 | /** The address of Bs3Trap64GenericEntries.
|
---|
2046 | * Bs3Trap64GenericEntries is an array of interrupt/trap/whatever entry
|
---|
2047 | * points, 8 bytes each, that will create a register frame and call the generic
|
---|
2048 | * C compatible trap handlers. */
|
---|
2049 | extern uint32_t BS3_DATA_NM(g_Bs3Trap64GenericEntriesFlatAddr);
|
---|
2050 |
|
---|
2051 | /**
|
---|
2052 | * C-style trap handler.
|
---|
2053 | *
|
---|
2054 | * Upon return Bs3Trap16ResumeFrame_c16, #Bs3Trap32ResumeFrame_c32, or
|
---|
2055 | * Bs3Trap64ResumeFrame_c64 will be called depending on the current template
|
---|
2056 | * context.
|
---|
2057 | *
|
---|
2058 | * @param pTrapFrame The trap frame. Registers can be modified.
|
---|
2059 | */
|
---|
2060 | typedef BS3_DECL_CALLBACK(void) FNBS3TRAPHANDLER(PBS3TRAPFRAME pTrapFrame);
|
---|
2061 | /** Pointer to a trap handler (current template context). */
|
---|
2062 | typedef FNBS3TRAPHANDLER *PFNBS3TRAPHANDLER;
|
---|
2063 |
|
---|
2064 | /**
|
---|
2065 | * Sets a trap handler (C/C++/assembly) for the current bitness.
|
---|
2066 | *
|
---|
2067 | * When using a 32-bit IDT, only #Bs3TrapSetHandler_c32 will have any effect.
|
---|
2068 | * Likewise, when using a 16-bit IDT, only Bs3TrapSetHandler_c16 will make any
|
---|
2069 | * difference. Ditto 64-bit.
|
---|
2070 | *
|
---|
2071 | * Rational: It's mainly a C API, can't easily mix function pointers from other
|
---|
2072 | * bit counts in C. Use assembly helpers or something if that is necessary.
|
---|
2073 | * Besides, most of the real trap handling goes thru the default handler with
|
---|
2074 | * help of trap records.
|
---|
2075 | *
|
---|
2076 | * @returns Previous handler.
|
---|
2077 | * @param iIdt The index of the IDT entry to set.
|
---|
2078 | * @param pfnHandler Pointer to the handler.
|
---|
2079 | */
|
---|
2080 | BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c16(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler);
|
---|
2081 | BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c32(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */
|
---|
2082 | BS3_DECL(PFNBS3TRAPHANDLER) Bs3TrapSetHandler_c64(uint8_t iIdt, PFNBS3TRAPHANDLER pfnHandler); /**< @copydoc Bs3Trap32SetHandler_c16 */
|
---|
2083 | #define Bs3Trap32SetHandler BS3_CMN_NM(Bs3Trap32SetHandler) /**< Selects #Bs3Trap32SetHandler_c16, #Bs3Trap32SetHandler_c32 or #Bs3Trap32SetHandler_c64. */
|
---|
2084 |
|
---|
2085 | /**
|
---|
2086 | * Default C/C++ trap handler.
|
---|
2087 | *
|
---|
2088 | * This will check trap record and panic if no match was found.
|
---|
2089 | *
|
---|
2090 | * @param pTrapFrame Trap frame of the trap to handle.
|
---|
2091 | */
|
---|
2092 | BS3_DECL(void) Bs3TrapDefaultHandler_c16(PBS3TRAPFRAME pTrapFrame);
|
---|
2093 | BS3_DECL(void) Bs3TrapDefaultHandler_c32(PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapDefaultHandler_c16 */
|
---|
2094 | BS3_DECL(void) Bs3TrapDefaultHandler_c64(PBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapDefaultHandler_c16 */
|
---|
2095 | #define Bs3TrapDefaultHandler BS3_CMN_NM(Bs3TrapDefaultHandler) /**< Selects #Bs3TrapDefaultHandler_c16, #Bs3TrapDefaultHandler_c32 or #Bs3TrapDefaultHandler_c64. */
|
---|
2096 |
|
---|
2097 | /**
|
---|
2098 | * Prints the trap frame (to screen).
|
---|
2099 | * @param pTrapFrame Trap frame to print.
|
---|
2100 | */
|
---|
2101 | BS3_DECL(void) Bs3TrapPrintFrame_c16(PCBS3TRAPFRAME pTrapFrame);
|
---|
2102 | BS3_DECL(void) Bs3TrapPrintFrame_c32(PCBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapPrintFrame_c16 */
|
---|
2103 | BS3_DECL(void) Bs3TrapPrintFrame_c64(PCBS3TRAPFRAME pTrapFrame); /**< @copydoc Bs3TrapPrintFrame_c16 */
|
---|
2104 | #define Bs3TrapPrintFrame BS3_CMN_NM(Bs3TrapPrintFrame) /**< Selects #Bs3TrapPrintFrame_c16, #Bs3TrapPrintFrame_c32 or #Bs3TrapPrintFrame_c64. */
|
---|
2105 |
|
---|
2106 | /** @} */
|
---|
2107 |
|
---|
2108 |
|
---|
2109 | /**
|
---|
2110 | * Initializes all of boot sector kit \#3.
|
---|
2111 | */
|
---|
2112 | BS3_DECL(void) Bs3InitAll_rm(void);
|
---|
2113 |
|
---|
2114 | /**
|
---|
2115 | * Initializes the REAL and TILED memory pools.
|
---|
2116 | *
|
---|
2117 | * For proper operation on OLDer CPUs, call #Bs3CpuDetect_mmm first.
|
---|
2118 | */
|
---|
2119 | BS3_DECL(void) Bs3InitMemory_rm(void);
|
---|
2120 |
|
---|
2121 |
|
---|
2122 |
|
---|
2123 | /** @defgroup grp_bs3kit_mode Mode Specific Functions and Data
|
---|
2124 | *
|
---|
2125 | * The mode specific functions come in bit count variations and CPU mode
|
---|
2126 | * variations. The bs3kit-template-header.h/mac defines the BS3_NM macro to
|
---|
2127 | * mangle a function or variable name according to the target CPU mode. In
|
---|
2128 | * non-templated code, it's common to spell the name out in full.
|
---|
2129 | *
|
---|
2130 | * @{
|
---|
2131 | */
|
---|
2132 |
|
---|
2133 |
|
---|
2134 | /**
|
---|
2135 | * Macro for reducing typing.
|
---|
2136 | *
|
---|
2137 | * Doxygen knows how to expand this, well, kind of.
|
---|
2138 | */
|
---|
2139 | #define BS3_MODE_EXPAND_PROTOTYPES(a_RetType, a_BaseFnNm, a_Parameters) \
|
---|
2140 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_rm) a_Parameters; \
|
---|
2141 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16) a_Parameters; \
|
---|
2142 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16_32) a_Parameters; \
|
---|
2143 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe16_v86) a_Parameters; \
|
---|
2144 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe32) a_Parameters; \
|
---|
2145 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pe32_16) a_Parameters; \
|
---|
2146 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pev86) a_Parameters; \
|
---|
2147 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16) a_Parameters; \
|
---|
2148 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16_32) a_Parameters; \
|
---|
2149 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp16_v86) a_Parameters; \
|
---|
2150 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp32) a_Parameters; \
|
---|
2151 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pp32_16) a_Parameters; \
|
---|
2152 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_ppv86) a_Parameters; \
|
---|
2153 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16) a_Parameters; \
|
---|
2154 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16_16) a_Parameters; \
|
---|
2155 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae16_v86)a_Parameters; \
|
---|
2156 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae32) a_Parameters; \
|
---|
2157 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_pae32_16) a_Parameters; \
|
---|
2158 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_paev86) a_Parameters; \
|
---|
2159 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_lm16) a_Parameters; \
|
---|
2160 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_lm32) a_Parameters; \
|
---|
2161 | BS3_DECL(a_RetType) RT_CONCAT(a_BaseFnNm,_lm64) a_Parameters
|
---|
2162 |
|
---|
2163 | /**
|
---|
2164 | * Macro for reducing typing.
|
---|
2165 | *
|
---|
2166 | * Doxygen knows how to expand this, well, kind of.
|
---|
2167 | */
|
---|
2168 | #define BS3_MODE_EXPAND_EXTERN_DATA16(a_VarType, a_VarName, a_Suffix) \
|
---|
2169 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_rm)) a_Suffix; \
|
---|
2170 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pe16)) a_Suffix; \
|
---|
2171 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pe16_32)) a_Suffix; \
|
---|
2172 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pe16_v86)) a_Suffix; \
|
---|
2173 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pe32)) a_Suffix; \
|
---|
2174 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pe32_16)) a_Suffix; \
|
---|
2175 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pev86)) a_Suffix; \
|
---|
2176 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pp16)) a_Suffix; \
|
---|
2177 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pp16_32)) a_Suffix; \
|
---|
2178 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pp16_v86)) a_Suffix; \
|
---|
2179 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pp32)) a_Suffix; \
|
---|
2180 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pp32_16)) a_Suffix; \
|
---|
2181 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_ppv86)) a_Suffix; \
|
---|
2182 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pae16)) a_Suffix; \
|
---|
2183 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pae16_32)) a_Suffix; \
|
---|
2184 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pae16_v86))a_Suffix; \
|
---|
2185 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pae32)) a_Suffix; \
|
---|
2186 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_pae32_16)) a_Suffix; \
|
---|
2187 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_paev86)) a_Suffix; \
|
---|
2188 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_lm16)) a_Suffix; \
|
---|
2189 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_lm32)) a_Suffix; \
|
---|
2190 | extern a_VarType BS3_FAR_DATA BS3_DATA_NM(RT_CONCAT(a_VarName,_lm64)) a_Suffix
|
---|
2191 |
|
---|
2192 |
|
---|
2193 | /** The TMPL_MODE_STR value for each mode.
|
---|
2194 | * These are all in DATA16 so they can be accessed from any code. */
|
---|
2195 | BS3_MODE_EXPAND_EXTERN_DATA16(const char *, g_szBs3ModeName, []);
|
---|
2196 |
|
---|
2197 | /**
|
---|
2198 | * Basic CPU detection.
|
---|
2199 | *
|
---|
2200 | * This sets the #g_bBs3CpuDetected global variable to the return value.
|
---|
2201 | *
|
---|
2202 | * @returns BS3CPU_XXX value with the BS3CPU_F_CPUID flag set depending on
|
---|
2203 | * capabilities.
|
---|
2204 | */
|
---|
2205 | BS3_MODE_EXPAND_PROTOTYPES(uint8_t, Bs3CpuDetect,(void));
|
---|
2206 |
|
---|
2207 | /** @name BS3CPU_XXX - CPU detected by BS3CpuDetect_c16() and friends.
|
---|
2208 | * @{ */
|
---|
2209 | #define BS3CPU_8086 UINT16_C(0x0001) /**< Both 8086 and 8088. */
|
---|
2210 | #define BS3CPU_V20 UINT16_C(0x0002) /**< Both NEC V20, V30 and relatives. */
|
---|
2211 | #define BS3CPU_80186 UINT16_C(0x0003) /**< Both 80186 and 80188. */
|
---|
2212 | #define BS3CPU_80286 UINT16_C(0x0004)
|
---|
2213 | #define BS3CPU_80386 UINT16_C(0x0005)
|
---|
2214 | #define BS3CPU_80486 UINT16_C(0x0006)
|
---|
2215 | #define BS3CPU_Pentium UINT16_C(0x0007)
|
---|
2216 | #define BS3CPU_PPro UINT16_C(0x0008)
|
---|
2217 | #define BS3CPU_PProOrNewer UINT16_C(0x0009)
|
---|
2218 | /** CPU type mask. This is a full byte so it's possible to use byte access
|
---|
2219 | * without and AND'ing to get the type value. */
|
---|
2220 | #define BS3CPU_TYPE_MASK UINT16_C(0x00ff)
|
---|
2221 | /** Flag indicating that the CPUID instruction is supported by the CPU. */
|
---|
2222 | #define BS3CPU_F_CPUID UINT16_C(0x0100)
|
---|
2223 | /** Flag indicating that extend CPUID leaves are available (at least two). */
|
---|
2224 | #define BS3CPU_F_CPUID_EXT_LEAVES UINT16_C(0x0200)
|
---|
2225 | /** Flag indicating that the CPU supports PAE. */
|
---|
2226 | #define BS3CPU_F_PAE UINT16_C(0x0400)
|
---|
2227 | /** Flag indicating that the CPU supports long mode. */
|
---|
2228 | #define BS3CPU_F_LONG_MODE UINT16_C(0x0800)
|
---|
2229 | /** @} */
|
---|
2230 |
|
---|
2231 | /** The return value of #Bs3CpuDetect_mmm. (Initial value is BS3CPU_TYPE_MASK.) */
|
---|
2232 | extern uint16_t BS3_DATA_NM(g_uBs3CpuDetected);
|
---|
2233 |
|
---|
2234 |
|
---|
2235 | /**
|
---|
2236 | * Executes the array of tests in every possibly mode.
|
---|
2237 | *
|
---|
2238 | * @param paEntries The mode sub-test entries.
|
---|
2239 | * @param cEntries The number of sub-test entries.
|
---|
2240 | */
|
---|
2241 | BS3_MODE_EXPAND_PROTOTYPES(void, Bs3TestDoModes, (BS3TESTMODEENTRY paEntries, unsigned cEntries));
|
---|
2242 |
|
---|
2243 | /** @} */
|
---|
2244 |
|
---|
2245 | RT_C_DECLS_END
|
---|
2246 |
|
---|
2247 |
|
---|
2248 | #endif
|
---|
2249 |
|
---|