Hi Sunny Thanks for reviewing. Here's the updated PR for your review: https://github.com/tianocore/edk2-test/pull/96 [https://opengraph.githubassets.com/f2f41b8e5ab4b752bd722613f51dc6ea43cf452487d02210da33e18645b38eda/tianocore/edk2-test/pull/96] EDK2-Test: Bug 4244 - SCT improvement - Print out the PCIe device pat… by PrachotanReddy · Pull Request #96 · tianocore/edk2-test https://bugzilla.tianocore.org/show_bug.cgi?id=4244 Tests Modified: AdapterInfoBBTestConformance HIIConfigAccessBBTestConformance PxeBaseCodeBBTestConformance SimpleNetworkBBTestConformance UEFI-SC... github.com ________________________________ From: Sunny Wang Sent: Wednesday, June 5, 2024 12:32 PM To: devel@edk2.groups.io ; Prachotan Bathi Cc: G Edhaya Chandran ; Barton Gao ; Carolyn Gjertsen ; Samer El-Haj-Mahmoud ; Eric Jin ; Arvin Chen ; Supreeth Venkatesh ; Sunny Wang Subject: RE: [edk2-devel] [PATCH v1 1/1] EDK2-Test: Bug 4244 - SCT improvement - Print out the PCIe device path fo.. Thanks for working on this, @Prachotan Bathi I directly reviewed and added comments on pull request. https://github.com/tianocore/edk2-test/pull/96 Best Regards, Sunny -----Original Message----- From: devel@edk2.groups.io On Behalf Of Prachotan Bathi via groups.io Sent: Monday, June 3, 2024 1:28 PM To: devel@edk2.groups.io Cc: G Edhaya Chandran ; Barton Gao ; Carolyn Gjertsen ; Samer El-Haj-Mahmoud ; Eric Jin ; Arvin Chen ; Supreeth Venkatesh Subject: [edk2-devel] [PATCH v1 1/1] EDK2-Test: Bug 4244 - SCT improvement - Print out the PCIe device path fo.. Tests Modified: AdapterInfoBBTestConformance ComponentName2BBTestConformance HIIConfigAccessBBTestConformance PxeBaseCodeBBTestConformance SimpleNetworkBBTestConformance UEFI-SCT Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Cc: Samer El-Haj-Mahmoud Cc: Eric Jin Cc: Arvin Chen Cc: Supreeth Venkatesh Signed-off-by: Prachotan Bathi --- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf | 2 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBBTest.inf | 3 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTest.inf | 4 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.h | 17 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h | 6 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.h | 6 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.h | 6 + uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c | 63 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.c | 96 ++ uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c | 48 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c | 67 +- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestConformance.c | 305 +++++- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.c | 1158 +++++++++----------- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestConformance.c | 258 ++++- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.c | 96 ++ 15 files changed, 1451 insertions(+), 684 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf index b3bf99440705..464029ec10ce 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf @@ -49,3 +49,5 @@ [LibraryClasses] EfiTestLib [Protocols] + gEfiAdapterInformationProtocolGuid + gBlackBoxEfiDevicePathProtocolGuid \ No newline at end of file diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBBTest.inf index 41367ce496b3..29392ca83dca 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBBTest.inf +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBBTest.inf @@ -57,4 +57,5 @@ [Protocols] gEfiTestLoggingLibraryGuid gBlackBoxEfiSimpleNetworkProtocolGuid gBlackBoxEfiPxeBaseCodeProtocolGuid - gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid + gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid + gBlackBoxEfiDevicePathProtocolGuid diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTest.inf index 1d2d1d395fbb..14b24173f311 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTest.inf +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTest.inf @@ -51,4 +51,6 @@ [LibraryClasses] EfiTestLib [Protocols] - gEfiTestLoggingLibraryGuid + gEfiTestLoggingLibraryGuid + gBlackBoxEfiSimpleNetworkProtocolGuid + gBlackBoxEfiDevicePathProtocolGuid \ No newline at end of file diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.h index 9952fbcab833..a1ef9db3b127 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.h @@ -28,9 +28,11 @@ Abstract: #define _ADAPTER_INFORMATION_BB_TEST_MAIN #include "Efi.h" +#include +#include "SctLib.h" +#include "Guid.h" #include #include -#include "Guid.h" #define EFI_ADAPTER_INFORMATION_PROTOCOL_TEST_REVISION 0x00010000 @@ -160,12 +162,9 @@ BBTestGetSupportedTypesFunctionTest ( IN EFI_HANDLE SupportHandle ); - -VOID -SctInitializeLib ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - +EFI_STATUS +LocateDevicePathFromAdapterInfo( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *AdapterInfo2, + IN EFI_DEVICE_PATH_PROTOCOL **DevicePath, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib); #endif diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h index 0e17954d7762..812698779f12 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.h @@ -148,6 +148,12 @@ GetDevicePath ( OUT EFI_STRING *DevicePathStr ); +EFI_STATUS +GetDevicePathProtocol ( + IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess, + IN EFI_DEVICE_PATH_PROTOCOL **DevicePath + ); + EFI_STATUS GetCorrespondingRequest ( IN EFI_STRING MultiConfigAltResp, diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.h index b94f200ff7aa..dfef671824f2 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.h @@ -578,6 +578,12 @@ LogChar8String( IN UINTN Len ); +EFI_STATUS +LocateDevicePathFromBcInterface ( + IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface2, + IN EFI_DEVICE_PATH_PROTOCOL **DevicePath, //reuse the EFI_DEVICE_PATH_PROTOCOL as EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib + ); // // Entry GUIDs // diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.h index ea14aaa77963..60ffabe257ee 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.h @@ -357,6 +357,12 @@ BBTestReceiveConformanceTest ( IN EFI_HANDLE SupportHandle ); +EFI_STATUS +LocateDevicePathFromSnpInterface ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface2, + IN EFI_DEVICE_PATH_PROTOCOL **DevicePath, //reuse the EFI_DEVICE_PATH_PROTOCOL as EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib + ); // // Prototypes of Internal Functions diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c index 19ccac93c7c7..7317e53ff1fc 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestConformance.c @@ -93,7 +93,8 @@ BBTestGetInformationConformanceTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_STATUS Status; EFI_ADAPTER_INFORMATION_PROTOCOL *AdapterInfo; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // init // @@ -111,6 +112,25 @@ BBTestGetInformationConformanceTest ( return Status; } + Status=LocateDevicePathFromAdapterInfo(AdapterInfo,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } + + // //Call check points // @@ -137,7 +157,8 @@ BBTestSetInformationConformanceTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_STATUS Status; EFI_ADAPTER_INFORMATION_PROTOCOL *AdapterInfo; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // init // @@ -155,6 +176,23 @@ BBTestSetInformationConformanceTest ( return Status; } + Status=LocateDevicePathFromAdapterInfo(AdapterInfo,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // //Call check points // @@ -178,7 +216,8 @@ BBTestGetSupportedTypesConformanceTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_STATUS Status; EFI_ADAPTER_INFORMATION_PROTOCOL *AdapterInfo; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // init // @@ -195,7 +234,23 @@ BBTestGetSupportedTypesConformanceTest ( if ( EFI_ERROR(Status) ) { return Status; } - + Status=LocateDevicePathFromAdapterInfo(AdapterInfo,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // //Call check points // diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.c index cc37a497614e..8e884b4374e7 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoBBTestMain.c @@ -207,3 +207,99 @@ UnloadAdapterInfoBBTest ( gBBTestProtocolInterface ); } + +EFI_STATUS LocateDevicePathFromAdapterInfo(IN EFI_ADAPTER_INFORMATION_PROTOCOL *AdapterInfo2, IN EFI_DEVICE_PATH_PROTOCOL **DevicePath, IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib) +{ + EFI_STATUS Status; + + UINTN NoHandles, Index; + EFI_HANDLE *HandleBuffer; + EFI_ADAPTER_INFORMATION_PROTOCOL *OtherAdapterInfo2; + + // + // Locate the Handle that the AdapterInfo is bound to + // + Status = gtBS->LocateHandleBuffer( + ByProtocol, + &gEfiAdapterInformationProtocolGuid, + NULL, + &NoHandles, + &HandleBuffer); + if (EFI_ERROR(Status)) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.LocateHandle - LocateHandle", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status); + return Status; + } + + if (NoHandles <= 0) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.LocateHandle - LocateHandle", + L"%a:%d:Device Error", + __FILE__, + (UINTN)__LINE__); + return EFI_DEVICE_ERROR; + } + + // + // Find the exact handle that AdapterInfo bound to + // + for (Index = 0; Index < NoHandles; Index++) + { + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gEfiAdapterInformationProtocolGuid, + (VOID **) &OtherAdapterInfo2); + if (EFI_ERROR(Status)) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.HandleProtocol - HandleProtocol", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status); + + gtBS->FreePool(HandleBuffer); + return Status; + } + + if (OtherAdapterInfo2 == AdapterInfo2) + { + break; + } + } + + // + // Locate the Loaded DevicePath Protocol bound to ADAPTER_INFORMATION Protocol + // + if (Index >= NoHandles) + { + // + // No Handle Found!! + // + gtBS->FreePool(HandleBuffer); + return EFI_DEVICE_ERROR; + } + + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gBlackBoxEfiDevicePathProtocolGuid, + (VOID **) DevicePath); + + gtBS->FreePool(HandleBuffer); + return Status; +} \ No newline at end of file diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c index 964a64cd1d34..16ca0b323914 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestConformance.c @@ -120,7 +120,8 @@ BBTestExtractConfigConformanceTest ( EFI_STATUS Status; EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess; EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // init // @@ -137,6 +138,28 @@ BBTestExtractConfigConformanceTest ( if (EFI_ERROR(Status)) { return Status; } + // + // Get Loaded Device Path of current EFI_HII_CONFIG_ACCESS_PROTOCOL + // And out put device path or device name + // + + Status = GetDevicePathProtocol(HIIConfigAccess,&DevicePath); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Get the Config Routing Protocol Interface @@ -170,7 +193,8 @@ BBTestRouteConfigConformanceTest ( EFI_STATUS Status; EFI_HII_CONFIG_ACCESS_PROTOCOL *HIIConfigAccess; EFI_HII_CONFIG_ROUTING_PROTOCOL *HIIConfigRouting; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // init // @@ -187,7 +211,23 @@ BBTestRouteConfigConformanceTest ( if (EFI_ERROR(Status)) { return Status; } - + Status = GetDevicePathProtocol(HIIConfigAccess,&DevicePath); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Get the Config Routing Protocol Interface // @@ -195,7 +235,7 @@ BBTestRouteConfigConformanceTest ( if ( EFI_ERROR(Status) ) { return Status; } - + // //Call check points // diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c index 099b10f7a38a..2929d8f04c26 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/HIIConfigAccess/BlackBoxTest/HIIConfigAccessBBTestMain.c @@ -381,6 +381,71 @@ GetDevicePath ( return Status; } +EFI_STATUS +GetDevicePathProtocol ( + IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess, + IN EFI_DEVICE_PATH_PROTOCOL **DevicePath + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN NoHandles; + EFI_HANDLE *HandleBuffer; + EFI_HANDLE ConfigAccessHandle = NULL; + EFI_HII_CONFIG_ACCESS_PROTOCOL *TestedConfigAccess; + UINTN Length; + UINTN PathHdrSize; + + // + // locate all Hii Configuration Access Protocol Instances + // + Status = gtBS->LocateHandleBuffer ( + ByProtocol, + &gBlackBoxEfiHIIConfigAccessProtocolGuid, + NULL, + &NoHandles, + &HandleBuffer + ); + if (EFI_ERROR(Status) || (NoHandles == 0)) { + return EFI_NOT_FOUND; + } + + // + // scan for the handle that matched with the Hii Configuration Access Protocol that + // passed in by the test framework + // + for (Index = 0; Index < NoHandles; Index++) { + Status = gtBS->HandleProtocol ( + HandleBuffer[Index], + &gBlackBoxEfiHIIConfigAccessProtocolGuid, + (VOID **) &TestedConfigAccess + ); + if (EFI_ERROR(Status)) { + continue; + } + + if (TestedConfigAccess == ConfigAccess) { + ConfigAccessHandle = HandleBuffer[Index]; + break; + } + } + + gtBS->FreePool (HandleBuffer); + + if (ConfigAccessHandle == NULL) { + return EFI_NOT_FOUND; + } + + // + // find controller handles managed by the component name handle. + // + Status = gtBS->HandleProtocol ( + ConfigAccessHandle, + &gBlackBoxEfiDevicePathProtocolGuid, + (void **)DevicePath + ); + return Status; +} EFI_STATUS GetCorrespondingRequest ( @@ -654,4 +719,4 @@ MultiAltRespToMultiReq ( SctFreePool (FreePtr); return EFI_SUCCESS; -} +} \ No newline at end of file diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestConformance.c index d03eb850c5ad..77b5afe388a3 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestConformance.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestConformance.c @@ -50,6 +50,8 @@ BBTestNewStartConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -68,7 +70,23 @@ BBTestNewStartConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Disable EFI_PXE_BASE_CODE_PROTOCOL Protocol interface // @@ -237,6 +255,8 @@ BBTestNewStopConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -255,7 +275,23 @@ BBTestNewStopConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Disable EFI_PXE_BASE_CODE_PROTOCOL Protocol interface // @@ -418,6 +454,8 @@ BBTestStartConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -436,7 +474,23 @@ BBTestStartConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Change EFI_PXE_BASE_CODE_PROTOCOL Protocol state to enabled // @@ -522,6 +576,8 @@ BBTestStopConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -540,7 +596,23 @@ BBTestStopConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Make sure the EFI_PXE_BASE_CODE_PROTOCOL Protocol is disabled // @@ -606,6 +678,8 @@ BBTestDhcpConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -624,7 +698,23 @@ BBTestDhcpConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Change EFI_PXE_BASE_CODE_PROTOCOL Protocol to disabled // @@ -791,6 +881,8 @@ BBTestDiscoverConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -809,7 +901,23 @@ BBTestDiscoverConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Change EFI_PXE_BASE_CODE_PROTOCOL Protocol to disabled // @@ -988,6 +1096,8 @@ BBTestMtftpConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; UINTN BlockSize=512; EFI_IP_ADDRESS ServerIp; CHAR8 *FileName; @@ -1013,7 +1123,23 @@ BBTestMtftpConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Fill Parameters (ServerIp, FileName, BufferPtr) // Get parameter from ini file. @@ -1473,6 +1599,8 @@ BBTestUdpWriteConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; EFI_IP_ADDRESS DestIp; EFI_PXE_BASE_CODE_UDP_PORT DestPort; UINTN BufferSize; @@ -1501,7 +1629,23 @@ BBTestUdpWriteConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Disable EFI_PXE_BASE_CODE_PROTOCOL protocol if needed Status = ChangePxeState (BcInterface, FALSE, BcInterface->Mode->Started, FALSE); if (EFI_ERROR(Status)) { @@ -1689,6 +1833,8 @@ BBTestUdpReadConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; UINT16 OpFlags; UINTN BufferSize; VOID *BufferPtr; @@ -1713,7 +1859,23 @@ BBTestUdpReadConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Malloc for data BufferSize = MAX_UDP_SIZE; Status = gtBS->AllocatePool (EfiBootServicesData, BufferSize, (VOID **) &BufferPtr); @@ -2004,6 +2166,8 @@ BBTestSetIpFilterConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; EFI_PXE_BASE_CODE_IP_FILTER BcIpFilter; // @@ -2023,7 +2187,23 @@ BBTestSetIpFilterConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Disable EFI_PXE_BASE_CODE_PROTOCOL protocol if needed Status = ChangePxeState (BcInterface, FALSE, BcInterface->Mode->Started, FALSE); if (EFI_ERROR(Status)) { @@ -2083,11 +2263,12 @@ BBTestArpConformanceAutoTest ( EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; - EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; EFI_IP_ADDRESS IpAddr; + EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - // // Get support library (Standard Lib, Profile Lib, Logging Lib) // @@ -2110,7 +2291,23 @@ BBTestArpConformanceAutoTest ( ); return Status; } - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Disable EFI_PXE_BASE_CODE_PROTOCOL Protocol interface // @@ -2130,7 +2327,7 @@ BBTestArpConformanceAutoTest ( return Status; } } - + // // Enable EFI_PXE_BASE_CODE_PROTOCOL Protocol interface in Ipv4 // @@ -2232,6 +2429,8 @@ BBTestArpConformanceManualTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; EFI_IP_ADDRESS IpAddr; EFI_MAC_ADDRESS MacAddr; EFI_INI_FILE_HANDLE FileHandle; @@ -2263,7 +2462,23 @@ BBTestArpConformanceManualTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Disable EFI_PXE_BASE_CODE_PROTOCOL protocol if needed Status = ChangePxeState (BcInterface, FALSE, BcInterface->Mode->Started, FALSE); if (EFI_ERROR(Status)) { @@ -2452,6 +2667,8 @@ BBTestSetParametersConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -2470,7 +2687,23 @@ BBTestSetParametersConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Disable EFI_PXE_BASE_CODE_PROTOCOL protocol if needed Status = ChangePxeState (BcInterface, FALSE, BcInterface->Mode->Started, FALSE); if (EFI_ERROR(Status)) { @@ -2531,6 +2764,8 @@ BBTestSetStationIpConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -2549,7 +2784,23 @@ BBTestSetStationIpConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Disable EFI_PXE_BASE_CODE_PROTOCOL protocol if needed Status = ChangePxeState (BcInterface, FALSE, BcInterface->Mode->Started, FALSE); if (EFI_ERROR(Status)) { @@ -2603,6 +2854,8 @@ BBTestSetPacketsConformanceTest ( EFI_STATUS Status; EFI_TEST_ASSERTION AssertionType; EFI_PXE_BASE_CODE_PROTOCOL *BcInterface; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface @@ -2621,7 +2874,23 @@ BBTestSetPacketsConformanceTest ( // Get the EFI_PXE_BASE_CODE_PROTOCOL Protocol interface to be tested // BcInterface = (EFI_PXE_BASE_CODE_PROTOCOL *)ClientInterface; - + Status=LocateDevicePathFromBcInterface(BcInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // Disable EFI_PXE_BASE_CODE_PROTOCOL protocol if needed Status = ChangePxeState (BcInterface, FALSE, BcInterface->Mode->Started, FALSE); if (EFI_ERROR(Status)) { diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.c index a2db1fb77e51..191f46002230 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PxeBaseCode/BlackBoxTest/PxeBaseCodeBBTestMain.c @@ -5,12 +5,12 @@ 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 + 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. - + **/ /*++ @@ -28,316 +28,94 @@ Abstract: #include "PxeBaseCodeBBTestMain.h" #include "PxeBaseCodeBBTestSupport.h" -EFI_EVENT TimerEvent; -UINTN gCallBackInvoked; -EFI_PXE_BASE_CODE_FUNCTION gFunction; -EFI_PXE_CALLBACK gOldCallBack; -EFI_HANDLE gHandle; +EFI_EVENT TimerEvent; +UINTN gCallBackInvoked; +EFI_PXE_BASE_CODE_FUNCTION gFunction; +EFI_PXE_CALLBACK gOldCallBack; +EFI_HANDLE gHandle; EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL NewCallBackProtocol = { - EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION, - NewCallBack -}; + EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION, + NewCallBack}; EFI_BB_TEST_PROTOCOL_FIELD gEfiPxeBcTestProtField = { - PXE_BASE_CODE_TEST_REVISION, - EFI_PXE_BASE_CODE_PROTOCOL_GUID, - L"PXE Base Code Protocol Test", - L"Test PXE Base Code Protocol" -}; + PXE_BASE_CODE_TEST_REVISION, + EFI_PXE_BASE_CODE_PROTOCOL_GUID, + L"PXE Base Code Protocol Test", + L"Test PXE Base Code Protocol"}; EFI_GUID gSupportProtocolGuid1[] = { - EFI_STANDARD_TEST_LIBRARY_GUID, - EFI_NULL_GUID -}; + EFI_STANDARD_TEST_LIBRARY_GUID, + EFI_NULL_GUID}; EFI_BB_TEST_ENTRY_FIELD gPxeTestEntryField[] = { - { - PXE_START_FUNCTION_TEST_GUID, - L"Start_Func", - L"Function Test of Start", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestNewStartFunctionTest - }, - { - PXE_STOP_FUNCTION_TEST_GUID, - L"Stop_Func", - L"Function Test of Stop", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestNewStopFunctionTest - }, - { - PXE_SETIPFILTER_FUNCTION_TEST_GUID, - L"SetIpFilter_Func", - L"Function Test of SetIpFilter", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestSetIpFilterFunctionTest - }, - { - PXE_START_CONFORMANCE_TEST_GUID, - L"Start_Conf", - L"Conformance Test for Start", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestNewStartConformanceTest - }, - { - PXE_STOP_CONFORMANCE_TEST_GUID, - L"Stop_Conf", - L"Conformance Test for Stop", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestNewStopConformanceTest - }, - { - PXE_ARP_CONFORMANCE_AUTO_TEST_GUID, - L"Arp_Conf", - L"Auto Conformance Test for Arp", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestArpConformanceAutoTest - }, - -#ifdef EFI_TEST_EXHAUSTIVE //Switch off the 5 old test case + {PXE_START_FUNCTION_TEST_GUID, + L"Start_Func", + L"Function Test of Start", + EFI_TEST_LEVEL_DEFAULT, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestNewStartFunctionTest}, + {PXE_STOP_FUNCTION_TEST_GUID, + L"Stop_Func", + L"Function Test of Stop", + EFI_TEST_LEVEL_DEFAULT, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestNewStopFunctionTest}, + {PXE_SETIPFILTER_FUNCTION_TEST_GUID, + L"SetIpFilter_Func", + L"Function Test of SetIpFilter", + EFI_TEST_LEVEL_DEFAULT, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestSetIpFilterFunctionTest}, + {PXE_START_CONFORMANCE_TEST_GUID, + L"Start_Conf", + L"Conformance Test for Start", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestNewStartConformanceTest}, + {PXE_STOP_CONFORMANCE_TEST_GUID, + L"Stop_Conf", + L"Conformance Test for Stop", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestNewStopConformanceTest}, + {PXE_ARP_CONFORMANCE_AUTO_TEST_GUID, + L"Arp_Conf", + L"Auto Conformance Test for Arp", + EFI_TEST_LEVEL_MINIMAL, + gSupportProtocolGuid1, + EFI_TEST_CASE_AUTO, + BBTestArpConformanceAutoTest}, + +#ifdef EFI_TEST_EXHAUSTIVE // Switch off the 5 old test case PXE_START_FUNCTION_TEST_GUID, L"Start_Func", L"Function Test of Start", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_AUTO, - BBTestStartFunctionTest - }, - { - PXE_STOP_FUNCTION_TEST_GUID, - L"Stop_Func", - L"Function Test of Stop", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestStopFunctionTest - }, - { - PXE_SETIPFILTER_FUNCTION_TEST_GUID, - L"SetIpFilter_Func", - L"Function Test of SetIpFilter", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestSetIpFilterFunctionTest - }, - { - PXE_START_CONFORMANCE_TEST_GUID, - L"Start_Conf", - L"Conformance Test for Start", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestStartConformanceTest - }, - { - PXE_STOP_CONFORMANCE_TEST_GUID, - L"Stop_Conf", - L"Conformance Test for Stop", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_AUTO, - BBTestStopConformanceTest - }, + BBTestStartFunctionTest}, + {PXE_STOP_FUNCTION_TEST_GUID, L"Stop_Func", L"Function Test of Stop", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_AUTO, BBTestStopFunctionTest}, {PXE_SETIPFILTER_FUNCTION_TEST_GUID, L"SetIpFilter_Func", L"Function Test of SetIpFilter", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_AUTO, BBTestSetIpFilterFunctionTest}, {PXE_START_CONFORMANCE_TEST_GUID, L"Start_Conf", L"Conformance Test for Start", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_AUTO, BBTestStartConformanceTest}, {PXE_STOP_CONFORMANCE_TEST_GUID, L"Stop_Conf", L"Conformance Test for Stop", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_AUTO, BBTestStopConformanceTest}, -//#ifdef EFI_TEST_EXHAUSTIVE - { - PXE_DHCP_FUNCTION_TEST_GUID, - L"Dhcp_Func_Manual", - L"Manual Function Test of Dhcp", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestDhcpFunctionTest - }, - { - PXE_DISCOVER_FUNCTION_TEST_GUID, - L"Discover_Func_Manual", - L"Manual Function Test of Discover", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestDiscoverFunctionTest - }, - { - PXE_MTFTP_FUNCTION_TEST_GUID, - L"Mtftp_Func_Manual", - L"Manual Function Test of Mtftp", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestMtftpFunctionTest - }, - { - PXE_UDPWRITE_FUNCTION_TEST_GUID, - L"UdpWrite_Func_Manual", - L"Manual Function Test of UdpWrite", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestUdpWriteFunctionTest - }, - { - PXE_UDPREAD_FUNCTION_TEST_GUID, - L"UdpRead_Func_Manual", - L"Manual Function Test of UdpRead", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestUdpReadFunctionTest - }, - { - PXE_ARP_FUNCTION_TEST_GUID, - L"Arp_Func_Manual", - L"Manual Function Test of Arp", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestArpFunctionTest - }, - { - PXE_SETPARAMETERS_FUNCTION_TEST_GUID, - L"SetParameters_Func_Manual", - L"Manual Function Test of SetParameters", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetParametersFunctionTest - }, - { - PXE_SETSTATIONIP_FUNCTION_TEST_GUID, - L"SetStationIp_Func_Manual", - L"Manual Function Test of SetStationIp", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetStationIpFunctionTest - }, - { - PXE_SETPACKETS_FUNCTION_TEST_GUID, - L"SetPackets_Func_Manual", - L"Manual Function Test of SetPackets", - EFI_TEST_LEVEL_DEFAULT, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetPacketsFunctionTest - }, - { - PXE_DHCP_CONFORMANCE_TEST_GUID, - L"Dhcp_Conf_Manual", - L"Manual Conformance Test for Dhcp", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestDhcpConformanceTest - }, - { - PXE_DISCOVER_CONFORMANCE_TEST_GUID, - L"Discover_Conf_Manual", - L"Manual Conformance Test for Discover", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestDiscoverConformanceTest - }, - { - PXE_Mtftp_CONFORMANCE_TEST_GUID, - L"Mtftp_Conf_Manual", - L"Manual Conformance Test for Mtftp", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestMtftpConformanceTest - }, - { - PXE_UDPWRITE_CONFORMANCE_TEST_GUID, - L"Dhcp_Conf_Manual", - L"Manual Conformance Test for UdpWrite", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestUdpWriteConformanceTest - }, - { - PXE_UDPREAD_CONFORMANCE_TEST_GUID, - L"UdpRead_Conf_Manual", - L"Manual Conformance Test for UdpRead", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestUdpReadConformanceTest - }, - { - PXE_SETIPFILTER_CONFORMANCE_TEST_GUID, - L"SetIpFilter_Conf_Manual", - L"Manual Conformance Test for SetIpFilter", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetIpFilterConformanceTest - }, - { - PXE_ARP_CONFORMANCE_MANUAL_TEST_GUID, - L"ARP_Conf_Manual", - L"Manual Conformance Test for ARP", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestArpConformanceManualTest - }, - { - PXE_SETPARAMETERS_CONFORMANCE_TEST_GUID, - L"SetParameters_Conf_Manual", - L"Manual Conformance Test for SetParameters", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetParametersConformanceTest - }, - { - PXE_SETSTATIONIP_CONFORMANCE_TEST_GUID, - L"SetStationIp_Conf_Manual", - L"Manual Conformance Test for SetStationIp", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetStationIpConformanceTest - }, - { - PXE_SETPACKETS_CONFORMANCE_TEST_GUID, - L"SetPackets_Conf_Manual", - L"Manual Conformance Test for SetPackets", - EFI_TEST_LEVEL_MINIMAL, - gSupportProtocolGuid1, - EFI_TEST_CASE_MANUAL, - BBTestSetPacketsConformanceTest - }, + // #ifdef EFI_TEST_EXHAUSTIVE + {PXE_DHCP_FUNCTION_TEST_GUID, L"Dhcp_Func_Manual", L"Manual Function Test of Dhcp", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestDhcpFunctionTest}, {PXE_DISCOVER_FUNCTION_TEST_GUID, L"Discover_Func_Manual", L"Manual Function Test of Discover", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestDiscoverFunctionTest}, {PXE_MTFTP_FUNCTION_TEST_GUID, L"Mtftp_Func_Manual", L"Manual Function Test of Mtftp", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestMtftpFunctionTest}, {PXE_UDPWRITE_FUNCTION_TEST_GUID, L"UdpWrite_Func_Manual", L"Manual Function Test of UdpWrite", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestUdpWriteFunctionTest}, {PXE_UDPREAD_FUNCTION_TEST_GUID, L"UdpRead_Func_Manual", L"Manual Function Test of UdpRead", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestUdpReadFunctionTest}, {PXE_ARP_FUNCTION_TEST_GUID, L"Arp_Func_Manual", L"Manual Function Test of Arp", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestArpFunctionTest}, {PXE_SETPARAMETERS_FUNCTION_TEST_GUID, L"SetParameters_Func_Manual", L"Manual Function Test of SetParameters", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetParametersFunctionTest}, {PXE_SETSTATIONIP_FUNCTION_TEST_GUID, L"SetStationIp_Func_Manual", L"Manual Function Test of SetStationIp", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetStationIpFunctionTest}, {PXE_SETPACKETS_FUNCTION_TEST_GUID, L"SetPackets_Func_Manual", L"Manual Function Test of SetPackets", EFI_TEST_LEVEL_DEFAULT, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetPacketsFunctionTest}, {PXE_DHCP_CONFORMANCE_TEST_GUID, L"Dhcp_Conf_Manual", L"Manual Conformance Test for Dhcp", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestDhcpConformanceTest}, {PXE_DISCOVER_CONFORMANCE_TEST_GUID, L"Discover_Conf_Manual", L"Manual Conformance Test for Discover", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestDiscoverConformanceTest}, {PXE_Mtftp_CONFORMANCE_TEST_GUID, L"Mtftp_Conf_Manual", L"Manual Conformance Test for Mtftp", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestMtftpConformanceTest}, {PXE_UDPWRITE_CONFORMANCE_TEST_GUID, L"Dhcp_Conf_Manual", L"Manual Conformance Test for UdpWrite", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestUdpWriteConformanceTest}, {PXE_UDPREAD_CONFORMANCE_TEST_GUID, L"UdpRead_Conf_Manual", L"Manual Conformance Test for UdpRead", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestUdpReadConformanceTest}, {PXE_SETIPFILTER_CONFORMANCE_TEST_GUID, L"SetIpFilter_Conf_Manual", L"Manual Conformance Test for SetIpFilter", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetIpFilterConformanceTest}, {PXE_ARP_CONFORMANCE_MANUAL_TEST_GUID, L"ARP_Conf_Manual", L"Manual Conformance Test for ARP", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestArpConformanceManualTest}, {PXE_SETPARAMETERS_CONFORMANCE_TEST_GUID, L"SetParameters_Conf_Manual", L"Manual Conformance Test for SetParameters", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetParametersConformanceTest}, {PXE_SETSTATIONIP_CONFORMANCE_TEST_GUID, L"SetStationIp_Conf_Manual", L"Manual Conformance Test for SetStationIp", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetStationIpConformanceTest}, {PXE_SETPACKETS_CONFORMANCE_TEST_GUID, L"SetPackets_Conf_Manual", L"Manual Conformance Test for SetPackets", EFI_TEST_LEVEL_MINIMAL, gSupportProtocolGuid1, EFI_TEST_CASE_MANUAL, BBTestSetPacketsConformanceTest}, #endif - EFI_NULL_GUID -}; - + EFI_NULL_GUID +} +; EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface; EFI_STATUS EFIAPI -BBTestPxeBcUnload ( - IN EFI_HANDLE ImageHandle - ); +BBTestPxeBcUnload( + IN EFI_HANDLE ImageHandle); /** * Creates/installs the BlackBox Interface and eminating Entry Point node list. @@ -349,34 +127,34 @@ BBTestPxeBcUnload ( */ EFI_STATUS EFIAPI -InitializeBBTestPxeBCProtocol ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) +InitializeBBTestPxeBCProtocol( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable) { EFI_STATUS Status; - EfiInitializeTestLib (ImageHandle, SystemTable); - SctInitializeLib (ImageHandle, SystemTable); - SctInitializeDriver (ImageHandle, SystemTable); + EfiInitializeTestLib(ImageHandle, SystemTable); + SctInitializeLib(ImageHandle, SystemTable); + SctInitializeDriver(ImageHandle, SystemTable); - Status = gtBS->CreateEvent (EVT_TIMER, 0, (EFI_EVENT_NOTIFY) NULL, NULL, &TimerEvent); - if (EFI_ERROR(Status)) { + Status = gtBS->CreateEvent(EVT_TIMER, 0, (EFI_EVENT_NOTIFY)NULL, NULL, &TimerEvent); + if (EFI_ERROR(Status)) + { return Status; } - Status = GetSystemDevicePathAndFilePath (ImageHandle); - if (EFI_ERROR(Status)) { + Status = GetSystemDevicePathAndFilePath(ImageHandle); + if (EFI_ERROR(Status)) + { return Status; } - return EfiInitAndInstallBBTestInterface ( - &ImageHandle, - &gEfiPxeBcTestProtField, - gPxeTestEntryField, - BBTestPxeBcUnload, - &gBBTestProtocolInterface - ); + return EfiInitAndInstallBBTestInterface( + &ImageHandle, + &gEfiPxeBcTestProtField, + gPxeTestEntryField, + BBTestPxeBcUnload, + &gBBTestProtocolInterface); } /** @@ -386,29 +164,29 @@ InitializeBBTestPxeBCProtocol ( */ EFI_STATUS EFIAPI -BBTestPxeBcUnload ( - IN EFI_HANDLE ImageHandle - ) +BBTestPxeBcUnload( + IN EFI_HANDLE ImageHandle) { EFI_STATUS Status; - if (gDevicePath != NULL) { - gtBS->FreePool (gDevicePath); + if (gDevicePath != NULL) + { + gtBS->FreePool(gDevicePath); } - if (gFilePath != NULL) { - gtBS->FreePool (gFilePath); + if (gFilePath != NULL) + { + gtBS->FreePool(gFilePath); } - Status = gtBS->CloseEvent (TimerEvent); - if (EFI_ERROR(Status)) { - + Status = gtBS->CloseEvent(TimerEvent); + if (EFI_ERROR(Status)) + { } - return EfiUninstallAndFreeBBTestInterface ( - ImageHandle, - gBBTestProtocolInterface - ); + return EfiUninstallAndFreeBBTestInterface( + ImageHandle, + gBBTestProtocolInterface); } /******************************* Internal Function ************************************/ @@ -422,42 +200,44 @@ BBTestPxeBcUnload ( * @return EFI_SUCCESS Finish the test successfully. */ EFI_STATUS -ChangePxeState ( - IN EFI_PXE_BASE_CODE_PROTOCOL *PxeInterface, - IN BOOLEAN UsingIpv6, - IN BOOLEAN Cur, - IN BOOLEAN Nxt - ) +ChangePxeState( + IN EFI_PXE_BASE_CODE_PROTOCOL *PxeInterface, + IN BOOLEAN UsingIpv6, + IN BOOLEAN Cur, + IN BOOLEAN Nxt) { - if (Cur==Nxt) { + if (Cur == Nxt) + { return EFI_SUCCESS; } - if (Cur == TRUE) { - return PxeInterface->Stop (PxeInterface); + if (Cur == TRUE) + { + return PxeInterface->Stop(PxeInterface); } - return PxeInterface->Start (PxeInterface, UsingIpv6); + return PxeInterface->Start(PxeInterface, UsingIpv6); } EFI_STATUS -ReInitPxeBaseCode ( - IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface -) +ReInitPxeBaseCode( + IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface) { - EFI_STATUS Status; + EFI_STATUS Status; // Re-initialize the EFI_PXE_BASE_CODE_PROTOCOL if (BcInterface->Mode->Started == TRUE) { - Status = BcInterface->Stop (BcInterface); - if (EFI_ERROR(Status)){ + Status = BcInterface->Stop(BcInterface); + if (EFI_ERROR(Status)) + { return Status; } } - Status = BcInterface->Start (BcInterface, FALSE); - if (EFI_ERROR(Status)){ + Status = BcInterface->Start(BcInterface, FALSE); + if (EFI_ERROR(Status)) + { return Status; } @@ -469,19 +249,19 @@ ReInitPxeBaseCode ( * @return TRUE to indicate user operation complete. */ BOOLEAN -WaitForAnyInput () +WaitForAnyInput() { - UINTN NoWait = 1, WaitIndex; - EFI_EVENT WaitList[1]; - EFI_STATUS Status; - EFI_INPUT_KEY Key; + UINTN NoWait = 1, WaitIndex; + EFI_EVENT WaitList[1]; + EFI_STATUS Status; + EFI_INPUT_KEY Key; - SctPrint (L"Press any key to continue..."); + SctPrint(L"Press any key to continue..."); // // Set 1 second periodic timer // - Status = gtBS->SetTimer (TimerEvent, TimerPeriodic, 10000000); + Status = gtBS->SetTimer(TimerEvent, TimerPeriodic, 10000000); // // Set up a wait list for a key and the timer @@ -492,50 +272,50 @@ WaitForAnyInput () // // Wait for either // - while (NoWait) { - Status = gtBS->WaitForEvent (NoWait, WaitList, &WaitIndex); + while (NoWait) + { + Status = gtBS->WaitForEvent(NoWait, WaitList, &WaitIndex); - switch (WaitIndex) { - case 0: - // - // Read the key - // - Status = gtST->ConIn->ReadKeyStroke (gtST->ConIn, &Key); - if (EFI_SUCCESS == Status) - NoWait = 0; - break; + switch (WaitIndex) + { + case 0: + // + // Read the key + // + Status = gtST->ConIn->ReadKeyStroke(gtST->ConIn, &Key); + if (EFI_SUCCESS == Status) + NoWait = 0; + break; - default: - break; + default: + break; } } - SctPrint (L"\r\n"); + SctPrint(L"\r\n"); // // Done, cancle periodic timer // - Status = gtBS->SetTimer (TimerEvent, TimerCancel, 0); + Status = gtBS->SetTimer(TimerEvent, TimerCancel, 0); return TRUE; - } - BOOLEAN -WaitForUserCheck () +WaitForUserCheck() { - UINTN NoWait = 1, WaitIndex; - EFI_EVENT WaitList[1]; - EFI_STATUS Status; - EFI_INPUT_KEY Key; - BOOLEAN PressYes=FALSE; + UINTN NoWait = 1, WaitIndex; + EFI_EVENT WaitList[1]; + EFI_STATUS Status; + EFI_INPUT_KEY Key; + BOOLEAN PressYes = FALSE; - SctPrint (L"\r\nPress \"Y\" or \"N\"..."); + SctPrint(L"\r\nPress \"Y\" or \"N\"..."); // // Set 1 second periodic timer // - Status = gtBS->SetTimer (TimerEvent, TimerPeriodic, 10000000); + Status = gtBS->SetTimer(TimerEvent, TimerPeriodic, 10000000); // // Set up a wait list for a key and the timer @@ -546,83 +326,88 @@ WaitForUserCheck () // // Wait for either // - while (NoWait) { - Status = gtBS->WaitForEvent (NoWait, WaitList, &WaitIndex); + while (NoWait) + { + Status = gtBS->WaitForEvent(NoWait, WaitList, &WaitIndex); - switch (WaitIndex) { - case 0: - // - // Read the key - // - Status = gtST->ConIn->ReadKeyStroke (gtST->ConIn, &Key); - SctAPrint ((char *)(&Key.UnicodeChar)); - switch (Key.UnicodeChar) { - case 'Y': - case 'y': - NoWait = 0; - PressYes = TRUE; - break; + switch (WaitIndex) + { + case 0: + // + // Read the key + // + Status = gtST->ConIn->ReadKeyStroke(gtST->ConIn, &Key); + SctAPrint((char *)(&Key.UnicodeChar)); + switch (Key.UnicodeChar) + { + case 'Y': + case 'y': + NoWait = 0; + PressYes = TRUE; + break; - case 'N': - case 'n': - NoWait = 0; - PressYes = FALSE; - break; - - default : - SctPrint (L"\n"); - break; - } + case 'N': + case 'n': + NoWait = 0; + PressYes = FALSE; break; default: + SctPrint(L"\n"); break; + } + break; + + default: + break; } } - SctPrint (L"\r\n"); + SctPrint(L"\r\n"); // // Done, cancle periodic timer // - Status = gtBS->SetTimer (TimerEvent, TimerCancel, 0); + Status = gtBS->SetTimer(TimerEvent, TimerCancel, 0); return PressYes; - } EFI_PXE_BASE_CODE_CALLBACK_STATUS EFIAPI -NewCallBack ( - IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *This, - IN EFI_PXE_BASE_CODE_FUNCTION Function, - IN BOOLEAN Received, - IN UINT32 PacketLen, - IN EFI_PXE_BASE_CODE_PACKET *Packet OPTIONAL - ) +NewCallBack( + IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_FUNCTION Function, + IN BOOLEAN Received, + IN UINT32 PacketLen, + IN EFI_PXE_BASE_CODE_PACKET *Packet OPTIONAL) { - if (Function == gFunction) { - gCallBackInvoked ++; + if (Function == gFunction) + { + gCallBackInvoked++; return EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT; - } else if (gOldCallBack != NULL) { - return gOldCallBack (This, Function, Received, PacketLen, Packet); - } else { + } + else if (gOldCallBack != NULL) + { + return gOldCallBack(This, Function, Received, PacketLen, Packet); + } + else + { return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE; } } EFI_STATUS -HookReturnAbortCallBack ( - IN EFI_PXE_BASE_CODE_FUNCTION FuncNum, - IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface - ) +HookReturnAbortCallBack( + IN EFI_PXE_BASE_CODE_FUNCTION FuncNum, + IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface) { - EFI_STATUS Status; - EFI_HANDLE *HandleBuffer; - UINTN HandleCount; - UINTN Index; - EFI_PXE_BASE_CODE_PROTOCOL *Interface; + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + EFI_PXE_BASE_CODE_PROTOCOL *Interface; EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *BcCallBack; - BOOLEAN NewMakeCallback; + BOOLEAN NewMakeCallback; // // init global variables @@ -634,14 +419,14 @@ HookReturnAbortCallBack ( // // Locate all handles of Pxe protocol // - Status = gtBS->LocateHandleBuffer ( - ByProtocol, - &gBlackBoxEfiPxeBaseCodeProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { + Status = gtBS->LocateHandleBuffer( + ByProtocol, + &gBlackBoxEfiPxeBaseCodeProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer); + if (EFI_ERROR(Status)) + { return EFI_NOT_FOUND; } @@ -649,67 +434,70 @@ HookReturnAbortCallBack ( // Looking for the handle corresponding to the BcInterface // gHandle = NULL; - for (Index = 0; Index < HandleCount; Index += 1) { - Status = gtBS->HandleProtocol ( - HandleBuffer[Index], - &gBlackBoxEfiPxeBaseCodeProtocolGuid, - (VOID **)&Interface - ); - if (BcInterface == Interface) { + for (Index = 0; Index < HandleCount; Index += 1) + { + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gBlackBoxEfiPxeBaseCodeProtocolGuid, + (VOID **)&Interface); + if (BcInterface == Interface) + { gHandle = HandleBuffer[Index]; break; } } - gtBS->FreePool (HandleBuffer); + gtBS->FreePool(HandleBuffer); - if (gHandle == NULL) { + if (gHandle == NULL) + { return EFI_NOT_FOUND; } // // Is Pxe Callback probocol installed? // - Status = gtBS->HandleProtocol ( - gHandle, - &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, - (VOID **)&BcCallBack - ); - if (Status == EFI_SUCCESS) { + Status = gtBS->HandleProtocol( + gHandle, + &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, + (VOID **)&BcCallBack); + if (Status == EFI_SUCCESS) + { // Replace the previous call back function gOldCallBack = BcCallBack->Callback; BcCallBack->Callback = NewCallBack; - } else { + } + else + { // // Install a call back protocol // - Status = gtBS->InstallProtocolInterface ( - &gHandle, - &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, - EFI_NATIVE_INTERFACE, - &NewCallBackProtocol - ); - if (EFI_ERROR(Status)) { + Status = gtBS->InstallProtocolInterface( + &gHandle, + &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, + EFI_NATIVE_INTERFACE, + &NewCallBackProtocol); + if (EFI_ERROR(Status)) + { return Status; } // // Enable PXE to use call back // NewMakeCallback = TRUE; - Status = BcInterface->SetParameters ( - BcInterface, - NULL, - NULL, - NULL, - NULL, - &NewMakeCallback - ); - if (EFI_ERROR(Status)) { - gtBS->UninstallProtocolInterface ( - gHandle, - &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, - &NewCallBackProtocol - ); + Status = BcInterface->SetParameters( + BcInterface, + NULL, + NULL, + NULL, + NULL, + &NewMakeCallback); + if (EFI_ERROR(Status)) + { + gtBS->UninstallProtocolInterface( + gHandle, + &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, + &NewCallBackProtocol); return Status; } } @@ -718,48 +506,50 @@ HookReturnAbortCallBack ( } EFI_STATUS -UnHookReturnAbortCallBack ( - IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface - ) +UnHookReturnAbortCallBack( + IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface) { - EFI_STATUS Status; + EFI_STATUS Status; EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *BcCallBack; - BOOLEAN NewMakeCallback; + BOOLEAN NewMakeCallback; - if (gOldCallBack != NULL) { - Status = gtBS->HandleProtocol ( - gHandle, - &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, - (VOID **)&BcCallBack - ); - if (EFI_ERROR(Status)) { + if (gOldCallBack != NULL) + { + Status = gtBS->HandleProtocol( + gHandle, + &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, + (VOID **)&BcCallBack); + if (EFI_ERROR(Status)) + { return Status; } // restore the previous call back function BcCallBack->Callback = gOldCallBack; gOldCallBack = NULL; - } else { + } + else + { // // Disable PXE to use call back // NewMakeCallback = FALSE; - Status = BcInterface->SetParameters ( - BcInterface, - NULL, - NULL, - NULL, - NULL, - &NewMakeCallback - ); - if (EFI_ERROR(Status)) { + Status = BcInterface->SetParameters( + BcInterface, + NULL, + NULL, + NULL, + NULL, + &NewMakeCallback); + if (EFI_ERROR(Status)) + { return Status; } - Status = gtBS->UninstallProtocolInterface ( - gHandle, - &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, - &NewCallBackProtocol - ); - if (EFI_ERROR(Status)) { + Status = gtBS->UninstallProtocolInterface( + gHandle, + &gBlackBoxEfiPxeBaseCodeCallbackProtocolGuid, + &NewCallBackProtocol); + if (EFI_ERROR(Status)) + { return Status; } } @@ -768,44 +558,44 @@ UnHookReturnAbortCallBack ( } BOOLEAN -IsPxePacketValid ( - IN EFI_PXE_PACKET_TYPE PacketType, - IN EFI_PXE_BASE_CODE_PACKET *Packet - ) +IsPxePacketValid( + IN EFI_PXE_PACKET_TYPE PacketType, + IN EFI_PXE_BASE_CODE_PACKET *Packet) { - //BootpOpCode + // BootpOpCode switch (PacketType) { - case EFI_PXE_PACKET_TYPE_DHCP_DISCOVER: - return TRUE; + case EFI_PXE_PACKET_TYPE_DHCP_DISCOVER: + return TRUE; - case EFI_PXE_PACKET_TYPE_DHCP_ACK: - return TRUE; + case EFI_PXE_PACKET_TYPE_DHCP_ACK: + return TRUE; - case EFI_PXE_PACKET_TYPE_PROXY_OFFER: - return TRUE; + case EFI_PXE_PACKET_TYPE_PROXY_OFFER: + return TRUE; - case EFI_PXE_PACKET_TYPE_PXE_DISCOVER: - return TRUE; + case EFI_PXE_PACKET_TYPE_PXE_DISCOVER: + return TRUE; - case EFI_PXE_PACKET_TYPE_PXE_OFFER: - return TRUE; + case EFI_PXE_PACKET_TYPE_PXE_OFFER: + return TRUE; - default: - return FALSE; + default: + return FALSE; } } BOOLEAN -IsBufZeroed ( - IN CHAR8 *Buf, - IN UINTN Len - ) +IsBufZeroed( + IN CHAR8 *Buf, + IN UINTN Len) { UINTN i; - for (i=0; iRaw),1472/2); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Raw Packet]", SctStrLen(L"[Raw Packet]")); + LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16 *)(Packet->Raw), 1472 / 2); TempUint16 = (UINT16)Packet->Dhcpv4.BootpOpcode; - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Opcode]", SctStrLen (L"[Bootp Opcode]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Opcode]", SctStrLen(L"[Bootp Opcode]")); LOG_UINT16_HEX_DFLT(LoggingLib, TempUint16); TempUint16 = (UINT16)Packet->Dhcpv4.BootpHwType; - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Hw Type]", SctStrLen (L"[Bootp Hw Type]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Hw Type]", SctStrLen(L"[Bootp Hw Type]")); LOG_UINT16_HEX_DFLT(LoggingLib, TempUint16); TempUint16 = (UINT16)Packet->Dhcpv4.BootpHwAddrLen; - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Hw Addr Len]", SctStrLen (L"[Bootp Hw Addr Len]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Hw Addr Len]", SctStrLen(L"[Bootp Hw Addr Len]")); LOG_UINT16_HEX_DFLT(LoggingLib, TempUint16); TempUint16 = (UINT16)Packet->Dhcpv4.BootpGateHops; - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Gate Hop]", SctStrLen (L"[Bootp Gate Hop]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Gate Hop]", SctStrLen(L"[Bootp Gate Hop]")); LOG_UINT16_HEX_DFLT(LoggingLib, TempUint16); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Iden]", SctStrLen (L"[Bootp Iden]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Iden]", SctStrLen(L"[Bootp Iden]")); LOG_UINT32_HEX_DFLT(LoggingLib, (Packet->Dhcpv4.BootpIdent)); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Seconds]", SctStrLen (L"[Bootp Seconds]")); - LOG_UINT16_HEX_DFLT(LoggingLib,Packet->Dhcpv4.BootpSeconds); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Seconds]", SctStrLen(L"[Bootp Seconds]")); + LOG_UINT16_HEX_DFLT(LoggingLib, Packet->Dhcpv4.BootpSeconds); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Flags]", SctStrLen (L"[Bootp Flags]")); - LOG_UINT16_HEX_DFLT(LoggingLib,(Packet->Dhcpv4.BootpFlags)); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Flags]", SctStrLen(L"[Bootp Flags]")); + LOG_UINT16_HEX_DFLT(LoggingLib, (Packet->Dhcpv4.BootpFlags)); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp CiAddr]", SctStrLen (L"[Bootp CiAddr]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp CiAddr]", SctStrLen(L"[Bootp CiAddr]")); LOG_IP_HEX_DFLT(LoggingLib, Packet->Dhcpv4.BootpCiAddr); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp YiAddr]", SctStrLen (L"[Bootp YiAddr]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp YiAddr]", SctStrLen(L"[Bootp YiAddr]")); LOG_IP_HEX_DFLT(LoggingLib, Packet->Dhcpv4.BootpYiAddr); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp SiAddr]", SctStrLen (L"[Bootp SiAddr]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp SiAddr]", SctStrLen(L"[Bootp SiAddr]")); LOG_IP_HEX_DFLT(LoggingLib, Packet->Dhcpv4.BootpSiAddr); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp GiAddr]", SctStrLen (L"[Bootp GiAddr]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp GiAddr]", SctStrLen(L"[Bootp GiAddr]")); LOG_IP_HEX_DFLT(LoggingLib, Packet->Dhcpv4.BootpGiAddr); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp HwAddr]", SctStrLen (L"[Bootp HwAddr]")); - LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16*)(Packet->Dhcpv4.BootpSrvName), 32); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp HwAddr]", SctStrLen(L"[Bootp HwAddr]")); + LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16 *)(Packet->Dhcpv4.BootpSrvName), 32); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp SrvName]", SctStrLen (L"[Bootp SrvName]")); - LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16*)(Packet->Dhcpv4.BootpHwAddr), 8); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp SrvName]", SctStrLen(L"[Bootp SrvName]")); + LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16 *)(Packet->Dhcpv4.BootpHwAddr), 8); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp BootFile]", SctStrLen (L"[Bootp BootFile]")); - LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16*)(Packet->Dhcpv4.BootpBootFile), 64); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp BootFile]", SctStrLen(L"[Bootp BootFile]")); + LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16 *)(Packet->Dhcpv4.BootpBootFile), 64); - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Magik]", SctStrLen (L"[Bootp Magik]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Bootp Magik]", SctStrLen(L"[Bootp Magik]")); LOG_UINT32_HEX_DFLT(LoggingLib, Packet->Dhcpv4.DhcpMagik); return EFI_SUCCESS; } EFI_STATUS -PrintArpTable ( - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_PXE_BASE_CODE_MODE *Mode - ) +PrintArpTable( + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_PXE_BASE_CODE_MODE *Mode) { - UINTN i, cnt; - CHAR16 *Buffer; + UINTN i, cnt; + CHAR16 *Buffer; - LoggingLib->DumpBuf (LoggingLib, EFI_VERBOSE_LEVEL_DEFAULT, L"Arp Entry is", (UINT32)SctStrLen (L"Arp Entry is"), EFI_DUMP_ASCII); + LoggingLib->DumpBuf(LoggingLib, EFI_VERBOSE_LEVEL_DEFAULT, L"Arp Entry is", (UINT32)SctStrLen(L"Arp Entry is"), EFI_DUMP_ASCII); cnt = 0; for (i = 0; i < EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES; i++) { - if (FALSE == IsBufZeroed ((CHAR8 *)(&Mode->ArpCache[i]), sizeof (EFI_PXE_BASE_CODE_ARP_ENTRY))) + if (FALSE == IsBufZeroed((CHAR8 *)(&Mode->ArpCache[i]), sizeof(EFI_PXE_BASE_CODE_ARP_ENTRY))) { - cnt ++; + cnt++; Buffer = (CHAR16 *)(&Mode->ArpCache[i]); - LoggingLib->DumpBuf (LoggingLib, EFI_VERBOSE_LEVEL_DEFAULT, Buffer, (UINT32)SctStrLen (Buffer), EFI_DUMP_HEX); + LoggingLib->DumpBuf(LoggingLib, EFI_VERBOSE_LEVEL_DEFAULT, Buffer, (UINT32)SctStrLen(Buffer), EFI_DUMP_HEX); } } if (cnt == Mode->ArpCacheEntries) return EFI_SUCCESS; - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"Arp Cache Unmatched", SctStrLen (L"Arp Cache Unmatched")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"Arp Cache Unmatched", SctStrLen(L"Arp Cache Unmatched")); return EFI_INVALID_PARAMETER; } EFI_STATUS SetIpAndMask( - IN EFI_IP_ADDRESS *EfiIp, - IN EFI_IP_ADDRESS *EfiMask, - IN UINT32 NumIpv4, - IN UINT32 NumMask - ) + IN EFI_IP_ADDRESS *EfiIp, + IN EFI_IP_ADDRESS *EfiMask, + IN UINT32 NumIpv4, + IN UINT32 NumMask) { - EFI_STATUS Status; + EFI_STATUS Status; if (NULL != EfiIp) { - Status = SetIpAddress (EfiIp, NumIpv4); + Status = SetIpAddress(EfiIp, NumIpv4); if (EFI_ERROR(Status)) return Status; } if (NULL != EfiMask) { - Status = SetIpAddress (EfiMask, NumMask); + Status = SetIpAddress(EfiMask, NumMask); if (EFI_ERROR(Status)) return Status; } @@ -940,10 +726,9 @@ SetIpAndMask( } EFI_STATUS -SetIpAddress ( - IN OUT EFI_IP_ADDRESS *EfiIp, - IN UINT32 NumIpv4 - ) +SetIpAddress( + IN OUT EFI_IP_ADDRESS *EfiIp, + IN UINT32 NumIpv4) { if (NULL == EfiIp) return EFI_INVALID_PARAMETER; @@ -957,21 +742,24 @@ SetIpAddress ( } BOOLEAN -IsIpMaskEqual ( - IN EFI_IP_ADDRESS *NewStationIp, - IN EFI_IP_ADDRESS *NewSubnetMask, - IN EFI_IP_ADDRESS *OldStationIp, - IN EFI_IP_ADDRESS *OldSubnetMask - ) +IsIpMaskEqual( + IN EFI_IP_ADDRESS *NewStationIp, + IN EFI_IP_ADDRESS *NewSubnetMask, + IN EFI_IP_ADDRESS *OldStationIp, + IN EFI_IP_ADDRESS *OldSubnetMask) { - if (NULL != NewStationIp){ - if (FALSE == (0 == SctCompareMem (NewStationIp, OldStationIp, sizeof (EFI_IP_ADDRESS)))) { + if (NULL != NewStationIp) + { + if (FALSE == (0 == SctCompareMem(NewStationIp, OldStationIp, sizeof(EFI_IP_ADDRESS)))) + { return FALSE; } } - if (NULL != NewSubnetMask){ - if (FALSE == (0 == SctCompareMem (NewSubnetMask, OldSubnetMask, sizeof (EFI_IP_ADDRESS)))){ + if (NULL != NewSubnetMask) + { + if (FALSE == (0 == SctCompareMem(NewSubnetMask, OldSubnetMask, sizeof(EFI_IP_ADDRESS)))) + { return FALSE; } } @@ -979,55 +767,59 @@ IsIpMaskEqual ( } EFI_STATUS -CopyPxePacket ( - IN EFI_PXE_BASE_CODE_PACKET *DestPacket, - IN EFI_PXE_BASE_CODE_PACKET *SrcPacket - ) +CopyPxePacket( + IN EFI_PXE_BASE_CODE_PACKET *DestPacket, + IN EFI_PXE_BASE_CODE_PACKET *SrcPacket) { - if (NULL == DestPacket) { + if (NULL == DestPacket) + { return EFI_SUCCESS; } - if (NULL == SrcPacket) { + if (NULL == SrcPacket) + { return EFI_INVALID_PARAMETER; } - SctCopyMem (DestPacket, SrcPacket, sizeof (EFI_PXE_BASE_CODE_PACKET)); + SctCopyMem(DestPacket, SrcPacket, sizeof(EFI_PXE_BASE_CODE_PACKET)); return EFI_SUCCESS; } BOOLEAN -IsPxePacketEqual ( - IN EFI_PXE_BASE_CODE_PACKET *DestPacket, - IN EFI_PXE_BASE_CODE_PACKET *SrcPacket - ) +IsPxePacketEqual( + IN EFI_PXE_BASE_CODE_PACKET *DestPacket, + IN EFI_PXE_BASE_CODE_PACKET *SrcPacket) { - if (NULL == DestPacket && NULL == SrcPacket) { + if (NULL == DestPacket && NULL == SrcPacket) + { return TRUE; } - if (0==SctCompareMem (DestPacket, SrcPacket, sizeof (EFI_PXE_BASE_CODE_PACKET))){ + if (0 == SctCompareMem(DestPacket, SrcPacket, sizeof(EFI_PXE_BASE_CODE_PACKET))) + { return TRUE; } return FALSE; } BOOLEAN -IsIpFilterEqual ( - IN EFI_PXE_BASE_CODE_IP_FILTER *SrcIpFilter, - IN EFI_PXE_BASE_CODE_IP_FILTER *DstIpFilter - ) +IsIpFilterEqual( + IN EFI_PXE_BASE_CODE_IP_FILTER *SrcIpFilter, + IN EFI_PXE_BASE_CODE_IP_FILTER *DstIpFilter) { - if (NULL == SrcIpFilter && NULL == DstIpFilter) { + if (NULL == SrcIpFilter && NULL == DstIpFilter) + { return TRUE; } if (NULL != SrcIpFilter && NULL != DstIpFilter) { - if (SrcIpFilter->IpCnt != DstIpFilter->IpCnt) { + if (SrcIpFilter->IpCnt != DstIpFilter->IpCnt) + { return FALSE; } - if (0==SctCompareMem (SrcIpFilter->IpList, DstIpFilter->IpList, sizeof (EFI_IP_ADDRESS) * SrcIpFilter->IpCnt)){ + if (0 == SctCompareMem(SrcIpFilter->IpList, DstIpFilter->IpList, sizeof(EFI_IP_ADDRESS) * SrcIpFilter->IpCnt)) + { return TRUE; } } @@ -1035,71 +827,167 @@ IsIpFilterEqual ( } EFI_STATUS -LogUdpPacket ( - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_IP_ADDRESS *DestIp, - IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort, - IN EFI_IP_ADDRESS *SrcIp, - IN EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, - IN UINTN BufferSize, - IN VOID *BufferPtr - ) +LogUdpPacket( + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_IP_ADDRESS *DestIp, + IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort, + IN EFI_IP_ADDRESS *SrcIp, + IN EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, + IN UINTN BufferSize, + IN VOID *BufferPtr) { - if (NULL!=DestIp) + if (NULL != DestIp) { - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Dest IP]", SctStrLen (L"[Dest IP]")); - //LOG_IP_HEX_DFLT (LoggingLib, DestIp->v4.Addr); - LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16*)&DestIp, sizeof (EFI_IP_ADDRESS)/2); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Dest IP]", SctStrLen(L"[Dest IP]")); + // LOG_IP_HEX_DFLT (LoggingLib, DestIp->v4.Addr); + LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16 *)&DestIp, sizeof(EFI_IP_ADDRESS) / 2); } if (NULL != DestPort) { - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Dest Port]", SctStrLen (L"[Dest Port]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Dest Port]", SctStrLen(L"[Dest Port]")); LOG_UINT16_HEX_DFLT(LoggingLib, *DestPort); } if (NULL != SrcIp) { - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Src IP]", SctStrLen (L"[Src IP]")); - //LOG_IP_HEX_DFLT (LoggingLib, SrcIp->v4.Addr); - LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16*)&SrcIp, sizeof (EFI_IP_ADDRESS)/2); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Src IP]", SctStrLen(L"[Src IP]")); + // LOG_IP_HEX_DFLT (LoggingLib, SrcIp->v4.Addr); + LOG_BUF_HEX_DFLT(LoggingLib, (CHAR16 *)&SrcIp, sizeof(EFI_IP_ADDRESS) / 2); } if (NULL != SrcPort) { - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Src Port]", SctStrLen (L"[Src Port]")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"[Src Port]", SctStrLen(L"[Src Port]")); LOG_UINT16_HEX_DFLT(LoggingLib, *SrcPort); } - if (0!=BufferSize) + if (0 != BufferSize) { - LOG_CHAR16_ASCII_DFLT(LoggingLib, L"Received UDP Packet", SctStrLen (L"Received UDP Packet")); + LOG_CHAR16_ASCII_DFLT(LoggingLib, L"Received UDP Packet", SctStrLen(L"Received UDP Packet")); LOG_BUF_HEX_DFLT(LoggingLib, BufferPtr, BufferSize); } return EFI_SUCCESS; } EFI_STATUS -LogChar8String ( - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN CHAR8 *Buffer, - IN UINTN Len - ) +LogChar8String( + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN CHAR8 *Buffer, + IN UINTN Len) { - EFI_STATUS Status; - CHAR16 *TempBuffer; + EFI_STATUS Status; + CHAR16 *TempBuffer; - if (NULL == Buffer) { + if (NULL == Buffer) + { return EFI_INVALID_PARAMETER; } - Status = gtBS->AllocatePool (EfiRuntimeServicesData, Len * sizeof (CHAR16), (VOID **) &TempBuffer); - if (EFI_ERROR(Status)) { + Status = gtBS->AllocatePool(EfiRuntimeServicesData, Len * sizeof(CHAR16), (VOID **)&TempBuffer); + if (EFI_ERROR(Status)) + { return Status; } - SctZeroMem (&TempBuffer, Len * sizeof (CHAR16)); + SctZeroMem(&TempBuffer, Len * sizeof(CHAR16)); - LOG_CHAR16_ASCII_DFLT (LoggingLib, TempBuffer, Len); + LOG_CHAR16_ASCII_DFLT(LoggingLib, TempBuffer, Len); - gtBS->FreePool (TempBuffer); + gtBS->FreePool(TempBuffer); return EFI_SUCCESS; } + +EFI_STATUS LocateDevicePathFromBcInterface(IN EFI_PXE_BASE_CODE_PROTOCOL *BcInterface2, IN EFI_DEVICE_PATH_PROTOCOL **DevicePath, IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib) +{ + EFI_STATUS Status; + + UINTN NoHandles, Index; + EFI_HANDLE *HandleBuffer; + EFI_PXE_BASE_CODE_PROTOCOL *OtherBcInterface2; + + // + // Locate the Handle that the BcInterface is bound to + // + Status = gtBS->LocateHandleBuffer( + ByProtocol, + &gBlackBoxEfiPxeBaseCodeProtocolGuid, + NULL, + &NoHandles, + &HandleBuffer); + if (EFI_ERROR(Status)) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.LocateHandle - LocateHandle", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status); + return Status; + } + + if (NoHandles <= 0) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.LocateHandle - LocateHandle", + L"%a:%d:Device Error", + __FILE__, + (UINTN)__LINE__); + return EFI_DEVICE_ERROR; + } + + // + // Find the exact handle that BcInterface bound to + // + for (Index = 0; Index < NoHandles; Index++) + { + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gBlackBoxEfiPxeBaseCodeProtocolGuid, + (VOID **) &OtherBcInterface2); + if (EFI_ERROR(Status)) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.HandleProtocol - HandleProtocol", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status); + + gtBS->FreePool(HandleBuffer); + return Status; + } + + if (OtherBcInterface2 == BcInterface2) + { + break; + } + } + + // + // Locate the Loaded Image DevicePath Protocol bound to PXE_BASE_CODE Protocol + // + if (Index >= NoHandles) + { + // + // No Handle Found!! + // + gtBS->FreePool(HandleBuffer); + return EFI_DEVICE_ERROR; + } + + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gBlackBoxEfiDevicePathProtocolGuid, + (VOID **) DevicePath); + + gtBS->FreePool(HandleBuffer); + return Status; +} \ No newline at end of file diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestConformance.c index e73c7cebcbcf..b1b9005059bb 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestConformance.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestConformance.c @@ -54,6 +54,8 @@ BBTestStartConformanceTest ( EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_SIMPLE_NETWORK_STATE State1, State2; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -72,6 +74,23 @@ BBTestStartConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStarted. // If not, change the state to EfiSimpleNetworkStarted. @@ -160,7 +179,8 @@ BBTestStopConformanceTest ( EFI_TEST_ASSERTION AssertionType; EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_SIMPLE_NETWORK_STATE State1, State2; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -179,6 +199,23 @@ BBTestStopConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -266,7 +303,8 @@ BBTestInitializeConformanceTest ( EFI_TEST_ASSERTION AssertionType; EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_SIMPLE_NETWORK_STATE State1, State2; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -285,6 +323,23 @@ BBTestInitializeConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -377,7 +432,8 @@ BBTestResetConformanceTest ( EFI_TEST_ASSERTION AssertionType; EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_SIMPLE_NETWORK_STATE State1, State2; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -396,6 +452,23 @@ BBTestResetConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -488,7 +561,8 @@ BBTestShutdownConformanceTest ( EFI_TEST_ASSERTION AssertionType; EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_SIMPLE_NETWORK_STATE State1, State2; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -507,6 +581,23 @@ BBTestShutdownConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -594,7 +685,8 @@ BBTestReceiveFilterConformanceTest ( EFI_TEST_ASSERTION AssertionType; EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_MAC_ADDRESS MAC; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -613,6 +705,23 @@ BBTestReceiveFilterConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -840,7 +949,8 @@ BBTestStationAddressConformanceTest ( EFI_TEST_ASSERTION AssertionType; EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface; EFI_SIMPLE_NETWORK_STATE State1, State2; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -859,6 +969,23 @@ BBTestStationAddressConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -988,7 +1115,8 @@ BBTestStatisticsConformanceTest ( EFI_SIMPLE_NETWORK_STATE State1, State2; EFI_NETWORK_STATISTICS StatisticsTable; UINTN StatisticsSize; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -1007,6 +1135,23 @@ BBTestStatisticsConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -1164,7 +1309,8 @@ BBTestMCastIpToMacConformanceTest ( EFI_SIMPLE_NETWORK_STATE State1, State2; EFI_IP_ADDRESS IP; EFI_MAC_ADDRESS MAC; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -1183,6 +1329,23 @@ BBTestMCastIpToMacConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -1279,6 +1442,8 @@ BBTestNVDataConformanceTest ( EFI_SIMPLE_NETWORK_STATE State1, State2, State3; VOID *Buffer; UINT32 CheckPoint1State; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -1297,6 +1462,23 @@ BBTestNVDataConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the network interface support NvData if not return // @@ -1526,7 +1708,8 @@ BBTestGetStatusConformanceTest ( VOID *TxBuf; UINT32 InterruptStatus; //UINT32 *pInterruptStatus; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -1545,6 +1728,23 @@ BBTestGetStatusConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -1717,7 +1917,8 @@ BBTestTransmitConformanceTest ( EFI_MAC_ADDRESS SrcAddr; EFI_MAC_ADDRESS DestAddr; UINT16 Protocol; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -1736,6 +1937,23 @@ BBTestTransmitConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. @@ -1993,7 +2211,8 @@ BBTestReceiveConformanceTest ( EFI_MAC_ADDRESS SrcAddr; EFI_MAC_ADDRESS DestAddr; UINT16 Protocol; - + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + CHAR16 *DevicePathStr; // // Get the Standard Library Interface // @@ -2012,6 +2231,23 @@ BBTestReceiveConformanceTest ( // SnpInterface = (EFI_SIMPLE_NETWORK_PROTOCOL *)ClientInterface; + Status=LocateDevicePathFromSnpInterface(SnpInterface,&DevicePath,StandardLib); + if (Status == EFI_SUCCESS) { + DevicePathStr = NULL; + DevicePathStr = SctDevicePathToStr (DevicePath); + if (DevicePathStr != NULL) { + StandardLib->RecordMessage ( + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"Device Path: %s\r\n", + DevicePathStr + ); + Status = gtBS->FreePool (DevicePathStr); + if (EFI_ERROR(Status)) + return Status; + DevicePathStr=NULL; + } + } // // Check whether the state of network interface is EfiSimpleNetworkStopped. // If not, change the state to EfiSimpleNetworkStopped. diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.c index 918fac7dbd7f..21d20b82b025 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleNetwork/BlackBoxTest/SimpleNetworkBBTestMain.c @@ -336,3 +336,99 @@ BBTestSimpleNetworkUnload ( ); } + +EFI_STATUS LocateDevicePathFromSnpInterface(IN EFI_SIMPLE_NETWORK_PROTOCOL *SnpInterface2, IN EFI_DEVICE_PATH_PROTOCOL **DevicePath, IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib) +{ + EFI_STATUS Status; + + UINTN NoHandles, Index; + EFI_HANDLE *HandleBuffer; + EFI_SIMPLE_NETWORK_PROTOCOL *OtherSnpInterface2; + + // + // Locate the Handle that the SnpInterface is bound to + // + Status = gtBS->LocateHandleBuffer( + ByProtocol, + &gBlackBoxEfiSimpleNetworkProtocolGuid, + NULL, + &NoHandles, + &HandleBuffer); + if (EFI_ERROR(Status)) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.LocateHandle - LocateHandle", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status); + return Status; + } + + if (NoHandles <= 0) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.LocateHandle - LocateHandle", + L"%a:%d:Device Error", + __FILE__, + (UINTN)__LINE__); + return EFI_DEVICE_ERROR; + } + + // + // Find the exact handle that SnpInterface bound to + // + for (Index = 0; Index < NoHandles; Index++) + { + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gBlackBoxEfiSimpleNetworkProtocolGuid, + (VOID **) &OtherSnpInterface2); + if (EFI_ERROR(Status)) + { + StandardLib->RecordAssertion( + StandardLib, + EFI_TEST_ASSERTION_FAILED, + gTestGenericFailureGuid, + L"BS.HandleProtocol - HandleProtocol", + L"%a:%d:Status - %r", + __FILE__, + (UINTN)__LINE__, + Status); + + gtBS->FreePool(HandleBuffer); + return Status; + } + + if (OtherSnpInterface2 == SnpInterface2) + { + break; + } + } + + // + // Locate the Loaded DevicePath Protocol bound to SIMPLE_NETWORK Protocol + // + if (Index >= NoHandles) + { + // + // No Handle Found!! + // + gtBS->FreePool(HandleBuffer); + return EFI_DEVICE_ERROR; + } + + Status = gtBS->HandleProtocol( + HandleBuffer[Index], + &gBlackBoxEfiDevicePathProtocolGuid, + (VOID **) DevicePath); + + gtBS->FreePool(HandleBuffer); + return Status; +} \ No newline at end of file -- 2.34.1 ®‹©²* Šy,b‹«yÇ¢½æ¥–g¬±¨²Ç§¶Ú-†+ ®‹©V'°ý©—#§–)Þ×_x߸m¶›?ýçdÚ èº›"£ø?uëÞ—ùž²Æ {ýu÷�û2ë^N¬NŠbrm¦Ïÿ‚º.¦È¨þk×N¸ï]ºãþ}ó�=ìj躓°�êÝz÷¥úŒ'z·�“h+¢êlŠ…'²æìr¸›zm¦ÏÿyÙ6‚º.¦È¨þÝz÷¥þéì¹´®ž|–jx®g( IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119487): https://edk2.groups.io/g/devel/message/119487 Mute This Topic: https://groups.io/mt/106471264/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-