--- /dev/null
+/** @file\r
+ Produce "MpProtocolUnitTest" shell dynamic command.\r
+\r
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Protocol/ShellDynamicCommand.h>\r
+#include "EfiMpServicesUnitTestCommom.h"\r
+\r
+CHAR16 *mMpProtocolUnitTestCommandHelp = L".TH MpProtocolUnitTest 0\r\n.SH NAME\r\nDisplay unit test results of EFI MP services protocol.\r\n";\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMpServiceProtocolUnitTest (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This is the shell command handler function pointer callback type. This\r
+ function handles the command when it is invoked in the shell.\r
+\r
+ @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+ @param[in] SystemTable The pointer to the system table.\r
+ @param[in] ShellParameters The parameters associated with the command.\r
+ @param[in] Shell The instance of the shell protocol used in the context\r
+ of processing this command.\r
+\r
+ @return EFI_SUCCESS the operation was successful\r
+ @return other the operation failed.\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+MpProtocolUnitTestCommandHandler (\r
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
+ IN EFI_SYSTEM_TABLE *SystemTable,\r
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
+ IN EFI_SHELL_PROTOCOL *Shell\r
+ )\r
+{\r
+ return EfiMpServiceProtocolUnitTest ();\r
+}\r
+\r
+/**\r
+ This is the command help handler function pointer callback type. This\r
+ function is responsible for displaying help information for the associated\r
+ command.\r
+\r
+ @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+ @param[in] Language The pointer to the language string to use.\r
+\r
+ @return string Pool allocated help string, must be freed by caller\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+MpProtocolUnitTestCommandGetHelp (\r
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,\r
+ IN CONST CHAR8 *Language\r
+ )\r
+{\r
+ return AllocateCopyPool (StrSize (mMpProtocolUnitTestCommandHelp), mMpProtocolUnitTestCommandHelp);\r
+}\r
+\r
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mMpProtocolUnitTestDynamicCommand = {\r
+ L"MpProtocolUnitTest",\r
+ MpProtocolUnitTestCommandHandler,\r
+ MpProtocolUnitTestCommandGetHelp\r
+};\r
+\r
+/**\r
+ Entry point of MpProtocolUnitTest Dynamic Command.\r
+\r
+ Produce the DynamicCommand protocol to handle "MpProtocolUnitTest" command.\r
+\r
+ @param ImageHandle The image handle of the process.\r
+ @param SystemTable The EFI System Table pointer.\r
+\r
+ @retval EFI_SUCCESS Tftp command is executed successfully.\r
+ @retval EFI_ABORTED HII package was failed to initialize.\r
+ @retval others Other errors when executing MpProtocolUnitTest command.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MpProtocolUnitTestCommandInitialize (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEfiShellDynamicCommandProtocolGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ &mMpProtocolUnitTestDynamicCommand\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Driver unload handler.\r
+\r
+ @param ImageHandle The image handle of the process.\r
+\r
+ @retval EFI_SUCCESS The image is unloaded.\r
+ @retval Others Failed to unload the image.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MpProtocolUnitTestUnload (\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->UninstallProtocolInterface (\r
+ ImageHandle,\r
+ &gEfiShellDynamicCommandProtocolGuid,\r
+ &mMpProtocolUnitTestDynamicCommand\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+## @file\r
+# DXE driver that provides Shell 'MpProtocolUnitTest' dynamic command to test EfiMpServiceProtocol.\r
+#\r
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = EfiMpServiceProtocolDynamicCmdUnitTest\r
+ FILE_GUID = 8C4624B1-58CC-4DF6-9E6D-09B38D67DFA6\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = MpProtocolUnitTestCommandInitialize\r
+ UNLOAD_IMAGE = MpProtocolUnitTestUnload\r
+\r
+[Sources]\r
+ EfiMpServicesUnitTestCommom.c\r
+ EfiMpServicesUnitTestCommom.h\r
+ EfiMpServiceProtocolUnitTest.c\r
+ EfiMpServiceProtocolDynamicCmdUnitTest.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ BaseMemoryLib\r
+ MemoryAllocationLib\r
+ UefiDriverEntryPoint\r
+ UefiBootServicesTableLib\r
+ UefiLib\r
+ UnitTestPersistenceLib\r
+ UnitTestLib\r
+\r
+[Protocols]\r
+ gEfiMpServiceProtocolGuid ## CONSUMES\r
+ gEfiShellDynamicCommandProtocolGuid ## PRODUCES\r
+\r
+[Depex]\r
+ TRUE\r
--- /dev/null
+## @file\r
+# UEFI application that tests EfiMpServiceProtocol in Shell.\r
+#\r
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = MpProtocolUnitTest\r
+ FILE_GUID = 4CEE6399-A22C-4FFD-B148-3A56B1DD83F1\r
+ MODULE_TYPE = UEFI_APPLICATION\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = DxeEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64\r
+#\r
+\r
+[Sources]\r
+ EfiMpServicesUnitTestCommom.c\r
+ EfiMpServicesUnitTestCommom.h\r
+ EfiMpServiceProtocolUnitTest.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ BaseMemoryLib\r
+ MemoryAllocationLib\r
+ UefiApplicationEntryPoint\r
+ UefiBootServicesTableLib\r
+ UnitTestPersistenceLib\r
+ UnitTestLib\r
+\r
+[Protocols]\r
+ gEfiMpServiceProtocolGuid ## CONSUMES\r