1 | ;; @file
|
---|
2 | ; IPRT - Global YASM/NASM macros
|
---|
3 | ;
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; Copyright (C) 2006-2007 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 | ; Make the mask for the given bit.
|
---|
31 | %define RT_BIT(bit) (1 << bit)
|
---|
32 |
|
---|
33 | ;;
|
---|
34 | ; Align code, pad with INT3.
|
---|
35 | %define ALIGNCODE(alignment) align alignment, db 0cch
|
---|
36 |
|
---|
37 | ;;
|
---|
38 | ; Align data, pad with ZEROs.
|
---|
39 | %define ALIGNDATA(alignment) align alignment, db 0
|
---|
40 |
|
---|
41 | ;;
|
---|
42 | ; Align BSS, pad with ZEROs.
|
---|
43 | %define ALIGNBSS(alignment) align alignment, resb 1
|
---|
44 |
|
---|
45 | ;;
|
---|
46 | ; NAME_OVERLOAD can be defined by a .asm module to modify all the
|
---|
47 | ; names created using the name macros in this files.
|
---|
48 | ; This is handy when you've got some kind of template code.
|
---|
49 | %ifndef NAME_OVERLOAD
|
---|
50 | %define NAME_OVERLOAD(name) name
|
---|
51 | %endif
|
---|
52 |
|
---|
53 | ;;
|
---|
54 | ; Mangles the given name so it can be referenced using DECLASM() in the
|
---|
55 | ; C/C++ world.
|
---|
56 | %ifdef RT_ARCH_X86
|
---|
57 | %ifdef RT_OS_OS2
|
---|
58 | %define NAME(name) _ %+ NAME_OVERLOAD(name)
|
---|
59 | %endif
|
---|
60 | %ifdef RT_OS_WINDOWS
|
---|
61 | %define NAME(name) _ %+ NAME_OVERLOAD(name)
|
---|
62 | %endif
|
---|
63 | %endif
|
---|
64 | %ifdef RT_OS_DARWIN
|
---|
65 | %define NAME(name) _ %+ NAME_OVERLOAD(name)
|
---|
66 | %endif
|
---|
67 | %ifndef NAME
|
---|
68 | %define NAME(name) NAME_OVERLOAD(name)
|
---|
69 | %endif
|
---|
70 |
|
---|
71 | ;;
|
---|
72 | ; Mangles the given C name so it will _import_ the right symbol.
|
---|
73 | %ifdef ASM_FORMAT_PE
|
---|
74 | %define IMPNAME(name) __imp_ %+ NAME(name)
|
---|
75 | %else
|
---|
76 | %define IMPNAME(name) NAME(name)
|
---|
77 | %endif
|
---|
78 |
|
---|
79 | ;;
|
---|
80 | ; Gets the pointer to an imported object.
|
---|
81 | %ifdef ASM_FORMAT_PE
|
---|
82 | %ifdef RT_ARCH_AMD64
|
---|
83 | %define IMP(name) qword [IMPNAME(name) wrt rip]
|
---|
84 | %else
|
---|
85 | %define IMP(name) dword [IMPNAME(name)]
|
---|
86 | %endif
|
---|
87 | %else
|
---|
88 | %define IMP(name) IMPNAME(name)
|
---|
89 | %endif
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | ;;
|
---|
94 | ; Global marker which is DECLASM() compatible.
|
---|
95 | %macro GLOBALNAME 1,
|
---|
96 | global NAME(%1)
|
---|
97 | NAME(%1):
|
---|
98 | %endmacro
|
---|
99 |
|
---|
100 | ;;
|
---|
101 | ; Global exported marker which is DECLASM() compatible.
|
---|
102 | %macro EXPORTEDNAME 1,
|
---|
103 | %ifdef ASM_FORMAT_PE
|
---|
104 | export %1=NAME(%1)
|
---|
105 | %endif
|
---|
106 | %ifdef __NASM__
|
---|
107 | %ifdef ASM_FORMAT_OMF
|
---|
108 | export NAME(%1) NAME(%1)
|
---|
109 | %endif
|
---|
110 | %endif
|
---|
111 | GLOBALNAME %1
|
---|
112 | %endmacro
|
---|
113 |
|
---|
114 | ;;
|
---|
115 | ; Begins a C callable procedure.
|
---|
116 | %macro BEGINPROC 1
|
---|
117 | GLOBALNAME %1
|
---|
118 | %endmacro
|
---|
119 |
|
---|
120 | ;;
|
---|
121 | ; Begins a C callable exported procedure.
|
---|
122 | %macro BEGINPROC_EXPORTED 1
|
---|
123 | EXPORTEDNAME %1
|
---|
124 | %endmacro
|
---|
125 |
|
---|
126 | ;;
|
---|
127 | ; Ends a C callable procedure.
|
---|
128 | %macro ENDPROC 1
|
---|
129 | GLOBALNAME %1_EndProc
|
---|
130 | db 0xCC, 0xCC, 0xCC, 0xCC
|
---|
131 | %endmacro
|
---|
132 |
|
---|
133 |
|
---|
134 | ;
|
---|
135 | ; Do OMF and Mach-O/Yasm segment definitions
|
---|
136 | ;
|
---|
137 | ; Both format requires this to get the segment order right, in the Mach-O/Yasm case
|
---|
138 | ; it's only to make sure the .bss section ends up last (it's not declared here).
|
---|
139 | ;
|
---|
140 | %ifdef ASM_FORMAT_OMF
|
---|
141 |
|
---|
142 | ; 16-bit segments first (OMF / OS/2 specific).
|
---|
143 | %ifdef RT_INCL_16BIT_SEGMENTS
|
---|
144 | segment DATA16 public CLASS=FAR_DATA align=16 use16
|
---|
145 | segment DATA16_INIT public CLASS=FAR_DATA align=16 use16
|
---|
146 | group DGROUP16 DATA16 DATA16_INIT
|
---|
147 |
|
---|
148 | ;;
|
---|
149 | ; Begins 16-bit data
|
---|
150 | %macro BEGINDATA16 0
|
---|
151 | segment DATA16
|
---|
152 | %endmacro
|
---|
153 |
|
---|
154 | ;;
|
---|
155 | ; Begins 16-bit init data
|
---|
156 | %macro BEGINDATA16INIT 0
|
---|
157 | segment DATA16_INIT
|
---|
158 | %endmacro
|
---|
159 |
|
---|
160 | segment CODE16 public CLASS=FAR_CODE align=16 use16
|
---|
161 | segment CODE16_INIT public CLASS=FAR_CODE align=16 use16
|
---|
162 | group CGROUP16 CODE16 CODE16_INIT
|
---|
163 |
|
---|
164 | ;;
|
---|
165 | ; Begins 16-bit code
|
---|
166 | %macro BEGINCODE16 0
|
---|
167 | segment CODE16
|
---|
168 | %endmacro
|
---|
169 |
|
---|
170 | ;;
|
---|
171 | ; Begins 16-bit init code
|
---|
172 | %macro BEGINCODE16INIT 0
|
---|
173 | segment CODE16_INIT
|
---|
174 | %endmacro
|
---|
175 |
|
---|
176 | %endif
|
---|
177 |
|
---|
178 | ; 32-bit segments.
|
---|
179 | segment TEXT32 public CLASS=CODE align=16 use32 flat
|
---|
180 | segment DATA32 public CLASS=DATA align=16 use32 flat
|
---|
181 | segment BSS32 public CLASS=BSS align=16 use32 flat
|
---|
182 |
|
---|
183 | ; Make the TEXT32 segment default.
|
---|
184 | segment TEXT32
|
---|
185 | %endif
|
---|
186 |
|
---|
187 | %ifdef ASM_FORMAT_MACHO
|
---|
188 | %ifdef __YASM__
|
---|
189 | [section .text]
|
---|
190 | [section .data]
|
---|
191 | %endif
|
---|
192 | %endif
|
---|
193 |
|
---|
194 |
|
---|
195 | ;;
|
---|
196 | ; Begins code
|
---|
197 | %ifdef ASM_FORMAT_OMF
|
---|
198 | %macro BEGINCODE 0
|
---|
199 | segment TEXT32
|
---|
200 | %endmacro
|
---|
201 | %else
|
---|
202 | %macro BEGINCODE 0
|
---|
203 | [section .text]
|
---|
204 | %endmacro
|
---|
205 | %endif
|
---|
206 |
|
---|
207 | ;;
|
---|
208 | ; Begins constant (read-only) data
|
---|
209 | ;
|
---|
210 | ; @remarks This is mapped to the CODE section/segment when there isn't
|
---|
211 | ; any dedicated const section/segment. (There is code that
|
---|
212 | ; assumes this, so don't try change it.)
|
---|
213 | %ifdef ASM_FORMAT_OMF
|
---|
214 | %macro BEGINCONST 0
|
---|
215 | segment TEXT32
|
---|
216 | %endmacro
|
---|
217 | %else
|
---|
218 | %macro BEGINCONST 0
|
---|
219 | %ifdef ASM_FORMAT_MACHO ;; @todo check the other guys too.
|
---|
220 | [section .rodata]
|
---|
221 | %else
|
---|
222 | [section .text]
|
---|
223 | %endif
|
---|
224 | %endmacro
|
---|
225 | %endif
|
---|
226 |
|
---|
227 | ;;
|
---|
228 | ; Begins initialized data
|
---|
229 | %ifdef ASM_FORMAT_OMF
|
---|
230 | %macro BEGINDATA 0
|
---|
231 | segment DATA32
|
---|
232 | %endmacro
|
---|
233 | %else
|
---|
234 | %macro BEGINDATA 0
|
---|
235 | [section .data]
|
---|
236 | %endmacro
|
---|
237 | %endif
|
---|
238 |
|
---|
239 | ;;
|
---|
240 | ; Begins uninitialized data
|
---|
241 | %ifdef ASM_FORMAT_OMF
|
---|
242 | %macro BEGINBSS 0
|
---|
243 | segment BSS32
|
---|
244 | %endmacro
|
---|
245 | %else
|
---|
246 | %macro BEGINBSS 0
|
---|
247 | [section .bss]
|
---|
248 | %endmacro
|
---|
249 | %endif
|
---|
250 |
|
---|
251 |
|
---|
252 |
|
---|
253 | ;; @def ARCH_BITS
|
---|
254 | ; Defines the bit count of the current context.
|
---|
255 | %ifndef ARCH_BITS
|
---|
256 | %ifdef RT_ARCH_AMD64
|
---|
257 | %define ARCH_BITS 64
|
---|
258 | %else
|
---|
259 | %define ARCH_BITS 32
|
---|
260 | %endif
|
---|
261 | %endif
|
---|
262 |
|
---|
263 | ;; @def HC_ARCH_BITS
|
---|
264 | ; Defines the host architechture bit count.
|
---|
265 | %ifndef HC_ARCH_BITS
|
---|
266 | %ifndef IN_RC
|
---|
267 | %define HC_ARCH_BITS ARCH_BITS
|
---|
268 | %else
|
---|
269 | %define HC_ARCH_BITS 32
|
---|
270 | %endif
|
---|
271 | %endif
|
---|
272 |
|
---|
273 | ;; @def R3_ARCH_BITS
|
---|
274 | ; Defines the host ring-3 architechture bit count.
|
---|
275 | %ifndef R3_ARCH_BITS
|
---|
276 | %ifdef IN_RING3
|
---|
277 | %define R3_ARCH_BITS ARCH_BITS
|
---|
278 | %else
|
---|
279 | %define R3_ARCH_BITS HC_ARCH_BITS
|
---|
280 | %endif
|
---|
281 | %endif
|
---|
282 |
|
---|
283 | ;; @def R0_ARCH_BITS
|
---|
284 | ; Defines the host ring-0 architechture bit count.
|
---|
285 | %ifndef R0_ARCH_BITS
|
---|
286 | %ifdef IN_RING0
|
---|
287 | %define R0_ARCH_BITS ARCH_BITS
|
---|
288 | %else
|
---|
289 | %define R0_ARCH_BITS HC_ARCH_BITS
|
---|
290 | %endif
|
---|
291 | %endif
|
---|
292 |
|
---|
293 | ;; @def GC_ARCH_BITS
|
---|
294 | ; Defines the guest architechture bit count.
|
---|
295 | %ifndef GC_ARCH_BITS
|
---|
296 | %ifdef IN_RC
|
---|
297 | %define GC_ARCH_BITS ARCH_BITS
|
---|
298 | %else
|
---|
299 | %define GC_ARCH_BITS 32
|
---|
300 | %endif
|
---|
301 | %endif
|
---|
302 |
|
---|
303 |
|
---|
304 |
|
---|
305 | ;; @def RTHCPTR_DEF
|
---|
306 | ; The pesudo-instruction used to declare an initialized pointer variable in the host context.
|
---|
307 | %if HC_ARCH_BITS == 64
|
---|
308 | %define RTHCPTR_DEF dq
|
---|
309 | %else
|
---|
310 | %define RTHCPTR_DEF dd
|
---|
311 | %endif
|
---|
312 |
|
---|
313 | ;; @def RTHCPTR_RES
|
---|
314 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
315 | ; variable of the host context.
|
---|
316 | %if HC_ARCH_BITS == 64
|
---|
317 | %define RTHCPTR_RES resq
|
---|
318 | %else
|
---|
319 | %define RTHCPTR_RES resd
|
---|
320 | %endif
|
---|
321 |
|
---|
322 | ;; @def RTHCPTR_PRE
|
---|
323 | ; The memory operand prefix used for a pointer in the host context.
|
---|
324 | %if HC_ARCH_BITS == 64
|
---|
325 | %define RTHCPTR_PRE qword
|
---|
326 | %else
|
---|
327 | %define RTHCPTR_PRE dword
|
---|
328 | %endif
|
---|
329 |
|
---|
330 | ;; @def RTHCPTR_CB
|
---|
331 | ; The size in bytes of a pointer in the host context.
|
---|
332 | %if HC_ARCH_BITS == 64
|
---|
333 | %define RTHCPTR_CB 8
|
---|
334 | %else
|
---|
335 | %define RTHCPTR_CB 4
|
---|
336 | %endif
|
---|
337 |
|
---|
338 |
|
---|
339 |
|
---|
340 | ;; @def RTR0PTR_DEF
|
---|
341 | ; The pesudo-instruction used to declare an initialized pointer variable in the ring-0 host context.
|
---|
342 | %if R0_ARCH_BITS == 64
|
---|
343 | %define RTR0PTR_DEF dq
|
---|
344 | %else
|
---|
345 | %define RTR0PTR_DEF dd
|
---|
346 | %endif
|
---|
347 |
|
---|
348 | ;; @def RTR0PTR_RES
|
---|
349 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
350 | ; variable of the ring-0 host context.
|
---|
351 | %if R0_ARCH_BITS == 64
|
---|
352 | %define RTR0PTR_RES resq
|
---|
353 | %else
|
---|
354 | %define RTR0PTR_RES resd
|
---|
355 | %endif
|
---|
356 |
|
---|
357 | ;; @def RTR0PTR_PRE
|
---|
358 | ; The memory operand prefix used for a pointer in the ring-0 host context.
|
---|
359 | %if R0_ARCH_BITS == 64
|
---|
360 | %define RTR0PTR_PRE qword
|
---|
361 | %else
|
---|
362 | %define RTR0PTR_PRE dword
|
---|
363 | %endif
|
---|
364 |
|
---|
365 | ;; @def RTR0PTR_CB
|
---|
366 | ; The size in bytes of a pointer in the ring-0 host context.
|
---|
367 | %if R0_ARCH_BITS == 64
|
---|
368 | %define RTR0PTR_CB 8
|
---|
369 | %else
|
---|
370 | %define RTR0PTR_CB 4
|
---|
371 | %endif
|
---|
372 |
|
---|
373 |
|
---|
374 |
|
---|
375 | ;; @def RTR3PTR_DEF
|
---|
376 | ; The pesudo-instruction used to declare an initialized pointer variable in the ring-3 host context.
|
---|
377 | %if R3_ARCH_BITS == 64
|
---|
378 | %define RTR3PTR_DEF dq
|
---|
379 | %else
|
---|
380 | %define RTR3PTR_DEF dd
|
---|
381 | %endif
|
---|
382 |
|
---|
383 | ;; @def RTR3PTR_RES
|
---|
384 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
385 | ; variable of the ring-3 host context.
|
---|
386 | %if R3_ARCH_BITS == 64
|
---|
387 | %define RTR3PTR_RES resq
|
---|
388 | %else
|
---|
389 | %define RTR3PTR_RES resd
|
---|
390 | %endif
|
---|
391 |
|
---|
392 | ;; @def RTR3PTR_PRE
|
---|
393 | ; The memory operand prefix used for a pointer in the ring-3 host context.
|
---|
394 | %if R3_ARCH_BITS == 64
|
---|
395 | %define RTR3PTR_PRE qword
|
---|
396 | %else
|
---|
397 | %define RTR3PTR_PRE dword
|
---|
398 | %endif
|
---|
399 |
|
---|
400 | ;; @def RTR3PTR_CB
|
---|
401 | ; The size in bytes of a pointer in the ring-3 host context.
|
---|
402 | %if R3_ARCH_BITS == 64
|
---|
403 | %define RTR3PTR_CB 8
|
---|
404 | %else
|
---|
405 | %define RTR3PTR_CB 4
|
---|
406 | %endif
|
---|
407 |
|
---|
408 |
|
---|
409 |
|
---|
410 | ;; @def RTGCPTR_DEF
|
---|
411 | ; The pesudo-instruction used to declare an initialized pointer variable in the guest context.
|
---|
412 | %if GC_ARCH_BITS == 64
|
---|
413 | %define RTGCPTR_DEF dq
|
---|
414 | %else
|
---|
415 | %define RTGCPTR_DEF dd
|
---|
416 | %endif
|
---|
417 |
|
---|
418 | ;; @def RTGCPTR_RES
|
---|
419 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
420 | ; variable of the guest context.
|
---|
421 | %if GC_ARCH_BITS == 64
|
---|
422 | %define RTGCPTR_RES resq
|
---|
423 | %else
|
---|
424 | %define RTGCPTR_RES resd
|
---|
425 | %endif
|
---|
426 |
|
---|
427 | %define RTGCPTR32_RES resd
|
---|
428 | %define RTGCPTR64_RES resq
|
---|
429 |
|
---|
430 | ;; @def RTGCPTR_PRE
|
---|
431 | ; The memory operand prefix used for a pointer in the guest context.
|
---|
432 | %if GC_ARCH_BITS == 64
|
---|
433 | %define RTGCPTR_PRE qword
|
---|
434 | %else
|
---|
435 | %define RTGCPTR_PRE dword
|
---|
436 | %endif
|
---|
437 |
|
---|
438 | ;; @def RTGCPTR_CB
|
---|
439 | ; The size in bytes of a pointer in the guest context.
|
---|
440 | %if GC_ARCH_BITS == 64
|
---|
441 | %define RTGCPTR_CB 8
|
---|
442 | %else
|
---|
443 | %define RTGCPTR_CB 4
|
---|
444 | %endif
|
---|
445 |
|
---|
446 |
|
---|
447 | ;; @def RTRCPTR_DEF
|
---|
448 | ; The pesudo-instruction used to declare an initialized pointer variable in the raw mode context.
|
---|
449 | %define RTRCPTR_DEF dd
|
---|
450 |
|
---|
451 | ;; @def RTRCPTR_RES
|
---|
452 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
453 | ; variable of the raw mode context.
|
---|
454 | %define RTRCPTR_RES resd
|
---|
455 |
|
---|
456 | ;; @def RTRCPTR_PRE
|
---|
457 | ; The memory operand prefix used for a pointer in the raw mode context.
|
---|
458 | %define RTRCPTR_PRE dword
|
---|
459 |
|
---|
460 | ;; @def RTRCPTR_CB
|
---|
461 | ; The size in bytes of a pointer in the raw mode context.
|
---|
462 | %define RTRCPTR_CB 4
|
---|
463 |
|
---|
464 |
|
---|
465 | ;; @def RT_CCPTR_DEF
|
---|
466 | ; The pesudo-instruction used to declare an initialized pointer variable in the current context.
|
---|
467 |
|
---|
468 | ;; @def RT_CCPTR_RES
|
---|
469 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized pointer
|
---|
470 | ; variable of the current context.
|
---|
471 |
|
---|
472 | ;; @def RT_CCPTR_PRE
|
---|
473 | ; The memory operand prefix used for a pointer in the current context.
|
---|
474 |
|
---|
475 | ;; @def RT_CCPTR_CB
|
---|
476 | ; The size in bytes of a pointer in the current context.
|
---|
477 |
|
---|
478 | %ifdef IN_RC
|
---|
479 | %define RTCCPTR_DEF RTRCPTR_DEF
|
---|
480 | %define RTCCPTR_RES RTRCPTR_RES
|
---|
481 | %define RTCCPTR_PRE RTRCPTR_PRE
|
---|
482 | %define RTCCPTR_CB RTRCPTR_CB
|
---|
483 | %else
|
---|
484 | %ifdef IN_RING0
|
---|
485 | %define RTCCPTR_DEF RTR0PTR_DEF
|
---|
486 | %define RTCCPTR_RES RTR0PTR_RES
|
---|
487 | %define RTCCPTR_PRE RTR0PTR_PRE
|
---|
488 | %define RTCCPTR_CB RTR0PTR_CB
|
---|
489 | %else
|
---|
490 | %define RTCCPTR_DEF RTR3PTR_DEF
|
---|
491 | %define RTCCPTR_RES RTR3PTR_RES
|
---|
492 | %define RTCCPTR_PRE RTR3PTR_PRE
|
---|
493 | %define RTCCPTR_CB RTR3PTR_CB
|
---|
494 | %endif
|
---|
495 | %endif
|
---|
496 |
|
---|
497 |
|
---|
498 |
|
---|
499 | ;; @def RTHCPHYS_DEF
|
---|
500 | ; The pesudo-instruction used to declare an initialized host physical address.
|
---|
501 | %define RTHCPHYS_DEF dq
|
---|
502 |
|
---|
503 | ;; @def RTHCPTR_RES
|
---|
504 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized
|
---|
505 | ; host physical address variable
|
---|
506 | %define RTHCPHYS_RES resq
|
---|
507 |
|
---|
508 | ;; @def RTHCPTR_PRE
|
---|
509 | ; The memory operand prefix used for a host physical address.
|
---|
510 | %define RTHCPHYS_PRE qword
|
---|
511 |
|
---|
512 | ;; @def RTHCPHYS_CB
|
---|
513 | ; The size in bytes of a host physical address.
|
---|
514 | %define RTHCPHYS_CB 8
|
---|
515 |
|
---|
516 |
|
---|
517 |
|
---|
518 | ;; @def RTGCPHYS_DEF
|
---|
519 | ; The pesudo-instruction used to declare an initialized guest physical address.
|
---|
520 | %define RTGCPHYS_DEF dq
|
---|
521 |
|
---|
522 | ;; @def RTGCPHYS_RES
|
---|
523 | ; The pesudo-instruction used to declare (=reserve space for) an uninitialized
|
---|
524 | ; guest physical address variable
|
---|
525 | %define RTGCPHYS_RES resq
|
---|
526 |
|
---|
527 | ;; @def RTGCPTR_PRE
|
---|
528 | ; The memory operand prefix used for a guest physical address.
|
---|
529 | %define RTGCPHYS_PRE qword
|
---|
530 |
|
---|
531 | ;; @def RTGCPHYS_CB
|
---|
532 | ; The size in bytes of a guest physical address.
|
---|
533 | %define RTGCPHYS_CB 8
|
---|
534 |
|
---|
535 |
|
---|
536 |
|
---|
537 | ;;
|
---|
538 | ; The size of the long double C/C++ type.
|
---|
539 | ; On 32-bit Darwin this is 16 bytes, on L4, Linux, OS/2 and Windows
|
---|
540 | ; it's 12 bytes.
|
---|
541 | ; @todo figure out what 64-bit Windows does (I don't recall right now).
|
---|
542 | %ifdef RT_ARCH_X86
|
---|
543 | %ifdef RT_OS_DARWIN
|
---|
544 | %define RTLRD_CB 16
|
---|
545 | %else
|
---|
546 | %define RTLRD_CB 12
|
---|
547 | %endif
|
---|
548 | %else
|
---|
549 | %define RTLRD_CB 16
|
---|
550 | %endif
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 | ;; @def ASM_CALL64_GCC
|
---|
555 | ; Indicates that we're using the GCC 64-bit calling convention.
|
---|
556 | ; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
|
---|
557 |
|
---|
558 | ;; @def ASM_CALL64_MSC
|
---|
559 | ; Indicates that we're using the Microsoft 64-bit calling convention (fastcall on steroids).
|
---|
560 | ; @see @ref sec_vboxrem_amd64_compare (in VBoxREMWrapper.cpp) for an ABI description.
|
---|
561 |
|
---|
562 | ; Note: On X86 we're using cdecl unconditionally. There is not yet any common
|
---|
563 | ; calling convention on AMD64, that's why we need to support two different ones.)
|
---|
564 |
|
---|
565 | %ifdef RT_ARCH_AMD64
|
---|
566 | %ifndef ASM_CALL64_GCC
|
---|
567 | %ifndef ASM_CALL64_MSC
|
---|
568 | ; define it based on the object format.
|
---|
569 | %ifdef ASM_FORMAT_PE
|
---|
570 | %define ASM_CALL64_MSC
|
---|
571 | %else
|
---|
572 | %define ASM_CALL64_GCC
|
---|
573 | %endif
|
---|
574 | %endif
|
---|
575 | %else
|
---|
576 | ; sanity check.
|
---|
577 | %ifdef ASM_CALL64_MSC
|
---|
578 | %error "Only one of the ASM_CALL64_* defines should be defined!"
|
---|
579 | %endif
|
---|
580 | %endif
|
---|
581 | %endif
|
---|
582 |
|
---|
583 |
|
---|
584 | ;; @def RT_NOCRT
|
---|
585 | ; Symbol name wrapper for the No-CRT bits.
|
---|
586 | ;
|
---|
587 | ; In order to coexist in the same process as other CRTs, we need to
|
---|
588 | ; decorate the symbols such that they don't conflict the ones in the
|
---|
589 | ; other CRTs. The result of such conflicts / duplicate symbols can
|
---|
590 | ; confuse the dynamic loader on unix like systems.
|
---|
591 | ;
|
---|
592 | ; @remark Always feed the name to this macro first and then pass the result
|
---|
593 | ; on to the next *NAME* macro.
|
---|
594 | ;
|
---|
595 | %ifndef RT_WITHOUT_NOCRT_WRAPPERS
|
---|
596 | %define RT_NOCRT(name) nocrt_ %+ name
|
---|
597 | %else
|
---|
598 | %define RT_NOCRT(name) name
|
---|
599 | %endif
|
---|
600 |
|
---|
601 | ;; @def RT_NOCRT_BEGINPROC
|
---|
602 | ; Starts a NOCRT procedure, taking care of name wrapping and aliasing.
|
---|
603 | ;
|
---|
604 | ; Aliasing (weak ones, if supported) will be created when RT_WITH_NOCRT_ALIASES
|
---|
605 | ; is defined and RT_WITHOUT_NOCRT_WRAPPERS isn't.
|
---|
606 | ;
|
---|
607 | %macro RT_NOCRT_BEGINPROC 1
|
---|
608 | %ifdef RT_WITH_NOCRT_ALIASES
|
---|
609 | BEGINPROC RT_NOCRT(%1)
|
---|
610 | %ifdef ASM_FORMAT_ELF
|
---|
611 | global NAME(%1)
|
---|
612 | weak NAME(%1)
|
---|
613 | NAME(%1):
|
---|
614 | %else
|
---|
615 | GLOBALNAME %1
|
---|
616 | %endif
|
---|
617 | %else ; !RT_WITH_NOCRT_ALIASES
|
---|
618 | BEGINPROC RT_NOCRT(%1)
|
---|
619 | %endif ; !RT_WITH_NOCRT_ALIASES
|
---|
620 | %endmacro ; RT_NOCRT_BEGINPROC
|
---|
621 |
|
---|
622 | %ifdef RT_WITH_NOCRT_ALIASES
|
---|
623 | %ifdef RT_WITHOUT_NOCRT_WRAPPERS
|
---|
624 | %error "RT_WITH_NOCRT_ALIASES and RT_WITHOUT_NOCRT_WRAPPERS doesn't mix."
|
---|
625 | %endif
|
---|
626 | %endif
|
---|
627 |
|
---|
628 |
|
---|
629 |
|
---|
630 | ;; @def xS
|
---|
631 | ; The stack unit size / The register unit size.
|
---|
632 |
|
---|
633 | ;; @def xSP
|
---|
634 | ; The stack pointer register (RSP or ESP).
|
---|
635 |
|
---|
636 | ;; @def xBP
|
---|
637 | ; The base pointer register (RBP or ESP).
|
---|
638 |
|
---|
639 | ;; @def xAX
|
---|
640 | ; RAX or EAX depending on context.
|
---|
641 |
|
---|
642 | ;; @def xBX
|
---|
643 | ; RBX or EBX depending on context.
|
---|
644 |
|
---|
645 | ;; @def xCX
|
---|
646 | ; RCX or ECX depending on context.
|
---|
647 |
|
---|
648 | ;; @def xDX
|
---|
649 | ; RDX or EDX depending on context.
|
---|
650 |
|
---|
651 | ;; @def xDI
|
---|
652 | ; RDI or EDI depending on context.
|
---|
653 |
|
---|
654 | ;; @def xSI
|
---|
655 | ; RSI or ESI depending on context.
|
---|
656 |
|
---|
657 | ;; @def xWrtRIP
|
---|
658 | ; 'wrt rip' for AMD64 targets, nothing for x86 ones.
|
---|
659 |
|
---|
660 | %ifdef RT_ARCH_AMD64
|
---|
661 | %define xS 8
|
---|
662 | %define xSP rsp
|
---|
663 | %define xBP rbp
|
---|
664 | %define xAX rax
|
---|
665 | %define xBX rbx
|
---|
666 | %define xCX rcx
|
---|
667 | %define xDX rdx
|
---|
668 | %define xDI rdi
|
---|
669 | %define xSI rsi
|
---|
670 | %define xWrtRIP wrt rip
|
---|
671 | %else
|
---|
672 | %define xS 4
|
---|
673 | %define xSP esp
|
---|
674 | %define xBP ebp
|
---|
675 | %define xAX eax
|
---|
676 | %define xBX ebx
|
---|
677 | %define xCX ecx
|
---|
678 | %define xDX edx
|
---|
679 | %define xDI edi
|
---|
680 | %define xSI esi
|
---|
681 | %define xWrtRIP
|
---|
682 | %endif
|
---|
683 |
|
---|
684 | %endif
|
---|