diff options
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r-- | MdeModulePkg/Core/Pei/Dependency/Dependency.c | 6 | ||||
-rw-r--r-- | MdeModulePkg/Core/Pei/FwVol/FwVol.c | 120 | ||||
-rw-r--r-- | MdeModulePkg/Core/Pei/Image/Image.c | 88 |
3 files changed, 82 insertions, 132 deletions
diff --git a/MdeModulePkg/Core/Pei/Dependency/Dependency.c b/MdeModulePkg/Core/Pei/Dependency/Dependency.c index 234e0bf82d..654068f119 100644 --- a/MdeModulePkg/Core/Pei/Dependency/Dependency.c +++ b/MdeModulePkg/Core/Pei/Dependency/Dependency.c @@ -5,7 +5,7 @@ if a driver can be scheduled for execution. The criteria for
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
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
@@ -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.
- @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
@retval TRUE if the PPI is already installed.
@@ -84,7 +84,7 @@ IsPpiInstalled ( 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
the BNF described above and is stored in postfix notation.
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index 89bac8c6de..a841a7eb24 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -1,7 +1,7 @@ /** @file
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
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
@@ -22,17 +22,17 @@ STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = { #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
in the Attributes field.
@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
GetFileState(
@@ -48,7 +48,10 @@ GetFileState( if (ErasePolarity != 0) {
FileState = (EFI_FFS_FILE_STATE)~FileState;
}
-
+
+ //
+ // Get file state set by its highest none zero bit.
+ //
HighestBit = 0x80;
while (HighestBit != 0 && (HighestBit & FileState) == 0) {
HighestBit >>= 1;
@@ -63,7 +66,6 @@ GetFileState( @param FileHeader Pointer to FFS File Header.
@return Checksum of the header.
- The header is zero byte checksum.
Zero means the header is good.
Non-zero means the header is bad.
**/
@@ -72,45 +74,26 @@ CalculateHeaderChecksum ( IN EFI_FFS_FILE_HEADER *FileHeader
)
{
- UINT8 *Ptr;
- UINTN Index;
- UINT8 Sum;
-
- Sum = 0;
- Ptr = (UINT8 *)FileHeader;
-
- for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) {
- 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]);
- }
+ EFI_FFS_FILE_HEADER TestFileHeader;
+ CopyMem (&TestFileHeader, FileHeader, sizeof (EFI_FFS_FILE_HEADER));
//
- // State field (since this indicates the different state of file).
+ // Ingore State and File field in FFS header.
//
- Sum = (UINT8)(Sum - FileHeader->State);
- //
- // Checksum field of the file is not part of the header checksum.
- //
- Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
+ TestFileHeader.State = 0;
+ TestFileHeader.IntegrityCheck.Checksum.File = 0;
- return Sum;
+ return CalculateSum8 ((CONST UINT8 *) &TestFileHeader, sizeof (EFI_FFS_FILE_HEADER));
}
/**
Find FV handler according some FileHandle in that FV.
@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
- file name.
- @retval FALSE Can not find the FV that contains file by given file name.
+ @retval TRUE The corresponding FV handler is found.
+ @retval FALSE The corresponding FV handler is not found.
**/
BOOLEAN
@@ -133,22 +116,22 @@ PeiFileHandleToVolume ( return TRUE;
}
}
+ *VolumeHandle = NULL;
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
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 FileName File name
@param SearchType Filter to find only files of this type.
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 AprioriFile Pointer to AprioriFile image in this FV if has
@@ -316,12 +299,14 @@ PeiInitializeFv ( /**
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 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
@@ -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,
- when meeting an encapsuled section.
-
-
- @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.
+ @return EFI_NOT_FOUND The match section is not found.
+ @return EFI_SUCCESS The match section is found.
**/
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.
-
- @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 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
@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 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
EFIAPI
diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c index 786266b080..6ac537b42f 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -1,7 +1,7 @@ /** @file
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
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
@@ -15,32 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #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().
@param This - Pointer to EFI_PEI_LOAD_FILE_PPI.
@@ -94,27 +68,17 @@ EFIAPI PeiImageRead (
IN VOID *FileHandle,
IN UINTN FileOffset,
- IN OUT UINTN *ReadSize,
+ IN UINTN *ReadSize,
OUT VOID *Buffer
)
{
- CHAR8 *Destination8;
- CHAR8 *Source8;
- UINTN Length;
-
- Destination8 = Buffer;
- Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
- Length = *ReadSize;
- while (Length--) {
- *(Destination8++) = *(Source8++);
- }
-
+ CopyMem (Buffer, (VOID *)((UINTN) FileHandle + FileOffset), *ReadSize);
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
@@ -150,6 +114,7 @@ GetImageReadFunction ( @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_INVALID_PARAMETER The image withou .reloc section can't be relocated.
**/
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 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.
+ @retval EFI_SUCCESS Image is successfully loaded.
+ @retval EFI_NOT_FOUND Fail to locate necessary PPI.
+ @retval EFI_UNSUPPORTED Image Machine Type is not supported.
**/
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.
+ @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.
- @retval EFI_NOT_FOUND Fail to locate necessary PPI
- @retval Others Fail to load file.
+ @retval EFI_SUCCESS - Image is successfully loaded.
+ @retval EFI_NOT_FOUND - Fail to locate necessary PPI
+ @retval Others - Fail to load file.
**/
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.
- @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
- to permenent memory.
+ Install Pei Load File PPI.
+
+
+ @param PrivateData - Pointer to PEI_CORE_INSTANCE.
+ @param OldCoreData - Pointer to PEI_CORE_INSTANCE.
**/
VOID
|