From 0d770a3213eb66b56682ccd1ab775ef96d6cb069 Mon Sep 17 00:00:00 2001 From: Jiewen Yao Date: Wed, 22 Nov 2017 16:51:29 +0800 Subject: TestPoint: avoid using ReportStatus code to make test point check as last one. Use event signal instead. Cc: Michael A Kubacki Cc: Amy Chan Cc: Chasel Chiu Cc: Brett Wang Cc: Daocheng Bu Cc: Isaac W Oram Cc: Rangasai V Chaganty Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Amy Chan --- .../PlatformInit/PlatformInitDxe/PlatformInitDxe.c | 211 ++++++--------------- .../PlatformInitDxe/PlatformInitDxe.inf | 5 - .../Test/TestPointStubDxe/TestPointStubDxe.c | 158 +++++---------- .../Test/TestPointStubDxe/TestPointStubDxe.inf | 5 - 4 files changed, 99 insertions(+), 280 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c index feb54e93b3..7694d27423 100644 --- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.c @@ -25,15 +25,6 @@ #include #include #include -#include - -EFI_STATUS -PlatformInitUnRegisterRscHandler ( - VOID - ); - -EFI_EVENT mRscNotifyEvent = NULL; -EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL; /** PciEnumerationComplete Protocol notification event handler. @@ -130,6 +121,47 @@ OnDxeSmmReadyToLock ( TestPointDxeSmmReadyToLockWsmtTableFuntional (); } +/** + Notification function of EVT_GROUP_READY_TO_BOOT event group. + It runs after most ReadyToBoot event signaled. + + This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group. + When the Boot Manager is about to load and execute a boot option, it reclaims variable + storage if free size is below the threshold. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. + +**/ +VOID +EFIAPI +OnReadyToBootLater ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DEBUG ((DEBUG_INFO, "OnReadyToBootLater\n")); + + gBS->CloseEvent (Event); + + TestPointReadyToBootMemoryTypeInformationFunctional (); + TestPointReadyToBootUefiMemoryAttributeTableFunctional (); + TestPointReadyToBootUefiBootVariableFunctional (); + TestPointReadyToBootUefiConsoleVariableFunctional (); + TestPointReadyToBootHstiTableFunctional (); + TestPointReadyToBootAcpiTableFuntional (); + TestPointReadyToBootGcdResourceFuntional (); + + TestPointDxeSmmReadyToBootSmiHandlerInstrument (); + TestPointDxeSmmReadyToBootSmmPageProtection (); + + TestPointReadyToBootUefiSecureBootEnabled (); + TestPointReadyToBootPiSignedFvBootEnabled (); + TestPointReadyToBootTcgTrustedBootEnabled (); + TestPointReadyToBootTcgMorEnabled (); + TestPointReadyToBootEsrtTableFunctional (); +} + /** Notification function of EVT_GROUP_READY_TO_BOOT event group. @@ -149,13 +181,25 @@ OnReadyToBoot ( ) { EFI_STATUS Status; + EFI_EVENT ReadyToBootLaterEvent; + + DEBUG ((DEBUG_INFO, "OnReadyToBoot\n")); gBS->CloseEvent (Event); Status = BoardInitReadyToBoot (); ASSERT_EFI_ERROR(Status); - - TestPointDxeSmmReadyToBootSmmPageProtection (); + + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + OnReadyToBootLater, + NULL, + &ReadyToBootLaterEvent + ); + ASSERT_EFI_ERROR (Status); + + gBS->SignalEvent (ReadyToBootLaterEvent); } /** @@ -177,8 +221,6 @@ OnEndOfFirmware ( EFI_STATUS Status; gBS->CloseEvent (Event); - - PlatformInitUnRegisterRscHandler (); Status = BoardInitEndOfFirmware (); ASSERT_EFI_ERROR(Status); @@ -260,148 +302,6 @@ BoardNotificationInitEntryPoint ( return EFI_SUCCESS; } -/** - Report status code listener - for OsLoaderLoadImageStart and OsLoaderStartImageStart. - - @param[in] CodeType Indicates the type of status code being reported. - @param[in] Value Describes the current status of a hardware or software entity. - This included information about the class and subclass that is used to - classify the entity as well as an operation. - @param[in] Instance The enumeration of a hardware or software entity within - the system. Valid instance numbers start with 1. - @param[in] CallerId This optional parameter may be used to identify the caller. - This parameter allows the status code driver to apply different rules to - different callers. - @param[in] Data This optional parameter may be used to pass additional data. - - @retval EFI_SUCCESS Status code is what we expected. - @retval EFI_UNSUPPORTED Status code not supported. - -**/ -EFI_STATUS -EFIAPI -PlatformInitStatusCodeListener ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN EFI_GUID *CallerId, - IN EFI_STATUS_CODE_DATA *Data - ) -{ - EFI_STATUS Status; - STATIC BOOLEAN Tested = FALSE; - - // - // Check whether status code is what we are interested in. - // - if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { - return EFI_UNSUPPORTED; - } - - Status = EFI_SUCCESS; - if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) { - if (!Tested) { - TestPointReadyToBootAcpiTableFuntional (); - TestPointReadyToBootGcdResourceFuntional (); - TestPointReadyToBootMemoryTypeInformationFunctional (); - TestPointReadyToBootUefiMemoryAttributeTableFunctional (); - TestPointReadyToBootUefiBootVariableFunctional (); - TestPointReadyToBootUefiConsoleVariableFunctional (); - TestPointReadyToBootHstiTableFunctional (); - TestPointDxeSmmReadyToBootSmiHandlerInstrument (); - - TestPointReadyToBootUefiSecureBootEnabled (); - TestPointReadyToBootPiSignedFvBootEnabled (); - TestPointReadyToBootTcgTrustedBootEnabled (); - TestPointReadyToBootTcgMorEnabled (); - TestPointReadyToBootEsrtTableFunctional (); - Tested = TRUE; - } - } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) { - } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderStart)) { - } else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) { - PlatformInitUnRegisterRscHandler (); - } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT)) { - } else { - // - // Ignore else progress code. - // - Status = EFI_UNSUPPORTED; - } - - return Status; -} - -/** - RscHandler Protocol notification event handler. - - @param[in] Event Event whose notification function is being invoked. - @param[in] Context Pointer to the notification function's context. -**/ -VOID -EFIAPI -OnRscHandlerInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - Status = gBS->LocateProtocol ( - &gEfiRscHandlerProtocolGuid, - NULL, - &mRscHandlerProtocol - ); - if (EFI_ERROR (Status)) { - return ; - } - - // - // Register report status code listener for OS Loader load and start. - // - Status = mRscHandlerProtocol->Register (PlatformInitStatusCodeListener, TPL_HIGH_LEVEL); - ASSERT_EFI_ERROR (Status); - - gBS->CloseEvent (mRscNotifyEvent); - mRscNotifyEvent = NULL; -} - -EFI_STATUS -PlatformInitRegisterRscHandler ( - VOID - ) -{ - VOID *Registration; - - mRscNotifyEvent = EfiCreateProtocolNotifyEvent ( - &gEfiRscHandlerProtocolGuid, - TPL_CALLBACK, - OnRscHandlerInstalled, - NULL, - &Registration - ); - ASSERT (mRscNotifyEvent != NULL); - - return EFI_SUCCESS; -} - -EFI_STATUS -PlatformInitUnRegisterRscHandler ( - VOID - ) -{ - if (mRscHandlerProtocol != NULL) { - mRscHandlerProtocol->Unregister (PlatformInitStatusCodeListener); - mRscHandlerProtocol = NULL; - } - if (mRscNotifyEvent != NULL) { - gBS->CloseEvent (mRscNotifyEvent); - mRscNotifyEvent = NULL; - } - return EFI_SUCCESS; -} - /** Initialize DXE Platform. @@ -420,7 +320,6 @@ PlatformInitDxeEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { - PlatformInitRegisterRscHandler (); BoardNotificationInitEntryPoint (); return EFI_SUCCESS; diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.inf b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.inf index e64d62c756..18546d0da0 100644 --- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.inf +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitDxe/PlatformInitDxe.inf @@ -42,15 +42,10 @@ [Sources] PlatformInitDxe.c - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad - gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart [Protocols] gEfiPciEnumerationCompleteProtocolGuid gEfiDxeSmmReadyToLockProtocolGuid - gEfiRscHandlerProtocolGuid [Guids] gEfiEventExitBootServicesGuid diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c index b80db2d547..d6878f45de 100644 --- a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c +++ b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c @@ -23,19 +23,10 @@ #include #include #include -#include - -EFI_STATUS -TestPointStubUnRegisterRscHandler ( - VOID - ); UINTN mSmmTestPointDatabaseSize; VOID *mSmmTestPointDatabase; -EFI_EVENT mRscNotifyEvent = NULL; -EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL; - VOID PublishPeiTestPoint ( VOID @@ -256,132 +247,62 @@ PublishSmmTestPoint ( } /** - Report status code listener - for OsLoaderLoadImageStart and OsLoaderStartImageStart. - - @param[in] CodeType Indicates the type of status code being reported. - @param[in] Value Describes the current status of a hardware or software entity. - This included information about the class and subclass that is used to - classify the entity as well as an operation. - @param[in] Instance The enumeration of a hardware or software entity within - the system. Valid instance numbers start with 1. - @param[in] CallerId This optional parameter may be used to identify the caller. - This parameter allows the status code driver to apply different rules to - different callers. - @param[in] Data This optional parameter may be used to pass additional data. - - @retval EFI_SUCCESS Status code is what we expected. - @retval EFI_UNSUPPORTED Status code not supported. + Notification function of EVT_GROUP_READY_TO_BOOT event group. + It runs after most ReadyToBoot event signaled. + + This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group. + When the Boot Manager is about to load and execute a boot option, it reclaims variable + storage if free size is below the threshold. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. **/ -EFI_STATUS +VOID EFIAPI -TestPointStubStatusCodeListener ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN UINT32 Instance, - IN EFI_GUID *CallerId, - IN EFI_STATUS_CODE_DATA *Data +OnReadyToBootLater ( + IN EFI_EVENT Event, + IN VOID *Context ) { - EFI_STATUS Status; - STATIC BOOLEAN Published = FALSE; - - // - // Check whether status code is what we are interested in. - // - if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { - return EFI_UNSUPPORTED; - } - - Status = EFI_SUCCESS; - if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) { - if (!Published) { - PublishSmmTestPoint (); - Published = TRUE; - } - } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) { - } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderStart)) { - } else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) { - TestPointStubUnRegisterRscHandler (); - } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT)) { - } else { - // - // Ignore else progress code. - // - Status = EFI_UNSUPPORTED; - } + gBS->CloseEvent (Event); - return Status; + PublishSmmTestPoint (); } /** - RscHandler Protocol notification event handler. + Notification function of EVT_GROUP_READY_TO_BOOT event group. + + This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group. + When the Boot Manager is about to load and execute a boot option, it reclaims variable + storage if free size is below the threshold. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. - @param[in] Event Event whose notification function is being invoked. - @param[in] Context Pointer to the notification function's context. **/ VOID EFIAPI -OnRscHandlerInstalled ( +OnReadyToBoot ( IN EFI_EVENT Event, IN VOID *Context ) { - EFI_STATUS Status; + EFI_STATUS Status; + EFI_EVENT ReadyToBootLaterEvent; + + gBS->CloseEvent (Event); - Status = gBS->LocateProtocol ( - &gEfiRscHandlerProtocolGuid, + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + OnReadyToBootLater, NULL, - &mRscHandlerProtocol + &ReadyToBootLaterEvent ); - if (EFI_ERROR (Status)) { - return ; - } - - // - // Register report status code listener for OS Loader load and start. - // - Status = mRscHandlerProtocol->Register (TestPointStubStatusCodeListener, TPL_HIGH_LEVEL); ASSERT_EFI_ERROR (Status); - - gBS->CloseEvent (mRscNotifyEvent); - mRscNotifyEvent = NULL; -} - -EFI_STATUS -TestPointStubRegisterRscHandler ( - VOID - ) -{ - VOID *Registration; - - mRscNotifyEvent = EfiCreateProtocolNotifyEvent ( - &gEfiRscHandlerProtocolGuid, - TPL_CALLBACK, - OnRscHandlerInstalled, - NULL, - &Registration - ); - ASSERT (mRscNotifyEvent != NULL); - return EFI_SUCCESS; -} - -EFI_STATUS -TestPointStubUnRegisterRscHandler ( - VOID - ) -{ - if (mRscHandlerProtocol != NULL) { - mRscHandlerProtocol->Unregister (TestPointStubStatusCodeListener); - mRscHandlerProtocol = NULL; - } - if (mRscNotifyEvent != NULL) { - gBS->CloseEvent (mRscNotifyEvent); - mRscNotifyEvent = NULL; - } - return EFI_SUCCESS; + gBS->SignalEvent (ReadyToBootLaterEvent); } VOID @@ -389,7 +310,16 @@ TestPointStubForSmm ( VOID ) { - TestPointStubRegisterRscHandler (); + EFI_STATUS Status; + EFI_EVENT ReadyToBootEvent; + + Status = EfiCreateEventReadyToBootEx ( + TPL_CALLBACK, + OnReadyToBoot, + NULL, + &ReadyToBootEvent + ); + ASSERT_EFI_ERROR (Status); } /** diff --git a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf index 09d6f2a9f0..de7aa8a10f 100644 --- a/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf +++ b/Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.inf @@ -44,14 +44,9 @@ gAdapterInfoPlatformTestPointGuid gEdkiiPiSmmCommunicationRegionTableGuid -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad - gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart - [Protocols] gEfiAdapterInformationProtocolGuid gEfiSmmCommunicationProtocolGuid - gEfiRscHandlerProtocolGuid [Depex] TRUE -- cgit v1.2.3