]>
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 | |
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 | |
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 |
b0d803fe | 110 | IN CONST EFI_GUID *NameGuid,\r |
111 | IN EFI_SECTION_TYPE SectionType,\r | |
ff197efb | 112 | IN UINTN SectionInstance,\r |
b0d803fe | 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 |
b0d803fe | 165 | IN CONST EFI_GUID *NameGuid,\r |
166 | IN EFI_SECTION_TYPE SectionType,\r | |
ff197efb | 167 | IN UINTN SectionInstance,\r |
b0d803fe | 168 | OUT VOID **Buffer,\r |
169 | OUT UINTN *Size\r | |
ed66e1bc | 170 | );\r |
b0d803fe | 171 | \r |
172 | \r | |
173 | /**\r | |
c1d8b697 | 174 | Searches the FFS file the currently executing module was loaded from and returns the first matching FFS section.\r |
b75a165d LG |
175 | \r |
176 | This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.\r | |
9095d37b LG |
177 | If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType,\r |
178 | then the SectionInstance instance is returned in Buffer. Buffer is allocated using AllocatePool(),\r | |
179 | and the size of the allocated buffer is returned in Size. It is the caller's responsibility\r | |
180 | to use FreePool() to free the allocated buffer. See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for\r | |
b75a165d LG |
181 | details on how sections are retrieved from an FFS file based on SectionType and SectionInstance.\r |
182 | \r | |
183 | If the currently executing module was not loaded from an FFS file, then EFI_NOT_FOUND is returned.\r | |
9095d37b | 184 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r |
b75a165d LG |
185 | the search will be retried with a section type of EFI_SECTION_PE32.\r |
186 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
9095d37b | 187 | \r |
b75a165d | 188 | If Buffer is NULL, then ASSERT().\r |
ff197efb | 189 | If Size is NULL, then ASSERT().\r |
190 | \r | |
b75a165d | 191 | \r |
9095d37b LG |
192 | @param SectionType Indicates the FFS section type to search for within\r |
193 | the FFS file that the currently executing module\r | |
af2dc6a7 | 194 | was loaded from.\r |
9095d37b LG |
195 | @param SectionInstance Indicates which section instance to retrieve within\r |
196 | the FFS file that the currently executing module\r | |
af2dc6a7 | 197 | was loaded from.\r |
9095d37b LG |
198 | @param Buffer On output, a pointer to a callee allocated buffer\r |
199 | containing the FFS file section that was found.\r | |
200 | It is the caller's responsibility to free this buffer\r | |
af2dc6a7 | 201 | using FreePool().\r |
b75a165d LG |
202 | @param Size On output, a pointer to the size, in bytes, of Buffer.\r |
203 | \r | |
204 | @retval EFI_SUCCESS The specified FFS section was returned.\r | |
205 | @retval EFI_NOT_FOUND The specified FFS section could not be found.\r | |
9095d37b | 206 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r |
af2dc6a7 | 207 | the matching FFS section.\r |
9095d37b | 208 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r |
af2dc6a7 | 209 | device error.\r |
9095d37b LG |
210 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the\r |
211 | firmware volume that contains the matching FFS\r | |
212 | section does not allow reads.\r | |
213 | \r | |
f80b0830 | 214 | **/\r |
b0d803fe | 215 | EFI_STATUS\r |
216 | EFIAPI\r | |
fdbee2e4 | 217 | GetSectionFromFfs (\r |
b0d803fe | 218 | IN EFI_SECTION_TYPE SectionType,\r |
ff197efb | 219 | IN UINTN SectionInstance,\r |
b0d803fe | 220 | OUT VOID **Buffer,\r |
221 | OUT UINTN *Size\r | |
ed66e1bc | 222 | );\r |
1c280088 | 223 | \r |
84716614 LG |
224 | \r |
225 | /**\r | |
9095d37b LG |
226 | Get the image file buffer data and buffer size by its device path.\r |
227 | \r | |
228 | Access the file either from a firmware volume, from a file system interface,\r | |
84716614 | 229 | or from the load file interface.\r |
9095d37b | 230 | \r |
84716614 LG |
231 | Allocate memory to store the found image. The caller is responsible to free memory.\r |
232 | \r | |
3556c7a2 | 233 | If FilePath is NULL, then NULL is returned.\r |
84716614 LG |
234 | If FileSize is NULL, then NULL is returned.\r |
235 | If AuthenticationStatus is NULL, then NULL is returned.\r | |
236 | \r | |
9095d37b LG |
237 | @param[in] BootPolicy The policy for Open Image File.If TRUE,\r |
238 | indicates that the request originates from\r | |
af2dc6a7 | 239 | the boot manager, and that the boot manager is\r |
9095d37b LG |
240 | attempting to load FilePath as a boot selection.\r |
241 | If FALSE, then FilePath must match an exact\r | |
af2dc6a7 | 242 | file to be loaded.\r |
243 | @param[in] FilePath Pointer to the device path of the file that is abstracted to\r | |
ea6898b9 | 244 | the file buffer.\r |
245 | @param[out] FileSize Pointer to the size of the abstracted file buffer.\r | |
3556c7a2 | 246 | @param[out] AuthenticationStatus Pointer to the authentication status.\r |
84716614 | 247 | \r |
3556c7a2 | 248 | @retval NULL FilePath is NULL, or FileSize is NULL, or AuthenticationStatus is NULL, or the file can't be found.\r |
84716614 LG |
249 | @retval other The abstracted file buffer. The caller is responsible to free memory.\r |
250 | **/\r | |
251 | VOID *\r | |
252 | EFIAPI\r | |
253 | GetFileBufferByFilePath (\r | |
254 | IN BOOLEAN BootPolicy,\r | |
255 | IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath,\r | |
256 | OUT UINTN *FileSize,\r | |
257 | OUT UINT32 *AuthenticationStatus\r | |
258 | );\r | |
259 | \r | |
711ef3f6 SC |
260 | /**\r |
261 | Searches all the available firmware volumes and returns the file device path of first matching\r | |
262 | FFS section.\r | |
263 | \r | |
264 | This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.\r | |
265 | The order that the firmware volumes is searched is not deterministic. For each FFS file found a search\r | |
266 | is made for FFS sections of type SectionType.\r | |
267 | \r | |
268 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r | |
269 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
270 | This function must be called with a TPL <= TPL_NOTIFY.\r | |
271 | \r | |
272 | If NameGuid is NULL, then ASSERT().\r | |
273 | \r | |
274 | @param NameGuid A pointer to to the FFS filename GUID to search for\r | |
275 | within any of the firmware volumes in the platform.\r | |
276 | @param SectionType Indicates the FFS section type to search for within\r | |
277 | the FFS file specified by NameGuid.\r | |
278 | @param SectionInstance Indicates which section instance within the FFS file\r | |
279 | specified by NameGuid to retrieve.\r | |
280 | @param FvFileDevicePath Device path for the target FFS\r | |
281 | file.\r | |
282 | \r | |
283 | @retval EFI_SUCCESS The specified file device path of FFS section was returned.\r | |
284 | @retval EFI_NOT_FOUND The specified file device path of FFS section could not be found.\r | |
285 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r | |
286 | device error.\r | |
287 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the\r | |
288 | firmware volume that contains the matching FFS section does not\r | |
289 | allow reads.\r | |
290 | @retval EFI_INVALID_PARAMETER FvFileDevicePath is NULL.\r | |
291 | \r | |
292 | **/\r | |
293 | EFI_STATUS\r | |
294 | EFIAPI\r | |
295 | GetFileDevicePathFromAnyFv (\r | |
296 | IN CONST EFI_GUID *NameGuid,\r | |
297 | IN EFI_SECTION_TYPE SectionType,\r | |
298 | IN UINTN SectionInstance,\r | |
299 | OUT EFI_DEVICE_PATH_PROTOCOL **FvFileDevicePath\r | |
300 | );\r | |
301 | \r | |
a40e0b7a AB |
302 | /**\r |
303 | Allocates one or more 4KB pages of a given type from a memory region that is\r | |
304 | accessible to PEI.\r | |
305 | \r | |
306 | Allocates the number of 4KB pages of type 'MemoryType' and returns a\r | |
307 | pointer to the allocated buffer. The buffer returned is aligned on a 4KB\r | |
308 | boundary. If Pages is 0, then NULL is returned. If there is not enough\r | |
309 | memory remaining to satisfy the request, then NULL is returned.\r | |
1c280088 | 310 | \r |
a40e0b7a AB |
311 | @param[in] MemoryType The memory type to allocate\r |
312 | @param[in] Pages The number of 4 KB pages to allocate.\r | |
313 | \r | |
314 | @return A pointer to the allocated buffer or NULL if allocation fails.\r | |
315 | \r | |
316 | **/\r | |
317 | VOID *\r | |
318 | EFIAPI\r | |
319 | AllocatePeiAccessiblePages (\r | |
320 | IN EFI_MEMORY_TYPE MemoryType,\r | |
321 | IN UINTN Pages\r | |
322 | );\r | |
323 | \r | |
324 | #endif\r |