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