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