VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-c32-Trap32Generic.asm@ 60202

Last change on this file since 60202 was 60202, checked in by vboxsync, 9 years ago

bs3kit: updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.0 KB
Line 
1; $Id: bs3-c32-Trap32Generic.asm 60202 2016-03-26 23:45:22Z vboxsync $
2;; @file
3; BS3Kit - Trap, 32-bit assembly handlers.
4;
5
6;
7; Copyright (C) 2007-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; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27;*********************************************************************************************************************************
28;* Header Files *
29;*********************************************************************************************************************************
30%include "bs3kit-template-header.mac"
31
32%ifndef TMPL_32BIT
33 %error "32-bit only template"
34%endif
35
36
37;*********************************************************************************************************************************
38;* External Symbols *
39;*********************************************************************************************************************************
40BS3_EXTERN_DATA16 g_bBs3CurrentMode
41BS3_EXTERN_SYSTEM16 Bs3Gdt
42TMPL_BEGIN_TEXT
43BS3_EXTERN_CMN Bs3TrapDefaultHandler
44BS3_EXTERN_CMN Bs3RegCtxRestore
45TMPL_BEGIN_TEXT
46
47
48;*********************************************************************************************************************************
49;* Global Variables *
50;*********************************************************************************************************************************
51BS3_BEGIN_DATA16
52;; Easy to access flat address of Bs3Trap32GenericEntries.
53BS3_GLOBAL_DATA g_Bs3Trap32GenericEntriesFlatAddr, 4
54 dd Bs3Trap32GenericEntries wrt FLAT
55;; Easy to access flat address of Bs3Trap32DoubleFaultHandler.
56BS3_GLOBAL_DATA g_Bs3Trap32DoubleFaultHandlerFlatAddr, 4
57 dd Bs3Trap32DoubleFaultHandler wrt FLAT
58
59BS3_BEGIN_DATA32
60;; Pointer C trap handlers.
61BS3_GLOBAL_DATA g_apfnBs3TrapHandlers_c32, 1024
62 resd 256
63
64
65
66;;
67; Generic entry points for IDT handlers, 8 byte spacing.
68;
69BS3_PROC_BEGIN Bs3Trap32GenericEntries
70%macro Bs3Trap32GenericEntryNoErr 1
71 push byte 0 ; 2 byte: fake error code.
72 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value.
73 jmp near %1 ; 5 byte
74 ALIGNCODE(2)
75%assign i i+1
76%endmacro
77
78%macro Bs3Trap32GenericEntryErrCd 1
79 db 06ah, i ; 2 byte: push imm8 - note that this is a signextended value.
80 jmp near %1 ; 5 byte
81 db 0cch, 0cch ; 2 byte: padding.
82 ALIGNCODE(2)
83%assign i i+1
84%endmacro
85
86%assign i 0 ; start counter.
87 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 0
88 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1
89 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 2
90 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 3
91 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 4
92 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 5
93 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 6
94 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 7
95 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 8
96 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 9
97 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; a
98 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; b
99 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; c
100 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; d
101 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; e
102 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; f (reserved)
103 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 10
104 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 11
105 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 12
106 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 13
107 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 14
108 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 15 (reserved)
109 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 16 (reserved)
110 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 17 (reserved)
111 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 18 (reserved)
112 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 19 (reserved)
113 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1a (reserved)
114 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1b (reserved)
115 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1c (reserved)
116 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1d (reserved)
117 Bs3Trap32GenericEntryErrCd bs3Trap32GenericTrapOrInt ; 1e
118 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt ; 1f (reserved)
119%rep 224
120 Bs3Trap32GenericEntryNoErr bs3Trap32GenericTrapOrInt
121%endrep
122BS3_PROC_END Bs3Trap32GenericEntries
123AssertCompile(Bs3Trap32GenericEntries_EndProc - Bs3Trap32GenericEntries == 10*256)
124
125
126;;
127; Trap or interrupt with error code, faked if necessary.
128;
129BS3_PROC_BEGIN bs3Trap32GenericTrapOrInt
130 push ebp ; 0
131 mov ebp, esp
132 pushfd ; -04h
133 cld
134 push eax ; -08h
135 push edi ; -0ch
136 lea eax, [esp + (4+1+1)*4] ; 4 pushes above, 1 exception number push, 1 error code.
137 push eax ; -10h = handler ESP
138 add eax, 3*4 ; 3 dword iret frame
139 push eax ; -14h = caller ESP if same CPL
140 push ss ; -18h
141 push ds ; -1ch
142
143 ; Make sure we've got a flat DS (ASSUMES ring-0). It makes everything so much simpler.
144 mov ax, ss
145 and al, 3
146 AssertCompile(BS3_SEL_RING_SHIFT == 8)
147 mov ah, al
148 add ax, BS3_SEL_R0_DS32
149 mov ds, ax
150
151 ;
152 ; We may be comming from 16-bit code with a 16-bit SS. Thunk it as
153 ; the C code may assume flat SS and we'll mess up by using EBP/ESP/EDI
154 ; instead of BP/SP/SS:DI. ASSUMES standard GDT selector.
155 ;
156 mov ax, ss
157 lar eax, ax
158 test eax, X86LAR_F_D
159 jz .stack_thunk
160 mov ax, ss
161 and al, 3
162 AssertCompile(BS3_SEL_RING_SHIFT == 8)
163 mov ah, al
164 add ax, BS3_SEL_R0_SS32
165 mov ss, ax
166 jmp .stack_flat
167.stack_thunk:
168 mov di, ss
169 and edi, X86_SEL_MASK_OFF_RPL
170 mov al, [X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8 + edi + Bs3Gdt wrt FLAT]
171 mov ah, [X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8 + edi + Bs3Gdt wrt FLAT]
172 shl eax, 16
173 mov ax, [X86DESCGENERIC_BIT_OFF_BASE_LOW / 8 + edi + Bs3Gdt wrt FLAT] ; eax = SS.base
174 movzx ebp, bp ; SS:BP -> flat EBP.
175 add ebp, eax
176 movzx edi, sp ; SS:SP -> flat ESP in EAX.
177 add edi, eax
178 mov ax, ss
179 and al, 3
180 AssertCompile(BS3_SEL_RING_SHIFT == 8)
181 mov ah, al
182 add ax, BS3_SEL_R0_SS32
183 mov ss, ax
184 mov esp, edi
185 sub dword [ebp - 10h], (4+1)*4 ; Recalc handler ESP in case of wraparound.
186 add word [ebp - 10h], (4+1)*4
187 sub dword [ebp - 10h], (4+1+3)*4 ; Recalc caller ESP in case of wraparound.
188 add word [ebp - 10h], (4+1+3)*4
189.stack_flat:
190
191 ; Reserve space for the the register and trap frame.
192 mov eax, (BS3TRAPFRAME_size + 7) / 8
193AssertCompileSizeAlignment(BS3TRAPFRAME, 8)
194.more_zeroed_space:
195 push dword 0
196 push dword 0
197 dec eax
198 jnz .more_zeroed_space
199 mov edi, esp ; edi points to trapframe structure.
200
201 ; Copy stuff from the stack over.
202 mov eax, [ebp + 8]
203;; @todo Do voodoo checks for 'int xx' or misguided hardware interrupts.
204 mov [edi + BS3TRAPFRAME.uErrCd], eax
205 mov al, [ebp + 4]
206 mov [edi + BS3TRAPFRAME.bXcpt], al
207 mov eax, [ebp]
208 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], eax
209 mov eax, [ebp - 04h]
210 mov [edi + BS3TRAPFRAME.fHandlerRfl], eax
211 mov eax, [ebp - 08h]
212 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], eax
213 mov eax, [ebp - 0ch]
214 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], eax
215 mov eax, [ebp - 10h]
216 mov [edi + BS3TRAPFRAME.uHandlerRsp], eax
217 mov eax, [ebp - 14h]
218 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], eax
219 mov ax, [ebp - 18h]
220 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], ax
221 mov [edi + BS3TRAPFRAME.uHandlerSs], ax
222 mov ax, [ebp - 1ch]
223 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], ax
224
225 lea ebp, [ebp + 8] ; iret - 4 (i.e. ebp frame chain location)
226 jmp bs3Trap32GenericCommon
227BS3_PROC_END bs3Trap32GenericTrapErrCode
228
229
230;;
231; Common context saving code and dispatching.
232;
233; @param edi Pointer to the trap frame. The following members have been
234; filled in by the previous code:
235; - bXcpt
236; - uErrCd
237; - fHandlerRfl
238; - uHandlerRsp
239; - uHandlerSs
240; - Ctx.rax
241; - Ctx.rbp
242; - Ctx.rdi
243; - Ctx.rsp - assuming same CPL
244; - Ctx.ds
245; - Ctx.ss
246;
247; @param ebp Pointer to the dword before the iret frame, i.e. where ebp
248; would be saved if this was a normal call.
249;
250; @remarks This is a separate function for hysterical raisins.
251;
252BS3_PROC_BEGIN bs3Trap32GenericCommon
253 ;
254 ; Fake EBP frame.
255 ;
256 mov eax, [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp]
257 mov [ebp], eax
258
259 ;
260 ; Save the remaining GPRs and segment registers.
261 ;
262 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx
263 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], edx
264 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ebx
265 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], esi
266 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.es], es
267 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], fs
268 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], gs
269
270 ;
271 ; Load 32-bit data selector for the DPL we're executing at into DS and ES.
272 ; Save the handler CS value first.
273 ;
274 mov ax, cs
275 mov [edi + BS3TRAPFRAME.uHandlerCs], ax
276 and al, 3
277 AssertCompile(BS3_SEL_RING_SHIFT == 8)
278 mov ah, al
279 add ax, BS3_SEL_R0_DS32
280 mov ds, ax
281 mov es, ax
282
283 ;
284 ; Copy and update the mode now that we've got a flat DS.
285 ;
286 mov al, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
287 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], al
288 and al, ~BS3_MODE_CODE_MASK
289 or al, BS3_MODE_CODE_32
290 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], al
291
292 ;
293 ; Copy iret info.
294 ;
295 mov ecx, [ebp + 4]
296 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx
297 mov ecx, [ebp + 12]
298 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx
299 mov cx, [ebp + 8]
300 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
301 test dword [ebp + 12], X86_EFL_VM
302 jnz .iret_frame_v8086
303 mov ax, ss
304 and al, 3
305 and cl, 3
306 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl
307 cmp cl, al
308 je .iret_frame_same_cpl
309
310.iret_frame_different_cpl:
311 mov ecx, [ebp + 16]
312 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
313 mov cx, [ebp + 20]
314 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
315 mov byte [edi + BS3TRAPFRAME.cbIretFrame], 5*4
316 jmp .iret_frame_done
317
318.iret_frame_v8086:
319 mov byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], 3
320 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], BS3_MODE_CODE_V86 ; paranoia ^ 2
321 movzx ecx, word [ebp + 16]
322 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
323 mov cx, [ebp + 20]
324 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
325 mov cx, [ebp + 24]
326 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
327 mov cx, [ebp + 28]
328 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
329 mov cx, [ebp + 32]
330 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx
331 mov cx, [ebp + 36]
332 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx
333 mov byte [edi + BS3TRAPFRAME.cbIretFrame], 9*4
334 jmp .iret_frame_done
335
336.iret_frame_same_cpl: ; (caller already set SS:RSP and uHandlerRsp for same CPL iret frames)
337 mov byte [edi + BS3TRAPFRAME.cbIretFrame], 3*4
338
339.iret_frame_done:
340 ;
341 ; Control registers.
342 ;
343 str ax
344 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax
345 sldt ax
346 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], ax
347
348 mov ax, ss
349 test al, 3
350 jnz .skip_crX_because_cpl_not_0
351
352 mov eax, cr0
353 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], eax
354 mov eax, cr2
355 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], eax
356 mov eax, cr3
357 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], eax
358 mov eax, cr4
359 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], eax
360 jmp .dispatch_to_handler
361.skip_crX_because_cpl_not_0:
362 or byte [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR
363
364 ;
365 ; Dispatch it to C code.
366 ;
367.dispatch_to_handler: ; The double fault code joins us here.
368 movzx ebx, byte [edi + BS3TRAPFRAME.bXcpt]
369 mov eax, [ebx * 4 + BS3_DATA16_WRT(_g_apfnBs3TrapHandlers_c32)]
370 or eax, eax
371 jnz .call_handler
372 mov eax, Bs3TrapDefaultHandler
373.call_handler:
374 push edi
375 call eax
376
377 ;
378 ; Resume execution using trap frame.
379 ;
380 push 0
381 add edi, BS3TRAPFRAME.Ctx
382 push edi
383 call Bs3RegCtxRestore
384.panic:
385 hlt
386 jmp .panic
387BS3_PROC_END bs3Trap32GenericCommon
388
389
390;;
391; Helper.
392;
393; @retruns Flat address in eax.
394; @param ax
395; @uses eax
396;
397bs3Trap32TssInAxToFlatInEax:
398 ; Get the GDT base address and find the descriptor address (EAX)
399 sub esp, 8+2
400 sgdt [esp]
401 and eax, 0fff8h
402 add eax, [esp + 2] ; GDT base address.
403 add esp, 8+2
404
405 ; Get the flat TSS address from the descriptor.
406 mov al, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH1 / 8)]
407 mov ah, [eax + (X86DESCGENERIC_BIT_OFF_BASE_HIGH2 / 8)]
408 shl eax, 16
409 mov ax, [eax + (X86DESCGENERIC_BIT_OFF_BASE_LOW / 8)]
410 ret
411
412;;
413; Double fault handler.
414;
415; We don't have to load any selectors or clear anything in EFLAGS because the
416; TSS specified sane values which got loaded during the task switch.
417;
418BS3_PROC_BEGIN Bs3Trap32DoubleFaultHandler
419 push 0 ; We'll copy the rip from the other TSS here later to create a more sensible call chain.
420 push ebp
421 mov ebp, esp
422
423 pushfd ; Get handler flags.
424 pop ecx
425
426 xor edx, edx ; NULL register.
427
428 ;
429 ; Allocate a zero filled trap frame.
430 ;
431 mov eax, (BS3TRAPFRAME_size + 7) / 8
432AssertCompileSizeAlignment(BS3TRAPFRAME, 8)
433.more_zeroed_space:
434 push edx
435 push edx
436 dec eax
437 jz .more_zeroed_space
438 mov edi, esp
439
440 ;
441 ; Fill in the non-context trap frame bits.
442 ;
443 mov [edi + BS3TRAPFRAME.fHandlerRfl], ecx
444 mov word [edi + BS3TRAPFRAME.bXcpt], X86_XCPT_DF
445 mov [edi + BS3TRAPFRAME.uHandlerCs], cs
446 mov [edi + BS3TRAPFRAME.uHandlerSs], ss
447 lea ecx, [ebp + 3*4] ; two pushes, one error code.
448 mov [edi + BS3TRAPFRAME.uHandlerRsp], ecx
449 mov ecx, [ebp + 8]
450 mov [edi + BS3TRAPFRAME.uErrCd], ecx
451
452 ;
453 ; Copy the register state from the previous task segment.
454 ;
455
456 ; Find our TSS.
457 str ax
458 call bs3Trap32TssInAxToFlatInEax
459
460 ; Find the previous TSS.
461 mov ax, [eax + X86TSS32.selPrev]
462 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.tr], ax
463 call bs3Trap32TssInAxToFlatInEax
464
465 ; Do the copying.
466 mov ecx, [eax + X86TSS32.eax]
467 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rax], ecx
468 mov ecx, [eax + X86TSS32.ecx]
469 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rcx], ecx
470 mov ecx, [eax + X86TSS32.edx]
471 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdx], ecx
472 mov ecx, [eax + X86TSS32.ebx]
473 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbx], ecx
474 mov ecx, [eax + X86TSS32.esp]
475 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsp], ecx
476 mov ecx, [eax + X86TSS32.ebp]
477 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rbp], ecx
478 mov [ebp], ecx ; For better call stacks.
479 mov ecx, [eax + X86TSS32.esi]
480 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx
481 mov ecx, [eax + X86TSS32.edi]
482 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rdi], ecx
483 mov ecx, [eax + X86TSS32.esi]
484 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rsi], ecx
485 mov ecx, [eax + X86TSS32.eflags]
486 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rflags], ecx
487 mov ecx, [eax + X86TSS32.eip]
488 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.rip], ecx
489 mov [ebp + 4], ecx ; For better call stacks.
490 mov cx, [eax + X86TSS32.cs]
491 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cs], cx
492 mov cx, [eax + X86TSS32.ds]
493 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ds], cx
494 mov cx, [eax + X86TSS32.es]
495 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.es], cx
496 mov cx, [eax + X86TSS32.fs]
497 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.fs], cx
498 mov cx, [eax + X86TSS32.gs]
499 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.gs], cx
500 mov cx, [eax + X86TSS32.ss]
501 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss], cx
502 mov cx, [eax + X86TSS32.selLdt] ; Note! This isn't necessarily the ldtr at the time of the fault.
503 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ldtr], cx
504 mov cx, [eax + X86TSS32.cr3] ; Note! This isn't necessarily the cr3 at the time of the fault.
505 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr3], ecx
506
507 ;
508 ; Set CPL; copy and update mode.
509 ;
510 mov cl, [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.ss]
511 and cl, 3
512 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bCpl], cl
513
514 mov cl, [BS3_DATA16_WRT(g_bBs3CurrentMode)]
515 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.bMode], cl
516 and cl, ~BS3_MODE_CODE_MASK
517 or cl, BS3_MODE_CODE_32
518 mov [BS3_DATA16_WRT(g_bBs3CurrentMode)], cl
519
520 ;
521 ; Control registers.
522 ;
523 mov ecx, cr0
524 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr0], ecx
525 mov ecx, cr2
526 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr2], ecx
527 mov ecx, cr4
528 mov [edi + BS3TRAPFRAME.Ctx + BS3REGCTX.cr4], ecx
529
530 ;
531 ; Join code paths with the generic handler code.
532 ;
533 jmp bs3Trap32GenericCommon.dispatch_to_handler
534BS3_PROC_END Bs3Trap32DoubleFaultHandler
535
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