VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h@ 58814

Last change on this file since 58814 was 58814, checked in by vboxsync, 9 years ago

bs3kit: Solved the FLAT fixup issue for OMF files, while for COFF/ELF (64-bit only) we cannot do absolute fixups in places we care about (like just won't do what we want it to). Made the object converter check for COFF relocation we don't want, found 4 in one file and convinced the compiler to use RIP relative addressing instead of image relative addressing. (There's an alternative I've been avoiding, which is linking LX and using RTLdr to do the final linking.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 69.0 KB
Line 
1/* $Id: bs3kit.h 58814 2015-11-22 06:50:50Z vboxsync $ */
2/** @file
3 * BS3Kit - structures, symbols, macros and stuff.
4 */
5
6/*
7 * Copyright (C) 2007-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___bs3kit_h
28#define ___bs3kit_h
29
30#ifndef DOXYGEN_RUNNING
31# define IN_RING0
32#endif
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#ifndef DOXYGEN_RUNNING
36# undef IN_RING0
37#endif
38
39/*
40 * We may want to reuse some IPRT code in the common name space, so we
41 * redefine the RT_MANGLER to work like BS3_CMN_NM. (We cannot use
42 * BS3_CMN_NM yet, as we need to include IPRT headers with function
43 * declarations before we can define it. Thus the duplciate effort.)
44 */
45#define RT_MANGLER(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
46#include <iprt/mangling.h>
47#include <iprt/x86.h>
48
49
50
51RT_C_DECLS_BEGIN
52
53/** @defgroup grp_bs3kit BS3Kit
54 * @{ */
55
56
57/** @name BS3_ADDR_XXX - Static Memory Allocation
58 * @{ */
59/** The flat load address for the code after the bootsector. */
60#define BS3_ADDR_LOAD 0x10000
61/** Where we save the boot registers during init.
62 * Located right before the code. */
63#define BS3_ADDR_REG_SAVE (BS3_ADDR_LOAD - sizeof(BS3REGS) - 8)
64/** Where the stack starts (initial RSP value).
65 * Located 16 bytes (assumed by boot sector) before the saved registers.
66 * SS.BASE=0. The size is a little short of 32KB */
67#define BS3_ADDR_STACK (BS3_ADDR_REG_SAVE - 16)
68/** The ring-0 stack (8KB) for ring transitions. */
69#define BS3_ADDR_STACK_R0 0x06000
70/** The ring-1 stack (8KB) for ring transitions. */
71#define BS3_ADDR_STACK_R1 0x04000
72/** The ring-2 stack (8KB) for ring transitions. */
73#define BS3_ADDR_STACK_R2 0x02000
74/** IST1 ring-0 stack for long mode (4KB), used for double faults elsewhere. */
75#define BS3_ADDR_STACK_R0_IST1 0x09000
76/** IST2 ring-0 stack for long mode (3KB), used for spare 0 stack elsewhere. */
77#define BS3_ADDR_STACK_R0_IST2 0x08000
78/** IST3 ring-0 stack for long mode (1KB). */
79#define BS3_ADDR_STACK_R0_IST3 0x07400
80/** IST4 ring-0 stack for long mode (1KB), used for spare 1 stack elsewhere. */
81#define BS3_ADDR_STACK_R0_IST4 0x07000
82/** IST5 ring-0 stack for long mode (1KB). */
83#define BS3_ADDR_STACK_R0_IST5 0x06c00
84/** IST6 ring-0 stack for long mode (1KB). */
85#define BS3_ADDR_STACK_R0_IST6 0x06800
86/** IST7 ring-0 stack for long mode (1KB). */
87#define BS3_ADDR_STACK_R0_IST7 0x06400
88
89/** The base address of the BS3TEXT16 segment (same as BS3_LOAD_ADDR).
90 * @sa BS3_SEL_TEXT16 */
91#define BS3_ADDR_BS3TEXT16 0x10000
92/** The base address of the BS3SYSTEM16 segment.
93 * @sa BS3_SEL_SYSTEM16 */
94#define BS3_ADDR_BS3SYSTEM16 0x20000
95/** The base address of the BS3DATA16 segment.
96 * @sa BS3_SEL_DATA16 */
97#define BS3_ADDR_BS3DATA16 0x27000
98/** @} */
99
100/** @name BS3_SEL_XXX - GDT selector assignments.
101 *
102 * The real mode segment numbers for BS16TEXT, BS16DATA and BS16SYSTEM are
103 * present in the GDT, this allows the 16-bit C/C++ and assembly code to
104 * continue using the real mode segment values in ring-0 protected mode.
105 *
106 * The three segments have fixed locations:
107 * | segment | flat address | real mode segment |
108 * | ----------- | ------------ | ----------------- |
109 * | BS3TEXT16 | 0x00010000 | 1000h |
110 * | BS3SYSTEM16 | 0x00020000 | 2000h |
111 * | BS3DATA16 | 0x00027000 | 2700h |
112 *
113 * This means that we've got a lot of GDT space to play around with.
114 *
115 * @{ */
116#define BS3_SEL_LDT 0x0010 /**< The LDT selector for Bs3Ldt. */
117#define BS3_SEL_TSS16 0x0020 /**< The 16-bit TSS selector. */
118#define BS3_SEL_TSS16_DF 0x0028 /**< The 16-bit TSS selector for double faults. */
119#define BS3_SEL_TSS16_SPARE0 0x0030 /**< The 16-bit TSS selector for testing. */
120#define BS3_SEL_TSS16_SPARE1 0x0038 /**< The 16-bit TSS selector for testing. */
121#define BS3_SEL_TSS32 0x0040 /**< The 32-bit TSS selector. */
122#define BS3_SEL_TSS32_DF 0x0048 /**< The 32-bit TSS selector for double faults. */
123#define BS3_SEL_TSS32_SPARE0 0x0050 /**< The 32-bit TSS selector for testing. */
124#define BS3_SEL_TSS32_SPARE1 0x0058 /**< The 32-bit TSS selector for testing. */
125#define BS3_SEL_TSS32_IOBP_IRB 0x0060 /**< The 32-bit TSS selector with I/O permission and interrupt redirection bitmaps. */
126#define BS3_SEL_TSS32_IRB 0x0068 /**< The 32-bit TSS selector with only interrupt redirection bitmap (IOPB stripped by limit). */
127#define BS3_SEL_TSS64 0x0070 /**< The 64-bit TSS selector. */
128#define BS3_SEL_TSS64_SPARE0 0x0080 /**< The 64-bit TSS selector. */
129#define BS3_SEL_TSS64_SPARE1 0x0090 /**< The 64-bit TSS selector. */
130#define BS3_SEL_TSS64_IOBP 0x00a0 /**< The 64-bit TSS selector. */
131
132#define BS3_SEL_VMMDEV_MMIO16 0x00f8 /**< Selector for accessing the VMMDev MMIO segment at 0100000h from 16-bit code. */
133
134#define BS3_SEL_RING_SHIFT 8 /**< For the formula: BS3_SEL_R0_XXX + ((cs & 3) << BS3_SEL_RING_SHIFT) */
135
136#define BS3_SEL_R0_FIRST 0x0100 /**< The first selector in the ring-0 block. */
137#define BS3_SEL_R0_CS16 0x0100 /**< ring-0: 16-bit code selector, base 0x10000. */
138#define BS3_SEL_R0_DS16 0x0108 /**< ring-0: 16-bit data selector, base 0x23000. */
139#define BS3_SEL_R0_SS16 0x0110 /**< ring-0: 16-bit stack selector, base 0x00000. */
140#define BS3_SEL_R0_CS32 0x0118 /**< ring-0: 32-bit flat code selector. */
141#define BS3_SEL_R0_DS32 0x0120 /**< ring-0: 32-bit flat data selector. */
142#define BS3_SEL_R0_SS32 0x0128 /**< ring-0: 32-bit flat stack selector. */
143#define BS3_SEL_R0_CS64 0x0130 /**< ring-0: 64-bit flat code selector. */
144#define BS3_SEL_R0_DS64 0x0138 /**< ring-0: 64-bit flat data & stack selector. */
145#define BS3_SEL_R0_CS16_EO 0x0140 /**< ring-0: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
146#define BS3_SEL_R0_CS16_CNF 0x0148 /**< ring-0: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
147#define BS3_SEL_R0_CS16_CNF_EO 0x0150 /**< ring-0: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
148#define BS3_SEL_R0_CS32_EO 0x0158 /**< ring-0: 32-bit execute-only code selector, not accessed, flat. */
149#define BS3_SEL_R0_CS32_CNF 0x0160 /**< ring-0: 32-bit conforming code selector, not accessed, flat. */
150#define BS3_SEL_R0_CS32_CNF_EO 0x0168 /**< ring-0: 32-bit execute-only conforming code selector, not accessed, flat. */
151#define BS3_SEL_R0_CS64_EO 0x0170 /**< ring-0: 64-bit execute-only code selector, not accessed, flat. */
152#define BS3_SEL_R0_CS64_CNF 0x0178 /**< ring-0: 64-bit conforming code selector, not accessed, flat. */
153#define BS3_SEL_R0_CS64_CNF_EO 0x0180 /**< ring-0: 64-bit execute-only conforming code selector, not accessed, flat. */
154
155#define BS3_SEL_R1_FIRST 0x0200 /**< The first selector in the ring-1 block. */
156#define BS3_SEL_R1_CS16 0x0200 /**< ring-1: 16-bit code selector, base 0x10000. */
157#define BS3_SEL_R1_DS16 0x0208 /**< ring-1: 16-bit data selector, base 0x23000. */
158#define BS3_SEL_R1_SS16 0x0210 /**< ring-1: 16-bit stack selector, base 0x00000. */
159#define BS3_SEL_R1_CS32 0x0218 /**< ring-1: 32-bit flat code selector. */
160#define BS3_SEL_R1_DS32 0x0220 /**< ring-1: 32-bit flat data selector. */
161#define BS3_SEL_R1_SS32 0x0228 /**< ring-1: 32-bit flat stack selector. */
162#define BS3_SEL_R1_CS64 0x0230 /**< ring-1: 64-bit flat code selector. */
163#define BS3_SEL_R1_DS64 0x0238 /**< ring-1: 64-bit flat data & stack selector. */
164#define BS3_SEL_R1_CS16_EO 0x0240 /**< ring-1: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
165#define BS3_SEL_R1_CS16_CNF 0x0248 /**< ring-1: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
166#define BS3_SEL_R1_CS16_CNF_EO 0x0250 /**< ring-1: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
167#define BS3_SEL_R1_CS32_EO 0x0258 /**< ring-1: 32-bit execute-only code selector, not accessed, flat. */
168#define BS3_SEL_R1_CS32_CNF 0x0260 /**< ring-1: 32-bit conforming code selector, not accessed, flat. */
169#define BS3_SEL_R1_CS32_CNF_EO 0x0268 /**< ring-1: 32-bit execute-only conforming code selector, not accessed, flat. */
170#define BS3_SEL_R1_CS64_EO 0x0270 /**< ring-1: 64-bit execute-only code selector, not accessed, flat. */
171#define BS3_SEL_R1_CS64_CNF 0x0278 /**< ring-1: 64-bit conforming code selector, not accessed, flat. */
172#define BS3_SEL_R1_CS64_CNF_EO 0x0280 /**< ring-1: 64-bit execute-only conforming code selector, not accessed, flat. */
173
174#define BS3_SEL_R2_FIRST 0x0300 /**< The first selector in the ring-2 block. */
175#define BS3_SEL_R2_CS16 0x0300 /**< ring-2: 16-bit code selector, base 0x10000. */
176#define BS3_SEL_R2_DS16 0x0308 /**< ring-2: 16-bit data selector, base 0x23000. */
177#define BS3_SEL_R2_SS16 0x0310 /**< ring-2: 16-bit stack selector, base 0x00000. */
178#define BS3_SEL_R2_CS32 0x0318 /**< ring-2: 32-bit flat code selector. */
179#define BS3_SEL_R2_DS32 0x0320 /**< ring-2: 32-bit flat data selector. */
180#define BS3_SEL_R2_SS32 0x0328 /**< ring-2: 32-bit flat stack selector. */
181#define BS3_SEL_R2_CS64 0x0330 /**< ring-2: 64-bit flat code selector. */
182#define BS3_SEL_R2_DS64 0x0338 /**< ring-2: 64-bit flat data & stack selector. */
183#define BS3_SEL_R2_CS16_EO 0x0340 /**< ring-2: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
184#define BS3_SEL_R2_CS16_CNF 0x0348 /**< ring-2: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
185#define BS3_SEL_R2_CS16_CNF_EO 0x0350 /**< ring-2: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
186#define BS3_SEL_R2_CS32_EO 0x0358 /**< ring-2: 32-bit execute-only code selector, not accessed, flat. */
187#define BS3_SEL_R2_CS32_CNF 0x0360 /**< ring-2: 32-bit conforming code selector, not accessed, flat. */
188#define BS3_SEL_R2_CS32_CNF_EO 0x0368 /**< ring-2: 32-bit execute-only conforming code selector, not accessed, flat. */
189#define BS3_SEL_R2_CS64_EO 0x0370 /**< ring-2: 64-bit execute-only code selector, not accessed, flat. */
190#define BS3_SEL_R2_CS64_CNF 0x0378 /**< ring-2: 64-bit conforming code selector, not accessed, flat. */
191#define BS3_SEL_R2_CS64_CNF_EO 0x0380 /**< ring-2: 64-bit execute-only conforming code selector, not accessed, flat. */
192
193#define BS3_SEL_R3_FIRST 0x0400 /**< The first selector in the ring-3 block. */
194#define BS3_SEL_R3_CS16 0x0400 /**< ring-3: 16-bit code selector, base 0x10000. */
195#define BS3_SEL_R3_DS16 0x0408 /**< ring-3: 16-bit data selector, base 0x23000. */
196#define BS3_SEL_R3_SS16 0x0410 /**< ring-3: 16-bit stack selector, base 0x00000. */
197#define BS3_SEL_R3_CS32 0x0418 /**< ring-3: 32-bit flat code selector. */
198#define BS3_SEL_R3_DS32 0x0420 /**< ring-3: 32-bit flat data selector. */
199#define BS3_SEL_R3_SS32 0x0428 /**< ring-3: 32-bit flat stack selector. */
200#define BS3_SEL_R3_CS64 0x0430 /**< ring-3: 64-bit flat code selector. */
201#define BS3_SEL_R3_DS64 0x0438 /**< ring-3: 64-bit flat data & stack selector. */
202#define BS3_SEL_R3_CS16_EO 0x0440 /**< ring-3: 16-bit execute-only code selector, not accessed, 0xfffe limit, CS16 base. */
203#define BS3_SEL_R3_CS16_CNF 0x0448 /**< ring-3: 16-bit conforming code selector, not accessed, 0xfffe limit, CS16 base. */
204#define BS3_SEL_R3_CS16_CNF_EO 0x0450 /**< ring-3: 16-bit execute-only conforming code selector, not accessed, 0xfffe limit, CS16 base. */
205#define BS3_SEL_R3_CS32_EO 0x0458 /**< ring-3: 32-bit execute-only code selector, not accessed, flat. */
206#define BS3_SEL_R3_CS32_CNF 0x0460 /**< ring-3: 32-bit conforming code selector, not accessed, flat. */
207#define BS3_SEL_R3_CS32_CNF_EO 0x0468 /**< ring-3: 32-bit execute-only conforming code selector, not accessed, flat. */
208#define BS3_SEL_R3_CS64_EO 0x0470 /**< ring-3: 64-bit execute-only code selector, not accessed, flat. */
209#define BS3_SEL_R3_CS64_CNF 0x0478 /**< ring-3: 64-bit conforming code selector, not accessed, flat. */
210#define BS3_SEL_R3_CS64_CNF_EO 0x0480 /**< ring-3: 64-bit execute-only conforming code selector, not accessed, flat. */
211
212#define BS3_SEL_SPARE_FIRST 0x0500 /**< The first selector in the spare block */
213#define BS3_SEL_SPARE_00 0x0500 /**< Spare selector number 00h. */
214#define BS3_SEL_SPARE_01 0x0508 /**< Spare selector number 01h. */
215#define BS3_SEL_SPARE_02 0x0510 /**< Spare selector number 02h. */
216#define BS3_SEL_SPARE_03 0x0518 /**< Spare selector number 03h. */
217#define BS3_SEL_SPARE_04 0x0520 /**< Spare selector number 04h. */
218#define BS3_SEL_SPARE_05 0x0528 /**< Spare selector number 05h. */
219#define BS3_SEL_SPARE_06 0x0530 /**< Spare selector number 06h. */
220#define BS3_SEL_SPARE_07 0x0538 /**< Spare selector number 07h. */
221#define BS3_SEL_SPARE_08 0x0540 /**< Spare selector number 08h. */
222#define BS3_SEL_SPARE_09 0x0548 /**< Spare selector number 09h. */
223#define BS3_SEL_SPARE_0a 0x0550 /**< Spare selector number 0ah. */
224#define BS3_SEL_SPARE_0b 0x0558 /**< Spare selector number 0bh. */
225#define BS3_SEL_SPARE_0c 0x0560 /**< Spare selector number 0ch. */
226#define BS3_SEL_SPARE_0d 0x0568 /**< Spare selector number 0dh. */
227#define BS3_SEL_SPARE_0e 0x0570 /**< Spare selector number 0eh. */
228#define BS3_SEL_SPARE_0f 0x0578 /**< Spare selector number 0fh. */
229#define BS3_SEL_SPARE_10 0x0580 /**< Spare selector number 10h. */
230#define BS3_SEL_SPARE_11 0x0588 /**< Spare selector number 11h. */
231#define BS3_SEL_SPARE_12 0x0590 /**< Spare selector number 12h. */
232#define BS3_SEL_SPARE_13 0x0598 /**< Spare selector number 13h. */
233#define BS3_SEL_SPARE_14 0x05a0 /**< Spare selector number 14h. */
234#define BS3_SEL_SPARE_15 0x05a8 /**< Spare selector number 15h. */
235#define BS3_SEL_SPARE_16 0x05b0 /**< Spare selector number 16h. */
236#define BS3_SEL_SPARE_17 0x05b8 /**< Spare selector number 17h. */
237#define BS3_SEL_SPARE_18 0x05c0 /**< Spare selector number 18h. */
238#define BS3_SEL_SPARE_19 0x05c8 /**< Spare selector number 19h. */
239#define BS3_SEL_SPARE_1a 0x05d0 /**< Spare selector number 1ah. */
240#define BS3_SEL_SPARE_1b 0x05d8 /**< Spare selector number 1bh. */
241#define BS3_SEL_SPARE_1c 0x05e0 /**< Spare selector number 1ch. */
242#define BS3_SEL_SPARE_1d 0x05e8 /**< Spare selector number 1dh. */
243#define BS3_SEL_SPARE_1e 0x05f0 /**< Spare selector number 1eh. */
244#define BS3_SEL_SPARE_1f 0x05f8 /**< Spare selector number 1fh. */
245
246#define BS3_SEL_TILED 0x0600 /**< 16-bit data tiling: First - base=0x00000000, limit=64KB. */
247#define BS3_SEL_TILED_LAST 0x0df8 /**< 16-bit data tiling: Last - base=0x00ff0000, limit=64KB. */
248#define BS3_SEL_TILED_AREA_SIZE 0x001000000 /**< 16-bit data tiling: Size of addressable area, in bytes. (16 MB) */
249
250#define BS3_SEL_FREE_PART1 0x0e00 /**< Free selector space - part \#1. */
251#define BS3_SEL_FREE_PART1_LAST 0x0ff8 /**< Free selector space - part \#1, last entry. */
252
253#define BS3_SEL_TEXT16 0x1000 /**< The BS3TEXT16 selector. */
254
255#define BS3_SEL_FREE_PART2 0x1008 /**< Free selector space - part \#2. */
256#define BS3_SEL_FREE_PART2_LAST 0x1ff8 /**< Free selector space - part \#2, last entry. */
257
258#define BS3_SEL_SYSTEM16 0x2000 /**< The BS3SYSTEM16 selector. */
259
260#define BS3_SEL_FREE_PART3 0x2008 /**< Free selector space - part \#3. */
261#define BS3_SEL_FREE_PART3_LAST 0x26f8 /**< Free selector space - part \#3, last entry. */
262
263#define BS3_SEL_DATA16 0x2700 /**< The BS3DATA16 selector. */
264
265#define BS3_SEL_GDT_LIMIT 0x2707 /**< The GDT limit. */
266/** @} */
267
268
269/** @def BS3_FAR
270 * For indicating far pointers in 16-bit code.
271 * Does nothing in 32-bit and 64-bit code. */
272/** @def BS3_NEAR
273 * For indicating near pointers in 16-bit code.
274 * Does nothing in 32-bit and 64-bit code. */
275/** @def BS3_FAR_CODE
276 * For indicating far 16-bit functions.
277 * Does nothing in 32-bit and 64-bit code. */
278/** @def BS3_NEAR_CODE
279 * For indicating near 16-bit functions.
280 * Does nothing in 32-bit and 64-bit code. */
281#ifdef M_I86
282# define BS3_FAR __far
283# define BS3_NEAR __near
284# define BS3_FAR_CODE __far
285# define BS3_NEAR_CODE __near
286#else
287# define BS3_FAR
288# define BS3_NEAR
289# define BS3_FAR_CODE
290# define BS3_NEAR_CODE
291#endif
292
293#if ARCH_BITS == 16 || defined(DOXYGEN_RUNNING)
294/** @def BS3_FP_SEG
295 * Get the selector (segment) part of a far pointer.
296 * @returns selector.
297 * @param a_pv Far pointer.
298 */
299# define BS3_FP_SEG(a_pv) ((uint16_t)(__segment)(void BS3_FAR *)(a_pv))
300/** @def BS3_FP_OFF
301 * Get the segment offset part of a far pointer.
302 * @returns offset.
303 * @param a_pv Far pointer.
304 */
305# define BS3_FP_OFF(a_pv) ((uint16_t)(void __near *)(a_pv))
306/** @def BS3_FP_MAKE
307 * Create a far pointer.
308 * @returns selector.
309 * @param a_pv Far pointer.
310 */
311# define BS3_FP_MAKE(a_uSeg, a_off) (((__segment)(a_uSeg)) :> ((void __near *)(a_off)))
312#endif
313
314/** @def BS3_CALL
315 * The calling convension used by BS3 functions. */
316#if ARCH_BITS != 64
317# define BS3_CALL __cdecl
318#elif !defined(_MSC_VER)
319# define BS3_CALL __attribute__((__ms_abi__))
320#else
321# define BS3_CALL
322#endif
323
324/** @def IN_BS3KIT
325 * Indicates that we're in the same link job as the BS3Kit code. */
326#ifdef DOXYGEN_RUNNING
327# define IN_BS3KIT
328#endif
329
330/** @def BS3_DECL
331 * Declares a BS3Kit function.
332 *
333 * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
334 *
335 * @param a_Type The return type. */
336#ifdef IN_BS3KIT
337# define BS3_DECL(a_Type) DECLEXPORT(a_Type) BS3_NEAR_CODE BS3_CALL
338#else
339# define BS3_DECL(a_Type) DECLIMPORT(a_Type) BS3_NEAR_CODE BS3_CALL
340#endif
341
342/** @def BS3_DECL_CALLBACK
343 * Declares a BS3Kit callback function (typically static).
344 *
345 * Until we outgrow BS3TEXT16, we use all near functions in 16-bit.
346 *
347 * @param a_Type The return type. */
348#ifdef IN_BS3KIT
349# define BS3_DECL_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL
350#else
351# define BS3_DECL_CALLBACK(a_Type) a_Type BS3_NEAR_CODE BS3_CALL
352#endif
353
354/**
355 * Constructs a common name.
356 *
357 * Example: BS3_CMN_NM(Bs3Shutdown)
358 *
359 * @param a_Name The name of the function or global variable.
360 */
361#define BS3_CMN_NM(a_Name) RT_CONCAT3(a_Name,_c,ARCH_BITS)
362
363/**
364 * Constructs a data name.
365 *
366 * Example: BS3_DATA_NM(Bs3Gdt)
367 *
368 * @param a_Name The name of the global variable.
369 */
370#if ARCH_BITS == 64
371# define BS3_DATA_NM(a_Name) RT_CONCAT(_,a_Name)
372#else
373# define BS3_DATA_NM(a_Name) a_Name
374#endif
375
376/** @def BS3_MSC64_FIXUP_HACK
377 * Used to avoid IMAGE_REL_AMD64_ADDR32NB fixups where the compiler tries to
378 * make use of __ImageBase as a base pointer instead of emitting rip relative
379 * accesses. Happens when there are a bunch of global data accesses in the same
380 * function, probably to save space.
381 *
382 * The volatile variable in the lambda fixes it.
383 */
384#if _MSC_VER && ARCH_BITS == 64
385# define BS3_MSC64_FIXUP_HACK(a_BaseType, a_Data) \
386 ([]() -> a_BaseType * \
387 { \
388 a_BaseType * volatile x = a_Data; \
389 return x; \
390 }())
391
392#else
393# define BS3_MSC64_FIXUP_HACK(a_BaseType, a_Data) (a_Data)
394#endif
395
396
397/**
398 * Template for createing a pointer union type.
399 * @param a_BaseName The base type name.
400 * @param a_Modifier The type modifier.
401 */
402#define BS3_PTR_UNION_TEMPLATE(a_BaseName, a_Modifiers) \
403 typedef union a_BaseName \
404 { \
405 /** Pointer into the void. */ \
406 a_Modifiers void BS3_FAR *pv; \
407 /** As a signed integer. */ \
408 intptr_t i; \
409 /** As an unsigned integer. */ \
410 uintptr_t u; \
411 /** Pointer to char value. */ \
412 a_Modifiers char BS3_FAR *pch; \
413 /** Pointer to char value. */ \
414 a_Modifiers unsigned char BS3_FAR *puch; \
415 /** Pointer to a int value. */ \
416 a_Modifiers int BS3_FAR *pi; \
417 /** Pointer to a unsigned int value. */ \
418 a_Modifiers unsigned int BS3_FAR *pu; \
419 /** Pointer to a long value. */ \
420 a_Modifiers long BS3_FAR *pl; \
421 /** Pointer to a long value. */ \
422 a_Modifiers unsigned long BS3_FAR *pul; \
423 /** Pointer to a memory size value. */ \
424 a_Modifiers size_t BS3_FAR *pcb; \
425 /** Pointer to a byte value. */ \
426 a_Modifiers uint8_t BS3_FAR *pb; \
427 /** Pointer to a 8-bit unsigned value. */ \
428 a_Modifiers uint8_t BS3_FAR *pu8; \
429 /** Pointer to a 16-bit unsigned value. */ \
430 a_Modifiers uint16_t BS3_FAR *pu16; \
431 /** Pointer to a 32-bit unsigned value. */ \
432 a_Modifiers uint32_t BS3_FAR *pu32; \
433 /** Pointer to a 64-bit unsigned value. */ \
434 a_Modifiers uint64_t BS3_FAR *pu64; \
435 /** Pointer to a UTF-16 character. */ \
436 a_Modifiers RTUTF16 BS3_FAR *pwc; \
437 /** Pointer to a UUID character. */ \
438 a_Modifiers RTUUID BS3_FAR *pUuid; \
439 } a_BaseName; \
440 /** Pointer to a pointer union. */ \
441 typedef a_BaseName *RT_CONCAT(P,a_BaseName)
442BS3_PTR_UNION_TEMPLATE(BS3PTRUNION, RT_NOTHING);
443BS3_PTR_UNION_TEMPLATE(BS3CPTRUNION, const);
444BS3_PTR_UNION_TEMPLATE(BS3VPTRUNION, volatile);
445BS3_PTR_UNION_TEMPLATE(BS3CVPTRUNION, const volatile);
446
447
448
449/** @defgroup grp_bs3kit_system System structures
450 * @{ */
451/** The GDT, indexed by BS3_SEL_XXX shifted by 3. */
452extern X86DESC BS3_DATA_NM(Bs3Gdt)[(BS3_SEL_GDT_LIMIT + 1) / 8];
453
454extern X86DESC64 BS3_DATA_NM(Bs3Gdt_Ldt); /**< @see BS3_SEL_LDT */
455extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16); /**< @see BS3_SEL_TSS16 */
456extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16DoubleFault); /**< @see BS3_SEL_TSS16_DF */
457extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16Spare0); /**< @see BS3_SEL_TSS16_SPARE0 */
458extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss16Spare1); /**< @see BS3_SEL_TSS16_SPARE1 */
459extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32); /**< @see BS3_SEL_TSS32 */
460extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32DoubleFault); /**< @see BS3_SEL_TSS32_DF */
461extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32Spare0); /**< @see BS3_SEL_TSS32_SPARE0 */
462extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32Spare1); /**< @see BS3_SEL_TSS32_SPARE1 */
463extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32IobpIntRedirBm); /**< @see BS3_SEL_TSS32_IOBP_IRB */
464extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss32IntRedirBm); /**< @see BS3_SEL_TSS32_IRB */
465extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64); /**< @see BS3_SEL_TSS64 */
466extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Spare0); /**< @see BS3_SEL_TSS64_SPARE0 */
467extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Spare1); /**< @see BS3_SEL_TSS64_SPARE1 */
468extern X86DESC BS3_DATA_NM(Bs3Gdte_Tss64Iobp); /**< @see BS3_SEL_TSS64_IOBP */
469extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_MMIO16); /**< @see BS3_SEL_VMMDEV_MMIO16 */
470
471extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_First); /**< @see BS3_SEL_R0_FIRST */
472extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16); /**< @see BS3_SEL_R0_CS16 */
473extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS16); /**< @see BS3_SEL_R0_DS16 */
474extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_SS16); /**< @see BS3_SEL_R0_SS16 */
475extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32); /**< @see BS3_SEL_R0_CS32 */
476extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS32); /**< @see BS3_SEL_R0_DS32 */
477extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_SS32); /**< @see BS3_SEL_R0_SS32 */
478extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64); /**< @see BS3_SEL_R0_CS64 */
479extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_DS64); /**< @see BS3_SEL_R0_DS64 */
480extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_EO); /**< @see BS3_SEL_R0_CS16_EO */
481extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_CNF); /**< @see BS3_SEL_R0_CS16_CNF */
482extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS16_CND_EO); /**< @see BS3_SEL_R0_CS16_CNF_EO */
483extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_EO); /**< @see BS3_SEL_R0_CS32_EO */
484extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF); /**< @see BS3_SEL_R0_CS32_CNF */
485extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS32_CNF_EO); /**< @see BS3_SEL_R0_CS32_CNF_EO */
486extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_EO); /**< @see BS3_SEL_R0_CS64_EO */
487extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF); /**< @see BS3_SEL_R0_CS64_CNF */
488extern X86DESC BS3_DATA_NM(Bs3Gdte_R0_CS64_CNF_EO); /**< @see BS3_SEL_R0_CS64_CNF_EO */
489
490extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_First); /**< @see BS3_SEL_R1_FIRST */
491extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16); /**< @see BS3_SEL_R1_CS16 */
492extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS16); /**< @see BS3_SEL_R1_DS16 */
493extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_SS16); /**< @see BS3_SEL_R1_SS16 */
494extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32); /**< @see BS3_SEL_R1_CS32 */
495extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS32); /**< @see BS3_SEL_R1_DS32 */
496extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_SS32); /**< @see BS3_SEL_R1_SS32 */
497extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64); /**< @see BS3_SEL_R1_CS64 */
498extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_DS64); /**< @see BS3_SEL_R1_DS64 */
499extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_EO); /**< @see BS3_SEL_R1_CS16_EO */
500extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_CNF); /**< @see BS3_SEL_R1_CS16_CNF */
501extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS16_CND_EO); /**< @see BS3_SEL_R1_CS16_CNF_EO */
502extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_EO); /**< @see BS3_SEL_R1_CS32_EO */
503extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF); /**< @see BS3_SEL_R1_CS32_CNF */
504extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS32_CNF_EO); /**< @see BS3_SEL_R1_CS32_CNF_EO */
505extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_EO); /**< @see BS3_SEL_R1_CS64_EO */
506extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF); /**< @see BS3_SEL_R1_CS64_CNF */
507extern X86DESC BS3_DATA_NM(Bs3Gdte_R1_CS64_CNF_EO); /**< @see BS3_SEL_R1_CS64_CNF_EO */
508
509extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_First); /**< @see BS3_SEL_R2_FIRST */
510extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16); /**< @see BS3_SEL_R2_CS16 */
511extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS16); /**< @see BS3_SEL_R2_DS16 */
512extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_SS16); /**< @see BS3_SEL_R2_SS16 */
513extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32); /**< @see BS3_SEL_R2_CS32 */
514extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS32); /**< @see BS3_SEL_R2_DS32 */
515extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_SS32); /**< @see BS3_SEL_R2_SS32 */
516extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64); /**< @see BS3_SEL_R2_CS64 */
517extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_DS64); /**< @see BS3_SEL_R2_DS64 */
518extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_EO); /**< @see BS3_SEL_R2_CS16_EO */
519extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_CNF); /**< @see BS3_SEL_R2_CS16_CNF */
520extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS16_CND_EO); /**< @see BS3_SEL_R2_CS16_CNF_EO */
521extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_EO); /**< @see BS3_SEL_R2_CS32_EO */
522extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF); /**< @see BS3_SEL_R2_CS32_CNF */
523extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS32_CNF_EO); /**< @see BS3_SEL_R2_CS32_CNF_EO */
524extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_EO); /**< @see BS3_SEL_R2_CS64_EO */
525extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF); /**< @see BS3_SEL_R2_CS64_CNF */
526extern X86DESC BS3_DATA_NM(Bs3Gdte_R2_CS64_CNF_EO); /**< @see BS3_SEL_R2_CS64_CNF_EO */
527
528extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_First); /**< @see BS3_SEL_R3_FIRST */
529extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16); /**< @see BS3_SEL_R3_CS16 */
530extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS16); /**< @see BS3_SEL_R3_DS16 */
531extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_SS16); /**< @see BS3_SEL_R3_SS16 */
532extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32); /**< @see BS3_SEL_R3_CS32 */
533extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS32); /**< @see BS3_SEL_R3_DS32 */
534extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_SS32); /**< @see BS3_SEL_R3_SS32 */
535extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64); /**< @see BS3_SEL_R3_CS64 */
536extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_DS64); /**< @see BS3_SEL_R3_DS64 */
537extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_EO); /**< @see BS3_SEL_R3_CS16_EO */
538extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_CNF); /**< @see BS3_SEL_R3_CS16_CNF */
539extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS16_CND_EO); /**< @see BS3_SEL_R3_CS16_CNF_EO */
540extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_EO); /**< @see BS3_SEL_R3_CS32_EO */
541extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF); /**< @see BS3_SEL_R3_CS32_CNF */
542extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS32_CNF_EO); /**< @see BS3_SEL_R3_CS32_CNF_EO */
543extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_EO); /**< @see BS3_SEL_R3_CS64_EO */
544extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF); /**< @see BS3_SEL_R3_CS64_CNF */
545extern X86DESC BS3_DATA_NM(Bs3Gdte_R3_CS64_CNF_EO); /**< @see BS3_SEL_R3_CS64_CNF_EO */
546
547extern X86DESC BS3_DATA_NM(Bs3GdteSpare00); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_00 */
548extern X86DESC BS3_DATA_NM(Bs3GdteSpare01); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_01 */
549extern X86DESC BS3_DATA_NM(Bs3GdteSpare02); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_02 */
550extern X86DESC BS3_DATA_NM(Bs3GdteSpare03); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_03 */
551extern X86DESC BS3_DATA_NM(Bs3GdteSpare04); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_04 */
552extern X86DESC BS3_DATA_NM(Bs3GdteSpare05); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_05 */
553extern X86DESC BS3_DATA_NM(Bs3GdteSpare06); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_06 */
554extern X86DESC BS3_DATA_NM(Bs3GdteSpare07); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_07 */
555extern X86DESC BS3_DATA_NM(Bs3GdteSpare08); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_08 */
556extern X86DESC BS3_DATA_NM(Bs3GdteSpare09); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_09 */
557extern X86DESC BS3_DATA_NM(Bs3GdteSpare0a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0a */
558extern X86DESC BS3_DATA_NM(Bs3GdteSpare0b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0b */
559extern X86DESC BS3_DATA_NM(Bs3GdteSpare0c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0c */
560extern X86DESC BS3_DATA_NM(Bs3GdteSpare0d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0d */
561extern X86DESC BS3_DATA_NM(Bs3GdteSpare0e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0e */
562extern X86DESC BS3_DATA_NM(Bs3GdteSpare0f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_0f */
563extern X86DESC BS3_DATA_NM(Bs3GdteSpare10); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_10 */
564extern X86DESC BS3_DATA_NM(Bs3GdteSpare11); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_11 */
565extern X86DESC BS3_DATA_NM(Bs3GdteSpare12); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_12 */
566extern X86DESC BS3_DATA_NM(Bs3GdteSpare13); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_13 */
567extern X86DESC BS3_DATA_NM(Bs3GdteSpare14); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_14 */
568extern X86DESC BS3_DATA_NM(Bs3GdteSpare15); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_15 */
569extern X86DESC BS3_DATA_NM(Bs3GdteSpare16); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_16 */
570extern X86DESC BS3_DATA_NM(Bs3GdteSpare17); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_17 */
571extern X86DESC BS3_DATA_NM(Bs3GdteSpare18); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_18 */
572extern X86DESC BS3_DATA_NM(Bs3GdteSpare19); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_19 */
573extern X86DESC BS3_DATA_NM(Bs3GdteSpare1a); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1a */
574extern X86DESC BS3_DATA_NM(Bs3GdteSpare1b); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1b */
575extern X86DESC BS3_DATA_NM(Bs3GdteSpare1c); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1c */
576extern X86DESC BS3_DATA_NM(Bs3GdteSpare1d); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1d */
577extern X86DESC BS3_DATA_NM(Bs3GdteSpare1e); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1e */
578extern X86DESC BS3_DATA_NM(Bs3GdteSpare1f); /**< GDT entry for playing with in testcases. @see BS3_SEL_SPARE_1f */
579
580/** GDTs setting up the tiled 16-bit access to the first 16 MBs of memory.
581 * @see BS3_SEL_TILED, BS3_SEL_TILED_LAST, BS3_SEL_TILED_AREA_SIZE */
582extern X86DESC BS3_DATA_NM(Bs3GdteTiled)[256];
583/** Free GDTes, part \#1. */
584extern X86DESC BS3_DATA_NM(Bs3GdteFreePart1)[64];
585/** The BS3CODE16 GDT entry. @see BS3_SEL_TEXT16 */
586extern X86DESC BS3_DATA_NM(Bs3Gdte_CODE16);
587/** Free GDTes, part \#2. */
588extern X86DESC BS3_DATA_NM(Bs3GdteFreePart2)[511];
589/** The BS3SYSTEM16 GDT entry. */
590extern X86DESC BS3_DATA_NM(Bs3Gdte_SYSTEM16);
591/** Free GDTes, part \#3. */
592extern X86DESC BS3_DATA_NM(Bs3GdteFreePart3)[223];
593/** The BS3DATA16 GDT entry. */
594extern X86DESC BS3_DATA_NM(Bs3Gdte_DATA16);
595/** The end of the GDT (exclusive). */
596extern X86DESC BS3_DATA_NM(Bs3GdtEnd);
597
598/** The default 16-bit TSS. */
599extern X86TSS16 BS3_DATA_NM(Bs3Tss16);
600extern X86TSS16 BS3_DATA_NM(Bs3Tss16DoubleFault);
601extern X86TSS16 BS3_DATA_NM(Bs3Tss16Spare0);
602extern X86TSS16 BS3_DATA_NM(Bs3Tss16Spare1);
603/** The default 32-bit TSS. */
604extern X86TSS32 BS3_DATA_NM(Bs3Tss32);
605extern X86TSS32 BS3_DATA_NM(Bs3Tss32DoubleFault);
606extern X86TSS32 BS3_DATA_NM(Bs3Tss32Spare0);
607extern X86TSS32 BS3_DATA_NM(Bs3Tss32Spare1);
608/** The default 64-bit TSS. */
609extern X86TSS64 BS3_DATA_NM(Bs3Tss64);
610extern X86TSS64 BS3_DATA_NM(Bs3Tss64Spare0);
611extern X86TSS64 BS3_DATA_NM(Bs3Tss64Spare1);
612extern X86TSS64 BS3_DATA_NM(Bs3Tss64WithIopb);
613extern X86TSS32 BS3_DATA_NM(Bs3Tss32WithIopb);
614/** Interrupt redirection bitmap used by Bs3Tss32WithIopb. */
615extern uint8_t BS3_DATA_NM(Bs3SharedIntRedirBm)[32];
616/** I/O permission bitmap used by Bs3Tss32WithIopb and Bs3Tss64WithIopb. */
617extern uint8_t BS3_DATA_NM(Bs3SharedIobp)[8192+2];
618/** End of the I/O permission bitmap (exclusive). */
619extern uint8_t BS3_DATA_NM(Bs3SharedIobpEnd);
620/** 16-bit IDT. */
621extern X86DESC BS3_DATA_NM(Bs3Idt16)[256];
622/** 32-bit IDT. */
623extern X86DESC BS3_DATA_NM(Bs3Idt32)[256];
624/** 64-bit IDT. */
625extern X86DESC64 BS3_DATA_NM(Bs3Idt64)[256];
626/** Structure for the LIDT instruction for loading the 16-bit IDT. */
627extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt16);
628/** Structure for the LIDT instruction for loading the 32-bit IDT. */
629extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt32);
630/** Structure for the LIDT instruction for loading the 64-bit IDT. */
631extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Idt64);
632/** Structure for the LIDT instruction for loading the real mode interrupt
633 * vector table.. */
634extern X86XDTR64 BS3_DATA_NM(Bs3Lidt_Ivt);
635/** Structure for the LGDT instruction for loading the GDT. */
636extern X86XDTR64 BS3_DATA_NM(Bs3Lgdt_Gdt);
637/** The LDT (all entries are empty, fill in for testing). */
638extern X86DESC BS3_DATA_NM(Bs3Ldt)[118];
639/** The end of the LDT (exclusive). */
640extern X86DESC BS3_DATA_NM(Bs3LdtEnd);
641
642/** @} */
643
644
645/** @name Segment start and end markers, sizes.
646 * @{ */
647/** Start of the BS3TEXT16 segment. */
648extern uint8_t BS3_DATA_NM(Bs3Text16_StartOfSegment);
649/** End of the BS3TEXT16 segment. */
650extern uint8_t BS3_DATA_NM(Bs3Text16_EndOfSegment);
651/** The size of the BS3TEXT16 segment. */
652extern uint16_t BS3_DATA_NM(Bs3Text16_Size);
653
654/** Start of the BS3SYSTEM16 segment. */
655extern uint8_t BS3_DATA_NM(Bs3System16_StartOfSegment);
656/** End of the BS3SYSTEM16 segment. */
657extern uint8_t BS3_DATA_NM(Bs3System16_EndOfSegment);
658
659/** Start of the BS3DATA16 segment. */
660extern uint8_t BS3_DATA_NM(Bs3Data16_StartOfSegment);
661/** End of the BS3DATA16 segment. */
662extern uint8_t BS3_DATA_NM(Bs3Data16_EndOfSegment);
663
664/** Start of the BS3TEXT32 segment. */
665extern uint8_t BS3_DATA_NM(Bs3Text32_StartOfSegment);
666/** Start of the BS3TEXT32 segment. */
667extern uint8_t BS3_DATA_NM(Bs3Text32_EndOfSegment);
668
669/** Start of the BS3DATA32 segment. */
670extern uint8_t BS3_DATA_NM(Bs3Data32_StartOfSegment);
671/** Start of the BS3DATA32 segment. */
672extern uint8_t BS3_DATA_NM(Bs3Data32_EndOfSegment);
673
674/** Start of the BS3TEXT64 segment. */
675extern uint8_t BS3_DATA_NM(Bs3Text64_StartOfSegment);
676/** Start of the BS3TEXT64 segment. */
677extern uint8_t BS3_DATA_NM(Bs3Text64_EndOfSegment);
678
679/** Start of the BS3DATA64 segment. */
680extern uint8_t BS3_DATA_NM(Bs3Data64_StartOfSegment);
681/** Start of the BS3DATA64 segment. */
682extern uint8_t BS3_DATA_NM(Bs3Data64_EndOfSegment);
683
684/** The size of the Data16, Text32, Text64, Data32 and Data64 blob. */
685extern uint32_t BS3_DATA_NM(Bs3Data16Thru64Text32And64_TotalSize);
686/** The total image size (from Text16 thu Data64). */
687extern uint32_t BS3_DATA_NM(Bs3TotalImageSize);
688/** @} */
689
690
691/** Lower case hex digits. */
692extern char const BS3_DATA_NM(g_achBs3HexDigits)[16+1];
693/** Upper case hex digits. */
694extern char const BS3_DATA_NM(g_achBs3HexDigitsUpper)[16+1];
695
696
697#ifdef __WATCOMC__
698/**
699 * Executes the SMSW instruction and returns the value.
700 *
701 * @returns Machine status word.
702 */
703uint16_t Bs3AsmSmsw(void);
704# pragma aux Bs3AsmSmsw = \
705 "smsw ax" \
706 value [ax] modify exact [ax] nomemory;
707#endif
708
709
710/** @def BS3_IS_PROTECTED_MODE
711 * @returns true if protected mode, false if not. */
712#if ARCH_BITS != 16
713# define BS3_IS_PROTECTED_MODE() (true)
714#else
715# define BS3_IS_PROTECTED_MODE() (Bs3AsmSmsw() & 1 /*PE*/)
716#endif
717
718
719/** @defgroup bs3kit_cross_ptr Cross context pointer type
720 *
721 * The cross context pointer type is
722 *
723 * @{ */
724
725/**
726 * Cross context pointer base type.
727 */
728#pragma pack(4)
729typedef union BS3XPTR
730{
731 /** The flat pointer. */
732 uint32_t uFlat;
733 /** 16-bit view. */
734 struct
735 {
736 uint16_t uLow;
737 uint16_t uHigh;
738 } u;
739#if ARCH_BITS == 16
740 /** 16-bit near pointer. */
741 void __near *pvNear;
742#elif ARCH_BITS == 32
743 /** 32-bit pointer. */
744 void *pvRaw;
745#endif
746} BS3XPTR;
747#pragma pack()
748
749
750/** @def BS3_XPTR_DEF_INTERNAL
751 * Internal worker.
752 *
753 * @param a_Scope RT_NOTHING if structure or global, static or extern
754 * otherwise.
755 * @param a_Type The type we're pointing to.
756 * @param a_Name The member or variable name.
757 * @internal
758 */
759#if ARCH_BITS == 16
760# define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
761 a_Scope union \
762 { \
763 BS3XPTR XPtr; \
764 a_Type __near *pNearTyped; \
765 } a_Name
766#elif ARCH_BITS == 32
767# define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
768 a_Scope union \
769 { \
770 BS3XPTR XPtr; \
771 a_Type *pTyped; \
772 } a_Name
773#elif ARCH_BITS == 64
774# define BS3_XPTR_DEF_INTERNAL(a_Scope, a_Type, a_Name) \
775 a_Scope union \
776 { \
777 BS3XPTR XPtr; \
778 a_Type *pTyped; \
779 } a_Name
780#else
781# error "ARCH_BITS"
782#endif
783
784/** @def BS3_XPTR_DEF_MEMBER
785 * Defines a pointer member that can be shared by all CPU modes.
786 *
787 * @param a_Type The type we're pointing to.
788 * @param a_Name The member or variable name.
789 */
790#define BS3_XPTR_MEMBER(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name)
791
792/** @def BS3_XPTR_DEF_AUTO
793 * Defines a pointer static variable for working with an XPTR.
794 *
795 * This is typically used to convert flat pointers into context specific
796 * pointers.
797 *
798 * @param a_Type The type we're pointing to.
799 * @param a_Name The member or variable name.
800 */
801#define BS3_XPTR_AUTO(a_Type, a_Name) BS3_XPTR_DEF_INTERNAL(RT_NOTHING, a_Type, a_Name)
802
803/** @def BS3_XPTR_SET
804 * Sets a cross context pointer.
805 *
806 * @param a_Type The type we're pointing to.
807 * @param a_Name The member or variable name.
808 * @param a_uFlatPtr The flat pointer value to assign. If the x-pointer is
809 * used in real mode, this must be less than 1MB.
810 * Otherwise the limit is 16MB (due to selector tiling).
811 */
812#define BS3_XPTR_SET_FLAT(a_Type, a_Name, a_uFlatPtr) \
813 do { a_Name.XPtr.uFlat = (a_uFlatPtr); } while (0)
814
815/** @def BS3_XPTR_GET_FLAT
816 * Gets the flat address of a cross context pointer.
817 *
818 * @returns 32-bit flat pointer.
819 * @param a_Type The type we're pointing to.
820 * @param a_Name The member or variable name.
821 */
822#define BS3_XPTR_GET_FLAT(a_Type, a_Name) (a_Name.XPtr.uFlat)
823
824/** @def BS3_XPTR_GET_FLAT_LOW
825 * Gets the low 16 bits of the flat address.
826 *
827 * @returns Low 16 bits of the flat pointer.
828 * @param a_Type The type we're pointing to.
829 * @param a_Name The member or variable name.
830 */
831#define BS3_XPTR_GET_FLAT_LOW(a_Type, a_Name) (a_Name.XPtr.u.uLow)
832
833
834#if ARCH_BITS == 16
835
836/**
837 * Gets the current ring number.
838 * @returns Ring number.
839 */
840DECLINLINE(uint16_t) Bs3Sel16GetCurRing(void);
841# pragma aux Bs3Sel16GetCurRing = \
842 "mov ax, ss" \
843 "and ax, 3" \
844 value [ax] modify exact [ax] nomemory;
845
846/**
847 * Converts the high word of a flat pointer into a 16-bit selector.
848 *
849 * This makes use of the tiled area. It also handles real mode.
850 *
851 * @returns Segment selector value.
852 * @param uHigh The high part of flat pointer.
853 * @sa BS3_XPTR_GET, BS3_XPTR_SET
854 */
855DECLINLINE(__segment) Bs3Sel16HighFlatPtrToSelector(uint16_t uHigh)
856{
857 if (BS3_IS_PROTECTED_MODE())
858 return (__segment)(((uHigh << 3) + BS3_SEL_TILED) | Bs3Sel16GetCurRing());
859 return (__segment)(uHigh << 12);
860}
861
862#endif /* ARCH_BITS == 16*/
863
864/** @def BS3_XPTR_GET
865 * Gets the current context pointer value.
866 *
867 * @returns Usable pointer.
868 * @param a_Type The type we're pointing to.
869 * @param a_Name The member or variable name.
870 */
871#if ARCH_BITS == 16
872# define BS3_XPTR_GET(a_Type, a_Name) \
873 ((a_Type BS3_FAR *)BS3_FP_MAKE(Bs3Sel16HighFlatPtrToSelector((a_Name).XPtr.u.uHigh), (a_Name).pNearTyped))
874#elif ARCH_BITS == 32
875# define BS3_XPTR_GET(a_Type, a_Name) ((a_Name).pTyped)
876#elif ARCH_BITS == 64
877# define BS3_XPTR_GET(a_Type, a_Name) ((a_Type *)(uintptr_t)(a_Name).XPtr.uFlat)
878#else
879# error "ARCH_BITS"
880#endif
881
882/** @def BS3_XPTR_SET
883 * Gets the current context pointer value.
884 *
885 * @returns Usable pointer.
886 * @param a_Type The type we're pointing to.
887 * @param a_Name The member or variable name.
888 * @param a_pValue The new pointer value, current context pointer.
889 */
890#if ARCH_BITS == 16
891# define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
892 do { \
893 a_Type BS3_FAR *pTypeCheck = (a_pValue); \
894 if (BS3_IS_PROTECTED_MODE()) \
895 { \
896 (a_Name).XPtr.u.uLow = BS3_FP_OFF(pTypeCheck); \
897 (a_Name).XPtr.u.uHigh = (BS3_FP_SEG(pTypeCheck) & UINT16_C(0xfff8)) - BS3_SEL_TILED; \
898 } \
899 else \
900 (a_Name).XPtr.uFlat = BS3_FP_OFF(pTypeCheck) + ((uint32_t)BS3_FP_SEG(pTypeCheck) << 4); \
901 } while (0)
902#elif ARCH_BITS == 32
903# define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
904 do { (a_Name).pTyped = (a_pValue); } while (0)
905#elif ARCH_BITS == 64
906# define BS3_XPTR_SET(a_Type, a_Name, a_pValue) \
907 do { \
908 a_Type *pTypeCheck = (a_pValue); \
909 (a_Name).XPtr.uFlat = (uint32_t)(uintptr_t)pTypeCheck; \
910 } while (0)
911#else
912# error "ARCH_BITS"
913#endif
914
915
916/** @def BS3_XPTR_IS_NULL
917 * Checks if the cross context pointer is NULL.
918 *
919 * @returns true if NULL, false if not.
920 * @param a_Type The type we're pointing to.
921 * @param a_Name The member or variable name.
922 */
923#define BS3_XPTR_IS_NULL(a_Type, a_Name) ((a_Name).XPtr.uFlat == 0)
924/** @} */
925
926
927
928/** @defgroup grp_bs3kit_cmn Common Functions and Data
929 *
930 * The common functions comes in three variations: 16-bit, 32-bit and 64-bit.
931 * Templated code uses the #BS3_CMN_NM macro to mangle the name according to the
932 * desired
933 *
934 * @{
935 */
936
937#define BS3_STRICT /**< @todo later */
938#ifdef BS3_STRICT
939# define BS3_ASSERT(a_Expr) do { } while (0) /**< @todo later */
940#else
941# define BS3_ASSERT(a_Expr) do { } while (0) /**< @todo later */
942#endif
943
944/**
945 * Panic, never return.
946 *
947 * The current implementation will only halt the CPU.
948 */
949BS3_DECL(void) Bs3Panic_c16(void);
950BS3_DECL(void) Bs3Panic_c32(void); /**< @copydoc Bs3Panic_c16 */
951BS3_DECL(void) Bs3Panic_c64(void); /**< @copydoc Bs3Panic_c16 */
952#define Bs3Panic BS3_CMN_NM(Bs3Panic) /**< Selects #Bs3Panic_c16, #Bs3Panic_c32 or #Bs3Panic_c64. */
953
954/**
955 * Shutdown the system, never returns.
956 *
957 * This currently only works for VMs. When running on real systems it will
958 * just halt the CPU.
959 */
960BS3_DECL(void) Bs3Shutdown_c16(void);
961BS3_DECL(void) Bs3Shutdown_c32(void); /**< @copydoc Bs3Shutdown_c16 */
962BS3_DECL(void) Bs3Shutdown_c64(void); /**< @copydoc Bs3Shutdown_c16 */
963#define Bs3Shutdown BS3_CMN_NM(Bs3Shutdown) /**< Selects #Bs3Shutdown_c16, #Bs3Shutdown_c32 or #Bs3Shutdown_c64. */
964
965/**
966 * Prints a 32-bit unsigned value as decimal to the screen.
967 *
968 * @param uValue The 32-bit value.
969 */
970BS3_DECL(void) Bs3PrintU32_c16(uint32_t uValue);
971BS3_DECL(void) Bs3PrintU32_c32(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
972BS3_DECL(void) Bs3PrintU32_c64(uint32_t uValue); /**< @copydoc Bs3PrintU32_c16 */
973#define Bs3PrintU32 BS3_CMN_NM(Bs3PrintU32) /**< Selects #Bs3PrintU32_c16, #Bs3PrintU32_c32 or #Bs3PrintU32_c64. */
974
975/**
976 * Prints a 32-bit unsigned value as hex to the screen.
977 *
978 * @param uValue The 32-bit value.
979 */
980BS3_DECL(void) Bs3PrintX32_c16(uint32_t uValue);
981BS3_DECL(void) Bs3PrintX32_c32(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */
982BS3_DECL(void) Bs3PrintX32_c64(uint32_t uValue); /**< @copydoc Bs3PrintX32_c16 */
983#define Bs3PrintX32 BS3_CMN_NM(Bs3PrintX32) /**< Selects #Bs3PrintX32_c16, #Bs3PrintX32_c32 or #Bs3PrintX32_c64. */
984
985/**
986 * Formats and prints a string to the screen.
987 *
988 * See #Bs3StrFormatV_c16 for supported format types.
989 *
990 * @param pszFormat The format string.
991 * @param ... Format arguments.
992 */
993BS3_DECL(size_t) Bs3Printf_c16(const char BS3_FAR *pszFormat, ...);
994BS3_DECL(size_t) Bs3Printf_c32(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3Printf_c16 */
995BS3_DECL(size_t) Bs3Printf_c64(const char BS3_FAR *pszFormat, ...); /**< @copydoc Bs3Printf_c16 */
996#define Bs3Printf BS3_CMN_NM(Bs3Printf) /**< Selects #Bs3Printf_c16, #Bs3Printf_c32 or #Bs3Printf_c64. */
997
998/**
999 * Formats and prints a string to the screen, va_list version.
1000 *
1001 * See #Bs3Format_c16 for supported format types.
1002 *
1003 * @param pszFormat The format string.
1004 * @param va Format arguments.
1005 */
1006BS3_DECL(size_t) Bs3PrintfV_c16(const char BS3_FAR *pszFormat, va_list va);
1007BS3_DECL(size_t) Bs3PrintfV_c32(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3PrintfV_c16 */
1008BS3_DECL(size_t) Bs3PrintfV_c64(const char BS3_FAR *pszFormat, va_list va); /**< @copydoc Bs3PrintfV_c16 */
1009#define Bs3PrintfV BS3_CMN_NM(Bs3PrintfV) /**< Selects #Bs3PrintfV_c16, #Bs3PrintfV_c32 or #Bs3PrintfV_c64. */
1010
1011/**
1012 * Prints a string to the screen.
1013 *
1014 * @param pszString The string to print.
1015 */
1016BS3_DECL(void) Bs3PrintStr_c16(const char BS3_FAR *pszString);
1017BS3_DECL(void) Bs3PrintStr_c32(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
1018BS3_DECL(void) Bs3PrintStr_c64(const char BS3_FAR *pszString); /**< @copydoc Bs3PrintStr_c16 */
1019#define Bs3PrintStr BS3_CMN_NM(Bs3PrintStr) /**< Selects #Bs3PrintStr_c16, #Bs3PrintStr_c32 or #Bs3PrintStr_c64. */
1020
1021/**
1022 * Prints a char to the screen.
1023 *
1024 * @param ch The character to print.
1025 */
1026BS3_DECL(void) Bs3PrintChr_c16(char ch);
1027BS3_DECL(void) Bs3PrintChr_c32(char ch); /**< @copydoc Bs3PrintChr_c16 */
1028BS3_DECL(void) Bs3PrintChr_c64(char ch); /**< @copydoc Bs3PrintChr_c16 */
1029#define Bs3PrintChr BS3_CMN_NM(Bs3PrintChr) /**< Selects #Bs3PrintChr_c16, #Bs3PrintChr_c32 or #Bs3PrintChr_c64. */
1030
1031
1032/**
1033 * An output function for #Bs3StrFormatV.
1034 *
1035 * @returns Number of characters written.
1036 * @param ch The character to write. Zero in the final call.
1037 * @param pvUser User argument supplied to #Bs3StrFormatV.
1038 */
1039typedef size_t BS3_CALL FNBS3STRFORMATOUTPUT(char ch, void BS3_FAR *pvUser);
1040/** Pointer to an output function for #Bs3StrFormatV. */
1041typedef FNBS3STRFORMATOUTPUT BS3_NEAR_CODE *PFNBS3STRFORMATOUTPUT;
1042
1043/**
1044 * Formats a string, sending the output to @a pfnOutput.
1045 *
1046 * Supported types:
1047 * - %RI8, %RI16, %RI32, %RI64
1048 * - %RU8, %RU16, %RU32, %RU64
1049 * - %RX8, %RX16, %RX32, %RX64
1050 * - %i, %d
1051 * - %u
1052 * - %x
1053 * - %c
1054 * - %p (far pointer)
1055 * - %s (far pointer)
1056 *
1057 * @returns Sum of @a pfnOutput return values.
1058 * @param pszFormat The format string.
1059 * @param va Format arguments.
1060 * @param pfnOutput The output function.
1061 * @param pvUser The user argument for the output function.
1062 */
1063BS3_DECL(size_t) Bs3StrFormatV_c16(const char BS3_FAR *pszFormat, va_list va,
1064 PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
1065/** @copydoc Bs3StrFormatV_c16 */
1066BS3_DECL(size_t) Bs3StrFormatV_c32(const char BS3_FAR *pszFormat, va_list va,
1067 PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
1068/** @copydoc Bs3StrFormatV_c16 */
1069BS3_DECL(size_t) Bs3StrFormatV_c64(const char BS3_FAR *pszFormat, va_list va,
1070 PFNBS3STRFORMATOUTPUT pfnOutput, void BS3_FAR *pvUser);
1071#define Bs3StrFormatV BS3_CMN_NM(Bs3StrFormatV) /**< Selects #Bs3StrFormatV_c16, #Bs3StrFormatV_c32 or #Bs3StrFormatV_c64. */
1072
1073/**
1074 * Formats a string into a buffer.
1075 *
1076 * See #Bs3Format_c16 for supported format types.
1077 *
1078 * @returns The length of the formatted string (excluding terminator).
1079 * This will be higher or equal to @c cbBuf in case of an overflow.
1080 * @param pszBuf The output buffer.
1081 * @param cbBuf The size of the output buffer.
1082 * @param pszFormat The format string.
1083 * @param va Format arguments.
1084 */
1085BS3_DECL(size_t) Bs3StrPrintfV_c16(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
1086/** @copydoc Bs3StrPrintfV_c16 */
1087BS3_DECL(size_t) Bs3StrPrintfV_c32(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
1088/** @copydoc Bs3StrPrintfV_c16 */
1089BS3_DECL(size_t) Bs3StrPrintfV_c64(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, va_list va);
1090#define Bs3StrPrintfV BS3_CMN_NM(Bs3StrPrintfV) /**< Selects #Bs3StrPrintfV_c16, #Bs3StrPrintfV_c32 or #Bs3StrPrintfV_c64. */
1091
1092/**
1093 * Formats a string into a buffer.
1094 *
1095 * See #Bs3Format_c16 for supported format types.
1096 *
1097 * @returns The length of the formatted string (excluding terminator).
1098 * This will be higher or equal to @c cbBuf in case of an overflow.
1099 * @param pszBuf The output buffer.
1100 * @param cbBuf The size of the output buffer.
1101 * @param pszFormat The format string.
1102 * @param ... Format arguments.
1103 */
1104BS3_DECL(size_t) Bs3StrPrintf_c16(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
1105/** @copydoc Bs3StrPrintf_c16 */
1106BS3_DECL(size_t) Bs3StrPrintf_c32(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
1107/** @copydoc Bs3StrPrintf_c16 */
1108BS3_DECL(size_t) Bs3StrPrintf_c64(char BS3_FAR *pszBuf, size_t cbBuf, const char BS3_FAR *pszFormat, ...);
1109#define Bs3StrPrintf BS3_CMN_NM(Bs3StrPrintf) /**< Selects #Bs3StrPrintf_c16, #Bs3StrPrintf_c32 or #Bs3StrPrintf_c64. */
1110
1111
1112/**
1113 * Finds the length of a zero terminated string.
1114 *
1115 * @returns String length in chars/bytes.
1116 * @param pszString The string to examine.
1117 */
1118BS3_DECL(size_t) Bs3StrLen_c16(const char BS3_FAR *pszString);
1119BS3_DECL(size_t) Bs3StrLen_c32(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
1120BS3_DECL(size_t) Bs3StrLen_c64(const char BS3_FAR *pszString); /** @copydoc Bs3StrLen_c16 */
1121#define Bs3StrLen BS3_CMN_NM(Bs3StrLen) /**< Selects #Bs3StrLen_c16, #Bs3StrLen_c32 or #Bs3StrLen_c64. */
1122
1123/**
1124 * Finds the length of a zero terminated string, but with a max length.
1125 *
1126 * @returns String length in chars/bytes, or @a cchMax if no zero-terminator
1127 * was found before we reached the limit.
1128 * @param pszString The string to examine.
1129 * @param cchMax The max length to examine.
1130 */
1131BS3_DECL(size_t) Bs3StrNLen_c16(const char BS3_FAR *pszString, size_t cchMax);
1132BS3_DECL(size_t) Bs3StrNLen_c32(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
1133BS3_DECL(size_t) Bs3StrNLen_c64(const char BS3_FAR *pszString, size_t cchMax); /** @copydoc Bs3StrNLen_c16 */
1134#define Bs3StrNLen BS3_CMN_NM(Bs3StrNLen) /**< Selects #Bs3StrNLen_c16, #Bs3StrNLen_c32 or #Bs3StrNLen_c64. */
1135
1136/**
1137 * CRT style unsafe strcpy.
1138 *
1139 * @returns pszDst.
1140 * @param pszDst The destination buffer. Must be large enough to
1141 * hold the source string.
1142 * @param pszSrc The source string.
1143 */
1144BS3_DECL(char BS3_FAR *) Bs3StrCpy_c16(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc);
1145BS3_DECL(char BS3_FAR *) Bs3StrCpy_c32(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
1146BS3_DECL(char BS3_FAR *) Bs3StrCpy_c64(char BS3_FAR *pszDst, const char BS3_FAR *pszSrc); /** @copydoc Bs3StrCpy_c16 */
1147#define Bs3StrCpy BS3_CMN_NM(Bs3StrCpy) /**< Selects #Bs3StrCpy_c16, #Bs3StrCpy_c32 or #Bs3StrCpy_c64. */
1148
1149/**
1150 * CRT style memcpy.
1151 *
1152 * @returns pvDst
1153 * @param pvDst The destination buffer.
1154 * @param pvSrc The source buffer.
1155 * @param cbCopy The number of bytes to copy.
1156 */
1157BS3_DECL(void BS3_FAR *) Bs3MemCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
1158BS3_DECL(void BS3_FAR *) Bs3MemCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
1159BS3_DECL(void BS3_FAR *) Bs3MemCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemCpy_c16 */
1160#define Bs3MemCpy BS3_CMN_NM(Bs3MemCpy) /**< Selects #Bs3MemCpy_c16, #Bs3MemCpy_c32 or #Bs3MemCpy_c64. */
1161
1162/**
1163 * GNU (?) style mempcpy.
1164 *
1165 * @returns pvDst + cbCopy
1166 * @param pvDst The destination buffer.
1167 * @param pvSrc The source buffer.
1168 * @param cbCopy The number of bytes to copy.
1169 */
1170BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
1171BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
1172BS3_DECL(void BS3_FAR *) Bs3MemPCpy_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemPCpy_c16 */
1173#define Bs3MemPCpy BS3_CMN_NM(Bs3MemPCpy) /**< Selects #Bs3MemPCpy_c16, #Bs3MemPCpy_c32 or #Bs3MemPCpy_c64. */
1174
1175/**
1176 * CRT style memmove (overlapping buffers is fine).
1177 *
1178 * @returns pvDst
1179 * @param pvDst The destination buffer.
1180 * @param pvSrc The source buffer.
1181 * @param cbCopy The number of bytes to copy.
1182 */
1183BS3_DECL(void BS3_FAR *) Bs3MemMove_c16(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy);
1184BS3_DECL(void BS3_FAR *) Bs3MemMove_c32(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
1185BS3_DECL(void BS3_FAR *) Bs3MemMove_c64(void BS3_FAR *pvDst, const void BS3_FAR *pvSrc, size_t cbToCopy); /** @copydoc Bs3MemMove_c16 */
1186#define Bs3MemMove BS3_CMN_NM(Bs3MemMove) /**< Selects #Bs3MemMove_c16, #Bs3MemMove_c32 or #Bs3MemMove_c64. */
1187
1188/**
1189 * BSD style bzero.
1190 *
1191 * @param pvDst The buffer to be zeroed.
1192 * @param cbDst The number of bytes to zero.
1193 */
1194BS3_DECL(void) Bs3MemZero_c16(void BS3_FAR *pvDst, size_t cbDst);
1195BS3_DECL(void) Bs3MemZero_c32(void BS3_FAR *pvDst, size_t cbDst); /** @copydoc Bs3MemZero_c16 */
1196BS3_DECL(void) Bs3MemZero_c64(void BS3_FAR *pvDst, size_t cbDst); /** @copydoc Bs3MemZero_c16 */
1197#define Bs3MemZero BS3_CMN_NM(Bs3MemZero) /**< Selects #Bs3MemZero_c16, #Bs3MemZero_c32 or #Bs3MemZero_c64. */
1198
1199
1200
1201/**
1202 * Equivalent to RTTestCreate + RTTestBanner.
1203 *
1204 * @param pszTest The test name.
1205 */
1206BS3_DECL(void) Bs3TestInit_c16(const char BS3_FAR *pszTest);
1207BS3_DECL(void) Bs3TestInit_c32(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
1208BS3_DECL(void) Bs3TestInit_c64(const char BS3_FAR *pszTest); /**< @copydoc Bs3TestInit_c16 */
1209#define Bs3TestInit BS3_CMN_NM(Bs3TestInit) /**< Selects #Bs3TestInit_c16, #Bs3TestInit_c32 or #Bs3TestInit_c64. */
1210
1211
1212/**
1213 * Slab control structure list head.
1214 *
1215 * The slabs on the list must all have the same chunk size.
1216 */
1217typedef struct BS3SLABHEAD
1218{
1219 /** Pointer to the first slab. */
1220 BS3_XPTR_MEMBER(struct BS3SLABCTL, pFirst);
1221 /** The allocation chunk size. */
1222 uint16_t cbChunk;
1223 /** Number of slabs in the list. */
1224 uint16_t cSlabs;
1225 /** Number of chunks in the list. */
1226 uint32_t cChunks;
1227 /** Number of free chunks. */
1228 uint32_t cFreeChunks;
1229} BS3SLABHEAD;
1230/** Pointer to a slab list head. */
1231typedef BS3SLABHEAD BS3_FAR *PBS3SLABHEAD;
1232
1233/**
1234 * Allocation slab control structure.
1235 *
1236 * This may live at the start of the slab for 4KB slabs, while in a separate
1237 * static location for the larger ones.
1238 */
1239typedef struct BS3SLABCTL
1240{
1241 /** Pointer to the next slab control structure in this list. */
1242 BS3_XPTR_MEMBER(struct BS3SLABCTL, pNext);
1243 /** Pointer to the slab list head. */
1244 BS3_XPTR_MEMBER(BS3SLABHEAD, pHead);
1245 /** The base address of the slab. */
1246 BS3_XPTR_MEMBER(uint8_t, pbStart);
1247 /** Number of chunks in this slab. */
1248 uint16_t cChunks;
1249 /** Number of currently free chunks. */
1250 uint16_t cFreeChunks;
1251 /** The chunk size. */
1252 uint16_t cbChunk;
1253 /** The shift count corresponding to cbChunk.
1254 * This is for turning a chunk number into a byte offset and vice versa. */
1255 uint16_t cChunkShift;
1256 /** Bitmap where set bits indicates allocated blocks (variable size,
1257 * multiple of 4). */
1258 uint8_t bmAllocated[4];
1259} BS3SLABCTL;
1260/** Pointer to a bs3kit slab control structure. */
1261typedef BS3SLABCTL BS3_FAR *PBS3SLABCTL;
1262
1263/** The chunks must all be in the same 16-bit segment tile. */
1264#define BS3_SLAB_ALLOC_F_SAME_TILE UINT16_C(0x0001)
1265
1266/**
1267 * Initializes a slab.
1268 *
1269 * @param pSlabCtl The slab control structure to initialize.
1270 * @param cbSlabCtl The size of the slab control structure.
1271 * @param uFlatSlabPtr The base address of the slab.
1272 * @param cbSlab The size of the slab.
1273 * @param cbChunk The chunk size.
1274 */
1275BS3_DECL(void) Bs3SlabInit_c16(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
1276/** @copydoc Bs3SlabInit_c16 */
1277BS3_DECL(void) Bs3SlabInit_c32(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
1278/** @copydoc Bs3SlabInit_c16 */
1279BS3_DECL(void) Bs3SlabInit_c64(PBS3SLABCTL pSlabCtl, size_t cbSlabCtl, uint32_t uFlatSlabPtr, uint32_t cbSlab, uint16_t cbChunk);
1280#define Bs3SlabInit BS3_CMN_NM(Bs3SlabInit) /**< Selects #Bs3SlabInit_c16, #Bs3SlabInit_c32 or #Bs3SlabInit_c64. */
1281
1282/**
1283 * Allocates one chunk from a slab.
1284 *
1285 * @returns Pointer to a chunk on success, NULL if we're out of chunks.
1286 * @param pSlabCtl The slab constrol structure to allocate from.
1287 */
1288BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c16(PBS3SLABCTL pSlabCtl);
1289BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c32(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */
1290BS3_DECL(void BS3_FAR *) Bs3SlabAlloc_c64(PBS3SLABCTL pSlabCtl); /**< @copydoc Bs3SlabAlloc_c16 */
1291#define Bs3SlabAlloc BS3_CMN_NM(Bs3SlabAlloc) /**< Selects #Bs3SlabAlloc_c16, #Bs3SlabAlloc_c32 or #Bs3SlabAlloc_c64. */
1292
1293/**
1294 * Allocates one or more chunks rom a slab.
1295 *
1296 * @returns Pointer to the request number of chunks on success, NULL if we're
1297 * out of chunks.
1298 * @param pSlabCtl The slab constrol structure to allocate from.
1299 * @param cChunks The number of contiguous chunks we want.
1300 * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX
1301 */
1302BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c16(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags);
1303BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c32(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */
1304BS3_DECL(void BS3_FAR *) Bs3SlabAllocEx_c64(PBS3SLABCTL pSlabCtl, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabAllocEx_c16 */
1305#define Bs3SlabAllocEx BS3_CMN_NM(Bs3SlabAllocEx) /**< Selects #Bs3SlabAllocEx_c16, #Bs3SlabAllocEx_c32 or #Bs3SlabAllocEx_c64. */
1306
1307/**
1308 * Frees one or more chunks from a slab.
1309 *
1310 * @returns Number of chunks actually freed. When correctly used, this will
1311 * match the @a cChunks parameter, of course.
1312 * @param pSlabCtl The slab constrol structure to free from.
1313 * @param uFlatChunkPtr The flat address of the chunks to free.
1314 * @param cChunks The number of contiguous chunks to free.
1315 */
1316BS3_DECL(uint16_t) Bs3SlabFree_c16(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks);
1317BS3_DECL(uint16_t) Bs3SlabFree_c32(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
1318BS3_DECL(uint16_t) Bs3SlabFree_c64(PBS3SLABCTL pSlabCtl, uint32_t uFlatChunkPtr, uint16_t cChunks); /**< @copydoc Bs3SlabFree_c16 */
1319#define Bs3SlabFree BS3_CMN_NM(Bs3SlabFree) /**< Selects #Bs3SlabFree_c16, #Bs3SlabFree_c32 or #Bs3SlabFree_c64. */
1320
1321
1322/**
1323 * Initializes the given slab list head.
1324 *
1325 * @param pHead The slab list head.
1326 * @param cbChunk The chunk size.
1327 */
1328BS3_DECL(void) Bs3SlabListInit_c16(PBS3SLABHEAD pHead, uint16_t cbChunk);
1329BS3_DECL(void) Bs3SlabListInit_c32(PBS3SLABHEAD pHead, uint16_t cbChunk); /**< @copydoc Bs3SlabListInit_c16 */
1330BS3_DECL(void) Bs3SlabListInit_c64(PBS3SLABHEAD pHead, uint16_t cbChunk); /**< @copydoc Bs3SlabListInit_c16 */
1331#define Bs3SlabListInit BS3_CMN_NM(Bs3SlabListInit) /**< Selects #Bs3SlabListInit_c16, #Bs3SlabListInit_c32 or #Bs3SlabListInit_c64. */
1332
1333/**
1334 * Adds an initialized slab control structure to the list.
1335 *
1336 * @param pHead The slab list head to add it to.
1337 * @param pSlabCtl The slab control structure to add.
1338 */
1339BS3_DECL(void) Bs3SlabListAdd_c16(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
1340/** @copydoc Bs3SlabListAdd_c16 */
1341BS3_DECL(void) Bs3SlabListAdd_c32(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
1342/** @copydoc Bs3SlabListAdd_c16 */
1343BS3_DECL(void) Bs3SlabListAdd_c64(PBS3SLABHEAD pHead, PBS3SLABCTL pSlabCtl);
1344#define Bs3SlabListAdd BS3_CMN_NM(Bs3SlabListAdd) /**< Selects #Bs3SlabListAdd_c16, #Bs3SlabListAdd_c32 or #Bs3SlabListAdd_c64. */
1345
1346/**
1347 * Allocates one chunk.
1348 *
1349 * @returns Pointer to a chunk on success, NULL if we're out of chunks.
1350 * @param pHead The slab list to allocate from.
1351 */
1352BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c16(PBS3SLABHEAD pHead);
1353BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c32(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */
1354BS3_DECL(void BS3_FAR *) Bs3SlabListAlloc_c64(PBS3SLABHEAD pHead); /**< @copydoc Bs3SlabListAlloc_c16 */
1355#define Bs3SlabListAlloc BS3_CMN_NM(Bs3SlabListAlloc) /**< Selects #Bs3SlabListAlloc_c16, #Bs3SlabListAlloc_c32 or #Bs3SlabListAlloc_c64. */
1356
1357/**
1358 * Allocates one or more chunks.
1359 *
1360 * @returns Pointer to the request number of chunks on success, NULL if we're
1361 * out of chunks.
1362 * @param pHead The slab list to allocate from.
1363 * @param cChunks The number of contiguous chunks we want.
1364 * @param fFlags Flags, see BS3_SLAB_ALLOC_F_XXX
1365 */
1366BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c16(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags);
1367BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c32(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */
1368BS3_DECL(void BS3_FAR *) Bs3SlabListAllocEx_c64(PBS3SLABHEAD pHead, uint16_t cChunks, uint16_t fFlags); /**< @copydoc Bs3SlabListAllocEx_c16 */
1369#define Bs3SlabListAllocEx BS3_CMN_NM(Bs3SlabListAllocEx) /**< Selects #Bs3SlabListAllocEx_c16, #Bs3SlabListAllocEx_c32 or #Bs3SlabListAllocEx_c64. */
1370
1371/**
1372 * Frees one or more chunks from a slab list.
1373 *
1374 * @param pHead The slab list to allocate from.
1375 * @param pvChunks Pointer to the first chunk to free.
1376 * @param cChunks The number of contiguous chunks to free.
1377 */
1378BS3_DECL(void) Bs3SlabListFree_c16(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks);
1379BS3_DECL(void) Bs3SlabListFree_c32(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks); /**< @copydoc Bs3SlabListFree_c16 */
1380BS3_DECL(void) Bs3SlabListFree_c64(PBS3SLABHEAD pHead, void BS3_FAR *pvChunks, uint16_t cChunks); /**< @copydoc Bs3SlabListFree_c16 */
1381#define Bs3SlabListFree BS3_CMN_NM(Bs3SlabListFree) /**< Selects #Bs3SlabListFree_c16, #Bs3SlabListFree_c32 or #Bs3SlabListFree_c64. */
1382
1383/**
1384 * Allocation addressing constraints.
1385 */
1386typedef enum BS3MEMKIND
1387{
1388 /** Invalid zero type. */
1389 BS3MEMKIND_INVALID = 0,
1390 /** Real mode addressable memory. */
1391 BS3MEMKIND_REAL,
1392 /** Memory addressable using the 16-bit protected mode tiling. */
1393 BS3MEMKIND_TILED,
1394 /** Memory addressable using 32-bit flat addressing. */
1395 BS3MEMKIND_FLAT32,
1396 /** Memory addressable using 64-bit flat addressing. */
1397 BS3MEMKIND_FLAT64,
1398 /** End of valid types. */
1399 BS3MEMKIND_END,
1400} BS3MEMKIND;
1401
1402/**
1403 * Allocates low memory.
1404 *
1405 * @returns Pointer to a chunk on success, NULL if we're out of chunks.
1406 * @param enmKind The kind of addressing constraints imposed on the
1407 * allocation.
1408 * @param cb How much to allocate. Must be 4KB or less.
1409 */
1410BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c16(BS3MEMKIND enmKind, size_t cb);
1411BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c32(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAlloc_c16 */
1412BS3_DECL(void BS3_FAR *) Bs3MemAlloc_c64(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAlloc_c16 */
1413#define Bs3MemAlloc BS3_CMN_NM(Bs3MemAlloc) /**< Selects #Bs3MemAlloc_c16, #Bs3MemAlloc_c32 or #Bs3MemAlloc_c64. */
1414
1415/**
1416 * Allocates zero'ed memory.
1417 *
1418 * @param enmKind The kind of addressing constraints imposed on the
1419 * allocation.
1420 * @param cb How much to allocate. Must be 4KB or less.
1421 */
1422BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c16(BS3MEMKIND enmKind, size_t cb);
1423BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c32(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAllocZ_c16 */
1424BS3_DECL(void BS3_FAR *) Bs3MemAllocZ_c64(BS3MEMKIND enmKind, size_t cb); /**< @copydoc Bs3MemAllocZ_c16 */
1425#define Bs3MemAllocZ BS3_CMN_NM(Bs3MemAllocZ) /**< Selects #Bs3MemAllocZ_c16, #Bs3MemAllocZ_c32 or #Bs3MemAllocZ_c64. */
1426
1427/**
1428 * Frees memory.
1429 *
1430 * @returns Pointer to a chunk on success, NULL if we're out of chunks.
1431 * @param pv The memory to free (returned by #Bs3MemAlloc).
1432 * @param cb The size of the allocation.
1433 */
1434BS3_DECL(void) Bs3MemFree_c16(void BS3_FAR *pv, size_t cb);
1435BS3_DECL(void) Bs3MemFree_c32(void BS3_FAR *pv, size_t cb); /**< @copydoc Bs3MemFree_c16 */
1436BS3_DECL(void) Bs3MemFree_c64(void BS3_FAR *pv, size_t cb); /**< @copydoc Bs3MemFree_c16 */
1437#define Bs3MemFree BS3_CMN_NM(Bs3MemFree) /**< Selects #Bs3MemFree_c16, #Bs3MemFree_c32 or #Bs3MemFree_c64. */
1438
1439/** @} */
1440
1441
1442/**
1443 * Initializes the REAL and TILED memory pools.
1444 */
1445BS3_DECL(void) Bs3InitMemory_rm(void);
1446
1447
1448/** @defgroup grp_bs3kit_mode Mode Specific Functions and Data
1449 *
1450 * The mode specific functions come in bit count variations and CPU mode
1451 * variations. The bs3kit-template-header.h/mac defines the BS3_NM macro to
1452 * mangle a function or variable name according to the target CPU mode. In
1453 * non-templated code, it's common to spell the name out in full.
1454 *
1455 * @{
1456 */
1457
1458
1459/** @} */
1460
1461RT_C_DECLS_END
1462
1463
1464#endif
1465
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette