Simplify the code to use the EFI_FV_FILE_INFO structure of DxeCore to save the extra GUID copy.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5525 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2008-07-19 01:38:40 +00:00
parent 555a6f4536
commit b6b98e9133
2 changed files with 25 additions and 29 deletions

View File

@ -91,16 +91,15 @@ PeiLoadFile (
/** /**
Searches DxeCore in all firmware Volumes and loads the first instance that contains DxeCore. Searches DxeCore in all firmware Volumes and loads the first
instance that contains DxeCore.
@param DxeCoreFileName A Pointer to the EFI_GUID to contain the output DxeCore GUID file name.
@return FileHandle of DxeCore to load DxeCore. @return FileHandle of DxeCore to load DxeCore.
**/ **/
EFI_PEI_FILE_HANDLE EFI_PEI_FILE_HANDLE
DxeIplFindDxeCore ( DxeIplFindDxeCore (
OUT EFI_GUID *DxeCoreFileName VOID
); );

View File

@ -142,7 +142,7 @@ DxeLoadCore (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_GUID DxeCoreFileName; EFI_FV_FILE_INFO DxeCoreFileInfo;
EFI_PHYSICAL_ADDRESS DxeCoreAddress; EFI_PHYSICAL_ADDRESS DxeCoreAddress;
UINT64 DxeCoreSize; UINT64 DxeCoreSize;
EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint; EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint;
@ -201,9 +201,9 @@ 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
// //
FileHandle = DxeIplFindDxeCore (&DxeCoreFileName); FileHandle = DxeIplFindDxeCore ();
// //
// 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.
@ -216,11 +216,17 @@ DxeLoadCore (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
//
// Get the DxeCore File Info from the FileHandle for the DxeCore GUID file name.
//
Status = PeiServicesFfsGetFileInfo (FileHandle, &DxeCoreFileInfo);
ASSERT_EFI_ERROR (Status);
// //
// Add HOB for the DXE Core // Add HOB for the DXE Core
// //
BuildModuleHob ( BuildModuleHob (
&DxeCoreFileName, &DxeCoreFileInfo.FileName,
DxeCoreAddress, DxeCoreAddress,
EFI_SIZE_TO_PAGES ((UINTN) DxeCoreSize) * EFI_PAGE_SIZE, EFI_SIZE_TO_PAGES ((UINTN) DxeCoreSize) * EFI_PAGE_SIZE,
DxeCoreEntryPoint DxeCoreEntryPoint
@ -256,22 +262,18 @@ DxeLoadCore (
Searches DxeCore in all firmware Volumes and loads the first Searches DxeCore in all firmware Volumes and loads the first
instance that contains DxeCore. instance that contains DxeCore.
@param DxeCoreFileName A Pointer to the EFI_GUID to contain
the output DxeCore GUID file name.
@return FileHandle of DxeCore to load DxeCore. @return FileHandle of DxeCore to load DxeCore.
**/ **/
EFI_PEI_FILE_HANDLE EFI_PEI_FILE_HANDLE
DxeIplFindDxeCore ( DxeIplFindDxeCore (
OUT EFI_GUID *DxeCoreFileName VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN Instance; UINTN Instance;
EFI_PEI_FV_HANDLE VolumeHandle; EFI_PEI_FV_HANDLE VolumeHandle;
EFI_PEI_FILE_HANDLE FileHandle; EFI_PEI_FILE_HANDLE FileHandle;
EFI_FV_FILE_INFO FvFileInfo;
Instance = 0; Instance = 0;
while (TRUE) { while (TRUE) {
@ -292,9 +294,10 @@ DxeIplFindDxeCore (
Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle); Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
// //
// Find DxeCore FileHandle in this volume, then we skip other firmware volume. // Find DxeCore FileHandle in this volume, then we skip other firmware volume and
// return the FileHandle.
// //
break; return FileHandle;
} }
// //
// We cannot find DxeCore in this firmware volume, then search the next volume. // We cannot find DxeCore in this firmware volume, then search the next volume.
@ -303,16 +306,10 @@ DxeIplFindDxeCore (
} }
// //
// Extract the DxeCore GUID file name. // We should never reach here.
// //
Status = PeiServicesFfsGetFileInfo (FileHandle, &FvFileInfo); ASSERT (FALSE);
ASSERT_EFI_ERROR (Status); return NULL;
CopyGuid (DxeCoreFileName, &FvFileInfo.FileName);
//
// Return the FileHandle to load DxeCore from this volume.
//
return FileHandle;
} }
@ -480,11 +477,11 @@ CustomGuidedSectionExtract (
// Call GetInfo to get the size and attribute of input guided section data. // Call GetInfo to get the size and attribute of input guided section data.
// //
Status = ExtractGuidedSectionGetInfo ( Status = ExtractGuidedSectionGetInfo (
InputSection, InputSection,
&OutputBufferSize, &OutputBufferSize,
&ScratchBufferSize, &ScratchBufferSize,
&SectionAttribute &SectionAttribute
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "GetInfo from guided section Failed - %r\n", Status)); DEBUG ((DEBUG_ERROR, "GetInfo from guided section Failed - %r\n", Status));