]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmPlatformPkg/PlatformPei/PlatformPeim.c
ArmPlatformPkg/PlatformPeim: allow PlatformPeiLib to set the boot mode
[mirror_edk2.git] / ArmPlatformPkg / PlatformPei / PlatformPeim.c
... / ...
CommitLineData
1/** @file\r
2*\r
3* Copyright (c) 2011, ARM Limited. All rights reserved.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#include <PiPei.h>\r
16\r
17//\r
18// The protocols, PPI and GUID defintions for this module\r
19//\r
20#include <Ppi/MasterBootMode.h>\r
21#include <Ppi/BootInRecoveryMode.h>\r
22#include <Ppi/GuidedSectionExtraction.h>\r
23//\r
24// The Library classes this module consumes\r
25//\r
26#include <Library/ArmPlatformLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/DebugLib.h>\r
29#include <Library/HobLib.h>\r
30#include <Library/PeimEntryPoint.h>\r
31#include <Library/PeiServicesLib.h>\r
32#include <Library/PcdLib.h>\r
33\r
34EFI_STATUS\r
35EFIAPI\r
36InitializePlatformPeim (\r
37 IN EFI_PEI_FILE_HANDLE FileHandle,\r
38 IN CONST EFI_PEI_SERVICES **PeiServices\r
39 );\r
40\r
41EFI_STATUS\r
42EFIAPI\r
43PlatformPeim (\r
44 VOID\r
45 );\r
46\r
47//\r
48// Module globals\r
49//\r
50CONST EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {\r
51 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
52 &gEfiPeiMasterBootModePpiGuid,\r
53 NULL\r
54};\r
55\r
56CONST EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {\r
57 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
58 &gEfiPeiBootInRecoveryModePpiGuid,\r
59 NULL\r
60};\r
61\r
62/*++\r
63\r
64Routine Description:\r
65\r
66\r
67\r
68Arguments:\r
69\r
70 FileHandle - Handle of the file being invoked.\r
71 PeiServices - Describes the list of possible PEI Services.\r
72\r
73Returns:\r
74\r
75 Status - EFI_SUCCESS if the boot mode could be set\r
76\r
77--*/\r
78EFI_STATUS\r
79EFIAPI\r
80InitializePlatformPeim (\r
81 IN EFI_PEI_FILE_HANDLE FileHandle,\r
82 IN CONST EFI_PEI_SERVICES **PeiServices\r
83 )\r
84{\r
85 EFI_STATUS Status;\r
86 EFI_BOOT_MODE BootMode;\r
87\r
88 DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));\r
89\r
90 Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ());\r
91 ASSERT_EFI_ERROR (Status);\r
92\r
93 PlatformPeim ();\r
94\r
95 Status = PeiServicesGetBootMode (&BootMode);\r
96 ASSERT_EFI_ERROR (Status);\r
97\r
98 Status = PeiServicesInstallPpi (&mPpiListBootMode);\r
99 ASSERT_EFI_ERROR (Status);\r
100\r
101 if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
102 Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
103 ASSERT_EFI_ERROR (Status);\r
104 }\r
105\r
106 return Status;\r
107}\r