1 | /* $Id: bs3kit.h 58694 2015-11-15 21:56:46Z 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 | #include <iprt/x86.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | /** @defgroup grp_bs3kit BS3Kit
|
---|
42 | * @{ */
|
---|
43 |
|
---|
44 |
|
---|
45 | /** @name BS3_ADDR_XXX - Static Memory Allocation
|
---|
46 | * @{ */
|
---|
47 | /** The flat load address for the code after the bootsector. */
|
---|
48 | #define BS3_ADDR_LOAD 0x10000
|
---|
49 | /** Where we save the boot registers during init.
|
---|
50 | * Located right before the code. */
|
---|
51 | #define BS3_ADDR_REG_SAVE (BS3_ADDR_LOAD - sizeof(BS3REGS) - 8)
|
---|
52 | /** Where the stack starts (initial RSP value).
|
---|
53 | * Located 16 bytes (assumed by boot sector) before the saved registers.
|
---|
54 | * SS.BASE=0. The size is a little short of 32KB */
|
---|
55 | #define BS3_ADDR_STACK (BS3_ADDR_REG_SAVE - 16)
|
---|
56 | /** The ring-0 stack (8KB) for ring transitions. */
|
---|
57 | #define BS3_ADDR_STACK_R0 0x06000
|
---|
58 | /** The ring-1 stack (8KB) for ring transitions. */
|
---|
59 | #define BS3_ADDR_STACK_R1 0x04000
|
---|
60 | /** The ring-2 stack (8KB) for ring transitions. */
|
---|
61 | #define BS3_ADDR_STACK_R2 0x02000
|
---|
62 | /** IST1 ring-0 stack for long mode (4KB), used for double faults elsewhere. */
|
---|
63 | #define BS3_ADDR_STACK_R0_IST1 0x09000
|
---|
64 | /** IST2 ring-0 stack for long mode (3KB), used for spare 0 stack elsewhere. */
|
---|
65 | #define BS3_ADDR_STACK_R0_IST2 0x08000
|
---|
66 | /** IST3 ring-0 stack for long mode (1KB). */
|
---|
67 | #define BS3_ADDR_STACK_R0_IST3 0x07400
|
---|
68 | /** IST4 ring-0 stack for long mode (1KB), used for spare 1 stack elsewhere. */
|
---|
69 | #define BS3_ADDR_STACK_R0_IST4 0x07000
|
---|
70 | /** IST5 ring-0 stack for long mode (1KB). */
|
---|
71 | #define BS3_ADDR_STACK_R0_IST5 0x06c00
|
---|
72 | /** IST6 ring-0 stack for long mode (1KB). */
|
---|
73 | #define BS3_ADDR_STACK_R0_IST6 0x06800
|
---|
74 | /** IST7 ring-0 stack for long mode (1KB). */
|
---|
75 | #define BS3_ADDR_STACK_R0_IST7 0x06400
|
---|
76 |
|
---|
77 | /** The base address of the BS3TEXT16 segment (same as BS3_LOAD_ADDR).
|
---|
78 | * @sa BS3_SEL_TEXT16 */
|
---|
79 | #define BS3_ADDR_BS3TEXT16 0x10000
|
---|
80 | /** The base address of the BS3SYSTEM16 segment.
|
---|
81 | * @sa BS3_SEL_SYSTEM16 */
|
---|
82 | #define BS3_ADDR_BS3SYSTEM16 0x20000
|
---|
83 | /** The base address of the BS3DATA16 segment.
|
---|
84 | * @sa BS3_SEL_DATA16 */
|
---|
85 | #define BS3_ADDR_BS3DATA16 0x27000
|
---|
86 | /** @} */
|
---|
87 |
|
---|
88 | /** @name BS3_SEL_XXX - GDT selector assignments.
|
---|
89 | *
|
---|
90 | * The real mode segment numbers for BS16TEXT, BS16DATA and BS16SYSTEM are
|
---|
91 | * present in the GDT, this allows the 16-bit C/C++ and assembly code to
|
---|
92 | * continue using the real mode segment values in ring-0 protected mode.
|
---|
93 | *
|
---|
94 | * The three segments have fixed locations:
|
---|
95 | * | segment | flat address | real mode segment |
|
---|
96 | * | ----------- | ------------ | ----------------- |
|
---|
97 | * | BS3TEXT16 | 0x00010000 | 1000h |
|
---|
98 | * | BS3SYSTEM16 | 0x00020000 | 2000h |
|
---|
99 | * | BS3DATA16 | 0x00027000 | 2700h |
|
---|
100 | *
|
---|
101 | * This means that we've got a lot of GDT space to play around with.
|
---|
102 | *
|
---|
103 | * @{ */
|
---|
104 | #define BS3_SEL_LDT 0x0010 /**< The LDT selector for Bs3Ldt. */
|
---|
105 | #define BS3_SEL_TSS16 0x0020 /**< The 16-bit TSS selector. */
|
---|
106 | #define BS3_SEL_TSS16_DF 0x0028 /**< The 16-bit TSS selector for double faults. */
|
---|
107 | #define BS3_SEL_TSS16_SPARE0 0x0030 /**< The 16-bit TSS selector for testing. */
|
---|
108 | #define BS3_SEL_TSS16_SPARE1 0x0038 /**< The 16-bit TSS selector for testing. */
|
---|
109 | #define BS3_SEL_TSS32 0x0040 /**< The 32-bit TSS selector. */
|
---|
110 | #define BS3_SEL_TSS32_DF 0x0048 /**< The 32-bit TSS selector for double faults. */
|
---|
111 | #define BS3_SEL_TSS32_SPARE0 0x0050 /**< The 32-bit TSS selector for testing. */
|
---|
112 | #define BS3_SEL_TSS32_SPARE1 0x0058 /**< The 32-bit TSS selector for testing. */
|
---|
113 | #define BS3_SEL_TSS32_IOBP_IRB 0x0060 /**< The 32-bit TSS selector with I/O permission and interrupt redirection bitmaps. */
|
---|
114 | #define BS3_SEL_TSS32_IRB 0x0068 /**< The 32-bit TSS selector with only interrupt redirection bitmap (IOPB stripped by limit). */
|
---|
115 | #define BS3_SEL_TSS64 0x0070 /**< The 64-bit TSS selector. */
|
---|
116 | #define BS3_SEL_TSS64_SPARE0 0x0080 /**< The 64-bit TSS selector. */
|
---|
117 | #define BS3_SEL_TSS64_SPARE1 0x0090 /**< The 64-bit TSS selector. */
|
---|
118 | #define BS3_SEL_TSS64_IOBP 0x00a0 /**< The 64-bit TSS selector. */
|
---|
119 |
|
---|
120 | #define BS3_SEL_VMMDEV_MMIO16 0x00f8 /**< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code. */
|
---|
121 |
|
---|
122 | #define BS3_SEL_R0_FIRST 0x0100 /**< The first selector in the ring-0 block. */
|
---|
123 | #define BS3_SEL_R0_CS16 0x0100 /**< ring-0: 16-bit code selector, base 0x10000. */
|
---|
124 | #define BS3_SEL_R0_DS16 0x0108 /**< ring-0: 16-bit data selector, base 0x23000. */
|
---|
125 | #define BS3_SEL_R0_SS16 0x0110 /**< ring-0: 16-bit stack selector, base 0x00000. */
|
---|
126 | #define BS3_SEL_R0_CS32 0x0118 /**< ring-0: 32-bit flat code selector. */
|
---|
127 | #define BS3_SEL_R0_DS32 0x0120 /**< ring-0: 32-bit flat data selector. */
|
---|
128 | #define BS3_SEL_R0_SS32 0x0128 /**< ring-0: 32-bit flat stack selector. */
|
---|
129 | #define BS3_SEL_R0_CS64 0x0130 /**< ring-0: 64-bit flat code selector. */
|
---|
130 | #define BS3_SEL_R0_DS64 0x0138 /**< ring-0: 64-bit flat data & stack selector. */
|
---|
131 | #define BS3_SEL_R0_CS16_EO 0x0140 /**< ring-0: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
132 | #define BS3_SEL_R0_CS16_CNF 0x0148 /**< ring-0: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
133 | #define BS3_SEL_R0_CS16_CNF_EO 0x0150 /**< ring-0: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
134 | #define BS3_SEL_R0_CS32_EO 0x0158 /**< ring-0: 32-bit execute-only code selector, not accessed, flat. */
|
---|
135 | #define BS3_SEL_R0_CS32_CNF 0x0160 /**< ring-0: 32-bit conforming code selector, not accessed, flat. */
|
---|
136 | #define BS3_SEL_R0_CS32_CNF_EO 0x0168 /**< ring-0: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
137 | #define BS3_SEL_R0_CS64_EO 0x0170 /**< ring-0: 64-bit execute-only code selector, not accessed, flat. */
|
---|
138 | #define BS3_SEL_R0_CS64_CNF 0x0178 /**< ring-0: 64-bit conforming code selector, not accessed, flat. */
|
---|
139 | #define BS3_SEL_R0_CS64_CNF_EO 0x0180 /**< ring-0: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
140 |
|
---|
141 | #define BS3_SEL_R1_FIRST 0x0200 /**< The first selector in the ring-1 block. */
|
---|
142 | #define BS3_SEL_R1_CS16 0x0200 /**< ring-1: 16-bit code selector, base 0x10000. */
|
---|
143 | #define BS3_SEL_R1_DS16 0x0208 /**< ring-1: 16-bit data selector, base 0x23000. */
|
---|
144 | #define BS3_SEL_R1_SS16 0x0210 /**< ring-1: 16-bit stack selector, base 0x00000. */
|
---|
145 | #define BS3_SEL_R1_CS32 0x0218 /**< ring-1: 32-bit flat code selector. */
|
---|
146 | #define BS3_SEL_R1_DS32 0x0220 /**< ring-1: 32-bit flat data selector. */
|
---|
147 | #define BS3_SEL_R1_SS32 0x0228 /**< ring-1: 32-bit flat stack selector. */
|
---|
148 | #define BS3_SEL_R1_CS64 0x0230 /**< ring-1: 64-bit flat code selector. */
|
---|
149 | #define BS3_SEL_R1_DS64 0x0238 /**< ring-1: 64-bit flat data & stack selector. */
|
---|
150 | #define BS3_SEL_R1_CS16_EO 0x0240 /**< ring-1: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
151 | #define BS3_SEL_R1_CS16_CNF 0x0248 /**< ring-1: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
152 | #define BS3_SEL_R1_CS16_CNF_EO 0x0250 /**< ring-1: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
153 | #define BS3_SEL_R1_CS32_EO 0x0258 /**< ring-1: 32-bit execute-only code selector, not accessed, flat. */
|
---|
154 | #define BS3_SEL_R1_CS32_CNF 0x0260 /**< ring-1: 32-bit conforming code selector, not accessed, flat. */
|
---|
155 | #define BS3_SEL_R1_CS32_CNF_EO 0x0268 /**< ring-1: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
156 | #define BS3_SEL_R1_CS64_EO 0x0270 /**< ring-1: 64-bit execute-only code selector, not accessed, flat. */
|
---|
157 | #define BS3_SEL_R1_CS64_CNF 0x0278 /**< ring-1: 64-bit conforming code selector, not accessed, flat. */
|
---|
158 | #define BS3_SEL_R1_CS64_CNF_EO 0x0280 /**< ring-1: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
159 |
|
---|
160 | #define BS3_SEL_R2_FIRST 0x0300 /**< The first selector in the ring-2 block. */
|
---|
161 | #define BS3_SEL_R2_CS16 0x0300 /**< ring-2: 16-bit code selector, base 0x10000. */
|
---|
162 | #define BS3_SEL_R2_DS16 0x0308 /**< ring-2: 16-bit data selector, base 0x23000. */
|
---|
163 | #define BS3_SEL_R2_SS16 0x0310 /**< ring-2: 16-bit stack selector, base 0x00000. */
|
---|
164 | #define BS3_SEL_R2_CS32 0x0318 /**< ring-2: 32-bit flat code selector. */
|
---|
165 | #define BS3_SEL_R2_DS32 0x0320 /**< ring-2: 32-bit flat data selector. */
|
---|
166 | #define BS3_SEL_R2_SS32 0x0328 /**< ring-2: 32-bit flat stack selector. */
|
---|
167 | #define BS3_SEL_R2_CS64 0x0330 /**< ring-2: 64-bit flat code selector. */
|
---|
168 | #define BS3_SEL_R2_DS64 0x0338 /**< ring-2: 64-bit flat data & stack selector. */
|
---|
169 | #define BS3_SEL_R2_CS16_EO 0x0340 /**< ring-2: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
170 | #define BS3_SEL_R2_CS16_CNF 0x0348 /**< ring-2: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
171 | #define BS3_SEL_R2_CS16_CNF_EO 0x0350 /**< ring-2: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
172 | #define BS3_SEL_R2_CS32_EO 0x0358 /**< ring-2: 32-bit execute-only code selector, not accessed, flat. */
|
---|
173 | #define BS3_SEL_R2_CS32_CNF 0x0360 /**< ring-2: 32-bit conforming code selector, not accessed, flat. */
|
---|
174 | #define BS3_SEL_R2_CS32_CNF_EO 0x0368 /**< ring-2: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
175 | #define BS3_SEL_R2_CS64_EO 0x0370 /**< ring-2: 64-bit execute-only code selector, not accessed, flat. */
|
---|
176 | #define BS3_SEL_R2_CS64_CNF 0x0378 /**< ring-2: 64-bit conforming code selector, not accessed, flat. */
|
---|
177 | #define BS3_SEL_R2_CS64_CNF_EO 0x0380 /**< ring-2: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
178 |
|
---|
179 | #define BS3_SEL_R3_FIRST 0x0400 /**< The first selector in the ring-3 block. */
|
---|
180 | #define BS3_SEL_R3_CS16 0x0400 /**< ring-3: 16-bit code selector, base 0x10000. */
|
---|
181 | #define BS3_SEL_R3_DS16 0x0408 /**< ring-3: 16-bit data selector, base 0x23000. */
|
---|
182 | #define BS3_SEL_R3_SS16 0x0410 /**< ring-3: 16-bit stack selector, base 0x00000. */
|
---|
183 | #define BS3_SEL_R3_CS32 0x0418 /**< ring-3: 32-bit flat code selector. */
|
---|
184 | #define BS3_SEL_R3_DS32 0x0420 /**< ring-3: 32-bit flat data selector. */
|
---|
185 | #define BS3_SEL_R3_SS32 0x0428 /**< ring-3: 32-bit flat stack selector. */
|
---|
186 | #define BS3_SEL_R3_CS64 0x0430 /**< ring-3: 64-bit flat code selector. */
|
---|
187 | #define BS3_SEL_R3_DS64 0x0438 /**< ring-3: 64-bit flat data & stack selector. */
|
---|
188 | #define BS3_SEL_R3_CS16_EO 0x0440 /**< ring-3: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
189 | #define BS3_SEL_R3_CS16_CNF 0x0448 /**< ring-3: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
190 | #define BS3_SEL_R3_CS16_CNF_EO 0x0450 /**< ring-3: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
|
---|
191 | #define BS3_SEL_R3_CS32_EO 0x0458 /**< ring-3: 32-bit execute-only code selector, not accessed, flat. */
|
---|
192 | #define BS3_SEL_R3_CS32_CNF 0x0460 /**< ring-3: 32-bit conforming code selector, not accessed, flat. */
|
---|
193 | #define BS3_SEL_R3_CS32_CNF_EO 0x0468 /**< ring-3: 32-bit execute-only conforming code selector, not accessed, flat. */
|
---|
194 | #define BS3_SEL_R3_CS64_EO 0x0470 /**< ring-3: 64-bit execute-only code selector, not accessed, flat. */
|
---|
195 | #define BS3_SEL_R3_CS64_CNF 0x0478 /**< ring-3: 64-bit conforming code selector, not accessed, flat. */
|
---|
196 | #define BS3_SEL_R3_CS64_CNF_EO 0x0480 /**< ring-3: 64-bit execute-only conforming code selector, not accessed, flat. */
|
---|
197 |
|
---|
198 | #define BS3_SEL_SPARE_FIRST 0x0500 /**< The first selector in the spare block */
|
---|
199 | #define BS3_SEL_SPARE_00 0x0500 /**< Spare selector number 00h. */
|
---|
200 | #define BS3_SEL_SPARE_01 0x0508 /**< Spare selector number 01h. */
|
---|
201 | #define BS3_SEL_SPARE_02 0x0510 /**< Spare selector number 02h. */
|
---|
202 | #define BS3_SEL_SPARE_03 0x0518 /**< Spare selector number 03h. */
|
---|
203 | #define BS3_SEL_SPARE_04 0x0520 /**< Spare selector number 04h. */
|
---|
204 | #define BS3_SEL_SPARE_05 0x0528 /**< Spare selector number 05h. */
|
---|
205 | #define BS3_SEL_SPARE_06 0x0530 /**< Spare selector number 06h. */
|
---|
206 | #define BS3_SEL_SPARE_07 0x0538 /**< Spare selector number 07h. */
|
---|
207 | #define BS3_SEL_SPARE_08 0x0540 /**< Spare selector number 08h. */
|
---|
208 | #define BS3_SEL_SPARE_09 0x0548 /**< Spare selector number 09h. */
|
---|
209 | #define BS3_SEL_SPARE_0a 0x0550 /**< Spare selector number 0ah. */
|
---|
210 | #define BS3_SEL_SPARE_0b 0x0558 /**< Spare selector number 0bh. */
|
---|
211 | #define BS3_SEL_SPARE_0c 0x0560 /**< Spare selector number 0ch. */
|
---|
212 | #define BS3_SEL_SPARE_0d 0x0568 /**< Spare selector number 0dh. */
|
---|
213 | #define BS3_SEL_SPARE_0e 0x0570 /**< Spare selector number 0eh. */
|
---|
214 | #define BS3_SEL_SPARE_0f 0x0578 /**< Spare selector number 0fh. */
|
---|
215 | #define BS3_SEL_SPARE_10 0x0580 /**< Spare selector number 10h. */
|
---|
216 | #define BS3_SEL_SPARE_11 0x0588 /**< Spare selector number 11h. */
|
---|
217 | #define BS3_SEL_SPARE_12 0x0590 /**< Spare selector number 12h. */
|
---|
218 | #define BS3_SEL_SPARE_13 0x0598 /**< Spare selector number 13h. */
|
---|
219 | #define BS3_SEL_SPARE_14 0x05a0 /**< Spare selector number 14h. */
|
---|
220 | #define BS3_SEL_SPARE_15 0x05a8 /**< Spare selector number 15h. */
|
---|
221 | #define BS3_SEL_SPARE_16 0x05b0 /**< Spare selector number 16h. */
|
---|
222 | #define BS3_SEL_SPARE_17 0x05b8 /**< Spare selector number 17h. */
|
---|
223 | #define BS3_SEL_SPARE_18 0x05c0 /**< Spare selector number 18h. */
|
---|
224 | #define BS3_SEL_SPARE_19 0x05c8 /**< Spare selector number 19h. */
|
---|
225 | #define BS3_SEL_SPARE_1a 0x05d0 /**< Spare selector number 1ah. */
|
---|
226 | #define BS3_SEL_SPARE_1b 0x05d8 /**< Spare selector number 1bh. */
|
---|
227 | #define BS3_SEL_SPARE_1c 0x05e0 /**< Spare selector number 1ch. */
|
---|
228 | #define BS3_SEL_SPARE_1d 0x05e8 /**< Spare selector number 1dh. */
|
---|
229 | #define BS3_SEL_SPARE_1e 0x05f0 /**< Spare selector number 1eh. */
|
---|
230 | #define BS3_SEL_SPARE_1f 0x05f8 /**< Spare selector number 1fh. */
|
---|
231 |
|
---|
232 | #define BS3_SEL_TILED 0x0600 /**< 16-bit data tiling: First - base=0x00000000, limit=64KB. */
|
---|
233 | #define BS3_SEL_TILED_LAST 0x0df8 /**< 16-bit data tiling: Last - base=0x00ff0000, limit=64KB. */
|
---|
234 | #define BS3_SEL_TILED_AREA_SIZE 0x001000000 /**< 16-bit data tiling: Size of addressable area, in bytes. (16 MB) */
|
---|
235 |
|
---|
236 | #define BS3_SEL_FREE_PART1 0x0e00 /**< Free selector space - part \#1. */
|
---|
237 | #define BS3_SEL_FREE_PART1_LAST 0x0ff8 /**< Free selector space - part \#1, last entry. */
|
---|
238 |
|
---|
239 | #define BS3_SEL_TEXT16 0x1000 /**< The BS3TEXT16 selector. */
|
---|
240 |
|
---|
241 | #define BS3_SEL_FREE_PART2 0x1008 /**< Free selector space - part \#2. */
|
---|
242 | #define BS3_SEL_FREE_PART2_LAST 0x1ff8 /**< Free selector space - part \#2, last entry. */
|
---|
243 |
|
---|
244 | #define BS3_SEL_SYSTEM16 0x2000 /**< The BS3SYSTEM16 selector. */
|
---|
245 |
|
---|
246 | #define BS3_SEL_FREE_PART3 0x2008 /**< Free selector space - part \#3. */
|
---|
247 | #define BS3_SEL_FREE_PART3_LAST 0x26f8 /**< Free selector space - part \#3, last entry. */
|
---|
248 |
|
---|
249 | #define BS3_SEL_DATA16 0x2700 /**< The BS3DATA16 selector. */
|
---|
250 |
|
---|
251 | #define BS3_SEL_GDT_LIMIT 0x2707 /**< The GDT limit. */
|
---|
252 | /** @} */
|
---|
253 |
|
---|
254 |
|
---|
255 | /** @def BS3_FAR
|
---|
256 | * For inidicating far pointers in 16-bit code.
|
---|
257 | * Does nothing in 32-bit and 64-bit code. */
|
---|
258 | /** @def BS3_NEAR
|
---|
259 | * For inidicating near pointers in 16-bit code.
|
---|
260 | * Does nothing in 32-bit and 64-bit code. */
|
---|
261 | #ifdef M_I86
|
---|
262 | # define BS3_FAR __far
|
---|
263 | # define BS3_NEAR __near
|
---|
264 | #else
|
---|
265 | # define BS3_FAR
|
---|
266 | # define BS3_NEAR
|
---|
267 | #endif
|
---|
268 |
|
---|
269 | /** @def BS3_CALL
|
---|
270 | * The calling convension used by BS3 functions. */
|
---|
271 | #if ARCH_BITS != 64
|
---|
272 | # define BS3_CALL __cdecl
|
---|
273 | #elif !defined(_MSC_VER)
|
---|
274 | # define BS3_CALL __attribute__((__ms_abi__))
|
---|
275 | #else
|
---|
276 | # define BS3_CALL
|
---|
277 | #endif
|
---|
278 |
|
---|
279 | /** @def IN_BS3KIT
|
---|
280 | * Indicates that we're in the same link job as the BS3Kit code. */
|
---|
281 | #ifdef DOXYGEN_RUNNING
|
---|
282 | # define IN_BS3KIT
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | /** @def BS3_DECL
|
---|
286 | * Declares a BS3Kit function.
|
---|
287 | * @param a_Type The return type. */
|
---|
288 | #ifdef IN_BS3KIT
|
---|
289 | # define BS3_DECL(a_Type) DECLEXPORT(a_Type) BS3_CALL
|
---|
290 | #else
|
---|
291 | # define BS3_DECL(a_Type) DECLIMPORT(a_Type) BS3_CALL
|
---|
292 | #endif
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Constructs a common name.
|
---|
296 | *
|
---|
297 | * Example: BS3_CMN_NM(Bs3Shutdown)
|
---|
298 | *
|
---|
299 | * @param a_Name The name of the function or global variable.
|
---|
300 | */
|
---|
301 | #define BS3_CMN_NM(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * Constructs a data name.
|
---|
305 | *
|
---|
306 | * Example: BS3_DATA_NM(Bs3Gdt)
|
---|
307 | *
|
---|
308 | * @param a_Name The name of the global variable.
|
---|
309 | */
|
---|
310 | #if ARCH_BITS == 64
|
---|
311 | # define BS3_DATA_NM(a_Name) RT_CONCAT(_,a_Name)
|
---|
312 | #else
|
---|
313 | # define BS3_DATA_NM(a_Name) a_Name
|
---|
314 | #endif
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * Template for createing a pointer union type.
|
---|
318 | * @param a_BaseName The base type name.
|
---|
319 | * @param a_Modifier The type modifier.
|
---|
320 | */
|
---|
321 | #define BS3_PTR_UNION_TEMPLATE(a_BaseName, a_Modifiers) \
|
---|
322 | typedef union a_BaseName \
|
---|
323 | { \
|
---|
324 | /** Pointer into the void. */ \
|
---|
325 | a_Modifiers void BS3_FAR *pv; \
|
---|
326 | /** As a signed integer. */ \
|
---|
327 | intptr_t i; \
|
---|
328 | /** As an unsigned integer. */ \
|
---|
329 | uintptr_t u; \
|
---|
330 | /** Pointer to char value. */ \
|
---|
331 | a_Modifiers char BS3_FAR *pch; \
|
---|
332 | /** Pointer to char value. */ \
|
---|
333 | a_Modifiers unsigned char BS3_FAR *puch; \
|
---|
334 | /** Pointer to a int value. */ \
|
---|
335 | a_Modifiers int BS3_FAR *pi; \
|
---|
336 | /** Pointer to a unsigned int value. */ \
|
---|
337 | a_Modifiers unsigned int BS3_FAR *pu; \
|
---|
338 | /** Pointer to a long value. */ \
|
---|
339 | a_Modifiers long BS3_FAR *pl; \
|
---|
340 | /** Pointer to a long value. */ \
|
---|
341 | a_Modifiers unsigned long BS3_FAR *pul; \
|
---|
342 | /** Pointer to a memory size value. */ \
|
---|
343 | a_Modifiers size_t BS3_FAR *pcb; \
|
---|
344 | /** Pointer to a byte value. */ \
|
---|
345 | a_Modifiers uint8_t BS3_FAR *pb; \
|
---|
346 | /** Pointer to a 8-bit unsigned value. */ \
|
---|
347 | a_Modifiers uint8_t BS3_FAR *pu8; \
|
---|
348 | /** Pointer to a 16-bit unsigned value. */ \
|
---|
349 | a_Modifiers uint16_t BS3_FAR *pu16; \
|
---|
350 | /** Pointer to a 32-bit unsigned value. */ \
|
---|
351 | a_Modifiers uint32_t BS3_FAR *pu32; \
|
---|
352 | /** Pointer to a 64-bit unsigned value. */ \
|
---|
353 | a_Modifiers uint64_t BS3_FAR *pu64; \
|
---|
354 | /** Pointer to a UTF-16 character. */ \
|
---|
355 | a_Modifiers RTUTF16 BS3_FAR *pwc; \
|
---|
356 | /** Pointer to a UUID character. */ \
|
---|
357 | a_Modifiers RTUUID BS3_FAR *pUuid; \
|
---|
358 | } a_BaseName; \
|
---|
359 | /** Pointer to a pointer union. */ \
|
---|
360 | typedef a_BaseName *RT_CONCAT(P,a_BaseName)
|
---|
361 | BS3_PTR_UNION_TEMPLATE(BS3PTRUNION, RT_NOTHING);
|
---|
362 | BS3_PTR_UNION_TEMPLATE(BS3CPTRUNION, const);
|
---|
363 | BS3_PTR_UNION_TEMPLATE(BS3VPTRUNION, volatile);
|
---|
364 | BS3_PTR_UNION_TEMPLATE(BS3CVPTRUNION, const volatile);
|
---|
365 |
|
---|
366 |
|
---|
367 | /** @defgroup grp_bs3kit_system System structures
|
---|
368 | * @{ */
|
---|
369 | /** The GDT, indexed by BS3_SEL_XXX shifted by 3. */
|
---|
370 | extern X86DESC BS3_DATA_NM(Bs3Gdt)[(BS3_SEL_GDT_LIMIT + 1) / 8];
|
---|
371 |
|
---|
372 | extern X86DESC64 BS3_DATA_NM(Bs3Gdt_Ldt); /**< @see BS3_SEL_LDT */
|
---|
373 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16); /**< @see BS3_SEL_TSS16 */
|
---|
374 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16DoubleFault); /**< @see BS3_SEL_TSS16_DF */
|
---|
375 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16Spare0); /**< @see BS3_SEL_TSS16_SPARE0 */
|
---|
376 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16Spare1); /**< @see BS3_SEL_TSS16_SPARE1 */
|
---|
377 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32); /**< @see BS3_SEL_TSS32 */
|
---|
378 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32DoubleFault); /**< @see BS3_SEL_TSS32_DF */
|
---|
379 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32Spare0); /**< @see BS3_SEL_TSS32_SPARE0 */
|
---|
380 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32Spare1); /**< @see BS3_SEL_TSS32_SPARE1 */
|
---|
381 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32IobpIntRedirBm); /**< @see BS3_SEL_TSS32_IOBP_IRB */
|
---|
382 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32IntRedirBm); /**< @see BS3_SEL_TSS32_IRB */
|
---|
383 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64); /**< @see BS3_SEL_TSS64 */
|
---|
384 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Spare0); /**< @see BS3_SEL_TSS64_SPARE0 */
|
---|
385 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Spare1); /**< @see BS3_SEL_TSS64_SPARE1 */
|
---|
386 | extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Iobp); /**< @see BS3_SEL_TSS64_IOBP */
|
---|
387 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_MMIO16); /**< @see BS3_SEL_VMMDEV_MMIO16 */
|
---|
388 |
|
---|
389 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_First); /**< @see BS3_SEL_R0_FIRST */
|
---|
390 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16); /**< @see BS3_SEL_R0_CS16 */
|
---|
391 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS16); /**< @see BS3_SEL_R0_DS16 */
|
---|
392 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_SS16); /**< @see BS3_SEL_R0_SS16 */
|
---|
393 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32); /**< @see BS3_SEL_R0_CS32 */
|
---|
394 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS32); /**< @see BS3_SEL_R0_DS32 */
|
---|
395 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_SS32); /**< @see BS3_SEL_R0_SS32 */
|
---|
396 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64); /**< @see BS3_SEL_R0_CS64 */
|
---|
397 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS64); /**< @see BS3_SEL_R0_DS64 */
|
---|
398 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_EO); /**< @see BS3_SEL_R0_CS16_EO */
|
---|
399 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_CNF); /**< @see BS3_SEL_R0_CS16_CNF */
|
---|
400 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_CND_EO); /**< @see BS3_SEL_R0_CS16_CNF_EO */
|
---|
401 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_EO); /**< @see BS3_SEL_R0_CS32_EO */
|
---|
402 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF); /**< @see BS3_SEL_R0_CS32_CNF */
|
---|
403 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF_EO); /**< @see BS3_SEL_R0_CS32_CNF_EO */
|
---|
404 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_EO); /**< @see BS3_SEL_R0_CS64_EO */
|
---|
405 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF); /**< @see BS3_SEL_R0_CS64_CNF */
|
---|
406 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF_EO); /**< @see BS3_SEL_R0_CS64_CNF_EO */
|
---|
407 |
|
---|
408 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_First); /**< @see BS3_SEL_R1_FIRST */
|
---|
409 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16); /**< @see BS3_SEL_R1_CS16 */
|
---|
410 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS16); /**< @see BS3_SEL_R1_DS16 */
|
---|
411 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_SS16); /**< @see BS3_SEL_R1_SS16 */
|
---|
412 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32); /**< @see BS3_SEL_R1_CS32 */
|
---|
413 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS32); /**< @see BS3_SEL_R1_DS32 */
|
---|
414 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_SS32); /**< @see BS3_SEL_R1_SS32 */
|
---|
415 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64); /**< @see BS3_SEL_R1_CS64 */
|
---|
416 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS64); /**< @see BS3_SEL_R1_DS64 */
|
---|
417 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_EO); /**< @see BS3_SEL_R1_CS16_EO */
|
---|
418 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_CNF); /**< @see BS3_SEL_R1_CS16_CNF */
|
---|
419 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_CND_EO); /**< @see BS3_SEL_R1_CS16_CNF_EO */
|
---|
420 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_EO); /**< @see BS3_SEL_R1_CS32_EO */
|
---|
421 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF); /**< @see BS3_SEL_R1_CS32_CNF */
|
---|
422 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF_EO); /**< @see BS3_SEL_R1_CS32_CNF_EO */
|
---|
423 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_EO); /**< @see BS3_SEL_R1_CS64_EO */
|
---|
424 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF); /**< @see BS3_SEL_R1_CS64_CNF */
|
---|
425 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF_EO); /**< @see BS3_SEL_R1_CS64_CNF_EO */
|
---|
426 |
|
---|
427 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_First); /**< @see BS3_SEL_R2_FIRST */
|
---|
428 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16); /**< @see BS3_SEL_R2_CS16 */
|
---|
429 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS16); /**< @see BS3_SEL_R2_DS16 */
|
---|
430 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_SS16); /**< @see BS3_SEL_R2_SS16 */
|
---|
431 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32); /**< @see BS3_SEL_R2_CS32 */
|
---|
432 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS32); /**< @see BS3_SEL_R2_DS32 */
|
---|
433 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_SS32); /**< @see BS3_SEL_R2_SS32 */
|
---|
434 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64); /**< @see BS3_SEL_R2_CS64 */
|
---|
435 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS64); /**< @see BS3_SEL_R2_DS64 */
|
---|
436 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_EO); /**< @see BS3_SEL_R2_CS16_EO */
|
---|
437 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_CNF); /**< @see BS3_SEL_R2_CS16_CNF */
|
---|
438 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_CND_EO); /**< @see BS3_SEL_R2_CS16_CNF_EO */
|
---|
439 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_EO); /**< @see BS3_SEL_R2_CS32_EO */
|
---|
440 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF); /**< @see BS3_SEL_R2_CS32_CNF */
|
---|
441 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF_EO); /**< @see BS3_SEL_R2_CS32_CNF_EO */
|
---|
442 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_EO); /**< @see BS3_SEL_R2_CS64_EO */
|
---|
443 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF); /**< @see BS3_SEL_R2_CS64_CNF */
|
---|
444 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF_EO); /**< @see BS3_SEL_R2_CS64_CNF_EO */
|
---|
445 |
|
---|
446 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_First); /**< @see BS3_SEL_R3_FIRST */
|
---|
447 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16); /**< @see BS3_SEL_R3_CS16 */
|
---|
448 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS16); /**< @see BS3_SEL_R3_DS16 */
|
---|
449 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_SS16); /**< @see BS3_SEL_R3_SS16 */
|
---|
450 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32); /**< @see BS3_SEL_R3_CS32 */
|
---|
451 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS32); /**< @see BS3_SEL_R3_DS32 */
|
---|
452 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_SS32); /**< @see BS3_SEL_R3_SS32 */
|
---|
453 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64); /**< @see BS3_SEL_R3_CS64 */
|
---|
454 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS64); /**< @see BS3_SEL_R3_DS64 */
|
---|
455 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_EO); /**< @see BS3_SEL_R3_CS16_EO */
|
---|
456 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_CNF); /**< @see BS3_SEL_R3_CS16_CNF */
|
---|
457 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_CND_EO); /**< @see BS3_SEL_R3_CS16_CNF_EO */
|
---|
458 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_EO); /**< @see BS3_SEL_R3_CS32_EO */
|
---|
459 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF); /**< @see BS3_SEL_R3_CS32_CNF */
|
---|
460 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF_EO); /**< @see BS3_SEL_R3_CS32_CNF_EO */
|
---|
461 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_EO); /**< @see BS3_SEL_R3_CS64_EO */
|
---|
462 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF); /**< @see BS3_SEL_R3_CS64_CNF */
|
---|
463 | extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF_EO); /**< @see BS3_SEL_R3_CS64_CNF_EO */
|
---|
464 |
|
---|
465 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare00); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_00 */
|
---|
466 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare01); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_01 */
|
---|
467 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare02); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_02 */
|
---|
468 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare03); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_03 */
|
---|
469 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare04); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_04 */
|
---|
470 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare05); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_05 */
|
---|
471 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare06); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_06 */
|
---|
472 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare07); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_07 */
|
---|
473 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare08); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_08 */
|
---|
474 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare09); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_09 */
|
---|
475 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare0a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0a */
|
---|
476 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare0b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0b */
|
---|
477 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare0c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0c */
|
---|
478 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare0d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0d */
|
---|
479 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare0e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0e */
|
---|
480 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare0f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0f */
|
---|
481 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare10); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_10 */
|
---|
482 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare11); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_11 */
|
---|
483 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare12); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_12 */
|
---|
484 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare13); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_13 */
|
---|
485 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare14); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_14 */
|
---|
486 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare15); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_15 */
|
---|
487 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare16); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_16 */
|
---|
488 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare17); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_17 */
|
---|
489 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare18); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_18 */
|
---|
490 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare19); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_19 */
|
---|
491 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare1a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1a */
|
---|
492 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare1b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1b */
|
---|
493 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare1c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1c */
|
---|
494 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare1d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1d */
|
---|
495 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare1e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1e */
|
---|
496 | extern X86DESC BS3_DATA_NM(Bs3GdteSpare1f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1f */
|
---|
497 |
|
---|
498 | /** GDTs setting up the tiled 16-bit access to the first 16 MBs of memory.
|
---|
499 | * @see BS3_SEL_TILED, BS3_SEL_TILED_LAST, BS3_SEL_TILED_AREA_SIZE */
|
---|
500 | extern X86DESC BS3_DATA_NM(Bs3GdteTiled)[256];
|
---|
501 | /** Free GDTes, part \#1. */
|
---|
502 | extern X86DESC BS3_DATA_NM(Bs3GdteFreePart1)[64];
|
---|
503 | /** The BS3CODE16 GDT entry. @see BS3_SEL_TEXT16 */
|
---|
504 | extern X86DESC BS3_DATA_NM(Bs3Gdte_CODE16);
|
---|
505 | /** Free GDTes, part \#2. */
|
---|
506 | extern X86DESC BS3_DATA_NM(Bs3GdteFreePart2)[511];
|
---|
507 | /** The BS3SYSTEM16 GDT entry. */
|
---|
508 | extern X86DESC BS3_DATA_NM(Bs3Gdte_SYSTEM16);
|
---|
509 | /** Free GDTes, part \#3. */
|
---|
510 | extern X86DESC BS3_DATA_NM(Bs3GdteFreePart3)[223];
|
---|
511 | /** The BS3DATA16 GDT entry. */
|
---|
512 | extern X86DESC BS3_DATA_NM(Bs3Gdte_DATA16);
|
---|
513 | /** The end of the GDT (exclusive). */
|
---|
514 | extern X86DESC BS3_DATA_NM(Bs3GdtEnd);
|
---|
515 |
|
---|
516 | /** The default 16-bit TSS. */
|
---|
517 | extern X86TSS16 BS3_DATA_NM(Bs3Tss16);
|
---|
518 | extern X86TSS16 BS3_DATA_NM(Bs3Tss16DoubleFault);
|
---|
519 | extern X86TSS16 BS3_DATA_NM(Bs3Tss16Spare0);
|
---|
520 | extern X86TSS16 BS3_DATA_NM(Bs3Tss16Spare1);
|
---|
521 | /** The default 32-bit TSS. */
|
---|
522 | extern X86TSS32 BS3_DATA_NM(Bs3Tss32);
|
---|
523 | extern X86TSS32 BS3_DATA_NM(Bs3Tss32DoubleFault);
|
---|
524 | extern X86TSS32 BS3_DATA_NM(Bs3Tss32Spare0);
|
---|
525 | extern X86TSS32 BS3_DATA_NM(Bs3Tss32Spare1);
|
---|
526 | /** The default 64-bit TSS. */
|
---|
527 | extern X86TSS64 BS3_DATA_NM(Bs3Tss64);
|
---|
528 | extern X86TSS64 BS3_DATA_NM(Bs3Tss64Spare0);
|
---|
529 | extern X86TSS64 BS3_DATA_NM(Bs3Tss64Spare1);
|
---|
530 | extern X86TSS64 BS3_DATA_NM(Bs3Tss64WithIopb);
|
---|
531 | extern X86TSS32 BS3_DATA_NM(Bs3Tss32WithIopb);
|
---|
532 | /** Interrupt redirection bitmap used by Bs3Tss32WithIopb. */
|
---|
533 | extern uint8_t BS3_DATA_NM(Bs3SharedIntRedirBm)[32];
|
---|
534 | /** I/O permission bitmap used by Bs3Tss32WithIopb and Bs3Tss64WithIopb. */
|
---|
535 | extern uint8_t BS3_DATA_NM(Bs3SharedIobp)[8192+2];
|
---|
536 | /** End of the I/O permission bitmap (exclusive). */
|
---|
537 | extern uint8_t BS3_DATA_NM(Bs3SharedIobpEnd);
|
---|
538 | /** 16-bit IDT. */
|
---|
539 | extern X86DESC BS3_DATA_NM(Bs3Idt16)[256];
|
---|
540 | /** 32-bit IDT. */
|
---|
541 | extern X86DESC BS3_DATA_NM(Bs3Idt32)[256];
|
---|
542 | /** 64-bit IDT. */
|
---|
543 | extern X86DESC64 BS3_DATA_NM(Bs3Idt64)[256];
|
---|
544 | /** Structure for the LIDT instruction for loading the 16-bit IDT. */
|
---|
545 | extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt16);
|
---|
546 | /** Structure for the LIDT instruction for loading the 32-bit IDT. */
|
---|
547 | extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt32);
|
---|
548 | /** Structure for the LIDT instruction for loading the 64-bit IDT. */
|
---|
549 | extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt64);
|
---|
550 | /** Structure for the LIDT instruction for loading the real mode interrupt
|
---|
551 | * vector table.. */
|
---|
552 | extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Ivt);
|
---|
553 | /** Structure for the LGDT instruction for loading the GDT. */
|
---|
554 | extern X86XDTR64 BS3_DATA_NM(Bs3Lgdt_Gdt);
|
---|
555 | /** The LDT (all entries are empty, fill in for testing). */
|
---|
556 | extern X86DESC BS3_DATA_NM(Bs3Ldt)[118];
|
---|
557 | /** The end of the LDT (exclusive). */
|
---|
558 | extern X86DESC BS3_DATA_NM(Bs3LdtEnd);
|
---|
559 |
|
---|
560 |
|
---|
561 |
|
---|
562 |
|
---|
563 | /** @defgroup grp_bs3kit_cmn Common Functions and Data
|
---|
564 | *
|
---|
565 | * The common functions comes in three variations: 16-bit, 32-bit and 64-bit.
|
---|
566 | * Templated code uses the #BS3_CMN_NM macro to mangle the name according to the
|
---|
567 | * desired
|
---|
568 | *
|
---|
569 | * @{
|
---|
570 | */
|
---|
571 |
|
---|
572 | /**
|
---|
573 | * Panic, never return.
|
---|
574 | *
|
---|
575 | * The current implementation will only halt the CPU.
|
---|
576 | */
|
---|
577 | BS3_DECL(void) Bs3Panic_c16(void);
|
---|
578 | BS3_DECL(void) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16 */
|
---|
579 | BS3_DECL(void) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16 */
|
---|
580 | #define Bs3Panic BS3_CMN_NM(Bs3Panic) /**< Selects #Bs3Panic_c16, #Bs3Panic_c32 or #Bs3Panic_c64. */
|
---|
581 |
|
---|
582 | /**
|
---|
583 | * Shutdown the system, never returns.
|
---|
584 | *
|
---|
585 | * This currently only works for VMs. When running on real systems it will
|
---|
586 | * just halt the CPU.
|
---|
587 | */
|
---|
588 | BS3_DECL(void) Bs3Shutdown_c16(void);
|
---|
589 | BS3_DECL(void) Bs3Shutdown_c32(void); /**< @copydoc Bs3Shutdown_c16 */
|
---|
590 | BS3_DECL(void) Bs3Shutdown_c64(void); /**< @copydoc Bs3Shutdown_c16 */
|
---|
591 | #define Bs3Shutdown BS3_CMN_NM(Bs3Shutdown) /**< Selects #Bs3Shutdown_c16, #Bs3Shutdown_c32 or #Bs3Shutdown_c64. */
|
---|
592 |
|
---|
593 | /**
|
---|
594 | * Prints a 32-bit unsigned value as hex to the screen.
|
---|
595 | *
|
---|
596 | * @param uValue The 32-bit value.
|
---|
597 | */
|
---|
598 | BS3_DECL(void) Bs3PrintU32_c16(uint32_t uValue);
|
---|
599 | BS3_DECL(void) Bs3PrintU32_c32(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
|
---|
600 | BS3_DECL(void) Bs3PrintU32_c64(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
|
---|
601 | #define Bs3PrintU32 BS3_CMN_NM(Bs3PrintU32) /**< Selects #Bs3PrintU32_c16, #Bs3PrintU32_c32 or #Bs3PrintU32_c64. */
|
---|
602 |
|
---|
603 | /**
|
---|
604 | * Prints a string to the screen.
|
---|
605 | *
|
---|
606 | * @param pszString The string to print.
|
---|
607 | */
|
---|
608 | BS3_DECL(void) Bs3PrintStr_c16(const char BS3_FAR *pszString);
|
---|
609 | BS3_DECL(void) Bs3PrintStr_c32(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
|
---|
610 | BS3_DECL(void) Bs3PrintStr_c64(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
|
---|
611 | #define Bs3PrintStr BS3_CMN_NM(Bs3PrintStr) /**< Selects #Bs3PrintStr_c16, #Bs3PrintStr_c32 or #Bs3PrintStr_c64. */
|
---|
612 |
|
---|
613 | /**
|
---|
614 | * Prints a char to the screen.
|
---|
615 | *
|
---|
616 | * @param ch The character to print.
|
---|
617 | */
|
---|
618 | BS3_DECL(void) Bs3PrintChr_c16(char ch);
|
---|
619 | BS3_DECL(void) Bs3PrintChr_c32(char ch); /**< @copydoc Bs3PrintChr_c16 */
|
---|
620 | BS3_DECL(void) Bs3PrintChr_c64(char ch); /**< @copydoc Bs3PrintChr_c16 */
|
---|
621 | #define Bs3PrintChr BS3_CMN_NM(Bs3PrintChr) /**< Selects #Bs3PrintChr_c16, #Bs3PrintChr_c32 or #Bs3PrintChr_c64. */
|
---|
622 |
|
---|
623 |
|
---|
624 | /**
|
---|
625 | * Finds the length of a zero terminated string.
|
---|
626 | *
|
---|
627 | * @returns String length in chars/bytes.
|
---|
628 | * @param pszString The string to examine.
|
---|
629 | */
|
---|
630 | BS3_DECL(size_t) Bs3StrLen_c16(const char BS3_FAR *pszString);
|
---|
631 | BS3_DECL(size_t) Bs3StrLen_c32(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
|
---|
632 | BS3_DECL(size_t) Bs3StrLen_c64(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
|
---|
633 | #define Bs3StrLen BS3_CMN_NM(Bs3StrLen) /**< Selects #Bs3StrLen_c16, #Bs3StrLen_c32 or #Bs3StrLen_c64. */
|
---|
634 |
|
---|
635 | /**
|
---|
636 | * Finds the length of a zero terminated string, but with a max length.
|
---|
637 | *
|
---|
638 | * @returns String length in chars/bytes, or @a cchMax if no zero-terminator
|
---|
639 | * was found before we reached the limit.
|
---|
640 | * @param pszString The string to examine.
|
---|
641 | * @param cchMax The max length to examine.
|
---|
642 | */
|
---|
643 | BS3_DECL(size_t) Bs3StrNLen_c16(const char BS3_FAR *pszString, size_t cchMax);
|
---|
644 | BS3_DECL(size_t) Bs3StrNLen_c32(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
|
---|
645 | BS3_DECL(size_t) Bs3StrNLen_c64(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
|
---|
646 | #define Bs3StrNLen BS3_CMN_NM(Bs3StrNLen) /**< Selects #Bs3StrNLen_c16, #Bs3StrNLen_c32 or #Bs3StrNLen_c64. */
|
---|
647 |
|
---|
648 | /**
|
---|
649 | * CRT style unsafe strcpy.
|
---|
650 | *
|
---|
651 | * @returns pszDst.
|
---|
652 | * @param pszDst The destination buffer. Must be large enough to
|
---|
653 | * hold the source string.
|
---|
654 | * @param pszSrc The source string.
|
---|
655 | */
|
---|
656 | BS3_DECL(char BS3_FAR *) Bs3StrCpy_c16(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc);
|
---|
657 | BS3_DECL(char BS3_FAR *) Bs3StrCpy_c32(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
|
---|
658 | BS3_DECL(char BS3_FAR *) Bs3StrCpy_c64(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
|
---|
659 | #define Bs3StrCpy BS3_CMN_NM(Bs3StrCpy) /**< Selects #Bs3StrCpy_c16, #Bs3StrCpy_c32 or #Bs3StrCpy_c64. */
|
---|
660 |
|
---|
661 | /**
|
---|
662 | * CRT style memcpy.
|
---|
663 | *
|
---|
664 | * @returns pvDst
|
---|
665 | * @param pvDst The destination buffer.
|
---|
666 | * @param pvSrc The source buffer.
|
---|
667 | * @param cbCopy The number of bytes to copy.
|
---|
668 | */
|
---|
669 | BS3_DECL(void BS3_FAR *) Bs3MemCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
|
---|
670 | BS3_DECL(void BS3_FAR *) Bs3MemCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
|
---|
671 | BS3_DECL(void BS3_FAR *) Bs3MemCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
|
---|
672 | #define Bs3MemCpy BS3_CMN_NM(Bs3MemCpy) /**< Selects #Bs3MemCpy_c16, #Bs3MemCpy_c32 or #Bs3MemCpy_c64. */
|
---|
673 |
|
---|
674 | /**
|
---|
675 | * GNU (?) style mempcpy.
|
---|
676 | *
|
---|
677 | * @returns pvDst + cbCopy
|
---|
678 | * @param pvDst The destination buffer.
|
---|
679 | * @param pvSrc The source buffer.
|
---|
680 | * @param cbCopy The number of bytes to copy.
|
---|
681 | */
|
---|
682 | BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
|
---|
683 | BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
|
---|
684 | BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
|
---|
685 | #define Bs3MemPCpy BS3_CMN_NM(Bs3MemPCpy) /**< Selects #Bs3MemPCpy_c16, #Bs3MemPCpy_c32 or #Bs3MemPCpy_c64. */
|
---|
686 |
|
---|
687 | /**
|
---|
688 | * CRT style memmove (overlapping buffers is fine).
|
---|
689 | *
|
---|
690 | * @returns pvDst
|
---|
691 | * @param pvDst The destination buffer.
|
---|
692 | * @param pvSrc The source buffer.
|
---|
693 | * @param cbCopy The number of bytes to copy.
|
---|
694 | */
|
---|
695 | BS3_DECL(void BS3_FAR *) Bs3MemMove_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
|
---|
696 | BS3_DECL(void BS3_FAR *) Bs3MemMove_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
|
---|
697 | BS3_DECL(void BS3_FAR *) Bs3MemMove_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
|
---|
698 | #define Bs3MemMove BS3_CMN_NM(Bs3MemMove) /**< Selects #Bs3MemMove_c16, #Bs3MemMove_c32 or #Bs3MemMove_c64. */
|
---|
699 |
|
---|
700 |
|
---|
701 |
|
---|
702 | /**
|
---|
703 | * Equivalent to RTTestCreate + RTTestBanner.
|
---|
704 | *
|
---|
705 | * @param pszTest The test name.
|
---|
706 | */
|
---|
707 | BS3_DECL(void) Bs3TestInit_c16(const char BS3_FAR *pszTest);
|
---|
708 | BS3_DECL(void) Bs3TestInit_c32(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
|
---|
709 | BS3_DECL(void) Bs3TestInit_c64(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
|
---|
710 | #define Bs3TestInit BS3_CMN_NM(Bs3TestInit) /**< Selects #Bs3TestInit_c16, #Bs3TestInit_c32 or #Bs3TestInit_c64. */
|
---|
711 |
|
---|
712 |
|
---|
713 | /** @} */
|
---|
714 |
|
---|
715 |
|
---|
716 |
|
---|
717 | /** @defgroup grp_bs3kit_mode Mode Specific Functions and Data
|
---|
718 | *
|
---|
719 | * The mode specific functions come in bit count variations and CPU mode
|
---|
720 | * variations. The bs3kit-template-header.h/mac defines the BS3_NM macro to
|
---|
721 | * mangle a function or variable name according to the target CPU mode. In
|
---|
722 | * non-templated code, it's common to spell the name out in full.
|
---|
723 | *
|
---|
724 | * @{
|
---|
725 | */
|
---|
726 |
|
---|
727 |
|
---|
728 | /** @} */
|
---|
729 |
|
---|
730 | #endif
|
---|
731 |
|
---|