Coding style modification.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5058 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2
2008-04-14 03:12:57 +00:00
parent e1a09a0eaa
commit bcd7041487
61 changed files with 3405 additions and 4718 deletions

View File

@ -1,20 +1,4 @@
/**@file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
SectionExtraction.c
Abstract:
Section Extraction Protocol implementation.
Stream database is implemented as a linked list of section streams,
@ -42,7 +26,17 @@ Abstract:
3) A support protocol is not found, and the data is not available to be read
without it. This results in EFI_PROTOCOL_ERROR.
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "SectionExtraction.h"
@ -235,27 +229,23 @@ EFI_SECTION_EXTRACTION_PROTOCOL mSectionExtraction = {
CloseSectionStream
};
/**
Entry point of the section extraction code. Initializes an instance of the
section extraction interface and installs it on a new handle.
@param ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
@param SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
@retval EFI_SUCCESS Driver initialized successfully
@retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
**/
EFI_STATUS
EFIAPI
SectionExtractionEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Entry point of the section extraction code. Initializes an instance of the
section extraction interface and installs it on a new handle.
Arguments:
ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
Returns:
EFI_SUCCESS: Driver initialized successfully
EFI_OUT_OF_RESOURCES: Could not allocate needed resources
--*/
{
EFI_STATUS Status;
@ -273,6 +263,22 @@ Returns:
return Status;
}
/**
SEP member function. This function creates and returns a new section stream
handle to represent the new section stream.
@param This Indicates the calling context.
@param SectionStreamLength Size in bytes of the section stream.
@param SectionStream Buffer containing the new section stream.
@param SectionStreamHandle A pointer to a caller allocated UINTN that on output
contains the new section stream handle.
@retval EFI_SUCCESS
@retval EFI_OUT_OF_RESOURCES memory allocation failed.
@retval EFI_INVALID_PARAMETER section stream does not end concident with end of
last section.
**/
STATIC
EFI_STATUS
EFIAPI
@ -282,26 +288,6 @@ OpenSectionStream (
IN VOID *SectionStream,
OUT UINTN *SectionStreamHandle
)
/*++
Routine Description:
SEP member function. This function creates and returns a new section stream
handle to represent the new section stream.
Arguments:
This - Indicates the calling context.
SectionStreamLength - Size in bytes of the section stream.
SectionStream - Buffer containing the new section stream.
SectionStreamHandle - A pointer to a caller allocated UINTN that on output
contains the new section stream handle.
Returns:
EFI_SUCCESS
EFI_OUT_OF_RESOURCES - memory allocation failed.
EFI_INVALID_PARAMETER - section stream does not end concident with end of
last section.
--*/
{
//
// Check to see section stream looks good...
@ -319,6 +305,49 @@ Returns:
);
}
/**
SEP member function. Retrieves requested section from section stream.
@param This: Pointer to SEP instance.
@param SectionStreamHandle: The section stream from which to extract the requested
section.
@param SectionType: A pointer to the type of section to search for.
@param SectionDefinitionGuid: If the section type is EFI_SECTION_GUID_DEFINED, then
SectionDefinitionGuid indicates which of these types
of sections to search for.
@param SectionInstance: Indicates which instance of the requested section to
return.
@param Buffer: Double indirection to buffer. If *Buffer is non-null on
input, then the buffer is caller allocated. If
*Buffer is NULL, then the buffer is callee allocated.
In either case, the requried buffer size is returned
in *BufferSize.
@param BufferSize: On input, indicates the size of *Buffer if *Buffer is
non-null on input. On output, indicates the required
size (allocated size if callee allocated) of *Buffer.
@param AuthenticationStatus: Indicates the authentication status of the retrieved
section.
@retval EFI_SUCCESS: Section was retrieved successfully
@retval EFI_PROTOCOL_ERROR: A GUID defined section was encountered in the section
stream with its EFI_GUIDED_SECTION_PROCESSING_REQUIRED
bit set, but there was no corresponding GUIDed Section
Extraction Protocol in the handle database. *Buffer is
unmodified.
@retval EFI_NOT_FOUND: An error was encountered when parsing the SectionStream.
This indicates the SectionStream is not correctly
formatted.
@retval EFI_NOT_FOUND: The requested section does not exist.
@retval EFI_OUT_OF_RESOURCES: The system has insufficient resources to process the
request.
@retval EFI_INVALID_PARAMETER: The SectionStreamHandle does not exist.
@retval EFI_WARN_TOO_SMALL: The size of the caller allocated input buffer is
insufficient to contain the requested section. The
input buffer is filled and contents are section contents
are truncated.
**/
STATIC
EFI_STATUS
EFIAPI
@ -332,52 +361,7 @@ GetSection (
IN OUT UINTN *BufferSize,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
SEP member function. Retrieves requested section from section stream.
Arguments:
This: Pointer to SEP instance.
SectionStreamHandle: The section stream from which to extract the requested
section.
SectionType: A pointer to the type of section to search for.
SectionDefinitionGuid: If the section type is EFI_SECTION_GUID_DEFINED, then
SectionDefinitionGuid indicates which of these types
of sections to search for.
SectionInstance: Indicates which instance of the requested section to
return.
Buffer: Double indirection to buffer. If *Buffer is non-null on
input, then the buffer is caller allocated. If
*Buffer is NULL, then the buffer is callee allocated.
In either case, the requried buffer size is returned
in *BufferSize.
BufferSize: On input, indicates the size of *Buffer if *Buffer is
non-null on input. On output, indicates the required
size (allocated size if callee allocated) of *Buffer.
AuthenticationStatus: Indicates the authentication status of the retrieved
section.
Returns:
EFI_SUCCESS: Section was retrieved successfully
EFI_PROTOCOL_ERROR: A GUID defined section was encountered in the section
stream with its EFI_GUIDED_SECTION_PROCESSING_REQUIRED
bit set, but there was no corresponding GUIDed Section
Extraction Protocol in the handle database. *Buffer is
unmodified.
EFI_NOT_FOUND: An error was encountered when parsing the SectionStream.
This indicates the SectionStream is not correctly
formatted.
EFI_NOT_FOUND: The requested section does not exist.
EFI_OUT_OF_RESOURCES: The system has insufficient resources to process the
request.
EFI_INVALID_PARAMETER: The SectionStreamHandle does not exist.
EFI_WARN_TOO_SMALL: The size of the caller allocated input buffer is
insufficient to contain the requested section. The
input buffer is filled and contents are section contents
are truncated.
--*/
{
CORE_SECTION_STREAM_NODE *StreamNode;
EFI_TPL OldTpl;
@ -461,7 +445,18 @@ GetSection_Done:
return Status;
}
/**
SEP member function. Deletes an existing section stream
@param This - Indicates the calling context.
@param StreamHandleToClose - Indicates the stream to close
@retval EFI_SUCCESS
@retval EFI_OUT_OF_RESOURCES - memory allocation failed.
@retval EFI_INVALID_PARAMETER - section stream does not end concident with end of
last section.
**/
STATIC
EFI_STATUS
EFIAPI
@ -469,22 +464,7 @@ CloseSectionStream (
IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
IN UINTN StreamHandleToClose
)
/*++
Routine Description:
SEP member function. Deletes an existing section stream
Arguments:
This - Indicates the calling context.
StreamHandleToClose - Indicates the stream to close
Returns:
EFI_SUCCESS
EFI_OUT_OF_RESOURCES - memory allocation failed.
EFI_INVALID_PARAMETER - section stream does not end concident with end of
last section.
--*/
{
CORE_SECTION_STREAM_NODE *StreamNode;
EFI_TPL OldTpl;
@ -519,7 +499,19 @@ Returns:
return Status;
}
/**
Worker function. Determine if the input stream:child matches the input type.
@param Stream - Indicates the section stream associated with the child
@param Child - Indicates the child to check
@param SearchType - Indicates the type of section to check against for
@param SectionDefinitionGuid - Indicates the GUID to check against if the type is
EFI_SECTION_GUID_DEFINED
@retval TRUE - The child matches
@retval FALSE - The child doesn't match
**/
STATIC
BOOLEAN
ChildIsType (
@ -528,22 +520,6 @@ ChildIsType (
IN EFI_SECTION_TYPE SearchType,
IN EFI_GUID *SectionDefinitionGuid
)
/*++
Routine Description:
Worker function. Determine if the input stream:child matches the input type.
Arguments:
Stream - Indicates the section stream associated with the child
Child - Indicates the child to check
SearchType - Indicates the type of section to check against for
SectionDefinitionGuid - Indicates the GUID to check against if the type is
EFI_SECTION_GUID_DEFINED
Returns:
TRUE - The child matches
FALSE - The child doesn't match
--*/
{
EFI_GUID_DEFINED_SECTION *GuidedSection;
@ -560,7 +536,30 @@ Returns:
return CompareGuid (&GuidedSection->SectionDefinitionGuid, SectionDefinitionGuid);
}
/**
Worker function Recursively searches / builds section stream database
looking for requested section.
@param SourceStream - Indicates the section stream in which to do the search.
@param SearchType - Indicates the type of section to search for.
@param SectionInstance - Indicates which instance of section to find. This is
an in/out parameter to deal with recursions.
@param SectionDefinitionGuid - Guid of section definition
@param FoundChild - Output indicating the child node that is found.
@param FoundStream - Output indicating which section stream the child was
found in. If this stream was generated as a result of
an encapsulation section, the streamhandle is visible
within the SEP driver only.
@param AuthenticationStatus- Indicates the authentication status of the found section.
@retval EFI_SUCCESS - Child node was found and returned.
@retval EFI_OUT_OF_RESOURCES- Memory allocation failed.
@retval EFI_NOT_FOUND - Requested child node does not exist.
@retval EFI_PROTOCOL_ERROR - a required GUIDED section extraction protocol does not
exist
**/
STATIC
EFI_STATUS
FindChildNode (
@ -572,33 +571,7 @@ FindChildNode (
OUT CORE_SECTION_STREAM_NODE **FoundStream,
OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
Worker function Recursively searches / builds section stream database
looking for requested section.
Arguments:
SourceStream - Indicates the section stream in which to do the search.
SearchType - Indicates the type of section to search for.
SectionInstance - Indicates which instance of section to find. This is
an in/out parameter to deal with recursions.
SectionDefinitionGuid - Guid of section definition
FoundChild - Output indicating the child node that is found.
FoundStream - Output indicating which section stream the child was
found in. If this stream was generated as a result of
an encapsulation section, the streamhandle is visible
within the SEP driver only.
AuthenticationStatus- Indicates the authentication status of the found section.
Returns:
EFI_SUCCESS - Child node was found and returned.
EFI_OUT_OF_RESOURCES- Memory allocation failed.
EFI_NOT_FOUND - Requested child node does not exist.
EFI_PROTOCOL_ERROR - a required GUIDED section extraction protocol does not
exist
--*/
{
CORE_SECTION_CHILD_NODE *CurrentChildNode;
CORE_SECTION_CHILD_NODE *RecursedChildNode;
@ -715,7 +688,24 @@ Returns:
}
}
/**
Worker function. Constructor for new child nodes.
@param Stream - Indicates the section stream in which to add the child.
@param ChildOffset - Indicates the offset in Stream that is the beginning
of the child section.
@param ChildNode - Indicates the Callee allocated and initialized child.
@retval EFI_SUCCESS - Child node was found and returned.
@retval EFI_OUT_OF_RESOURCES- Memory allocation failed.
@retval EFI_PROTOCOL_ERROR - Encapsulation sections produce new stream handles when
the child node is created. If the section type is GUID
defined, and the extraction GUID does not exist, and
producing the stream requires the GUID, then a protocol
error is generated and no child is produced.
Values returned by OpenSectionStreamEx.
**/
STATIC
EFI_STATUS
CreateChildNode (
@ -723,28 +713,6 @@ CreateChildNode (
IN UINT32 ChildOffset,
OUT CORE_SECTION_CHILD_NODE **ChildNode
)
/*++
Routine Description:
Worker function. Constructor for new child nodes.
Arguments:
Stream - Indicates the section stream in which to add the child.
ChildOffset - Indicates the offset in Stream that is the beginning
of the child section.
ChildNode - Indicates the Callee allocated and initialized child.
Returns:
EFI_SUCCESS - Child node was found and returned.
EFI_OUT_OF_RESOURCES- Memory allocation failed.
EFI_PROTOCOL_ERROR - Encapsulation sections produce new stream handles when
the child node is created. If the section type is GUID
defined, and the extraction GUID does not exist, and
producing the stream requires the GUID, then a protocol
error is generated and no child is produced.
Values returned by OpenSectionStreamEx.
--*/
{
EFI_STATUS Status;
EFI_COMMON_SECTION_HEADER *SectionHeader;
@ -997,27 +965,20 @@ Returns:
return EFI_SUCCESS;
}
/**
Worker function. Constructor for RPN event if needed to keep AuthenticationStatus
cache correct when a missing GUIDED_SECTION_EXTRACTION_PROTOCOL appears...
@param ParentStream - Indicates the parent of the ecnapsulation section (child)
@param ChildNode - Indicates the child node that is the encapsulation section.
**/
STATIC
VOID
CreateGuidedExtractionRpnEvent (
IN CORE_SECTION_STREAM_NODE *ParentStream,
IN CORE_SECTION_CHILD_NODE *ChildNode
)
/*++
Routine Description:
Worker function. Constructor for RPN event if needed to keep AuthenticationStatus
cache correct when a missing GUIDED_SECTION_EXTRACTION_PROTOCOL appears...
Arguments:
ParentStream - Indicates the parent of the ecnapsulation section (child)
ChildNode - Indicates the child node that is the encapsulation section.
Returns:
None
--*/
{
RPN_EVENT_CONTEXT *Context;
@ -1040,7 +1001,15 @@ Returns:
);
}
/**
RPN callback function. Removes a stale section stream and re-initializes it
with an updated AuthenticationStatus.
@param Event - The event that fired
@param RpnContext - A pointer to the context that allows us to identify
the relevent encapsulation...
**/
STATIC
VOID
EFIAPI
@ -1048,21 +1017,6 @@ NotifyGuidedExtraction (
IN EFI_EVENT Event,
IN VOID *RpnContext
)
/*++
Routine Description:
RPN callback function. Removes a stale section stream and re-initializes it
with an updated AuthenticationStatus.
Arguments:
Event - The event that fired
RpnContext - A pointer to the context that allows us to identify
the relevent encapsulation...
Returns:
None
--*/
{
EFI_STATUS Status;
EFI_GUID_DEFINED_SECTION *GuidedHeader;
@ -1120,24 +1074,18 @@ Returns:
gBS->FreePool (Context);
}
/**
Worker function. Destructor for child nodes.
@param ChildNode - Indicates the node to destroy
**/
STATIC
VOID
FreeChildNode (
IN CORE_SECTION_CHILD_NODE *ChildNode
)
/*++
Routine Description:
Worker function. Destructor for child nodes.
Arguments:
ChildNode - Indicates the node to destroy
Returns:
none
--*/
{
ASSERT (ChildNode->Signature == CORE_SECTION_CHILD_SIGNATURE);
//
@ -1158,7 +1106,22 @@ Returns:
gBS->FreePool (ChildNode);
}
/**
Worker function. Constructor for section streams.
@param SectionStreamLength - Size in bytes of the section stream.
@param SectionStream - Buffer containing the new section stream.
@param AllocateBuffer - Indicates whether the stream buffer is to be copied
or the input buffer is to be used in place.
@param AuthenticationStatus- Indicates the default authentication status for the
new stream.
@param SectionStreamHandle - A pointer to a caller allocated section stream handle.
@retval EFI_SUCCESS - Stream was added to stream database.
@retval EFI_OUT_OF_RESOURCES - memory allocation failed.
**/
STATIC
EFI_STATUS
OpenSectionStreamEx (
@ -1168,25 +1131,7 @@ OpenSectionStreamEx (
IN UINT32 AuthenticationStatus,
OUT UINTN *SectionStreamHandle
)
/*++
Routine Description:
Worker function. Constructor for section streams.
Arguments:
SectionStreamLength - Size in bytes of the section stream.
SectionStream - Buffer containing the new section stream.
AllocateBuffer - Indicates whether the stream buffer is to be copied
or the input buffer is to be used in place.
AuthenticationStatus- Indicates the default authentication status for the
new stream.
SectionStreamHandle - A pointer to a caller allocated section stream handle.
Returns:
EFI_SUCCESS - Stream was added to stream database.
EFI_OUT_OF_RESOURCES - memory allocation failed.
--*/
{
CORE_SECTION_STREAM_NODE *NewStream;
EFI_TPL OldTpl;
@ -1250,28 +1195,24 @@ OpenSectionStreamEx (
return EFI_SUCCESS;
}
/**
Worker function. Search stream database for requested stream handle.
@param SearchHandle - Indicates which stream to look for.
@param FoundStream - Output pointer to the found stream.
@retval EFI_SUCCESS - StreamHandle was found and *FoundStream contains
the stream node.
@retval EFI_NOT_FOUND - SearchHandle was not found in the stream database.
**/
STATIC
EFI_STATUS
FindStreamNode (
IN UINTN SearchHandle,
OUT CORE_SECTION_STREAM_NODE **FoundStream
)
/*++
Routine Description:
Worker function. Search stream database for requested stream handle.
Arguments:
SearchHandle - Indicates which stream to look for.
FoundStream - Output pointer to the found stream.
Returns:
EFI_SUCCESS - StreamHandle was found and *FoundStream contains
the stream node.
EFI_NOT_FOUND - SearchHandle was not found in the stream database.
--*/
{
CORE_SECTION_STREAM_NODE *StreamNode;
@ -1292,27 +1233,22 @@ FindStreamNode (
return EFI_NOT_FOUND;
}
/**
Check if a stream is valid.
@param SectionStream - The section stream to be checked
@param SectionStreamLength - The length of section stream
@return if a stream is valid.
**/
STATIC
BOOLEAN
IsValidSectionStream (
IN VOID *SectionStream,
IN UINTN SectionStreamLength
)
/*++
Routine Description:
Check if a stream is valid.
Arguments:
SectionStream - The section stream to be checked
SectionStreamLength - The length of section stream
Returns:
TRUE
FALSE
--*/
{
UINTN TotalLength;
UINTN SectionLength;
@ -1348,6 +1284,25 @@ Returns:
return FALSE;
}
/**
Create a protocol notification event and return it.
@param ProtocolGuid - Protocol to register notification event on.
@param NotifyTpl - Maximum TPL to signal the NotifyFunction.
@param NotifyFuncition - EFI notification routine.
@param NotifyContext - Context passed into Event when it is created.
@param Registration - Registration key returned from RegisterProtocolNotify().
@param SignalFlag - Boolean value to decide whether kick the event after register or not.
@Return The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
is added to the system.
**/
EFI_EVENT
CoreCreateProtocolNotifyEvent (
IN EFI_GUID *ProtocolGuid,
@ -1357,32 +1312,6 @@ CoreCreateProtocolNotifyEvent (
OUT VOID **Registration,
IN BOOLEAN SignalFlag
)
/*++
Routine Description:
Create a protocol notification event and return it.
Arguments:
ProtocolGuid - Protocol to register notification event on.
NotifyTpl - Maximum TPL to signal the NotifyFunction.
NotifyFuncition - EFI notification routine.
NotifyContext - Context passed into Event when it is created.
Registration - Registration key returned from RegisterProtocolNotify().
SignalFlag - Boolean value to decide whether kick the event after register or not.
Returns:
The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
is added to the system.
--*/
{
EFI_STATUS Status;
EFI_EVENT Event;