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.
16 // The package level header files this module uses
20 // The protocols, PPI and GUID defintions for this module
22 #include <Ppi/MasterBootMode.h>
23 #include <Ppi/BootInRecoveryMode.h>
25 // The Library classes this module consumes
27 #include <Library/DebugLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/PcdLib.h>
30 #include <Library/HobLib.h>
36 EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode
= {
37 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
38 &gEfiPeiMasterBootModePpiGuid
,
42 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode
= {
43 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
44 &gEfiPeiBootInRecoveryModePpiGuid
,
50 InitializePlatformPeim (
51 IN EFI_PEI_FILE_HANDLE FileHandle
,
52 IN CONST EFI_PEI_SERVICES
**PeiServices
62 FileHandle - Handle of the file being invoked.
63 PeiServices - Describes the list of possible PEI Services.
67 Status - EFI_SUCCESS if the boot mode could be set
74 DEBUG ((EFI_D_ERROR
, "Platform PEIM Loaded\n"));
76 BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize
), PcdGet8 (PcdPrePiCpuIoSize
));
78 BuildFvHob (FixedPcdGet32(PcdFlashFvMainBase
), FixedPcdGet32(PcdFlashFvMainSize
));
81 // Let's assume things are OK if not told otherwise
82 // Should we read an environment variable in order to easily change this?
84 BootMode
= BOOT_WITH_FULL_CONFIGURATION
;
86 Status
= (**PeiServices
).SetBootMode (PeiServices
, (UINT8
) BootMode
);
87 ASSERT_EFI_ERROR (Status
);
89 Status
= (**PeiServices
).InstallPpi (PeiServices
, &mPpiListBootMode
);
90 ASSERT_EFI_ERROR (Status
);
92 if (BootMode
== BOOT_IN_RECOVERY_MODE
) {
93 Status
= (**PeiServices
).InstallPpi (PeiServices
, &mPpiListRecoveryBootMode
);
94 ASSERT_EFI_ERROR (Status
);