1 | ; $Id: VBoxREMWrapperA.asm 17042 2009-02-23 23:10:37Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VBoxREM Wrapper, Assembly routines and wrapper Templates.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | ; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | ; Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | ; additional information or have any questions.
|
---|
20 | ;
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 | ;*******************************************************************************
|
---|
26 | ;* Header Files *
|
---|
27 | ;*******************************************************************************
|
---|
28 | %include "iprt/asmdefs.mac"
|
---|
29 |
|
---|
30 | %define REM_FIXUP_32_REAL_STUFF 0deadbeefh
|
---|
31 | %define REM_FIXUP_64_REAL_STUFF 0deadf00df00ddeadh
|
---|
32 | %define REM_FIXUP_64_DESC 0dead00010001deadh
|
---|
33 | %define REM_FIXUP_64_LOG_ENTRY 0dead00020002deadh
|
---|
34 | %define REM_FIXUP_64_LOG_EXIT 0dead00030003deadh
|
---|
35 | %define REM_FIXUP_64_WRAP_GCC_CB 0dead00040004deadh
|
---|
36 |
|
---|
37 | ;%define ENTRY_LOGGING 1
|
---|
38 | ;%define EXIT_LOGGING 1
|
---|
39 |
|
---|
40 |
|
---|
41 | %ifdef RT_ARCH_AMD64
|
---|
42 | ;;
|
---|
43 | ; 64-bit pushad
|
---|
44 | %macro MY_PUSHAQ 0
|
---|
45 | push rax
|
---|
46 | push rbx
|
---|
47 | push rcx
|
---|
48 | push rdx
|
---|
49 | push rsi
|
---|
50 | push rdi
|
---|
51 | push rbp
|
---|
52 | push r8
|
---|
53 | push r9
|
---|
54 | push r10
|
---|
55 | push r11
|
---|
56 | push r12
|
---|
57 | push r13
|
---|
58 | push r14
|
---|
59 | push r15
|
---|
60 | %endmacro
|
---|
61 |
|
---|
62 | ;;
|
---|
63 | ; 64-bit popad
|
---|
64 | %macro MY_POPAQ 0
|
---|
65 | pop r15
|
---|
66 | pop r14
|
---|
67 | pop r13
|
---|
68 | pop r12
|
---|
69 | pop r11
|
---|
70 | pop r10
|
---|
71 | pop r9
|
---|
72 | pop r8
|
---|
73 | pop rbp
|
---|
74 | pop rdi
|
---|
75 | pop rsi
|
---|
76 | pop rdx
|
---|
77 | pop rcx
|
---|
78 | pop rbx
|
---|
79 | pop rax
|
---|
80 | %endmacro
|
---|
81 |
|
---|
82 | ;;
|
---|
83 | ; Entry logging
|
---|
84 | %ifdef ENTRY_LOGGING
|
---|
85 | %macro LOG_ENTRY 0
|
---|
86 | MY_PUSHAQ
|
---|
87 | push rbp
|
---|
88 | mov rbp, rsp
|
---|
89 | and rsp, ~0fh
|
---|
90 | sub rsp, 20h ; shadow space
|
---|
91 |
|
---|
92 | %ifdef RT_OS_WINDOWS
|
---|
93 | mov rcx, REM_FIXUP_64_DESC
|
---|
94 | %else
|
---|
95 | mov rdi, REM_FIXUP_64_DESC
|
---|
96 | %endif
|
---|
97 | mov rax, REM_FIXUP_64_LOG_ENTRY
|
---|
98 | call rax
|
---|
99 |
|
---|
100 | leave
|
---|
101 | MY_POPAQ
|
---|
102 | %endmacro
|
---|
103 | %else
|
---|
104 | %define LOG_ENTRY
|
---|
105 | %endif
|
---|
106 |
|
---|
107 | ;;
|
---|
108 | ; Exit logging
|
---|
109 | %ifdef EXIT_LOGGING
|
---|
110 | %macro LOG_EXIT 0
|
---|
111 | MY_PUSHAQ
|
---|
112 | push rbp
|
---|
113 | mov rbp, rsp
|
---|
114 | and rsp, ~0fh
|
---|
115 | sub rsp, 20h ; shadow space
|
---|
116 |
|
---|
117 | %ifdef RT_OS_WINDOWS
|
---|
118 | mov rdx, rax
|
---|
119 | mov rcx, REM_FIXUP_64_DESC
|
---|
120 | %else
|
---|
121 | mov rsi, eax
|
---|
122 | mov rdi, REM_FIXUP_64_DESC
|
---|
123 | %endif
|
---|
124 | mov rax, REM_FIXUP_64_LOG_EXIT
|
---|
125 | call rax
|
---|
126 |
|
---|
127 | leave
|
---|
128 | MY_POPAQ
|
---|
129 | %endmacro
|
---|
130 | %else
|
---|
131 | %define LOG_EXIT
|
---|
132 | %endif
|
---|
133 |
|
---|
134 | %else
|
---|
135 | %define LOG_ENTRY
|
---|
136 | %define LOG_EXIT
|
---|
137 | %endif
|
---|
138 |
|
---|
139 |
|
---|
140 | BEGINCODE
|
---|
141 |
|
---|
142 | %ifdef RT_OS_WINDOWS
|
---|
143 | %ifdef RT_ARCH_AMD64
|
---|
144 |
|
---|
145 |
|
---|
146 | BEGINPROC WrapGCC2MSC0Int
|
---|
147 | LOG_ENTRY
|
---|
148 | push rbp
|
---|
149 | mov rbp, rsp
|
---|
150 | sub rsp, 20h
|
---|
151 |
|
---|
152 | %ifdef USE_DIRECT_CALLS
|
---|
153 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
154 | %else
|
---|
155 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
156 | call rax
|
---|
157 | %endif
|
---|
158 |
|
---|
159 | leave
|
---|
160 | LOG_EXIT
|
---|
161 | ret
|
---|
162 | ENDPROC WrapGCC2MSC0Int
|
---|
163 |
|
---|
164 |
|
---|
165 | BEGINPROC WrapGCC2MSC1Int
|
---|
166 | LOG_ENTRY
|
---|
167 | push rbp
|
---|
168 | mov rbp, rsp
|
---|
169 | sub rsp, 20h
|
---|
170 |
|
---|
171 | mov rcx, rdi
|
---|
172 | %ifdef USE_DIRECT_CALLS
|
---|
173 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
174 | %else
|
---|
175 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
176 | call rax
|
---|
177 | %endif
|
---|
178 |
|
---|
179 | leave
|
---|
180 | LOG_EXIT
|
---|
181 | ret
|
---|
182 | ENDPROC WrapGCC2MSC1Int
|
---|
183 |
|
---|
184 |
|
---|
185 | BEGINPROC WrapGCC2MSC2Int
|
---|
186 | LOG_ENTRY
|
---|
187 | push rbp
|
---|
188 | mov rbp, rsp
|
---|
189 | sub rsp, 20h
|
---|
190 |
|
---|
191 | mov rdx, rsi
|
---|
192 | mov rcx, rdi
|
---|
193 | %ifdef USE_DIRECT_CALLS
|
---|
194 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
195 | %else
|
---|
196 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
197 | call rax
|
---|
198 | %endif
|
---|
199 |
|
---|
200 | leave
|
---|
201 | LOG_EXIT
|
---|
202 | ret
|
---|
203 | ENDPROC WrapGCC2MSC2Int
|
---|
204 |
|
---|
205 |
|
---|
206 | BEGINPROC WrapGCC2MSC3Int
|
---|
207 | LOG_ENTRY
|
---|
208 | push rbp
|
---|
209 | mov rbp, rsp
|
---|
210 | sub rsp, 20h
|
---|
211 |
|
---|
212 | mov r8, rdx
|
---|
213 | mov rdx, rsi
|
---|
214 | mov rcx, rdi
|
---|
215 | %ifdef USE_DIRECT_CALLS
|
---|
216 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
217 | %else
|
---|
218 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
219 | call rax
|
---|
220 | %endif
|
---|
221 |
|
---|
222 | leave
|
---|
223 | LOG_EXIT
|
---|
224 | ret
|
---|
225 | ENDPROC WrapGCC2MSC3Int
|
---|
226 |
|
---|
227 |
|
---|
228 | BEGINPROC WrapGCC2MSC4Int
|
---|
229 | LOG_ENTRY
|
---|
230 | push rbp
|
---|
231 | mov rbp, rsp
|
---|
232 | sub rsp, 20h
|
---|
233 |
|
---|
234 | mov r9, rcx
|
---|
235 | mov r8, rdx
|
---|
236 | mov rdx, rsi
|
---|
237 | mov rcx, rdi
|
---|
238 | %ifdef USE_DIRECT_CALLS
|
---|
239 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
240 | %else
|
---|
241 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
242 | call rax
|
---|
243 | %endif
|
---|
244 |
|
---|
245 | leave
|
---|
246 | LOG_EXIT
|
---|
247 | ret
|
---|
248 | ENDPROC WrapGCC2MSC4Int
|
---|
249 |
|
---|
250 |
|
---|
251 | BEGINPROC WrapGCC2MSC5Int
|
---|
252 | LOG_ENTRY
|
---|
253 | push rbp
|
---|
254 | mov rbp, rsp
|
---|
255 | sub rsp, 30h
|
---|
256 |
|
---|
257 | mov [rsp + 20h], r8
|
---|
258 | mov r9, rcx
|
---|
259 | mov r8, rdx
|
---|
260 | mov rdx, rsi
|
---|
261 | mov rcx, rdi
|
---|
262 | %ifdef USE_DIRECT_CALLS
|
---|
263 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
264 | %else
|
---|
265 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
266 | call rax
|
---|
267 | %endif
|
---|
268 |
|
---|
269 | leave
|
---|
270 | LOG_EXIT
|
---|
271 | ret
|
---|
272 | ENDPROC WrapGCC2MSC5Int
|
---|
273 |
|
---|
274 |
|
---|
275 | BEGINPROC WrapGCC2MSC6Int
|
---|
276 | LOG_ENTRY
|
---|
277 | push rbp
|
---|
278 | mov rbp, rsp
|
---|
279 | sub rsp, 30h
|
---|
280 |
|
---|
281 | mov [rsp + 28h], r9
|
---|
282 | mov [rsp + 20h], r8
|
---|
283 | mov r9, rcx
|
---|
284 | mov r8, rdx
|
---|
285 | mov rdx, rsi
|
---|
286 | mov rcx, rdi
|
---|
287 | %ifdef USE_DIRECT_CALLS
|
---|
288 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
289 | %else
|
---|
290 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
291 | call rax
|
---|
292 | %endif
|
---|
293 |
|
---|
294 | leave
|
---|
295 | LOG_EXIT
|
---|
296 | ret
|
---|
297 | ENDPROC WrapGCC2MSC6Int
|
---|
298 |
|
---|
299 |
|
---|
300 | BEGINPROC WrapGCC2MSC7Int
|
---|
301 | LOG_ENTRY
|
---|
302 | push rbp
|
---|
303 | mov rbp, rsp
|
---|
304 | sub rsp, 40h
|
---|
305 |
|
---|
306 | mov r11, [ebp + 10h]
|
---|
307 | mov [rsp + 30h], r11
|
---|
308 | mov [rsp + 28h], r9
|
---|
309 | mov [rsp + 20h], r8
|
---|
310 | mov r9, rcx
|
---|
311 | mov r8, rdx
|
---|
312 | mov rdx, rsi
|
---|
313 | mov rcx, rdi
|
---|
314 | %ifdef USE_DIRECT_CALLS
|
---|
315 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
316 | %else
|
---|
317 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
318 | call rax
|
---|
319 | %endif
|
---|
320 |
|
---|
321 | leave
|
---|
322 | LOG_EXIT
|
---|
323 | ret
|
---|
324 | ENDPROC WrapGCC2MSC7Int
|
---|
325 |
|
---|
326 |
|
---|
327 | BEGINPROC WrapGCC2MSC8Int
|
---|
328 | LOG_ENTRY
|
---|
329 | push rbp
|
---|
330 | mov rbp, rsp
|
---|
331 | sub rsp, 40h
|
---|
332 |
|
---|
333 | mov r10, [ebp + 18h]
|
---|
334 | mov [rsp + 38h], r10
|
---|
335 | mov r11, [ebp + 10h]
|
---|
336 | mov [rsp + 30h], r11
|
---|
337 | mov [rsp + 28h], r9
|
---|
338 | mov [rsp + 20h], r8
|
---|
339 | mov r9, rcx
|
---|
340 | mov r8, rdx
|
---|
341 | mov rdx, rsi
|
---|
342 | mov rcx, rdi
|
---|
343 | %ifdef USE_DIRECT_CALLS
|
---|
344 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
345 | %else
|
---|
346 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
347 | call rax
|
---|
348 | %endif
|
---|
349 |
|
---|
350 | leave
|
---|
351 | LOG_EXIT
|
---|
352 | ret
|
---|
353 | ENDPROC WrapGCC2MSC8Int
|
---|
354 |
|
---|
355 |
|
---|
356 | BEGINPROC WrapGCC2MSC9Int
|
---|
357 | LOG_ENTRY
|
---|
358 | push rbp
|
---|
359 | mov rbp, rsp
|
---|
360 | sub rsp, 50h
|
---|
361 |
|
---|
362 | mov rax, [ebp + 20h]
|
---|
363 | mov [rsp + 40h], rax
|
---|
364 | mov r10, [ebp + 18h]
|
---|
365 | mov [rsp + 38h], r10
|
---|
366 | mov r11, [ebp + 10h]
|
---|
367 | mov [rsp + 30h], r11
|
---|
368 | mov [rsp + 28h], r9
|
---|
369 | mov [rsp + 20h], r8
|
---|
370 | mov r9, rcx
|
---|
371 | mov r8, rdx
|
---|
372 | mov rdx, rsi
|
---|
373 | mov rcx, rdi
|
---|
374 | %ifdef USE_DIRECT_CALLS
|
---|
375 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
376 | %else
|
---|
377 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
378 | call rax
|
---|
379 | %endif
|
---|
380 |
|
---|
381 | leave
|
---|
382 | LOG_EXIT
|
---|
383 | ret
|
---|
384 | ENDPROC WrapGCC2MSC9Int
|
---|
385 |
|
---|
386 |
|
---|
387 | BEGINPROC WrapGCC2MSC10Int
|
---|
388 | LOG_ENTRY
|
---|
389 | push rbp
|
---|
390 | mov rbp, rsp
|
---|
391 | sub rsp, 50h
|
---|
392 |
|
---|
393 | mov r11, [ebp + 28h]
|
---|
394 | mov [rsp + 48h], r11
|
---|
395 | mov rax, [ebp + 20h]
|
---|
396 | mov [rsp + 40h], rax
|
---|
397 | mov r10, [ebp + 18h]
|
---|
398 | mov [rsp + 38h], r10
|
---|
399 | mov r11, [ebp + 10h]
|
---|
400 | mov [rsp + 30h], r11
|
---|
401 | mov [rsp + 28h], r9
|
---|
402 | mov [rsp + 20h], r8
|
---|
403 | mov r9, rcx
|
---|
404 | mov r8, rdx
|
---|
405 | mov rdx, rsi
|
---|
406 | mov rcx, rdi
|
---|
407 | %ifdef USE_DIRECT_CALLS
|
---|
408 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
409 | %else
|
---|
410 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
411 | call rax
|
---|
412 | %endif
|
---|
413 |
|
---|
414 | leave
|
---|
415 | LOG_EXIT
|
---|
416 | ret
|
---|
417 | ENDPROC WrapGCC2MSC10Int
|
---|
418 |
|
---|
419 |
|
---|
420 | BEGINPROC WrapGCC2MSC11Int
|
---|
421 | LOG_ENTRY
|
---|
422 | push rbp
|
---|
423 | mov rbp, rsp
|
---|
424 | sub rsp, 60h
|
---|
425 |
|
---|
426 | mov r10, [ebp + 30h]
|
---|
427 | mov [rsp + 50h], r10
|
---|
428 | mov r11, [ebp + 28h]
|
---|
429 | mov [rsp + 48h], r11
|
---|
430 | mov rax, [ebp + 20h]
|
---|
431 | mov [rsp + 40h], rax
|
---|
432 | mov r10, [ebp + 18h]
|
---|
433 | mov [rsp + 38h], r10
|
---|
434 | mov r11, [ebp + 10h]
|
---|
435 | mov [rsp + 30h], r11
|
---|
436 | mov [rsp + 28h], r9
|
---|
437 | mov [rsp + 20h], r8
|
---|
438 | mov r9, rcx
|
---|
439 | mov r8, rdx
|
---|
440 | mov rdx, rsi
|
---|
441 | mov rcx, rdi
|
---|
442 | %ifdef USE_DIRECT_CALLS
|
---|
443 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
444 | %else
|
---|
445 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
446 | call rax
|
---|
447 | %endif
|
---|
448 |
|
---|
449 | leave
|
---|
450 | LOG_EXIT
|
---|
451 | ret
|
---|
452 | ENDPROC WrapGCC2MSC11Int
|
---|
453 |
|
---|
454 |
|
---|
455 | BEGINPROC WrapGCC2MSC12Int
|
---|
456 | LOG_ENTRY
|
---|
457 | push rbp
|
---|
458 | mov rbp, rsp
|
---|
459 | sub rsp, 60h
|
---|
460 |
|
---|
461 | mov rax, [ebp + 28h]
|
---|
462 | mov [rsp + 48h], rax
|
---|
463 | mov r10, [ebp + 30h]
|
---|
464 | mov [rsp + 50h], r10
|
---|
465 | mov r11, [ebp + 28h]
|
---|
466 | mov [rsp + 48h], r11
|
---|
467 | mov rax, [ebp + 20h]
|
---|
468 | mov [rsp + 40h], rax
|
---|
469 | mov r10, [ebp + 18h]
|
---|
470 | mov [rsp + 38h], r10
|
---|
471 | mov r11, [ebp + 10h]
|
---|
472 | mov [rsp + 30h], r11
|
---|
473 | mov [rsp + 28h], r9
|
---|
474 | mov [rsp + 20h], r8
|
---|
475 | mov r9, rcx
|
---|
476 | mov r8, rdx
|
---|
477 | mov rdx, rsi
|
---|
478 | mov rcx, rdi
|
---|
479 | %ifdef USE_DIRECT_CALLS
|
---|
480 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
481 | %else
|
---|
482 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
483 | call rax
|
---|
484 | %endif
|
---|
485 |
|
---|
486 | leave
|
---|
487 | LOG_EXIT
|
---|
488 | ret
|
---|
489 | ENDPROC WrapGCC2MSC12Int
|
---|
490 |
|
---|
491 |
|
---|
492 |
|
---|
493 | BEGINPROC WrapGCC2MSCVariadictInt
|
---|
494 | LOG_ENTRY
|
---|
495 | %ifdef DEBUG
|
---|
496 | ; check that there are NO floting point arguments in XMM registers!
|
---|
497 | or rax, rax
|
---|
498 | jz .ok
|
---|
499 | int3
|
---|
500 | .ok:
|
---|
501 | %endif
|
---|
502 | sub rsp, 28h
|
---|
503 | mov r11, [rsp + 28h] ; r11 = return address.
|
---|
504 | mov [rsp + 28h], r9
|
---|
505 | mov [rsp + 20h], r8
|
---|
506 | mov r9, rcx
|
---|
507 | mov [rsp + 18h], r9 ; (*)
|
---|
508 | mov r8, rdx
|
---|
509 | mov [rsp + 14h], r8 ; (*)
|
---|
510 | mov rdx, rsi
|
---|
511 | mov [rsp + 8h], rdx ; (*)
|
---|
512 | mov rcx, rdi
|
---|
513 | mov [rsp], rcx ; (*)
|
---|
514 | mov rsi, r11 ; rsi is preserved by the callee.
|
---|
515 | %ifdef USE_DIRECT_CALLS
|
---|
516 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
517 | %else
|
---|
518 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
519 | call rax
|
---|
520 | %endif
|
---|
521 |
|
---|
522 | add rsp, 30h
|
---|
523 | LOG_EXIT
|
---|
524 | jmp rsi
|
---|
525 | ; (*) unconditionally spill the registers, just in case '...' implies weird stuff on MSC. Check this out!
|
---|
526 | ENDPROC WrapGCC2MSCVariadictInt
|
---|
527 |
|
---|
528 |
|
---|
529 | ;;
|
---|
530 | ; Custom template for SSMR3RegisterInternal.
|
---|
531 | ;
|
---|
532 | ; (This is based on the WrapGCC2MSC11Int template.)
|
---|
533 | ;
|
---|
534 | ; @cproto
|
---|
535 | ;
|
---|
536 | ; SSMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
|
---|
537 | ; PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
|
---|
538 | ; PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone);
|
---|
539 | ;
|
---|
540 | ; @param pVM rdi 0
|
---|
541 | ; @param pszName rsi 1
|
---|
542 | ; @param u32Instance rdx 2
|
---|
543 | ; @param u32Version rcx 3
|
---|
544 | ; @param cbGuess r8 4
|
---|
545 | ; @param pfnSavePrep r9 5
|
---|
546 | ; @param pfnSaveExec rbp + 10h 6
|
---|
547 | ; @param pfnSaveDone rbp + 18h 7
|
---|
548 | ; @param pfnLoadPrep rbp + 20h 8
|
---|
549 | ; @param pfnLoadExec rbp + 28h 9
|
---|
550 | ; @param pfnLoadDone rbp + 30h 10
|
---|
551 | ;
|
---|
552 | BEGINPROC WrapGCC2MSC_SSMR3RegisterInternal
|
---|
553 | LOG_ENTRY
|
---|
554 | push rbp
|
---|
555 | mov rbp, rsp
|
---|
556 |
|
---|
557 | sub rsp, 60h
|
---|
558 |
|
---|
559 | mov r10, [ebp + 30h]
|
---|
560 | mov [rsp + 50h], r10 ; pfnLoadDone
|
---|
561 | mov r11, [ebp + 28h]
|
---|
562 | mov [rsp + 48h], r11 ; pfnLoadExec
|
---|
563 | mov rax, [ebp + 20h]
|
---|
564 | mov [rsp + 40h], rax ; pfnLoadPrep
|
---|
565 | mov r10, [ebp + 18h]
|
---|
566 | mov [rsp + 38h], r10 ; pfnSaveDone
|
---|
567 | mov r11, [ebp + 10h]
|
---|
568 | mov [rsp + 30h], r11 ; pfnSaveExec
|
---|
569 | mov [rsp + 28h], r9 ; pfnSavePrep
|
---|
570 | mov [rsp + 20h], r8
|
---|
571 | mov [rsp + 18h], rcx ; -> r9
|
---|
572 | mov [rsp + 10h], rdx ; -> r8
|
---|
573 | mov [rsp + 08h], rsi ; -> rdx
|
---|
574 | mov [rsp], rdi ; -> rcx
|
---|
575 |
|
---|
576 | ; Now convert the function pointers. Have to setup a new shadow
|
---|
577 | ; space here since the SSMR3RegisterInternal one is already in use.
|
---|
578 | sub rsp, 20h
|
---|
579 |
|
---|
580 | mov rcx, REM_FIXUP_64_DESC ; pDesc
|
---|
581 | lea rdx, [rsp + 28h + 20h] ; pValue
|
---|
582 | mov r8d, 5 ; iParam
|
---|
583 | mov rax, REM_FIXUP_64_WRAP_GCC_CB
|
---|
584 | call rax
|
---|
585 |
|
---|
586 | mov rcx, REM_FIXUP_64_DESC ; pDesc
|
---|
587 | lea rdx, [rsp + 30h + 20h] ; pValue
|
---|
588 | mov r8d, 6 ; iParam
|
---|
589 | mov rax, REM_FIXUP_64_WRAP_GCC_CB
|
---|
590 | call rax
|
---|
591 |
|
---|
592 | mov rcx, REM_FIXUP_64_DESC ; pDesc
|
---|
593 | lea rdx, [rsp + 38h + 20h] ; pValue
|
---|
594 | mov r8d, 7 ; iParam
|
---|
595 | mov rax, REM_FIXUP_64_WRAP_GCC_CB
|
---|
596 | call rax
|
---|
597 |
|
---|
598 | mov rcx, REM_FIXUP_64_DESC ; pDesc
|
---|
599 | lea rdx, [rsp + 40h + 20h] ; pValue
|
---|
600 | mov r8d, 8 ; iParam
|
---|
601 | mov rax, REM_FIXUP_64_WRAP_GCC_CB
|
---|
602 | call rax
|
---|
603 |
|
---|
604 | mov rcx, REM_FIXUP_64_DESC ; pDesc
|
---|
605 | lea rdx, [rsp + 48h + 20h] ; pValue
|
---|
606 | mov r8d, 9 ; iParam
|
---|
607 | mov rax, REM_FIXUP_64_WRAP_GCC_CB
|
---|
608 | call rax
|
---|
609 |
|
---|
610 | mov rcx, REM_FIXUP_64_DESC ; pDesc
|
---|
611 | lea rdx, [rsp + 50h + 20h] ; pValue
|
---|
612 | mov r8d, 10 ; iParam
|
---|
613 | mov rax, REM_FIXUP_64_WRAP_GCC_CB
|
---|
614 | call rax
|
---|
615 |
|
---|
616 | add rsp, 20h
|
---|
617 |
|
---|
618 | ; finally do the call.
|
---|
619 | mov r9, [rsp + 18h]
|
---|
620 | mov r8, [rsp + 10h]
|
---|
621 | mov rdx, [rsp + 08h]
|
---|
622 | mov rcx, [rsp]
|
---|
623 | %ifdef USE_DIRECT_CALLS
|
---|
624 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
625 | %else
|
---|
626 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
627 | call rax
|
---|
628 | %endif
|
---|
629 |
|
---|
630 | leave
|
---|
631 | LOG_EXIT
|
---|
632 | ret
|
---|
633 | ENDPROC WrapGCC2MSC_SSMR3RegisterInternal
|
---|
634 |
|
---|
635 |
|
---|
636 | ;
|
---|
637 | ; The other way around:
|
---|
638 | ;
|
---|
639 |
|
---|
640 |
|
---|
641 | BEGINPROC WrapMSC2GCC0Int
|
---|
642 | LOG_ENTRY
|
---|
643 | push rbp
|
---|
644 | mov rbp, rsp
|
---|
645 | sub rsp, 10h
|
---|
646 | mov [ebp - 10h], rsi
|
---|
647 | mov [ebp - 18h], rdi
|
---|
648 |
|
---|
649 | %ifdef USE_DIRECT_CALLS
|
---|
650 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
651 | %else
|
---|
652 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
653 | call rax
|
---|
654 | %endif
|
---|
655 |
|
---|
656 | mov rdi, [ebp - 18h]
|
---|
657 | mov rsi, [ebp - 10h]
|
---|
658 | leave
|
---|
659 | LOG_EXIT
|
---|
660 | ret
|
---|
661 | ENDPROC WrapMSC2GCC0Int
|
---|
662 |
|
---|
663 |
|
---|
664 | BEGINPROC WrapMSC2GCC1Int
|
---|
665 | LOG_ENTRY
|
---|
666 | push rbp
|
---|
667 | mov rbp, rsp
|
---|
668 | sub rsp, 20h
|
---|
669 | mov [ebp - 10h], rsi
|
---|
670 | mov [ebp - 18h], rdi
|
---|
671 |
|
---|
672 | mov rdi, rcx
|
---|
673 | %ifdef USE_DIRECT_CALLS
|
---|
674 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
675 | %else
|
---|
676 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
677 | call rax
|
---|
678 | %endif
|
---|
679 |
|
---|
680 | mov rdi, [ebp - 18h]
|
---|
681 | mov rsi, [ebp - 10h]
|
---|
682 | leave
|
---|
683 | LOG_EXIT
|
---|
684 | ret
|
---|
685 | ENDPROC WrapMSC2GCC1Int
|
---|
686 |
|
---|
687 |
|
---|
688 | BEGINPROC WrapMSC2GCC2Int
|
---|
689 | LOG_ENTRY
|
---|
690 | push rbp
|
---|
691 | mov rbp, rsp
|
---|
692 | sub rsp, 20h
|
---|
693 | mov [ebp - 10h], rsi
|
---|
694 | mov [ebp - 18h], rdi
|
---|
695 |
|
---|
696 | mov rdi, rcx
|
---|
697 | mov rsi, rdx
|
---|
698 | %ifdef USE_DIRECT_CALLS
|
---|
699 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
700 | %else
|
---|
701 | mov rax, REM_FIXUP_64_REAL_STUFF
|
---|
702 | call rax
|
---|
703 | %endif
|
---|
704 |
|
---|
705 | mov rdi, [ebp - 18h]
|
---|
706 | mov rsi, [ebp - 10h]
|
---|
707 | leave
|
---|
708 | LOG_EXIT
|
---|
709 | ret
|
---|
710 | ENDPROC WrapMSC2GCC2Int
|
---|
711 |
|
---|
712 |
|
---|
713 | BEGINPROC WrapMSC2GCC3Int
|
---|
714 | LOG_ENTRY
|
---|
715 | push rbp
|
---|
716 | mov rbp, rsp
|
---|
717 | sub rsp, 20h
|
---|
718 | mov [ebp - 10h], rsi
|
---|
719 | mov [ebp - 18h], rdi
|
---|
720 |
|
---|
721 | mov rdi, rcx
|
---|
722 | mov rsi, rdx
|
---|
723 | mov rdx, r8
|
---|
724 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
725 |
|
---|
726 | mov rdi, [ebp - 18h]
|
---|
727 | mov rsi, [ebp - 10h]
|
---|
728 | leave
|
---|
729 | LOG_EXIT
|
---|
730 | ret
|
---|
731 | ENDPROC WrapMSC2GCC3Int
|
---|
732 |
|
---|
733 |
|
---|
734 | BEGINPROC WrapMSC2GCC4Int
|
---|
735 | LOG_ENTRY
|
---|
736 | push rbp
|
---|
737 | mov rbp, rsp
|
---|
738 | sub rsp, 20h
|
---|
739 | mov [ebp - 10h], rsi
|
---|
740 | mov [ebp - 18h], rdi
|
---|
741 |
|
---|
742 | mov rdi, rcx
|
---|
743 | mov rsi, rdx
|
---|
744 | mov rdx, r8
|
---|
745 | mov rcx, r9
|
---|
746 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
747 |
|
---|
748 | mov rdi, [ebp - 18h]
|
---|
749 | mov rsi, [ebp - 10h]
|
---|
750 | leave
|
---|
751 | LOG_EXIT
|
---|
752 | ret
|
---|
753 | ENDPROC WrapMSC2GCC4Int
|
---|
754 |
|
---|
755 |
|
---|
756 | BEGINPROC WrapMSC2GCC5Int
|
---|
757 | LOG_ENTRY
|
---|
758 | push rbp
|
---|
759 | mov rbp, rsp
|
---|
760 | sub rsp, 20h
|
---|
761 | mov [ebp - 10h], rsi
|
---|
762 | mov [ebp - 18h], rdi
|
---|
763 |
|
---|
764 | mov rdi, rcx
|
---|
765 | mov rsi, rdx
|
---|
766 | mov rdx, r8
|
---|
767 | mov rcx, r9
|
---|
768 | mov r8, [ebp + 30h]
|
---|
769 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
770 |
|
---|
771 | mov rdi, [ebp - 18h]
|
---|
772 | mov rsi, [ebp - 10h]
|
---|
773 | leave
|
---|
774 | LOG_EXIT
|
---|
775 | ret
|
---|
776 | ENDPROC WrapMSC2GCC5Int
|
---|
777 |
|
---|
778 |
|
---|
779 | BEGINPROC WrapMSC2GCC6Int
|
---|
780 | LOG_ENTRY
|
---|
781 | push rbp
|
---|
782 | mov rbp, rsp
|
---|
783 | sub rsp, 20h
|
---|
784 | mov [ebp - 10h], rsi
|
---|
785 | mov [ebp - 18h], rdi
|
---|
786 |
|
---|
787 | mov rdi, rcx
|
---|
788 | mov rsi, rdx
|
---|
789 | mov rdx, r8
|
---|
790 | mov rcx, r9
|
---|
791 | mov r8, [ebp + 30h]
|
---|
792 | mov r9, [ebp + 38h]
|
---|
793 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
794 |
|
---|
795 | mov rdi, [ebp - 18h]
|
---|
796 | mov rsi, [ebp - 10h]
|
---|
797 | leave
|
---|
798 | LOG_EXIT
|
---|
799 | ret
|
---|
800 | ENDPROC WrapMSC2GCC6Int
|
---|
801 |
|
---|
802 |
|
---|
803 | BEGINPROC WrapMSC2GCC7Int
|
---|
804 | LOG_ENTRY
|
---|
805 | push rbp
|
---|
806 | mov rbp, rsp
|
---|
807 | sub rsp, 30h
|
---|
808 | mov [ebp - 10h], rsi ;; @todo wtf is this using ebp instead of rbp?
|
---|
809 | mov [ebp - 18h], rdi
|
---|
810 |
|
---|
811 | mov rdi, rcx
|
---|
812 | mov rsi, rdx
|
---|
813 | mov rdx, r8
|
---|
814 | mov rcx, r9
|
---|
815 | mov r8, [ebp + 30h]
|
---|
816 | mov r9, [ebp + 38h]
|
---|
817 | mov r10, [ebp + 40h]
|
---|
818 | mov [esp], r10
|
---|
819 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
820 |
|
---|
821 | mov rdi, [ebp - 18h]
|
---|
822 | mov rsi, [ebp - 10h]
|
---|
823 | leave
|
---|
824 | LOG_EXIT
|
---|
825 | ret
|
---|
826 | ENDPROC WrapMSC2GCC7Int
|
---|
827 |
|
---|
828 |
|
---|
829 | BEGINPROC WrapMSC2GCC8Int
|
---|
830 | LOG_ENTRY
|
---|
831 | push rbp
|
---|
832 | mov rbp, rsp
|
---|
833 | sub rsp, 30h
|
---|
834 | mov [ebp - 10h], rsi
|
---|
835 | mov [ebp - 18h], rdi
|
---|
836 |
|
---|
837 | mov rdi, rcx
|
---|
838 | mov rsi, rdx
|
---|
839 | mov rdx, r8
|
---|
840 | mov rcx, r9
|
---|
841 | mov r8, [ebp + 30h]
|
---|
842 | mov r9, [ebp + 38h]
|
---|
843 | mov r10, [ebp + 40h]
|
---|
844 | mov [esp], r10
|
---|
845 | mov r11, [ebp + 48h]
|
---|
846 | mov [esp + 8], r11
|
---|
847 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
848 |
|
---|
849 | mov rdi, [ebp - 18h]
|
---|
850 | mov rsi, [ebp - 10h]
|
---|
851 | leave
|
---|
852 | LOG_EXIT
|
---|
853 | ret
|
---|
854 | ENDPROC WrapMSC2GCC8Int
|
---|
855 |
|
---|
856 |
|
---|
857 | BEGINPROC WrapMSC2GCC9Int
|
---|
858 | LOG_ENTRY
|
---|
859 | push rbp
|
---|
860 | mov rbp, rsp
|
---|
861 | sub rsp, 40h
|
---|
862 | mov [ebp - 10h], rsi
|
---|
863 | mov [ebp - 18h], rdi
|
---|
864 |
|
---|
865 | mov rdi, rcx
|
---|
866 | mov rsi, rdx
|
---|
867 | mov rdx, r8
|
---|
868 | mov rcx, r9
|
---|
869 | mov r8, [ebp + 30h]
|
---|
870 | mov r9, [ebp + 38h]
|
---|
871 | mov r10, [ebp + 40h]
|
---|
872 | mov [esp], r10
|
---|
873 | mov r11, [ebp + 48h]
|
---|
874 | mov [esp + 8], r11
|
---|
875 | mov rax, [ebp + 50h]
|
---|
876 | mov [esp + 10h], rax
|
---|
877 | call $+5+REM_FIXUP_32_REAL_STUFF
|
---|
878 |
|
---|
879 | mov rdi, [ebp - 18h]
|
---|
880 | mov rsi, [ebp - 10h]
|
---|
881 | leave
|
---|
882 | LOG_EXIT
|
---|
883 | ret
|
---|
884 | ENDPROC WrapMSC2GCC9Int
|
---|
885 |
|
---|
886 | %endif ; RT_ARCH_AMD64
|
---|
887 | %endif ; RT_OS_WINDOWS
|
---|
888 |
|
---|