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