2 # ConvertAsm.py: Automatically generated from CpuAsm.asm
6 #------------------------------------------------------------------------------
8 #* Copyright 2006 - 2009, Intel Corporation
9 #* All rights reserved. This program and the accompanying materials
10 #* are licensed and made available under the terms and conditions of the BSD License
11 #* which accompanies this distribution. The full text of the license may be found at
12 #* http://opensource.org/licenses/bsd-license.php
14 #* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 #* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #------------------------------------------------------------------------------
27 #EXTRN ASM_PFX(mErrorCodeFlag):DWORD # Error code flags for exceptions
31 # point to the external interrupt vector table
33 ExternalVectorTablePtr:
37 ASM_GLOBAL ASM_PFX(InitializeExternalVectorTablePtr)
38 ASM_PFX(InitializeExternalVectorTablePtr):
40 mov ExternalVectorTablePtr, eax
43 #------------------------------------------------------------------------------
48 #------------------------------------------------------------------------------
50 ASM_GLOBAL ASM_PFX(SetCodeSelector)
51 ASM_PFX(SetCodeSelector):
54 lea %eax, setCodeSelectorLongJump
58 setCodeSelectorLongJump:
62 #------------------------------------------------------------------------------
67 #------------------------------------------------------------------------------
69 ASM_GLOBAL ASM_PFX(SetDataSelectors)
70 ASM_PFX(SetDataSelectors):
79 #---------------------------------------;
80 # CommonInterruptEntry ;
81 #---------------------------------------;
82 # The follow algorithm is used for the common interrupt routine.
85 ASM_GLOBAL ASM_PFX(CommonInterruptEntry)
86 ASM_PFX(CommonInterruptEntry):
89 # All interrupt handlers are invoked through interrupt gates, so
90 # IF flag automatically cleared at the entry point
94 # Calculate vector number
96 # Get the return address of call, actually, it is the
97 # address of vector number.
102 cmp ecx, 32 # Intel reserved vector for exceptions?
104 bt ASM_PFX(mErrorCodeFlag), ecx
111 # +---------------------+
113 # +---------------------+
115 # +---------------------+
117 # +---------------------+
119 # +---------------------+ <-- ESP
122 # ECX - Vector Number
126 # Put Vector Number on stack
131 # Put 0 (dummy) error code on stack, and restore ECX
133 xor ecx, ecx # ECX = 0
136 jmp ErrorCodeAndVectorOnStack
142 # +---------------------+
144 # +---------------------+
146 # +---------------------+
148 # +---------------------+
150 # +---------------------+
152 # +---------------------+ <-- ESP
155 # ECX - Vector Number
159 # Put Vector Number on stack and restore ECX
164 # Fall through to join main routine code
165 # at ErrorCodeAndVectorOnStack
167 CommonInterruptEntry_al_0000:
168 jmp CommonInterruptEntry_al_0000
170 ErrorCodeAndVectorOnStack:
176 # +---------------------+
178 # +---------------------+
180 # +---------------------+
182 # +---------------------+
184 # +---------------------+
186 # +---------------------+
188 # +---------------------+ <-- EBP
192 # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32
198 #; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
203 lea ecx, [ebp + 6 * 4]
205 push dword ptr [ebp] # EBP
209 #; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
212 movzx eax, word ptr [ebp + 4 * 4]
224 mov eax, [ebp + 3 * 4]
227 #; UINT32 Gdtr[2], Idtr[2];
250 mov eax, [ebp + 5 * 4]
253 #; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
267 #; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
270 #; clear Dr7 while executing debugger itself
276 #; insure all status bits in dr6 are clear...
289 #; FX_SAVE_STATE_IA32 FxSaveState;
292 .byte 0x0f, 0x0ae, 0x07 #fxsave [edi]
294 #; UINT32 ExceptionData;
295 push dword ptr [ebp + 2 * 4]
297 #; call into exception handler
298 mov eax, ExternalVectorTablePtr # get the interrupt vectors base
300 jz nullExternalExceptionHandler
303 mov eax, [eax + ecx * 4]
305 jz nullExternalExceptionHandler
307 #; Prepare parameter and call
310 mov edx, dword ptr [ebp + 1 * 4]
314 # Call External Exception Handler
319 nullExternalExceptionHandler:
322 #; UINT32 ExceptionData;
325 #; FX_SAVE_STATE_IA32 FxSaveState;
327 .byte 0x0f, 0x0ae, 0x0e # fxrstor [esi]
330 #; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
339 #; skip restore of dr6. We cleared dr6 during the context save.
344 #; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
347 add esp, 4 # not for Cr1
356 pop dword ptr [ebp + 5 * 4]
359 #; UINT32 Gdtr[2], Idtr[2];
360 #; Best not let anyone mess with these particular registers...
364 pop dword ptr [ebp + 3 * 4]
366 #; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
367 #; NOTE - modified segment registers could hang the debugger... We
368 #; could attempt to insulate ourselves against this possibility,
369 #; but that poses risks as well.
375 pop dword ptr [ebp + 4 * 4]
378 #; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
381 add esp, 4 # not for ebp
382 add esp, 4 # not for esp