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 #include <Ppi/GuidedSectionExtraction.h>
23 //
24 // The Library classes this module consumes
25 //
26 #include <Library/ArmPlatformLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/HobLib.h>
30 #include <Library/PeimEntryPoint.h>
31 #include <Library/PeiServicesLib.h>
32 #include <Library/PcdLib.h>
33
34 EFI_STATUS
35 EFIAPI
36 InitializePlatformPeim (
37 IN EFI_PEI_FILE_HANDLE FileHandle,
38 IN CONST EFI_PEI_SERVICES **PeiServices
39 );
40
41 EFI_STATUS
42 EFIAPI
43 PlatformPeim (
44 VOID
45 );
46
47 //
48 // Module globals
49 //
50 CONST EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
51 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
52 &gEfiPeiMasterBootModePpiGuid,
53 NULL
54 };
55
56 CONST EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
57 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
58 &gEfiPeiBootInRecoveryModePpiGuid,
59 NULL
60 };
61
62 /*++
63
64 Routine Description:
65
66
67
68 Arguments:
69
70 FileHandle - Handle of the file being invoked.
71 PeiServices - Describes the list of possible PEI Services.
72
73 Returns:
74
75 Status - EFI_SUCCESS if the boot mode could be set
76
77 --*/
78 EFI_STATUS
79 EFIAPI
InitializePlatformPeim(IN EFI_PEI_FILE_HANDLE FileHandle,IN CONST EFI_PEI_SERVICES ** PeiServices)80 InitializePlatformPeim (
81 IN EFI_PEI_FILE_HANDLE FileHandle,
82 IN CONST EFI_PEI_SERVICES **PeiServices
83 )
84 {
85 EFI_STATUS Status;
86 UINTN BootMode;
87
88 DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));
89
90 PlatformPeim ();
91
92 BootMode = ArmPlatformGetBootMode ();
93 Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
94 ASSERT_EFI_ERROR (Status);
95
96 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
97 ASSERT_EFI_ERROR (Status);
98
99 if (BootMode == BOOT_IN_RECOVERY_MODE) {
100 Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
101 ASSERT_EFI_ERROR (Status);
102 }
103
104 return Status;
105 }
106