VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/VMMR0A.asm@ 684

Last change on this file since 684 was 671, checked in by vboxsync, 18 years ago

Stub vmmR0LoggerWrapper on AMD64 even if it's never used.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1; $Id: VMMR0A.asm 671 2007-02-06 04:23:26Z vboxsync $
2;; @file
3; VMM - R0 assembly routines.
4;
5
6;
7; Copyright (C) 2006 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
13; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14; distribution. VirtualBox OSE is distributed in the hope that it will
15; be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; If you received this file as part of a commercial VirtualBox
18; distribution, then only the terms of your commercial VirtualBox
19; license agreement apply instead of the previous paragraph.
20;
21
22;*******************************************************************************
23;* Header Files *
24;*******************************************************************************
25%include "VBox/asmdefs.mac"
26%include "VMMInternal.mac"
27%include "iprt/err.mac"
28
29
30%ifdef __X86__ ; The other architecture(s) use(s) C99 variadict macros.
31extern IMPNAME(RTLogLogger)
32%endif
33
34
35BEGINCODE
36
37
38;;
39; The setjmp variant used for calling Ring-3.
40;
41; This differs from the normal setjmp in that it will resume VMMR0CallHost if we're
42; in the middle of a ring-3 call. Another differences is the function pointer and
43; argument. This has to do with resuming code and the stack frame of the caller.
44;
45; @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallHostLongJmp.
46; @param pJmpBuf Our jmp_buf.
47; @param pfn The function to be called when not resuming.
48; @param pVM The argument of that function.
49;
50BEGINPROC vmmR0CallHostSetJmp
51%ifdef __X86__
52 ;
53 ; Save the registers.
54 ;
55 mov edx, [esp + 4h] ; pJmpBuf
56 mov [edx + VMMR0JMPBUF.ebx], ebx
57 mov [edx + VMMR0JMPBUF.esi], esi
58 mov [edx + VMMR0JMPBUF.edi], edi
59 mov [edx + VMMR0JMPBUF.ebp], ebp
60 mov eax, [esp]
61 mov [edx + VMMR0JMPBUF.eip], eax
62 lea ecx, [esp + 4] ; (used in resume)
63 mov [edx + VMMR0JMPBUF.esp], ecx
64
65 ;
66 ; If we're not in a ring-3 call, call pfn and return.
67 ;
68 test byte [edx + VMMR0JMPBUF.fInRing3Call], 1
69 jnz .resume
70
71 mov ecx, [esp + 0ch] ; pvArg
72 mov eax, [esp + 08h] ; pfn
73 push ecx
74 call eax
75 add esp, 4
76 mov edx, [esp + 4h] ; pJmpBuf
77 and dword [edx + VMMR0JMPBUF.eip], byte 0 ; used for valid check.
78 ret
79
80 ;
81 ; Resume VMMR0CallHost the call.
82 ;
83.resume:
84 ; Sanity checks.
85 cmp ecx, [edx + VMMR0JMPBUF.SpCheck]
86 je .espCheck_ok
87.bad:
88 and dword [edx + VMMR0JMPBUF.eip], byte 0 ; used for valid check.
89 mov edi, [edx + VMMR0JMPBUF.edi]
90 mov esi, [edx + VMMR0JMPBUF.esi]
91 mov ebx, [edx + VMMR0JMPBUF.ebx]
92 mov eax, VERR_INTERNAL_ERROR ; todo better return code!
93 ret
94
95.espCheck_ok:
96 mov ecx, [edx + VMMR0JMPBUF.cbSavedStack]
97 cmp ecx, 8192
98 ja .bad
99 test ecx, 3
100 jnz .bad
101 mov edi, [edx + VMMR0JMPBUF.esp]
102 sub edi, [edx + VMMR0JMPBUF.SpResume]
103 cmp ecx, edi
104 jne .bad
105
106 ;
107 ; Restore the stack.
108 ;
109 mov byte [edx + VMMR0JMPBUF.fInRing3Call], 0
110 mov ecx, [edx + VMMR0JMPBUF.cbSavedStack]
111 shr ecx, 2
112 mov esi, [edx + VMMR0JMPBUF.pvSavedStack]
113 mov edi, [edx + VMMR0JMPBUF.SpResume]
114 mov esp, edi
115 rep movsd
116
117 ;
118 ; Continue where we left off.
119 ;
120 popf
121 pop ebx
122 pop esi
123 pop edi
124 pop ebp
125 xor eax, eax ; VINF_SUCCESS
126 ret
127%endif ; __X86__
128
129%ifdef __AMD64__
130 int3 ; implement me!
131%endif
132ENDPROC vmmR0CallHostSetJmp
133
134
135;;
136; Worker for VMMR0CallHost.
137; This will save the stack and registers.
138;
139; @param pJmpBuf Pointer to the jump buffer.
140; @param rc The return code.
141;
142BEGINPROC vmmR0CallHostLongJmp
143%ifdef __X86__
144 ;
145 ; Save the registers on the stack.
146 ;
147 push ebp
148 mov ebp, esp
149 push edi
150 push esi
151 push ebx
152 pushf
153
154 ;
155 ; Load parameters.
156 ;
157 mov edx, [ebp + 08h] ; pJmpBuf
158 mov eax, [ebp + 0ch] ; rc
159
160 ;
161 ; Is the jump buffer armed?
162 ;
163 cmp dword [edx + VMMR0JMPBUF.eip], byte 0
164 je .nok
165
166 ;
167 ; Save the stack.
168 ;
169 mov edi, [edx + VMMR0JMPBUF.pvSavedStack]
170 mov [edx + VMMR0JMPBUF.SpResume], esp
171 mov esi, esp
172 mov ecx, [edx + VMMR0JMPBUF.esp]
173 sub ecx, esi
174
175 ; two sanity checks on the size.
176 cmp ecx, 8192 ; check max size.
177 jbe .ok
178.nok:
179 mov eax, VERR_INTERNAL_ERROR
180 popf
181 pop ebx
182 pop esi
183 pop edi
184 leave
185 ret
186.ok:
187 test ecx, 3 ; check alignment
188 jnz .nok
189 mov [edx + VMMR0JMPBUF.cbSavedStack], ecx
190 shr ecx, 2
191 rep movsd
192
193 ; store the last pieces of info.
194 mov ecx, [edx + VMMR0JMPBUF.esp]
195 mov [edx + VMMR0JMPBUF.SpCheck], ecx
196 mov byte [edx + VMMR0JMPBUF.fInRing3Call], 1
197
198 ;
199 ; Do the long jump.
200 ;
201 mov ebx, [edx + VMMR0JMPBUF.ebx]
202 mov esi, [edx + VMMR0JMPBUF.esi]
203 mov edi, [edx + VMMR0JMPBUF.edi]
204 mov ebp, [edx + VMMR0JMPBUF.ebp]
205 mov ecx, [edx + VMMR0JMPBUF.eip]
206 mov esp, [edx + VMMR0JMPBUF.esp]
207 jmp ecx
208%endif ; __X86__
209
210%ifdef __AMD64__
211 int3 ; implement me!
212%endif
213ENDPROC vmmR0CallHostLongJmp
214
215
216;;
217; Internal R0 logger worker: Logger wrapper.
218;
219; @cproto VMMR0DECL(void) vmmR0LoggerWrapper(const char *pszFormat, ...)
220;
221EXPORTEDNAME vmmR0LoggerWrapper
222%ifdef __X86__ ; The other architecture(s) use(s) C99 variadict macros.
223 push 0 ; assumes we're the wrapper for a default instance.
224 call IMP(RTLogLogger)
225 add esp, byte 4
226 ret
227%else
228 int3
229 int3
230 int3
231 ret
232%endif
233ENDPROC vmmR0LoggerWrapper
234
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette