Code scrub for PeiCore module.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5558 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2
2008-07-23 09:15:14 +00:00
parent 11dad244fd
commit 40f26b8f44
11 changed files with 91 additions and 95 deletions

View File

@ -229,7 +229,6 @@ PeimDispatchReadiness (
// The grammar should never arrive here // The grammar should never arrive here
// //
return FALSE; return FALSE;
break;
} }
} }
} }

View File

@ -481,11 +481,19 @@ PeiDispatcher (
// CAUTION: The new base is computed accounding to gap of new stack. // CAUTION: The new base is computed accounding to gap of new stack.
// //
NewPermenentMemoryBase = Private->PhysicalMemoryBegin + StackGap; NewPermenentMemoryBase = Private->PhysicalMemoryBegin + StackGap;
//
// Caculate stack offset and heap offset between CAR and new permement
// memory seperately.
//
StackOffset = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->StackBase; StackOffset = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->StackBase;
HeapOffset = (INTN) ((UINTN) Private->PhysicalMemoryBegin + Private->StackSize - \ HeapOffset = (INTN) ((UINTN) Private->PhysicalMemoryBegin + Private->StackSize - \
(UINTN) SecCoreData->PeiTemporaryRamBase); (UINTN) SecCoreData->PeiTemporaryRamBase);
DEBUG ((EFI_D_INFO, "Heap Offset = 0x%X Stack Offset = 0x%X\n", HeapOffset, StackOffset)); DEBUG ((EFI_D_INFO, "Heap Offset = 0x%X Stack Offset = 0x%X\n", HeapOffset, StackOffset));
//
// Caculate new HandOffTable and PrivateData address in permenet memory's stack
//
NewHandOffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + HeapOffset); NewHandOffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + HeapOffset);
PrivateInMem = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + StackOffset); PrivateInMem = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + StackOffset);
@ -502,6 +510,12 @@ PeiDispatcher (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
//
// Temporary Ram support Ppi is provided by platform, it will copy
// temporary memory to permenent memory and do stack switching.
// After invoken temporary Ram support, following code's stack is in
// memory but not in CAR.
//
TemporaryRamSupportPpi->TemporaryRamMigration ( TemporaryRamSupportPpi->TemporaryRamMigration (
(CONST EFI_PEI_SERVICES **) PeiServices, (CONST EFI_PEI_SERVICES **) PeiServices,
(EFI_PHYSICAL_ADDRESS)(UINTN) SecCoreData->TemporaryRamBase, (EFI_PHYSICAL_ADDRESS)(UINTN) SecCoreData->TemporaryRamBase,
@ -549,7 +563,7 @@ PeiDispatcher (
// //
// We need convert the PPI desciptor's pointer // We need convert the PPI desciptor's pointer
// //
ConvertPpiPointers ((CONST EFI_PEI_SERVICES **)PeiServices, ConvertPpiPointers (PrivateInMem,
OldCheckingBottom, OldCheckingBottom,
OldCheckingTop, OldCheckingTop,
HeapOffset HeapOffset

View File

@ -10,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
FwVol.c
Abstract:
**/ **/
#include <PeiMain.h> #include <PeiMain.h>
@ -35,7 +27,6 @@ STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {
/** /**
Returns the highest bit set of the State field Returns the highest bit set of the State field
@param ErasePolarity Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY @param ErasePolarity Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY
in the Attributes field. in the Attributes field.
@param FfsHeader Pointer to FFS File Header. @param FfsHeader Pointer to FFS File Header.
@ -284,15 +275,10 @@ PeiFindFileEx (
} }
/** /**
Initialize PeiCore Fv List. Initialize PeiCore Fv List.
@param PrivateData - Pointer to PEI_CORE_INSTANCE. @param PrivateData - Pointer to PEI_CORE_INSTANCE.
@param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF. @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
@return NONE
**/ **/
VOID VOID
PeiInitializeFv ( PeiInitializeFv (

View File

@ -18,7 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Gets the pointer to the HOB List. Gets the pointer to the HOB List.
@param PeiServices The PEI core services table. @param PeiServices The PEI core services table.
@param HobList Pointer to the HOB List. @param HobList Pointer to the HOB List.
@ -36,7 +35,6 @@ PeiGetHobList (
{ {
PEI_CORE_INSTANCE *PrivateData; PEI_CORE_INSTANCE *PrivateData;
// //
// Only check this parameter in debug mode // Only check this parameter in debug mode
// //
@ -51,7 +49,6 @@ PeiGetHobList (
*HobList = PrivateData->HobList.Raw; *HobList = PrivateData->HobList.Raw;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -59,10 +56,10 @@ PeiGetHobList (
/** /**
Add a new HOB to the HOB List. Add a new HOB to the HOB List.
@param PeiServices - The PEI core services table. @param PeiServices The PEI core services table.
@param Type - Type of the new HOB. @param Type Type of the new HOB.
@param Length - Length of the new HOB to allocate. @param Length Length of the new HOB to allocate.
@param Hob - Pointer to the new HOB. @param Hob Pointer to the new HOB.
@return EFI_SUCCESS Success to create hob. @return EFI_SUCCESS Success to create hob.
@retval EFI_INVALID_PARAMETER if Hob is NULL @retval EFI_INVALID_PARAMETER if Hob is NULL
@ -118,11 +115,9 @@ PeiCreateHob (
HobEnd++; HobEnd++;
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Builds a Handoff Information Table HOB Builds a Handoff Information Table HOB
@ -160,7 +155,7 @@ PeiCoreBuildHobHandoffInfoTable (
Hob->EfiMemoryTop = MemoryBegin + MemoryLength; Hob->EfiMemoryTop = MemoryBegin + MemoryLength;
Hob->EfiMemoryBottom = MemoryBegin; Hob->EfiMemoryBottom = MemoryBegin;
Hob->EfiFreeMemoryTop = MemoryBegin + MemoryLength; Hob->EfiFreeMemoryTop = MemoryBegin + MemoryLength;
Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd+1); Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd + 1);
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -37,6 +37,10 @@ InitializeMemoryServices (
PrivateData->SwitchStackSignal = FALSE; PrivateData->SwitchStackSignal = FALSE;
//
// First entering PeiCore, following code will initialized some field
// in PeiCore's private data according to hand off data from sec core.
//
if (OldCoreData == NULL) { if (OldCoreData == NULL) {
PrivateData->PeiMemoryInstalled = FALSE; PrivateData->PeiMemoryInstalled = FALSE;
@ -159,8 +163,6 @@ PeiAllocatePages (
FreeMemoryBottom = &(Hob.HandoffInformationTable->EfiFreeMemoryBottom); FreeMemoryBottom = &(Hob.HandoffInformationTable->EfiFreeMemoryBottom);
} }
// //
// Check to see if on 4k boundary // Check to see if on 4k boundary
// //

View File

@ -58,6 +58,9 @@ typedef union {
VOID *Raw; VOID *Raw;
} PEI_PPI_LIST_POINTERS; } PEI_PPI_LIST_POINTERS;
///
/// PPI database structure
///
typedef struct { typedef struct {
INTN PpiListEnd; INTN PpiListEnd;
INTN NotifyListEnd; INTN NotifyListEnd;
@ -94,12 +97,12 @@ typedef struct {
UINTN SectionIndex; UINTN SectionIndex;
} CACHE_SECTION_DATA; } CACHE_SECTION_DATA;
//
// Pei Core private data structure instance
//
#define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C') #define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')
///
/// Pei Core private data structure instance
///
typedef struct{ typedef struct{
UINTN Signature; UINTN Signature;
EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow
@ -134,10 +137,9 @@ typedef struct{
CACHE_SECTION_DATA CacheSection; CACHE_SECTION_DATA CacheSection;
} PEI_CORE_INSTANCE; } PEI_CORE_INSTANCE;
// ///
// Pei Core Instance Data Macros /// Pei Core Instance Data Macros
// ///
#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \ #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE) CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
@ -266,8 +268,6 @@ PeiDispatcher (
environment, such as the size and location of temporary RAM, the stack location and environment, such as the size and location of temporary RAM, the stack location and
the BFV location. the BFV location.
@return None.
**/ **/
VOID VOID
InitializeDispatcherData ( InitializeDispatcherData (
@ -305,7 +305,6 @@ DepexSatisfied (
Initialize PPI services. Initialize PPI services.
@param PrivateData Pointer to the PEI Core data. @param PrivateData Pointer to the PEI Core data.
@param OldCoreData Pointer to old PEI Core data. @param OldCoreData Pointer to old PEI Core data.
NULL if being run in non-permament memory mode. NULL if being run in non-permament memory mode.
@ -331,10 +330,10 @@ InitializePpiServices (
**/ **/
VOID VOID
ConvertPpiPointers ( ConvertPpiPointers (
IN CONST EFI_PEI_SERVICES **PeiServices, IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OldCheckingBottom, IN UINTN OldCheckingBottom,
IN UINTN OldCheckingTop, IN UINTN OldCheckingTop,
IN UINTN Fixup IN INTN Fixup
) )
; ;
@ -512,9 +511,8 @@ PeiSetBootMode (
Initialize the security services. Initialize the security services.
@param PeiServices The PEI core services table.
@param PeiServices - The PEI core services table. @param OldCoreData Pointer to the old core data.
@param OldCoreData - Pointer to the old core data.
NULL if being run in non-permament memory mode. NULL if being run in non-permament memory mode.
**/ **/
@ -528,10 +526,10 @@ InitializeSecurityServices (
/** /**
Verify a Firmware volume 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 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test
**/ **/
EFI_STATUS EFI_STATUS

View File

@ -75,12 +75,12 @@
gEfiPeiStatusCodePpiGuid # PPI SOMETIMES_CONSUMED gEfiPeiStatusCodePpiGuid # PPI SOMETIMES_CONSUMED
gEfiPeiResetPpiGuid # PPI SOMETIMES_CONSUMED gEfiPeiResetPpiGuid # PPI SOMETIMES_CONSUMED
gEfiDxeIplPpiGuid # PPI ALWAYS_CONSUMED gEfiDxeIplPpiGuid # PPI ALWAYS_CONSUMED
gEfiPeiMemoryDiscoveredPpiGuid # PPI ALWAYS_PRODUCED gEfiPeiMemoryDiscoveredPpiGuid # PPI ALWAYS_CONSUMED
gEfiPeiDecompressPpiGuid gEfiPeiDecompressPpiGuid # PPI ALWAYS_CONSUMED
gEfiPeiFirmwareVolumeInfoPpiGuid gEfiPeiFirmwareVolumeInfoPpiGuid # PPI ALWAYS_CONSUMED
gEfiPeiLoadFilePpiGuid gEfiPeiLoadFilePpiGuid # PPI ALWAYS_CONSUMED
gEfiPeiSecurity2PpiGuid gEfiPeiSecurity2PpiGuid # PPI ALWAYS_CONSUMED
gEfiTemporaryRamSupportPpiGuid gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_CONSUMED
[FixedPcd.common] [FixedPcd.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported
@ -90,7 +90,6 @@
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeiCoreEntry gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeiCoreEntry
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize
[FeaturePcd.common] [FeaturePcd.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst

View File

@ -20,10 +20,10 @@ STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
NULL NULL
}; };
// ///
// Pei Core Module Variables /// Pei Core Module Variables
// ///
// ///
STATIC EFI_PEI_SERVICES gPs = { STATIC EFI_PEI_SERVICES gPs = {
{ {
PEI_SERVICES_SIGNATURE, PEI_SERVICES_SIGNATURE,
@ -107,12 +107,20 @@ PeiCore (
mTick = 0; mTick = 0;
OldCoreData = (PEI_CORE_INSTANCE *) Data; OldCoreData = (PEI_CORE_INSTANCE *) Data;
//
// Record the system tick for first entering PeiCore.
// This tick is duration of executing platform seccore module.
//
if (PerformanceMeasurementEnabled()) { if (PerformanceMeasurementEnabled()) {
if (OldCoreData == NULL) { if (OldCoreData == NULL) {
mTick = GetPerformanceCounter (); mTick = GetPerformanceCounter ();
} }
} }
//
// PeiCore has been shadowed to memory for first entering, so
// just jump to PeiCore in memory here.
//
if (OldCoreData != NULL) { if (OldCoreData != NULL) {
ShadowedPeiCore = (PEI_CORE_ENTRY_POINT) (UINTN) OldCoreData->ShadowedPeiCore; ShadowedPeiCore = (PEI_CORE_ENTRY_POINT) (UINTN) OldCoreData->ShadowedPeiCore;
if (ShadowedPeiCore != NULL) { if (ShadowedPeiCore != NULL) {
@ -143,7 +151,6 @@ PeiCore (
// //
// Initialize libraries that the PeiCore is linked against // Initialize libraries that the PeiCore is linked against
// BUGBUG: The FileHandle is passed in as NULL. Do we look it up or remove it from the lib init?
// //
ProcessLibraryConstructorList (NULL, &PrivateData.PS); ProcessLibraryConstructorList (NULL, &PrivateData.PS);
@ -213,6 +220,10 @@ PeiCore (
// //
ASSERT(PrivateData.PeiMemoryInstalled == TRUE); ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
//
// Till now, PEI phase will be finished, get performace count
// for computing duration of PEI phase
//
PERF_END (NULL, "PostMem", NULL, 0); PERF_END (NULL, "PostMem", NULL, 0);
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
@ -223,6 +234,9 @@ PeiCore (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
//
// Enter DxeIpl to load Dxe core.
//
DEBUG ((EFI_D_INFO, "DXE IPL Entry\n")); DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));
Status = TempPtr.DxeIpl->Entry ( Status = TempPtr.DxeIpl->Entry (
TempPtr.DxeIpl, TempPtr.DxeIpl,

View File

@ -18,7 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Initialize PPI services. Initialize PPI services.
@param PrivateData Pointer to the PEI Core data. @param PrivateData Pointer to the PEI Core data.
@param OldCoreData Pointer to old PEI Core data. @param OldCoreData Pointer to old PEI Core data.
NULL if being run in non-permament memory mode. NULL if being run in non-permament memory mode.
@ -50,18 +49,15 @@ InitializePpiServices (
**/ **/
VOID VOID
ConvertPpiPointers ( ConvertPpiPointers (
IN CONST EFI_PEI_SERVICES **PeiServices, IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OldCheckingBottom, IN UINTN OldCheckingBottom,
IN UINTN OldCheckingTop, IN UINTN OldCheckingTop,
IN UINTN Fixup IN INTN Fixup
) )
{ {
PEI_CORE_INSTANCE *PrivateData;
UINT8 Index; UINT8 Index;
PEI_PPI_LIST_POINTERS *PpiPointer; PEI_PPI_LIST_POINTERS *PpiPointer;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) { for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
if (Index < PrivateData->PpiData.PpiListEnd || if (Index < PrivateData->PpiData.PpiListEnd ||
Index > PrivateData->PpiData.NotifyListEnd) { Index > PrivateData->PpiData.NotifyListEnd) {
@ -342,7 +338,6 @@ PeiLocatePpi (
Install a notification for a given PPI. Install a notification for a given PPI.
@param PeiServices - Pointer to the PEI Service Table @param PeiServices - Pointer to the PEI Service Table
@param NotifyList - Pointer to list of Descriptors to notify upon. @param NotifyList - Pointer to list of Descriptors to notify upon.
@ -451,7 +446,6 @@ PeiNotifyPpi (
PrivateData->PpiData.NotifyListEnd PrivateData->PpiData.NotifyListEnd
); );
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -578,7 +572,5 @@ DispatchNotify (
} }
} }
} }
return;
} }

View File

@ -40,12 +40,10 @@ STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
}; };
/** /**
Initialize the security services. Initialize the security services.
@param PeiServices The PEI core services table.
@param PeiServices - The PEI core services table. @param OldCoreData Pointer to the old core data.
@param OldCoreData - Pointer to the old core data.
NULL if being run in non-permament memory mode. NULL if being run in non-permament memory mode.
**/ **/

View File

@ -44,9 +44,8 @@ PeiReportStatusCode (
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_PROGRESS_CODE_PPI *StatusCodePpi; EFI_PEI_PROGRESS_CODE_PPI *StatusCodePpi;
// //
//Locate StatusCode Ppi. // Locate StatusCode Ppi.
// //
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiStatusCodePpiGuid, &gEfiPeiStatusCodePpiGuid,