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