2 Pei Core Main Entry Point
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. 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
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.
17 STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi
= {
18 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
19 &gEfiPeiMemoryDiscoveredPpiGuid
,
24 // Pei Core Module Variables
27 STATIC EFI_PEI_SERVICES gPs
= {
29 PEI_SERVICES_SIGNATURE
,
30 PEI_SERVICES_REVISION
,
31 sizeof (EFI_PEI_SERVICES
),
48 PeiFfsFindSectionData
,
53 (EFI_PEI_COPY_MEM
)CopyMem
,
54 (EFI_PEI_SET_MEM
)SetMem
,
70 The entry routine to Pei Core, invoked by PeiMain during transition
71 from SEC to PEI. After switching stack in the PEI core, it will restart
72 with the old core data.
75 @param SecCoreData Points to a data structure containing information about the PEI core's operating
76 environment, such as the size and location of temporary RAM, the stack location and
78 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
79 An empty PPI list consists of a single descriptor with the end-tag
80 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization
81 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such
82 that both the PEI Foundation and any modules can leverage the associated service
83 calls and/or code in these early PPIs
84 @param Data Pointer to old core data that is used to initialize the
87 @retval EFI_NOT_FOUND Never reach
93 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
94 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
,
98 PEI_CORE_INSTANCE PrivateData
;
100 PEI_CORE_TEMP_POINTERS TempPtr
;
102 PEI_CORE_INSTANCE
*OldCoreData
;
103 EFI_PEI_CPU_IO_PPI
*CpuIo
;
104 EFI_PEI_PCI_CFG2_PPI
*PciCfg
;
105 PEI_CORE_ENTRY_POINT ShadowedPeiCore
;
108 OldCoreData
= (PEI_CORE_INSTANCE
*) Data
;
110 if (PerformanceMeasurementEnabled()) {
111 if (OldCoreData
== NULL
) {
112 mTick
= GetPerformanceCounter ();
116 if (OldCoreData
!= NULL
) {
117 ShadowedPeiCore
= (PEI_CORE_ENTRY_POINT
) (UINTN
) OldCoreData
->ShadowedPeiCore
;
118 if (ShadowedPeiCore
!= NULL
) {
119 OldCoreData
->ShadowedPeiCore
= NULL
;
127 CopyMem (&PrivateData
, OldCoreData
, sizeof (PEI_CORE_INSTANCE
));
129 CpuIo
= (VOID
*)PrivateData
.ServiceTableShadow
.CpuIo
;
130 PciCfg
= (VOID
*)PrivateData
.ServiceTableShadow
.PciCfg
;
132 CopyMem (&PrivateData
.ServiceTableShadow
, &gPs
, sizeof (gPs
));
134 PrivateData
.ServiceTableShadow
.CpuIo
= CpuIo
;
135 PrivateData
.ServiceTableShadow
.PciCfg
= PciCfg
;
137 ZeroMem (&PrivateData
, sizeof (PEI_CORE_INSTANCE
));
138 PrivateData
.Signature
= PEI_CORE_HANDLE_SIGNATURE
;
139 CopyMem (&PrivateData
.ServiceTableShadow
, &gPs
, sizeof (gPs
));
142 PrivateData
.PS
= &PrivateData
.ServiceTableShadow
;
145 // Initialize libraries that the PeiCore is linked against
146 // BUGBUG: The FileHandle is passed in as NULL. Do we look it up or remove it from the lib init?
148 ProcessLibraryConstructorList (NULL
, &PrivateData
.PS
);
150 InitializeMemoryServices (&PrivateData
, SecCoreData
, OldCoreData
);
152 InitializePpiServices (&PrivateData
, OldCoreData
);
155 // Save PeiServicePointer so that it can be retrieved anywhere.
157 SetPeiServicesTablePointer(&PrivateData
.PS
);
159 if (OldCoreData
!= NULL
) {
161 PERF_END (NULL
,"PreMem", NULL
, 0);
162 PERF_START (NULL
,"PostMem", NULL
, 0);
165 // Alert any listeners that there is permanent memory available
168 PERF_START (NULL
,"DisMem", NULL
, 0);
169 Status
= PeiServicesInstallPpi (&mMemoryDiscoveredPpi
);
170 PERF_END (NULL
,"DisMem", NULL
, 0);
175 // Report Status Code EFI_SW_PC_INIT
179 FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry
)
182 PERF_START (NULL
,"PEI", NULL
, mTick
);
184 // If first pass, start performance measurement.
186 PERF_START (NULL
,"PreMem", NULL
, mTick
);
189 // If SEC provided any PPI services to PEI, install them.
191 if (PpiList
!= NULL
) {
192 Status
= PeiServicesInstallPpi (PpiList
);
193 ASSERT_EFI_ERROR (Status
);
197 InitializeSecurityServices (&PrivateData
.PS
, OldCoreData
);
199 InitializeDispatcherData (&PrivateData
, OldCoreData
, SecCoreData
);
202 // Install Pei Load File PPI.
204 InitializeImageServices (&PrivateData
, OldCoreData
);
207 // Call PEIM dispatcher
209 PeiDispatcher (SecCoreData
, &PrivateData
);
212 // Check if InstallPeiMemory service was called.
214 ASSERT(PrivateData
.PeiMemoryInstalled
== TRUE
);
216 PERF_END (NULL
, "PostMem", NULL
, 0);
218 Status
= PeiServicesLocatePpi (
222 (VOID
**)&TempPtr
.DxeIpl
224 ASSERT_EFI_ERROR (Status
);
226 DEBUG ((EFI_D_INFO
, "DXE IPL Entry\n"));
227 Status
= TempPtr
.DxeIpl
->Entry (
233 ASSERT_EFI_ERROR (Status
);
235 return EFI_NOT_FOUND
;