From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=eric.jin@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 440382116527A for ; Thu, 11 Oct 2018 02:04:59 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 02:04:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,367,1534834800"; d="scan'208";a="271459442" Received: from shwdeopenpsi175.ccr.corp.intel.com ([10.239.9.140]) by fmsmga006.fm.intel.com with ESMTP; 11 Oct 2018 02:04:13 -0700 From: Eric Jin To: edk2-devel@lists.01.org Date: Thu, 11 Oct 2018 17:03:47 +0800 Message-Id: <20181011090347.4868-1-eric.jin@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [edk2-test][Patch] uefi-sct\SctPkg: Add the new test of ResetNotification Protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Oct 2018 09:05:00 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Jin Cc: Supreeth Venkatesh --- uefi-sct/SctPkg/CommonGenFramework.bat | 3 +- uefi-sct/SctPkg/CommonGenFramework.sh | 3 +- uefi-sct/SctPkg/Config/Data/Category.ini | 9 +- .../Protocol/ResetNotification/BlackBoxTest/Guid.c | 37 ++ .../Protocol/ResetNotification/BlackBoxTest/Guid.h | 58 +++ .../BlackBoxTest/ResetNotificationBBTest.inf | 55 +++ .../ResetNotificationBBTestConformance.c | 155 ++++++++ .../BlackBoxTest/ResetNotificationBBTestFunction.c | 408 +++++++++++++++++++++ .../BlackBoxTest/ResetNotificationBBTestMain.c | 230 ++++++++++++ .../BlackBoxTest/ResetNotificationBBTestMain.h | 149 ++++++++ uefi-sct/SctPkg/UEFI/Protocol/ResetNotification.h | 94 +++++ uefi-sct/SctPkg/UEFI/UEFI.dec | 3 +- uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 3 +- 13 files changed, 1202 insertions(+), 5 deletions(-) create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.h create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTest.inf create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestConformance.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestFunction.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.c create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.h create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/ResetNotification.h diff --git a/uefi-sct/SctPkg/CommonGenFramework.bat b/uefi-sct/SctPkg/CommonGenFramework.bat index 3ed9dcd..cf7f619 100644 --- a/uefi-sct/SctPkg/CommonGenFramework.bat +++ b/uefi-sct/SctPkg/CommonGenFramework.bat @@ -1,6 +1,6 @@ @REM @REM Copyright 2006 - 2017 Unified EFI, Inc.
-@REM Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. +@REM Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. @REM (C) Copyright 2017 Hewlett Packard Enterprise Development LP
@REM @REM This program and the accompanying materials @@ -186,6 +186,7 @@ copy %ProcessorType%\RamDiskProtocolBBTest.efi %Framework%\Test\ copy %ProcessorType%\NVMEPassThruBBTest.efi %Framework%\Test\ > NUL copy %ProcessorType%\EraseBlockBBTest.efi %Framework%\Test\ > NUL copy %ProcessorType%\SDMMCPassThruBBTest.efi %Framework%\Test\ > NUL +copy %ProcessorType%\ResetNotificationBBTest.efi %Framework%\Test\ > NUL rem ********************************************* rem Copy ENTS binary diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/CommonGenFramework.sh index 328bb6a..a37c76b 100755 --- a/uefi-sct/SctPkg/CommonGenFramework.sh +++ b/uefi-sct/SctPkg/CommonGenFramework.sh @@ -2,7 +2,7 @@ # # Copyright 2006 - 2017 Unified EFI, Inc.
# Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved. # (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# # This program and the accompanying materials @@ -219,6 +219,7 @@ then cp $ProcessorType/NVMEPassThruBBTest.efi $Framework/Test/ > NUL cp $ProcessorType/EraseBlockBBTest.efi $Framework/Test/ > NUL cp $ProcessorType/SDMMCPassThruBBTest.efi $Framework/Test/ > NUL + cp $ProcessorType/ResetNotificationBBTest.efi $Framework/Test/ > NUL # ********************************************* # Copy ENTS binary diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini b/uefi-sct/SctPkg/Config/Data/Category.ini index 6bffcb3..14cb2a2 100644 --- a/uefi-sct/SctPkg/Config/Data/Category.ini +++ b/uefi-sct/SctPkg/Config/Data/Category.ini @@ -1,7 +1,7 @@ ## @file # # Copyright 2006 - 2017 Unified EFI, Inc.
-# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# # This program and the accompanying materials @@ -642,6 +642,13 @@ Description = [Category Data] Revision = 0x00010000 +CategoryGuid = 9DA34AE0-EAF9-4BBF-8EC3-FD60226C44BE +InterfaceGuid = 9DA34AE0-EAF9-4BBF-8EC3-FD60226C44BE +Name = ResetNotificationProtocolTest +Description = + +[Category Data] +Revision = 0x00010000 CategoryGuid = 3152BCA5-EADE-433D-862E-C01CDC291F44 InterfaceGuid = 3152BCA5-EADE-433D-862E-C01CDC291F44 Name = SecureTechTest\RNGProtocolTest diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.c new file mode 100644 index 0000000..bb4cbab --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.c @@ -0,0 +1,37 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + + Module Name: + + Guid.c + + Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + +#include "ResetNotificationBBTestMain.h" + +EFI_GUID gResetNotificationBBTestConformanceAssertionGuid001 = EFI_TEST_RESET_NOTIFICATION_BBTESTCONFORMANCE_ASSERTION_001_GUID; +EFI_GUID gResetNotificationBBTestConformanceAssertionGuid002 = EFI_TEST_RESET_NOTIFICATION_BBTESTCONFORMANCE_ASSERTION_002_GUID; + + +EFI_GUID gResetNotificationBBTestFunctionAssertionGuid001 = EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_001_GUID; +EFI_GUID gResetNotificationBBTestFunctionAssertionGuid002 = EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_002_GUID; +EFI_GUID gResetNotificationBBTestFunctionAssertionGuid003 = EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_003_GUID; +EFI_GUID gResetNotificationBBTestFunctionAssertionGuid004 = EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_004_GUID; +EFI_GUID gResetNotificationBBTestFunctionAssertionGuid005 = EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_005_GUID; +EFI_GUID gResetNotificationBBTestFunctionAssertionGuid006 = EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_006_GUID; \ No newline at end of file diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.h new file mode 100644 index 0000000..487139b --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/Guid.h @@ -0,0 +1,58 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + + Module Name: + + Guid.h + + Abstract: + + GUIDs auto-generated for EFI test assertion. + +--*/ + + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTCONFORMANCE_ASSERTION_001_GUID \ +{ 0xc50231ca, 0x60ff, 0x404b, { 0x9b, 0x55, 0xb, 0x61, 0x47, 0x4b, 0x24, 0x12 } } +extern EFI_GUID gResetNotificationBBTestConformanceAssertionGuid001; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTCONFORMANCE_ASSERTION_002_GUID \ +{ 0x22d49da5, 0x2789, 0x47b5, { 0x89, 0x2d, 0xb3, 0x6f, 0x9c, 0x70, 0x8b, 0x2a } } +extern EFI_GUID gResetNotificationBBTestConformanceAssertionGuid002; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_001_GUID \ +{ 0x875d02cb, 0x7861, 0x4453, { 0x96, 0xfc, 0x7d, 0x77, 0x4f, 0x36, 0xb3, 0x57 } } +extern EFI_GUID gResetNotificationBBTestFunctionAssertionGuid001; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_002_GUID \ +{ 0x89145ddf, 0xca1, 0x4229, { 0x90, 0x82, 0x93, 0x74, 0xa5, 0xb6, 0xea, 0xd3 } } +extern EFI_GUID gResetNotificationBBTestFunctionAssertionGuid002; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_003_GUID \ +{ 0xc9d80a98, 0x199d, 0x4b4c, { 0x86, 0x79, 0x98, 0x60, 0xef, 0x81, 0x12, 0xf3 } } +extern EFI_GUID gResetNotificationBBTestFunctionAssertionGuid003; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_004_GUID \ +{ 0x3f097d6, 0x3b8a, 0x454a, { 0xb7, 0xb8, 0xff, 0x49, 0x5, 0xfa, 0xe8, 0xe } } +extern EFI_GUID gResetNotificationBBTestFunctionAssertionGuid004; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_005_GUID \ +{ 0x83c35b9a, 0xe8e2, 0x4c64, { 0xa6, 0xd4, 0xb1, 0xe, 0xd6, 0x1b, 0x2b, 0xe4 } } +extern EFI_GUID gResetNotificationBBTestFunctionAssertionGuid005; + +#define EFI_TEST_RESET_NOTIFICATION_BBTESTFUNCTION_ASSERTION_006_GUID \ +{ 0xc48c5eaf, 0xbd59, 0x4087, { 0xb8, 0x94, 0xba, 0xf7, 0x76, 0x83, 0x5b, 0x48 } } +extern EFI_GUID gResetNotificationBBTestFunctionAssertionGuid006; + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTest.inf new file mode 100644 index 0000000..d5f3a52 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTest.inf @@ -0,0 +1,55 @@ +## @file +# +# Copyright (c) 2018, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# 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 +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## +#/*++ +# +# Module Name: +# +# ResetNotificationBBTest.inf +# +# Abstract: +# +# Component description file for Reset Notification Protocol Black-Box Test. +# +#--*/ + +[defines] + INF_VERSION = 0x00010005 + BASE_NAME = ResetNotificationBBTest + FILE_GUID = 454842A0-7F41-484C-BD6A-08B34B292590 + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeResetNotificationBBTest + +[sources.common] + ResetNotificationBBTestConformance.c + ResetNotificationBBTestFunction.c + ResetNotificationBBTestMain.c + Guid.c + +[Packages] + MdePkg/MdePkg.dec + SctPkg/SctPkg.dec + SctPkg/UEFI/UEFI.dec + +[LibraryClasses] + UefiDriverEntryPoint + SctLib + EfiTestLib + +[Protocols] + gBlackBoxEfiResetNotificationProtocolGuid + gEfiTestRecoveryLibraryGuid + gEfiTestLoggingLibraryGuid + +[Guids] diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestConformance.c new file mode 100644 index 0000000..0be5dc2 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestConformance.c @@ -0,0 +1,155 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + ResetNotificationBBTestConformance.c + +Abstract: + + for EFI Driver Reset Notification Protocol's Conformance Test + +--*/ + +#include "ResetNotificationBBTestMain.h" + +EFI_STATUS +BBTestRegisterResetNotifyConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + + EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotification; + + + ResetNotification = (EFI_RESET_NOTIFICATION_PROTOCOL*)ClientInterface; + + + // + // Get the Standard Library Interface + // + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + + if ( EFI_ERROR(Status) ) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.HandleProtocol - Handle standard test library", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + Status = ResetNotification->RegisterResetNotify (ResetNotification, NULL); + if (Status == EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestConformanceAssertionGuid001, + L"EFI_RESET_NOTIFICATION_PROTOCOL.RegisterResetNotify - call RegisterResetNotify() with NULL ResetFunction, the status should be EFI_INVALID_PARAMETER", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + + +EFI_STATUS +BBTestUnregisterResetNotifyConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + + EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotification; + + + ResetNotification = (EFI_RESET_NOTIFICATION_PROTOCOL*)ClientInterface; + + + // + // Get the Standard Library Interface + // + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) &StandardLib + ); + + if ( EFI_ERROR(Status) ) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.HandleProtocol - Handle standard test library", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + Status = ResetNotification->UnregisterResetNotify (ResetNotification, NULL); + if (Status == EFI_INVALID_PARAMETER) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestConformanceAssertionGuid002, + L"EFI_RESET_NOTIFICATION_PROTOCOL.UnregisterResetNotify - call UnregisterResetNotify() with NULL ResetFunction, the status should be EFI_INVALID_PARAMETER", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + return EFI_SUCCESS; +} + + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestFunction.c new file mode 100644 index 0000000..b13e934 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestFunction.c @@ -0,0 +1,408 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + ResetNotificationFunction.c + +Abstract: + + for EFI Driver Reset Notification Protocol's Function Test + +--*/ + +#include "ResetNotificationBBTestMain.h" + +extern UINT8 EnterEvent; + +EFI_STATUS +BBTestRegisterResetNotifyFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; + EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; + + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotification; + UINTN RecoveryDataSize; + UINT8 *RecoveryData; + UINTN DataSize; + UINT32 Attributes1; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN Index; + + ResetNotification = (EFI_RESET_NOTIFICATION_PROTOCOL*)ClientInterface; + + // + // Get test support library interfaces + // + Status = GetTestSupportLibrary ( + SupportHandle, + &StandardLib, + &RecoveryLib, + &LoggingLib + ); + + if ( EFI_ERROR(Status) ) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"TestSupportLibrary - StandardLib, RecoveryLib, LoggingLib failure", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + // + // Allocate memory for recovery data + // + Status = gtBS->AllocatePool ( + EfiLoaderData, + 1024, + (VOID **)&RecoveryData + ); + if (EFI_ERROR(Status)) { + if (LoggingLib != NULL) { + LoggingLib->ExitFunction ( + LoggingLib, + L"BBTestRegisterResetNotifyFunctionTest", + L"Cannot allocate memory for recovery data" + ); + } + + return Status; + } + + // + // Read reset record + // + RecoveryDataSize = 1024; + Status = RecoveryLib->ReadResetRecord ( + RecoveryLib, + &RecoveryDataSize, + RecoveryData + ); + if (!EFI_ERROR(Status) && (RecoveryDataSize > 0)) { + switch (RecoveryData[0]) { + case 1: + goto step2; + default: + goto step3; + } + } + + Status = ResetNotification->RegisterResetNotify (ResetNotification, TestOnReset); + if (EFI_SUCCESS == Status) + AssertionType = EFI_TEST_ASSERTION_PASSED; + else + AssertionType = EFI_TEST_ASSERTION_FAILED; + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestFunctionAssertionGuid001, + L"EFI_RESET_NOTIFICATION_PROTOCOL.RegisterResetNotify - call RegisterResetNotify() with correct parameters, the status should be EFI_SUCCESS", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + Status = ResetNotification->RegisterResetNotify (ResetNotification, TestOnReset); + if (EFI_ALREADY_STARTED == Status) + AssertionType = EFI_TEST_ASSERTION_PASSED; + else + AssertionType = EFI_TEST_ASSERTION_FAILED; + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestFunctionAssertionGuid002, + L"EFI_RESET_NOTIFICATION_PROTOCOL.RegisterResetNotify - call RegisterResetNotify() with registered ResetFunction, the status should be EFI_ALREADY_STARTED", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + // + // Write reset record + // + RecoveryData[0] = 1; + RecoveryLib->WriteResetRecord (RecoveryLib, 1, RecoveryData); + + // + // Print out some information to avoid the user thought it is an error + // + SctPrint (L"System will cold reset after 1 second..."); + gtBS->Stall (1000000); + + gtRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + + +step2: + RecoveryLib->WriteResetRecord (RecoveryLib, 0, NULL); + + DataSize = MAX_BUFFER_SIZE; + Status = gtRT->GetVariable ( + VariableName, // VariableName + &gTestVendorGuid, // VendorGuid + &Attributes1, // Attributes + &DataSize, // DataSize + Data // Data + ); + + // + // Check results + // + if ((Status == EFI_SUCCESS) && (Attributes == Attributes1) && (DataSize == 10)) { + AssertionType = EFI_TEST_ASSERTION_PASSED; + + // + // Delete the variable (restore environment) + // + Status = gtRT->SetVariable ( + VariableName, // VariableName + &gTestVendorGuid, // VendorGuid + Attributes, // Attributes + 0, // DataSize + Data // Data + ); + + + for (Index = 0; Index < 10; Index++) { + if (Data[Index] != (UINT8)Index) { + AssertionType = EFI_TEST_ASSERTION_FAILED; + break; + } + } + } else { + AssertionType = EFI_TEST_ASSERTION_FAILED; + } + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestFunctionAssertionGuid003, + L"EFI_RESET_NOTIFICATION_PROTOCOL.RegisterResetNotify - The registered ResetFunction is called before ResetSystem", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); +step3: + + gtBS->FreePool (RecoveryData); + + return EFI_SUCCESS; +} + +EFI_STATUS +BBTestUnregisterResetNotifyFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ) +{ + + EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; + EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; + EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; + + EFI_STATUS Status; + EFI_TEST_ASSERTION AssertionType; + EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotification; + UINTN RecoveryDataSize; + UINT8 *RecoveryData; + UINTN DataSize; + UINT32 Attributes1; + UINT8 Data[MAX_BUFFER_SIZE]; + + ResetNotification = (EFI_RESET_NOTIFICATION_PROTOCOL*)ClientInterface; + + // + // Get test support library interfaces + // + Status = GetTestSupportLibrary ( + SupportHandle, + &StandardLib, + &RecoveryLib, + &LoggingLib + ); + + if ( EFI_ERROR(Status) ) { + StandardLib->RecordAssertion ( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"TestSupportLibrary - StandardLib, RecoveryLib, LoggingLib failure", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + // + // Allocate memory for recovery data + // + Status = gtBS->AllocatePool ( + EfiLoaderData, + 1024, + (VOID **)&RecoveryData + ); + if (EFI_ERROR(Status)) { + if (LoggingLib != NULL) { + LoggingLib->ExitFunction ( + LoggingLib, + L"BBTestRegisterResetNotifyFunctionTest", + L"Cannot allocate memory for recovery data" + ); + } + + return Status; + } + + // + // Read reset record + // + RecoveryDataSize = 1024; + Status = RecoveryLib->ReadResetRecord ( + RecoveryLib, + &RecoveryDataSize, + RecoveryData + ); + if (!EFI_ERROR(Status) && (RecoveryDataSize > 0)) { + switch (RecoveryData[0]) { + case 1: + goto step2; + default: + goto step3; + } + } + + Status = ResetNotification->UnregisterResetNotify (ResetNotification, TestOnReset); + if (EFI_INVALID_PARAMETER == Status) + AssertionType = EFI_TEST_ASSERTION_PASSED; + else + AssertionType = EFI_TEST_ASSERTION_FAILED; + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestFunctionAssertionGuid004, + L"EFI_RESET_NOTIFICATION_PROTOCOL.UnregisterResetNotify - call UnregisterResetNotify() with unregistered ResetFunction, the status should be EFI_INVALID_PARAMETER", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + Status = ResetNotification->RegisterResetNotify (ResetNotification, TestOnReset); + if (EFI_SUCCESS != Status) { + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gTestGenericFailureGuid, + L"EFI_RESET_NOTIFICATION_PROTOCOL.RegisterResetNotify - call RegisterResetNotify() with unregistered ResetFunction fail", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + return Status; + } + + Status = ResetNotification->UnregisterResetNotify (ResetNotification, TestOnReset); + if (EFI_SUCCESS == Status) + AssertionType = EFI_TEST_ASSERTION_PASSED; + else + AssertionType = EFI_TEST_ASSERTION_FAILED; + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestFunctionAssertionGuid005, + L"EFI_RESET_NOTIFICATION_PROTOCOL.UnregisterResetNotify - call UnregisterResetNotify() with registered ResetFunction, the status should be EFI_SUCCESS", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + // + // Write reset record + // + RecoveryData[0] = 1; + RecoveryLib->WriteResetRecord (RecoveryLib, 1, RecoveryData); + + // + // Print out some information to avoid the user thought it is an error + // + SctPrint (L"System will cold reset after 1 second..."); + gtBS->Stall (1000000); + + gtRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + + +step2: + RecoveryLib->WriteResetRecord (RecoveryLib, 0, NULL); + + DataSize = MAX_BUFFER_SIZE; + Status = gtRT->GetVariable ( + VariableName, // VariableName + &gTestVendorGuid, // VendorGuid + &Attributes1, // Attributes + &DataSize, // DataSize + Data // Data + ); + + if (Status == EFI_NOT_FOUND) + AssertionType = EFI_TEST_ASSERTION_PASSED; + else + AssertionType = EFI_TEST_ASSERTION_FAILED; + + StandardLib->RecordAssertion ( + StandardLib, + AssertionType, + gResetNotificationBBTestFunctionAssertionGuid006, + L"EFI_RESET_NOTIFICATION_PROTOCOL.UnregisterResetNotify - The unregistered ResetFunction should not be called before ResetSystem", + L"%a:%d:Status - %r\n", + __FILE__, + (UINTN)__LINE__, + Status + ); + + +step3: + + gtBS->FreePool (RecoveryData); + + return EFI_SUCCESS; +} + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.c new file mode 100644 index 0000000..83704a2 --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.c @@ -0,0 +1,230 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + ResetNotificationBBTestMain.c + +Abstract: + + Test Driver of Reset Notification Protocol + +--*/ + + +#include "ResetNotificationBBTestMain.h" + +#define EFI_RESET_NOTIFICATION_TEST_GUID \ +{ 0x9da34ae0, 0xeaf9, 0x4bbf, { 0x8e, 0xc3, 0xfd, 0x60, 0x22, 0x6c, 0x44, 0xbe } } + +// +// Global variables +// +EFI_HANDLE mImageHandle; + +CHAR16 *VariableName = L"ResetNotificationTest"; +EFI_GUID gTestVendorGuid = TEST_VENDOR_GUID; +UINT32 Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; + +EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface; + +EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = { + EFI_RESET_NOTIFICATION_PROTOCOL_TEST_REVISION, + EFI_RESET_NOTIFICATION_TEST_GUID, + L"Reset Notification Protocol Test", + L"UEFI Reset Notification Protocol Black-Box Test" +}; + +EFI_GUID gSupportProtocolGuid[] = { + EFI_STANDARD_TEST_LIBRARY_GUID, + EFI_NULL_GUID +}; + +EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = { + { + EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0101, + L"RegisterResetNotifyFunction", + L"Function auto test for Reset Notification Protocol RegisterResetNotify().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestRegisterResetNotifyFunctionTest + }, + + { + EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0102, + L"UnregisterResetNotifyFunction", + L"Function auto test for Reset Notification Protocol UnregisterResetNotify().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestUnregisterResetNotifyFunctionTest + }, + + { + EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0201, + L"RegisterResetNotifyConformance", + L"Conformance auto test for Reset Notification Protocol RegisterResetNotify().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestRegisterResetNotifyConformanceTest + }, + + { + EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0202, + L"UnregisterResetNotifyConformance", + L"Conformance auto test for Reset Notification Protocol UnregisterResetNotify().", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid, + EFI_TEST_CASE_AUTO, + BBTestUnregisterResetNotifyConformanceTest + }, + + 0 +}; + + +EFI_STATUS +InitializeResetNotificationBBTest ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + + EfiInitializeTestLib (ImageHandle, SystemTable); + + // + // initialize test utility lib + // + + SctInitializeLib (ImageHandle, SystemTable); + + mImageHandle = ImageHandle; + + return EfiInitAndInstallBBTestInterface ( + &ImageHandle, + &gBBTestProtocolField, + gBBTestEntryField, + UnloadResetNotificationBBTest, + &gBBTestProtocolInterface + ); + +} + + +EFI_STATUS +UnloadResetNotificationBBTest ( + IN EFI_HANDLE ImageHandle + ) +{ + + return EfiUninstallAndFreeBBTestInterface ( + ImageHandle, + gBBTestProtocolInterface + ); +} + + +/** + * Support function - Get test support protocol library. + * @param SupportHandle A handle containing support protocols. + * @param StandardLib A pointer to Standard Test Support Protocol. + * @param RecoveryLib A pointer to Test Recovery Support Protocol. + * @param LoggingLib A pointer to Test Logging Support Protocol. + * @return EFI_SUCCESS Successfully. + * @return Other value Something failed. + */ +EFI_STATUS +GetTestSupportLibrary ( + IN EFI_HANDLE SupportHandle, + OUT EFI_STANDARD_TEST_LIBRARY_PROTOCOL **StandardLib, + OUT EFI_TEST_RECOVERY_LIBRARY_PROTOCOL **RecoveryLib, + OUT EFI_TEST_LOGGING_LIBRARY_PROTOCOL **LoggingLib + ) +{ + EFI_STATUS Status; + + // + // Get the standard test support library interface + // + *StandardLib = NULL; + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiStandardTestLibraryGuid, + (VOID **) StandardLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Get the test recovery support library interface + // + *RecoveryLib = NULL; + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiTestRecoveryLibraryGuid, + (VOID **) RecoveryLib + ); + if (EFI_ERROR(Status)) { + return Status; + } + + // + // Get the test logging support library interface + // + *LoggingLib = NULL; + Status = gtBS->HandleProtocol ( + SupportHandle, + &gEfiTestLoggingLibraryGuid, + (VOID **) LoggingLib + ); + // Test logging support library is optional + + // + // Done + // + return EFI_SUCCESS; +} + +VOID +EFIAPI +TestOnReset ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + EFI_STATUS Status; + + UINTN Index; + UINT8 Data[MAX_BUFFER_SIZE]; + + for (Index = 0; Index < 10; Index++) { + Data[Index] = (UINT8)Index; + } + + Status = gtRT->SetVariable ( + VariableName, // VariableName + &gTestVendorGuid, // VendorGuid + Attributes, // Attributes + 10, // DataSize + Data // Data + ); + +} + diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.h new file mode 100644 index 0000000..f47e1ec --- /dev/null +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTestMain.h @@ -0,0 +1,149 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + ResetNotificationBBTestMain.h + +Abstract: + + Test Driver of Reset Notification Protocol header file + +--*/ + +#ifndef _RESET_NOTIFICATION_BB_TEST_MAIN_ +#define _RESET_NOTIFICATION_BB_TEST_MAIN_ + +#include +#include +#include +#include +#include "Guid.h" + + +#include EFI_TEST_PROTOCOL_DEFINITION(TestRecoveryLibrary) +#include EFI_TEST_PROTOCOL_DEFINITION(TestLoggingLibrary) + + +#define EFI_RESET_NOTIFICATION_PROTOCOL_TEST_REVISION 0x00010000 + +#define TEST_VENDOR_GUID \ + { 0xF6FAB04F, 0xACAF, 0x4af3, { 0xB9, 0xFA, 0xDC, 0xF9, 0x7F, 0xB4, 0x42, 0x6F } } + + +#define MAX_BUFFER_SIZE 1024 + +// +// Entry GUIDs for Func Test +// +#define EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0101 \ +{ 0x5b16218b, 0xfd90, 0x40f0, { 0x88, 0xfe, 0x4e, 0x9e, 0x44, 0xe1, 0x24, 0x74 } } + +#define EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0102 \ +{ 0xee5b57b0, 0xaad3, 0x49c7, { 0x96, 0xbf, 0x25, 0xdf, 0x42, 0x2f, 0x27, 0xa4 } } +// +// Entry GUIDs for Conf Test +// +#define EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0201 \ +{ 0x91d30199, 0x63c9, 0x4d1e, { 0x93, 0x97, 0xd2, 0x29, 0x3, 0xce, 0x0, 0x69 } } + +#define EFI_RESET_NOTIFICATION_PROTOCOL_TEST_ENTRY_GUID0202 \ +{ 0x3b8f4c78, 0xab7a, 0x4d93, { 0x9c, 0x2, 0xa, 0x3f, 0x6e, 0x16, 0xd1, 0xd6 } } + + +extern EFI_GUID gTestVendorGuid; +extern CHAR16 *VariableName; +extern UINT32 Attributes; + +// +// +// +EFI_STATUS +InitializeResetNotificationBBTest ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +UnloadResetNotificationBBTest ( + IN EFI_HANDLE ImageHandle + ); + +// +//Test Cases +// +EFI_STATUS +BBTestRegisterResetNotifyConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestUnregisterResetNotifyConformanceTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + + +EFI_STATUS +BBTestRegisterResetNotifyFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +EFI_STATUS +BBTestUnregisterResetNotifyFunctionTest ( + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle + ); + +/** + * Support function - Get test support protocol library. + * @param SupportHandle A handle containing support protocols. + * @param StandardLib A pointer to Standard Test Support Protocol. + * @param RecoveryLib A pointer to Test Recovery Support Protocol. + * @param LoggingLib A pointer to Test Logging Support Protocol. + * @return EFI_SUCCESS Successfully. + * @return Other value Something failed. + */ +EFI_STATUS +GetTestSupportLibrary ( + IN EFI_HANDLE SupportHandle, + OUT EFI_STANDARD_TEST_LIBRARY_PROTOCOL **StandardLib, + OUT EFI_TEST_RECOVERY_LIBRARY_PROTOCOL **RecoveryLib, + OUT EFI_TEST_LOGGING_LIBRARY_PROTOCOL **LoggingLib + ); + + +VOID +EFIAPI +TestOnReset ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ); + + +#endif + diff --git a/uefi-sct/SctPkg/UEFI/Protocol/ResetNotification.h b/uefi-sct/SctPkg/UEFI/Protocol/ResetNotification.h new file mode 100644 index 0000000..cad4597 --- /dev/null +++ b/uefi-sct/SctPkg/UEFI/Protocol/ResetNotification.h @@ -0,0 +1,94 @@ +/** @file + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +/*++ + +Module Name: + + ResetNotification.h + +Abstract: + + Reset Notification protocol from the UEFI specification. + +--*/ + +#ifndef _RESET_NOTIFICATION_PROTOCOL_H_ +#define _RESET_NOTIFICATION_PROTOCOL_H_ + + +#define EFI_RESET_NOTIFICATION_PROTOCOL_GUID \ +{ 0x9da34ae0, 0xeaf9, 0x4bbf, { 0x8e, 0xc3, 0xfd, 0x60, 0x22, 0x6c, 0x44, 0xbe } } + + +typedef struct _EFI_RESET_NOTIFICATION_PROTOCOL EFI_RESET_NOTIFICATION_PROTOCOL; + +/** + Register a notification function to be called when ResetSystem() is called. + + The RegisterResetNotify() function registers a notification function that is called when + ResetSystem()is called and prior to completing the reset of the platform. + The registered functions must not perform a platform reset themselves. These + notifications are intended only for the notification of components which may need some + special-purpose maintenance prior to the platform resetting. + The list of registered reset notification functions are processed if ResetSystem()is called + before ExitBootServices(). The list of registered reset notification functions is ignored if + ResetSystem()is called after ExitBootServices(). + + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance. + @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed. + + @retval EFI_SUCCESS The reset notification function was successfully registered. + @retval EFI_INVALID_PARAMETER ResetFunction is NULL. + @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register the reset notification function. + @retval EFI_ALREADY_STARTED The reset notification function specified by ResetFunction has already been registered. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_RESET_NOTIFY) ( + IN EFI_RESET_NOTIFICATION_PROTOCOL *This, + IN EFI_RESET_SYSTEM ResetFunction +); + +/** + Unregister a notification function. + + The UnregisterResetNotify() function removes the previously registered + notification using RegisterResetNotify(). + + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance. + @param[in] ResetFunction The pointer to the ResetFunction being unregistered. + + @retval EFI_SUCCESS The reset notification function was unregistered. + @retval EFI_INVALID_PARAMETER ResetFunction is NULL. + @retval EFI_INVALID_PARAMETER The reset notification function specified by ResetFunction was not previously + registered using RegisterResetNotify(). + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_UNREGISTER_RESET_NOTIFY) ( + IN EFI_RESET_NOTIFICATION_PROTOCOL *This, + IN EFI_RESET_SYSTEM ResetFunction +); + +typedef struct _EFI_RESET_NOTIFICATION_PROTOCOL { + EFI_REGISTER_RESET_NOTIFY RegisterResetNotify; + EFI_UNREGISTER_RESET_NOTIFY UnregisterResetNotify; +} EFI_RESET_NOTIFICATION_PROTOCOL; + + +extern EFI_GUID gBlackBoxEfiResetNotificationProtocolGuid; + +#endif diff --git a/uefi-sct/SctPkg/UEFI/UEFI.dec b/uefi-sct/SctPkg/UEFI/UEFI.dec index 0d9d111..efa52ff 100644 --- a/uefi-sct/SctPkg/UEFI/UEFI.dec +++ b/uefi-sct/SctPkg/UEFI/UEFI.dec @@ -2,7 +2,7 @@ # # Copyright 2004 - 2017 Unified EFI, Inc.
# Copyright (c) 2014, ARM Limited. All rights reserved. -# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# # This program and the accompanying materials @@ -182,3 +182,4 @@ gBlackBoxEfiRamDiskProtocolGuid = { 0xab38a0df, 0x6873, 0x44a9, { 0x87, 0xe6, 0xd4, 0xeb, 0x56, 0x14, 0x84, 0x49 }} gBlackBoxEfiEraseBlockProtocolGuid = { 0x95a9a93e, 0xa86e, 0x4926, {0xaa, 0xef, 0x99, 0x18, 0xe7, 0x72, 0xd9, 0x87}} gBlackBoxEfiSDMMCPassThruProtocolGuid = { 0x716ef0d9, 0xff83, 0x4f69, { 0x81, 0xe9, 0x51, 0x8b, 0xd3, 0x9a, 0x8e, 0x70 }} + gBlackBoxEfiResetNotificationProtocolGuid = { 0x9da34ae0, 0xeaf9, 0x4bbf, { 0x8e, 0xc3, 0xfd, 0x60, 0x22, 0x6c, 0x44, 0xbe } } \ No newline at end of file diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc index 744f409..315d30b 100644 --- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc +++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc @@ -1,7 +1,7 @@ ## @file # # Copyright 2006 - 2017 Unified EFI, Inc.
-# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# # This program and the accompanying materials @@ -284,6 +284,7 @@ SctPkg/TestCase/UEFI/EFI/Protocol/NVMEPassThru/BlackBoxTest/NVMEPassThruBBTest.i SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTest.inf SctPkg/TestCase/UEFI/EFI/Protocol/SDMMCPassThru/BlackBoxTest/SDMMCPassThruBBTest.inf +SctPkg/TestCase/UEFI/EFI/Protocol/ResetNotification/BlackBoxTest/ResetNotificationBBTest.inf # # Dependency files for UEFI/EFI Compliant Test # -- 2.9.0.windows.1