2011-02-01 06:41:42 +01:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011, ARM Limited. All rights reserved.
|
|
|
|
*
|
2014-08-19 15:29:52 +02:00
|
|
|
* This program and the accompanying materials
|
|
|
|
* are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
* which accompanies this distribution. The full text of the license may be found at
|
|
|
|
* http://opensource.org/licenses/bsd-license.php
|
|
|
|
*
|
|
|
|
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
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
|
|
|
//
|
|
|
|
// The protocols, PPI and GUID defintions for this module
|
|
|
|
//
|
2011-09-23 01:11:03 +02:00
|
|
|
#include <Ppi/ArmGlobalVariable.h>
|
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
|
|
|
|
|
|
|
#include <Guid/ArmGlobalVariableHob.h>
|
2011-02-01 06:41:42 +01: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
|
|
|
|
//
|
|
|
|
EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
|
|
|
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
|
|
|
&gEfiPeiMasterBootModePpiGuid,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
|
|
|
|
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
|
|
|
&gEfiPeiBootInRecoveryModePpiGuid,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2011-09-23 01:11:03 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
BuildGlobalVariableHob (
|
|
|
|
IN EFI_PHYSICAL_ADDRESS GlobalVariableBase,
|
|
|
|
IN UINT32 GlobalVariableSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
ARM_HOB_GLOBAL_VARIABLE *Hob;
|
|
|
|
|
|
|
|
Status = PeiServicesCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE), (VOID**)&Hob);
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
|
|
|
|
Hob->GlobalVariableBase = GlobalVariableBase;
|
|
|
|
Hob->GlobalVariableSize = GlobalVariableSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-01 06:41:42 +01:00
|
|
|
/*++
|
|
|
|
|
|
|
|
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;
|
|
|
|
UINTN BootMode;
|
2011-09-23 01:11:03 +02:00
|
|
|
ARM_GLOBAL_VARIABLE_PPI *ArmGlobalVariablePpi;
|
|
|
|
EFI_PHYSICAL_ADDRESS GlobalVariableBase;
|
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
|
|
|
|
2011-07-01 13:45:32 +02:00
|
|
|
PlatformPeim ();
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2011-09-23 01:11:03 +02:00
|
|
|
Status = PeiServicesLocatePpi (&gArmGlobalVariablePpiGuid, 0, NULL, (VOID**)&ArmGlobalVariablePpi);
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
Status = ArmGlobalVariablePpi->GetGlobalVariableMemory (&GlobalVariableBase);
|
|
|
|
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
// Declare the Global Variable HOB
|
|
|
|
BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 14:18:28 +02:00
|
|
|
BootMode = ArmPlatformGetBootMode ();
|
2011-02-01 06:41:42 +01:00
|
|
|
Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
if (BootMode == BOOT_IN_RECOVERY_MODE) {
|
|
|
|
Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|