Code scrub DxeIpl to add back the CONST modifier and solve a typecast warning.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5516 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2008-07-18 02:47:57 +00:00
parent f88f0fb67b
commit 9b937a73b0
6 changed files with 80 additions and 64 deletions

View File

@ -61,6 +61,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //
extern BOOLEAN gInMemory; extern BOOLEAN gInMemory;
//
// This PPI is installed to indicate the end of the PEI usage of memory
//
extern CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi;
/** /**
Loads and relocates a PE/COFF image into memory. Loads and relocates a PE/COFF image into memory.
@ -84,21 +91,19 @@ PeiLoadFile (
/** /**
Find DxeCore driver from all First Volumes. Searches DxeCore in all firmware Volumes and loads the first instance that contains DxeCore.
@param FileHandle Pointer to FFS file to search. @param DxeCoreFileName A Pointer to the EFI_GUID to contain the output DxeCore GUID file name.
@return EFI_SUCESS Success to find the FFS in specificed FV @return FileHandle of DxeCore to load DxeCore.
@return others Fail to find the FFS in specificed FV
**/ **/
EFI_STATUS EFI_PEI_FILE_HANDLE
DxeIplFindDxeCore ( DxeIplFindDxeCore (
OUT EFI_PEI_FILE_HANDLE *FileHandle OUT EFI_GUID *DxeCoreFileName
); );
/** /**
This function simply retrieves the function pointer of ImageRead in This function simply retrieves the function pointer of ImageRead in
ImageContext structure. ImageContext structure.
@ -145,14 +150,12 @@ DxeLoadCore (
@param DxeCoreEntryPoint The entrypoint of DxeCore. @param DxeCoreEntryPoint The entrypoint of DxeCore.
@param HobList The start of HobList passed to DxeCore. @param HobList The start of HobList passed to DxeCore.
@param EndOfPeiSignal The PPI descriptor for EFI_END_OF_PEI_PPI.
**/ **/
VOID VOID
HandOffToDxeCore ( HandOffToDxeCore (
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
IN EFI_PEI_HOB_POINTERS HobList, IN EFI_PEI_HOB_POINTERS HobList
IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal
); );

View File

