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