]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/PiLib.h
Merge branch of PI tree to main trunk
[mirror_edk2.git] / MdePkg / Include / Library / PiLib.h
index d15a712678067981bccf443ed63998fb76b10f16..8aaad25058b1422dbbbb615868559778ca759d64 100644 (file)
@@ -75,6 +75,233 @@ GetSectionFromFvFile (
   )\r
 ;\r
 \r
+/**\r
+  Identify the device handle from which the Image is loaded from. As this device handle is passed to\r
+  GetSectionFromFv as the identifier for a Firmware Volume, an EFI_FIRMWARE_VOLUME2_PROTOCOL \r
+  protocol instance should be located succesfully by calling gBS->HandleProtocol ().\r
+\r
+  This function locates the EFI_LOADED_IMAGE_PROTOCOL instance installed\r
+  on ImageHandle. It then returns EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle.\r
+  \r
+  If ImageHandle is NULL, then ASSERT ();\r
+  If failed to locate a EFI_LOADED_IMAGE_PROTOCOL on ImageHandle, then ASSERT ();\r
+  \r
+  @param  ImageHandle         The firmware allocated handle for UEFI image.\r
+\r
+  @retval  EFI_HANDLE          The device handle from which the Image is loaded from.\r
+\r
+**/\r
+\r
+EFI_HANDLE\r
+EFIAPI\r
+ImageHandleToFvHandle (\r
+  EFI_HANDLE ImageHandle\r
+  )\r
+;\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 the any Firmware Volumes in the system.\r
+  \r
+    The function will read the first Firmware Section found sepcifed by NameGuid and SectionType from the \r
+    any Firmware Volume 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
+  **/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetSectionFromAnyFv (\r
+  IN  CONST EFI_GUID                *NameGuid,\r
+  IN  EFI_SECTION_TYPE              SectionType,\r
+  IN  UINTN                         Instance,\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 specified Firmware Volume.\r
+  \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
+    \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  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  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
+  \r
+  **/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetSectionFromFv (\r
+  IN  EFI_HANDLE                    FvHandle,\r
+  IN  CONST EFI_GUID                *NameGuid,\r
+  IN  EFI_SECTION_TYPE              SectionType,\r
+  IN  UINTN                         Instance,\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
+  \r
+  **/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetSectionFromCurrentFv (\r
+  IN  CONST EFI_GUID                *NameGuid,\r
+  IN  EFI_SECTION_TYPE              SectionType,\r
+  IN  UINTN                         Instance,\r
+  OUT VOID                          **Buffer,\r
+  OUT UINTN                         *Size\r
+  )\r
+;\r
+\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
+  \r
+  **/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetSectionFromCurrentFfs (\r
+  IN  EFI_SECTION_TYPE              SectionType,\r
+  IN  UINTN                         Instance,\r
+  OUT VOID                          **Buffer,\r
+  OUT UINTN                         *Size\r
+  )\r
+;\r
 \r
 #endif\r
 \r