]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PlatformPei/PlatformPeim.c
ArmPlatformPkg/PlatformPei: Generate a library from the PEI Module
[mirror_edk2.git] / ArmPlatformPkg / PlatformPei / PlatformPeim.c
CommitLineData
1d5d0ae9 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
1d5d0ae9 15#include <PiPei.h>\r
48835130 16\r
1d5d0ae9 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//\r
23// The Library classes this module consumes\r
24//\r
1d5d0ae9 25#include <Library/PeimEntryPoint.h>\r
26#include <Library/PcdLib.h>\r
48835130 27#include <Library/DebugLib.h>\r
28#include <Library/ArmPlatformLib.h>\r
1d5d0ae9 29\r
48835130 30EFI_STATUS\r
31EFIAPI\r
32InitializePlatformPeim (\r
33 IN EFI_PEI_FILE_HANDLE FileHandle,\r
34 IN CONST EFI_PEI_SERVICES **PeiServices\r
35 );\r
1d5d0ae9 36\r
37//\r
38// Module globals\r
39//\r
40EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {\r
41 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
42 &gEfiPeiMasterBootModePpiGuid,\r
43 NULL\r
44};\r
45\r
46EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {\r
47 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
48 &gEfiPeiBootInRecoveryModePpiGuid,\r
49 NULL\r
50};\r
51\r
1d5d0ae9 52/*++\r
53\r
54Routine Description:\r
55\r
56 \r
57\r
58Arguments:\r
59\r
60 FileHandle - Handle of the file being invoked.\r
61 PeiServices - Describes the list of possible PEI Services.\r
62 \r
63Returns:\r
64\r
65 Status - EFI_SUCCESS if the boot mode could be set\r
66\r
67--*/\r
48835130 68EFI_STATUS\r
69EFIAPI\r
70InitializePlatformPeim (\r
71 IN EFI_PEI_FILE_HANDLE FileHandle,\r
72 IN CONST EFI_PEI_SERVICES **PeiServices\r
73 )\r
1d5d0ae9 74{\r
75 EFI_STATUS Status;\r
76 UINTN BootMode;\r
77\r
78 DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));\r
79\r
48835130 80 PlatformPeim ();\r
1d5d0ae9 81 \r
a534d714 82 BootMode = ArmPlatformGetBootMode ();\r
1d5d0ae9 83 Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);\r
84 ASSERT_EFI_ERROR (Status);\r
85\r
86 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);\r
87 ASSERT_EFI_ERROR (Status);\r
88\r
89 if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
90 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);\r
91 ASSERT_EFI_ERROR (Status);\r
92 }\r
93\r
94 return Status;\r
95}\r