1 #------------------------------------------------------------------------------
3 # Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
4 # This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php.
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 # Debug interrupt handle functions.
20 #------------------------------------------------------------------------------
22 #include "DebugException.h"
24 ASM_GLOBAL ASM_PFX(InterruptProcess)
25 ASM_GLOBAL ASM_PFX(Exception0Handle)
26 ASM_GLOBAL ASM_PFX(ExceptionStubHeaderSize)
27 ASM_GLOBAL ASM_PFX(TimerInterruptHandle)
28 ASM_GLOBAL ASM_PFX(CommonEntry)
32 ASM_PFX(ExceptionStubHeaderSize): .word ASM_PFX(Exception1Handle) - ASM_PFX(Exception0Handle)
36 ASM_PFX(Exception0Handle):
40 jmp ASM_PFX(CommonEntry)
41 ASM_PFX(Exception1Handle):
45 jmp ASM_PFX(CommonEntry)
46 ASM_PFX(Exception2Handle):
50 jmp ASM_PFX(CommonEntry)
51 ASM_PFX(Exception3Handle):
55 jmp ASM_PFX(CommonEntry)
56 ASM_PFX(Exception4Handle):
60 jmp ASM_PFX(CommonEntry)
61 ASM_PFX(Exception5Handle):
65 jmp ASM_PFX(CommonEntry)
66 ASM_PFX(Exception6Handle):
70 jmp ASM_PFX(CommonEntry)
71 ASM_PFX(Exception7Handle):
75 jmp ASM_PFX(CommonEntry)
76 ASM_PFX(Exception8Handle):
80 jmp ASM_PFX(CommonEntry)
81 ASM_PFX(Exception9Handle):
85 jmp ASM_PFX(CommonEntry)
86 ASM_PFX(Exception10Handle):
90 jmp ASM_PFX(CommonEntry)
91 ASM_PFX(Exception11Handle):
95 jmp ASM_PFX(CommonEntry)
96 ASM_PFX(Exception12Handle):
100 jmp ASM_PFX(CommonEntry)
101 ASM_PFX(Exception13Handle):
105 jmp ASM_PFX(CommonEntry)
106 ASM_PFX(Exception14Handle):
110 jmp ASM_PFX(CommonEntry)
111 ASM_PFX(Exception15Handle):
115 jmp ASM_PFX(CommonEntry)
116 ASM_PFX(Exception16Handle):
120 jmp ASM_PFX(CommonEntry)
121 ASM_PFX(Exception17Handle):
125 jmp ASM_PFX(CommonEntry)
126 ASM_PFX(Exception18Handle):
130 jmp ASM_PFX(CommonEntry)
131 ASM_PFX(Exception19Handle):
135 jmp ASM_PFX(CommonEntry)
137 ASM_PFX(TimerInterruptHandle):
141 jmp ASM_PFX(CommonEntry)
144 ASM_PFX(CommonEntry):
146 #---------------------------------------;
148 #----------------------------------------------------------------------------;
149 # The follow algorithm is used for the common interrupt routine.
150 # Entry from each interrupt with a push eax and eax=interrupt number
152 # +---------------------+
154 # +---------------------+
156 # +---------------------+
158 # +---------------------+
160 # +---------------------+
161 # + EAX / Vector Number +
162 # +---------------------+
164 # +---------------------+ <-- EBP
167 # We need to determine if any extra data was pushed by the exception
168 cmpl $DEBUG_EXCEPT_DOUBLE_FAULT, %eax
170 cmpl $DEBUG_EXCEPT_INVALID_TSS, %eax
172 cmpl $DEBUG_EXCEPT_SEG_NOT_PRESENT, %eax
174 cmpl $DEBUG_EXCEPT_STACK_FAULT, %eax
176 cmpl $DEBUG_EXCEPT_GP_FAULT, %eax
178 cmpl $DEBUG_EXCEPT_PAGE_FAULT, %eax
180 cmpl $DEBUG_EXCEPT_ALIGNMENT_CHECK, %eax
192 # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32
195 andl $0xfffffff0,%esp
198 ## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
203 mov %eax, %ebx # save vector in ebx
205 pushl %ecx # save original ESP
210 ## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
224 ## UINT32 Gs, Fs, Es, Ds, Cs, Ss;
227 movzwl 16(%ebp), %eax
241 ## UINT32 Gdtr[2], Idtr[2];
257 ## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
260 ## clear Dr7 while executing debugger itself
266 ## insure all status bits in dr6 are clear...
279 ## FX_SAVE_STATE_IA32 FxSaveState;
282 .byte 0x0f, 0xae, 0x07 # fxsave [edi]
284 ## Clear Direction Flag
287 ## Prepare parameter and call C function
290 call ASM_PFX(InterruptProcess)
293 ## FX_SAVE_STATE_IA32 FxSaveState;
295 .byte 0x0f, 0xae, 0x0e # fxrstor [esi]
298 ## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
307 ## skip restore of dr6. We cleared dr6 during the context save.
316 ## UINT32 Gdtr[2], Idtr[2];
317 ## Best not let anyone mess with these particular registers...
323 ## UINT32 Gs, Fs, Es, Ds, Cs, Ss;
324 ## NOTE - modified segment registers could hang the debugger... We
325 ## could attempt to insulate ourselves against this possibility,
326 ## but that poses risks as well.
335 ## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
338 addl $4,%esp # not for Cr1
346 ## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
349 addl $4,%esp # not for ebp
350 addl $4,%esp # not for esp
358 addl $8,%esp # skip eax