VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/VMMR0TripleFaultHackA.asm@ 63648

Last change on this file since 63648 was 62478, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1; $Id: VMMR0TripleFaultHackA.asm 62478 2016-07-22 18:29:06Z vboxsync $
2;; @file
3; VMM - Host Context Ring 0, Assembly Code for The Triple Fault Debugging Hack.
4;
5
6;
7; Copyright (C) 2011-2016 Oracle Corporation
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
18;*******************************************************************************
19;* Header Files *
20;*******************************************************************************
21%include "VBox/asmdefs.mac"
22
23
24BEGINCODE
25GLOBALNAME vmmR0TripleFaultHackStart
26%define CALC_ADDR(a_Addr) ( (a_Addr) - NAME(vmmR0TripleFaultHackStart) + 07000h )
27
28
29BITS 16
30BEGINPROC vmmR0TripleFaultHack
31 ; Set up stack.
32 cli ; paranoia
33 mov sp, 0ffffh
34 mov ax, cs
35 mov ss, ax
36 mov ds, ax
37 mov es, ax
38 cld ; paranoia
39
40 COM_INIT
41
42 ; Beep and say hello to the post-reset world.
43 call NAME(vmmR0TripleFaultHackBeep)
44 mov si, CALC_ADDR(.s_szHello)
45 call NAME(vmmR0TripleFaultHackPrint)
46
47.forever:
48 hlt
49 jmp .forever
50
51.s_szHello:
52 db 'Hello post-reset world', 0ah, 0dh, 0
53ENDPROC vmmR0TripleFaultHack
54
55;; ds:si = zero terminated string.
56BEGINPROC vmmR0TripleFaultHackPrint
57 push eax
58 push esi
59
60.outer_loop:
61 lodsb
62 cmp al, 0
63 je .done
64 call NAME(vmmR0TripleFaultHackPrintCh)
65 jmp .outer_loop
66
67.done:
68 pop esi
69 pop eax
70 ret
71ENDPROC vmmR0TripleFaultHackPrint
72
73
74;; al = char to print
75BEGINPROC vmmR0TripleFaultHackPrintCh
76 push eax
77 push edx
78 push ecx
79 mov ah, al ; save char.
80
81 ; Wait for status.
82 mov ecx, _1G
83 mov dx, VBOX_UART_BASE + 5
84.pre_status:
85 in al, dx
86 test al, 20h
87 jnz .put_char
88 dec ecx
89 jnz .pre_status
90
91 ; Write the character.
92.put_char:
93 mov al, ah
94 mov dx, VBOX_UART_BASE
95 out dx, al
96
97 ; Wait for status.
98 mov ecx, _1G
99 mov dx, VBOX_UART_BASE + 5
100.post_status:
101 in al, dx
102 test al, 20h
103 jnz .done
104 dec ecx
105 jnz .post_status
106
107.done:
108 pop ecx
109 pop edx
110 pop eax
111 ret
112ENDPROC vmmR0TripleFaultHackPrintCh
113
114;;
115; make a 440 BEEP.
116BEGINPROC vmmR0TripleFaultHackBeep
117 push eax
118 push edx
119 push ecx
120
121 ; program PIT(1) and stuff.
122 mov al, 10110110b
123 out 43h, al
124 mov ax, 0a79h ; A = 440
125 out 42h, al
126 shr ax, 8
127 out 42h, al
128
129 in al, 61h
130 or al, 3
131 out 61h, al
132
133 ; delay
134 mov ecx, _1G
135.delay:
136 inc ecx
137 dec ecx
138 dec ecx
139 jnz .delay
140
141 ; shut up speaker.
142 in al, 61h
143 and al, 11111100b
144 out 61h, al
145
146.done:
147 pop ecx
148 pop edx
149 pop eax
150 ret
151ENDPROC vmmR0TripleFaultHackBeep
152
153
154GLOBALNAME vmmR0TripleFaultHackEnd
155
156
157
158
159;;;
160;;;
161;;;
162;;;
163;;;
164
165
166
167BITS ARCH_BITS
168
169BEGINPROC vmmR0TripleFaultHackKbdWait
170 push xAX
171
172.check_status:
173 in al, 64h
174 test al, 1 ; KBD_STAT_OBF
175 jnz .read_data_and_status
176 test al, 2 ; KBD_STAT_IBF
177 jnz .check_status
178
179 pop xAX
180 ret
181
182.read_data_and_status:
183 in al, 60h
184 jmp .check_status
185ENDPROC vmmR0TripleFaultHackKbdWait
186
187
188BEGINPROC vmmR0TripleFaultHackKbdRead
189 out 64h, al ; Write the command.
190
191.check_status:
192 in al, 64h
193 test al, 1 ; KBD_STAT_OBF
194 jz .check_status
195
196 in al, 60h ; Read the data.
197 ret
198ENDPROC vmmR0TripleFaultHackKbdRead
199
200
201BEGINPROC vmmR0TripleFaultHackKbdWrite
202 out 64h, al ; Write the command.
203 call NAME(vmmR0TripleFaultHackKbdWait)
204
205 xchg al, ah
206 out 60h, al ; Write the data.
207 call NAME(vmmR0TripleFaultHackKbdWait)
208 xchg al, ah
209
210 ret
211ENDPROC vmmR0TripleFaultHackKbdWrite
212
213
214
215BEGINPROC vmmR0TripleFaultHackTripleFault
216 push xAX
217 push xSI
218
219 xor eax, eax
220 push xAX
221 push xAX
222 push xAX
223 push xAX
224
225 COM_CHAR 'B'
226 COM_CHAR 'y'
227 COM_CHAR 'e'
228 COM_CHAR '!'
229 COM_CHAR 0ah
230 COM_CHAR 0dh
231
232
233 ;call NAME(vmmR0TripleFaultHackBeep32)
234%if 1
235 lidt [xSP]
236%elif 0
237 in al, 92h
238 or al, 1
239 out 92h, al
240 in al, 92h
241 cli
242 hlt
243%else
244 mov al, 0d0h ; KBD_CCMD_READ_OUTPORT
245 call NAME(vmmR0TripleFaultHackKbdRead)
246 mov ah, 0feh
247 and ah, al
248 mov al, 0d1h ; KBD_CCMD_WRITE_OUTPORT
249 call NAME(vmmR0TripleFaultHackKbdWrite)
250 cli
251 hlt
252%endif
253 int3
254
255 pop xAX
256 pop xAX
257 pop xAX
258 pop xAX
259
260 pop xSI
261 pop xAX
262 ret
263ENDPROC vmmR0TripleFaultHackTripleFault
264
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