]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PlatformPei/PlatformPeim.c
8fcdc99c0ee7c8c4424307231ea4a761865fc0e2
[mirror_edk2.git] / ArmPlatformPkg / PlatformPei / PlatformPeim.c
1 /** @file
2
3 Copyright (c) 2011, ARM Limited. All rights reserved.
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <PiPei.h>
10
11 //
12 // The protocols, PPI and GUID definitions for this module
13 //
14 #include <Ppi/MasterBootMode.h>
15 #include <Ppi/BootInRecoveryMode.h>
16 #include <Ppi/GuidedSectionExtraction.h>
17 //
18 // The Library classes this module consumes
19 //
20 #include <Library/ArmPlatformLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/HobLib.h>
24 #include <Library/PeimEntryPoint.h>
25 #include <Library/PeiServicesLib.h>
26 #include <Library/PcdLib.h>
27
28 EFI_STATUS
29 EFIAPI
30 InitializePlatformPeim (
31 IN EFI_PEI_FILE_HANDLE FileHandle,
32 IN CONST EFI_PEI_SERVICES **PeiServices
33 );
34
35 EFI_STATUS
36 EFIAPI
37 PlatformPeim (
38 VOID
39 );
40
41 //
42 // Module globals
43 //
44 CONST EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
45 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
46 &gEfiPeiMasterBootModePpiGuid,
47 NULL
48 };
49
50 CONST EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
51 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
52 &gEfiPeiBootInRecoveryModePpiGuid,
53 NULL
54 };
55
56 /*++
57
58 Routine Description:
59
60
61
62 Arguments:
63
64 FileHandle - Handle of the file being invoked.
65 PeiServices - Describes the list of possible PEI Services.
66
67 Returns:
68
69 Status - EFI_SUCCESS if the boot mode could be set
70
71 --*/
72 EFI_STATUS
73 EFIAPI
74 InitializePlatformPeim (
75 IN EFI_PEI_FILE_HANDLE FileHandle,
76 IN CONST EFI_PEI_SERVICES **PeiServices
77 )
78 {
79 EFI_STATUS Status;
80 EFI_BOOT_MODE BootMode;
81
82 DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));
83
84 Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ());
85 ASSERT_EFI_ERROR (Status);
86
87 PlatformPeim ();
88
89 Status = PeiServicesGetBootMode (&BootMode);
90 ASSERT_EFI_ERROR (Status);
91
92 Status = PeiServicesInstallPpi (&mPpiListBootMode);
93 ASSERT_EFI_ERROR (Status);
94
95 if (BootMode == BOOT_IN_RECOVERY_MODE) {
96 Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);
97 ASSERT_EFI_ERROR (Status);
98 }
99
100 return Status;
101 }