]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Drivers/CpuPei/CpuPei.c
ArmPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ArmPkg / Drivers / CpuPei / CpuPei.c
1 /**@file
2
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 Copyright (c) 2011 Hewlett Packard Corporation. All rights reserved.<BR>
5 Copyright (c) 2011-2013, ARM Limited. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 Module Name:
10
11 MemoryInit.c
12
13 Abstract:
14
15 PEIM to provide fake memory init
16
17 **/
18
19
20
21 //
22 // The package level header files this module uses
23 //
24 #include <PiPei.h>
25 //
26 // The protocols, PPI and GUID defintions for this module
27 //
28 #include <Ppi/ArmMpCoreInfo.h>
29
30 //
31 // The Library classes this module consumes
32 //
33 #include <Library/DebugLib.h>
34 #include <Library/PeimEntryPoint.h>
35 #include <Library/PeiServicesLib.h>
36 #include <Library/PcdLib.h>
37 #include <Library/HobLib.h>
38 #include <Library/ArmLib.h>
39
40 /*++
41
42 Routine Description:
43
44 Arguments:
45
46 FileHandle - Handle of the file being invoked.
47 PeiServices - Describes the list of possible PEI Services.
48
49 Returns:
50
51 Status - EFI_SUCCESS if the boot mode could be set
52
53 --*/
54 EFI_STATUS
55 EFIAPI
56 InitializeCpuPeim (
57 IN EFI_PEI_FILE_HANDLE FileHandle,
58 IN CONST EFI_PEI_SERVICES **PeiServices
59 )
60 {
61 EFI_STATUS Status;
62 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;
63 UINTN ArmCoreCount;
64 ARM_CORE_INFO *ArmCoreInfoTable;
65
66 // Enable program flow prediction, if supported.
67 ArmEnableBranchPrediction ();
68
69 // Publish the CPU memory and io spaces sizes
70 BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
71
72 // Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
73 Status = PeiServicesLocatePpi (&gArmMpCoreInfoPpiGuid, 0, NULL, (VOID**)&ArmMpCoreInfoPpi);
74 if (!EFI_ERROR(Status)) {
75 // Build the MP Core Info Table
76 ArmCoreCount = 0;
77 Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);
78 if (!EFI_ERROR(Status) && (ArmCoreCount > 0)) {
79 // Build MPCore Info HOB
80 BuildGuidDataHob (&gArmMpCoreInfoGuid, ArmCoreInfoTable, sizeof (ARM_CORE_INFO) * ArmCoreCount);
81 }
82 }
83
84 return EFI_SUCCESS;
85 }