]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/DxeServicesLib.h
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Include / Library / DxeServicesLib.h
CommitLineData
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 5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
711ef3f6 6(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
9095d37b
LG
7This program and the accompanying materials are licensed and made available under\r
8the terms and conditions of the BSD License that accompanies this distribution.\r
af2dc6a7 9The full text of the license may be found at\r
9095d37b 10http://opensource.org/licenses/bsd-license.php.\r
1c280088 11\r
9095d37b
LG
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT 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 20/**\r
9095d37b 21 Searches all the available firmware volumes and returns the first matching FFS section.\r
682cee4c
LG
22\r
23 This function searches all the firmware volumes for FFS files with FV file type specified by FileType\r
9095d37b
LG
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
682cee4c
LG
32 are retrieved from an FFS file based on SectionType and SectionInstance.\r
33\r
9095d37b 34 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r
682cee4c
LG
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
9095d37b 44 @param SectionType Indicates the FFS section type to search for within the FFS file\r
682cee4c 45 specified by FileType with FileInstance.\r
9095d37b 46 @param SectionInstance Indicates which section instance within the FFS file\r
682cee4c
LG
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
9095d37b 56 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the firmware volume that\r
682cee4c
LG
57 contains the matching FFS section does not allow reads.\r
58**/\r
59EFI_STATUS\r
60EFIAPI\r
61GetSectionFromAnyFvByFileType (\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
9095d37b
LG
71 Searches all the available firmware volumes and returns the first matching FFS section.\r
72\r
73 This function searches all the firmware volumes for FFS files with an FFS filename specified by NameGuid.\r
74 The order in which the firmware volumes are searched is not deterministic. For each FFS file found, a search\r
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
b75a165d
LG
80 are retrieved from an FFS file based on SectionType and SectionInstance.\r
81\r
9095d37b 82 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r
b75a165d
LG
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
9095d37b
LG
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
af2dc6a7 94 the FFS file specified by NameGuid.\r
9095d37b 95 @param SectionInstance Indicates which section instance within the FFS file\r
af2dc6a7 96 specified by NameGuid to retrieve.\r
9095d37b
LG
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
af2dc6a7 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
9095d37b 105 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r
af2dc6a7 106 the matching FFS section.\r
9095d37b 107 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r
af2dc6a7 108 device error.\r
9095d37b
LG
109 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the\r
110 firmware volume that contains the matching FFS\r
af2dc6a7 111 section does not allow reads.\r
f80b0830 112**/\r
b0d803fe 113EFI_STATUS\r
114EFIAPI\r
fdbee2e4 115GetSectionFromAnyFv (\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
9095d37b 124 Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section.\r
b75a165d 125\r
9095d37b
LG
126 This function searches the firmware volume that the currently executing module was loaded\r
127 from for an FFS file with an FFS filename specified by NameGuid. If the FFS file is found, a search\r
128 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance\r
b75a165d 129 instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.\r
9095d37b
LG
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
b75a165d
LG
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
9095d37b 136 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r
b75a165d 137 the search will be retried with a section type of EFI_SECTION_PE32.\r
9095d37b 138\r
b75a165d
LG
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
9095d37b
LG
144 @param NameGuid A pointer to to the FFS filename GUID to search for\r
145 within the firmware volumes that the currently\r
af2dc6a7 146 executing module was loaded from.\r
9095d37b 147 @param SectionType Indicates the FFS section type to search for within\r
af2dc6a7 148 the FFS file specified by NameGuid.\r
9095d37b 149 @param SectionInstance Indicates which section instance within the FFS\r
af2dc6a7 150 file specified by NameGuid to retrieve.\r
9095d37b
LG
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
af2dc6a7 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
9095d37b 160 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r
af2dc6a7 161 the matching FFS section.\r
9095d37b 162 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r
af2dc6a7 163 device error.\r
9095d37b
LG
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 168EFI_STATUS\r
169EFIAPI\r
fdbee2e4 170GetSectionFromFv (\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
9095d37b
LG
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
b75a165d
LG
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
9095d37b 190 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,\r
b75a165d
LG
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
9095d37b 193\r
b75a165d 194 If Buffer is NULL, then ASSERT().\r
ff197efb 195 If Size is NULL, then ASSERT().\r
196\r
b75a165d 197\r
9095d37b
LG
198 @param SectionType Indicates the FFS section type to search for within\r
199 the FFS file that the currently executing module\r
af2dc6a7 200 was loaded from.\r
9095d37b
LG
201 @param SectionInstance Indicates which section instance to retrieve within\r
202 the FFS file that the currently executing module\r
af2dc6a7 203 was loaded from.\r
9095d37b
LG
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
af2dc6a7 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
9095d37b 212 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve\r
af2dc6a7 213 the matching FFS section.\r
9095d37b 214 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a\r
af2dc6a7 215 device error.\r
9095d37b
LG
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
219\r
f80b0830 220**/\r
b0d803fe 221EFI_STATUS\r
222EFIAPI\r
fdbee2e4 223GetSectionFromFfs (\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
9095d37b
LG
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
84716614 235 or from the load file interface.\r
9095d37b 236\r
84716614
LG
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
9095d37b
LG
243 @param[in] BootPolicy The policy for Open Image File.If TRUE,\r
244 indicates that the request originates from\r
af2dc6a7 245 the boot manager, and that the boot manager is\r
9095d37b
LG
246 attempting to load FilePath as a boot selection.\r
247 If FALSE, then FilePath must match an exact\r
af2dc6a7 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
257VOID *\r
258EFIAPI\r
259GetFileBufferByFilePath (\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
299EFI_STATUS\r
300EFIAPI\r
301GetFileDevicePathFromAnyFv (\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
a40e0b7a
AB
308/**\r
309 Allocates one or more 4KB pages of a given type from a memory region that is\r
310 accessible to PEI.\r
311\r
312 Allocates the number of 4KB pages of type 'MemoryType' and returns a\r
313 pointer to the allocated buffer. The buffer returned is aligned on a 4KB\r
314 boundary. If Pages is 0, then NULL is returned. If there is not enough\r
315 memory remaining to satisfy the request, then NULL is returned.\r
1c280088 316\r
a40e0b7a
AB
317 @param[in] MemoryType The memory type to allocate\r
318 @param[in] Pages The number of 4 KB pages to allocate.\r
319\r
320 @return A pointer to the allocated buffer or NULL if allocation fails.\r
321\r
322**/\r
323VOID *\r
324EFIAPI\r
325AllocatePeiAccessiblePages (\r
326 IN EFI_MEMORY_TYPE MemoryType,\r
327 IN UINTN Pages\r
328 );\r
329\r
330#endif\r