]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/DxeServicesLib.h
Grammatical and disclaimer changes (does not follow internal C coding stds.)
[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 an FFS filename specified by NameGuid.
23 The order in which the firmware volumes are searched is not deterministic. For each FFS file found, a search
24 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance instances
25 of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
26 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
27 It is the caller's responsibility to use FreePool() to free the allocated buffer.
28 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections
29 are retrieved from an FFS file based on SectionType and SectionInstance.
30
31 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
32 the search will be retried with a section type of EFI_SECTION_PE32.
33 This function must be called with a TPL <= TPL_NOTIFY.
34
35 If NameGuid is NULL, then ASSERT().
36 If Buffer is NULL, then ASSERT().
37 If Size is NULL, then ASSERT().
38
39
40 @param NameGuid A pointer to to the FFS filename GUID to search for
41 within any of the firmware volumes in the platform.
42 @param SectionType Indicates the FFS section type to search for within
43 the FFS file specified by NameGuid.
44 @param SectionInstance Indicates which section instance within the FFS file
45 specified by NameGuid to retrieve.
46 @param Buffer On output, a pointer to a callee-allocated buffer
47 containing the FFS file section that was found.
48 It is the caller's responsibility to free this
49 buffer using FreePool().
50 @param Size On output, a pointer to the size, in bytes, of Buffer.
51
52 @retval EFI_SUCCESS The specified FFS section was returned.
53 @retval EFI_NOT_FOUND The specified FFS section could not be found.
54 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve
55 the matching FFS section.
56 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
57 device error.
58 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
59 firmware volume that contains the matching FFS
60 section does not allow reads.
61 **/
62 EFI_STATUS
63 EFIAPI
64 GetSectionFromAnyFv (
65 IN CONST EFI_GUID *NameGuid,
66 IN EFI_SECTION_TYPE SectionType,
67 IN UINTN SectionInstance,
68 OUT VOID **Buffer,
69 OUT UINTN *Size
70 );
71
72 /**
73 Searches the firmware volume that the currently executing module was loaded from and returns the first matching FFS section.
74
75 This function searches the firmware volume that the currently executing module was loaded
76 from for an FFS file with an FFS filename specified by NameGuid. If the FFS file is found, a search
77 is made for FFS sections of type SectionType. If the FFS file contains at least SectionInstance
78 instances of the FFS section specified by SectionType, then the SectionInstance instance is returned in Buffer.
79 Buffer is allocated using AllocatePool(), and the size of the allocated buffer is returned in Size.
80 It is the caller's responsibility to use FreePool() to free the allocated buffer.
81 See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for details on how sections are retrieved from
82 an FFS file based on SectionType and SectionInstance.
83
84 If the currently executing module was not loaded from a firmware volume, then EFI_NOT_FOUND is returned.
85 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
86 the search will be retried with a section type of EFI_SECTION_PE32.
87
88 This function must be called with a TPL <= TPL_NOTIFY.
89 If NameGuid is NULL, then ASSERT().
90 If Buffer is NULL, then ASSERT().
91 If Size is NULL, then ASSERT().
92
93 @param NameGuid A pointer to to the FFS filename GUID to search for
94 within the firmware volumes that the currently
95 executing module was loaded from.
96 @param SectionType Indicates the FFS section type to search for within
97 the FFS file specified by NameGuid.
98 @param SectionInstance Indicates which section instance within the FFS
99 file specified by NameGuid to retrieve.
100 @param Buffer On output, a pointer to a callee allocated buffer
101 containing the FFS file section that was found.
102 It is the caller's responsibility to free this buffer
103 using FreePool().
104 @param Size On output, a pointer to the size, in bytes, of Buffer.
105
106
107 @retval EFI_SUCCESS The specified FFS section was returned.
108 @retval EFI_NOT_FOUND The specified FFS section could not be found.
109 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve
110 the matching FFS section.
111 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
112 device error.
113 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
114 firmware volume that contains the matching FFS
115 section does not allow reads.
116 **/
117 EFI_STATUS
118 EFIAPI
119 GetSectionFromFv (
120 IN CONST EFI_GUID *NameGuid,
121 IN EFI_SECTION_TYPE SectionType,
122 IN UINTN SectionInstance,
123 OUT VOID **Buffer,
124 OUT UINTN *Size
125 );
126
127
128 /**
129 Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.
130
131 This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.
132 If the FFS file contains at least SectionInstance instances of the FFS section specified by SectionType,
133 then the SectionInstance instance is returned in Buffer. Buffer is allocated using AllocatePool(),
134 and the size of the allocated buffer is returned in Size. It is the caller's responsibility
135 to use FreePool() to free the allocated buffer. See EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() for
136 details on how sections are retrieved from an FFS file based on SectionType and SectionInstance.
137
138 If the currently executing module was not loaded from an FFS file, then EFI_NOT_FOUND is returned.
139 If SectionType is EFI_SECTION_TE, and the search with an FFS file fails,
140 the search will be retried with a section type of EFI_SECTION_PE32.
141 This function must be called with a TPL <= TPL_NOTIFY.
142
143 If Buffer is NULL, then ASSERT().
144 If Size is NULL, then ASSERT().
145
146
147 @param SectionType Indicates the FFS section type to search for within
148 the FFS file that the currently executing module
149 was loaded from.
150 @param SectionInstance Indicates which section instance to retrieve within
151 the FFS file that the currently executing module
152 was loaded from.
153 @param Buffer On output, a pointer to a callee allocated buffer
154 containing the FFS file section that was found.
155 It is the caller's responsibility to free this buffer
156 using FreePool().
157 @param Size On output, a pointer to the size, in bytes, of Buffer.
158
159 @retval EFI_SUCCESS The specified FFS section was returned.
160 @retval EFI_NOT_FOUND The specified FFS section could not be found.
161 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to retrieve
162 the matching FFS section.
163 @retval EFI_DEVICE_ERROR The FFS section could not be retrieves due to a
164 device error.
165 @retval EFI_ACCESS_DENIED The FFS section could not be retrieves because the
166 firmware volume that contains the matching FFS
167 section does not allow reads.
168
169 **/
170 EFI_STATUS
171 EFIAPI
172 GetSectionFromFfs (
173 IN EFI_SECTION_TYPE SectionType,
174 IN UINTN SectionInstance,
175 OUT VOID **Buffer,
176 OUT UINTN *Size
177 );
178
179
180 /**
181 Get the image file buffer data and buffer size by its device path.
182
183 Access the file either from a firmware volume, from a file system interface,
184 or from the load file interface.
185
186 Allocate memory to store the found image. The caller is responsible to free memory.
187
188 If File is NULL, then NULL is returned.
189 If FileSize is NULL, then NULL is returned.
190 If AuthenticationStatus is NULL, then NULL is returned.
191
192 @param[in] BootPolicy The policy for Open Image File.If TRUE,
193 indicates that the request originates from
194 the boot manager, and that the boot manager is
195 attempting to load FilePath as a boot selection.
196 If FALSE, then FilePath must match an exact
197 file to be loaded.
198 @param[in] FilePath Pointer to the device path of the file that is abstracted to
199 the file buffer.
200 @param[out] FileSize Pointer to the size of the abstracted file buffer.
201 @param[out] AuthenticationStatus Pointer to a caller-allocated UINT32 in which the authentication
202 status is returned.
203
204 @retval NULL File is NULL, or FileSize is NULL, or the file can't be found.
205 @retval other The abstracted file buffer. The caller is responsible to free memory.
206 **/
207 VOID *
208 EFIAPI
209 GetFileBufferByFilePath (
210 IN BOOLEAN BootPolicy,
211 IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath,
212 OUT UINTN *FileSize,
213 OUT UINT32 *AuthenticationStatus
214 );
215
216 #endif
217