Code Scrub for Dxe Core.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5560 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2008-07-24 02:54:45 +00:00
parent 11c11e4ecf
commit 022c6d45ef
38 changed files with 2499 additions and 2504 deletions

View File

@@ -19,8 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
Get the FFS file state by checking the highest bit set in the header's state field.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header
@return FFS File state
@@ -53,11 +53,11 @@ GetFileState (
/**
Check if a block of buffer is erased.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param InBuffer The buffer to be checked
@param BufferSize Size of the buffer in bytes
@param ErasePolarity Erase polarity attribute of the firmware volume
@param InBuffer The buffer to be checked
@param BufferSize Size of the buffer in bytes
@retval TRUE The block of buffer is erased
@retval TRUE The block of buffer is erased
@retval FALSE The block of buffer is not erased
**/
@@ -93,9 +93,9 @@ IsBufferErased (
/**
Verify checksum of the firmware volume header.
@param FvHeader Points to the firmware volume header to be checked
@param FvHeader Points to the firmware volume header to be checked
@retval TRUE Checksum verification passed
@retval TRUE Checksum verification passed
@retval FALSE Checksum verification failed
**/
@@ -128,9 +128,9 @@ VerifyFvHeaderChecksum (
/**
Verify checksum of the FFS file header.
@param FfsHeader Points to the FFS file header to be checked
@param FfsHeader Points to the FFS file header to be checked
@retval TRUE Checksum verification passed
@retval TRUE Checksum verification passed
@retval FALSE Checksum verification failed
**/
@@ -163,11 +163,11 @@ VerifyHeaderChecksum (
/**
Check if it's a valid FFS file header.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header to be checked
@param FileState FFS file state to be returned
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file header to be checked
@param FileState FFS file state to be returned
@retval TRUE Valid FFS file header
@retval TRUE Valid FFS file header
@retval FALSE Invalid FFS file header
**/
@@ -189,7 +189,7 @@ IsValidFfsHeader (
// Here we need to verify header checksum
//
return VerifyHeaderChecksum (FfsHeader);
case EFI_FILE_HEADER_CONSTRUCTION:
case EFI_FILE_HEADER_INVALID:
default:
@@ -202,10 +202,10 @@ IsValidFfsHeader (
Check if it's a valid FFS file.
Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file to be checked
@param ErasePolarity Erase polarity attribute of the firmware volume
@param FfsHeader Points to the FFS file to be checked
@retval TRUE Valid FFS file
@retval TRUE Valid FFS file
@retval FALSE Invalid FFS file
**/

View File

@@ -1,6 +1,6 @@
/** @file
Firmware File System driver that produce Firmware Volume protocol.
Layers on top of Firmware Block protocol to produce a file abstraction
Layers on top of Firmware Block protocol to produce a file abstraction
of FV based files.
Copyright (c) 2006 - 2008, Intel Corporation. <BR>
@@ -56,13 +56,13 @@ FV_DEVICE mFvDevice = {
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it.
@param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
read the volume header
@param FwVolHeader Pointer to pointer to allocated buffer in which
the volume header is returned.
@param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
read the volume header
@param FwVolHeader Pointer to pointer to allocated buffer in which
the volume header is returned.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS Successfully read volume header to the allocated
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS Successfully read volume header to the allocated
buffer.
**/
@@ -109,7 +109,7 @@ GetFwVolHeader (
//
CoreFreePool (*FwVolHeader);
}
return Status;
}
@@ -118,7 +118,7 @@ GetFwVolHeader (
/**
Free FvDevice resource when error happens
@param FvDevice pointer to the FvDevice to be freed.
@param FvDevice pointer to the FvDevice to be freed.
**/
VOID
@@ -135,7 +135,7 @@ FreeFvDeviceResource (
FfsFileEntry = (FFS_FILE_LIST_ENTRY *)FvDevice->FfsFileListHeader.ForwardLink;
while (&FfsFileEntry->Link != &FvDevice->FfsFileListHeader) {
NextEntry = (&FfsFileEntry->Link)->ForwardLink;
if (FfsFileEntry->StreamHandle != 0) {
//
// Close stream and free resources from SEP
@@ -167,10 +167,10 @@ FreeFvDeviceResource (
/**
Check if an FV is consistent and allocate cache for it.
@param FvDevice A pointer to the FvDevice to be checked.
@param FvDevice A pointer to the FvDevice to be checked.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS FV is consistent and cache is allocated.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS FV is consistent and cache is allocated.
@retval EFI_VOLUME_CORRUPTED File system is corrupted.
**/
@@ -199,7 +199,7 @@ FvCheck (
Fvb = FvDevice->Fvb;
FwVolHeader = FvDevice->FwVolHeader;
Status = Fvb->GetAttributes (Fvb, &FvbAttributes);
if (EFI_ERROR (Status)) {
return Status;
@@ -230,7 +230,7 @@ FvCheck (
LbaIndex = 0;
LbaOffset = FwVolHeader->HeaderLength;
while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {
for (Index = 0; Index < BlockMap->NumBlocks; Index ++) {
Size = BlockMap->Length;
@@ -252,7 +252,7 @@ FvCheck (
if (EFI_ERROR (Status)) {
goto Done;
}
//
// After we skip Fv Header always read from start of block
//
@@ -271,7 +271,7 @@ FvCheck (
FvDevice->ErasePolarity = 1;
} else {
FvDevice->ErasePolarity = 0;
}
}
//
@@ -301,7 +301,7 @@ FvCheck (
}
if (!IsValidFfsHeader (FvDevice->ErasePolarity, FfsHeader, &FileState)) {
if ((FileState == EFI_FILE_HEADER_INVALID) ||
if ((FileState == EFI_FILE_HEADER_INVALID) ||
(FileState == EFI_FILE_HEADER_CONSTRUCTION)) {
FfsHeader++;
continue;
@@ -328,7 +328,7 @@ FvCheck (
FileLength = *(UINT32 *)&FfsHeader->Size[0] & 0x00FFFFFF;
FileState = GetFileState (FvDevice->ErasePolarity, FfsHeader);
//
// check for non-deleted file
//
@@ -341,18 +341,18 @@ FvCheck (
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
FfsFileEntry->FfsHeader = FfsHeader;
InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);
}
FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FfsHeader) + FileLength);
//
// Adjust pointer to the next 8-byte aligned boundry.
//
FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINTN)FfsHeader + 7) & ~0x07);
}
Done:
@@ -371,7 +371,7 @@ Done:
EFI_FIRMWARE_VOLUME2_PROTOCOL on the same handle. This is the function where
the actual initialization of the EFI_FIRMWARE_VOLUME2_PROTOCOL is done.
@param Event The event that occured
@param Event The event that occured
@param Context For EFI compatiblity. Not used.
**/
@@ -415,13 +415,13 @@ NotifyFwVolBlock (
if (EFI_ERROR (Status)) {
continue;
}
//
// Get the FirmwareVolumeBlock protocol on that handle
//
Status = CoreHandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **)&Fvb);
Status = CoreHandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **)&Fvb);
ASSERT_EFI_ERROR (Status);
//
// Make sure the Fv Header is O.K.
@@ -469,12 +469,12 @@ NotifyFwVolBlock (
if (FvDevice == NULL) {
return;
}
FvDevice->Fvb = Fvb;
FvDevice->Handle = Handle;
FvDevice->FwVolHeader = FwVolHeader;
FvDevice->Fv.ParentHandle = Fvb->ParentHandle;
//
// Install an New FV protocol on the existing handle
//
@@ -487,7 +487,7 @@ NotifyFwVolBlock (
ASSERT_EFI_ERROR (Status);
}
}
return;
}
@@ -498,8 +498,8 @@ NotifyFwVolBlock (
libraries, and registers two notification functions. These notification
functions are responsible for building the FV stack dynamically.
@param ImageHandle The image handle.
@param SystemTable The system table.
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS Function successfully returned.

View File

@@ -19,8 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter.
@param This Calling context
@param Attributes output buffer which contains attributes
@param This Calling context
@param Attributes output buffer which contains attributes
@retval EFI_SUCCESS Successfully got volume attributes
@@ -53,12 +53,12 @@ FvGetVolumeAttributes (
Status = Fvb->GetAttributes (Fvb, &FvbAttributes);
//
// Mask out Fvb bits that are not defined in FV
// Mask out Fvb bits that are not defined in FV
//
FvbAttributes &= 0xfffff0ff;
*Attributes = (EFI_FV_ATTRIBUTES)FvbAttributes;
*Attributes = (EFI_FV_ATTRIBUTES)FvbAttributes;
return Status;
}
@@ -67,9 +67,9 @@ FvGetVolumeAttributes (
/**
Sets current attributes for volume
@param This Calling context
@param Attributes At input, contains attributes to be set. At output
contains new value of FV
@param This Calling context
@param Attributes At input, contains attributes to be set. At output
contains new value of FV
@retval EFI_UNSUPPORTED Could not be set.
@@ -89,11 +89,11 @@ FvSetVolumeAttributes (
Return information of type InformationType for the requested firmware
volume.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@retval EFI_SUCCESS Successfully got volume Information.
@@ -116,11 +116,11 @@ FvGetVolumeInfo (
Set information of type InformationType for the requested firmware
volume.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
@param InformationType InformationType for requested.
@param BufferSize On input, size of Buffer.On output, the amount of data
returned in Buffer.
@param Buffer A poniter to the data buffer to return.
@retval EFI_SUCCESS Successfully set volume Information.

View File

@@ -32,14 +32,14 @@ Required Alignment Alignment Value in FFS Alignment Value in
--*/
UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
/**
Convert the FFS File Attributes to FV File Attributes
@param FfsAttributes The attributes of UINT8 type.
@param FfsAttributes The attributes of UINT8 type.
@return The attributes of EFI_FV_FILE_ATTRIBUTES
@@ -60,46 +60,46 @@ FfsAttributes2FvFileAttributes (
/**
Given the input key, search for the next matching file in the volume.
@param This Indicates the calling context.
@param Key Key is a pointer to a caller allocated
buffer that contains implementation specific
data that is used to track where to begin
the search for the next file. The size of
the buffer must be at least This->KeySize
bytes long. To reinitialize the search and
begin from the beginning of the firmware
volume, the entire buffer must be cleared to
zero. Other than clearing the buffer to
initiate a new search, the caller must not
modify the data in the buffer between calls
to GetNextFile().
@param FileType FileType is a pointer to a caller allocated
EFI_FV_FILETYPE. The GetNextFile() API can
filter it's search for files based on the
value of *FileType input. A *FileType input
of 0 causes GetNextFile() to search for
files of all types. If a file is found, the
file's type is returned in *FileType.
*FileType is not modified if no file is
found.
@param NameGuid NameGuid is a pointer to a caller allocated
EFI_GUID. If a file is found, the file's
name is returned in *NameGuid. *NameGuid is
not modified if no file is found.
@param Attributes Attributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. If a file
is found, the file's attributes are returned
in *Attributes. *Attributes is not modified
if no file is found.
@param Size Size is a pointer to a caller allocated
UINTN. If a file is found, the file's size
is returned in *Size. *Size is not modified
if no file is found.
@param This Indicates the calling context.
@param Key Key is a pointer to a caller allocated
buffer that contains implementation specific
data that is used to track where to begin
the search for the next file. The size of
the buffer must be at least This->KeySize
bytes long. To reinitialize the search and
begin from the beginning of the firmware
volume, the entire buffer must be cleared to
zero. Other than clearing the buffer to
initiate a new search, the caller must not
modify the data in the buffer between calls
to GetNextFile().
@param FileType FileType is a pointer to a caller allocated
EFI_FV_FILETYPE. The GetNextFile() API can
filter it's search for files based on the
value of *FileType input. A *FileType input
of 0 causes GetNextFile() to search for
files of all types. If a file is found, the
file's type is returned in *FileType.
*FileType is not modified if no file is
found.
@param NameGuid NameGuid is a pointer to a caller allocated
EFI_GUID. If a file is found, the file's
name is returned in *NameGuid. *NameGuid is
not modified if no file is found.
@param Attributes Attributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. If a file
is found, the file's attributes are returned
in *Attributes. *Attributes is not modified
if no file is found.
@param Size Size is a pointer to a caller allocated
UINTN. If a file is found, the file's size
is returned in *Size. *Size is not modified
if no file is found.
@retval EFI_SUCCESS Successfully find the file.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Fv could not read.
@retval EFI_NOT_FOUND No matching file found.
@retval EFI_SUCCESS Successfully find the file.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Fv could not read.
@retval EFI_NOT_FOUND No matching file found.
@retval EFI_INVALID_PARAMETER Invalid parameter
**/
@@ -194,7 +194,7 @@ FvGetNextFile (
break;
}
}
}
//
// Return FileType, NameGuid, and Attributes
@@ -222,39 +222,39 @@ FvGetNextFile (
Locates a file in the firmware volume and
copies it to the supplied buffer.
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN. On input *BufferSize indicates the
size in bytes of the memory region pointed
to by Buffer. On output, *BufferSize
contains the number of bytes required to
read the file.
@param FoundType FoundType is a pointer to a caller allocated
EFI_FV_FILETYPE that on successful return
from Read() contains the type of file read.
This output reflects the file type
irrespective of the value of the SectionType
input.
@param FileAttributes FileAttributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. On
successful return from Read(),
*FileAttributes contains the attributes of
the file read.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINTN in which the
authentication status is returned.
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN. On input *BufferSize indicates the
size in bytes of the memory region pointed
to by Buffer. On output, *BufferSize
contains the number of bytes required to
read the file.
@param FoundType FoundType is a pointer to a caller allocated
EFI_FV_FILETYPE that on successful return
from Read() contains the type of file read.
This output reflects the file type
irrespective of the value of the SectionType
input.
@param FileAttributes FileAttributes is a pointer to a caller
allocated EFI_FV_FILE_ATTRIBUTES. On
successful return from Read(),
*FileAttributes contains the attributes of
the file read.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINTN in which the
authentication status is returned.
@retval EFI_SUCCESS Successfully read to memory buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_SUCCESS Successfully read to memory buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
**/
@@ -279,13 +279,13 @@ FvReadFile (
UINT8 *SrcPtr;
EFI_FFS_FILE_HEADER *FfsHeader;
UINTN InputBufferSize;
if (NameGuid == NULL) {
return EFI_INVALID_PARAMETER;
}
FvDevice = FV_DEVICE_FROM_THIS (This);
//
// Keep looking until we find the matching NameGuid.
@@ -349,13 +349,13 @@ FvReadFile (
} else if (FileSize > InputBufferSize) {
//
// Callers buffer was not big enough
//
//
Status = EFI_WARN_BUFFER_TOO_SMALL;
FileSize = InputBufferSize;
}
//
// Copy data into callers buffer
// Copy data into callers buffer
//
CopyMem (*Buffer, SrcPtr, FileSize);
@@ -368,27 +368,27 @@ FvReadFile (
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param SectionType Indicates the section type to return.
@param SectionInstance Indicates which instance of sections with a
type of SectionType to return.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
@param This Indicates the calling context.
@param NameGuid Pointer to an EFI_GUID, which is the
filename.
@param SectionType Indicates the section type to return.
@param SectionInstance Indicates which instance of sections with a
type of SectionType to return.
@param Buffer Buffer is a pointer to pointer to a buffer
in which the file or section contents or are
returned.
@param BufferSize BufferSize is a pointer to caller allocated
UINTN.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINT32 in which the
authentication status is returned.
@param AuthenticationStatus AuthenticationStatus is a pointer to a
caller allocated UINT32 in which the
authentication status is returned.
@retval EFI_SUCCESS Successfully read the file section into
buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Section not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_SUCCESS Successfully read the file section into
buffer.
@retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
@retval EFI_NOT_FOUND Section not found.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_ACCESS_DENIED Could not read.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
@@ -411,7 +411,7 @@ FvReadFileSection (
UINTN FileSize;
UINT8 *FileBuffer;
FFS_FILE_LIST_ENTRY *FfsEntry;
if (NameGuid == NULL || Buffer == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -430,16 +430,16 @@ FvReadFileSection (
&FileType,
&FileAttributes,
AuthenticationStatus
);
);
//
// Get the last key used by our call to FvReadFile as it is the FfsEntry for this file.
//
//
FfsEntry = (FFS_FILE_LIST_ENTRY *) FvDevice->LastKey;
if (EFI_ERROR (Status)) {
return Status;
}
//
// Check to see that the file actually HAS sections before we go any further.
//

View File

@@ -19,21 +19,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
Writes one or more files to the firmware volume.
@param This Indicates the calling context.
@param NumberOfFiles Number of files.
@param WritePolicy WritePolicy indicates the level of reliability
for the write in the event of a power failure or
other system failure during the write operation.
@param FileData FileData is an pointer to an array of
@param This Indicates the calling context.
@param NumberOfFiles Number of files.
@param WritePolicy WritePolicy indicates the level of reliability
for the write in the event of a power failure or
other system failure during the write operation.
@param FileData FileData is an pointer to an array of
EFI_FV_WRITE_DATA. Each element of array
FileData represents a file to be written.
FileData represents a file to be written.
@retval EFI_SUCCESS Files successfully written to firmware volume
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_WRITE_PROTECTED Write protected.
@retval EFI_NOT_FOUND Not found.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_SUCCESS Files successfully written to firmware volume
@retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
@retval EFI_DEVICE_ERROR Device error.
@retval EFI_WRITE_PROTECTED Write protected.
@retval EFI_NOT_FOUND Not found.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_UNSUPPORTED This function not supported.
**/
@@ -45,7 +45,7 @@ FvWriteFile (
IN EFI_FV_WRITE_POLICY WritePolicy,
IN EFI_FV_WRITE_FILE_DATA *FileData
)
{
{
return EFI_UNSUPPORTED;
}