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 Locates a requested firmware section within a file and returns it to a buffer allocated by this function.
24 PiLibGetSectionFromAnyFv () is used to read a specific section from a file within a firmware volume. The function
25 will search the first file with the specified name in all firmware volumes in the system. The search order for firmware
26 volumes in the system is determistic but abitrary if no new firmware volume is added into the system between
27 each calls of this function.
29 After the specific file is located, the function searches the specifc firmware section with type SectionType in this file.
30 The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection ()
31 found in PI Specification.
33 If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section
34 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
37 The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
38 by this function. This function can only be called at TPL_NOTIFY and below.
40 If NameGuid is NULL, then ASSERT();
41 If Buffer is NULL, then ASSERT();
42 If Size is NULL, then ASSERT().
44 @param NameGuid Pointer to an EFI_GUID, which indicates the file name from which the requested
45 section will be read. Type EFI_GUID is defined in
46 InstallProtocolInterface() in the UEFI 2.0 specification.
47 @param SectionType Indicates the section type to return. SectionType in conjunction with
48 SectionInstance indicates which section to return. Type
49 EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.
50 @param SectionInstance Indicates which instance of sections with a type of SectionType to return.
51 SectionType in conjunction with SectionInstance indicates which section to
52 return. SectionInstance is zero based.
53 @param Buffer Pointer to a pointer to a buffer in which the section contents are returned, not
54 including the section header. Caller is responsible to free this memory.
55 @param Size Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by
58 @retval EFI_SUCCESS The image is found and data and size is returned.
59 @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.
60 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.
61 @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.
62 @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.
67 PiLibGetSectionFromAnyFv (
68 IN CONST EFI_GUID
*NameGuid
,
69 IN EFI_SECTION_TYPE SectionType
,
70 IN UINTN SectionInstance
,
77 Locates a requested firmware section within a file and returns it to a buffer allocated by this function.
79 PiLibGetSectionFromCurrentFv () is used to read a specific section from a file within the same firmware volume from which
80 the running image is loaded. If the specific file is found, the function searches the specifc firmware section with type SectionType.
81 The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection ()
82 found in PI Specification.
84 If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section
85 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
88 The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
89 by this function. This function can be only called at TPL_NOTIFY and below.
91 If NameGuid is NULL, then ASSERT();
92 If Buffer is NULL, then ASSERT();
93 If Size is NULL, then ASSERT().
95 @param NameGuid Pointer to an EFI_GUID, which indicates the file name from which the requested
96 section will be read. Type EFI_GUID is defined in
97 InstallProtocolInterface() in the UEFI 2.0 specification.
98 @param SectionType Indicates the section type to return. SectionType in conjunction with
99 SectionInstance indicates which section to return. Type
100 EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.
101 @param SectionInstance Indicates which instance of sections with a type of SectionType to return.
102 SectionType in conjunction with SectionInstance indicates which section to
103 return. SectionInstance is zero based.
104 @param Buffer Pointer to a pointer to a buffer in which the section contents are returned, not
105 including the section header. Caller is responsible to free this memory.
106 @param Size Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by
110 @retval EFI_SUCCESS The image is found and data and size is returned.
111 @retval EFI_UNSUPPORTED FvHandle does not support EFI_FIRMWARE_VOLUME2_PROTOCOL.
112 @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.
113 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.
114 @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.
115 @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.
120 PiLibGetSectionFromCurrentFv (
121 IN CONST EFI_GUID
*NameGuid
,
122 IN EFI_SECTION_TYPE SectionType
,
123 IN UINTN SectionInstance
,
131 Locates a requested firmware section within a file and returns it to a buffer allocated by this function.
133 PiLibGetSectionFromCurrentFfs () searches the specifc firmware section with type SectionType in the same firmware file from
134 which the running image is loaded. The details of this search order is defined in description of
135 EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection () found in PI Specification.
137 If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section
138 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
142 The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
143 by this function. This function can only be called at TPL_NOTIFY and below.
145 If Buffer is NULL, then ASSERT();
146 If Size is NULL, then ASSERT().
148 @param SectionType Indicates the section type to return. SectionType in conjunction with
149 SectionInstance indicates which section to return. Type
150 EFI_SECTION_TYPE is defined in EFI_COMMON_SECTION_HEADER.
151 @param SectionInstance Indicates which instance of sections with a type of SectionType to return.
152 SectionType in conjunction with SectionInstance indicates which section to
153 return. SectionInstance is zero based.
154 @param Buffer Pointer to a pointer to a buffer in which the section contents are returned, not
155 including the section header. Caller is responsible to free this memory.
156 @param Size Pointer to a caller-allocated UINTN. It indicates the size of the memory represented by
159 @retval EFI_SUCCESS The image is found and data and size is returned.
160 @retval EFI_NOT_FOUND The image specified by NameGuid and SectionType can't be found.
161 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the output data buffer or complete the operations.
162 @retval EFI_DEVICE_ERROR A hardware error occurs during reading from the Firmware Volume.
163 @retval EFI_ACCESS_DENIED The firmware volume containing the searched Firmware File is configured to disallow reads.
168 PiLibGetSectionFromCurrentFfs (
169 IN EFI_SECTION_TYPE SectionType
,
170 IN UINTN SectionInstance
,