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