3 * Copyright (c) 2011, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // The protocols, PPI and GUID defintions for this module
20 #include <Ppi/ArmGlobalVariable.h>
21 #include <Ppi/MasterBootMode.h>
22 #include <Ppi/BootInRecoveryMode.h>
23 #include <Ppi/GuidedSectionExtraction.h>
25 // The Library classes this module consumes
27 #include <Library/ArmPlatformLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/PeimEntryPoint.h>
32 #include <Library/PeiServicesLib.h>
33 #include <Library/PcdLib.h>
35 #include <Guid/ArmGlobalVariableHob.h>
39 InitializePlatformPeim (
40 IN EFI_PEI_FILE_HANDLE FileHandle
,
41 IN CONST EFI_PEI_SERVICES
**PeiServices
53 EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode
= {
54 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
55 &gEfiPeiMasterBootModePpiGuid
,
59 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode
= {
60 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
61 &gEfiPeiBootInRecoveryModePpiGuid
,
67 BuildGlobalVariableHob (
68 IN EFI_PHYSICAL_ADDRESS GlobalVariableBase
,
69 IN UINT32 GlobalVariableSize
73 ARM_HOB_GLOBAL_VARIABLE
*Hob
;
75 Status
= PeiServicesCreateHob (EFI_HOB_TYPE_GUID_EXTENSION
, sizeof (ARM_HOB_GLOBAL_VARIABLE
), (VOID
**)&Hob
);
76 if (!EFI_ERROR(Status
)) {
77 CopyGuid (&(Hob
->Header
.Name
), &gArmGlobalVariableGuid
);
78 Hob
->GlobalVariableBase
= GlobalVariableBase
;
79 Hob
->GlobalVariableSize
= GlobalVariableSize
;
91 FileHandle - Handle of the file being invoked.
92 PeiServices - Describes the list of possible PEI Services.
96 Status - EFI_SUCCESS if the boot mode could be set
101 InitializePlatformPeim (
102 IN EFI_PEI_FILE_HANDLE FileHandle
,
103 IN CONST EFI_PEI_SERVICES
**PeiServices
108 ARM_GLOBAL_VARIABLE_PPI
*ArmGlobalVariablePpi
;
109 EFI_PHYSICAL_ADDRESS GlobalVariableBase
;
111 DEBUG ((EFI_D_ERROR
, "Platform PEIM Loaded\n"));
115 Status
= PeiServicesLocatePpi (&gArmGlobalVariablePpiGuid
, 0, NULL
, (VOID
**)&ArmGlobalVariablePpi
);
116 if (!EFI_ERROR(Status
)) {
117 Status
= ArmGlobalVariablePpi
->GetGlobalVariableMemory (&GlobalVariableBase
);
119 if (!EFI_ERROR(Status
)) {
120 // Declare the Global Variable HOB
121 BuildGlobalVariableHob (GlobalVariableBase
, FixedPcdGet32 (PcdPeiGlobalVariableSize
));
125 BootMode
= ArmPlatformGetBootMode ();
126 Status
= (**PeiServices
).SetBootMode (PeiServices
, (UINT8
) BootMode
);
127 ASSERT_EFI_ERROR (Status
);
129 Status
= (**PeiServices
).InstallPpi (PeiServices
, &mPpiListBootMode
);
130 ASSERT_EFI_ERROR (Status
);
132 if (BootMode
== BOOT_IN_RECOVERY_MODE
) {
133 Status
= (**PeiServices
).InstallPpi (PeiServices
, &mPpiListRecoveryBootMode
);
134 ASSERT_EFI_ERROR (Status
);