1 | /* $Id: bs3kit-template-header.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit header for multi-mode code templates.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #include "bs3kit.h"
|
---|
38 |
|
---|
39 | /** @defgroup grp_bs3kit_tmpl Multi-Mode Code Templates
|
---|
40 | * @ingroup grp_bs3kit
|
---|
41 | *
|
---|
42 | * Multi-mode code templates avoid duplicating code for each of the CPU modes.
|
---|
43 | * Instead the code is compiled multiple times, either via multiple inclusions
|
---|
44 | * into a source files with different mode selectors defined or by multiple
|
---|
45 | * compiler invocations.
|
---|
46 | *
|
---|
47 | * In C/C++ code we're restricted to the compiler target bit count, whereas in
|
---|
48 | * assembly we can do everything in assembler run (with some 64-bit
|
---|
49 | * restrictions, that is).
|
---|
50 | *
|
---|
51 | * Before \#defining the next mode selector and including
|
---|
52 | * bs3kit-template-header.h again, include bs3kit-template-footer.h to undefine
|
---|
53 | * all the previous mode selectors and the macros defined by the header.
|
---|
54 | *
|
---|
55 | * @{
|
---|
56 | */
|
---|
57 |
|
---|
58 | #ifdef DOXYGEN_RUNNING
|
---|
59 | /** @name Template mode selectors.
|
---|
60 | *
|
---|
61 | * Exactly one of these are defined by the file including the
|
---|
62 | * bs3kit-template-header.h header file. When building the code libraries, the
|
---|
63 | * kBuild target defines this.
|
---|
64 | *
|
---|
65 | * @{ */
|
---|
66 | # define TMPL_RM /**< real mode. */
|
---|
67 |
|
---|
68 | # define TMPL_PE16 /**< 16-bit protected mode kernel+tss, running 16-bit code, unpaged. */
|
---|
69 | # define TMPL_PE16_32 /**< 16-bit protected mode kernel+tss, running 32-bit code, unpaged. */
|
---|
70 | # define TMPL_PE16_V86 /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
|
---|
71 | # define TMPL_PE32 /**< 32-bit protected mode kernel+tss, running 32-bit code, unpaged. */
|
---|
72 | # define TMPL_PE32_16 /**< 32-bit protected mode kernel+tss, running 16-bit code, unpaged. */
|
---|
73 | # define TMPL_PEV86 /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, unpaged. */
|
---|
74 |
|
---|
75 | # define TMPL_PP16 /**< 16-bit protected mode kernel+tss, running 16-bit code, paged. */
|
---|
76 | # define TMPL_PP16_32 /**< 16-bit protected mode kernel+tss, running 32-bit code, paged. */
|
---|
77 | # define TMPL_PP16_V86 /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
|
---|
78 | # define TMPL_PP32 /**< 32-bit protected mode kernel+tss, running 32-bit code, paged. */
|
---|
79 | # define TMPL_PP32_16 /**< 32-bit protected mode kernel+tss, running 16-bit code, paged. */
|
---|
80 | # define TMPL_PPV86 /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, paged. */
|
---|
81 |
|
---|
82 | # define TMPL_PAE16 /**< 16-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
|
---|
83 | # define TMPL_PAE16_32 /**< 16-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
|
---|
84 | # define TMPL_PAE16_V86 /**< 16-bit protected mode kernel+tss, running virtual 8086 mode code, PAE paging. */
|
---|
85 | # define TMPL_PAE32 /**< 32-bit protected mode kernel+tss, running 32-bit code, PAE paging. */
|
---|
86 | # define TMPL_PAE32_16 /**< 32-bit protected mode kernel+tss, running 16-bit code, PAE paging. */
|
---|
87 | # define TMPL_PAEV86 /**< 32-bit protected mode kernel+tss, running virtual 8086 mode code, PAE paging. */
|
---|
88 |
|
---|
89 | # define TMPL_LM16 /**< 16-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
90 | # define TMPL_LM32 /**< 32-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
91 | # define TMPL_LM64 /**< 64-bit long mode (paged), kernel+tss always 64-bit. */
|
---|
92 | /** @} */
|
---|
93 |
|
---|
94 | /** @name Derived Indicators
|
---|
95 | * @{ */
|
---|
96 | # define TMPL_CMN_PE /**< TMPL_PE16 | TMPL_PE16_32 | TMPL_PE16_V86 | TMPL_PE32 | TMPL_PE32_16 | TMPL_PEV86 */
|
---|
97 | # define TMPL_SYS_PE16 /**< TMPL_PE16 | TMPL_PE16_32 | TMPL_PE16_V86 */
|
---|
98 | # define TMPL_SYS_PE32 /**< TMPL_PE32 | TMPL_PE32_16 | TMPL_PEV86 */
|
---|
99 | # define TMPL_CMN_PP /**< TMPL_PP16 | TMPL_PP16_32 | TMPL_PP16_V86 | TMPL_PP32 | TMPL_PP32_16 | TMPL_PPV86 */
|
---|
100 | # define TMPL_SYS_PP16 /**< TMPL_PP16 | TMPL_PP16_32 | TMPL_PP16_V86 */
|
---|
101 | # define TMPL_SYS_PP32 /**< TMPL_PP32 | TMPL_PP32_16 | TMPL_PPV86 */
|
---|
102 | # define TMPL_CMN_PAE /**< TMPL_PAE16 | TMPL_PAE16_32 | TMPL_PAE16_V86 | TMPL_PAE32 | TMPL_PAE32_16 | TMPL_PAEV86 */
|
---|
103 | # define TMPL_SYS_PAE16 /**< TMPL_PAE16 | TMPL_PAE16_32 | TMPL_PAE16_V86 */
|
---|
104 | # define TMPL_SYS_PAE32 /**< TMPL_PAE32 | TMPL_PAE32_16 | TMPL_PAEV86 */
|
---|
105 | # define TMPL_CMN_LM /**< TMPL_LM16 | TMPL_LM32 | TMPL_LM64 */
|
---|
106 | # define TMPL_CMN_V86 /**< TMPL_PEV86 | TMPL_PE16_V86 | TMPL_PPV86 | TMPL_PP16_V86 | TMPL_PAEV86 | TMPL_PAE16_V86 */
|
---|
107 | # define TMPL_CMN_R86 /**< TMPL_CMN_V86 | TMPL_RM */
|
---|
108 | # define TMPL_CMN_PAGING /**< TMPL_CMN_PP | TMPL_CMN_PAE | TMPL_CMN_LM */
|
---|
109 | # define TMPL_CMN_WEIRD /**< TMPL_PE16_32 | TMPL_PE32_16 | TMPL_PP16_32 | TMPL_PP32_16 | TMPL_PAE16_32 | TMPL_PAE32_16 | TMPL_CMN_WEIRD_V86 */
|
---|
110 | # define TMPL_CMN_WEIRD_V86 /**< TMPL_PE16_V86 | TMPL_PP16_V86 | TMPL_PAE16_V86 */
|
---|
111 | /** @} */
|
---|
112 |
|
---|
113 | /** @def TMPL_NM
|
---|
114 | * Name mangling macro for the current mode.
|
---|
115 | *
|
---|
116 | * Example: TMPL_NM(PrintChr)
|
---|
117 | *
|
---|
118 | * @param Name The function or variable name to mangle.
|
---|
119 | * @sa #TMPL_FAR_NM, #BS3_CMN_NM, #BS3_CMN_FAR_NM
|
---|
120 | */
|
---|
121 | # define TMPL_NM(Name) RT_CONCAT(Name,_mode)
|
---|
122 |
|
---|
123 | /** @def TMPL_FAR_NM
|
---|
124 | * Name mangling macro for the current mode into a far function name.
|
---|
125 | *
|
---|
126 | * In 32-bit and 64-bit code this does not differ from #TMPL_NM.
|
---|
127 | *
|
---|
128 | * Example: TMPL_FAR_NM(PrintChr)
|
---|
129 | *
|
---|
130 | * @param Name The function or variable name to mangle.
|
---|
131 | * @sa #TMPL_NM, #BS3_CMN_FAR_NM, #BS3_CMN_NM
|
---|
132 | */
|
---|
133 | # define TMPL_FAR_NM(Name) RT_CONCAT3(Name,_mode,_far)
|
---|
134 |
|
---|
135 | /** @def TMPL_MODE_STR
|
---|
136 | * Short mode description. */
|
---|
137 | # define TMPL_MODE_STR
|
---|
138 |
|
---|
139 | /** @def TMPL_HAVE_BIOS
|
---|
140 | * Indicates that we have direct access to the BIOS (only in real mode). */
|
---|
141 | # define TMPL_HAVE_BIOS
|
---|
142 |
|
---|
143 |
|
---|
144 | /** @name For ASM compatability
|
---|
145 | * @{ */
|
---|
146 | /** @def TMPL_16BIT
|
---|
147 | * For ASM compatibility - please use ARCH_BITS == 16. */
|
---|
148 | # define TMPL_16BIT
|
---|
149 | /** @def TMPL_32BIT
|
---|
150 | * For ASM compatibility - please use ARCH_BITS == 32. */
|
---|
151 | # define TMPL_32BIT
|
---|
152 | /** @def TMPL_64BIT
|
---|
153 | * For ASM compatibility - please use ARCH_BITS == 64. */
|
---|
154 | # define TMPL_64BIT
|
---|
155 |
|
---|
156 | /** @def TMPL_BITS
|
---|
157 | * For ASM compatibility - please use ARCH_BITS instead. */
|
---|
158 | # define TMPL_BITS ARCH_BITS
|
---|
159 | /** @} */
|
---|
160 |
|
---|
161 | #else /* !DOXYGEN_RUNNING */
|
---|
162 |
|
---|
163 | //#undef BS3_CMN_NM
|
---|
164 | //#undef BS3_CMN_FAR_NM
|
---|
165 |
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * Convert TMPL_XXX to TMPL_MODE.
|
---|
169 | */
|
---|
170 | #ifndef TMPL_MODE
|
---|
171 | # ifdef TMPL_RM
|
---|
172 | # define TMPL_MODE BS3_MODE_RM
|
---|
173 | # elif defined(TMPL_PE16)
|
---|
174 | # define TMPL_MODE BS3_MODE_PE16
|
---|
175 | # elif defined(TMPL_PE16_32)
|
---|
176 | # define TMPL_MODE BS3_MODE_PE16_32
|
---|
177 | # elif defined(TMPL_PE16_V86)
|
---|
178 | # define TMPL_MODE BS3_MODE_PE16_V86
|
---|
179 | # elif defined(TMPL_PE32)
|
---|
180 | # define TMPL_MODE BS3_MODE_PE32
|
---|
181 | # elif defined(TMPL_PE32_16)
|
---|
182 | # define TMPL_MODE BS3_MODE_PE32_16
|
---|
183 | # elif defined(TMPL_PEV86)
|
---|
184 | # define TMPL_MODE BS3_MODE_PEV86
|
---|
185 | # elif defined(TMPL_PP16)
|
---|
186 | # define TMPL_MODE BS3_MODE_PP16
|
---|
187 | # elif defined(TMPL_PP16_32)
|
---|
188 | # define TMPL_MODE BS3_MODE_PP16_32
|
---|
189 | # elif defined(TMPL_PP16_V86)
|
---|
190 | # define TMPL_MODE BS3_MODE_PP16_V86
|
---|
191 | # elif defined(TMPL_PP32)
|
---|
192 | # define TMPL_MODE BS3_MODE_PP32
|
---|
193 | # elif defined(TMPL_PP32_16)
|
---|
194 | # define TMPL_MODE BS3_MODE_PP32_16
|
---|
195 | # elif defined(TMPL_PPV86)
|
---|
196 | # define TMPL_MODE BS3_MODE_PPV86
|
---|
197 | # elif defined(TMPL_PAE16)
|
---|
198 | # define TMPL_MODE BS3_MODE_PAE16
|
---|
199 | # elif defined(TMPL_PAE16_32)
|
---|
200 | # define TMPL_MODE BS3_MODE_PAE16_32
|
---|
201 | # elif defined(TMPL_PAE16_V86)
|
---|
202 | # define TMPL_MODE BS3_MODE_PAE16_V86
|
---|
203 | # elif defined(TMPL_PAE32)
|
---|
204 | # define TMPL_MODE BS3_MODE_PAE32
|
---|
205 | # elif defined(TMPL_PAE32_16)
|
---|
206 | # define TMPL_MODE BS3_MODE_PAE32_16
|
---|
207 | # elif defined(TMPL_PAEV86)
|
---|
208 | # define TMPL_MODE BS3_MODE_PAEV86
|
---|
209 | # elif defined(TMPL_LM16)
|
---|
210 | # define TMPL_MODE BS3_MODE_LM16
|
---|
211 | # elif defined(TMPL_LM32)
|
---|
212 | # define TMPL_MODE BS3_MODE_LM32
|
---|
213 | # elif defined(TMPL_LM64)
|
---|
214 | # define TMPL_MODE BS3_MODE_LM64
|
---|
215 | # else
|
---|
216 | # error "Unable to to figure out the template mode."
|
---|
217 | # endif
|
---|
218 | #endif
|
---|
219 |
|
---|
220 |
|
---|
221 | /*
|
---|
222 | * Check the code bitness and set derived defines.
|
---|
223 | */
|
---|
224 | #if (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_16
|
---|
225 | # if ARCH_BITS != 16
|
---|
226 | # error "BS3_MODE_CODE_16 requires ARCH_BITS to be 16."
|
---|
227 | # endif
|
---|
228 | # define TMPL_16BIT
|
---|
229 | # define TMPL_BITS 16
|
---|
230 | # define TMPL_UNDERSCORE _
|
---|
231 | //# define BS3_CMN_NM(Name) RT_CONCAT(Name,_c16)
|
---|
232 | //# define BS3_CMN_FAR_NM(Name) RT_CONCAT(Name,_f16)
|
---|
233 |
|
---|
234 |
|
---|
235 | #elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_32
|
---|
236 | # if ARCH_BITS != 32
|
---|
237 | # error "BS3_MODE_CODE_32 requires ARCH_BITS to be 32."
|
---|
238 | # endif
|
---|
239 | # define TMPL_32BIT
|
---|
240 | # define TMPL_BITS 32
|
---|
241 | # define TMPL_UNDERSCORE _
|
---|
242 | //# define BS3_CMN_NM(Name) RT_CONCAT(Name,_c32)
|
---|
243 | //# define BS3_CMN_FAR_NM(a_Name) RT_CONCAT(Name,_c32)
|
---|
244 |
|
---|
245 | #elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_V86
|
---|
246 | # if ARCH_BITS != 16
|
---|
247 | # error "BS3_MODE_CODE_V86 requires ARCH_BITS to be 16."
|
---|
248 | # endif
|
---|
249 | # define TMPL_16BIT
|
---|
250 | # define TMPL_BITS 16
|
---|
251 | # define TMPL_UNDERSCORE _
|
---|
252 | //# define BS3_CMN_NM(Name) RT_CONCAT(Name,_c16)
|
---|
253 | //# define BS3_CMN_FAR_NM(Name) RT_CONCAT(Name,_f16)
|
---|
254 | # define TMPL_CMN_R86
|
---|
255 | # define TMPL_CMN_V86
|
---|
256 |
|
---|
257 | #elif (TMPL_MODE & BS3_MODE_CODE_MASK) == BS3_MODE_CODE_64
|
---|
258 | # if ARCH_BITS != 64
|
---|
259 | # error "BS3_MODE_CODE_64 requires ARCH_BITS to be 64."
|
---|
260 | # endif
|
---|
261 | # define TMPL_64BIT
|
---|
262 | # define TMPL_BITS 64
|
---|
263 | # define TMPL_UNDERSCORE
|
---|
264 | //# define BS3_CMN_NM(Name) RT_CONCAT(Name,_c64)
|
---|
265 | //# define BS3_CMN_FAR_NM(a_Name) RT_CONCAT(Name,_c64)
|
---|
266 |
|
---|
267 | #else
|
---|
268 | # error "Invalid TMPL_MODE value!"
|
---|
269 | #endif
|
---|
270 |
|
---|
271 |
|
---|
272 | /*
|
---|
273 | * Check the system specific mask and set derived values.
|
---|
274 | */
|
---|
275 | #if (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_RM
|
---|
276 | # define TMPL_HAVE_BIOS
|
---|
277 | # define TMPL_CMN_R86
|
---|
278 |
|
---|
279 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE16
|
---|
280 | # define TMPL_SYS_PE16
|
---|
281 | # define TMPL_CMN_PE
|
---|
282 |
|
---|
283 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PE32
|
---|
284 | # define TMPL_SYS_PE32
|
---|
285 | # define TMPL_CMN_PE
|
---|
286 |
|
---|
287 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP16
|
---|
288 | # define TMPL_SYS_PP16
|
---|
289 | # define TMPL_CMN_PP
|
---|
290 | # define TMPL_CMN_PAGING
|
---|
291 |
|
---|
292 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PP32
|
---|
293 | # define TMPL_SYS_PP32
|
---|
294 | # define TMPL_CMN_PP
|
---|
295 | # define TMPL_CMN_PAGING
|
---|
296 |
|
---|
297 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE16
|
---|
298 | # define TMPL_SYS_PAE16
|
---|
299 | # define TMPL_CMN_PAE
|
---|
300 | # define TMPL_CMN_PAGING
|
---|
301 |
|
---|
302 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_PAE32
|
---|
303 | # define TMPL_SYS_PAE32
|
---|
304 | # define TMPL_CMN_PAE
|
---|
305 | # define TMPL_CMN_PAGING
|
---|
306 |
|
---|
307 | #elif (TMPL_MODE & BS3_MODE_SYS_MASK) == BS3_MODE_SYS_LM
|
---|
308 | # define TMPL_SYS_LM
|
---|
309 | # define TMPL_CMN_LM
|
---|
310 | # define TMPL_CMN_PAGING
|
---|
311 |
|
---|
312 | #else
|
---|
313 | # error "Invalid TMPL_MODE value!"
|
---|
314 | #endif
|
---|
315 |
|
---|
316 |
|
---|
317 | /*
|
---|
318 | * Mode specific stuff.
|
---|
319 | */
|
---|
320 | #if TMPL_MODE == BS3_MODE_RM
|
---|
321 | # define TMPL_RM 1
|
---|
322 | # define TMPL_MODE_STR "real mode"
|
---|
323 | # define TMPL_NM(Name) RT_CONCAT(Name,_rm)
|
---|
324 | # define TMPL_MODE_LNAME rm
|
---|
325 | # define TMPL_MODE_UNAME RM
|
---|
326 |
|
---|
327 |
|
---|
328 | #elif TMPL_MODE == BS3_MODE_PE16
|
---|
329 | # define TMPL_PE16 1
|
---|
330 | # define TMPL_MODE_STR "16-bit prot, 16-bit"
|
---|
331 | # define TMPL_NM(Name) RT_CONCAT(Name,_pe16)
|
---|
332 | # define TMPL_MODE_LNAME pe16
|
---|
333 | # define TMPL_MODE_UNAME PE16
|
---|
334 |
|
---|
335 | #elif TMPL_MODE == BS3_MODE_PE16_32
|
---|
336 | # define TMPL_PE16_32 1
|
---|
337 | # define TMPL_MODE_STR "16-bit prot, 32-bit"
|
---|
338 | # define TMPL_NM(Name) RT_CONCAT(Name,_pe16_32)
|
---|
339 | # define TMPL_MODE_LNAME pe16_32
|
---|
340 | # define TMPL_MODE_UNAME PE16_32
|
---|
341 | # define TMPL_CMN_WEIRD
|
---|
342 |
|
---|
343 | #elif TMPL_MODE == BS3_MODE_PE16_V86
|
---|
344 | # define TMPL_PE16_V86 1
|
---|
345 | # define TMPL_MODE_STR "16-bit prot, v8086"
|
---|
346 | # define TMPL_NM(Name) RT_CONCAT(Name,_pe16_v86)
|
---|
347 | # define TMPL_MODE_LNAME pe16_v86
|
---|
348 | # define TMPL_MODE_UNAME PE16_v86
|
---|
349 | # define TMPL_CMN_WEIRD
|
---|
350 | # define TMPL_CMN_WEIRD_V86
|
---|
351 |
|
---|
352 |
|
---|
353 | #elif TMPL_MODE == BS3_MODE_PE32
|
---|
354 | # define TMPL_PE32 1
|
---|
355 | # define TMPL_MODE_STR "32-bit prot, 32-bit"
|
---|
356 | # define TMPL_NM(Name) RT_CONCAT(Name,_pe32)
|
---|
357 | # define TMPL_MODE_LNAME pe32
|
---|
358 | # define TMPL_MODE_UNAME PE32
|
---|
359 |
|
---|
360 | #elif TMPL_MODE == BS3_MODE_PE32_16
|
---|
361 | # define TMPL_PE32_16 1
|
---|
362 | # define TMPL_MODE_STR "32-bit prot, 16-bit"
|
---|
363 | # define TMPL_NM(Name) RT_CONCAT(Name,_pe32_16)
|
---|
364 | # define TMPL_MODE_LNAME pe32_16
|
---|
365 | # define TMPL_MODE_UNAME PE32_16
|
---|
366 | # define TMPL_CMN_WEIRD
|
---|
367 |
|
---|
368 | #elif TMPL_MODE == BS3_MODE_PEV86
|
---|
369 | # define TMPL_PEV86 1
|
---|
370 | # define TMPL_MODE_STR "32-bit prot, v8086"
|
---|
371 | # define TMPL_NM(Name) RT_CONCAT(Name,_pev86)
|
---|
372 | # define TMPL_MODE_LNAME pev86
|
---|
373 | # define TMPL_MODE_UNAME PEV86
|
---|
374 |
|
---|
375 |
|
---|
376 | #elif TMPL_MODE == BS3_MODE_PP16
|
---|
377 | # define TMPL_PP16 1
|
---|
378 | # define TMPL_MODE_STR "16-bit paged, 16-bit"
|
---|
379 | # define TMPL_NM(Name) RT_CONCAT(Name,_pp16)
|
---|
380 | # define TMPL_MODE_LNAME pp16
|
---|
381 | # define TMPL_MODE_UNAME PP16
|
---|
382 |
|
---|
383 | #elif TMPL_MODE == BS3_MODE_PP16_32
|
---|
384 | # define TMPL_PP16_32 1
|
---|
385 | # define TMPL_MODE_STR "16-bit paged, 32-bit"
|
---|
386 | # define TMPL_NM(Name) RT_CONCAT(Name,_pp16_32)
|
---|
387 | # define TMPL_MODE_LNAME pp16_32
|
---|
388 | # define TMPL_MODE_UNAME PP16_32
|
---|
389 | # define TMPL_CMN_WEIRD
|
---|
390 |
|
---|
391 | #elif TMPL_MODE == BS3_MODE_PP16_V86
|
---|
392 | # define TMPL_PP16_V86 1
|
---|
393 | # define TMPL_MODE_STR "16-bit paged, v8086"
|
---|
394 | # define TMPL_NM(Name) RT_CONCAT(Name,_pp16_v86)
|
---|
395 | # define TMPL_MODE_LNAME pp16_v86
|
---|
396 | # define TMPL_MODE_UNAME PP16_v86
|
---|
397 | # define TMPL_CMN_WEIRD
|
---|
398 | # define TMPL_CMN_WEIRD_V86
|
---|
399 |
|
---|
400 |
|
---|
401 | #elif TMPL_MODE == BS3_MODE_PP32
|
---|
402 | # define TMPL_PP32 1
|
---|
403 | # define TMPL_MODE_STR "32-bit paged, 32-bit"
|
---|
404 | # define TMPL_NM(Name) RT_CONCAT(Name,_pp32)
|
---|
405 | # define TMPL_MODE_LNAME pp32
|
---|
406 | # define TMPL_MODE_UNAME PP32
|
---|
407 |
|
---|
408 | #elif TMPL_MODE == BS3_MODE_PP32_16
|
---|
409 | # define TMPL_PP32_16 1
|
---|
410 | # define TMPL_MODE_STR "32-bit paged, 16-bit"
|
---|
411 | # define TMPL_NM(Name) RT_CONCAT(Name,_pp32_16)
|
---|
412 | # define TMPL_MODE_LNAME pp32_16
|
---|
413 | # define TMPL_MODE_UNAME PP32_16
|
---|
414 | # define TMPL_CMN_WEIRD
|
---|
415 |
|
---|
416 | #elif TMPL_MODE == BS3_MODE_PPV86
|
---|
417 | # define TMPL_PPV86 1
|
---|
418 | # define TMPL_MODE_STR "32-bit paged, v8086"
|
---|
419 | # define TMPL_NM(Name) RT_CONCAT(Name,_ppv86)
|
---|
420 | # define TMPL_MODE_LNAME ppv86
|
---|
421 | # define TMPL_MODE_UNAME PPV86
|
---|
422 |
|
---|
423 |
|
---|
424 | #elif TMPL_MODE == BS3_MODE_PAE16
|
---|
425 | # define TMPL_PAE16 1
|
---|
426 | # define TMPL_MODE_STR "16-bit pae, 16-bit"
|
---|
427 | # define TMPL_NM(Name) RT_CONCAT(Name,_pae16)
|
---|
428 | # define TMPL_MODE_LNAME pae16
|
---|
429 | # define TMPL_MODE_UNAME PAE16
|
---|
430 |
|
---|
431 | #elif TMPL_MODE == BS3_MODE_PAE16_32
|
---|
432 | # define TMPL_PAE16_32 1
|
---|
433 | # define TMPL_MODE_STR "16-bit pae, 32-bit"
|
---|
434 | # define TMPL_NM(Name) RT_CONCAT(Name,_pae16_32)
|
---|
435 | # define TMPL_MODE_LNAME pae16_32
|
---|
436 | # define TMPL_MODE_UNAME PAE16_32
|
---|
437 | # define TMPL_CMN_WEIRD
|
---|
438 |
|
---|
439 | #elif TMPL_MODE == BS3_MODE_PAE16_V86
|
---|
440 | # define TMPL_PAE16_V86 1
|
---|
441 | # define TMPL_MODE_STR "16-bit pae, v8086"
|
---|
442 | # define TMPL_NM(Name) RT_CONCAT(Name,_pae16_v86)
|
---|
443 | # define TMPL_MODE_LNAME pae16_v86
|
---|
444 | # define TMPL_MODE_UNAME PAE16_v86
|
---|
445 | # define TMPL_CMN_WEIRD
|
---|
446 | # define TMPL_CMN_WEIRD_V86
|
---|
447 |
|
---|
448 |
|
---|
449 | #elif TMPL_MODE == BS3_MODE_PAE32
|
---|
450 | # define TMPL_PAE32 1
|
---|
451 | # define TMPL_MODE_STR "32-bit pae, 32-bit"
|
---|
452 | # define TMPL_NM(Name) RT_CONCAT(Name,_pae32)
|
---|
453 | # define TMPL_MODE_LNAME pae32
|
---|
454 | # define TMPL_MODE_UNAME PAE32
|
---|
455 |
|
---|
456 | #elif TMPL_MODE == BS3_MODE_PAE32_16
|
---|
457 | # define TMPL_PAE32_16 1
|
---|
458 | # define TMPL_MODE_STR "32-bit pae, 32-bit"
|
---|
459 | # define TMPL_NM(Name) RT_CONCAT(Name,_pae32_16)
|
---|
460 | # define TMPL_MODE_LNAME pae32_16
|
---|
461 | # define TMPL_MODE_UNAME PAE32_16
|
---|
462 | # define TMPL_CMN_WEIRD
|
---|
463 |
|
---|
464 | #elif TMPL_MODE == BS3_MODE_PAEV86
|
---|
465 | # define TMPL_PAEV86 1
|
---|
466 | # define TMPL_MODE_STR "32-bit pae, v8086 pae"
|
---|
467 | # define TMPL_NM(Name) RT_CONCAT(Name,_paev86)
|
---|
468 | # define TMPL_MODE_LNAME paev86
|
---|
469 | # define TMPL_MODE_UNAME PAEV86
|
---|
470 |
|
---|
471 |
|
---|
472 | #elif TMPL_MODE == BS3_MODE_LM16
|
---|
473 | # define TMPL_LM16 1
|
---|
474 | # define TMPL_MODE_STR "long, 16-bit"
|
---|
475 | # define TMPL_NM(Name) RT_CONCAT(Name,_lm16)
|
---|
476 | # define TMPL_MODE_LNAME lm16
|
---|
477 | # define TMPL_MODE_UNAME LM16
|
---|
478 |
|
---|
479 | #elif TMPL_MODE == BS3_MODE_LM32
|
---|
480 | # define TMPL_LM32 1
|
---|
481 | # define TMPL_MODE_STR "long, 32-bit"
|
---|
482 | # define TMPL_NM(Name) RT_CONCAT(Name,_lm32)
|
---|
483 | # define TMPL_MODE_LNAME lm32
|
---|
484 | # define TMPL_MODE_UNAME LM32
|
---|
485 |
|
---|
486 | #elif TMPL_MODE == BS3_MODE_LM64
|
---|
487 | # define TMPL_LM64 1
|
---|
488 | # define TMPL_MODE_STR "long, 64-bit"
|
---|
489 | # define TMPL_NM(Name) RT_CONCAT(Name,_lm64)
|
---|
490 | # define TMPL_MODE_LNAME lm64
|
---|
491 | # define TMPL_MODE_UNAME LM64
|
---|
492 |
|
---|
493 | #else
|
---|
494 | # error "Invalid TMPL_MODE value!!"
|
---|
495 | #endif
|
---|
496 |
|
---|
497 |
|
---|
498 | #if TMPL_MODE & (BS3_MODE_CODE_16 | BS3_MODE_CODE_V86)
|
---|
499 | # define TMPL_FAR_NM(Name) RT_CONCAT3(TMPL_NM(Name),_f,ar) /* _far and far may be #defined already. */
|
---|
500 | #else
|
---|
501 | # define TMPL_FAR_NM(Name) TMPL_NM(Name)
|
---|
502 | #endif
|
---|
503 |
|
---|
504 |
|
---|
505 | /** @def BS3_MODE_DEF
|
---|
506 | * Macro for defining a mode specific function.
|
---|
507 | *
|
---|
508 | * This makes 16-bit mode functions far, while 32-bit and 64-bit are near.
|
---|
509 | * You need to update the make file to generate near->far wrappers in most
|
---|
510 | * cases.
|
---|
511 | *
|
---|
512 | * @param a_RetType The return type.
|
---|
513 | * @param a_Name The function basename.
|
---|
514 | * @param a_Params The parameter list (in parentheses).
|
---|
515 | *
|
---|
516 | * @sa BS3_MODE_PROTO
|
---|
517 | */
|
---|
518 | #if ARCH_BITS == 16
|
---|
519 | # define BS3_MODE_DEF(a_RetType, a_Name, a_Params) BS3_DECL_FAR(a_RetType) TMPL_FAR_NM(a_Name) a_Params
|
---|
520 | #else
|
---|
521 | # define BS3_MODE_DEF(a_RetType, a_Name, a_Params) BS3_DECL_NEAR(a_RetType) TMPL_NM(a_Name) a_Params
|
---|
522 | #endif
|
---|
523 |
|
---|
524 |
|
---|
525 |
|
---|
526 | #ifndef TMPL_MODE_STR
|
---|
527 | # error "internal error"
|
---|
528 | #endif
|
---|
529 |
|
---|
530 | #endif /* !DOXYGEN_RUNNING */
|
---|
531 | /** @} */
|
---|
532 |
|
---|