summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-12 05:04:35 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-12 05:04:35 +0000
commit14941e689f3d4b006ba263de494c5b9e386a546a (patch)
treed94f6035539672e79345eb7edcd59591427e0c71 /MdeModulePkg
parent1bd90a4c479759542f86dbac953855552cbb31fa (diff)
downloadedk2-platforms-14941e689f3d4b006ba263de494c5b9e386a546a.tar.xz
Temporarily rollback the change from 5625 though 5628 for more investigation.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5629 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c78
-rw-r--r--MdeModulePkg/Core/Pei/Memory/MemoryServices.c70
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.h3
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain/PeiMain.c30
-rw-r--r--MdeModulePkg/Core/Pei/Security/Security.c10
5 files changed, 78 insertions, 113 deletions
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 3463987149..a4ed45af52 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -100,7 +100,7 @@ DiscoverPeimsAndOrderWithApriori (
Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);
Private->AprioriCount /= sizeof (EFI_GUID);
- ZeroMem (FileGuid, sizeof (FileGuid));
+ SetMem (FileGuid, sizeof (FileGuid), 0);
for (Index = 0; Index < PeimCount; Index++) {
//
// Make an array of file name guids that matches the FileHandle array so we can convert
@@ -178,7 +178,6 @@ DiscoverPeimsAndOrderWithApriori (
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param PrivateInMem PeiCore's private data structure
- @return PeiCore function address after shadowing.
**/
VOID*
ShadowPeiCore(
@@ -216,10 +215,6 @@ ShadowPeiCore(
);
ASSERT_EFI_ERROR (Status);
- //
- // Compute the PeiCore's function address after shaowed PeiCore.
- // _ModuleEntryPoint is PeiCore main function entry
- //
return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);
}
@@ -252,6 +247,8 @@ PeiDispatcher (
UINT32 AuthenticationState;
EFI_PHYSICAL_ADDRESS EntryPoint;
EFI_PEIM_ENTRY_POINT2 PeimEntryPoint;
+ BOOLEAN PeimNeedingDispatch;
+ BOOLEAN PeimDispatchOnThisPass;
UINTN SaveCurrentPeimCount;
UINTN SaveCurrentFvCount;
EFI_PEI_FILE_HANDLE SaveCurrentFileHandle;
@@ -335,16 +332,9 @@ PeiDispatcher (
// satisfied, this dipatcher should run only once.
//
do {
- //
- // In case that reenter PeiCore happens, the last pass record is still available.
- //
- if (!Private->PeimDispatcherReenter) {
- Private->PeimNeedingDispatch = FALSE;
- Private->PeimDispatchOnThisPass = FALSE;
- } else {
- Private->PeimDispatcherReenter = FALSE;
- }
-
+ PeimNeedingDispatch = FALSE;
+ PeimDispatchOnThisPass = FALSE;
+
for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {
Private->CurrentPeimFvCount = FvCount;
VolumeHandle = Private->Fv[FvCount].FvHeader;
@@ -369,7 +359,7 @@ PeiDispatcher (
if (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_NOT_DISPATCHED) {
if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {
- Private->PeimNeedingDispatch = TRUE;
+ PeimNeedingDispatch = TRUE;
} else {
Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);
ASSERT_EFI_ERROR (Status);
@@ -421,7 +411,7 @@ PeiDispatcher (
PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);
}
- Private->PeimDispatchOnThisPass = TRUE;
+ PeimDispatchOnThisPass = TRUE;
}
REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
@@ -591,10 +581,10 @@ PeiDispatcher (
PrivateInMem->PeiMemoryInstalled = TRUE;
//
- // Indicate that PeiCore reenter
+ // Restart scan of all PEIMs on next pass
//
- Private->PeimDispatcherReenter = TRUE;
-
+ PrivateInMem->CurrentPeimCount = 0;
+
//
// Shadow PEI Core. When permanent memory is avaiable, shadow
// PEI Core and PEIMs to get high performance.
@@ -678,7 +668,7 @@ PeiDispatcher (
// pass. If we did not dispatch a PEIM there is no point in trying again
// as it will fail the next time too (nothing has changed).
//
- } while (Private->PeimNeedingDispatch && Private->PeimDispatchOnThisPass);
+ } while (PeimNeedingDispatch && PeimDispatchOnThisPass);
}
@@ -703,7 +693,6 @@ InitializeDispatcherData (
)
{
if (OldCoreData == NULL) {
- PrivateData->PeimDispatcherReenter = FALSE;
PeiInitializeFv (PrivateData, SecCoreData);
}
@@ -809,11 +798,9 @@ PeiRegisterForShadow (
@param AuthenticationState Pointer to attestation authentication state of image.
- @retval EFI_NOT_FOUND FV image can't be found.
- @retval EFI_SUCCESS Successfully to process it.
- @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image
- @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section
-
+ @retval EFI_NOT_FOUND FV image can't be found.
+ @retval EFI_SUCCESS Successfully to process it.
+
**/
EFI_STATUS
ProcessFvFile (
@@ -827,7 +814,7 @@ ProcessFvFile (
EFI_FV_INFO FvImageInfo;
UINT32 FvAlignment;
VOID *FvBuffer;
- EFI_PEI_HOB_POINTERS HobPtr;
+ EFI_PEI_HOB_POINTERS HobFv2;
FvBuffer = NULL;
*AuthenticationState = 0;
@@ -836,15 +823,15 @@ ProcessFvFile (
// Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
// been extracted.
//
- HobPtr.Raw = GetHobList ();
- while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobPtr.Raw)) != NULL) {
- if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) {
+ HobFv2.Raw = GetHobList ();
+ while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {
+ if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobFv2.FirmwareVolume2->FileName)) {
//
// this FILE has been dispatched, it will not be dispatched again.
//
return EFI_SUCCESS;
}
- HobPtr.Raw = GET_NEXT_HOB (HobPtr);
+ HobFv2.Raw = GET_NEXT_HOB (HobFv2);
}
//
@@ -860,13 +847,11 @@ ProcessFvFile (
if (EFI_ERROR (Status)) {
return Status;
}
-
//
// Collect FvImage Info.
//
Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);
ASSERT_EFI_ERROR (Status);
-
//
// FvAlignment must be more than 8 bytes required by FvHeader structure.
//
@@ -874,7 +859,6 @@ ProcessFvFile (
if (FvAlignment < 8) {
FvAlignment = 8;
}
-
//
// Check FvImage
//
@@ -902,24 +886,12 @@ ProcessFvFile (
);
//
- // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase
- // based on its parent Fvimage is informed or not.
- // If FvHob of its parent fvimage is built, the extracted FvImage will be built also.
- // Or, the extracted FvImage will not be built.
+ // Inform HOB consumer phase, i.e. DXE core, the existance of this FV
//
- HobPtr.Raw = GetHobList ();
- while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV, HobPtr.Raw)) != NULL) {
- if (((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle > HobPtr.FirmwareVolume->BaseAddress) &&
- ((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle < HobPtr.FirmwareVolume->BaseAddress + HobPtr.FirmwareVolume->Length)) {
- BuildFvHob (
- (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,
- FvImageInfo.FvSize
- );
- break;
- }
- HobPtr.Raw = GET_NEXT_HOB (HobPtr);
- }
-
+ BuildFvHob (
+ (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,
+ FvImageInfo.FvSize
+ );
//
// Makes the encapsulated volume show up in DXE phase to skip processing of
// encapsulated file again.
diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
index 7e841c3c46..d24897d776 100644
--- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -18,7 +18,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Initialize the memory services.
- @param PrivateData Points to PeiCore's private instance data.
+
+ @param PrivateData Add parameter description
@param SecCoreData Points to a data structure containing information about the PEI core's operating
environment, such as the size and location of temporary RAM, the stack location and
the BFV location.
@@ -75,13 +76,9 @@ InitializeMemoryServices (
/**
- This function registers the found memory configuration with the PEI Foundation.
+ Install the permanent memory is now available.
+ Creates HOB (PHIT and Stack).
- The usage model is that the PEIM that discovers the permanent memory shall invoke this service.
- This routine will hold discoveried memory information into PeiCore's private data,
- and set SwitchStackSignal flag. After PEIM who discovery memory is dispatched,
- PeiDispatcher will migrate temporary memory to permenement memory.
-
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param MemoryBegin Start of memory address.
@param MemoryLength Length of memory.
@@ -123,6 +120,7 @@ PeiInstallPeiMemory (
@param Memory Pointer of memory allocated.
@retval EFI_SUCCESS The allocation was successful
+ @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
@retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available
@retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
to allocate the number of pages.
@@ -131,14 +129,15 @@ PeiInstallPeiMemory (
EFI_STATUS
EFIAPI
PeiAllocatePages (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT EFI_PHYSICAL_ADDRESS *Memory
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
PEI_CORE_INSTANCE *PrivateData;
EFI_PEI_HOB_POINTERS Hob;
+ EFI_PHYSICAL_ADDRESS Offset;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
@@ -151,7 +150,7 @@ PeiAllocatePages (
if (!PrivateData->PeiMemoryInstalled) {
//
// When PeiInstallMemory is called but CAR has *not* been moved to temporary memory,
- // the AllocatePage will dependent on the field of PEI_CORE_INSTANCE structure.
+ // the AllocatePage will dependent the field of PEI_CORE_INSTANCE structure.
//
if (!PrivateData->SwitchStackSignal) {
return EFI_NOT_AVAILABLE_YET;
@@ -165,9 +164,16 @@ PeiAllocatePages (
}
//
- // Check to see if on 4k boundary, If not aligned, make the allocation aligned.
+ // Check to see if on 4k boundary
//
- *(FreeMemoryTop) -= *(FreeMemoryTop) & 0xFFF;
+ Offset = *(FreeMemoryTop) & 0xFFF;
+
+ //
+ // If not aligned, make the allocation aligned.
+ //
+ if (Offset != 0) {
+ *(FreeMemoryTop) -= Offset;
+ }
//
// Verify that there is sufficient memory to satisfy the allocation
@@ -204,14 +210,12 @@ PeiAllocatePages (
/**
- Pool allocation service. Before permenent memory is discoveried, the pool will
- be allocated the heap in the CAR. Genenrally, the size of heap in temporary
- memory does not exceed to 64K, so the biggest pool size could be allocated is
- 64K.
+ Memory allocation service on the CAR.
+
- @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
- @param Size Amount of memory required
- @param Buffer Address of pointer to the buffer
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param Size Amount of memory required
+ @param Buffer Address of pointer to the buffer
@retval EFI_SUCCESS The allocation was successful
@retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
@@ -221,30 +225,26 @@ PeiAllocatePages (
EFI_STATUS
EFIAPI
PeiAllocatePool (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN UINTN Size,
- OUT VOID **Buffer
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Size,
+ OUT VOID **Buffer
)
{
EFI_STATUS Status;
EFI_HOB_MEMORY_POOL *Hob;
- //
- // If some "post-memory" PEIM wishes to allocate larger pool,
- // it should use AllocatePages service instead.
- //
-
- //
- // Generally, the size of heap in temporary memory does not exceed to 64K,
- // so the maxmium size of pool is 0x10000 - sizeof (EFI_HOB_MEMORY_POOL)
- //
- ASSERT (Size < 0x10000 - sizeof (EFI_HOB_MEMORY_POOL));
- Status = PeiServicesCreateHob (
+ //
+ // If some "post-memory" PEIM wishes to allocate larger pool,
+ // it should use AllocatePages service instead.
+ //
+ ASSERT (Size < 0x10000 - sizeof (EFI_HOB_MEMORY_POOL));
+ Status = PeiServicesCreateHob (
EFI_HOB_TYPE_MEMORY_POOL,
(UINT16)(sizeof (EFI_HOB_MEMORY_POOL) + Size),
(VOID **)&Hob
);
*Buffer = Hob+1;
+
return Status;
}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 0524d95636..e121fa4281 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -137,9 +137,6 @@ typedef struct{
UINTN CurrentPeimFvCount;
UINTN CurrentPeimCount;
EFI_PEI_FILE_HANDLE CurrentFileHandle;
- BOOLEAN PeimNeedingDispatch;
- BOOLEAN PeimDispatchOnThisPass;
- BOOLEAN PeimDispatcherReenter;
UINTN AllFvCount;
EFI_PEI_FV_HANDLE AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
EFI_PEI_HOB_POINTERS HobList;
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 6e032783d0..d257eaee43 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -21,7 +21,8 @@ STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
};
///
-/// Pei service instance
+/// Pei Core Module Variables
+///
///
STATIC EFI_PEI_SERVICES gPs = {
{
@@ -66,10 +67,11 @@ STATIC EFI_PEI_SERVICES gPs = {
/**
- This routine is invoked by main entry of PeiMain module during transition
+ The entry routine to Pei Core, invoked by PeiMain during transition
from SEC to PEI. After switching stack in the PEI core, it will restart
with the old core data.
+
@param SecCoreData Points to a data structure containing information about the PEI core's operating
environment, such as the size and location of temporary RAM, the stack location and
the BFV location.
@@ -81,7 +83,6 @@ STATIC EFI_PEI_SERVICES gPs = {
calls and/or code in these early PPIs
@param Data Pointer to old core data that is used to initialize the
core's data areas.
- If NULL, it is first PeiCore entering.
@retval EFI_NOT_FOUND Never reach
@@ -97,13 +98,13 @@ PeiCore (
PEI_CORE_INSTANCE PrivateData;
EFI_STATUS Status;
PEI_CORE_TEMP_POINTERS TempPtr;
- UINT64 Tick;
+ UINT64 mTick;
PEI_CORE_INSTANCE *OldCoreData;
EFI_PEI_CPU_IO_PPI *CpuIo;
EFI_PEI_PCI_CFG2_PPI *PciCfg;
PEICORE_FUNCTION_POINTER ShadowedPeiCore;
- Tick = 0;
+ mTick = 0;
OldCoreData = (PEI_CORE_INSTANCE *) Data;
//
@@ -112,17 +113,16 @@ PeiCore (
//
if (PerformanceMeasurementEnabled()) {
if (OldCoreData == NULL) {
- Tick = GetPerformanceCounter ();
+ mTick = GetPerformanceCounter ();
}
}
+ //
+ // PeiCore has been shadowed to memory for first entering, so
+ // just jump to PeiCore in memory here.
+ //
if (OldCoreData != NULL) {
ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) OldCoreData->ShadowedPeiCore;
-
- //
- // PeiCore has been shadowed to memory for first entering, so
- // just jump to PeiCore in memory here.
- //
if (ShadowedPeiCore != NULL) {
OldCoreData->ShadowedPeiCore = NULL;
ShadowedPeiCore (
@@ -142,10 +142,6 @@ PeiCore (
PrivateData.ServiceTableShadow.CpuIo = CpuIo;
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));
@@ -190,11 +186,11 @@ PeiCore (
FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)
);
- PERF_START (NULL,"PEI", NULL, Tick);
+ PERF_START (NULL,"PEI", NULL, mTick);
//
// If first pass, start performance measurement.
//
- PERF_START (NULL,"PreMem", NULL, Tick);
+ PERF_START (NULL,"PreMem", NULL, mTick);
//
// If SEC provided any PPI services to PEI, install them.
diff --git a/MdeModulePkg/Core/Pei/Security/Security.c b/MdeModulePkg/Core/Pei/Security/Security.c
index 469686ff23..7460707a27 100644
--- a/MdeModulePkg/Core/Pei/Security/Security.c
+++ b/MdeModulePkg/Core/Pei/Security/Security.c
@@ -62,8 +62,7 @@ InitializeSecurityServices (
/**
Provide a callback for when the security PPI is installed.
- This routine will cache installed security PPI into PeiCore's private data.
-
+
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param NotifyDescriptor The descriptor for the notification event.
@param Ppi Pointer to the PPI in question.
@@ -106,7 +105,7 @@ SecurityPpiNotifyCallback (
@retval EFI_SUCCESS Image is OK
@retval EFI_SECURITY_VIOLATION Image is illegal
- @retval EFI_NOT_FOUND If security PPI is not installed.
+
**/
EFI_STATUS
VerifyPeim (
@@ -149,9 +148,10 @@ VerifyPeim (
/**
Verify a Firmware volume.
- @param CurrentFvAddress Pointer to the current Firmware Volume under consideration
+ @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration
- @retval EFI_SUCCESS Firmware Volume is legal
+ @retval EFI_SUCCESS Firmware Volume is legal
+ @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test
**/
EFI_STATUS