UefiCpuPkg/ExceptionLib: Update RegisterCpuInterruptHandlerWorker()

Add parameter CpuExceptionData for RegisterCpuInterruptHandlerWorker().

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
Jeff Fan 2016-05-24 21:25:17 +08:00
parent 9db15f8148
commit 670f13af60
4 changed files with 29 additions and 17 deletions

View File

@ -152,10 +152,11 @@ InitializeCpuExceptionHandlersWorker (
/** /**
Registers a function to be called from the processor interrupt handler. Registers a function to be called from the processor interrupt handler.
@param[in] InterruptType Defines which interrupt or exception to hook. @param[in] InterruptType Defines which interrupt or exception to hook.
@param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
when a processor interrupt occurs. If this parameter is NULL, then the handler when a processor interrupt occurs. If this parameter is NULL, then the handler
will be uninstalled. will be uninstalled
@param[in] ExceptionHandlerData Pointer to exception handler data.
@retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
@retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
@ -168,7 +169,8 @@ InitializeCpuExceptionHandlersWorker (
EFI_STATUS EFI_STATUS
RegisterCpuInterruptHandlerWorker ( RegisterCpuInterruptHandlerWorker (
IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
); );
/** /**

View File

@ -179,5 +179,5 @@ RegisterCpuInterruptHandler (
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
) )
{ {
return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler); return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);
} }

View File

@ -262,10 +262,11 @@ InitializeCpuExceptionHandlersWorker (
/** /**
Registers a function to be called from the processor interrupt handler. Registers a function to be called from the processor interrupt handler.
@param[in] InterruptType Defines which interrupt or exception to hook. @param[in] InterruptType Defines which interrupt or exception to hook.
@param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
when a processor interrupt occurs. If this parameter is NULL, then the handler when a processor interrupt occurs. If this parameter is NULL, then the handler
will be uninstalled. will be uninstalled
@param[in] ExceptionHandlerData Pointer to exception handler data.
@retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
@retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
@ -278,23 +279,32 @@ InitializeCpuExceptionHandlersWorker (
EFI_STATUS EFI_STATUS
RegisterCpuInterruptHandlerWorker ( RegisterCpuInterruptHandlerWorker (
IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
) )
{ {
if (InterruptType < 0 || InterruptType >= (EFI_EXCEPTION_TYPE)mEnabledInterruptNum || UINTN EnabledInterruptNum;
mReservedVectors[InterruptType].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK) { RESERVED_VECTORS_DATA *ReservedVectors;
EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;
EnabledInterruptNum = ExceptionHandlerData->IdtEntryCount;
ReservedVectors = ExceptionHandlerData->ReservedVectors;
ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler;
if (InterruptType < 0 || InterruptType >= (EFI_EXCEPTION_TYPE)EnabledInterruptNum ||
ReservedVectors[InterruptType].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (InterruptHandler == NULL && mExternalInterruptHandler[InterruptType] == NULL) { if (InterruptHandler == NULL && ExternalInterruptHandler[InterruptType] == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (InterruptHandler != NULL && mExternalInterruptHandler[InterruptType] != NULL) { if (InterruptHandler != NULL && ExternalInterruptHandler[InterruptType] != NULL) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
mExternalInterruptHandler[InterruptType] = InterruptHandler; ExternalInterruptHandler[InterruptType] = InterruptHandler;
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -103,5 +103,5 @@ RegisterCpuInterruptHandler (
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
) )
{ {
return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler); return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);
} }