2011-02-01 06:41:42 +01:00
|
|
|
/** @file
|
2021-02-25 17:37:35 +01:00
|
|
|
|
|
|
|
Copyright (c) 2011, ARM Limited. All rights reserved.
|
|
|
|
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
|
2011-02-01 06:41:42 +01:00
|
|
|
**/
|
|
|
|
|
|
|
|
#include <PiPei.h>
|
2011-07-01 13:45:32 +02:00
|
|
|
|
2011-02-01 06:41:42 +01:00
|
|
|
//
|
2019-02-06 16:40:38 +01:00
|
|
|
// The protocols, PPI and GUID definitions for this module
|
2011-02-01 06:41:42 +01:00
|
|
|
//
|
|
|
|
#include <Ppi/MasterBootMode.h>
|
|
|
|
#include <Ppi/BootInRecoveryMode.h>
|
2011-09-23 01:11:03 +02:00
|
|
|
#include <Ppi/GuidedSectionExtraction.h>
|
2011-02-01 06:41:42 +01:00
|
|
|
//
|
|
|
|
// The Library classes this module consumes
|
|
|
|
//
|
2011-09-23 01:11:03 +02:00
|
|
|
#include <Library/ArmPlatformLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/HobLib.h>
|
2011-02-01 06:41:42 +01:00
|
|
|
#include <Library/PeimEntryPoint.h>
|
2011-09-23 01:11:03 +02:00
|
|
|
#include <Library/PeiServicesLib.h>
|
2011-02-01 06:41:42 +01:00
|
|
|
#include <Library/PcdLib.h>
|
2011-09-23 01:11:03 +02:00
|
|
|
|
2011-07-01 13:45:32 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializePlatformPeim (
|
|
|
|
IN EFI_PEI_FILE_HANDLE FileHandle,
|
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices
|
|
|
|
);
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2011-07-01 21:51:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PlatformPeim (
|
|
|
|
VOID
|
|
|
|
);
|
2011-02-01 06:41:42 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Module globals
|
|
|
|
//
|
2015-08-07 19:27:33 +02:00
|
|
|
CONST EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
|
2011-02-01 06:41:42 +01:00
|
|
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
|
|
|
&gEfiPeiMasterBootModePpiGuid,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-08-07 19:27:33 +02:00
|
|
|
CONST EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
|
2011-02-01 06:41:42 +01:00
|
|
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
|
|
|
&gEfiPeiBootInRecoveryModePpiGuid,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2011-02-01 06:41:42 +01:00
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
FileHandle - Handle of the file being invoked.
|
|
|
|
PeiServices - Describes the list of possible PEI Services.
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2011-02-01 06:41:42 +01:00
|
|
|
Returns:
|
|
|
|
|
|
|
|
Status - EFI_SUCCESS if the boot mode could be set
|
|
|
|
|
|
|
|
--*/
|
2011-07-01 13:45:32 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializePlatformPeim (
|
|
|
|
IN EFI_PEI_FILE_HANDLE FileHandle,
|
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices
|
|
|
|
)
|
2011-02-01 06:41:42 +01:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2017-11-01 13:57:26 +01:00
|
|
|
EFI_BOOT_MODE BootMode;
|
2011-02-01 06:41:42 +01:00
|
|
|
|
2015-03-02 17:19:32 +01:00
|
|
|
DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));
|
2011-02-01 06:41:42 +01:00
|
|
|
|
2017-11-01 13:57:26 +01:00
|
|
|
Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ());
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2011-07-01 13:45:32 +02:00
|
|
|
PlatformPeim ();
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2017-11-01 13:57:26 +01:00
|
|
|
Status = PeiServicesGetBootMode (&BootMode);
|
2011-02-01 06:41:42 +01:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2017-11-01 13:57:26 +01:00
|
|
|
Status = PeiServicesInstallPpi (&mPpiListBootMode);
|
2011-02-01 06:41:42 +01:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
if (BootMode == BOOT_IN_RECOVERY_MODE) {
|
2017-11-01 13:57:26 +01:00
|
|
|
Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
|
2011-02-01 06:41:42 +01:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|