2 MDE DXE Services Library provides functions that simplify the development of DXE Drivers.
3 These functions help access data from sections of FFS files or from file path.
5 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
7 This program and the accompanying materials are licensed and made available under
8 the terms and conditions of the BSD License that accompanies this distribution.
9 The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef __DXE_SERVICES_LIB_H__
18 #define __DXE_SERVICES_LIB_H__
21 Searches all the available firmware volumes and returns the first matching FFS section.
23 This function searches all the firmware volumes for FFS files with FV file type specified by FileType
24 The order that the firmware volumes is searched is not deterministic. For each available FV a search
25 is made for FFS file of type FileType. If the FV contains more than one FFS file with the same FileType,
26 the FileInstance instance will be the matched FFS file. For each FFS file found a search
27 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances
28 of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
29 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
30 It is the caller's responsibility to use FreePool() to free the allocated buffer.
31 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections
32 are retrieved from an FFS file based on SectionType and SectionInstance.
34 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
35 the search will be retried with a section type of EFI_SECTION_PE32.
36 This function must be called with a TPL <= TPL_NOTIFY.
38 If Buffer is NULL, then ASSERT().
39 If Size is NULL, then ASSERT().
41 @param FileType Indicates the FV file type to search for within all available FVs.
42 @param FileInstance Indicates which file instance within all available FVs specified by FileType.
43 FileInstance starts from zero.
44 @param SectionType Indicates the FFS section type to search for within the FFS file
45 specified by FileType with FileInstance.
46 @param SectionInstance Indicates which section instance within the FFS file
47 specified by FileType with FileInstance to retrieve. SectionInstance starts from zero.
48 @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.
49 Is it the caller's responsibility to free this buffer using FreePool().
50 @param Size On output, a pointer to the size, in bytes, of Buffer.
52 @retval EFI_SUCCESS The specified FFS section was returned.
53 @retval EFI_NOT_FOUND The specified FFS section could not be found.
54 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
55 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.
56 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that
57 contains the matching FFS section does not allow reads.
61 GetSectionFromAnyFvByFileType (
62 IN EFI_FV_FILETYPE FileType
,
63 IN UINTN FileInstance
,
64 IN EFI_SECTION_TYPE SectionType
,
65 IN UINTN SectionInstance
,
71 Searches all the available firmware volumes and returns the first matching FFS section.
73 This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.
74 The order in which the firmware volumes are searched is not deterministic. For each FFS file found, a search
75 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances
76 of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
77 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
78 It is the caller's responsibility to use FreePool() to free the allocated buffer.
79 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections
80 are retrieved from an FFS file based on SectionType and SectionInstance.
82 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
83 the search will be retried with a section type of EFI_SECTION_PE32.
84 This function must be called with a TPL <= TPL_NOTIFY.
86 If NameGuid is NULL, then ASSERT().
87 If Buffer is NULL, then ASSERT().
88 If Size is NULL, then ASSERT().
91 @param NameGuid A pointer to to the FFS filename GUID to search for
92 within any of the firmware volumes in the platform.
93 @param SectionType Indicates the FFS section type to search for within
94 the FFS file specified by NameGuid.
95 @param SectionInstance Indicates which section instance within the FFS file
96 specified by NameGuid to retrieve.
97 @param Buffer On output, a pointer to a callee-allocated buffer
98 containing the FFS file section that was found.
99 It is the caller's responsibility to free this
100 buffer using FreePool().
101 @param Size On output, a pointer to the size, in bytes, of Buffer.
103 @retval EFI_SUCCESS The specified FFS section was returned.
104 @retval EFI_NOT_FOUND The specified FFS section could not be found.
105 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve
106 the matching FFS section.
107 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
109 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
110 firmware volume that contains the matching FFS
111 section does not allow reads.
115 GetSectionFromAnyFv (
116 IN CONST EFI_GUID
*NameGuid
,
117 IN EFI_SECTION_TYPE SectionType
,
118 IN UINTN SectionInstance
,
124 Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section.
126 This function searches the firmware volume that the currently executing module was loaded
127 from for an FFS file with an FFS filename specified by NameGuid. If the FFS file is found, a search
128 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance
129 instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
130 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
131 It is the caller's responsibility to use FreePool() to free the allocated buffer.
132 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections are retrieved from
133 an FFS file based on SectionType and SectionInstance.
135 If the currently executing module was not loaded from a firmware volume, then EFI_NOT_FOUND is returned.
136 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
137 the search will be retried with a section type of EFI_SECTION_PE32.
139 This function must be called with a TPL <= TPL_NOTIFY.
140 If NameGuid is NULL, then ASSERT().
141 If Buffer is NULL, then ASSERT().
142 If Size is NULL, then ASSERT().
144 @param NameGuid A pointer to to the FFS filename GUID to search for
145 within the firmware volumes that the currently
146 executing module was loaded from.
147 @param SectionType Indicates the FFS section type to search for within
148 the FFS file specified by NameGuid.
149 @param SectionInstance Indicates which section instance within the FFS
150 file specified by NameGuid to retrieve.
151 @param Buffer On output, a pointer to a callee allocated buffer
152 containing the FFS file section that was found.
153 It is the caller's responsibility to free this buffer
155 @param Size On output, a pointer to the size, in bytes, of Buffer.
158 @retval EFI_SUCCESS The specified FFS section was returned.
159 @retval EFI_NOT_FOUND The specified FFS section could not be found.
160 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve
161 the matching FFS section.
162 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
164 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
165 firmware volume that contains the matching FFS
166 section does not allow reads.
171 IN CONST EFI_GUID
*NameGuid
,
172 IN EFI_SECTION_TYPE SectionType
,
173 IN UINTN SectionInstance
,
180 Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.
182 This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.
183 If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType,
184 then the SectionInstance instance is returned in Buffer. Buffer is allocated using AllocatePool(),
185 and the size of the allocated buffer is returned in Size. It is the caller's responsibility
186 to use FreePool() to free the allocated buffer. See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for
187 details on how sections are retrieved from an FFS file based on SectionType and SectionInstance.
189 If the currently executing module was not loaded from an FFS file, then EFI_NOT_FOUND is returned.
190 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
191 the search will be retried with a section type of EFI_SECTION_PE32.
192 This function must be called with a TPL <= TPL_NOTIFY.
194 If Buffer is NULL, then ASSERT().
195 If Size is NULL, then ASSERT().
198 @param SectionType Indicates the FFS section type to search for within
199 the FFS file that the currently executing module
201 @param SectionInstance Indicates which section instance to retrieve within
202 the FFS file that the currently executing module
204 @param Buffer On output, a pointer to a callee allocated buffer
205 containing the FFS file section that was found.
206 It is the caller's responsibility to free this buffer
208 @param Size On output, a pointer to the size, in bytes, of Buffer.
210 @retval EFI_SUCCESS The specified FFS section was returned.
211 @retval EFI_NOT_FOUND The specified FFS section could not be found.
212 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve
213 the matching FFS section.
214 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
216 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
217 firmware volume that contains the matching FFS
218 section does not allow reads.
224 IN EFI_SECTION_TYPE SectionType
,
225 IN UINTN SectionInstance
,
232 Get the image file buffer data and buffer size by its device path.
234 Access the file either from a firmware volume, from a file system interface,
235 or from the load file interface.
237 Allocate memory to store the found image. The caller is responsible to free memory.
239 If FilePath is NULL, then NULL is returned.
240 If FileSize is NULL, then NULL is returned.
241 If AuthenticationStatus is NULL, then NULL is returned.
243 @param[in] BootPolicy The policy for Open Image File.If TRUE,
244 indicates that the request originates from
245 the boot manager, and that the boot manager is
246 attempting to load FilePath as a boot selection.
247 If FALSE, then FilePath must match an exact
249 @param[in] FilePath Pointer to the device path of the file that is abstracted to
251 @param[out] FileSize Pointer to the size of the abstracted file buffer.
252 @param[out] AuthenticationStatus Pointer to the authentication status.
254 @retval NULL FilePath is NULL, or FileSize is NULL, or AuthenticationStatus is NULL, or the file can't be found.
255 @retval other The abstracted file buffer. The caller is responsible to free memory.
259 GetFileBufferByFilePath (
260 IN BOOLEAN BootPolicy
,
261 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
263 OUT UINT32
*AuthenticationStatus
267 Searches all the available firmware volumes and returns the file device path of first matching
270 This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.
271 The order that the firmware volumes is searched is not deterministic. For each FFS file found a search
272 is made for FFS sections of type SectionType.
274 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
275 the search will be retried with a section type of EFI_SECTION_PE32.
276 This function must be called with a TPL <= TPL_NOTIFY.
278 If NameGuid is NULL, then ASSERT().
280 @param NameGuid A pointer to to the FFS filename GUID to search for
281 within any of the firmware volumes in the platform.
282 @param SectionType Indicates the FFS section type to search for within
283 the FFS file specified by NameGuid.
284 @param SectionInstance Indicates which section instance within the FFS file
285 specified by NameGuid to retrieve.
286 @param FvFileDevicePath Device path for the target FFS
289 @retval EFI_SUCCESS The specified file device path of FFS section was returned.
290 @retval EFI_NOT_FOUND The specified file device path of FFS section could not be found.
291 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
293 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
294 firmware volume that contains the matching FFS section does not
296 @retval EFI_INVALID_PARAMETER FvFileDevicePath is NULL.
301 GetFileDevicePathFromAnyFv (
302 IN CONST EFI_GUID
*NameGuid
,
303 IN EFI_SECTION_TYPE SectionType
,
304 IN UINTN SectionInstance
,
305 OUT EFI_DEVICE_PATH_PROTOCOL
**FvFileDevicePath