mirror of https://github.com/acidanthera/audk.git
1) Call ProcessNotifyList() to process all Dispatch Notifications after the Memory Discovered PPI is installed.
2) Add ProcessLibraryConstructorList() call when OldCoreData != NULL and OldCoreData->ShadowedPeiCore == NULL. 3) Make sure no lib functions are used prior to the ProcessLibraryConstructorList() call. 4) Clean up comments git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10611 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
7a743a2c09
commit
6b22483ffb
|
@ -143,39 +143,47 @@ PeiCore (
|
||||||
PEI_CORE_INSTANCE PrivateData;
|
PEI_CORE_INSTANCE PrivateData;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PEI_CORE_TEMP_POINTERS TempPtr;
|
PEI_CORE_TEMP_POINTERS TempPtr;
|
||||||
UINT64 Tick;
|
|
||||||
PEI_CORE_INSTANCE *OldCoreData;
|
PEI_CORE_INSTANCE *OldCoreData;
|
||||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||||
EFI_PEI_PCI_CFG2_PPI *PciCfg;
|
EFI_PEI_PCI_CFG2_PPI *PciCfg;
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;
|
EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;
|
||||||
|
|
||||||
Tick = 0;
|
//
|
||||||
|
// Retrieve context passed into PEI Core
|
||||||
|
//
|
||||||
OldCoreData = (PEI_CORE_INSTANCE *)Data;
|
OldCoreData = (PEI_CORE_INSTANCE *)Data;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Record the system tick for first entering PeiCore.
|
// Perform PEI Core phase specific actions.
|
||||||
// This tick is duration of executing platform seccore module.
|
|
||||||
//
|
//
|
||||||
if (PerformanceMeasurementEnabled()) {
|
if (OldCoreData == NULL) {
|
||||||
if (OldCoreData == NULL) {
|
//
|
||||||
Tick = GetPerformanceCounter ();
|
// If OldCoreData is NULL, means current is the first entry into the PEI Core before memory is available.
|
||||||
}
|
//
|
||||||
}
|
ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));
|
||||||
|
PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;
|
||||||
if (OldCoreData != NULL) {
|
CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Memory is available to the PEI Core. See if the PEI Core has been shadowed to memory yet.
|
||||||
|
//
|
||||||
if (OldCoreData->ShadowedPeiCore == NULL) {
|
if (OldCoreData->ShadowedPeiCore == NULL) {
|
||||||
//
|
|
||||||
//
|
//
|
||||||
// Fixup the PeiCore's private data
|
// Fixup the PeiCore's private data
|
||||||
//
|
//
|
||||||
OldCoreData->Ps = &OldCoreData->ServiceTableShadow;
|
OldCoreData->Ps = &OldCoreData->ServiceTableShadow;
|
||||||
OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;
|
OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;
|
||||||
if (OldCoreData->HeapOffsetPositive) {
|
if (OldCoreData->HeapOffsetPositive) {
|
||||||
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
|
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
|
||||||
} else {
|
} else {
|
||||||
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
|
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize libraries that the PEI Core is linked against
|
||||||
|
//
|
||||||
|
ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fixup for PeiService's address
|
// Fixup for PeiService's address
|
||||||
//
|
//
|
||||||
|
@ -219,12 +227,6 @@ PeiCore (
|
||||||
OldCoreData->PeiCodeMemoryRangeUsageBitMap = AllocateZeroPool (((PcdGet32(PcdLoadFixAddressPeiCodePageNumber)>>6) + 1)*sizeof(UINT64));
|
OldCoreData->PeiCodeMemoryRangeUsageBitMap = AllocateZeroPool (((PcdGet32(PcdLoadFixAddressPeiCodePageNumber)>>6) + 1)*sizeof(UINT64));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Process the Notify list and dispatch any notifies for
|
|
||||||
// newly installed PPIs.
|
|
||||||
//
|
|
||||||
ProcessNotifyList (OldCoreData);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow PEI Core. When permanent memory is avaiable, shadow
|
// Shadow PEI Core. When permanent memory is avaiable, shadow
|
||||||
// PEI Core and PEIMs to get high performance.
|
// PEI Core and PEIMs to get high performance.
|
||||||
|
@ -232,12 +234,21 @@ PeiCore (
|
||||||
OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);
|
OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);
|
||||||
|
|
||||||
//
|
//
|
||||||
// PeiCore has been shadowed to memory for first entering, so
|
// PEI Core has now been shadowed to memory. Restart PEI Core in memory.
|
||||||
// just jump to PeiCore in memory here.
|
|
||||||
//
|
//
|
||||||
OldCoreData->ShadowedPeiCore (SecCoreData, PpiList, OldCoreData);
|
OldCoreData->ShadowedPeiCore (SecCoreData, PpiList, OldCoreData);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Should never reach here.
|
||||||
|
//
|
||||||
|
ASSERT (FALSE);
|
||||||
|
CpuDeadLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Memory is available to the PEI Core and the PEI Core has been shadowed to memory.
|
||||||
|
//
|
||||||
|
|
||||||
CopyMem (&PrivateData, OldCoreData, sizeof (PrivateData));
|
CopyMem (&PrivateData, OldCoreData, sizeof (PrivateData));
|
||||||
|
|
||||||
CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;
|
CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;
|
||||||
|
@ -247,47 +258,58 @@ PeiCore (
|
||||||
|
|
||||||
PrivateData.ServiceTableShadow.CpuIo = CpuIo;
|
PrivateData.ServiceTableShadow.CpuIo = CpuIo;
|
||||||
PrivateData.ServiceTableShadow.PciCfg = PciCfg;
|
PrivateData.ServiceTableShadow.PciCfg = PciCfg;
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// If OldCoreData is NULL, means current is first Peicore's entering.
|
|
||||||
//
|
|
||||||
|
|
||||||
ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));
|
|
||||||
PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;
|
|
||||||
CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cache a pointer to the PEI Services Table that is either in temporary memory or permanent memory
|
||||||
|
//
|
||||||
PrivateData.Ps = &PrivateData.ServiceTableShadow;
|
PrivateData.Ps = &PrivateData.ServiceTableShadow;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize libraries that the PeiCore is linked against
|
// Initialize libraries that the PEI Core is linked against
|
||||||
//
|
//
|
||||||
ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
|
ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
|
||||||
|
|
||||||
InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
|
|
||||||
|
|
||||||
InitializePpiServices (&PrivateData, OldCoreData);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save PeiServicePointer so that it can be retrieved anywhere.
|
// Save PeiServicePointer so that it can be retrieved anywhere.
|
||||||
//
|
//
|
||||||
SetPeiServicesTablePointer((CONST EFI_PEI_SERVICES **) &PrivateData.Ps);
|
SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
|
||||||
|
|
||||||
if (OldCoreData != NULL) {
|
//
|
||||||
|
// Initialize PEI Core Services
|
||||||
|
//
|
||||||
|
InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
|
||||||
|
InitializePpiServices (&PrivateData, OldCoreData);
|
||||||
|
|
||||||
PERF_END (NULL,"PreMem", NULL, 0);
|
//
|
||||||
PERF_START (NULL,"PostMem", NULL, 0);
|
// Update performance measurements
|
||||||
|
//
|
||||||
|
if (OldCoreData == NULL) {
|
||||||
|
PERF_START (NULL, "SEC", NULL, 1);
|
||||||
|
PERF_END (NULL, "SEC", NULL, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Alert any listeners that there is permanent memory available
|
// If first pass, start performance measurement.
|
||||||
//
|
//
|
||||||
|
PERF_START (NULL,"PEI", NULL, 0);
|
||||||
PERF_START (NULL,"DisMem", NULL, 0);
|
PERF_START (NULL,"PreMem", NULL, 0);
|
||||||
Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);
|
|
||||||
PERF_END (NULL,"DisMem", NULL, 0);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
PERF_END (NULL,"PreMem", NULL, 0);
|
||||||
|
PERF_START (NULL,"PostMem", NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Complete PEI Core Service initialization
|
||||||
|
//
|
||||||
|
InitializeSecurityServices (&PrivateData.Ps, OldCoreData);
|
||||||
|
InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);
|
||||||
|
InitializeImageServices (&PrivateData, OldCoreData);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Perform PEI Core Phase specific actions
|
||||||
|
//
|
||||||
|
if (OldCoreData == NULL) {
|
||||||
//
|
//
|
||||||
// Report Status Code EFI_SW_PC_INIT
|
// Report Status Code EFI_SW_PC_INIT
|
||||||
//
|
//
|
||||||
|
@ -296,15 +318,6 @@ PeiCore (
|
||||||
(EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)
|
(EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)
|
||||||
);
|
);
|
||||||
|
|
||||||
PERF_START (NULL, "SEC", NULL, 1);
|
|
||||||
PERF_END (NULL, "SEC", NULL, Tick);
|
|
||||||
|
|
||||||
PERF_START (NULL,"PEI", NULL, Tick);
|
|
||||||
//
|
|
||||||
// If first pass, start performance measurement.
|
|
||||||
//
|
|
||||||
PERF_START (NULL,"PreMem", NULL, Tick);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If SEC provided any PPI services to PEI, install them.
|
// If SEC provided any PPI services to PEI, install them.
|
||||||
//
|
//
|
||||||
|
@ -312,17 +325,21 @@ PeiCore (
|
||||||
Status = PeiServicesInstallPpi (PpiList);
|
Status = PeiServicesInstallPpi (PpiList);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Alert any listeners that there is permanent memory available
|
||||||
|
//
|
||||||
|
PERF_START (NULL,"DisMem", NULL, 0);
|
||||||
|
Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Process the Notify list and dispatch any notifies for the Memory Discovered PPI
|
||||||
|
//
|
||||||
|
ProcessNotifyList (&PrivateData);
|
||||||
|
|
||||||
|
PERF_END (NULL,"DisMem", NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeSecurityServices (&PrivateData.Ps, OldCoreData);
|
|
||||||
|
|
||||||
InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Install Pei Load File PPI.
|
|
||||||
//
|
|
||||||
InitializeImageServices (&PrivateData, OldCoreData);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Call PEIM dispatcher
|
// Call PEIM dispatcher
|
||||||
//
|
//
|
||||||
|
@ -334,11 +351,13 @@ PeiCore (
|
||||||
ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
|
ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Till now, PEI phase will be finished, get performace count
|
// Measure PEI Core execution time.
|
||||||
// for computing duration of PEI phase
|
|
||||||
//
|
//
|
||||||
PERF_END (NULL, "PostMem", NULL, 0);
|
PERF_END (NULL, "PostMem", NULL, 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lookup DXE IPL PPI
|
||||||
|
//
|
||||||
Status = PeiServicesLocatePpi (
|
Status = PeiServicesLocatePpi (
|
||||||
&gEfiDxeIplPpiGuid,
|
&gEfiDxeIplPpiGuid,
|
||||||
0,
|
0,
|
||||||
|
@ -362,5 +381,3 @@ PeiCore (
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
CpuDeadLoop();
|
CpuDeadLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue