Add parameter CpuExceptionData for RegisterCpuInterruptHandlerWorker().

Cc: Michael Kinney <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Feng Tian <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
---
 .../CpuExceptionHandlerLib/CpuExceptionCommon.h    | 12 +++++----
 .../Library/CpuExceptionHandlerLib/DxeException.c  |  2 +-
 .../CpuExceptionHandlerLib/PeiDxeSmmCpuException.c | 30 ++++++++++++++--------
 .../Library/CpuExceptionHandlerLib/SmmException.c  |  2 +-
 4 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index 99be61f..f2c44f0 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -152,10 +152,11 @@ InitializeCpuExceptionHandlersWorker (
 /**
   Registers a function to be called from the processor interrupt handler.
 
-  @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
-                                when a processor interrupt occurs. If this 
parameter is NULL, then the handler
-                                will be uninstalled.
+  @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
+                                   when a processor interrupt occurs. If this 
parameter is NULL, then the handler
+                                   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_ALREADY_STARTED   InterruptHandler is not NULL, and a handler 
for InterruptType was
@@ -168,7 +169,8 @@ InitializeCpuExceptionHandlersWorker (
 EFI_STATUS
 RegisterCpuInterruptHandlerWorker (
   IN EFI_EXCEPTION_TYPE            InterruptType,
-  IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler
+  IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler,
+  IN EXCEPTION_HANDLER_DATA        *ExceptionHandlerData
   );
 
 /**
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
index cffb13a..5c4ee2a 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
@@ -179,5 +179,5 @@ RegisterCpuInterruptHandler (
   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler
   )
 {
-  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler);
+  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, 
&mExceptionHandlerData);
 }
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
index 25eba6b..536c2a4 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c
@@ -262,10 +262,11 @@ InitializeCpuExceptionHandlersWorker (
 /**
   Registers a function to be called from the processor interrupt handler.
 
-  @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
-                                when a processor interrupt occurs. If this 
parameter is NULL, then the handler
-                                will be uninstalled.
+  @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
+                                   when a processor interrupt occurs. If this 
parameter is NULL, then the handler
+                                   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_ALREADY_STARTED   InterruptHandler is not NULL, and a handler 
for InterruptType was
@@ -278,23 +279,32 @@ InitializeCpuExceptionHandlersWorker (
 EFI_STATUS
 RegisterCpuInterruptHandlerWorker (
   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 ||
-      mReservedVectors[InterruptType].Attribute == 
EFI_VECTOR_HANDOFF_DO_NOT_HOOK) {
+  UINTN                          EnabledInterruptNum;
+  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;
   }
 
-  if (InterruptHandler == NULL && mExternalInterruptHandler[InterruptType] == 
NULL) {
+  if (InterruptHandler == NULL && ExternalInterruptHandler[InterruptType] == 
NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
-  if (InterruptHandler != NULL && mExternalInterruptHandler[InterruptType] != 
NULL) {
+  if (InterruptHandler != NULL && ExternalInterruptHandler[InterruptType] != 
NULL) {
     return EFI_ALREADY_STARTED;
   }
 
-  mExternalInterruptHandler[InterruptType] = InterruptHandler;
+  ExternalInterruptHandler[InterruptType] = InterruptHandler;
   return EFI_SUCCESS;
 }
 
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c
index b88305d..c3af4d4 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c
@@ -103,5 +103,5 @@ RegisterCpuInterruptHandler (
   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler
   )
 {
-  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler);
+  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, 
&mExceptionHandlerData);
 }
\ No newline at end of file
-- 
2.7.4.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to