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 | ; Gets the pointer to an imported object, version 2.
|
---|
134 | %ifdef ASM_FORMAT_PE
|
---|
135 | %ifdef RT_ARCH_AMD64
|
---|
136 | %define IMP2(name) qword [IMPNAME(name) wrt rip]
|
---|
137 | %else
|
---|
138 | %define IMP2(name) dword [IMPNAME(name)]
|
---|
139 | %endif
|
---|
140 | %elifdef ASM_FORMAT_ELF
|
---|
141 | %ifdef PIC
|
---|
142 | %ifdef RT_ARCH_AMD64
|
---|
143 | %define IMP2(name) qword [rel IMPNAME(name) wrt ..got]
|
---|
144 | %else
|
---|
145 | %define IMP2(name) IMPNAME(name) wrt ..plt
|
---|
146 | %endif
|
---|
147 | %endif
|
---|
148 | %elifdef ASM_FORMAT_MACHO
|
---|
149 | %ifdef RT_ARCH_AMD64
|
---|
150 | %define IMP2(name) qword [IMPNAME(name) wrt rip]
|
---|
151 | %else
|
---|
152 | %define IMP2(name) IMPNAME(name)
|
---|
153 | %endif
|
---|
154 | %endif
|
---|
155 | %ifndef IMP2
|
---|
156 | %define IMP2(name) IMPNAME(name)
|
---|
157 | %endif
|
---|
158 |
|
---|
159 |
|
---|
160 |
|
---|
161 | ;;
|
---|
162 | ; Global marker which is DECLASM() compatible.
|
---|
163 | %macro GLOBALNAME 1,
|
---|
164 | %ifndef ASM_FORMAT_BIN
|
---|
165 | global NAME(%1)
|
---|
166 | %endif
|
---|
167 | NAME(%1):
|
---|
168 | %endmacro
|
---|
169 |
|
---|
170 | ;;
|
---|
171 | ; Global exported marker which is DECLASM() compatible.
|
---|
172 | %macro EXPORTEDNAME 1,
|
---|
173 | %ifdef ASM_FORMAT_PE
|
---|
174 | export %1=NAME(%1)
|
---|
175 | %endif
|
---|
176 | %ifdef __NASM__
|
---|
177 | %ifdef ASM_FORMAT_OMF
|
---|
178 | export NAME(%1) NAME(%1)
|
---|
179 | %endif
|
---|
180 | %endif
|
---|
181 | GLOBALNAME %1
|
---|
182 | %endmacro
|
---|
183 |
|
---|
184 | ;;
|
---|
185 | ; Global marker which is DECLASM() compatible.
|
---|
186 | %macro GLOBALNAME_EX 2,
|
---|
187 | %ifndef ASM_FORMAT_BIN
|
---|
188 | %ifdef ASM_FORMAT_ELF
|
---|
189 | global NAME(%1):%2
|
---|
190 | %else
|
---|
191 | global NAME(%1)
|
---|
192 | %endif
|
---|
193 | %endif
|
---|
194 | NAME(%1):
|
---|
195 | %endmacro
|
---|
196 |
|
---|
197 | ;;
|
---|
198 | ; Global exported marker which is DECLASM() compatible.
|
---|
199 | %macro EXPORTEDNAME_EX 2,
|
---|
200 | %ifdef ASM_FORMAT_PE
|
---|
201 | export %1=NAME(%1)
|
---|
202 | %endif
|
---|
203 | %ifdef __NASM__
|
---|
204 | %ifdef ASM_FORMAT_OMF
|
---|
205 | export NAME(%1) NAME(%1)
|
---|
206 | %endif
|
---|
207 | %endif
|
---|
208 | GLOBALNAME_EX %1, %2
|
---|
209 | %endmacro
|
---|
210 |
|
---|
211 | ;;
|
---|
212 | ; Begins a C callable procedure.
|
---|
213 | %macro BEGINPROC 1
|
---|
214 | GLOBALNAME_EX %1, function hidden
|
---|
215 | %endmacro
|
---|
216 |
|
---|
217 | ;;
|
---|
218 | ; Begins a C callable exported procedure.
|
---|
219 | %macro BEGINPROC_EXPORTED 1
|
---|
220 | EXPORTEDNAME_EX %1, function
|
---|
221 | %endmacro
|
---|
222 |
|
---|
223 | ;;
|
---|
224 | ; Ends a C callable procedure.
|
---|
225 | %macro ENDPROC 1
|
---|
226 | GLOBALNAME_EX %1 %+ _EndProc, function hidden
|
---|
227 | %ifdef ASM_FORMAT_ELF
|
---|
228 | size NAME(%1) NAME(%1 %+ _EndProc) - NAME(%1)
|
---|
229 | size NAME(%1 %+ _EndProc) 0
|
---|
230 | %endif
|
---|
231 | db 0xCC, 0xCC, 0xCC, 0xCC
|
---|
232 | %endmacro
|
---|
233 |
|
---|
234 |
|
---|
235 | ;
|
---|
236 | ; Do OMF and Mach-O/Yasm segment definitions
|
---|
237 | ;
|
---|
238 | ; Both format requires this to get the segment order right, in the Mach-O/Yasm case
|
---|
239 | ; it's only to make sure the .bss section ends up last (it's not declared here).
|
---|
240 | ;
|
---|
241 | %ifdef ASM_FORMAT_OMF
|
---|
242 |
|
---|
243 | ; 16-bit segments first (OMF / OS/2 specific).
|
---|
244 | %ifdef RT_INCL_16BIT_SEGMENTS
|
---|
245 | segment DATA16 public CLASS=FAR_DATA align=16 use16
|
---|
246 | segment DATA16_INIT public CLASS=FAR_DATA align=16 use16
|
---|
247 | group DGROUP16 DATA16 DATA16_INIT
|
---|
248 |
|
---|
249 | ;;
|
---|
250 | ; Begins 16-bit data
|
---|
251 | %macro BEGINDATA16 0
|
---|
252 | segment DATA16
|
---|
253 | %endmacro
|
---|
254 |
|
---|
255 | ;;
|
---|
256 | ; Begins 16-bit init data
|
---|
257 | %macro BEGINDATA16INIT 0
|
---|
258 | segment DATA16_INIT
|
---|
259 | %endmacro
|
---|
260 |
|
---|
261 | segment CODE16 public CLASS=FAR_CODE align=16 use16
|
---|
262 | segment CODE16_INIT public CLASS=FAR_CODE align=16 use16
|
---|
263 | group CGROUP16 CODE16 CODE16_INIT
|
---|
264 |
|
---|
265 | ;;
|
---|
266 | ; Begins 16-bit code
|
---|
267 | %macro BEGINCODE16 0
|
---|
268 | segment CODE16
|
---|
269 | %endmacro
|
---|
270 |
|
---|
271 | ;;
|
---|
272 | ; Begins 16-bit init code
|
---|
273 | %macro BEGINCODE16INIT 0
|
---|
274 | segment CODE16_INIT
|
---|
275 | %endmacro
|
---|
276 |
|
---|
277 | %endif
|
---|
278 |
|
---|
279 | ; 32-bit segments.
|
---|
280 | segment TEXT32 public CLASS=CODE align=16 use32 flat
|
---|
281 | segment DATA32 public CLASS=DATA align=16 use32 flat
|
---|
282 | segment BSS32 public CLASS=BSS align=16 use32 flat
|
---|
283 |
|
---|
284 | ; Make the TEXT32 segment default.
|
---|
285 | segment TEXT32
|
---|
286 | %endif
|
---|
287 |
|
---|
288 | %ifdef ASM_FORMAT_MACHO
|
---|
289 | %ifdef __YASM__
|
---|
290 | [section .text]
|
---|
291 | [section .data]
|
---|
292 | %endif
|
---|
293 | %endif
|
---|
294 |
|
---|
295 |
|
---|
296 | ;;
|
---|
297 | ; Begins code
|
---|
298 | %ifdef ASM_FORMAT_OMF
|
---|
299 | %macro BEGINCODE 0
|
---|
300 | segment TEXT32
|
---|
301 | %endmacro
|
---|
302 | %else
|
---|
303 | %macro BEGINCODE 0
|
---|
304 | [section .text]
|
---|
305 | %endmacro
|
---|
306 | %endif
|
---|
307 |
|
---|
308 | ;;
|
---|
309 | ; Begins constant (read-only) data
|
---|
310 | ;
|
---|
311 | ; @remarks This is mapped to the CODE section/segment when there isn't
|
---|
312 | ; any dedicated const section/segment. (There is code that
|
---|
313 | ; assumes this, so don't try change it.)
|
---|
314 | %ifdef ASM_FORMAT_OMF
|
---|
315 | %macro BEGINCONST 0
|
---|
316 | segment TEXT32
|
---|
317 | %endmacro
|
---|
318 | %else
|
---|
319 | %macro BEGINCONST 0
|
---|
320 | %ifdef ASM_FORMAT_MACHO ;; @todo check the other guys too.
|
---|
321 | [section .rodata]
|
---|
322 | %else
|
---|
323 | [section .text]
|
---|
324 | %endif
|
---|
325 | %endmacro
|
---|
326 | %endif
|
---|
327 |
|
---|
328 | ;;
|
---|
329 | ; Begins initialized data
|
---|
330 | %ifdef ASM_FORMAT_OMF
|
---|
331 | %macro BEGINDATA 0
|
---|
332 | segment DATA32
|
---|
333 | %endmacro
|
---|
334 | %else
|
---|
335 | %macro BEGINDATA 0
|
---|
336 | [section .data]
|
---|
337 | %endmacro
|
---|
338 | %endif
|
---|
339 |
|
---|
340 | ;;
|
---|
341 | ; Begins uninitialized data
|
---|
342 | %ifdef ASM_FORMAT_OMF
|
---|
343 | %macro BEGINBSS 0
|
---|
344 | segment BSS32
|
---|
345 | %endmacro
|
---|
346 | %else
|
---|
347 | %macro BEGINBSS 0
|
---|
348 | [section .bss]
|
---|
349 | %endmacro
|
---|
350 | %endif
|
---|
351 |
|
---|
352 |
|
---|
353 |
|
---|
354 | ;; @def ARCH_BITS
|
---|
355 | ; Defines the bit count of the current context.
|
---|
356 | %ifndef ARCH_BITS
|
---|
357 | %ifdef RT_ARCH_AMD64
|
---|
358 | %define ARCH_BITS 64
|
---|
359 | %else
|
---|
360 | %define ARCH_BITS 32
|
---|
361 | %endif
|
---|
362 | %endif
|
---|
363 |
|
---|
364 | ;; @def HC_ARCH_BITS
|
---|
365 | ; Defines the host architechture bit count.
|
---|
366 | %ifndef HC_ARCH_BITS
|
---|
367 | %ifndef IN_RC
|
---|
368 | %define HC_ARCH_BITS ARCH_BITS
|
---|
369 | %else
|
---|
370 | %define HC_ARCH_BITS 32
|
---|
371 | %endif
|
---|
372 | %endif
|
---|
373 |
|
---|
374 | ;; @def R3_ARCH_BITS
|
---|
375 | ; Defines the host ring-3 architechture bit count.
|
---|
376 | %ifndef R3_ARCH_BITS
|
---|
377 | %ifdef IN_RING3
|
---|
378 | %define R3_ARCH_BITS ARCH_BITS
|
---|
379 | %else
|
---|
380 | %define R3_ARCH_BITS HC_ARCH_BITS
|
---|
381 | %endif
|
---|
382 | %endif
|
---|
383 |
|
---|
384 | ;; @def R0_ARCH_BITS
|
---|
385 | ; Defines the host ring-0 architechture bit count.
|
---|
386 | %ifndef R0_ARCH_BITS
|
---|
387 | %ifdef IN_RING0
|
---|
388 | %define R0_ARCH_BITS ARCH_BITS
|
---|
389 | %else
|
---|
390 | %define R0_ARCH_BITS HC_ARCH_BITS
|
---|
391 | %endif
|
---|
392 | %endif
|
---|
393 |
|
---|
394 | ;; @def GC_ARCH_BITS
|
---|
395 | ; Defines the guest architechture bit count.
|
---|
396 | %ifndef GC_ARCH_BITS
|
---|
397 | %ifdef IN_RC
|
---|
398 | %define GC_ARCH_BITS ARCH_BITS
|
---|
399 | %else
|
---|
400 | %define GC_ARCH_BITS 32
|
---|
401 | %endif
|
---|
402 | %endif
|
---|
403 |
|
---|
404 |
|
---|
405 |
|
---|
406 | ;; @def RTHCPTR_DEF
|
---|
407 | ; The pesudo-instruction used to declare an initialized pointer variable in the host context.
|
---|
408 | %if HC_ARCH_BITS == 64
|
---|
409 | %define RTHCPTR_DEF dq
|
---|
410 | %else
|
---|
411 | %define RTHCPTR_DEF dd
|
---|
412 | %endif
|
---|
413 |
|
---|
414 | ;; @def RTHCPTR_RES
|
---|
415 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
416 | ; variable of the host context.
|
---|
417 | %if HC_ARCH_BITS == 64
|
---|
418 | %define RTHCPTR_RES resq
|
---|
419 | %else
|
---|
420 | %define RTHCPTR_RES resd
|
---|
421 | %endif
|
---|
422 |
|
---|
423 | ;; @def RTHCPTR_PRE
|
---|
424 | ; The memory operand prefix used for a pointer in the host context.
|
---|
425 | %if HC_ARCH_BITS == 64
|
---|
426 | %define RTHCPTR_PRE qword
|
---|
427 | %else
|
---|
428 | %define RTHCPTR_PRE dword
|
---|
429 | %endif
|
---|
430 |
|
---|
431 | ;; @def RTHCPTR_CB
|
---|
432 | ; The size in bytes of a pointer in the host context.
|
---|
433 | %if HC_ARCH_BITS == 64
|
---|
434 | %define RTHCPTR_CB 8
|
---|
435 | %else
|
---|
436 | %define RTHCPTR_CB 4
|
---|
437 | %endif
|
---|
438 |
|
---|
439 |
|
---|
440 |
|
---|
441 | ;; @def RTR0PTR_DEF
|
---|
442 | ; The pesudo-instruction used to declare an initialized pointer variable in the ring-0 host context.
|
---|
443 | %if R0_ARCH_BITS == 64
|
---|
444 | %define RTR0PTR_DEF dq
|
---|
445 | %else
|
---|
446 | %define RTR0PTR_DEF dd
|
---|
447 | %endif
|
---|
448 |
|
---|
449 | ;; @def RTR0PTR_RES
|
---|
450 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
451 | ; variable of the ring-0 host context.
|
---|
452 | %if R0_ARCH_BITS == 64
|
---|
453 | %define RTR0PTR_RES resq
|
---|
454 | %else
|
---|
455 | %define RTR0PTR_RES resd
|
---|
456 | %endif
|
---|
457 |
|
---|
458 | ;; @def RTR0PTR_PRE
|
---|
459 | ; The memory operand prefix used for a pointer in the ring-0 host context.
|
---|
460 | %if R0_ARCH_BITS == 64
|
---|
461 | %define RTR0PTR_PRE qword
|
---|
462 | %else
|
---|
463 | %define RTR0PTR_PRE dword
|
---|
464 | %endif
|
---|
465 |
|
---|
466 | ;; @def RTR0PTR_CB
|
---|
467 | ; The size in bytes of a pointer in the ring-0 host context.
|
---|
468 | %if R0_ARCH_BITS == 64
|
---|
469 | %define RTR0PTR_CB 8
|
---|
470 | %else
|
---|
471 | %define RTR0PTR_CB 4
|
---|
472 | %endif
|
---|
473 |
|
---|
474 |
|
---|
475 |
|
---|
476 | ;; @def RTR3PTR_DEF
|
---|
477 | ; The pesudo-instruction used to declare an initialized pointer variable in the ring-3 host context.
|
---|
478 | %if R3_ARCH_BITS == 64
|
---|
479 | %define RTR3PTR_DEF dq
|
---|
480 | %else
|
---|
481 | %define RTR3PTR_DEF dd
|
---|
482 | %endif
|
---|
483 |
|
---|
484 | ;; @def RTR3PTR_RES
|
---|
485 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
486 | ; variable of the ring-3 host context.
|
---|
487 | %if R3_ARCH_BITS == 64
|
---|
488 | %define RTR3PTR_RES resq
|
---|
489 | %else
|
---|
490 | %define RTR3PTR_RES resd
|
---|
491 | %endif
|
---|
492 |
|
---|
493 | ;; @def RTR3PTR_PRE
|
---|
494 | ; The memory operand prefix used for a pointer in the ring-3 host context.
|
---|
495 | %if R3_ARCH_BITS == 64
|
---|
496 | %define RTR3PTR_PRE qword
|
---|
497 | %else
|
---|
498 | %define RTR3PTR_PRE dword
|
---|
499 | %endif
|
---|
500 |
|
---|
501 | ;; @def RTR3PTR_CB
|
---|
502 | ; The size in bytes of a pointer in the ring-3 host context.
|
---|
503 | %if R3_ARCH_BITS == 64
|
---|
504 | %define RTR3PTR_CB 8
|
---|
505 | %else
|
---|
506 | %define RTR3PTR_CB 4
|
---|
507 | %endif
|
---|
508 |
|
---|
509 |
|
---|
510 |
|
---|
511 | ;; @def RTGCPTR_DEF
|
---|
512 | ; The pesudo-instruction used to declare an initialized pointer variable in the guest context.
|
---|
513 | %if GC_ARCH_BITS == 64
|
---|
514 | %define RTGCPTR_DEF dq
|
---|
515 | %else
|
---|
516 | %define RTGCPTR_DEF dd
|
---|
517 | %endif
|
---|
518 |
|
---|
519 | ;; @def RTGCPTR_RES
|
---|
520 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
521 | ; variable of the guest context.
|
---|
522 | %if GC_ARCH_BITS == 64
|
---|
523 | %define RTGCPTR_RES resq
|
---|
524 | %else
|
---|
525 | %define RTGCPTR_RES resd
|
---|
526 | %endif
|
---|
527 |
|
---|
528 | %define RTGCPTR32_RES resd
|
---|
529 | %define RTGCPTR64_RES resq
|
---|
530 |
|
---|
531 | ;; @def RTGCPTR_PRE
|
---|
532 | ; The memory operand prefix used for a pointer in the guest context.
|
---|
533 | %if GC_ARCH_BITS == 64
|
---|
534 | %define RTGCPTR_PRE qword
|
---|
535 | %else
|
---|
536 | %define RTGCPTR_PRE dword
|
---|
537 | %endif
|
---|
538 |
|
---|
539 | ;; @def RTGCPTR_CB
|
---|
540 | ; The size in bytes of a pointer in the guest context.
|
---|
541 | %if GC_ARCH_BITS == 64
|
---|
542 | %define RTGCPTR_CB 8
|
---|
543 | %else
|
---|
544 | %define RTGCPTR_CB 4
|
---|
545 | %endif
|
---|
546 |
|
---|
547 |
|
---|
548 | ;; @def RTRCPTR_DEF
|
---|
549 | ; The pesudo-instruction used to declare an initialized pointer variable in the raw mode context.
|
---|
550 | %define RTRCPTR_DEF dd
|
---|
551 |
|
---|
552 | ;; @def RTRCPTR_RES
|
---|
553 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
554 | ; variable of the raw mode context.
|
---|
555 | %define RTRCPTR_RES resd
|
---|
556 |
|
---|
557 | ;; @def RTRCPTR_PRE
|
---|
558 | ; The memory operand prefix used for a pointer in the raw mode context.
|
---|
559 | %define RTRCPTR_PRE dword
|
---|
560 |
|
---|
561 | ;; @def RTRCPTR_CB
|
---|
562 | ; The size in bytes of a pointer in the raw mode context.
|
---|
563 | %define RTRCPTR_CB 4
|
---|
564 |
|
---|
565 |
|
---|
566 | ;; @def RT_CCPTR_DEF
|
---|
567 | ; The pesudo-instruction used to declare an initialized pointer variable in the current context.
|
---|
568 |
|
---|
569 | ;; @def RT_CCPTR_RES
|
---|
570 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
571 | ; variable of the current context.
|
---|
572 |
|
---|
573 | ;; @def RT_CCPTR_PRE
|
---|
574 | ; The memory operand prefix used for a pointer in the current context.
|
---|
575 |
|
---|
576 | ;; @def RT_CCPTR_CB
|
---|
577 | ; The size in bytes of a pointer in the current context.
|
---|
578 |
|
---|
579 | %ifdef IN_RC
|
---|
580 | %define RTCCPTR_DEF RTRCPTR_DEF
|
---|
581 | %define RTCCPTR_RES RTRCPTR_RES
|
---|
582 | %define RTCCPTR_PRE RTRCPTR_PRE
|
---|
583 | %define RTCCPTR_CB RTRCPTR_CB
|
---|
584 | %else
|
---|
585 | %ifdef IN_RING0
|
---|
586 | %define RTCCPTR_DEF RTR0PTR_DEF
|
---|
587 | %define RTCCPTR_RES RTR0PTR_RES
|
---|
588 | %define RTCCPTR_PRE RTR0PTR_PRE
|
---|
589 | %define RTCCPTR_CB RTR0PTR_CB
|
---|
590 | %else
|
---|
591 | %define RTCCPTR_DEF RTR3PTR_DEF
|
---|
592 | %define RTCCPTR_RES RTR3PTR_RES
|
---|
593 | %define RTCCPTR_PRE RTR3PTR_PRE
|
---|
594 | %define RTCCPTR_CB RTR3PTR_CB
|
---|
595 | %endif
|
---|
596 | %endif
|
---|
597 |
|
---|
598 |
|
---|
599 |
|
---|
600 | ;; @def RTHCPHYS_DEF
|
---|
601 | ; The pesudo-instruction used to declare an initialized host physical address.
|
---|
602 | %define RTHCPHYS_DEF dq
|
---|
603 |
|
---|
604 | ;; @def RTHCPTR_RES
|
---|
605 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized
|
---|
606 | ; host physical address variable
|
---|
607 | %define RTHCPHYS_RES resq
|
---|
608 |
|
---|
609 | ;; @def RTHCPTR_PRE
|
---|
610 | ; The memory operand prefix used for a host physical address.
|
---|
611 | %define RTHCPHYS_PRE qword
|
---|
612 |
|
---|
613 | ;; @def RTHCPHYS_CB
|
---|
614 | ; The size in bytes of a host physical address.
|
---|
615 | %define RTHCPHYS_CB 8
|
---|
616 |
|
---|
617 |
|
---|
618 |
|
---|
619 | ;; @def RTGCPHYS_DEF
|
---|
620 | ; The pesudo-instruction used to declare an initialized guest physical address.
|
---|
621 | %define RTGCPHYS_DEF dq
|
---|
622 |
|
---|
623 | ;; @def RTGCPHYS_RES
|
---|
624 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized
|
---|
625 | ; guest physical address variable
|
---|
626 | %define RTGCPHYS_RES resq
|
---|
627 |
|
---|
628 | ;; @def RTGCPTR_PRE
|
---|
629 | ; The memory operand prefix used for a guest physical address.
|
---|
630 | %define RTGCPHYS_PRE qword
|
---|
631 |
|
---|
632 | ;; @def RTGCPHYS_CB
|
---|
633 | ; The size in bytes of a guest physical address.
|
---|
634 | %define RTGCPHYS_CB 8
|
---|
635 |
|
---|
636 |
|
---|
637 |
|
---|
638 | ;;
|
---|
639 | ; The size of the long double C/C++ type.
|
---|
640 | ; On 32-bit Darwin this is 16 bytes, on L4, Linux, OS/2 and Windows
|
---|
641 | ; it's 12 bytes.
|
---|
642 | ; @todo figure out what 64-bit Windows does (I don't recall right now).
|
---|
643 | %ifdef RT_ARCH_X86
|
---|
644 | %ifdef RT_OS_DARWIN
|
---|
645 | %define RTLRD_CB 16
|
---|
646 | %else
|
---|
647 | %define RTLRD_CB 12
|
---|
648 | %endif
|
---|
649 | %else
|
---|
650 | %define RTLRD_CB 16
|
---|
651 | %endif
|
---|
652 |
|
---|
653 |
|
---|
654 |
|
---|
655 | ;; @def ASM_CALL64_GCC
|
---|
656 | ; Indicates that we're using the GCC 64-bit calling convention.
|
---|
657 | ; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
|
---|
658 |
|
---|
659 | ;; @def ASM_CALL64_MSC
|
---|
660 | ; Indicates that we're using the Microsoft 64-bit calling convention (fastcall on steroids).
|
---|
661 | ; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
|
---|
662 |
|
---|
663 | ; Note: On X86 we're using cdecl unconditionally. There is not yet any common
|
---|
664 | ; calling convention on AMD64, that's why we need to support two different ones.)
|
---|
665 |
|
---|
666 | %ifdef RT_ARCH_AMD64
|
---|
667 | %ifndef ASM_CALL64_GCC
|
---|
668 | %ifndef ASM_CALL64_MSC
|
---|
669 | ; define it based on the object format.
|
---|
670 | %ifdef ASM_FORMAT_PE
|
---|
671 | %define ASM_CALL64_MSC
|
---|
672 | %else
|
---|
673 | %define ASM_CALL64_GCC
|
---|
674 | %endif
|
---|
675 | %endif
|
---|
676 | %else
|
---|
677 | ; sanity check.
|
---|
678 | %ifdef ASM_CALL64_MSC
|
---|
679 | %error "Only one of the ASM_CALL64_* defines should be defined!"
|
---|
680 | %endif
|
---|
681 | %endif
|
---|
682 | %endif
|
---|
683 |
|
---|
684 |
|
---|
685 | ;; @def RT_NOCRT
|
---|
686 | ; Symbol name wrapper for the No-CRT bits.
|
---|
687 | ;
|
---|
688 | ; In order to coexist in the same process as other CRTs, we need to
|
---|
689 | ; decorate the symbols such that they don't conflict the ones in the
|
---|
690 | ; other CRTs. The result of such conflicts / duplicate symbols can
|
---|
691 | ; confuse the dynamic loader on unix like systems.
|
---|
692 | ;
|
---|
693 | ; @remark Always feed the name to this macro first and then pass the result
|
---|
694 | ; on to the next *NAME* macro.
|
---|
695 | ;
|
---|
696 | %ifndef RT_WITHOUT_NOCRT_WRAPPERS
|
---|
697 | %define RT_NOCRT(name) nocrt_ %+ name
|
---|
698 | %else
|
---|
699 | %define RT_NOCRT(name) name
|
---|
700 | %endif
|
---|
701 |
|
---|
702 | ;; @def RT_NOCRT_BEGINPROC
|
---|
703 | ; Starts a NOCRT procedure, taking care of name wrapping and aliasing.
|
---|
704 | ;
|
---|
705 | ; Aliasing (weak ones, if supported) will be created when RT_WITH_NOCRT_ALIASES
|
---|
706 | ; is defined and RT_WITHOUT_NOCRT_WRAPPERS isn't.
|
---|
707 | ;
|
---|
708 | %macro RT_NOCRT_BEGINPROC 1
|
---|
709 | %ifdef RT_WITH_NOCRT_ALIASES
|
---|
710 | BEGINPROC RT_NOCRT(%1)
|
---|
711 | %ifdef ASM_FORMAT_ELF
|
---|
712 | global NAME(%1)
|
---|
713 | weak NAME(%1)
|
---|
714 | NAME(%1):
|
---|
715 | %else
|
---|
716 | GLOBALNAME %1
|
---|
717 | %endif
|
---|
718 | %else ; !RT_WITH_NOCRT_ALIASES
|
---|
719 | BEGINPROC RT_NOCRT(%1)
|
---|
720 | %endif ; !RT_WITH_NOCRT_ALIASES
|
---|
721 | %endmacro ; RT_NOCRT_BEGINPROC
|
---|
722 |
|
---|
723 | %ifdef RT_WITH_NOCRT_ALIASES
|
---|
724 | %ifdef RT_WITHOUT_NOCRT_WRAPPERS
|
---|
725 | %error "RT_WITH_NOCRT_ALIASES and RT_WITHOUT_NOCRT_WRAPPERS doesn't mix."
|
---|
726 | %endif
|
---|
727 | %endif
|
---|
728 |
|
---|
729 |
|
---|
730 |
|
---|
731 | ;; @def xCB
|
---|
732 | ; The stack unit size / The register unit size.
|
---|
733 |
|
---|
734 | ;; @def xSP
|
---|
735 | ; The stack pointer register (RSP or ESP).
|
---|
736 |
|
---|
737 | ;; @def xBP
|
---|
738 | ; The base pointer register (RBP or ESP).
|
---|
739 |
|
---|
740 | ;; @def xAX
|
---|
741 | ; RAX or EAX depending on context.
|
---|
742 |
|
---|
743 | ;; @def xBX
|
---|
744 | ; RBX or EBX depending on context.
|
---|
745 |
|
---|
746 | ;; @def xCX
|
---|
747 | ; RCX or ECX depending on context.
|
---|
748 |
|
---|
749 | ;; @def xDX
|
---|
750 | ; RDX or EDX depending on context.
|
---|
751 |
|
---|
752 | ;; @def xDI
|
---|
753 | ; RDI or EDI depending on context.
|
---|
754 |
|
---|
755 | ;; @def xSI
|
---|
756 | ; RSI or ESI depending on context.
|
---|
757 |
|
---|
758 | ;; @def xWrtRIP
|
---|
759 | ; 'wrt rip' for AMD64 targets, nothing for x86 ones.
|
---|
760 |
|
---|
761 | %ifdef RT_ARCH_AMD64
|
---|
762 | %define xCB 8
|
---|
763 | %define xSP rsp
|
---|
764 | %define xBP rbp
|
---|
765 | %define xAX rax
|
---|
766 | %define xBX rbx
|
---|
767 | %define xCX rcx
|
---|
768 | %define xDX rdx
|
---|
769 | %define xDI rdi
|
---|
770 | %define xSI rsi
|
---|
771 | %define xWrtRIP wrt rip
|
---|
772 | %else
|
---|
773 | %define xCB 4
|
---|
774 | %define xSP esp
|
---|
775 | %define xBP ebp
|
---|
776 | %define xAX eax
|
---|
777 | %define xBX ebx
|
---|
778 | %define xCX ecx
|
---|
779 | %define xDX edx
|
---|
780 | %define xDI edi
|
---|
781 | %define xSI esi
|
---|
782 | %define xWrtRIP
|
---|
783 | %endif
|
---|
784 |
|
---|
785 | %endif
|
---|