]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | MDE DXE Services Library provides functions that simplify the development of DXE Drivers.\r | |
3 | These functions help access data from sections of FFS files or from file path.\r | |
4 | \r | |
5 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
6 | (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r | |
7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
8 | \r | |
9 | **/\r | |
10 | \r | |
11 | #ifndef __DXE_SERVICES_LIB_H__\r | |
12 | #define __DXE_SERVICES_LIB_H__\r | |
13 | \r | |
14 | /**\r | |
15 | Searches all the available firmware volumes and returns the first matching FFS section.\r | |
16 | \r | |
17 | This function searches all the firmware volumes for FFS files with FV file type specified by FileType\r | |
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 | |
26 | are retrieved from an FFS file based on SectionType and SectionInstance.\r | |
27 | \r | |
28 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r | |
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 | |
38 | @param SectionType Indicates the FFS section type to search for within the FFS file\r | |
39 | specified by FileType with FileInstance.\r | |
40 | @param SectionInstance Indicates which section instance within the FFS file\r | |
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 | |
50 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that\r | |
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 | |
64 | /**\r | |
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 | |
74 | are retrieved from an FFS file based on SectionType and SectionInstance.\r | |
75 | \r | |
76 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r | |
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 | |
82 | If Size is NULL, then ASSERT().\r | |
83 | \r | |
84 | \r | |
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 | |
88 | the FFS file specified by NameGuid.\r | |
89 | @param SectionInstance Indicates which section instance within the FFS file\r | |
90 | specified by NameGuid to retrieve.\r | |
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 | |
94 | buffer using FreePool().\r | |
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 | |
99 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r | |
100 | the matching FFS section.\r | |
101 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r | |
102 | device error.\r | |
103 | @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the\r | |
104 | firmware volume that contains the matching FFS\r | |
105 | section does not allow reads.\r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | GetSectionFromAnyFv (\r | |
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 | |
115 | );\r | |
116 | \r | |
117 | /**\r | |
118 | Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section.\r | |
119 | \r | |
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 | |
123 | instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.\r | |
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 | |
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 | |
130 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r | |
131 | the search will be retried with a section type of EFI_SECTION_PE32.\r | |
132 | \r | |
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 | |
136 | If Size is NULL, then ASSERT().\r | |
137 | \r | |
138 | @param NameGuid A pointer to to the FFS filename GUID to search for\r | |
139 | within the firmware volumes that the currently\r | |
140 | executing module was loaded from.\r | |
141 | @param SectionType Indicates the FFS section type to search for within\r | |
142 | the FFS file specified by NameGuid.\r | |
143 | @param SectionInstance Indicates which section instance within the FFS\r | |
144 | file specified by NameGuid to retrieve.\r | |
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 | |
148 | using FreePool().\r | |
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 | |
154 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r | |
155 | the matching FFS section.\r | |
156 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r | |
157 | device error.\r | |
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 | |
161 | **/\r | |
162 | EFI_STATUS\r | |
163 | EFIAPI\r | |
164 | GetSectionFromFv (\r | |
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 | |
170 | );\r | |
171 | \r | |
172 | \r | |
173 | /**\r | |
174 | Searches the FFS file the currently executing module was loaded from and returns the first matching FFS section.\r | |
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 | |
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 | |
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 | |
184 | If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r | |
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 | |
187 | \r | |
188 | If Buffer is NULL, then ASSERT().\r | |
189 | If Size is NULL, then ASSERT().\r | |
190 | \r | |
191 | \r | |
192 | @param SectionType Indicates the FFS section type to search for within\r | |
193 | the FFS file that the currently executing module\r | |
194 | was loaded from.\r | |
195 | @param SectionInstance Indicates which section instance to retrieve within\r | |
196 | the FFS file that the currently executing module\r | |
197 | was loaded from.\r | |
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 | |
201 | using FreePool().\r | |
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 | |
206 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r | |
207 | the matching FFS section.\r | |
208 | @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r | |
209 | device error.\r | |
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 | |
214 | **/\r | |
215 | EFI_STATUS\r | |
216 | EFIAPI\r | |
217 | GetSectionFromFfs (\r | |
218 | IN EFI_SECTION_TYPE SectionType,\r | |
219 | IN UINTN SectionInstance,\r | |
220 | OUT VOID **Buffer,\r | |
221 | OUT UINTN *Size\r | |
222 | );\r | |
223 | \r | |
224 | \r | |
225 | /**\r | |
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 | |
229 | or from the load file interface.\r | |
230 | \r | |
231 | Allocate memory to store the found image. The caller is responsible to free memory.\r | |
232 | \r | |
233 | If FilePath is NULL, then NULL is returned.\r | |
234 | If FileSize is NULL, then NULL is returned.\r | |
235 | If AuthenticationStatus is NULL, then NULL is returned.\r | |
236 | \r | |
237 | @param[in] BootPolicy The policy for Open Image File.If TRUE,\r | |
238 | indicates that the request originates from\r | |
239 | the boot manager, and that the boot manager is\r | |
240 | attempting to load FilePath as a boot selection.\r | |
241 | If FALSE, then FilePath must match an exact\r | |
242 | file to be loaded.\r | |
243 | @param[in] FilePath Pointer to the device path of the file that is abstracted to\r | |
244 | the file buffer.\r | |
245 | @param[out] FileSize Pointer to the size of the abstracted file buffer.\r | |
246 | @param[out] AuthenticationStatus Pointer to the authentication status.\r | |
247 | \r | |
248 | @retval NULL FilePath is NULL, or FileSize is NULL, or AuthenticationStatus is NULL, or the file can't be found.\r | |
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 | |
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 | |
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 | |
310 | \r | |
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 |