]>
Commit | Line | Data |
---|---|---|
1c280088 | 1 | /** @file\r |
b75a165d | 2 | MDE DXE Services Library provides functions that simplify the development of DXE Drivers. \r |
84716614 | 3 | These functions help access data from sections of FFS files or from file path.\r |
1c280088 | 4 | \r |
3556c7a2 | 5 | Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r |
711ef3f6 | 6 | (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r |
af2dc6a7 | 7 | This program and the accompanying materials are licensed and made available under \r |
8 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
9 | The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php. \r | |
1c280088 | 11 | \r |
af2dc6a7 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
1c280088 | 14 | \r |
15 | **/\r | |
16 | \r | |
68167fed | 17 | #ifndef __DXE_SERVICES_LIB_H__\r |
18 | #define __DXE_SERVICES_LIB_H__\r | |
b0d803fe | 19 | \r |
682cee4c LG |
20 | /**\r |
21 | Searches all the available firmware volumes and returns the first matching FFS section. \r | |
22 | \r | |
23 | This function searches all the firmware volumes for FFS files with FV file type specified by FileType\r | |
24 | The order that the firmware volumes is searched is not deterministic. For each available FV a search \r | |
25 | is made for FFS file of type FileType. If the FV contains more than one FFS file with the same FileType, \r | |
26 | the FileInstance instance will be the matched FFS file. For each FFS file found a search \r | |
27 | is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances \r | |
28 | of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer. \r | |
29 | Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size. \r | |
30 | It is the caller's responsibility to use FreePool() to free the allocated buffer. \r | |
31 | See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections \r | |
32 | are retrieved from an FFS file based on SectionType and SectionInstance.\r | |
33 | \r | |
34 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails, \r | |
35 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
36 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
37 | \r | |
38 | If Buffer is NULL, then ASSERT().\r | |
39 | If Size is NULL, then ASSERT().\r | |
40 | \r | |
41 | @param FileType Indicates the FV file type to search for within all available FVs.\r | |
42 | @param FileInstance Indicates which file instance within all available FVs specified by FileType.\r | |
43 | FileInstance starts from zero.\r | |
44 | @param SectionType Indicates the FFS section type to search for within the FFS file \r | |
45 | specified by FileType with FileInstance.\r | |
46 | @param SectionInstance Indicates which section instance within the FFS file \r | |
47 | specified by FileType with FileInstance to retrieve. SectionInstance starts from zero.\r | |
48 | @param Buffer On output, a pointer to a callee allocated buffer containing the FFS file section that was found.\r | |
49 | Is it the caller's responsibility to free this buffer using FreePool().\r | |
50 | @param Size On output, a pointer to the size, in bytes, of Buffer.\r | |
51 | \r | |
52 | @retval EFI_SUCCESS The specified FFS section was returned.\r | |
53 | @retval EFI_NOT_FOUND The specified FFS section could not be found.\r | |
54 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.\r | |
55 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a device error.\r | |
56 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that \r | |
57 | contains the matching FFS section does not allow reads.\r | |
58 | **/\r | |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
61 | GetSectionFromAnyFvByFileType (\r | |
62 | IN EFI_FV_FILETYPE FileType,\r | |
63 | IN UINTN FileInstance,\r | |
64 | IN EFI_SECTION_TYPE SectionType,\r | |
65 | IN UINTN SectionInstance,\r | |
66 | OUT VOID **Buffer,\r | |
67 | OUT UINTN *Size\r | |
68 | );\r | |
69 | \r | |
b0d803fe | 70 | /**\r |
1a2f870c | 71 | Searches all the available firmware volumes and returns the first matching FFS section. \r |
b75a165d LG |
72 | \r |
73 | This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid. \r | |
1a2f870c | 74 | The order in which the firmware volumes are searched is not deterministic. For each FFS file found, a search \r |
b75a165d LG |
75 | is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances \r |
76 | of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer. \r | |
77 | Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size. \r | |
78 | It is the caller's responsibility to use FreePool() to free the allocated buffer. \r | |
79 | See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections \r | |
80 | are retrieved from an FFS file based on SectionType and SectionInstance.\r | |
81 | \r | |
82 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails, \r | |
83 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
84 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
85 | \r | |
86 | If NameGuid is NULL, then ASSERT().\r | |
87 | If Buffer is NULL, then ASSERT().\r | |
ff197efb | 88 | If Size is NULL, then ASSERT().\r |
89 | \r | |
ff197efb | 90 | \r |
af2dc6a7 | 91 | @param NameGuid A pointer to to the FFS filename GUID to search for \r |
92 | within any of the firmware volumes in the platform. \r | |
93 | @param SectionType Indicates the FFS section type to search for within \r | |
94 | the FFS file specified by NameGuid.\r | |
95 | @param SectionInstance Indicates which section instance within the FFS file \r | |
96 | specified by NameGuid to retrieve.\r | |
97 | @param Buffer On output, a pointer to a callee-allocated buffer \r | |
98 | containing the FFS file section that was found. \r | |
99 | It is the caller's responsibility to free this \r | |
100 | buffer using FreePool().\r | |
b75a165d LG |
101 | @param Size On output, a pointer to the size, in bytes, of Buffer.\r |
102 | \r | |
103 | @retval EFI_SUCCESS The specified FFS section was returned.\r | |
104 | @retval EFI_NOT_FOUND The specified FFS section could not be found.\r | |
af2dc6a7 | 105 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve \r |
106 | the matching FFS section.\r | |
107 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a \r | |
108 | device error.\r | |
109 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the \r | |
110 | firmware volume that contains the matching FFS \r | |
111 | section does not allow reads.\r | |
f80b0830 | 112 | **/\r |
b0d803fe | 113 | EFI_STATUS\r |
114 | EFIAPI\r | |
fdbee2e4 | 115 | GetSectionFromAnyFv (\r |
b0d803fe | 116 | IN CONST EFI_GUID *NameGuid,\r |
117 | IN EFI_SECTION_TYPE SectionType,\r | |
ff197efb | 118 | IN UINTN SectionInstance,\r |
b0d803fe | 119 | OUT VOID **Buffer,\r |
120 | OUT UINTN *Size\r | |
ed66e1bc | 121 | );\r |
b0d803fe | 122 | \r |
123 | /**\r | |
b75a165d LG |
124 | Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section. \r |
125 | \r | |
126 | This function searches the firmware volume that the currently executing module was loaded \r | |
1a2f870c | 127 | from for an FFS file with an FFS filename specified by NameGuid. If the FFS file is found, a search \r |
b75a165d LG |
128 | is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance \r |
129 | instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.\r | |
130 | Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size. \r | |
131 | It is the caller's responsibility to use FreePool() to free the allocated buffer. \r | |
132 | See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections are retrieved from \r | |
133 | an FFS file based on SectionType and SectionInstance.\r | |
134 | \r | |
135 | If the currently executing module was not loaded from a firmware volume, then EFI_NOT_FOUND is returned.\r | |
136 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails, \r | |
137 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
138 | \r | |
139 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
140 | If NameGuid is NULL, then ASSERT().\r | |
141 | If Buffer is NULL, then ASSERT().\r | |
ff197efb | 142 | If Size is NULL, then ASSERT().\r |
143 | \r | |
af2dc6a7 | 144 | @param NameGuid A pointer to to the FFS filename GUID to search for \r |
145 | within the firmware volumes that the currently \r | |
146 | executing module was loaded from.\r | |
147 | @param SectionType Indicates the FFS section type to search for within \r | |
148 | the FFS file specified by NameGuid.\r | |
149 | @param SectionInstance Indicates which section instance within the FFS \r | |
150 | file specified by NameGuid to retrieve.\r | |
151 | @param Buffer On output, a pointer to a callee allocated buffer \r | |
152 | containing the FFS file section that was found. \r | |
153 | It is the caller's responsibility to free this buffer \r | |
154 | using FreePool().\r | |
b75a165d LG |
155 | @param Size On output, a pointer to the size, in bytes, of Buffer.\r |
156 | \r | |
157 | \r | |
158 | @retval EFI_SUCCESS The specified FFS section was returned.\r | |
159 | @retval EFI_NOT_FOUND The specified FFS section could not be found.\r | |
af2dc6a7 | 160 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve \r |
161 | the matching FFS section.\r | |
162 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a \r | |
163 | device error.\r | |
164 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the \r | |
165 | firmware volume that contains the matching FFS \r | |
166 | section does not allow reads. \r | |
f80b0830 | 167 | **/\r |
b0d803fe | 168 | EFI_STATUS\r |
169 | EFIAPI\r | |
fdbee2e4 | 170 | GetSectionFromFv (\r |
b0d803fe | 171 | IN CONST EFI_GUID *NameGuid,\r |
172 | IN EFI_SECTION_TYPE SectionType,\r | |
ff197efb | 173 | IN UINTN SectionInstance,\r |
b0d803fe | 174 | OUT VOID **Buffer,\r |
175 | OUT UINTN *Size\r | |
ed66e1bc | 176 | );\r |
b0d803fe | 177 | \r |
178 | \r | |
179 | /**\r | |
b75a165d LG |
180 | Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.\r |
181 | \r | |
182 | This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.\r | |
183 | If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType, \r | |
184 | then the SectionInstance instance is returned in Buffer. Buffer is allocated using AllocatePool(), \r | |
185 | and the size of the allocated buffer is returned in Size. It is the caller's responsibility \r | |
186 | to use FreePool() to free the allocated buffer. See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for \r | |
187 | details on how sections are retrieved from an FFS file based on SectionType and SectionInstance.\r | |
188 | \r | |
189 | If the currently executing module was not loaded from an FFS file, then EFI_NOT_FOUND is returned.\r | |
190 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails, \r | |
191 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
192 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
193 | \r | |
194 | If Buffer is NULL, then ASSERT().\r | |
ff197efb | 195 | If Size is NULL, then ASSERT().\r |
196 | \r | |
b75a165d | 197 | \r |
af2dc6a7 | 198 | @param SectionType Indicates the FFS section type to search for within \r |
199 | the FFS file that the currently executing module \r | |
200 | was loaded from.\r | |
201 | @param SectionInstance Indicates which section instance to retrieve within \r | |
202 | the FFS file that the currently executing module \r | |
203 | was loaded from.\r | |
204 | @param Buffer On output, a pointer to a callee allocated buffer \r | |
205 | containing the FFS file section that was found. \r | |
206 | It is the caller's responsibility to free this buffer \r | |
207 | using FreePool().\r | |
b75a165d LG |
208 | @param Size On output, a pointer to the size, in bytes, of Buffer.\r |
209 | \r | |
210 | @retval EFI_SUCCESS The specified FFS section was returned.\r | |
211 | @retval EFI_NOT_FOUND The specified FFS section could not be found.\r | |
af2dc6a7 | 212 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve \r |
213 | the matching FFS section.\r | |
214 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a \r | |
215 | device error.\r | |
216 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the \r | |
217 | firmware volume that contains the matching FFS \r | |
218 | section does not allow reads. \r | |
b0d803fe | 219 | \r |
f80b0830 | 220 | **/\r |
b0d803fe | 221 | EFI_STATUS\r |
222 | EFIAPI\r | |
fdbee2e4 | 223 | GetSectionFromFfs (\r |
b0d803fe | 224 | IN EFI_SECTION_TYPE SectionType,\r |
ff197efb | 225 | IN UINTN SectionInstance,\r |
b0d803fe | 226 | OUT VOID **Buffer,\r |
227 | OUT UINTN *Size\r | |
ed66e1bc | 228 | );\r |
1c280088 | 229 | \r |
84716614 LG |
230 | \r |
231 | /**\r | |
232 | Get the image file buffer data and buffer size by its device path. \r | |
233 | \r | |
234 | Access the file either from a firmware volume, from a file system interface, \r | |
235 | or from the load file interface.\r | |
236 | \r | |
237 | Allocate memory to store the found image. The caller is responsible to free memory.\r | |
238 | \r | |
3556c7a2 | 239 | If FilePath is NULL, then NULL is returned.\r |
84716614 LG |
240 | If FileSize is NULL, then NULL is returned.\r |
241 | If AuthenticationStatus is NULL, then NULL is returned.\r | |
242 | \r | |
af2dc6a7 | 243 | @param[in] BootPolicy The policy for Open Image File.If TRUE, \r |
244 | indicates that the request originates from \r | |
245 | the boot manager, and that the boot manager is\r | |
246 | attempting to load FilePath as a boot selection. \r | |
247 | If FALSE, then FilePath must match an exact \r | |
248 | file to be loaded.\r | |
249 | @param[in] FilePath Pointer to the device path of the file that is abstracted to\r | |
ea6898b9 | 250 | the file buffer.\r |
251 | @param[out] FileSize Pointer to the size of the abstracted file buffer.\r | |
3556c7a2 | 252 | @param[out] AuthenticationStatus Pointer to the authentication status.\r |
84716614 | 253 | \r |
3556c7a2 | 254 | @retval NULL FilePath is NULL, or FileSize is NULL, or AuthenticationStatus is NULL, or the file can't be found.\r |
84716614 LG |
255 | @retval other The abstracted file buffer. The caller is responsible to free memory.\r |
256 | **/\r | |
257 | VOID *\r | |
258 | EFIAPI\r | |
259 | GetFileBufferByFilePath (\r | |
260 | IN BOOLEAN BootPolicy,\r | |
261 | IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath,\r | |
262 | OUT UINTN *FileSize,\r | |
263 | OUT UINT32 *AuthenticationStatus\r | |
264 | );\r | |
265 | \r | |
711ef3f6 SC |
266 | /**\r |
267 | Searches all the available firmware volumes and returns the file device path of first matching\r | |
268 | FFS section.\r | |
269 | \r | |
270 | This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.\r | |
271 | The order that the firmware volumes is searched is not deterministic. For each FFS file found a search\r | |
272 | is made for FFS sections of type SectionType.\r | |
273 | \r | |
274 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r | |
275 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
276 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
277 | \r | |
278 | If NameGuid is NULL, then ASSERT().\r | |
279 | \r | |
280 | @param NameGuid A pointer to to the FFS filename GUID to search for\r | |
281 | within any of the firmware volumes in the platform.\r | |
282 | @param SectionType Indicates the FFS section type to search for within\r | |
283 | the FFS file specified by NameGuid.\r | |
284 | @param SectionInstance Indicates which section instance within the FFS file\r | |
285 | specified by NameGuid to retrieve.\r | |
286 | @param FvFileDevicePath Device path for the target FFS\r | |
287 | file.\r | |
288 | \r | |
289 | @retval EFI_SUCCESS The specified file device path of FFS section was returned.\r | |
290 | @retval EFI_NOT_FOUND The specified file device path of FFS section could not be found.\r | |
291 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r | |
292 | device error.\r | |
293 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the\r | |
294 | firmware volume that contains the matching FFS section does not\r | |
295 | allow reads.\r | |
296 | @retval EFI_INVALID_PARAMETER FvFileDevicePath is NULL.\r | |
297 | \r | |
298 | **/\r | |
299 | EFI_STATUS\r | |
300 | EFIAPI\r | |
301 | GetFileDevicePathFromAnyFv (\r | |
302 | IN CONST EFI_GUID *NameGuid,\r | |
303 | IN EFI_SECTION_TYPE SectionType,\r | |
304 | IN UINTN SectionInstance,\r | |
305 | OUT EFI_DEVICE_PATH_PROTOCOL **FvFileDevicePath\r | |
306 | );\r | |
307 | \r | |
1c280088 | 308 | #endif\r |
309 | \r |