EfiMpServiceProtocolDynamicCmdUnitTest.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /** @file
  2. Produce "MpProtocolUnitTest" shell dynamic command.
  3. Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Library/UefiBootServicesTableLib.h>
  7. #include <Protocol/ShellDynamicCommand.h>
  8. #include "EfiMpServicesUnitTestCommom.h"
  9. CHAR16 *mMpProtocolUnitTestCommandHelp = L".TH MpProtocolUnitTest 0\r\n.SH NAME\r\nDisplay unit test results of EFI MP services protocol.\r\n";
  10. EFI_STATUS
  11. EFIAPI
  12. EfiMpServiceProtocolUnitTest (
  13. VOID
  14. );
  15. /**
  16. This is the shell command handler function pointer callback type. This
  17. function handles the command when it is invoked in the shell.
  18. @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
  19. @param[in] SystemTable The pointer to the system table.
  20. @param[in] ShellParameters The parameters associated with the command.
  21. @param[in] Shell The instance of the shell protocol used in the context
  22. of processing this command.
  23. @return EFI_SUCCESS the operation was successful
  24. @return other the operation failed.
  25. **/
  26. SHELL_STATUS
  27. EFIAPI
  28. MpProtocolUnitTestCommandHandler (
  29. IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
  30. IN EFI_SYSTEM_TABLE *SystemTable,
  31. IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
  32. IN EFI_SHELL_PROTOCOL *Shell
  33. )
  34. {
  35. return EfiMpServiceProtocolUnitTest ();
  36. }
  37. /**
  38. This is the command help handler function pointer callback type. This
  39. function is responsible for displaying help information for the associated
  40. command.
  41. @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
  42. @param[in] Language The pointer to the language string to use.
  43. @return string Pool allocated help string, must be freed by caller
  44. **/
  45. CHAR16 *
  46. EFIAPI
  47. MpProtocolUnitTestCommandGetHelp (
  48. IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
  49. IN CONST CHAR8 *Language
  50. )
  51. {
  52. return AllocateCopyPool (StrSize (mMpProtocolUnitTestCommandHelp), mMpProtocolUnitTestCommandHelp);
  53. }
  54. EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mMpProtocolUnitTestDynamicCommand = {
  55. L"MpProtocolUnitTest",
  56. MpProtocolUnitTestCommandHandler,
  57. MpProtocolUnitTestCommandGetHelp
  58. };
  59. /**
  60. Entry point of MpProtocolUnitTest Dynamic Command.
  61. Produce the DynamicCommand protocol to handle "MpProtocolUnitTest" command.
  62. @param ImageHandle The image handle of the process.
  63. @param SystemTable The EFI System Table pointer.
  64. @retval EFI_SUCCESS Tftp command is executed successfully.
  65. @retval EFI_ABORTED HII package was failed to initialize.
  66. @retval others Other errors when executing MpProtocolUnitTest command.
  67. **/
  68. EFI_STATUS
  69. EFIAPI
  70. MpProtocolUnitTestCommandInitialize (
  71. IN EFI_HANDLE ImageHandle,
  72. IN EFI_SYSTEM_TABLE *SystemTable
  73. )
  74. {
  75. EFI_STATUS Status;
  76. Status = gBS->InstallProtocolInterface (
  77. &ImageHandle,
  78. &gEfiShellDynamicCommandProtocolGuid,
  79. EFI_NATIVE_INTERFACE,
  80. &mMpProtocolUnitTestDynamicCommand
  81. );
  82. ASSERT_EFI_ERROR (Status);
  83. return Status;
  84. }
  85. /**
  86. Driver unload handler.
  87. @param ImageHandle The image handle of the process.
  88. @retval EFI_SUCCESS The image is unloaded.
  89. @retval Others Failed to unload the image.
  90. **/
  91. EFI_STATUS
  92. EFIAPI
  93. MpProtocolUnitTestUnload (
  94. IN EFI_HANDLE ImageHandle
  95. )
  96. {
  97. EFI_STATUS Status;
  98. Status = gBS->UninstallProtocolInterface (
  99. ImageHandle,
  100. &gEfiShellDynamicCommandProtocolGuid,
  101. &mMpProtocolUnitTestDynamicCommand
  102. );
  103. ASSERT_EFI_ERROR (Status);
  104. return Status;
  105. }