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