@ -25,32 +25,32 @@ BOOLEAN gInMemory = FALSE;
// Module Globals used in the DXE to PEI handoff // Module Globals used in the DXE to PEI handoff
// These must be module globals, so the stack can be switched // These must be module globals, so the stack can be switched
// //
EFI_DXE_IPL_PPI mDxeIplPpi = { CONST EFI_DXE_IPL_PPI mDxeIplPpi = {
DxeLoadCore DxeLoadCore
}; };
EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = { CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = {
CustomGuidedSectionExtract CustomGuidedSectionExtract
}; };
EFI_PEI_DECOMPRESS_PPI mDecompressPpi = { CONST EFI_PEI_DECOMPRESS_PPI mDecompressPpi = {
Decompress Decompress
}; };
EFI_PEI_PPI_DESCRIPTOR mPpiList[] = { CONST EFI_PEI_PPI_DESCRIPTOR mPpiList[] = {
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI, EFI_PEI_PPI_DESCRIPTOR_PPI,
&gEfiDxeIplPpiGuid, &gEfiDxeIplPpiGuid,
&mDxeIplPpi (VOID *) &mDxeIplPpi
}, },
{ {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiDecompressPpiGuid, &gEfiPeiDecompressPpiGuid,
&mDecompressPpi (VOID *) &mDecompressPpi
} }
}; };
EFI_PEI_PPI_DESCRIPTOR mPpiSignal = { CONST EFI_PEI_PPI_DESCRIPTOR gEndOfPeiSignalPpi = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiEndOfPeiSignalPpiGuid, &gEfiEndOfPeiSignalPpiGuid,
NULL NULL
@ -102,7 +102,7 @@ PeimInitializeDxeIpl (
ASSERT (GuidPpi != NULL); ASSERT (GuidPpi != NULL);
while (ExtractHandlerNumber-- > 0) { while (ExtractHandlerNumber-- > 0) {
GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
GuidPpi->Ppi = &mCustomGuidedSectionExtractionPpi; GuidPpi->Ppi = (VOID *) &mCustomGuidedSectionExtractionPpi;
GuidPpi->Guid = &(ExtractHandlerGuidTable [ExtractHandlerNumber]); GuidPpi->Guid = &(ExtractHandlerGuidTable [ExtractHandlerNumber]);
Status = PeiServicesInstallPpi (GuidPpi++); Status = PeiServicesInstallPpi (GuidPpi++);
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
@ -203,11 +203,7 @@ DxeLoadCore (
// //
// Look in all the FVs present in PEI and find the DXE Core // Look in all the FVs present in PEI and find the DXE Core
// //
FileHandle = NULL; FileHandle = DxeIplFindDxeCore (&DxeCoreFileName);
Status = DxeIplFindDxeCore (&FileHandle);
ASSERT_EFI_ERROR (Status);
CopyGuid(&DxeCoreFileName, &(((EFI_FFS_FILE_HEADER*)FileHandle)->Name));
// //
// Load the DXE Core from a Firmware Volume, may use LoadFile ppi to do this for save code size. // Load the DXE Core from a Firmware Volume, may use LoadFile ppi to do this for save code size.
@ -244,7 +240,7 @@ DxeLoadCore (
// Transfer control to the DXE Core // Transfer control to the DXE Core
// The handoff state is simply a pointer to the HOB list // The handoff state is simply a pointer to the HOB list
// //
HandOffToDxeCore (DxeCoreEntryPoint, HobList, &mPpiSignal); HandOffToDxeCore (DxeCoreEntryPoint, HobList);
// //
// If we get here, then the DXE Core returned. This is an error // If we get here, then the DXE Core returned. This is an error
// Dxe Core should not return. // Dxe Core should not return.
@ -256,41 +252,67 @@ DxeLoadCore (
} }
/** /**
Find DxeCore driver from all First Volumes. Searches DxeCore in all firmware Volumes and loads the first
instance that contains DxeCore.
@param FileHandle Pointer to FFS file to search. @param DxeCoreFileName A Pointer to the EFI_GUID to contain
the output DxeCore GUID file name.
@return EFI_SUCESS Success to find the FFS in specificed FV @return FileHandle of DxeCore to load DxeCore.
@return others Fail to find the FFS in specificed FV
**/ **/
EFI_STATUS EFI_PEI_FILE_HANDLE
DxeIplFindDxeCore ( DxeIplFindDxeCore (
OUT EFI_PEI_FILE_HANDLE *FileHandle OUT EFI_GUID *DxeCoreFileName
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS FileStatus; UINTN Instance;
UINTN Instance; EFI_PEI_FV_HANDLE VolumeHandle;
EFI_PEI_FV_HANDLE VolumeHandle; EFI_PEI_FILE_HANDLE FileHandle;
EFI_FV_FILE_INFO FvFileInfo;
Instance = 0; Instance = 0;
*FileHandle = NULL; while (TRUE) {
//
// Traverse all firmware volume instances
//
Status = PeiServicesFfsFindNextVolume (Instance, &VolumeHandle);
//
// If some error occurs here, then we cannot find any firmware
// volume that may contain DxeCore.
//
ASSERT_EFI_ERROR (Status);
do { //
Status = PeiServicesFfsFindNextVolume (Instance++, &VolumeHandle); // Find the DxeCore file type from the beginning in this firmware volume.
//
FileHandle = NULL;
Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
FileStatus = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, FileHandle); //
if (!EFI_ERROR (FileStatus)) { // Find DxeCore FileHandle in this volume, then we skip other firmware volume.
return FileStatus; //
} break;
} }
} while (!EFI_ERROR (Status)); //
// We cannot find DxeCore in this firmware volume, then search the next volume.
//
Instance++;
}
return EFI_NOT_FOUND; //
// Extract the DxeCore GUID file name.
//
Status = PeiServicesFfsGetFileInfo (FileHandle, &FvFileInfo);
ASSERT_EFI_ERROR (Status);
CopyGuid (DxeCoreFileName, &FvFileInfo.FileName);
//
// Return the FileHandle to load DxeCore from this volume.
//
return FileHandle;
} }

View File

@ -53,14 +53,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED IA32_DESCRIPTOR gLidtDescriptor = {
@param DxeCoreEntryPoint The entrypoint of DxeCore. @param DxeCoreEntryPoint The entrypoint of DxeCore.
@param HobList The start of HobList passed to DxeCore. @param HobList The start of HobList passed to DxeCore.
@param EndOfPeiSignal The PPI descriptor for EFI_END_OF_PEI_PPI.
**/ **/
VOID VOID
HandOffToDxeCore ( HandOffToDxeCore (
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
IN EFI_PEI_HOB_POINTERS HobList, IN EFI_PEI_HOB_POINTERS HobList
IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -106,7 +104,7 @@ HandOffToDxeCore (
// //
// End of PEI phase singal // End of PEI phase singal
// //
Status = PeiServicesInstallPpi (EndOfPeiSignal); Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
AsmWriteCr3 (PageTables); AsmWriteCr3 (PageTables);
@ -169,7 +167,7 @@ HandOffToDxeCore (
// //
// End of PEI phase singal // End of PEI phase singal
// //
Status = PeiServicesInstallPpi (EndOfPeiSignal); Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //

View File

@ -56,9 +56,6 @@ PeiImageRead (
} }
/** /**
This function simply retrieves the function pointer of ImageRead in This function simply retrieves the function pointer of ImageRead in
ImageContext structure. ImageContext structure.

View File

@ -25,14 +25,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@param DxeCoreEntryPoint The entrypoint of DxeCore. @param DxeCoreEntryPoint The entrypoint of DxeCore.
@param HobList The start of HobList passed to DxeCore. @param HobList The start of HobList passed to DxeCore.
@param EndOfPeiSignal The PPI descriptor for EFI_END_OF_PEI_PPI.
**/ **/
VOID VOID
HandOffToDxeCore ( HandOffToDxeCore (
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
IN EFI_PEI_HOB_POINTERS HobList, IN EFI_PEI_HOB_POINTERS HobList
IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal
) )
{ {
VOID *BaseOfStack; VOID *BaseOfStack;
@ -66,7 +64,7 @@ HandOffToDxeCore (
// //
// End of PEI phase singal // End of PEI phase singal
// //
Status = PeiServicesInstallPpi (EndOfPeiSignal); Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //

View File

@ -25,14 +25,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@param DxeCoreEntryPoint The entrypoint of DxeCore. @param DxeCoreEntryPoint The entrypoint of DxeCore.
@param HobList The start of HobList passed to DxeCore. @param HobList The start of HobList passed to DxeCore.
@param EndOfPeiSignal The PPI descriptor for EFI_END_OF_PEI_PPI.
**/ **/
VOID VOID
HandOffToDxeCore ( HandOffToDxeCore (
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
IN EFI_PEI_HOB_POINTERS HobList, IN EFI_PEI_HOB_POINTERS HobList
IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal
) )
{ {
VOID *BaseOfStack; VOID *BaseOfStack;
@ -55,7 +53,7 @@ HandOffToDxeCore (
// //
// End of PEI phase singal // End of PEI phase singal
// //
Status = PeiServicesInstallPpi (EndOfPeiSignal); Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //