if DBG
ifndef _Ki16BitStackException
EXTRNP _Ki16BitStackException
endif
endif ; DBG
mov word ptr [esp+2], 0 ; Clear upper word of ErrorCode
push ebp ; Save the non-volatile registers
push ebx
push esi
push edi
push fs ; Save and set FS to PCR.
mov ebx,KGDT_R0_PCR
mov fs,bx
mov ebx, fs:[PcExceptionList] ;Save ExceptionList
push ebx
if DBG
push -1 ; Don't need to save ThPreviousMode from trap
else
sub esp, 4 ; pad dword
endif
push eax ; Save the volatile registers
push ecx
push edx
push ds ; Save segments
push es
push gs
;
; Skip allocate reset of trap frame and Set up DS/ES, they may be trash
;
mov ax,KGDT_R3_DATA OR RPL_MASK
sub esp,TsSegGs
mov ds,ax
mov es,ax
if DBG
;
; The code here check if the exception occurred in ring 0
; ABIOS code. If yes, this is a fatal condition. We will
; put out message and bugcheck.
;
cmp esp, 10000h ; Is the trap in abios?
jb _Ki16BitStackException ; if b, yes, switch stack and bugcheck.
endif ; DBG
mov ebp,esp
test dword ptr [esp].TsEflags,EFLAGS_V86_MASK
jnz V86_&AssistLabel
V86_&TargetLabel:
ifdef PcPrcbData
mov ecx,PCR[PcPrcbData+PbCurrentThread] ; get current thread address
else
mov ecx,PCR[PcPrcb]
mov ecx,[ecx].PbCurrentThread ; get current thread address
endif
cld
and dword ptr [ebp].TsDr7, 0
test byte ptr [ecx].ThDebugActive, 0ffh ; See if debug registers need saving