1 | ;; @file
|
---|
2 | ; IPRT - Global YASM/NASM macros
|
---|
3 | ;
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; Copyright (C) 2006-2012 Oracle Corporation
|
---|
7 | ;
|
---|
8 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
10 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | ; General Public License (GPL) as published by the Free Software
|
---|
12 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | ;
|
---|
16 | ; The contents of this file may alternatively be used under the terms
|
---|
17 | ; of the Common Development and Distribution License Version 1.0
|
---|
18 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | ; CDDL are applicable instead of those of the GPL.
|
---|
21 | ;
|
---|
22 | ; You may elect to license modified versions of this file under the
|
---|
23 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | ;
|
---|
25 |
|
---|
26 | %ifndef ___iprt_asmdefs_mac
|
---|
27 | %define ___iprt_asmdefs_mac
|
---|
28 |
|
---|
29 |
|
---|
30 | ;; @defgroup grp_rt_cdefs_size Size Constants
|
---|
31 | ; (Of course, these are binary computer terms, not SI.)
|
---|
32 | ; @{
|
---|
33 | ;; 1 K (Kilo) (1 024).
|
---|
34 | %define _1K 000000400h
|
---|
35 | ;; 4 K (Kilo) (4 096).
|
---|
36 | %define _4K 000001000h
|
---|
37 | ;; 32 K (Kilo) (32 678).
|
---|
38 | %define _32K 000008000h
|
---|
39 | ;; 64 K (Kilo) (65 536).
|
---|
40 | %define _64K 000010000h
|
---|
41 | ;; 128 K (Kilo) (131 072).
|
---|
42 | %define _128K 000020000h
|
---|
43 | ;; 256 K (Kilo) (262 144).
|
---|
44 | %define _256K 000040000h
|
---|
45 | ;; 512 K (Kilo) (524 288).
|
---|
46 | %define _512K 000080000h
|
---|
47 | ;; 1 M (Mega) (1 048 576).
|
---|
48 | %define _1M 000100000h
|
---|
49 | ;; 2 M (Mega) (2 097 152).
|
---|
50 | %define _2M 000200000h
|
---|
51 | ;; 4 M (Mega) (4 194 304).
|
---|
52 | %define _4M 000400000h
|
---|
53 | ;; 1 G (Giga) (1 073 741 824).
|
---|
54 | %define _1G 040000000h
|
---|
55 | ;; 2 G (Giga) (2 147 483 648).
|
---|
56 | %define _2G 00000000080000000h
|
---|
57 | ;; 4 G (Giga) (4 294 967 296).
|
---|
58 | %define _4G 00000000100000000h
|
---|
59 | ;; 1 T (Tera) (1 099 511 627 776).
|
---|
60 | %define _1T 00000010000000000h
|
---|
61 | ;; 1 P (Peta) (1 125 899 906 842 624).
|
---|
62 | %define _1P 00004000000000000h
|
---|
63 | ;; 1 E (Exa) (1 152 921 504 606 846 976).
|
---|
64 | %define _1E 01000000000000000h
|
---|
65 | ;; 2 E (Exa) (2 305 843 009 213 693 952).
|
---|
66 | %define _2E 02000000000000000h
|
---|
67 | ;; @}
|
---|
68 |
|
---|
69 |
|
---|
70 | ;;
|
---|
71 | ; Make the mask for the given bit.
|
---|
72 | %define RT_BIT(bit) (1 << bit)
|
---|
73 |
|
---|
74 | ;;
|
---|
75 | ; Align code, pad with INT3.
|
---|
76 | %define ALIGNCODE(alignment) align alignment, db 0cch
|
---|
77 |
|
---|
78 | ;;
|
---|
79 | ; Align data, pad with ZEROs.
|
---|
80 | %define ALIGNDATA(alignment) align alignment, db 0
|
---|
81 |
|
---|
82 | ;;
|
---|
83 | ; Align BSS, pad with ZEROs.
|
---|
84 | %define ALIGNBSS(alignment) align alignment, resb 1
|
---|
85 |
|
---|
86 | ;;
|
---|
87 | ; NAME_OVERLOAD can be defined by a .asm module to modify all the
|
---|
88 | ; names created using the name macros in this files.
|
---|
89 | ; This is handy when you've got some kind of template code.
|
---|
90 | %ifndef NAME_OVERLOAD
|
---|
91 | %define NAME_OVERLOAD(name) name
|
---|
92 | %endif
|
---|
93 |
|
---|
94 | ;;
|
---|
95 | ; Mangles the given name so it can be referenced using DECLASM() in the
|
---|
96 | ; C/C++ world.
|
---|
97 | %ifdef RT_ARCH_X86
|
---|
98 | %ifdef RT_OS_OS2
|
---|
99 | %define NAME(name) _ %+ NAME_OVERLOAD(name)
|
---|
100 | %endif
|
---|
101 | %ifdef RT_OS_WINDOWS
|
---|
102 | %define NAME(name) _ %+ NAME_OVERLOAD(name)
|
---|
103 | %endif
|
---|
104 | %endif
|
---|
105 | %ifdef RT_OS_DARWIN
|
---|
106 | %define NAME(name) _ %+ NAME_OVERLOAD(name)
|
---|
107 | %endif
|
---|
108 | %ifndef NAME
|
---|
109 | %define NAME(name) NAME_OVERLOAD(name)
|
---|
110 | %endif
|
---|
111 |
|
---|
112 | ;;
|
---|
113 | ; Mangles the given C name so it will _import_ the right symbol.
|
---|
114 | %ifdef ASM_FORMAT_PE
|
---|
115 | %define IMPNAME(name) __imp_ %+ NAME(name)
|
---|
116 | %else
|
---|
117 | %define IMPNAME(name) NAME(name)
|
---|
118 | %endif
|
---|
119 |
|
---|
120 | ;;
|
---|
121 | ; Gets the pointer to an imported object.
|
---|
122 | %ifdef ASM_FORMAT_PE
|
---|
123 | %ifdef RT_ARCH_AMD64
|
---|
124 | %define IMP(name) qword [IMPNAME(name) wrt rip]
|
---|
125 | %else
|
---|
126 | %define IMP(name) dword [IMPNAME(name)]
|
---|
127 | %endif
|
---|
128 | %else
|
---|
129 | %define IMP(name) IMPNAME(name)
|
---|
130 | %endif
|
---|
131 |
|
---|
132 | ;;
|
---|
133 | ; Declares an imported object for use with IMP2.
|
---|
134 | ; @note May change the current section!
|
---|
135 | %macro EXTERN_IMP2 1
|
---|
136 | extern IMPNAME(%1)
|
---|
137 | BEGINDATA
|
---|
138 | %ifdef ASM_FORMAT_MACHO
|
---|
139 | g_Imp2_ %+ %1: RTCCPTR_DEF IMPNAME(%1)
|
---|
140 | %endif
|
---|
141 | %endmacro
|
---|
142 |
|
---|
143 | ;;
|
---|
144 | ; Gets the pointer to an imported object, version 2.
|
---|
145 | %ifdef ASM_FORMAT_PE
|
---|
146 | %ifdef RT_ARCH_AMD64
|
---|
147 | %define IMP2(name) qword [IMPNAME(name) wrt rip]
|
---|
148 | %else
|
---|
149 | %define IMP2(name) dword [IMPNAME(name)]
|
---|
150 | %endif
|
---|
151 | %elifdef ASM_FORMAT_ELF
|
---|
152 | %ifdef PIC
|
---|
153 | %ifdef RT_ARCH_AMD64
|
---|
154 | %define IMP2(name) qword [rel IMPNAME(name) wrt ..got]
|
---|
155 | %else
|
---|
156 | %define IMP2(name) IMPNAME(name) wrt ..plt
|
---|
157 | %endif
|
---|
158 | %endif
|
---|
159 | %elifdef ASM_FORMAT_MACHO
|
---|
160 | %define IMP2(name) RTCCPTR_PRE [g_Imp2_ %+ name xWrtRIP]
|
---|
161 | %endif
|
---|
162 | %ifndef IMP2
|
---|
163 | %define IMP2(name) IMPNAME(name)
|
---|
164 | %endif
|
---|
165 |
|
---|
166 |
|
---|
167 |
|
---|
168 | ;;
|
---|
169 | ; Global marker which is DECLASM() compatible.
|
---|
170 | %macro GLOBALNAME 1,
|
---|
171 | %ifndef ASM_FORMAT_BIN
|
---|
172 | global NAME(%1)
|
---|
173 | %endif
|
---|
174 | NAME(%1):
|
---|
175 | %endmacro
|
---|
176 |
|
---|
177 | ;;
|
---|
178 | ; Global exported marker which is DECLASM() compatible.
|
---|
179 | %macro EXPORTEDNAME 1,
|
---|
180 | %ifdef ASM_FORMAT_PE
|
---|
181 | export %1=NAME(%1)
|
---|
182 | %endif
|
---|
183 | %ifdef __NASM__
|
---|
184 | %ifdef ASM_FORMAT_OMF
|
---|
185 | export NAME(%1) NAME(%1)
|
---|
186 | %endif
|
---|
187 | %endif
|
---|
188 | GLOBALNAME %1
|
---|
189 | %endmacro
|
---|
190 |
|
---|
191 | ;;
|
---|
192 | ; Global marker which is DECLASM() compatible.
|
---|
193 | %macro GLOBALNAME_EX 2,
|
---|
194 | %ifndef ASM_FORMAT_BIN
|
---|
195 | %ifdef ASM_FORMAT_ELF
|
---|
196 | global NAME(%1):%2
|
---|
197 | %else
|
---|
198 | global NAME(%1)
|
---|
199 | %endif
|
---|
200 | %endif
|
---|
201 | NAME(%1):
|
---|
202 | %endmacro
|
---|
203 |
|
---|
204 | ;;
|
---|
205 | ; Global exported marker which is DECLASM() compatible.
|
---|
206 | %macro EXPORTEDNAME_EX 2,
|
---|
207 | %ifdef ASM_FORMAT_PE
|
---|
208 | export %1=NAME(%1)
|
---|
209 | %endif
|
---|
210 | %ifdef __NASM__
|
---|
211 | %ifdef ASM_FORMAT_OMF
|
---|
212 | export NAME(%1) NAME(%1)
|
---|
213 | %endif
|
---|
214 | %endif
|
---|
215 | GLOBALNAME_EX %1, %2
|
---|
216 | %endmacro
|
---|
217 |
|
---|
218 | ;;
|
---|
219 | ; Begins a C callable procedure.
|
---|
220 | %macro BEGINPROC 1
|
---|
221 | GLOBALNAME_EX %1, function hidden
|
---|
222 | %endmacro
|
---|
223 |
|
---|
224 | ;;
|
---|
225 | ; Begins a C callable exported procedure.
|
---|
226 | %macro BEGINPROC_EXPORTED 1
|
---|
227 | EXPORTEDNAME_EX %1, function
|
---|
228 | %endmacro
|
---|
229 |
|
---|
230 | ;;
|
---|
231 | ; Ends a C callable procedure.
|
---|
232 | %macro ENDPROC 1
|
---|
233 | GLOBALNAME_EX %1 %+ _EndProc, function hidden
|
---|
234 | %ifdef ASM_FORMAT_ELF
|
---|
235 | size NAME(%1) NAME(%1 %+ _EndProc) - NAME(%1)
|
---|
236 | size NAME(%1 %+ _EndProc) 0
|
---|
237 | %endif
|
---|
238 | db 0xCC, 0xCC, 0xCC, 0xCC
|
---|
239 | %endmacro
|
---|
240 |
|
---|
241 |
|
---|
242 | ;
|
---|
243 | ; Do OMF and Mach-O/Yasm segment definitions
|
---|
244 | ;
|
---|
245 | ; Both format requires this to get the segment order right, in the Mach-O/Yasm case
|
---|
246 | ; it's only to make sure the .bss section ends up last (it's not declared here).
|
---|
247 | ;
|
---|
248 | %ifdef ASM_FORMAT_OMF
|
---|
249 |
|
---|
250 | ; 16-bit segments first (OMF / OS/2 specific).
|
---|
251 | %ifdef RT_INCL_16BIT_SEGMENTS
|
---|
252 | segment DATA16 public CLASS=FAR_DATA align=16 use16
|
---|
253 | segment DATA16_INIT public CLASS=FAR_DATA align=16 use16
|
---|
254 | group DGROUP16 DATA16 DATA16_INIT
|
---|
255 |
|
---|
256 | ;;
|
---|
257 | ; Begins 16-bit data
|
---|
258 | %macro BEGINDATA16 0
|
---|
259 | segment DATA16
|
---|
260 | %endmacro
|
---|
261 |
|
---|
262 | ;;
|
---|
263 | ; Begins 16-bit init data
|
---|
264 | %macro BEGINDATA16INIT 0
|
---|
265 | segment DATA16_INIT
|
---|
266 | %endmacro
|
---|
267 |
|
---|
268 | segment CODE16 public CLASS=FAR_CODE align=16 use16
|
---|
269 | segment CODE16_INIT public CLASS=FAR_CODE align=16 use16
|
---|
270 | group CGROUP16 CODE16 CODE16_INIT
|
---|
271 |
|
---|
272 | ;;
|
---|
273 | ; Begins 16-bit code
|
---|
274 | %macro BEGINCODE16 0
|
---|
275 | segment CODE16
|
---|
276 | %endmacro
|
---|
277 |
|
---|
278 | ;;
|
---|
279 | ; Begins 16-bit init code
|
---|
280 | %macro BEGINCODE16INIT 0
|
---|
281 | segment CODE16_INIT
|
---|
282 | %endmacro
|
---|
283 |
|
---|
284 | %endif
|
---|
285 |
|
---|
286 | ; 32-bit segments.
|
---|
287 | segment TEXT32 public CLASS=CODE align=16 use32 flat
|
---|
288 | segment DATA32 public CLASS=DATA align=16 use32 flat
|
---|
289 | segment BSS32 public CLASS=BSS align=16 use32 flat
|
---|
290 |
|
---|
291 | ; Make the TEXT32 segment default.
|
---|
292 | segment TEXT32
|
---|
293 | %endif
|
---|
294 |
|
---|
295 | %ifdef ASM_FORMAT_MACHO
|
---|
296 | %ifdef __YASM__
|
---|
297 | [section .text]
|
---|
298 | [section .data]
|
---|
299 | %endif
|
---|
300 | %endif
|
---|
301 |
|
---|
302 |
|
---|
303 | ;;
|
---|
304 | ; Begins code
|
---|
305 | %ifdef ASM_FORMAT_OMF
|
---|
306 | %macro BEGINCODE 0
|
---|
307 | segment TEXT32
|
---|
308 | %endmacro
|
---|
309 | %else
|
---|
310 | %macro BEGINCODE 0
|
---|
311 | [section .text]
|
---|
312 | %endmacro
|
---|
313 | %endif
|
---|
314 |
|
---|
315 | ;;
|
---|
316 | ; Begins constant (read-only) data
|
---|
317 | ;
|
---|
318 | ; @remarks This is mapped to the CODE section/segment when there isn't
|
---|
319 | ; any dedicated const section/segment. (There is code that
|
---|
320 | ; assumes this, so don't try change it.)
|
---|
321 | %ifdef ASM_FORMAT_OMF
|
---|
322 | %macro BEGINCONST 0
|
---|
323 | segment TEXT32
|
---|
324 | %endmacro
|
---|
325 | %else
|
---|
326 | %macro BEGINCONST 0
|
---|
327 | %ifdef ASM_FORMAT_MACHO ;; @todo check the other guys too.
|
---|
328 | [section .rodata]
|
---|
329 | %else
|
---|
330 | [section .text]
|
---|
331 | %endif
|
---|
332 | %endmacro
|
---|
333 | %endif
|
---|
334 |
|
---|
335 | ;;
|
---|
336 | ; Begins initialized data
|
---|
337 | %ifdef ASM_FORMAT_OMF
|
---|
338 | %macro BEGINDATA 0
|
---|
339 | segment DATA32
|
---|
340 | %endmacro
|
---|
341 | %else
|
---|
342 | %macro BEGINDATA 0
|
---|
343 | [section .data]
|
---|
344 | %endmacro
|
---|
345 | %endif
|
---|
346 |
|
---|
347 | ;;
|
---|
348 | ; Begins uninitialized data
|
---|
349 | %ifdef ASM_FORMAT_OMF
|
---|
350 | %macro BEGINBSS 0
|
---|
351 | segment BSS32
|
---|
352 | %endmacro
|
---|
353 | %else
|
---|
354 | %macro BEGINBSS 0
|
---|
355 | [section .bss]
|
---|
356 | %endmacro
|
---|
357 | %endif
|
---|
358 |
|
---|
359 |
|
---|
360 |
|
---|
361 | ;; @def ARCH_BITS
|
---|
362 | ; Defines the bit count of the current context.
|
---|
363 | %ifndef ARCH_BITS
|
---|
364 | %ifdef RT_ARCH_AMD64
|
---|
365 | %define ARCH_BITS 64
|
---|
366 | %else
|
---|
367 | %define ARCH_BITS 32
|
---|
368 | %endif
|
---|
369 | %endif
|
---|
370 |
|
---|
371 | ;; @def HC_ARCH_BITS
|
---|
372 | ; Defines the host architechture bit count.
|
---|
373 | %ifndef HC_ARCH_BITS
|
---|
374 | %ifndef IN_RC
|
---|
375 | %define HC_ARCH_BITS ARCH_BITS
|
---|
376 | %else
|
---|
377 | %define HC_ARCH_BITS 32
|
---|
378 | %endif
|
---|
379 | %endif
|
---|
380 |
|
---|
381 | ;; @def R3_ARCH_BITS
|
---|
382 | ; Defines the host ring-3 architechture bit count.
|
---|
383 | %ifndef R3_ARCH_BITS
|
---|
384 | %ifdef IN_RING3
|
---|
385 | %define R3_ARCH_BITS ARCH_BITS
|
---|
386 | %else
|
---|
387 | %define R3_ARCH_BITS HC_ARCH_BITS
|
---|
388 | %endif
|
---|
389 | %endif
|
---|
390 |
|
---|
391 | ;; @def R0_ARCH_BITS
|
---|
392 | ; Defines the host ring-0 architechture bit count.
|
---|
393 | %ifndef R0_ARCH_BITS
|
---|
394 | %ifdef IN_RING0
|
---|
395 | %define R0_ARCH_BITS ARCH_BITS
|
---|
396 | %else
|
---|
397 | %define R0_ARCH_BITS HC_ARCH_BITS
|
---|
398 | %endif
|
---|
399 | %endif
|
---|
400 |
|
---|
401 | ;; @def GC_ARCH_BITS
|
---|
402 | ; Defines the guest architechture bit count.
|
---|
403 | %ifndef GC_ARCH_BITS
|
---|
404 | %ifdef IN_RC
|
---|
405 | %define GC_ARCH_BITS ARCH_BITS
|
---|
406 | %else
|
---|
407 | %define GC_ARCH_BITS 32
|
---|
408 | %endif
|
---|
409 | %endif
|
---|
410 |
|
---|
411 |
|
---|
412 |
|
---|
413 | ;; @def RTHCPTR_DEF
|
---|
414 | ; The pesudo-instruction used to declare an initialized pointer variable in the host context.
|
---|
415 | %if HC_ARCH_BITS == 64
|
---|
416 | %define RTHCPTR_DEF dq
|
---|
417 | %else
|
---|
418 | %define RTHCPTR_DEF dd
|
---|
419 | %endif
|
---|
420 |
|
---|
421 | ;; @def RTHCPTR_RES
|
---|
422 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
423 | ; variable of the host context.
|
---|
424 | %if HC_ARCH_BITS == 64
|
---|
425 | %define RTHCPTR_RES resq
|
---|
426 | %else
|
---|
427 | %define RTHCPTR_RES resd
|
---|
428 | %endif
|
---|
429 |
|
---|
430 | ;; @def RTHCPTR_PRE
|
---|
431 | ; The memory operand prefix used for a pointer in the host context.
|
---|
432 | %if HC_ARCH_BITS == 64
|
---|
433 | %define RTHCPTR_PRE qword
|
---|
434 | %else
|
---|
435 | %define RTHCPTR_PRE dword
|
---|
436 | %endif
|
---|
437 |
|
---|
438 | ;; @def RTHCPTR_CB
|
---|
439 | ; The size in bytes of a pointer in the host context.
|
---|
440 | %if HC_ARCH_BITS == 64
|
---|
441 | %define RTHCPTR_CB 8
|
---|
442 | %else
|
---|
443 | %define RTHCPTR_CB 4
|
---|
444 | %endif
|
---|
445 |
|
---|
446 |
|
---|
447 |
|
---|
448 | ;; @def RTR0PTR_DEF
|
---|
449 | ; The pesudo-instruction used to declare an initialized pointer variable in the ring-0 host context.
|
---|
450 | %if R0_ARCH_BITS == 64
|
---|
451 | %define RTR0PTR_DEF dq
|
---|
452 | %else
|
---|
453 | %define RTR0PTR_DEF dd
|
---|
454 | %endif
|
---|
455 |
|
---|
456 | ;; @def RTR0PTR_RES
|
---|
457 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
458 | ; variable of the ring-0 host context.
|
---|
459 | %if R0_ARCH_BITS == 64
|
---|
460 | %define RTR0PTR_RES resq
|
---|
461 | %else
|
---|
462 | %define RTR0PTR_RES resd
|
---|
463 | %endif
|
---|
464 |
|
---|
465 | ;; @def RTR0PTR_PRE
|
---|
466 | ; The memory operand prefix used for a pointer in the ring-0 host context.
|
---|
467 | %if R0_ARCH_BITS == 64
|
---|
468 | %define RTR0PTR_PRE qword
|
---|
469 | %else
|
---|
470 | %define RTR0PTR_PRE dword
|
---|
471 | %endif
|
---|
472 |
|
---|
473 | ;; @def RTR0PTR_CB
|
---|
474 | ; The size in bytes of a pointer in the ring-0 host context.
|
---|
475 | %if R0_ARCH_BITS == 64
|
---|
476 | %define RTR0PTR_CB 8
|
---|
477 | %else
|
---|
478 | %define RTR0PTR_CB 4
|
---|
479 | %endif
|
---|
480 |
|
---|
481 |
|
---|
482 |
|
---|
483 | ;; @def RTR3PTR_DEF
|
---|
484 | ; The pesudo-instruction used to declare an initialized pointer variable in the ring-3 host context.
|
---|
485 | %if R3_ARCH_BITS == 64
|
---|
486 | %define RTR3PTR_DEF dq
|
---|
487 | %else
|
---|
488 | %define RTR3PTR_DEF dd
|
---|
489 | %endif
|
---|
490 |
|
---|
491 | ;; @def RTR3PTR_RES
|
---|
492 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
493 | ; variable of the ring-3 host context.
|
---|
494 | %if R3_ARCH_BITS == 64
|
---|
495 | %define RTR3PTR_RES resq
|
---|
496 | %else
|
---|
497 | %define RTR3PTR_RES resd
|
---|
498 | %endif
|
---|
499 |
|
---|
500 | ;; @def RTR3PTR_PRE
|
---|
501 | ; The memory operand prefix used for a pointer in the ring-3 host context.
|
---|
502 | %if R3_ARCH_BITS == 64
|
---|
503 | %define RTR3PTR_PRE qword
|
---|
504 | %else
|
---|
505 | %define RTR3PTR_PRE dword
|
---|
506 | %endif
|
---|
507 |
|
---|
508 | ;; @def RTR3PTR_CB
|
---|
509 | ; The size in bytes of a pointer in the ring-3 host context.
|
---|
510 | %if R3_ARCH_BITS == 64
|
---|
511 | %define RTR3PTR_CB 8
|
---|
512 | %else
|
---|
513 | %define RTR3PTR_CB 4
|
---|
514 | %endif
|
---|
515 |
|
---|
516 |
|
---|
517 |
|
---|
518 | ;; @def RTGCPTR_DEF
|
---|
519 | ; The pesudo-instruction used to declare an initialized pointer variable in the guest context.
|
---|
520 | %if GC_ARCH_BITS == 64
|
---|
521 | %define RTGCPTR_DEF dq
|
---|
522 | %else
|
---|
523 | %define RTGCPTR_DEF dd
|
---|
524 | %endif
|
---|
525 |
|
---|
526 | ;; @def RTGCPTR_RES
|
---|
527 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
528 | ; variable of the guest context.
|
---|
529 | %if GC_ARCH_BITS == 64
|
---|
530 | %define RTGCPTR_RES resq
|
---|
531 | %else
|
---|
532 | %define RTGCPTR_RES resd
|
---|
533 | %endif
|
---|
534 |
|
---|
535 | %define RTGCPTR32_RES resd
|
---|
536 | %define RTGCPTR64_RES resq
|
---|
537 |
|
---|
538 | ;; @def RTGCPTR_PRE
|
---|
539 | ; The memory operand prefix used for a pointer in the guest context.
|
---|
540 | %if GC_ARCH_BITS == 64
|
---|
541 | %define RTGCPTR_PRE qword
|
---|
542 | %else
|
---|
543 | %define RTGCPTR_PRE dword
|
---|
544 | %endif
|
---|
545 |
|
---|
546 | ;; @def RTGCPTR_CB
|
---|
547 | ; The size in bytes of a pointer in the guest context.
|
---|
548 | %if GC_ARCH_BITS == 64
|
---|
549 | %define RTGCPTR_CB 8
|
---|
550 | %else
|
---|
551 | %define RTGCPTR_CB 4
|
---|
552 | %endif
|
---|
553 |
|
---|
554 |
|
---|
555 | ;; @def RTRCPTR_DEF
|
---|
556 | ; The pesudo-instruction used to declare an initialized pointer variable in the raw mode context.
|
---|
557 | %define RTRCPTR_DEF dd
|
---|
558 |
|
---|
559 | ;; @def RTRCPTR_RES
|
---|
560 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
561 | ; variable of the raw mode context.
|
---|
562 | %define RTRCPTR_RES resd
|
---|
563 |
|
---|
564 | ;; @def RTRCPTR_PRE
|
---|
565 | ; The memory operand prefix used for a pointer in the raw mode context.
|
---|
566 | %define RTRCPTR_PRE dword
|
---|
567 |
|
---|
568 | ;; @def RTRCPTR_CB
|
---|
569 | ; The size in bytes of a pointer in the raw mode context.
|
---|
570 | %define RTRCPTR_CB 4
|
---|
571 |
|
---|
572 |
|
---|
573 | ;; @def RT_CCPTR_DEF
|
---|
574 | ; The pesudo-instruction used to declare an initialized pointer variable in the current context.
|
---|
575 |
|
---|
576 | ;; @def RT_CCPTR_RES
|
---|
577 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
578 | ; variable of the current context.
|
---|
579 |
|
---|
580 | ;; @def RT_CCPTR_PRE
|
---|
581 | ; The memory operand prefix used for a pointer in the current context.
|
---|
582 |
|
---|
583 | ;; @def RT_CCPTR_CB
|
---|
584 | ; The size in bytes of a pointer in the current context.
|
---|
585 |
|
---|
586 | %ifdef IN_RC
|
---|
587 | %define RTCCPTR_DEF RTRCPTR_DEF
|
---|
588 | %define RTCCPTR_RES RTRCPTR_RES
|
---|
589 | %define RTCCPTR_PRE RTRCPTR_PRE
|
---|
590 | %define RTCCPTR_CB RTRCPTR_CB
|
---|
591 | %else
|
---|
592 | %ifdef IN_RING0
|
---|
593 | %define RTCCPTR_DEF RTR0PTR_DEF
|
---|
594 | %define RTCCPTR_RES RTR0PTR_RES
|
---|
595 | %define RTCCPTR_PRE RTR0PTR_PRE
|
---|
596 | %define RTCCPTR_CB RTR0PTR_CB
|
---|
597 | %else
|
---|
598 | %define RTCCPTR_DEF RTR3PTR_DEF
|
---|
599 | %define RTCCPTR_RES RTR3PTR_RES
|
---|
600 | %define RTCCPTR_PRE RTR3PTR_PRE
|
---|
601 | %define RTCCPTR_CB RTR3PTR_CB
|
---|
602 | %endif
|
---|
603 | %endif
|
---|
604 |
|
---|
605 |
|
---|
606 |
|
---|
607 | ;; @def RTHCPHYS_DEF
|
---|
608 | ; The pesudo-instruction used to declare an initialized host physical address.
|
---|
609 | %define RTHCPHYS_DEF dq
|
---|
610 |
|
---|
611 | ;; @def RTHCPTR_RES
|
---|
612 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized
|
---|
613 | ; host physical address variable
|
---|
614 | %define RTHCPHYS_RES resq
|
---|
615 |
|
---|
616 | ;; @def RTHCPTR_PRE
|
---|
617 | ; The memory operand prefix used for a host physical address.
|
---|
618 | %define RTHCPHYS_PRE qword
|
---|
619 |
|
---|
620 | ;; @def RTHCPHYS_CB
|
---|
621 | ; The size in bytes of a host physical address.
|
---|
622 | %define RTHCPHYS_CB 8
|
---|
623 |
|
---|
624 |
|
---|
625 |
|
---|
626 | ;; @def RTGCPHYS_DEF
|
---|
627 | ; The pesudo-instruction used to declare an initialized guest physical address.
|
---|
628 | %define RTGCPHYS_DEF dq
|
---|
629 |
|
---|
630 | ;; @def RTGCPHYS_RES
|
---|
631 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized
|
---|
632 | ; guest physical address variable
|
---|
633 | %define RTGCPHYS_RES resq
|
---|
634 |
|
---|
635 | ;; @def RTGCPTR_PRE
|
---|
636 | ; The memory operand prefix used for a guest physical address.
|
---|
637 | %define RTGCPHYS_PRE qword
|
---|
638 |
|
---|
639 | ;; @def RTGCPHYS_CB
|
---|
640 | ; The size in bytes of a guest physical address.
|
---|
641 | %define RTGCPHYS_CB 8
|
---|
642 |
|
---|
643 |
|
---|
644 |
|
---|
645 | ;;
|
---|
646 | ; The size of the long double C/C++ type.
|
---|
647 | ; On 32-bit Darwin this is 16 bytes, on L4, Linux, OS/2 and Windows
|
---|
648 | ; it's 12 bytes.
|
---|
649 | ; @todo figure out what 64-bit Windows does (I don't recall right now).
|
---|
650 | %ifdef RT_ARCH_X86
|
---|
651 | %ifdef RT_OS_DARWIN
|
---|
652 | %define RTLRD_CB 16
|
---|
653 | %else
|
---|
654 | %define RTLRD_CB 12
|
---|
655 | %endif
|
---|
656 | %else
|
---|
657 | %define RTLRD_CB 16
|
---|
658 | %endif
|
---|
659 |
|
---|
660 |
|
---|
661 |
|
---|
662 | ;; @def ASM_CALL64_GCC
|
---|
663 | ; Indicates that we're using the GCC 64-bit calling convention.
|
---|
664 | ; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
|
---|
665 |
|
---|
666 | ;; @def ASM_CALL64_MSC
|
---|
667 | ; Indicates that we're using the Microsoft 64-bit calling convention (fastcall on steroids).
|
---|
668 | ; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
|
---|
669 |
|
---|
670 | ; Note: On X86 we're using cdecl unconditionally. There is not yet any common
|
---|
671 | ; calling convention on AMD64, that's why we need to support two different ones.)
|
---|
672 |
|
---|
673 | %ifdef RT_ARCH_AMD64
|
---|
674 | %ifndef ASM_CALL64_GCC
|
---|
675 | %ifndef ASM_CALL64_MSC
|
---|
676 | ; define it based on the object format.
|
---|
677 | %ifdef ASM_FORMAT_PE
|
---|
678 | %define ASM_CALL64_MSC
|
---|
679 | %else
|
---|
680 | %define ASM_CALL64_GCC
|
---|
681 | %endif
|
---|
682 | %endif
|
---|
683 | %else
|
---|
684 | ; sanity check.
|
---|
685 | %ifdef ASM_CALL64_MSC
|
---|
686 | %error "Only one of the ASM_CALL64_* defines should be defined!"
|
---|
687 | %endif
|
---|
688 | %endif
|
---|
689 | %endif
|
---|
690 |
|
---|
691 |
|
---|
692 | ;; @def RT_NOCRT
|
---|
693 | ; Symbol name wrapper for the No-CRT bits.
|
---|
694 | ;
|
---|
695 | ; In order to coexist in the same process as other CRTs, we need to
|
---|
696 | ; decorate the symbols such that they don't conflict the ones in the
|
---|
697 | ; other CRTs. The result of such conflicts / duplicate symbols can
|
---|
698 | ; confuse the dynamic loader on unix like systems.
|
---|
699 | ;
|
---|
700 | ; @remark Always feed the name to this macro first and then pass the result
|
---|
701 | ; on to the next *NAME* macro.
|
---|
702 | ;
|
---|
703 | %ifndef RT_WITHOUT_NOCRT_WRAPPERS
|
---|
704 | %define RT_NOCRT(name) nocrt_ %+ name
|
---|
705 | %else
|
---|
706 | %define RT_NOCRT(name) name
|
---|
707 | %endif
|
---|
708 |
|
---|
709 | ;; @def RT_NOCRT_BEGINPROC
|
---|
710 | ; Starts a NOCRT procedure, taking care of name wrapping and aliasing.
|
---|
711 | ;
|
---|
712 | ; Aliasing (weak ones, if supported) will be created when RT_WITH_NOCRT_ALIASES
|
---|
713 | ; is defined and RT_WITHOUT_NOCRT_WRAPPERS isn't.
|
---|
714 | ;
|
---|
715 | %macro RT_NOCRT_BEGINPROC 1
|
---|
716 | %ifdef RT_WITH_NOCRT_ALIASES
|
---|
717 | BEGINPROC RT_NOCRT(%1)
|
---|
718 | %ifdef ASM_FORMAT_ELF
|
---|
719 | global NAME(%1)
|
---|
720 | weak NAME(%1)
|
---|
721 | NAME(%1):
|
---|
722 | %else
|
---|
723 | GLOBALNAME %1
|
---|
724 | %endif
|
---|
725 | %else ; !RT_WITH_NOCRT_ALIASES
|
---|
726 | BEGINPROC RT_NOCRT(%1)
|
---|
727 | %endif ; !RT_WITH_NOCRT_ALIASES
|
---|
728 | %endmacro ; RT_NOCRT_BEGINPROC
|
---|
729 |
|
---|
730 | %ifdef RT_WITH_NOCRT_ALIASES
|
---|
731 | %ifdef RT_WITHOUT_NOCRT_WRAPPERS
|
---|
732 | %error "RT_WITH_NOCRT_ALIASES and RT_WITHOUT_NOCRT_WRAPPERS doesn't mix."
|
---|
733 | %endif
|
---|
734 | %endif
|
---|
735 |
|
---|
736 |
|
---|
737 |
|
---|
738 | ;; @def xCB
|
---|
739 | ; The stack unit size / The register unit size.
|
---|
740 |
|
---|
741 | ;; @def xSP
|
---|
742 | ; The stack pointer register (RSP or ESP).
|
---|
743 |
|
---|
744 | ;; @def xBP
|
---|
745 | ; The base pointer register (RBP or ESP).
|
---|
746 |
|
---|
747 | ;; @def xAX
|
---|
748 | ; RAX or EAX depending on context.
|
---|
749 |
|
---|
750 | ;; @def xBX
|
---|
751 | ; RBX or EBX depending on context.
|
---|
752 |
|
---|
753 | ;; @def xCX
|
---|
754 | ; RCX or ECX depending on context.
|
---|
755 |
|
---|
756 | ;; @def xDX
|
---|
757 | ; RDX or EDX depending on context.
|
---|
758 |
|
---|
759 | ;; @def xDI
|
---|
760 | ; RDI or EDI depending on context.
|
---|
761 |
|
---|
762 | ;; @def xSI
|
---|
763 | ; RSI or ESI depending on context.
|
---|
764 |
|
---|
765 | ;; @def xWrtRIP
|
---|
766 | ; 'wrt rip' for AMD64 targets, nothing for x86 ones.
|
---|
767 |
|
---|
768 | %ifdef RT_ARCH_AMD64
|
---|
769 | %define xCB 8
|
---|
770 | %define xSP rsp
|
---|
771 | %define xBP rbp
|
---|
772 | %define xAX rax
|
---|
773 | %define xBX rbx
|
---|
774 | %define xCX rcx
|
---|
775 | %define xDX rdx
|
---|
776 | %define xDI rdi
|
---|
777 | %define xSI rsi
|
---|
778 | %define xWrtRIP wrt rip
|
---|
779 | %else
|
---|
780 | %define xCB 4
|
---|
781 | %define xSP esp
|
---|
782 | %define xBP ebp
|
---|
783 | %define xAX eax
|
---|
784 | %define xBX ebx
|
---|
785 | %define xCX ecx
|
---|
786 | %define xDX edx
|
---|
787 | %define xDI edi
|
---|
788 | %define xSI esi
|
---|
789 | %define xWrtRIP
|
---|
790 | %endif
|
---|
791 |
|
---|
792 | %endif
|
---|