]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PlatformPei/PlatformPei.c
Add ArmPlatformPkg from ARM Ltd. patch.
[mirror_edk2.git] / ArmPlatformPkg / PlatformPei / PlatformPei.c
1 /** @file
2 *
3 * Copyright (c) 2011, ARM Limited. All rights reserved.
4 *
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
9 *
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.
12 *
13 **/
14
15 //
16 // The package level header files this module uses
17 //
18 #include <PiPei.h>
19 //
20 // The protocols, PPI and GUID defintions for this module
21 //
22 #include <Ppi/MasterBootMode.h>
23 #include <Ppi/BootInRecoveryMode.h>
24 //
25 // The Library classes this module consumes
26 //
27 #include <Library/DebugLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/PcdLib.h>
30 #include <Library/HobLib.h>
31
32
33 //
34 // Module globals
35 //
36 EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
37 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
38 &gEfiPeiMasterBootModePpiGuid,
39 NULL
40 };
41
42 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
43 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
44 &gEfiPeiBootInRecoveryModePpiGuid,
45 NULL
46 };
47
48 EFI_STATUS
49 EFIAPI
50 InitializePlatformPeim (
51 IN EFI_PEI_FILE_HANDLE FileHandle,
52 IN CONST EFI_PEI_SERVICES **PeiServices
53 )
54 /*++
55
56 Routine Description:
57
58
59
60 Arguments:
61
62 FileHandle - Handle of the file being invoked.
63 PeiServices - Describes the list of possible PEI Services.
64
65 Returns:
66
67 Status - EFI_SUCCESS if the boot mode could be set
68
69 --*/
70 {
71 EFI_STATUS Status;
72 UINTN BootMode;
73
74 DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));
75
76 BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
77
78 BuildFvHob (FixedPcdGet32(PcdFlashFvMainBase), FixedPcdGet32(PcdFlashFvMainSize));
79
80 //
81 // Let's assume things are OK if not told otherwise
82 // Should we read an environment variable in order to easily change this?
83 //
84 BootMode = BOOT_WITH_FULL_CONFIGURATION;
85
86 Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
87 ASSERT_EFI_ERROR (Status);
88
89 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
90 ASSERT_EFI_ERROR (Status);
91
92 if (BootMode == BOOT_IN_RECOVERY_MODE) {
93 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
94 ASSERT_EFI_ERROR (Status);
95 }
96
97 return Status;
98 }