BootModePei.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /** @file
  2. Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
  3. Portions copyright (c) 2011, Apple Inc. All rights reserved.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. //
  7. // The package level header files this module uses
  8. //
  9. #include <PiPei.h>
  10. #include <Library/PcdLib.h>
  11. #include <Library/PeiServicesLib.h>
  12. //
  13. // The protocols, PPI and GUID defintions for this module
  14. //
  15. #include <Ppi/MasterBootMode.h>
  16. #include <Ppi/BootInRecoveryMode.h>
  17. //
  18. // The Library classes this module consumes
  19. //
  20. #include <Library/DebugLib.h>
  21. #include <Library/PeimEntryPoint.h>
  22. //
  23. // Module globals
  24. //
  25. EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
  26. (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  27. &gEfiPeiMasterBootModePpiGuid,
  28. NULL
  29. };
  30. EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
  31. (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  32. &gEfiPeiBootInRecoveryModePpiGuid,
  33. NULL
  34. };
  35. EFI_STATUS
  36. EFIAPI
  37. InitializeBootMode (
  38. IN EFI_PEI_FILE_HANDLE FileHandle,
  39. IN CONST EFI_PEI_SERVICES **PeiServices
  40. )
  41. /*++
  42. Routine Description:
  43. Peform the boot mode determination logic
  44. Arguments:
  45. PeiServices - General purpose services available to every PEIM.
  46. Returns:
  47. Status - EFI_SUCCESS if the boot mode could be set
  48. **/
  49. {
  50. EFI_STATUS Status;
  51. EFI_BOOT_MODE BootMode;
  52. DEBUG ((DEBUG_ERROR, "Emu Boot Mode PEIM Loaded\n"));
  53. BootMode = FixedPcdGet32 (PcdEmuBootMode);
  54. Status = PeiServicesSetBootMode (BootMode);
  55. ASSERT_EFI_ERROR (Status);
  56. Status = PeiServicesInstallPpi (&mPpiListBootMode);
  57. ASSERT_EFI_ERROR (Status);
  58. if (BootMode == BOOT_IN_RECOVERY_MODE) {
  59. Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
  60. ASSERT_EFI_ERROR (Status);
  61. }
  62. return Status;
  63. }