public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V2] UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib
@ 2022-10-12  7:27 Zhiguang Liu
  2022-10-13  4:57 ` Ni, Ray
  0 siblings, 1 reply; 2+ messages in thread
From: Zhiguang Liu @ 2022-10-12  7:27 UTC (permalink / raw)
  To: devel; +Cc: Zhiguang Liu, Eric Dong, Ray Ni, Rahul Kumar

The PEI instance of the CpuExceptionHandlerLib didn't implement the
RegisterCpuInterruptHandler() API. This patch adds the missing API.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
index 940d83a92f..1c3012b770 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
@@ -100,6 +100,42 @@ CommonExceptionHandler (
   CommonExceptionHandlerWorker (ExceptionType, SystemContext, ExceptionHandlerData);
 }
 
+/**
+  Registers a function to be called from the processor interrupt handler.
+
+  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
+  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.
+  NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked,
+  otherwise EFI_UNSUPPORTED returned.
+
+  @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.
+
+  @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
+                                previously installed.
+  @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
+                                previously installed.
+  @retval EFI_UNSUPPORTED       The interrupt specified by InterruptType is not supported,
+                                or this function is not supported.
+**/
+EFI_STATUS
+EFIAPI
+RegisterCpuInterruptHandler (
+  IN EFI_EXCEPTION_TYPE         InterruptType,
+  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler
+  )
+{
+  EXCEPTION_HANDLER_DATA  *ExceptionHandlerData;
+
+  ExceptionHandlerData = GetExceptionHandlerData ();
+  return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, ExceptionHandlerData);
+}
+
 /**
   Initializes all CPU exceptions entries and provides the default exception handlers.
 
@@ -135,7 +171,7 @@ InitializeCpuExceptionHandlers (
   ASSERT (ExceptionHandlerData != NULL);
   ExceptionHandlerData->IdtEntryCount            = CPU_EXCEPTION_NUM;
   ExceptionHandlerData->ReservedVectors          = ReservedVectors;
-  ExceptionHandlerData->ExternalInterruptHandler = NULL;
+  ExceptionHandlerData->ExternalInterruptHandler = AllocateZeroPool (sizeof (EFI_CPU_INTERRUPT_HANDLER) * ExceptionHandlerData->IdtEntryCount);
   InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock);
 
   Status = InitializeCpuExceptionHandlersWorker (VectorInfo, ExceptionHandlerData);
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib
  2022-10-12  7:27 [PATCH V2] UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib Zhiguang Liu
@ 2022-10-13  4:57 ` Ni, Ray
  0 siblings, 0 replies; 2+ messages in thread
From: Ni, Ray @ 2022-10-13  4:57 UTC (permalink / raw)
  To: Liu, Zhiguang, devel@edk2.groups.io; +Cc: Dong, Eric, Kumar, Rahul R

Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Wednesday, October 12, 2022 3:28 PM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Dong, Eric
> <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>
> Subject: [PATCH V2] UefiCpuPkg:Add RegisterExceptionHandler in
> PeiCpuExceptionHandlerLib
> 
> The PEI instance of the CpuExceptionHandlerLib didn't implement the
> RegisterCpuInterruptHandler() API. This patch adds the missing API.
> 
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> ---
>  UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c | 38
> +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> index 940d83a92f..1c3012b770 100644
> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c
> @@ -100,6 +100,42 @@ CommonExceptionHandler (
>    CommonExceptionHandlerWorker (ExceptionType, SystemContext,
> ExceptionHandlerData);
>  }
> 
> +/**
> +  Registers a function to be called from the processor interrupt handler.
> +
> +  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
> +  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.
> +  NOTE: This function should be invoked after
> InitializeCpuExceptionHandlers() is invoked,
> +  otherwise EFI_UNSUPPORTED returned.
> +
> +  @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.
> +
> +  @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
> +                                previously installed.
> +  @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler
> for InterruptType was not
> +                                previously installed.
> +  @retval EFI_UNSUPPORTED       The interrupt specified by InterruptType is
> not supported,
> +                                or this function is not supported.
> +**/
> +EFI_STATUS
> +EFIAPI
> +RegisterCpuInterruptHandler (
> +  IN EFI_EXCEPTION_TYPE         InterruptType,
> +  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler
> +  )
> +{
> +  EXCEPTION_HANDLER_DATA  *ExceptionHandlerData;
> +
> +  ExceptionHandlerData = GetExceptionHandlerData ();
> +  return RegisterCpuInterruptHandlerWorker (InterruptType,
> InterruptHandler, ExceptionHandlerData);
> +}
> +
>  /**
>    Initializes all CPU exceptions entries and provides the default exception
> handlers.
> 
> @@ -135,7 +171,7 @@ InitializeCpuExceptionHandlers (
>    ASSERT (ExceptionHandlerData != NULL);
>    ExceptionHandlerData->IdtEntryCount            = CPU_EXCEPTION_NUM;
>    ExceptionHandlerData->ReservedVectors          = ReservedVectors;
> -  ExceptionHandlerData->ExternalInterruptHandler = NULL;
> +  ExceptionHandlerData->ExternalInterruptHandler = AllocateZeroPool
> (sizeof (EFI_CPU_INTERRUPT_HANDLER) * ExceptionHandlerData-
> >IdtEntryCount);
>    InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock);
> 
>    Status = InitializeCpuExceptionHandlersWorker (VectorInfo,
> ExceptionHandlerData);
> --
> 2.31.1.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-13  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-12  7:27 [PATCH V2] UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib Zhiguang Liu
2022-10-13  4:57 ` Ni, Ray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox