UefiCpuPkg/CpuExceptionHandlerLib: Trim white space at end of line

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
This commit is contained in:
Jeff Fan
2017-04-07 10:00:59 +08:00
parent c54a6e6feb
commit dd56374250
21 changed files with 152 additions and 152 deletions

View File

@ -1,4 +1,4 @@
/** @file /** @file
CPU Exception Handler Library common functions. CPU Exception Handler Library common functions.
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
@ -106,11 +106,11 @@ InternalPrintMessage (
/** /**
Find and display image base address and return image base and its entry point. Find and display image base address and return image base and its entry point.
@param CurrentEip Current instruction pointer. @param CurrentEip Current instruction pointer.
**/ **/
VOID VOID
DumpModuleImageInfo ( DumpModuleImageInfo (
IN UINTN CurrentEip IN UINTN CurrentEip
) )

View File

@ -108,7 +108,7 @@ ArchGetIdtHandler (
Prints a message to the serial port. Prints a message to the serial port.
@param Format Format string for the message to print. @param Format Format string for the message to print.
@param ... Variable argument list whose contents are accessed @param ... Variable argument list whose contents are accessed
based on the format string specified by Format. based on the format string specified by Format.
**/ **/
@ -121,11 +121,11 @@ InternalPrintMessage (
/** /**
Find and display image base address and return image base and its entry point. Find and display image base address and return image base and its entry point.
@param CurrentEip Current instruction pointer. @param CurrentEip Current instruction pointer.
**/ **/
VOID VOID
DumpModuleImageInfo ( DumpModuleImageInfo (
IN UINTN CurrentEip IN UINTN CurrentEip
); );
@ -147,8 +147,8 @@ DumpImageAndCpuContent (
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@param[in, out] ExceptionHandlerData Pointer to exception handler data. @param[in, out] ExceptionHandlerData Pointer to exception handler data.
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers. with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -230,7 +230,7 @@ ArchRestoreExceptionContext (
/** /**
Fix up the vector number and function address in the vector code. Fix up the vector number and function address in the vector code.
@param[in] NewVectorAddr New vector handler address. @param[in] NewVectorAddr New vector handler address.
@param[in] VectorNum Index of vector. @param[in] VectorNum Index of vector.
@param[in] OldVectorAddr Old vector handler address. @param[in] OldVectorAddr Old vector handler address.
@ -246,11 +246,11 @@ AsmVectorNumFixup (
/** /**
Read and save reserved vector information Read and save reserved vector information
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@param[out] ReservedVector Pointer to reserved vector data buffer. @param[out] ReservedVector Pointer to reserved vector data buffer.
@param[in] VectorCount Vector number to be updated. @param[in] VectorCount Vector number to be updated.
@return EFI_SUCCESS Read and save vector info successfully. @return EFI_SUCCESS Read and save vector info successfully.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@ -283,7 +283,7 @@ GetExceptionNameStr (
**/ **/
VOID VOID
CommonExceptionHandlerWorker ( CommonExceptionHandlerWorker (
IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext, IN EFI_SYSTEM_CONTEXT SystemContext,
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
); );

View File

@ -6,10 +6,10 @@
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]
@ -58,6 +58,6 @@
PrintLib PrintLib
SynchronizationLib SynchronizationLib
LocalApicLib LocalApicLib
PeCoffGetEntryPointLib PeCoffGetEntryPointLib
MemoryAllocationLib MemoryAllocationLib
DebugLib DebugLib

View File

@ -9,7 +9,7 @@
// are licensed and made available under the terms and conditions of the BSD License // are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //

View File

@ -34,7 +34,7 @@ EXCEPTION_HANDLER_DATA mExceptionHandlerData;
VOID VOID
EFIAPI EFIAPI
CommonExceptionHandler ( CommonExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext IN EFI_SYSTEM_CONTEXT SystemContext
) )
{ {
@ -43,15 +43,15 @@ CommonExceptionHandler (
/** /**
Initializes all CPU exceptions entries and provides the default exception handlers. Initializes all CPU exceptions entries and provides the default exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers. with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -71,15 +71,15 @@ InitializeCpuExceptionHandlers (
/** /**
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized
with default interrupt/exception handlers. with default interrupt/exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -135,7 +135,7 @@ InitializeCpuInterruptHandlers (
ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE); ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE);
InterruptEntryCode = AllocatePool (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM); InterruptEntryCode = AllocatePool (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM);
ASSERT (InterruptEntryCode != NULL); ASSERT (InterruptEntryCode != NULL);
InterruptEntry = (UINTN) InterruptEntryCode; InterruptEntry = (UINTN) InterruptEntryCode;
for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) { for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) {
CopyMem ( CopyMem (
@ -168,9 +168,9 @@ InitializeCpuInterruptHandlers (
/** /**
Registers a function to be called from the processor interrupt handler. Registers a function to be called from the processor interrupt handler.
This function registers and enables the handler specified by InterruptHandler for a processor This function registers and enables the handler specified by InterruptHandler for a processor
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
handler for the processor interrupt or exception type specified by InterruptType is uninstalled. handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
The installed handler is called once for each processor interrupt or exception. The installed handler is called once for each processor interrupt or exception.
NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or
InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.

View File

@ -76,7 +76,7 @@ ArchSaveExceptionContext (
// Clear IF flag to avoid old IDT handler enable interrupt by IRET // Clear IF flag to avoid old IDT handler enable interrupt by IRET
// //
Eflags.UintN = SystemContext.SystemContextIa32->Eflags; Eflags.UintN = SystemContext.SystemContextIa32->Eflags;
Eflags.Bits.IF = 0; Eflags.Bits.IF = 0;
SystemContext.SystemContextIa32->Eflags = Eflags.UintN; SystemContext.SystemContextIa32->Eflags = Eflags.UintN;
// //
// Modify the EIP in stack, then old IDT handler will return to the stub code // Modify the EIP in stack, then old IDT handler will return to the stub code

View File

@ -357,7 +357,7 @@ HasErrorCode:
# #
# Put Vector Number on stack and restore ECX # Put Vector Number on stack and restore ECX
# #
xchgl (%esp), %ecx xchgl (%esp), %ecx
ErrorCodeAndVectorOnStack: ErrorCodeAndVectorOnStack:
pushl %ebp pushl %ebp
@ -384,13 +384,13 @@ ErrorCodeAndVectorOnStack:
# Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32 # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32
# is 16-byte aligned # is 16-byte aligned
# #
andl $0x0fffffff0, %esp andl $0x0fffffff0, %esp
subl $12, %esp subl $12, %esp
subl $8, %esp subl $8, %esp
pushl $0 # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler pushl $0 # check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
pushl $0 # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag pushl $0 # check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag
#; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; #; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
pushl %eax pushl %eax
pushl %ecx pushl %ecx
@ -405,7 +405,7 @@ ErrorCodeAndVectorOnStack:
#; UINT32 Gs, Fs, Es, Ds, Cs, Ss; #; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
movl %ss, %eax movl %ss, %eax
pushl %eax pushl %eax
movzwl 16(%ebp), %eax movzwl 16(%ebp), %eax
pushl %eax pushl %eax
movl %ds, %eax movl %ds, %eax
pushl %eax pushl %eax
@ -425,14 +425,14 @@ ErrorCodeAndVectorOnStack:
sidt (%esp) sidt (%esp)
movl 2(%esp), %eax movl 2(%esp), %eax
xchgl (%esp), %eax xchgl (%esp), %eax
andl $0x0FFFF, %eax andl $0x0FFFF, %eax
movl %eax, 4(%esp) movl %eax, 4(%esp)
subl $8, %esp subl $8, %esp
sgdt (%esp) sgdt (%esp)
movl 2(%esp), %eax movl 2(%esp), %eax
xchgl (%esp), %eax xchgl (%esp), %eax
andl $0x0FFFF, %eax andl $0x0FFFF, %eax
movl %eax, 4(%esp) movl %eax, 4(%esp)
#; UINT32 Ldtr, Tr; #; UINT32 Ldtr, Tr;
@ -450,21 +450,21 @@ ErrorCodeAndVectorOnStack:
## insure FXSAVE/FXRSTOR is enabled in CR4... ## insure FXSAVE/FXRSTOR is enabled in CR4...
## ... while we're at it, make sure DE is also enabled... ## ... while we're at it, make sure DE is also enabled...
mov $1, %eax mov $1, %eax
pushl %ebx # temporarily save value of ebx on stack pushl %ebx # temporarily save value of ebx on stack
cpuid # use CPUID to determine if FXSAVE/FXRESTOR cpuid # use CPUID to determine if FXSAVE/FXRESTOR
# and DE are supported # and DE are supported
popl %ebx # retore value of ebx that was overwritten popl %ebx # retore value of ebx that was overwritten
# by CPUID # by CPUID
movl %cr4, %eax movl %cr4, %eax
pushl %eax # push cr4 firstly pushl %eax # push cr4 firstly
testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support
jz L1 jz L1
orl $BIT9, %eax # Set CR4.OSFXSR orl $BIT9, %eax # Set CR4.OSFXSR
L1: L1:
testl $BIT2, %edx # Test for Debugging Extensions support testl $BIT2, %edx # Test for Debugging Extensions support
jz L2 jz L2
orl $BIT3, %eax # Set CR4.DE orl $BIT3, %eax # Set CR4.DE
L2: L2:
movl %eax, %cr4 movl %eax, %cr4
movl %cr3, %eax movl %cr3, %eax
pushl %eax pushl %eax
@ -492,11 +492,11 @@ L2:
#; FX_SAVE_STATE_IA32 FxSaveState; #; FX_SAVE_STATE_IA32 FxSaveState;
subl $512, %esp subl $512, %esp
movl %esp, %edi movl %esp, %edi
testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support. testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support.
# edx still contains result from CPUID above # edx still contains result from CPUID above
jz L3 jz L3
.byte 0x0f, 0x0ae, 0x07 #fxsave [edi] .byte 0x0f, 0x0ae, 0x07 #fxsave [edi]
L3: L3:
#; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear #; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear
cld cld
@ -523,12 +523,12 @@ L3:
#; FX_SAVE_STATE_IA32 FxSaveState; #; FX_SAVE_STATE_IA32 FxSaveState;
movl %esp, %esi movl %esp, %esi
movl $1, %eax movl $1, %eax
cpuid # use CPUID to determine if FXSAVE/FXRESTOR cpuid # use CPUID to determine if FXSAVE/FXRESTOR
# are supported # are supported
testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support testl $BIT24, %edx # Test for FXSAVE/FXRESTOR support
jz L4 jz L4
.byte 0x0f, 0x0ae, 0x0e # fxrstor [esi] .byte 0x0f, 0x0ae, 0x0e # fxrstor [esi]
L4: L4:
addl $512, %esp addl $512, %esp
#; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; #; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
@ -612,30 +612,30 @@ DoIret:
#---------------------------------------; #---------------------------------------;
# _AsmGetTemplateAddressMap ; # _AsmGetTemplateAddressMap ;
#---------------------------------------; #---------------------------------------;
# #
# Protocol prototype # Protocol prototype
# AsmGetTemplateAddressMap ( # AsmGetTemplateAddressMap (
# EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap # EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap
# ); # );
# #
# Routine Description: # Routine Description:
# #
# Return address map of interrupt handler template so that C code can generate # Return address map of interrupt handler template so that C code can generate
# interrupt table. # interrupt table.
# #
# Arguments: # Arguments:
# #
# #
# Returns: # Returns:
# #
# Nothing # Nothing
# #
# #
# Input: [ebp][0] = Original ebp # Input: [ebp][0] = Original ebp
# [ebp][4] = Return address # [ebp][4] = Return address
# #
# Output: Nothing # Output: Nothing
# #
# Destroys: Nothing # Destroys: Nothing
#-----------------------------------------------------------------------------; #-----------------------------------------------------------------------------;
#------------------------------------------------------------------------------------- #-------------------------------------------------------------------------------------

View File

@ -53,7 +53,7 @@ AsmIdtVectorEnd:
HookAfterStubBegin: HookAfterStubBegin:
db 6ah ; push db 6ah ; push
VectorNum: VectorNum:
db 0 ; 0 will be fixed db 0 ; 0 will be fixed
push eax push eax
mov eax, HookAfterStubHeaderEnd mov eax, HookAfterStubHeaderEnd
jmp eax jmp eax
@ -193,7 +193,7 @@ ErrorCodeAndVectorOnStack:
sub esp, 8 sub esp, 8
push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax; ;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
push eax push eax
push ecx push ecx
@ -251,20 +251,20 @@ ErrorCodeAndVectorOnStack:
;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4; ;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
mov eax, 1 mov eax, 1
push ebx ; temporarily save value of ebx on stack push ebx ; temporarily save value of ebx on stack
cpuid ; use CPUID to determine if FXSAVE/FXRESTOR and DE cpuid ; use CPUID to determine if FXSAVE/FXRESTOR and DE
; are supported ; are supported
pop ebx ; retore value of ebx that was overwritten by CPUID pop ebx ; retore value of ebx that was overwritten by CPUID
mov eax, cr4 mov eax, cr4
push eax ; push cr4 firstly push eax ; push cr4 firstly
test edx, BIT24 ; Test for FXSAVE/FXRESTOR support test edx, BIT24 ; Test for FXSAVE/FXRESTOR support
jz @F jz @F
or eax, BIT9 ; Set CR4.OSFXSR or eax, BIT9 ; Set CR4.OSFXSR
@@: @@:
test edx, BIT2 ; Test for Debugging Extensions support test edx, BIT2 ; Test for Debugging Extensions support
jz @F jz @F
or eax, BIT3 ; Set CR4.DE or eax, BIT3 ; Set CR4.DE
@@: @@:
mov cr4, eax mov cr4, eax
mov eax, cr3 mov eax, cr3
push eax push eax
@ -296,7 +296,7 @@ ErrorCodeAndVectorOnStack:
; edx still contains result from CPUID above ; edx still contains result from CPUID above
jz @F jz @F
db 0fh, 0aeh, 07h ;fxsave [edi] db 0fh, 0aeh, 07h ;fxsave [edi]
@@: @@:
;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear ;; UEFI calling convention for IA32 requires that Direction flag in EFLAGs is clear
cld cld
@ -329,7 +329,7 @@ ErrorCodeAndVectorOnStack:
test edx, BIT24 ; Test for FXSAVE/FXRESTOR support test edx, BIT24 ; Test for FXSAVE/FXRESTOR support
jz @F jz @F
db 0fh, 0aeh, 0eh ; fxrstor [esi] db 0fh, 0aeh, 0eh ; fxrstor [esi]
@@: @@:
add esp, 512 add esp, 512
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; ;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
@ -395,7 +395,7 @@ ErrorCode:
sub esp, 4 sub esp, 4
jmp dword ptr [esp - 12] jmp dword ptr [esp - 12]
DoReturn: DoReturn:
cmp mDoFarReturnFlag, 0 ; Check if need to do far return instead of IRET cmp mDoFarReturnFlag, 0 ; Check if need to do far return instead of IRET
jz DoIret jz DoIret
push [esp + 8] ; save EFLAGS push [esp + 8] ; save EFLAGS
@ -414,30 +414,30 @@ CommonInterruptEntry ENDP
;---------------------------------------; ;---------------------------------------;
; _AsmGetTemplateAddressMap ; ; _AsmGetTemplateAddressMap ;
;----------------------------------------------------------------------------; ;----------------------------------------------------------------------------;
; ;
; Protocol prototype ; Protocol prototype
; AsmGetTemplateAddressMap ( ; AsmGetTemplateAddressMap (
; EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap ; EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap
; ); ; );
; ;
; Routine Description: ; Routine Description:
; ;
; Return address map of interrupt handler template so that C code can generate ; Return address map of interrupt handler template so that C code can generate
; interrupt table. ; interrupt table.
; ;
; Arguments: ; Arguments:
; ;
; ;
; Returns: ; Returns:
; ;
; Nothing ; Nothing
; ;
; ;
; Input: [ebp][0] = Original ebp ; Input: [ebp][0] = Original ebp
; [ebp][4] = Return address ; [ebp][4] = Return address
; ;
; Output: Nothing ; Output: Nothing
; ;
; Destroys: Nothing ; Destroys: Nothing
;-----------------------------------------------------------------------------; ;-----------------------------------------------------------------------------;
AsmGetTemplateAddressMap proc near public AsmGetTemplateAddressMap proc near public
@ -449,7 +449,7 @@ AsmGetTemplateAddressMap proc near public
mov dword ptr [ebx], AsmIdtVectorBegin mov dword ptr [ebx], AsmIdtVectorBegin
mov dword ptr [ebx + 4h], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32 mov dword ptr [ebx + 4h], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
mov dword ptr [ebx + 8h], HookAfterStubBegin mov dword ptr [ebx + 8h], HookAfterStubBegin
popad popad
pop ebp pop ebp
ret ret

View File

@ -25,7 +25,7 @@ EFI_GUID mCpuExceptrionHandlerLibHobGuid = CPU_EXCEPTION_HANDLER_LIB_HOB_GUID;
/** /**
Get exception handler data pointer from GUIDed HOb. Get exception handler data pointer from GUIDed HOb.
@return pointer to exception handler data. @return pointer to exception handler data.
**/ **/
EXCEPTION_HANDLER_DATA * EXCEPTION_HANDLER_DATA *
GetExceptionHandlerData ( GetExceptionHandlerData (
@ -55,7 +55,7 @@ GetExceptionHandlerData (
VOID VOID
EFIAPI EFIAPI
CommonExceptionHandler ( CommonExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext IN EFI_SYSTEM_CONTEXT SystemContext
) )
{ {
@ -67,17 +67,17 @@ CommonExceptionHandler (
/** /**
Initializes all CPU exceptions entries and provides the default exception handlers. Initializes all CPU exceptions entries and provides the default exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
Note: Before invoking this API, caller must allocate memory for IDT table and load Note: Before invoking this API, caller must allocate memory for IDT table and load
IDTR by AsmWriteIdtr(). IDTR by AsmWriteIdtr().
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers. with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -123,15 +123,15 @@ InitializeCpuExceptionHandlers (
/** /**
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized
with default interrupt/exception handlers. with default interrupt/exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -149,9 +149,9 @@ InitializeCpuInterruptHandlers (
/** /**
Registers a function to be called from the processor interrupt handler. Registers a function to be called from the processor interrupt handler.
This function registers and enables the handler specified by InterruptHandler for a processor This function registers and enables the handler specified by InterruptHandler for a processor
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
handler for the processor interrupt or exception type specified by InterruptType is uninstalled. handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
The installed handler is called once for each processor interrupt or exception. The installed handler is called once for each processor interrupt or exception.
NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or
InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.

View File

@ -6,10 +6,10 @@
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]

View File

@ -9,7 +9,7 @@
// are licensed and made available under the terms and conditions of the BSD License // are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //

View File

@ -24,7 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
VOID VOID
CommonExceptionHandlerWorker ( CommonExceptionHandlerWorker (
IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext, IN EFI_SYSTEM_CONTEXT SystemContext,
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
) )
@ -87,7 +87,7 @@ CommonExceptionHandlerWorker (
CpuDeadLoop (); CpuDeadLoop ();
break; break;
} }
if (ExternalInterruptHandler != NULL && if (ExternalInterruptHandler != NULL &&
ExternalInterruptHandler[ExceptionType] != NULL) { ExternalInterruptHandler[ExceptionType] != NULL) {
(ExternalInterruptHandler[ExceptionType]) (ExceptionType, SystemContext); (ExternalInterruptHandler[ExceptionType]) (ExceptionType, SystemContext);
@ -100,7 +100,7 @@ CommonExceptionHandlerWorker (
} }
// //
// Display ExceptionType, CPU information and Image information // Display ExceptionType, CPU information and Image information
// //
DumpImageAndCpuContent (ExceptionType, SystemContext); DumpImageAndCpuContent (ExceptionType, SystemContext);
// //
// Release Spinlock of output message // Release Spinlock of output message
@ -192,8 +192,8 @@ UpdateIdtTable (
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@param[in, out] ExceptionHandlerData Pointer to exception handler data. @param[in, out] ExceptionHandlerData Pointer to exception handler data.
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers. with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.

View File

@ -26,15 +26,15 @@ CONST UINTN mDoFarReturnFlag = 0;
VOID VOID
EFIAPI EFIAPI
CommonExceptionHandler ( CommonExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext IN EFI_SYSTEM_CONTEXT SystemContext
) )
{ {
// //
// Display ExceptionType, CPU information and Image information // Display ExceptionType, CPU information and Image information
// //
DumpImageAndCpuContent (ExceptionType, SystemContext); DumpImageAndCpuContent (ExceptionType, SystemContext);
// //
// Enter a dead loop. // Enter a dead loop.
// //
@ -43,17 +43,17 @@ CommonExceptionHandler (
/** /**
Initializes all CPU exceptions entries and provides the default exception handlers. Initializes all CPU exceptions entries and provides the default exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
Note: Before invoking this API, caller must allocate memory for IDT table and load Note: Before invoking this API, caller must allocate memory for IDT table and load
IDTR by AsmWriteIdtr(). IDTR by AsmWriteIdtr().
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers. with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -65,7 +65,7 @@ InitializeCpuExceptionHandlers (
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
RESERVED_VECTORS_DATA ReservedVectorData[CPU_EXCEPTION_NUM]; RESERVED_VECTORS_DATA ReservedVectorData[CPU_EXCEPTION_NUM];
IA32_DESCRIPTOR IdtDescriptor; IA32_DESCRIPTOR IdtDescriptor;
UINTN IdtEntryCount; UINTN IdtEntryCount;
@ -122,15 +122,15 @@ InitializeCpuExceptionHandlers (
/** /**
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized
with default interrupt/exception handlers. with default interrupt/exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -148,9 +148,9 @@ InitializeCpuInterruptHandlers (
/** /**
Registers a function to be called from the processor interrupt handler. Registers a function to be called from the processor interrupt handler.
This function registers and enables the handler specified by InterruptHandler for a processor This function registers and enables the handler specified by InterruptHandler for a processor
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
handler for the processor interrupt or exception type specified by InterruptType is uninstalled. handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
The installed handler is called once for each processor interrupt or exception. The installed handler is called once for each processor interrupt or exception.
NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or
InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.

View File

@ -6,10 +6,10 @@
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]

View File

@ -9,7 +9,7 @@
// are licensed and made available under the terms and conditions of the BSD License // are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //

View File

@ -6,10 +6,10 @@
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]

View File

@ -9,7 +9,7 @@
// are licensed and made available under the terms and conditions of the BSD License // are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //

View File

@ -15,7 +15,7 @@
#include <PiSmm.h> #include <PiSmm.h>
#include "CpuExceptionCommon.h" #include "CpuExceptionCommon.h"
CONST UINTN mDoFarReturnFlag = 1; CONST UINTN mDoFarReturnFlag = 1;
// //
// Spin lock for CPU information display // Spin lock for CPU information display
@ -34,7 +34,7 @@ EXCEPTION_HANDLER_DATA mExceptionHandlerData;
VOID VOID
EFIAPI EFIAPI
CommonExceptionHandler ( CommonExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext IN EFI_SYSTEM_CONTEXT SystemContext
) )
{ {
@ -43,15 +43,15 @@ CommonExceptionHandler (
/** /**
Initializes all CPU exceptions entries and provides the default exception handlers. Initializes all CPU exceptions entries and provides the default exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
with default exception handlers. with default exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -71,15 +71,15 @@ InitializeCpuExceptionHandlers (
/** /**
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers. Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
@param[in] VectorInfo Pointer to reserved vector list. @param[in] VectorInfo Pointer to reserved vector list.
@retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized
with default interrupt/exception handlers. with default interrupt/exception handlers.
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL. @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
@retval EFI_UNSUPPORTED This function is not supported. @retval EFI_UNSUPPORTED This function is not supported.
@ -97,9 +97,9 @@ InitializeCpuInterruptHandlers (
/** /**
Registers a function to be called from the processor interrupt handler. Registers a function to be called from the processor interrupt handler.
This function registers and enables the handler specified by InterruptHandler for a processor This function registers and enables the handler specified by InterruptHandler for a processor
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
handler for the processor interrupt or exception type specified by InterruptType is uninstalled. handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
The installed handler is called once for each processor interrupt or exception. The installed handler is called once for each processor interrupt or exception.
NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or
InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned. InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.

View File

@ -29,7 +29,7 @@ ArchUpdateIdtEntry (
{ {
IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16); IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
IdtEntry->Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32); IdtEntry->Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32);
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
} }
@ -79,7 +79,7 @@ ArchSaveExceptionContext (
// Clear IF flag to avoid old IDT handler enable interrupt by IRET // Clear IF flag to avoid old IDT handler enable interrupt by IRET
// //
Eflags.UintN = SystemContext.SystemContextX64->Rflags; Eflags.UintN = SystemContext.SystemContextX64->Rflags;
Eflags.Bits.IF = 0; Eflags.Bits.IF = 0;
SystemContext.SystemContextX64->Rflags = Eflags.UintN; SystemContext.SystemContextX64->Rflags = Eflags.UintN;
// //
// Modify the EIP in stack, then old IDT handler will return to the stub code // Modify the EIP in stack, then old IDT handler will return to the stub code
@ -236,7 +236,7 @@ DumpCpuContext (
SystemContext.SystemContextX64->Idtr[1], SystemContext.SystemContextX64->Idtr[1],
SystemContext.SystemContextX64->Tr SystemContext.SystemContextX64->Tr
); );
InternalPrintMessage ( InternalPrintMessage (
"FXSAVE_STATE - %016lx\n", "FXSAVE_STATE - %016lx\n",
&SystemContext.SystemContextX64->FxSaveState &SystemContext.SystemContextX64->FxSaveState
); );

View File

@ -29,8 +29,8 @@ ASM_GLOBAL ASM_PFX(CommonExceptionHandler)
.text .text
#ifdef __APPLE__ #ifdef __APPLE__
# macros are different between GNU and Xcode as. # macros are different between GNU and Xcode as.
.macro IDT_MACRO .macro IDT_MACRO
push $0 push $0
#else #else
.macro IDT_MACRO arg .macro IDT_MACRO arg
@ -78,7 +78,7 @@ AsmIdtVectorEnd:
HookAfterStubHeaderBegin: HookAfterStubHeaderBegin:
.byte 0x6a # push .byte 0x6a # push
PatchVectorNum: PatchVectorNum:
.byte 0 # 0 will be fixed .byte 0 # 0 will be fixed
.byte 0xe9 # jmp ASM_PFX(HookAfterStubHeaderEnd) .byte 0xe9 # jmp ASM_PFX(HookAfterStubHeaderEnd)
PatchFuncAddress: PatchFuncAddress:
.set HOOK_ADDRESS, ASM_PFX(HookAfterStubHeaderEnd) - . - 4 .set HOOK_ADDRESS, ASM_PFX(HookAfterStubHeaderEnd) - . - 4
@ -234,16 +234,16 @@ CommonInterruptEntry_al_0000:
movq %cr8, %rax movq %cr8, %rax
pushq %rax pushq %rax
movq %cr4, %rax movq %cr4, %rax
orq $0x208, %rax orq $0x208, %rax
movq %rax, %cr4 movq %rax, %cr4
pushq %rax pushq %rax
mov %cr3, %rax mov %cr3, %rax
pushq %rax pushq %rax
mov %cr2, %rax mov %cr2, %rax
pushq %rax pushq %rax
xorq %rax, %rax xorq %rax, %rax
pushq %rax pushq %rax
mov %cr0, %rax mov %cr0, %rax
pushq %rax pushq %rax
#; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7; #; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
@ -278,7 +278,7 @@ CommonInterruptEntry_al_0000:
# Per X64 calling convention, allocate maximum parameter stack space # Per X64 calling convention, allocate maximum parameter stack space
# and make sure RSP is 16-byte aligned # and make sure RSP is 16-byte aligned
# #
subq $40, %rsp subq $40, %rsp
call ASM_PFX(CommonExceptionHandler) call ASM_PFX(CommonExceptionHandler)
addq $40, %rsp addq $40, %rsp

View File

@ -47,7 +47,7 @@ AsmIdtVectorEnd:
HookAfterStubHeaderBegin: HookAfterStubHeaderBegin:
db 6ah ; push db 6ah ; push
@VectorNum: @VectorNum:
db 0 ; 0 will be fixed db 0 ; 0 will be fixed
push rax push rax
mov rax, HookAfterStubHeaderEnd mov rax, HookAfterStubHeaderEnd
jmp rax jmp rax
@ -89,7 +89,7 @@ HookAfterStubHeaderEnd:
; + RBP + ; + RBP +
; +---------------------+ <-- RBP, 16-byte aligned ; +---------------------+ <-- RBP, 16-byte aligned
; The follow algorithm is used for the common interrupt routine. ; The follow algorithm is used for the common interrupt routine.
CommonInterruptEntry PROC PUBLIC CommonInterruptEntry PROC PUBLIC
cli cli
pop rax pop rax
; ;
@ -111,7 +111,7 @@ NoErrorCode:
; ;
push [rsp] push [rsp]
mov qword ptr [rsp + 8], 0 mov qword ptr [rsp + 8], 0
@@: @@:
push rbp push rbp
mov rbp, rsp mov rbp, rsp
push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
@ -351,7 +351,7 @@ DoReturn:
jz DoIret jz DoIret
push rax push rax
mov rax, rsp ; save old RSP to rax mov rax, rsp ; save old RSP to rax
mov rsp, [rsp + 20h] mov rsp, [rsp + 20h]
push [rax + 10h] ; save CS in new location push [rax + 10h] ; save CS in new location
push [rax + 8h] ; save EIP in new location push [rax + 8h] ; save EIP in new location
push [rax + 18h] ; save EFLAGS in new location push [rax + 18h] ; save EFLAGS in new location