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 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 Module Name:
16
17 MemoryInit.c
18
19 Abstract:
20
21 PEIM to provide fake memory init
22
23 **/
24
25
26
27 //
28 // The package level header files this module uses
29 //
30 #include <PiPei.h>
31 //
32 // The protocols, PPI and GUID defintions for this module
33 //
34 #include <Ppi/ArmMpCoreInfo.h>
35
36 //
37 // The Library classes this module consumes
38 //
39 #include <Library/DebugLib.h>
40 #include <Library/PeimEntryPoint.h>
41 #include <Library/PeiServicesLib.h>
42 #include <Library/PcdLib.h>
43 #include <Library/HobLib.h>
44 #include <Library/ArmLib.h>
45
46 /*++
47
48 Routine Description:
49
50 Arguments:
51
52 FileHandle - Handle of the file being invoked.
53 PeiServices - Describes the list of possible PEI Services.
54
55 Returns:
56
57 Status - EFI_SUCCESS if the boot mode could be set
58
59 --*/
60 EFI_STATUS
61 EFIAPI
InitializeCpuPeim(IN EFI_PEI_FILE_HANDLE FileHandle,IN CONST EFI_PEI_SERVICES ** PeiServices)62 InitializeCpuPeim (
63 IN EFI_PEI_FILE_HANDLE FileHandle,
64 IN CONST EFI_PEI_SERVICES **PeiServices
65 )
66 {
67 EFI_STATUS Status;
68 ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;
69 UINTN ArmCoreCount;
70 ARM_CORE_INFO *ArmCoreInfoTable;
71
72 // Enable program flow prediction, if supported.
73 ArmEnableBranchPrediction ();
74
75 // Publish the CPU memory and io spaces sizes
76 BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
77
78 // Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
79 Status = PeiServicesLocatePpi (&gArmMpCoreInfoPpiGuid, 0, NULL, (VOID**)&ArmMpCoreInfoPpi);
80 if (!EFI_ERROR(Status)) {
81 // Build the MP Core Info Table
82 ArmCoreCount = 0;
83 Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);
84 if (!EFI_ERROR(Status) && (ArmCoreCount > 0)) {
85 // Build MPCore Info HOB
86 BuildGuidDataHob (&gArmMpCoreInfoGuid, ArmCoreInfoTable, sizeof (ARM_CORE_INFO) * ArmCoreCount);
87 }
88 }
89
90 return EFI_SUCCESS;
91 }
92