]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1) Update comments for API in DxePiLib.h
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Aug 2008 09:09:24 +0000 (09:09 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Aug 2008 09:09:24 +0000 (09:09 +0000)
2) Fix a bug that SectionInstance is not referenced in the function GetSectionFromFv
3) Some minor cleanup.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5711 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/DxePiLib.h
MdePkg/Library/DxePiLib/DxePiLib.c

index 16ede8147e967a2a2a48ade76a10d866f0e3279e..dd80da7a26f5ce7e62ddac8ec46ca162d54aa0d8 100644 (file)
 \r
 \r
 /**\r
-    Allocate and fill a buffer from the Firmware Section identified by a Firmware File GUID name and a Firmware \r
-    Section type and instance number from any Firmware Volumes in the system.\r
-  \r
-    The function will read the first Firmware Section sepcifed by NameGuid, SectionType and Instance by searching\r
-    for all Firmware Volumes in the system. \r
-\r
-    The search order for Firmware Volumes in the system is determistic but abitrary if no new Firmware Volume is installed\r
-    into the system. The search order for the section specified by SectionType within a Firmware File is defined by\r
-    EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r
-    Shared Architectural Elements for detailes.\r
-    \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section specified is found to match , \r
-    EFI_NOT_FOUND is returned.\r
-\r
-    The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
-    by this function. This function can only be called at TPL_NOTIFY and below.\r
-    \r
-    If NameGuid is NULL, then ASSERT();\r
-    If Buffer is NULL, then ASSERT();\r
-    If Size is NULL, then ASSERT().\r
-  \r
-    @param  NameGuid             The GUID name of a Firmware File.\r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Instance              The instance number of Firmware Section to read from starting from 0.\r
-    @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
-    @param  Size                    On output, the size of Buffer.\r
-  \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
-  \r
+  Locates a requested firmware section within a file and returns it to a buffer allocated by this function. \r
+\r
+  PiLibGetSectionFromAnyFv () is used to read a specific section from a file within a firmware volume. The function\r
+  will search the first file with the specified name in all firmware volumes in the system. The search order for firmware \r
+  volumes in the system is determistic but abitrary if no new firmware volume is added into the system between \r
+  each calls of this function. \r
+\r
+  After the specific file is located, the function searches the specifc firmware section with type SectionType in this file. \r
+  The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () \r
+  found in PI Specification.\r
+\r
+  If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+  is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+  is returned.\r
+\r
+  The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
+  by this function. This function can only be called at TPL_NOTIFY and below.\r
+\r
+  If NameGuid is NULL, then ASSERT();\r
+  If Buffer is NULL, then ASSERT();\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  NameGuid             Pointer to an EFI_GUID, which indicates the file name from which the requested \r
+                               section will be read. Type EFI_GUID is defined in \r
+                               InstallProtocolInterface() in the UEFI 2.0 specification. \r
+  @param  SectionType          Indicates the section type to return. SectionType in conjunction with \r
+                               SectionInstance indicates which section to return. Type \r
+                               EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.\r
+  @param  SectionInstance      Indicates which instance of sections with a type of SectionType to return. \r
+                               SectionType in conjunction with SectionInstance indicates which section to \r
+                               return. SectionInstance is zero based.\r
+  @param  Buffer               Pointer to a pointer to a buffer in which the section contents are returned, not \r
+                               including the section header. Caller is responsible to free this memory.\r
+  @param  Size                 Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by \r
+                               *Buffer.\r
+\r
+  @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
+  @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
+  @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
+  @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
+  @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PiLibGetSectionFromAnyFv (\r
   IN  CONST EFI_GUID                *NameGuid,\r
   IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         Instance,\r
+  IN  UINTN                         SectionInstance,\r
   OUT VOID                          **Buffer,\r
   OUT UINTN                         *Size\r
   )\r
 ;\r
 \r
 /**\r
-    Allocate and fill a buffer from a Firmware Section identified by a Firmware File GUID name, a Firmware \r
-    Section type and instance number from the same Firmware Volume with the caller's FFS.\r
-  \r
-    This functions first locates the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance for same Firmrware Volume\r
-    which also contains the FFS of the caller in order to carry out the Firmware Volume read operation. \r
-    The function then reads the Firmware Section found sepcifed by NameGuid, SectionType and Instance. \r
-    \r
-    The search order for the section specified by SectionType within a Firmware File is defined by\r
-    EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r
-    Shared Architectural Elements for detailes.\r
-    \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section specified is found to match , \r
-    EFI_NOT_FOUND is returned.\r
-    \r
-    The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
-    by this function. This function can be only called at TPL_NOTIFY and below.\r
-    \r
-    If FvHandle is NULL, then ASSERT ();\r
-    If NameGuid is NULL, then ASSERT();\r
-    If Buffer is NULL, then ASSERT();\r
-    If Size is NULL, then ASSERT().\r
-\r
-    @param  NameGuid             The GUID name of a Firmware File.\r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Instance              The instance number of Firmware Section to read from starting from 0.\r
-    @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
-    @param  Size                    On output, the size of Buffer.\r
-  \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_UNSUPPORTED   FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
+  Locates a requested firmware section within a file and returns it to a buffer allocated by this function. \r
+\r
+  PiLibGetSectionFromCurrentFv () is used to read a specific section from a file within the same firmware volume from which\r
+  the running image is loaded. If the specific file is found, the function searches the specifc firmware section with type SectionType. \r
+  The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () \r
+  found in PI Specification.\r
+\r
+  If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+  is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+  is returned.\r
+\r
+  The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
+  by this function. This function can be only called at TPL_NOTIFY and below.\r
+\r
+  If NameGuid is NULL, then ASSERT();\r
+  If Buffer is NULL, then ASSERT();\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  NameGuid             Pointer to an EFI_GUID, which indicates the file name from which the requested \r
+                               section will be read. Type EFI_GUID is defined in \r
+                               InstallProtocolInterface() in the UEFI 2.0 specification. \r
+  @param  SectionType          Indicates the section type to return. SectionType in conjunction with \r
+                               SectionInstance indicates which section to return. Type \r
+                               EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.\r
+  @param  SectionInstance      Indicates which instance of sections with a type of SectionType to return. \r
+                               SectionType in conjunction with SectionInstance indicates which section to \r
+                               return. SectionInstance is zero based.\r
+  @param  Buffer               Pointer to a pointer to a buffer in which the section contents are returned, not \r
+                               including the section header. Caller is responsible to free this memory.\r
+  @param  Size                 Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by \r
+                               *Buffer.\r
+\r
+\r
+  @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
+  @retval  EFI_UNSUPPORTED   FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
+  @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
+  @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
+  @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
+  @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
   \r
 **/\r
 EFI_STATUS\r
