Correct some comments to add the detailed information.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5620 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2008-08-08 03:33:16 +00:00
parent d73d93c31e
commit ed299e3c41
3 changed files with 84 additions and 134 deletions

View File

@ -5,7 +5,7 @@
if a driver can be scheduled for execution. The criteria for if a driver can be scheduled for execution. The criteria for
schedulability is that the dependency expression is satisfied. schedulability is that the dependency expression is satisfied.
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -26,7 +26,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
been published and can be queried from the PPI database. been published and can be queried from the PPI database.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param Stack Reference to EVAL_STACK_ENTRY that contains PPI GUID to check @param Stack Reference to EVAL_STACK_ENTRY that contains PPI GUID to check
@retval TRUE if the PPI is already installed. @retval TRUE if the PPI is already installed.
@ -84,7 +84,7 @@ IsPpiInstalled (
operation types (AND, OR). operation types (AND, OR).
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param DependencyExpression Pointer to a dependency expression. The Grammar adheres to @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to
the BNF described above and is stored in postfix notation. the BNF described above and is stored in postfix notation.

View File

@ -1,7 +1,7 @@
/** @file /** @file
Pei Core Firmware File System service routines. Pei Core Firmware File System service routines.
Copyright (c) 2006 - 2007, Intel Corporation Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -22,17 +22,17 @@ STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)) ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
/** /**
Returns the highest bit set of the State field Returns the file state set by the highest zero bit in 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.
@return Returns the highest bit in the State field @retval EFI_FFS_FILE_STATE File state is set by the highest none zero bit
in the header State field.
**/ **/
EFI_FFS_FILE_STATE EFI_FFS_FILE_STATE
GetFileState( GetFileState(
@ -48,7 +48,10 @@ GetFileState(
if (ErasePolarity != 0) { if (ErasePolarity != 0) {
FileState = (EFI_FFS_FILE_STATE)~FileState; FileState = (EFI_FFS_FILE_STATE)~FileState;
} }
//
// Get file state set by its highest none zero bit.
//
HighestBit = 0x80; HighestBit = 0x80;
while (HighestBit != 0 && (HighestBit & FileState) == 0) { while (HighestBit != 0 && (HighestBit & FileState) == 0) {
HighestBit >>= 1; HighestBit >>= 1;
@ -63,7 +66,6 @@ GetFileState(
@param FileHeader Pointer to FFS File Header. @param FileHeader Pointer to FFS File Header.
@return Checksum of the header. @return Checksum of the header.
The header is zero byte checksum.
Zero means the header is good. Zero means the header is good.
Non-zero means the header is bad. Non-zero means the header is bad.
**/ **/
@ -72,45 +74,26 @@ CalculateHeaderChecksum (
IN EFI_FFS_FILE_HEADER *FileHeader IN EFI_FFS_FILE_HEADER *FileHeader
) )
{ {
UINT8 *Ptr; EFI_FFS_FILE_HEADER TestFileHeader;
UINTN Index;
UINT8 Sum;
Sum = 0; CopyMem (&TestFileHeader, FileHeader, sizeof (EFI_FFS_FILE_HEADER));
Ptr = (UINT8 *)FileHeader; //
// Ingore State and File field in FFS header.
//
TestFileHeader.State = 0;
TestFileHeader.IntegrityCheck.Checksum.File = 0;
for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) { return CalculateSum8 ((CONST UINT8 *) &TestFileHeader, sizeof (EFI_FFS_FILE_HEADER));
Sum = (UINT8)(Sum + Ptr[Index]);
Sum = (UINT8)(Sum + Ptr[Index+1]);
Sum = (UINT8)(Sum + Ptr[Index+2]);
Sum = (UINT8)(Sum + Ptr[Index+3]);
}
for (; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {
Sum = (UINT8)(Sum + Ptr[Index]);
}
//
// State field (since this indicates the different state of file).
//
Sum = (UINT8)(Sum - FileHeader->State);
//
// Checksum field of the file is not part of the header checksum.
//
Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
return Sum;
} }
/** /**
Find FV handler according some FileHandle in that FV. Find FV handler according some FileHandle in that FV.
@param FileHandle Handle of file image @param FileHandle Handle of file image
@param VolumeHandle Handle of FV @param VolumeHandle Handle of the found FV, if not found, NULL will be set.
@retval TRUE Success to find FV and return FV handle that contains file by given @retval TRUE The corresponding FV handler is found.
file name. @retval FALSE The corresponding FV handler is not found.
@retval FALSE Can not find the FV that contains file by given file name.
**/ **/
BOOLEAN BOOLEAN
@ -133,22 +116,22 @@ PeiFileHandleToVolume (
return TRUE; return TRUE;
} }
} }
*VolumeHandle = NULL;
return FALSE; return FALSE;
} }
/** /**
Given the input file pointer, search for the next matching file in the Given the input file pointer, search for the first matching file in the
FFS volume as defined by SearchType. The search starts from FileHeader inside FFS volume as defined by SearchType. The search starts from FileHeader inside
the Firmware Volume defined by FwVolHeader. the Firmware Volume defined by FwVolHeader.
If SearchType is EFI_FV_FILETYPE_ALL, the first FFS file will return without check its file type.
If SearchType is PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE,
the first PEIM, or COMBINED PEIM or FV file type FFS file will return.
@param FvHandle Pointer to the FV header of the volume to search @param FvHandle Pointer to the FV header of the volume to search
@param FileName File name @param FileName File name
@param SearchType Filter to find only files of this type. @param SearchType Filter to find only files of this type.
Type EFI_FV_FILETYPE_ALL causes no filtering to be done. Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
Type PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE is an FFS type
extension used for PeiFindFileEx. It indicates current
Ffs searching is for all PEIMs can be dispatched by PeiCore.
@param FileHandle This parameter must point to a valid FFS volume. @param FileHandle This parameter must point to a valid FFS volume.
@param AprioriFile Pointer to AprioriFile image in this FV if has @param AprioriFile Pointer to AprioriFile image in this FV if has
@ -316,12 +299,14 @@ PeiInitializeFv (
/** /**
Process Firmware Volum Information once FvInfoPPI install. Process Firmware Volum Information once FvInfoPPI install.
The FV Info will be registered into PeiCore private data structure.
And search the inside FV image, if found, the new FV INFO PPI will be installed.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param NotifyDescriptor Address of the notification descriptor data structure. @param NotifyDescriptor Address of the notification descriptor data structure.
@param Ppi Address of the PPI that was installed. @param Ppi Address of the PPI that was installed.
@retval EFI_SUCCESS if the interface could be successfully installed @retval EFI_SUCCESS The FV Info is registered into PeiCore private data structure.
**/ **/
EFI_STATUS EFI_STATUS
@ -403,19 +388,19 @@ FirmwareVolmeInfoPpiNotifyCallback (
} }
/** /**
Go through the file to search SectionType section.
Search within encapsulation sections (compression and GUIDed) recursively,
until the match section is found.
@param PeiServices - An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param SectionType - Filter to find only section of this type.
@param Section - From where to search.
@param SectionSize - The file size to search.
@param OutputBuffer - A pointer to the discovered section, if successful.
NULL if section not found
Go through the file to search SectionType section, @return EFI_NOT_FOUND The match section is not found.
when meeting an encapsuled section. @return EFI_SUCCESS The match section is found.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param SectionType Filter to find only section of this type.
@param Section From where to search.
@param SectionSize The file size to search.
@param OutputBuffer Pointer to the section to search.
@retval EFI_NOT_FOUND Can not find the section by given section type.
@retval EFI_SUCCESS Success to find the section and process section correctly.
**/ **/
EFI_STATUS EFI_STATUS
@ -538,14 +523,13 @@ PeiFfsProcessSection (
/** /**
Given the input file pointer, search for the next matching section in the Given the input file pointer, search for the first matching section in the
FFS volume. FFS volume.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param SectionType Filter to find only sections of this type. @param SectionType Filter to find only sections of this type.
@param FileHandle Pointer to the current file to search. @param FileHandle Pointer to the current file to search.
@param SectionData Pointer to the Section matching SectionType in FfsFileHeader. @param SectionData A pointer to the discovered section, if successful.
NULL if section not found NULL if section not found
@retval EFI_NOT_FOUND No files matching the search criteria were found @retval EFI_NOT_FOUND No files matching the search criteria were found
@ -615,9 +599,9 @@ PeiFfsFindNextFile (
/** /**
search the firmware volumes by index Search the firmware volumes by index
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param Instance Instance of FV to find @param Instance Instance of FV to find
@param VolumeHandle Pointer to found Volume. @param VolumeHandle Pointer to found Volume.
@ -651,17 +635,17 @@ PeiFvFindNextVolume (
/** /**
Find a file within a volume by its name.
Given the input VolumeHandle, search for the next matching name file. @param FileName A pointer to the name of the file to find within the firmware volume.
@param VolumeHandle The firmware volume to search
@param FileHandle Upon exit, points to the found file's handle
or NULL if it could not be found.
@retval EFI_SUCCESS File was found.
@retval EFI_NOT_FOUND File was not found.
@retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or FileName was NULL.
@param FileName File name to search.
@param VolumeHandle The current FV to search.
@param FileHandle Pointer to the file matching name in VolumeHandle.
NULL if file not found
@retval EFI_NOT_FOUND No files matching the search criteria were found
@retval EFI_SUCCESS Success to search given file
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI

View File

@ -1,7 +1,7 @@
/** @file /** @file
Pei Core Load Image Support Pei Core Load Image Support
Copyright (c) 2006 - 2007, Intel Corporation Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -14,32 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PeiMain.h> #include <PeiMain.h>
/**
Routine for loading file image.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param FileHandle Pointer to the FFS file header of the image.
@param ImageAddressArg Pointer to PE/TE image.
@param ImageSizeArg Size of PE/TE image.
@param EntryPoint Pointer to entry point of specified image file for output.
@param AuthenticationState - Pointer to attestation authentication state of image.
@retval EFI_SUCCESS - Image is successfully loaded.
@retval EFI_NOT_FOUND - Fail to locate necessary PPI
@retval Others - Fail to load file.
**/
EFI_STATUS
PeiLoadImageLoadImage (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL
OUT UINT64 *ImageSizeArg, OPTIONAL
OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
OUT UINT32 *AuthenticationState
)
;
/** /**
The wrapper function of PeiLoadImageLoadImage(). The wrapper function of PeiLoadImageLoadImage().
@ -94,27 +68,17 @@ EFIAPI
PeiImageRead ( PeiImageRead (
IN VOID *FileHandle, IN VOID *FileHandle,
IN UINTN FileOffset, IN UINTN FileOffset,
IN OUT UINTN *ReadSize, IN UINTN *ReadSize,
OUT VOID *Buffer OUT VOID *Buffer
) )
{ {
CHAR8 *Destination8; CopyMem (Buffer, (VOID *)((UINTN) FileHandle + FileOffset), *ReadSize);
CHAR8 *Source8;
UINTN Length;
Destination8 = Buffer;
Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
Length = *ReadSize;
while (Length--) {
*(Destination8++) = *(Source8++);
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Support routine to return the Image Read. Support routine to get the Image read file function.
@param ImageContext - The context of the image being loaded @param ImageContext - The context of the image being loaded
@ -150,6 +114,7 @@ GetImageReadFunction (
@retval EFI_SUCCESS The file was loaded and relocated @retval EFI_SUCCESS The file was loaded and relocated
@retval EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file @retval EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file
@retval EFI_INVALID_PARAMETER The image withou .reloc section can't be relocated.
**/ **/
EFI_STATUS EFI_STATUS
@ -223,18 +188,20 @@ LoadAndRelocatePeCoffImage (
} }
/** /**
Routine for loading file image. Loads a PEIM into memory for subsequent execution. If there are compressed
images or images that need to be relocated into memory for performance reasons,
this service performs that transformation.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param FileHandle Pointer to the FFS file header of the image. @param FileHandle Pointer to the FFS file header of the image.
@param ImageAddressArg Pointer to PE/TE image. @param ImageAddressArg Pointer to PE/TE image.
@param ImageSizeArg Size of PE/TE image. @param ImageSizeArg Size of PE/TE image.
@param EntryPoint Pointer to entry point of specified image file for output. @param EntryPoint Pointer to entry point of specified image file for output.
@param AuthenticationState - Pointer to attestation authentication state of image. @param AuthenticationState - Pointer to attestation authentication state of image.
@retval EFI_SUCCESS - Image is successfully loaded. @retval EFI_SUCCESS Image is successfully loaded.
@retval EFI_NOT_FOUND - Fail to locate necessary PPI @retval EFI_NOT_FOUND Fail to locate necessary PPI.
@retval Others - Fail to load file. @retval EFI_UNSUPPORTED Image Machine Type is not supported.
**/ **/
EFI_STATUS EFI_STATUS
@ -428,18 +395,18 @@ PeiLoadImageLoadImageWrapper (
} }
/** /**
Routine to load image file for subsequent execution by LoadFile Ppi.
If any LoadFile Ppi is not found, the build-in support function for the PE32+/TE
XIP image format is used.
Routine for load image file. @param PeiServices - An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param FileHandle - Pointer to the FFS file header of the image.
@param EntryPoint - Pointer to entry point of specified image file for output.
@param AuthenticationState - Pointer to attestation authentication state of image.
@retval EFI_SUCCESS - Image is successfully loaded.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. @retval EFI_NOT_FOUND - Fail to locate necessary PPI
@param FileHandle Pointer to the FFS file header of the image. @retval Others - Fail to load file.
@param EntryPoint Pointer to entry point of specified image file for output.
@param AuthenticationState Pointer to attestation authentication state of image.
@retval EFI_SUCCESS Image is successfully loaded.
@retval EFI_NOT_FOUND Fail to locate necessary PPI
@retval Others Fail to load file.
**/ **/
EFI_STATUS EFI_STATUS
@ -502,13 +469,12 @@ PeiLoadImage (
/** /**
Initialize image service that install PeiLoadFilePpi.
@param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE. Install Pei Load File PPI.
@param OldCoreData Pointer to Old PeiCore's private data.
If NULL, PeiCore is entered at first time, stack/heap in temporary memory.
If not NULL, PeiCore is entered at second time, stack/heap has been moved @param PrivateData - Pointer to PEI_CORE_INSTANCE.
to permenent memory. @param OldCoreData - Pointer to PEI_CORE_INSTANCE.
**/ **/
VOID VOID