2 MDE PI library functions and macros
4 Copyright (c) 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Pi/PiFirmwareFile.h>
22 Allocate and fill a buffer from the Firmware Section identified by a Firmware File GUID name and a Firmware
23 Section type and instance number from any Firmware Volumes in the system.
25 The function will read the first Firmware Section sepcifed by NameGuid, SectionType and Instance by searching
26 for all Firmware Volumes in the system.
28 The search order for Firmware Volumes in the system is determistic but abitrary if no new Firmware Volume is installed
29 into the system. The search order for the section specified by SectionType within a Firmware File is defined by
30 EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization
31 Shared Architectural Elements for detailes.
33 If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section
34 data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to
35 read Firmware Section data from the Firmware File. If no such section specified is found to match ,
36 EFI_NOT_FOUND is returned.
38 The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
39 by this function. This function can only be called at TPL_NOTIFY and below.
41 If NameGuid is NULL, then ASSERT();
42 If Buffer is NULL, then ASSERT();
43 If Size is NULL, then ASSERT().
45 @param NameGuid The GUID name of a Firmware File.
46 @param SectionType The Firmware Section type.
47 @param Instance The instance number of Firmware Section to read from starting from 0.
48 @param Buffer On output, Buffer contains the the data read from the section in the Firmware File found.
49 @param Size On output, the size of Buffer.
51 @retval EFI_SUCCESS The image is found and data and size is returned.
52 @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.
53 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.
54 @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.
55 @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.
61 PiLibGetSectionFromAnyFv (
62 IN CONST EFI_GUID
*NameGuid
,
63 IN EFI_SECTION_TYPE SectionType
,
71 Allocate and fill a buffer from a Firmware Section identified by a Firmware File GUID name, a Firmware
72 Section type and instance number from the same Firmware Volume with the caller's FFS.
74 This functions first locates the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance for same Firmrware Volume
75 which also contains the FFS of the caller in order to carry out the Firmware Volume read operation.
76 The function then reads the Firmware Section found sepcifed by NameGuid, SectionType and Instance.
78 The search order for the section specified by SectionType within a Firmware File is defined by
79 EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection (). Please check Section 2.4 of Volume 3: Platform Initialization
80 Shared Architectural Elements for detailes.
82 If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section
83 data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to
84 read Firmware Section data from the Firmware File. If no such section specified is found to match ,
85 EFI_NOT_FOUND is returned.
87 The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
88 by this function. This function can be only called at TPL_NOTIFY and below.
90 If FvHandle is NULL, then ASSERT ();
91 If NameGuid is NULL, then ASSERT();
92 If Buffer is NULL, then ASSERT();
93 If Size is NULL, then ASSERT().
95 @param NameGuid The GUID name of a Firmware File.
96 @param SectionType The Firmware Section type.
97 @param Instance The instance number of Firmware Section to read from starting from 0.
98 @param Buffer On output, Buffer contains the the data read from the section in the Firmware File found.
99 @param Size On output, the size of Buffer.
101 @retval EFI_SUCCESS The image is found and data and size is returned.
102 @retval EFI_UNSUPPORTED FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.
103 @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.
104 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.
105 @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.
106 @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.
112 PiLibGetSectionFromCurrentFv (
113 IN CONST EFI_GUID
*NameGuid
,
114 IN EFI_SECTION_TYPE SectionType
,
123 Allocate and fill a buffer from the first Firmware Section in the same Firmware File as the caller of this function.
125 The function will read the first Firmware Section found sepcifed by NameGuid and SectionType from the
126 Firmware Volume specified by FvHandle. On this FvHandle, an EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance
127 should be located succesfully in order to carry out the Firmware Volume operations.
129 The search order for the section type specified by SectionType in the Firmware File is using a depth-first
130 and left-to-right algorithm through all sections. The first section found to match SectionType will be returned.
132 If SectionType is EFI_SECTION_PE32, EFI_SECTION_PE32 will be used as Firmware Section type
133 to read Firmware Section data from the Firmware File. If no such section exists, the function will try
134 to read a Firmware File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.
136 If SectionType is EFI_SECTION_TE, EFI_SECTION_TE will be used as Firmware Section type to read Firmware Section
137 data from the Firmware File. If no such section exists, EFI_SECTION_PE32 will be used as Firmware Section type to
138 read Firmware Section data from the Firmware File. If no such section exists, the function will try to read a Firmware
139 File named with NameGuid. If no such file exists, EFI_NOT_FOUND is returned.
141 The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
142 by this function. This function can only be called at TPL_NOTIFY and below.
144 If FvHandle is NULL and WithinImage is TRUE, then ASSERT ();
145 If NameGuid is NULL, then ASSERT();
146 If Buffer is NULL, then ASSERT();
147 If Size is NULL, then ASSERT().
149 @param NameGuid The GUID name of a Firmware File.
150 @param SectionType The Firmware Section type.
151 @param Buffer On output, Buffer contains the the data read from the section in the Firmware File found.
152 @param Size On output, the size of Buffer.
154 @retval EFI_SUCCESS The image is found and data and size is returned.
155 @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.
156 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.
157 @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.
158 @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.
164 PiLibGetSectionFromCurrentFfs (
165 IN EFI_SECTION_TYPE SectionType
,