PlatformPeim.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /** @file
  2. Copyright (c) 2011, ARM Limited. All rights reserved.
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #include <PiPei.h>
  6. //
  7. // The protocols, PPI and GUID definitions for this module
  8. //
  9. #include <Ppi/MasterBootMode.h>
  10. #include <Ppi/BootInRecoveryMode.h>
  11. #include <Ppi/GuidedSectionExtraction.h>
  12. //
  13. // The Library classes this module consumes
  14. //
  15. #include <Library/ArmPlatformLib.h>
  16. #include <Library/BaseMemoryLib.h>
  17. #include <Library/DebugLib.h>
  18. #include <Library/HobLib.h>
  19. #include <Library/PeimEntryPoint.h>
  20. #include <Library/PeiServicesLib.h>
  21. #include <Library/PcdLib.h>
  22. EFI_STATUS
  23. EFIAPI
  24. InitializePlatformPeim (
  25. IN EFI_PEI_FILE_HANDLE FileHandle,
  26. IN CONST EFI_PEI_SERVICES **PeiServices
  27. );
  28. EFI_STATUS
  29. EFIAPI
  30. PlatformPeim (
  31. VOID
  32. );
  33. //
  34. // Module globals
  35. //
  36. CONST EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
  37. (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  38. &gEfiPeiMasterBootModePpiGuid,
  39. NULL
  40. };
  41. CONST EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
  42. (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  43. &gEfiPeiBootInRecoveryModePpiGuid,
  44. NULL
  45. };
  46. /*++
  47. Routine Description:
  48. Arguments:
  49. FileHandle - Handle of the file being invoked.
  50. PeiServices - Describes the list of possible PEI Services.
  51. Returns:
  52. Status - EFI_SUCCESS if the boot mode could be set
  53. --*/
  54. EFI_STATUS
  55. EFIAPI
  56. InitializePlatformPeim (
  57. IN EFI_PEI_FILE_HANDLE FileHandle,
  58. IN CONST EFI_PEI_SERVICES **PeiServices
  59. )
  60. {
  61. EFI_STATUS Status;
  62. EFI_BOOT_MODE BootMode;
  63. DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Platform PEIM Loaded\n"));
  64. Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ());
  65. ASSERT_EFI_ERROR (Status);
  66. PlatformPeim ();
  67. Status = PeiServicesGetBootMode (&BootMode);
  68. ASSERT_EFI_ERROR (Status);
  69. Status = PeiServicesInstallPpi (&mPpiListBootMode);
  70. ASSERT_EFI_ERROR (Status);
  71. if (BootMode == BOOT_IN_RECOVERY_MODE) {
  72. Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
  73. ASSERT_EFI_ERROR (Status);
  74. }
  75. return Status;
  76. }