VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMGC/VMMGCA.asm@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1;; @file
2;
3; VMMGC - Guest Context Virtual Machine Monitor assembly routines.
4
5; Copyright (C) 2006 InnoTek Systemberatung GmbH
6;
7; This file is part of VirtualBox Open Source Edition (OSE), as
8; available from http://www.virtualbox.org. This file is free software;
9; you can redistribute it and/or modify it under the terms of the GNU
10; General Public License as published by the Free Software Foundation,
11; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
12; distribution. VirtualBox OSE is distributed in the hope that it will
13; be useful, but WITHOUT ANY WARRANTY of any kind.
14;
15; If you received this file as part of a commercial VirtualBox
16; distribution, then only the terms of your commercial VirtualBox
17; license agreement apply instead of the previous paragraph.
18
19;*******************************************************************************
20;* Header Files *
21;*******************************************************************************
22%include "VBox/nasm.mac"
23%include "VBox/x86.mac"
24
25
26;*******************************************************************************
27;* Defined Constants And Macros *
28;*******************************************************************************
29;; save all registers before loading special values for the faulting.
30%macro SaveAndLoadAll 0
31 pushad
32 push ds
33 push es
34 push fs
35 push gs
36 call NAME(vmmGCTestLoadRegs)
37%endmacro
38
39;; restore all registers after faulting.
40%macro RestoreAll 0
41 pop gs
42 pop fs
43 pop es
44 pop ds
45 popad
46%endmacro
47
48
49;*******************************************************************************
50;* External Symbols *
51;*******************************************************************************
52extern IMPNAME(g_Logger)
53extern IMPNAME(g_RelLogger)
54extern NAME(RTLogLogger)
55
56
57BEGINCODE
58
59;/**
60; * Internal GC logger worker: Logger wrapper.
61; */
62;VMMGCDECL(void) vmmGCLoggerWrapper(const char *pszFormat, ...);
63EXPORTEDNAME vmmGCLoggerWrapper
64%ifdef __YASM__
65%ifdef ASM_FORMAT_ELF
66 push dword IMP(g_Logger) ; YASM BUG #67! YASMCHECK!
67%else
68 push IMP(g_Logger)
69%endif
70%else
71 push IMP(g_Logger)
72%endif
73 call NAME(RTLogLogger)
74 add esp, byte 4
75 ret
76ENDPROC vmmGCLoggerWrapper
77
78
79;/**
80; * Internal GC logger worker: Logger (release) wrapper.
81; */
82;VMMGCDECL(void) vmmGCRelLoggerWrapper(const char *pszFormat, ...);
83EXPORTEDNAME vmmGCRelLoggerWrapper
84%ifdef __YASM__
85%ifdef ASM_FORMAT_ELF
86 push dword IMP(g_RelLogger) ; YASM BUG #67! YASMCHECK!
87%else
88 push IMP(g_RelLogger)
89%endif
90%else
91 push IMP(g_RelLogger)
92%endif
93 call NAME(RTLogLogger)
94 add esp, byte 4
95 ret
96ENDPROC vmmGCRelLoggerWrapper
97
98
99;;
100; Enables write protection.
101BEGINPROC vmmGCEnableWP
102 push eax
103 mov eax, cr0
104 or eax, X86_CR0_WRITE_PROTECT
105 mov cr0, eax
106 pop eax
107 ret
108ENDPROC vmmGCEnableWP
109
110
111;;
112; Disables write protection.
113BEGINPROC vmmGCDisableWP
114 push eax
115 mov eax, cr0
116 and eax, ~X86_CR0_WRITE_PROTECT
117 mov cr0, eax
118 pop eax
119 ret
120ENDPROC vmmGCDisableWP
121
122
123;;
124; Load special register set expected upon faults.
125; All registers are changed.
126BEGINPROC vmmGCTestLoadRegs
127 mov eax, ss
128 mov ds, eax
129 mov es, eax
130 mov fs, eax
131 mov gs, eax
132 mov edi, 001234567h
133 mov esi, 042000042h
134 mov ebp, 0ffeeddcch
135 mov ebx, 089abcdefh
136 mov ecx, 0ffffaaaah
137 mov edx, 077778888h
138 mov eax, 0f0f0f0f0h
139 ret
140ENDPROC vmmGCTestLoadRegs
141
142
143;;
144; A Trap 3 testcase.
145GLOBALNAME vmmGCTestTrap3
146 SaveAndLoadAll
147
148 int 3
149EXPORTEDNAME vmmGCTestTrap3_FaultEIP
150
151 RestoreAll
152 mov eax, 0ffffffffh
153 ret
154ENDPROC vmmGCTestTrap3
155
156
157;;
158; A Trap 8 testcase.
159GLOBALNAME vmmGCTestTrap8
160 SaveAndLoadAll
161
162 sub esp, byte 8
163 sidt [esp]
164 mov word [esp], 111 ; make any #PF double fault.
165 lidt [esp]
166 add esp, byte 8
167
168 COM_S_CHAR '!'
169
170 xor eax, eax
171EXPORTEDNAME vmmGCTestTrap8_FaultEIP
172 mov eax, [eax]
173
174
175 COM_S_CHAR '2'
176
177 RestoreAll
178 mov eax, 0ffffffffh
179 ret
180ENDPROC vmmGCTestTrap8
181
182
183;;
184; A simple Trap 0d testcase.
185GLOBALNAME vmmGCTestTrap0d
186 SaveAndLoadAll
187
188 push ds
189EXPORTEDNAME vmmGCTestTrap0d_FaultEIP
190 ltr [esp]
191 pop eax
192
193 RestoreAll
194 mov eax, 0ffffffffh
195 ret
196ENDPROC vmmGCTestTrap0d
197
198
199;;
200; A simple Trap 0e testcase.
201GLOBALNAME vmmGCTestTrap0e
202 SaveAndLoadAll
203
204 xor eax, eax
205EXPORTEDNAME vmmGCTestTrap0e_FaultEIP
206 mov eax, [eax]
207
208 RestoreAll
209 mov eax, 0ffffffffh
210 ret
211ENDPROC vmmGCTestTrap0e
212
Note: See TracBrowser for help on using the repository browser.

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