@@ -110,7 +120,7 @@ EFIAPI
 PiLibGetSectionFromCurrentFv (\r
   IN  CONST EFI_GUID                *NameGuid,\r
   IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         Instance,\r
+  IN  UINTN                         SectionInstance,\r
   OUT VOID                          **Buffer,\r
   OUT UINTN                         *Size\r
   )\r
@@ -118,47 +128,46 @@ PiLibGetSectionFromCurrentFv (
 \r
 \r
 /**\r
-    Allocate and fill a buffer from the first Firmware Section in the same Firmware File as the caller of this function.\r
-  \r
-    The function will read the first Firmware Section found sepcifed by NameGuid and SectionType from the \r
-    Firmware Volume specified by FvHandle. On this FvHandle, an EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance \r
-    should be located succesfully in order to carry out the Firmware Volume operations.\r
-    \r
-    The search order for the section type specified by SectionType in the Firmware File is using a depth-first \r
-    and left-to-right algorithm through all sections. The first section found to match SectionType will be returned. \r
-    \r
-    If SectionType is EFI_SECTION_PE32, EFI_SECTION_PE32 will be used as Firmware Section type \r
-    to read Firmware Section data from the Firmware File. If no such section exists, the function will try \r
-    to read a Firmware File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.\r
-    \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section exists, the function will try to read a Firmware \r
-    File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.\r
-    \r
-    The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
-    by this function. This function can only be called at TPL_NOTIFY and below.\r
-    \r
-    If Buffer is NULL, then ASSERT();\r
-    If Size is NULL, then ASSERT().\r
-  \r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Instance            Instance number of a section.\r
-    @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
-    @param  Size                    On output, the size of Buffer.\r
-  \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
+  Locates a requested firmware section within a file and returns it to a buffer allocated by this function. \r
+\r
+  PiLibGetSectionFromCurrentFfs () searches the specifc firmware section with type SectionType in the same firmware file from\r
+  which the running image is loaded. The details of this search order is defined in description of \r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () found in PI Specification.\r
+\r
+  If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+  is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+  is returned.\r
+\r
+\r
+  The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
+  by this function. This function can only be called at TPL_NOTIFY and below.\r
+\r
+  If Buffer is NULL, then ASSERT();\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  SectionType          Indicates the section type to return. SectionType in conjunction with \r
+                               SectionInstance indicates which section to return. Type \r
+                               EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.\r
+  @param  SectionInstance      Indicates which instance of sections with a type of SectionType to return. \r
+                               SectionType in conjunction with SectionInstance indicates which section to \r
+                               return. SectionInstance is zero based.\r
+  @param  Buffer               Pointer to a pointer to a buffer in which the section contents are returned, not \r
+                               including the section header. Caller is responsible to free this memory.\r
+  @param  Size                 Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by \r
+                               *Buffer.\r
+\r
+  @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
+  @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
+  @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
+  @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
+  @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
   \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PiLibGetSectionFromCurrentFfs (\r
   IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         Instance,\r
+  IN  UINTN                         SectionInstance,\r
   OUT VOID                          **Buffer,\r
   OUT UINTN                         *Size\r
   )\r
index 9953095e7dc9632b3088f04e9935116ce4c4d70e..b192028880a79e2c3c9566c2a18ce4b451ae6f34 100644 (file)
@@ -65,16 +65,14 @@ InternalImageHandleToFvHandle (
   \r
     This functions first locate the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance on FvHandle in order to \r
     carry out the Firmware Volume read operation. The function then reads the Firmware Section found sepcifed \r
-    by NameGuid, SectionType and Instance. \r
+    by NameGuid, SectionType and SectionInstance. \r
     \r
-    The search order for the section specified by SectionType within a Firmware File is defined by\r
-    EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r
-    Shared Architectural Elements for detailes.\r
+    The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () \r
+    found in PI Specification.\r
     \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section specified is found to match , \r
-    EFI_NOT_FOUND is returned.\r
+    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+    is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+    is returned.\r
     \r
     The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
     by this function. This function can be only called at TPL_NOTIFY and below.\r
@@ -84,19 +82,19 @@ InternalImageHandleToFvHandle (
     If Buffer is NULL, then ASSERT();\r
     If Size is NULL, then ASSERT().\r
 \r
-    @param  FvHandle              The device handle that contains a instance of EFI_FIRMWARE_VOLUME2_PROTOCOL instance.\r
-    @param  NameGuid             The GUID name of a Firmware File.\r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Instance              The instance number of Firmware Section to read from starting from 0.\r
+    @param  FvHandle                The device handle that contains a instance of EFI_FIRMWARE_VOLUME2_PROTOCOL instance.\r
+    @param  NameGuid                The GUID name of a Firmware File.\r
+    @param  SectionType             The Firmware Section type.\r
+    @param  SectionInstance         The instance number of Firmware Section to read from starting from 0.\r
     @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
     @param  Size                    On output, the size of Buffer.\r
   \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_UNSUPPORTED   FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
+    @retval  EFI_SUCCESS            The image is found and data and size is returned.\r
+    @retval  EFI_UNSUPPORTED        FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
+    @retval  EFI_NOT_FOUND          The image specified by NameGuid and SectionType can't be found.\r
+    @retval  EFI_OUT_OF_RESOURCES   There were not enough resources to allocate the output data buffer or complete the operations.\r
+    @retval  EFI_DEVICE_ERROR       A hardware error occurs during reading from the Firmware Volume.\r
+    @retval  EFI_ACCESS_DENIED      The firmware volume containing the searched Firmware File is configured to disallow reads.\r
   \r
 **/\r
 EFI_STATUS\r
@@ -104,7 +102,7 @@ GetSectionFromFv (
   IN  EFI_HANDLE                    FvHandle,\r
   IN  CONST EFI_GUID                *NameGuid,\r
   IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         Instance,\r
+  IN  UINTN                         SectionInstance,\r
   OUT VOID                          **Buffer,\r
   OUT UINTN                         *Size\r
   )\r
@@ -133,7 +131,7 @@ GetSectionFromFv (
                       Fv,\r
                       NameGuid,\r
                       SectionType,\r
-                      0,\r
+                      SectionInstance,\r
                       Buffer,\r
                       Size,\r
                       &AuthenticationStatus\r
@@ -149,7 +147,7 @@ GetSectionFromFv (
                     Fv,\r
                     NameGuid,\r
                     EFI_SECTION_PE32,\r
-                    0,\r
+                    SectionInstance,\r
                     Buffer,\r
                     Size,\r
                     &AuthenticationStatus\r
@@ -162,48 +160,55 @@ GetSectionFromFv (
 \r
 \r
 /**\r
-    Allocate and fill a buffer from the Firmware Section identified by a Firmware File GUID name and a Firmware \r
-    Section type and instance number from any Firmware Volumes in the system.\r
-  \r
-    The function will read the first Firmware Section sepcifed by NameGuid, SectionType and Instance by searching\r
-    for all Firmware Volumes in the system. \r
-\r
-    The search order for Firmware Volumes in the system is determistic but abitrary if no new Firmware Volume is installed\r
-    into the system. The search order for the section specified by SectionType within a Firmware File is defined by\r
-    EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r
-    Shared Architectural Elements for detailes.\r
-    \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section specified is found to match , \r
-    EFI_NOT_FOUND is returned.\r
+  Locates a requested firmware section within a file and returns it to a buffer allocated by this function. \r
+\r
+  PiLibGetSectionFromAnyFv () is used to read a specific section from a file within a firmware volume. The function\r
+  will search the first file with the specified name in all firmware volumes in the system. The search order for firmware \r
+  volumes in the system is determistic but abitrary if no new firmware volume is added into the system between \r
+  each calls of this function. \r
+\r
+  After the specific file is located, the function searches the specifc firmware section with type SectionType in this file. \r
+  The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () \r
+  found in PI Specification.\r
+\r
+  If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+  is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+  is returned.\r
+\r
+  The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
+  by this function. This function can only be called at TPL_NOTIFY and below.\r
+\r
+  If NameGuid is NULL, then ASSERT();\r
+  If Buffer is NULL, then ASSERT();\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  NameGuid             Pointer to an EFI_GUID, which indicates the file name from which the requested \r
+                               section will be read. Type EFI_GUID is defined in \r
+                               InstallProtocolInterface() in the UEFI 2.0 specification. \r
+  @param  SectionType          Indicates the section type to return. SectionType in conjunction with \r
+                               SectionInstance indicates which section to return. Type \r
+                               EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.\r
+  @param  SectionInstance      Indicates which instance of sections with a type of SectionType to return. \r
+                               SectionType in conjunction with SectionInstance indicates which section to \r
+                               return. SectionInstance is zero based.\r
+  @param  Buffer               Pointer to a pointer to a buffer in which the section contents are returned, not \r
+                               including the section header. Caller is responsible to free this memory.\r
+  @param  Size                 Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by \r
+                               *Buffer.\r
+\r
+  @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
+  @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
+  @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
+  @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
+  @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
 \r
-    The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
-    by this function. This function can only be called at TPL_NOTIFY and below.\r
-    \r
-    If NameGuid is NULL, then ASSERT();\r
-    If Buffer is NULL, then ASSERT();\r
-    If Size is NULL, then ASSERT().\r
-  \r
-    @param  NameGuid             The GUID name of a Firmware File.\r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Instance              The instance number of Firmware Section to read from starting from 0.\r
-    @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
-    @param  Size                    On output, the size of Buffer.\r
-  \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
-  \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PiLibGetSectionFromAnyFv (\r
   IN CONST  EFI_GUID           *NameGuid,\r
   IN        EFI_SECTION_TYPE   SectionType,\r
-  IN        UINTN              Instance,\r
+  IN        UINTN              SectionInstance,\r
   OUT       VOID               **Buffer,\r
   OUT       UINTN              *Size\r
   )\r
@@ -213,7 +218,6 @@ PiLibGetSectionFromAnyFv (
   UINTN                         HandleCount;\r
   UINTN                         Index;\r
   EFI_HANDLE                    FvHandle;\r
-  EFI_TPL                       OldTpl;\r
 \r
   //\r
   // Search the FV that contain the caller's FFS first.\r
@@ -226,7 +230,7 @@ PiLibGetSectionFromAnyFv (
              FvHandle,\r
              NameGuid,\r
              SectionType,\r
-             Instance,\r
+             SectionInstance,\r
              Buffer,\r
              Size\r
              );\r
@@ -234,8 +238,6 @@ PiLibGetSectionFromAnyFv (
     return EFI_SUCCESS;\r
   }\r
 \r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-  \r
   HandleBuffer = NULL;\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
@@ -248,26 +250,25 @@ PiLibGetSectionFromAnyFv (
     goto Done;\r
   }\r
 \r
-  for (Index = 0; Index < HandleCount; ++Index) {\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
     //\r
     // Skip the FV that contain the caller's FFS\r
     //\r
-    if (HandleBuffer[Index] == FvHandle) {\r
-      continue;\r
+    if (HandleBuffer[Index] != FvHandle) {\r
+      Status = GetSectionFromFv (\r
+                 HandleBuffer[Index], \r
+                 NameGuid, \r
+                 SectionType, \r
+                 SectionInstance,\r
+                 Buffer, \r
+                 Size\r
+                 );\r
+\r
+      if (!EFI_ERROR (Status)) {\r
+        goto Done;\r
+      }\r
     }\r
 \r
-    Status = GetSectionFromFv (\r
-               HandleBuffer[Index], \r
-               NameGuid, \r
-               SectionType, \r
-               Instance,\r
-               Buffer, \r
-               Size\r
-               );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
   }\r
 \r
   if (Index == HandleCount) {\r
@@ -276,8 +277,6 @@ PiLibGetSectionFromAnyFv (
 \r
 Done:\r
   \r
-  gBS->RestoreTPL (OldTpl);\r
-  \r
   if (HandleBuffer != NULL) {  \r
     FreePool(HandleBuffer);\r
   }\r
@@ -286,42 +285,45 @@ Done:
 }\r
 \r
 /**\r
-    Allocate and fill a buffer from a Firmware Section identified by a Firmware File GUID name, a Firmware \r
-    Section type and instance number from the same Firmware Volume with the caller's FFS.\r
-  \r
-    This functions first locates the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance for same Firmrware Volume\r
-    which also contains the FFS of the caller in order to carry out the Firmware Volume read operation. \r
-    The function then reads the Firmware Section found sepcifed by NameGuid, SectionType and Instance. \r
-    \r
-    The search order for the section specified by SectionType within a Firmware File is defined by\r
-    EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization \r
-    Shared Architectural Elements for detailes.\r
-    \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section specified is found to match , \r
-    EFI_NOT_FOUND is returned.\r
-    \r
-    The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
-    by this function. This function can be only called at TPL_NOTIFY and below.\r
-    \r
-    If FvHandle is NULL, then ASSERT ();\r
-    If NameGuid is NULL, then ASSERT();\r
-    If Buffer is NULL, then ASSERT();\r
-    If Size is NULL, then ASSERT().\r
-\r
-    @param  NameGuid             The GUID name of a Firmware File.\r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Instance              The instance number of Firmware Section to read from starting from 0.\r
-    @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
-    @param  Size                    On output, the size of Buffer.\r
-  \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_UNSUPPORTED   FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
+  Locates a requested firmware section within a file and returns it to a buffer allocated by this function. \r
+\r
+  PiLibGetSectionFromCurrentFv () is used to read a specific section from a file within the same firmware volume from which\r
+  the running image is loaded. If the specific file is found, the function searches the specifc firmware section with type SectionType. \r
+  The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () \r
+  found in PI Specification.\r
+\r
+  If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+  is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+  is returned.\r
+\r
+  The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
+  by this function. This function can be only called at TPL_NOTIFY and below.\r
+\r
+  If NameGuid is NULL, then ASSERT();\r
+  If Buffer is NULL, then ASSERT();\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  NameGuid             Pointer to an EFI_GUID, which indicates the file name from which the requested \r
+                               section will be read. Type EFI_GUID is defined in \r
+                               InstallProtocolInterface() in the UEFI 2.0 specification. \r
+  @param  SectionType          Indicates the section type to return. SectionType in conjunction with \r
+                               SectionInstance indicates which section to return. Type \r
+                               EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.\r
+  @param  SectionInstance      Indicates which instance of sections with a type of SectionType to return. \r
+                               SectionType in conjunction with SectionInstance indicates which section to \r
+                               return. SectionInstance is zero based.\r
+  @param  Buffer               Pointer to a pointer to a buffer in which the section contents are returned, not \r
+                               including the section header. Caller is responsible to free this memory.\r
+  @param  Size                 Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by \r
+                               *Buffer.\r
+\r
+\r
+  @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
+  @retval  EFI_UNSUPPORTED   FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.\r
+  @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
+  @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
+  @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
+  @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
   \r
 **/\r
 EFI_STATUS\r
@@ -329,7 +331,7 @@ EFIAPI
 PiLibGetSectionFromCurrentFv (\r
   IN  CONST EFI_GUID                *NameGuid,\r
   IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         Instance,\r
+  IN  UINTN                         SectionInstance,\r
   OUT VOID                          **Buffer,\r
   OUT UINTN                         *Size\r
     )\r
@@ -338,7 +340,7 @@ PiLibGetSectionFromCurrentFv (
           InternalImageHandleToFvHandle(gImageHandle),\r
           NameGuid,\r
           SectionType,\r
-          Instance,\r
+          SectionInstance,\r
           Buffer,\r
           Size\r
           );\r
@@ -346,49 +348,46 @@ PiLibGetSectionFromCurrentFv (
 \r
 \r
 /**\r
-    Allocate and fill a buffer from the first Firmware Section in the same Firmware File as the caller of this function.\r
-  \r
-    The function will read the first Firmware Section found sepcifed by NameGuid and SectionType from the \r
-    Firmware Volume specified by FvHandle. On this FvHandle, an EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance \r
-    should be located succesfully in order to carry out the Firmware Volume operations.\r
-    \r
-    The search order for the section type specified by SectionType in the Firmware File is using a depth-first \r
-    and left-to-right algorithm through all sections. The first section found to match SectionType will be returned. \r
-    \r
-    If SectionType is EFI_SECTION_PE32, EFI_SECTION_PE32 will be used as Firmware Section type \r
-    to read Firmware Section data from the Firmware File. If no such section exists, the function will try \r
-    to read a Firmware File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.\r
-    \r
-    If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section \r
-    data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to \r
-    read Firmware Section data from the Firmware File. If no such section exists, the function will try to read a Firmware \r
-    File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.\r
-    \r
-    The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
-    by this function. This function can only be called at TPL_NOTIFY and below.\r
-    \r
-    If FvHandle is NULL and WithinImage is TRUE, then ASSERT ();\r
-    If NameGuid is NULL, then ASSERT();\r
-    If Buffer is NULL, then ASSERT();\r
-    If Size is NULL, then ASSERT().\r
-  \r
-    @param  NameGuid             The GUID name of a Firmware File.\r
-    @param  SectionType         The Firmware Section type.\r
-    @param  Buffer                  On output, Buffer contains the the data read from the section in the Firmware File found.\r
-    @param  Size                    On output, the size of Buffer.\r
-  \r
-    @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
-    @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
-    @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
-    @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
-    @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
+  Locates a requested firmware section within a file and returns it to a buffer allocated by this function. \r
+\r
+  PiLibGetSectionFromCurrentFfs () searches the specifc firmware section with type SectionType in the same firmware file from\r
+  which the running image is loaded. The details of this search order is defined in description of \r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () found in PI Specification.\r
+\r
+  If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section \r
+  is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND \r
+  is returned.\r
+\r
+\r
+  The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated \r
+  by this function. This function can only be called at TPL_NOTIFY and below.\r
+\r
+  If Buffer is NULL, then ASSERT();\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  SectionType          Indicates the section type to return. SectionType in conjunction with \r
+                               SectionInstance indicates which section to return. Type \r
+                               EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.\r
+  @param  SectionInstance      Indicates which instance of sections with a type of SectionType to return. \r
+                               SectionType in conjunction with SectionInstance indicates which section to \r
+                               return. SectionInstance is zero based.\r
+  @param  Buffer               Pointer to a pointer to a buffer in which the section contents are returned, not \r
+                               including the section header. Caller is responsible to free this memory.\r
+  @param  Size                 Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by \r
+                               *Buffer.\r
+\r
+  @retval  EFI_SUCCESS        The image is found and data and size is returned.\r
+  @retval  EFI_NOT_FOUND      The image specified by NameGuid and SectionType can't be found.\r
+  @retval  EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.\r
+  @retval  EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.\r
+  @retval  EFI_ACCESS_DENIED  The firmware volume containing the searched Firmware File is configured to disallow reads.\r
   \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PiLibGetSectionFromCurrentFfs (\r
   IN  EFI_SECTION_TYPE              SectionType,\r
-  IN  UINTN                         Instance,\r
+  IN  UINTN                         SectionInstance,\r
   OUT VOID                          **Buffer,\r
   OUT UINTN                         *Size\r
     )\r
@@ -397,7 +396,7 @@ PiLibGetSectionFromCurrentFfs (
           InternalImageHandleToFvHandle(gImageHandle),\r
           &gEfiCallerIdGuid,\r
           SectionType,\r
-          Instance,\r
+          SectionInstance,\r
           Buffer,\r
           Size\r
           );\r