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