]> git.proxmox.com Git - mirror_edk2.git/blame - FmpDevicePkg/Include/Library/FmpDeviceLib.h
FmpDevicePkg: Fix code style issue
[mirror_edk2.git] / FmpDevicePkg / Include / Library / FmpDeviceLib.h
CommitLineData
a6d73269 1/** @file\r
cec7b8fb
KM
2 Provides firmware device specific services to support updates of a firmware\r
3 image stored in a firmware device.\r
4\r
5 Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>\r
6 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r
7\r
8 Redistribution and use in source and binary forms, with or without\r
9 modification, are permitted provided that the following conditions are met:\r
10 1. Redistributions of source code must retain the above copyright notice,\r
11 this list of conditions and the following disclaimer.\r
12 2. Redistributions in binary form must reproduce the above copyright notice,\r
13 this list of conditions and the following disclaimer in the documentation\r
14 and/or other materials provided with the distribution.\r
15\r
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
19 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r
20 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
21 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\r
24 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
25 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
26\r
27**/\r
28\r
29#ifndef __FMP_DEVICE_LIB__\r
30#define __FMP_DEVICE_LIB__\r
31\r
32#include <Protocol/FirmwareManagement.h>\r
33\r
34/**\r
35 Callback function that installs a Firmware Management Protocol instance onto\r
36 a handle.\r
37\r
38 @param[in] Handle The device handle to install a Firmware Management\r
39 Protocol instance.\r
40\r
41 @retval EFI_SUCCESS A Firmware Management Protocol instance was\r
42 installed onto Handle.\r
43 @retval EFI_INVALID_PARAMETER Handle is invalid\r
44 @retval other A Firmware Management Protocol instance could\r
45 not be installed onto Handle.\r
46\r
47**/\r
48typedef\r
49EFI_STATUS\r
50(EFIAPI *FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER)(\r
51 IN EFI_HANDLE Handle\r
52 );\r
53\r
54/**\r
55 Provide a function to install the Firmware Management Protocol instance onto a\r
56 device handle when the device is managed by a driver that follows the UEFI\r
57 Driver Model. If the device is not managed by a driver that follows the UEFI\r
58 Driver Model, then EFI_UNSUPPORTED is returned.\r
59\r
60 @param[in] FmpInstaller Function that installs the Firmware Management\r
61 Protocol.\r
62\r
63 @retval EFI_SUCCESS The device is managed by a driver that follows the\r
64 UEFI Driver Model. FmpInstaller must be called on\r
65 each Driver Binding Start().\r
66 @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r
67 the UEFI Driver Model.\r
68 @retval other The Firmware Management Protocol for this firmware\r
69 device is not installed. The firmware device is\r
70 still locked using FmpDeviceLock().\r
71\r
72**/\r
73EFI_STATUS\r
74EFIAPI\r
75RegisterFmpInstaller (\r
76 IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER FmpInstaller\r
77 );\r
78\r
79/**\r
80 Returns the size, in bytes, of the firmware image currently stored in the\r
81 firmware device. This function is used to by the GetImage() and\r
82 GetImageInfo() services of the Firmware Management Protocol. If the image\r
83 size can not be determined from the firmware device, then 0 must be returned.\r
84\r
85 @param[out] Size Pointer to the size, in bytes, of the firmware image\r
86 currently stored in the firmware device.\r
87\r
88 @retval EFI_SUCCESS The size of the firmware image currently\r
89 stored in the firmware device was returned.\r
90 @retval EFI_INVALID_PARAMETER Size is NULL.\r
91 @retval EFI_UNSUPPORTED The firmware device does not support reporting\r
92 the size of the currently stored firmware image.\r
93 @retval EFI_DEVICE_ERROR An error occured attempting to determine the\r
94 size of the firmware image currently stored in\r
95 in the firmware device.\r
96\r
97**/\r
98EFI_STATUS\r
99EFIAPI\r
100FmpDeviceGetSize (\r
101 OUT UINTN *Size\r
102 );\r
103\r
104/**\r
105 Returns the GUID value used to fill in the ImageTypeId field of the\r
106 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
107 service of the Firmware Management Protocol. If EFI_UNSUPPORTED is returned,\r
108 then the ImageTypeId field is set to gEfiCallerIdGuid. If EFI_SUCCESS is\r
109 returned, then ImageTypeId is set to the Guid returned from this function.\r
110\r
111 @param[out] Guid Double pointer to a GUID value that is updated to point to\r
112 to a GUID value. The GUID value is not allocated and must\r
113 not be modified or freed by the caller.\r
114\r
115 @retval EFI_SUCCESS EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set\r
116 to the returned Guid value.\r
117 @retval EFI_UNSUPPORTED EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set\r
118 to gEfiCallerIdGuid.\r
119\r
120**/\r
121EFI_STATUS\r
122EFIAPI\r
123FmpDeviceGetImageTypeIdGuidPtr (\r
124 OUT EFI_GUID **Guid\r
125 );\r
126\r
127/**\r
128 Returns values used to fill in the AttributesSupported and AttributesSettings\r
129 fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the\r
130 GetImageInfo() service of the Firmware Management Protocol. The following\r
131 bit values from the Firmware Management Protocol may be combined:\r
132 IMAGE_ATTRIBUTE_IMAGE_UPDATABLE\r
133 IMAGE_ATTRIBUTE_RESET_REQUIRED\r
134 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED\r
135 IMAGE_ATTRIBUTE_IN_USE\r
136 IMAGE_ATTRIBUTE_UEFI_IMAGE\r
137\r
138 @param[out] Supported Attributes supported by this firmware device.\r
139 @param[out] Setting Attributes settings for this firmware device.\r
140\r
141 @retval EFI_SUCCESS The attributes supported by the firmware\r
142 device were returned.\r
143 @retval EFI_INVALID_PARAMETER Supported is NULL.\r
144 @retval EFI_INVALID_PARAMETER Setting is NULL.\r
145\r
146**/\r
147EFI_STATUS\r
148EFIAPI\r
149FmpDeviceGetAttributes (\r
a6d73269
SZ
150 OUT UINT64 *Supported,\r
151 OUT UINT64 *Setting\r
cec7b8fb
KM
152 );\r
153\r
154/**\r
155 Returns the value used to fill in the LowestSupportedVersion field of the\r
156 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
157 service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r
158 the firmware device supports a method to report the LowestSupportedVersion\r
159 value from the currently stored firmware image. If the value can not be\r
160 reported for the firmware image currently stored in the firmware device, then\r
161 EFI_UNSUPPORTED must be returned. EFI_DEVICE_ERROR is returned if an error\r
162 occurs attempting to retrieve the LowestSupportedVersion value for the\r
163 currently stored firmware image.\r
164\r
165 @note It is recommended that all firmware devices support a method to report\r
166 the LowestSupportedVersion value from the currently stored firmware\r
167 image.\r
168\r
169 @param[out] LowestSupportedVersion LowestSupportedVersion value retrieved\r
170 from the currently stored firmware image.\r
171\r
172 @retval EFI_SUCCESS The lowest supported version of currently stored\r
173 firmware image was returned in LowestSupportedVersion.\r
174 @retval EFI_UNSUPPORTED The firmware device does not support a method to\r
175 report the lowest supported version of the currently\r
176 stored firmware image.\r
177 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the lowest\r
178 supported version of the currently stored firmware\r
179 image.\r
180\r
181**/\r
182EFI_STATUS\r
183EFIAPI\r
184FmpDeviceGetLowestSupportedVersion (\r
185 OUT UINT32 *LowestSupportedVersion\r
186 );\r
187\r
188/**\r
189 Returns the Null-terminated Unicode string that is used to fill in the\r
190 VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is\r
191 returned by the GetImageInfo() service of the Firmware Management Protocol.\r
192 The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().\r
193\r
194 @note It is recommended that all firmware devices support a method to report\r
195 the VersionName string from the currently stored firmware image.\r
196\r
197 @param[out] VersionString The version string retrieved from the currently\r
198 stored firmware image.\r
199\r
200 @retval EFI_SUCCESS The version string of currently stored\r
201 firmware image was returned in Version.\r
202 @retval EFI_INVALID_PARAMETER VersionString is NULL.\r
203 @retval EFI_UNSUPPORTED The firmware device does not support a method\r
204 to report the version string of the currently\r
205 stored firmware image.\r
206 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r
207 version string of the currently stored\r
208 firmware image.\r
209 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the\r
210 buffer for the version string of the currently\r
211 stored firmware image.\r
212\r
213**/\r
214EFI_STATUS\r
215EFIAPI\r
216FmpDeviceGetVersionString (\r
217 OUT CHAR16 **VersionString\r
218 );\r
219\r
220/**\r
221 Returns the value used to fill in the Version field of the\r
222 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
223 service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r
224 the firmware device supports a method to report the Version value from the\r
225 currently stored firmware image. If the value can not be reported for the\r
226 firmware image currently stored in the firmware device, then EFI_UNSUPPORTED\r
227 must be returned. EFI_DEVICE_ERROR is returned if an error occurs attempting\r
228 to retrieve the LowestSupportedVersion value for the currently stored firmware\r
229 image.\r
230\r
231 @note It is recommended that all firmware devices support a method to report\r
232 the Version value from the currently stored firmware image.\r
233\r
234 @param[out] Version The version value retrieved from the currently stored\r
235 firmware image.\r
236\r
237 @retval EFI_SUCCESS The version of currently stored firmware image was\r
238 returned in Version.\r
239 @retval EFI_UNSUPPORTED The firmware device does not support a method to\r
240 report the version of the currently stored firmware\r
241 image.\r
242 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the version\r
243 of the currently stored firmware image.\r
244\r
245**/\r
246EFI_STATUS\r
247EFIAPI\r
248FmpDeviceGetVersion (\r
249 OUT UINT32 *Version\r
250 );\r
251\r
252/**\r
253 Returns a copy of the firmware image currently stored in the firmware device.\r
254\r
255 @note It is recommended that all firmware devices support a method to retrieve\r
256 a copy currently stored firmware image. This can be used to support\r
257 features such as recovery and rollback.\r
258\r
a6d73269 259 @param[out] Image Pointer to a caller allocated buffer where the\r
cec7b8fb 260 currently stored firmware image is copied to.\r
a6d73269 261 @param[in, out] ImageSize Pointer the size, in bytes, of the Image buffer.\r
cec7b8fb
KM
262 On return, points to the size, in bytes, of firmware\r
263 image currently stored in the firmware device.\r
264\r
265 @retval EFI_SUCCESS Image contains a copy of the firmware image\r
266 currently stored in the firmware device, and\r
267 ImageSize contains the size, in bytes, of the\r
268 firmware image currently stored in the\r
269 firmware device.\r
270 @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small\r
271 to hold the firmware image currently stored in\r
272 the firmware device. The buffer size required\r
273 is returned in ImageSize.\r
274 @retval EFI_INVALID_PARAMETER The Image is NULL.\r
275 @retval EFI_INVALID_PARAMETER The ImageSize is NULL.\r
276 @retval EFI_UNSUPPORTED The operation is not supported.\r
277 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r
278 firmware image currently stored in the firmware\r
279 device.\r
280\r
281**/\r
282EFI_STATUS\r
283EFIAPI\r
284FmpDeviceGetImage (\r
a6d73269
SZ
285 OUT VOID *Image,\r
286 IN OUT UINTN *ImageSize\r
cec7b8fb
KM
287 );\r
288\r
289/**\r
290 Checks if a new firmware image is valid for the firmware device. This\r
291 function allows firmware update operation to validate the firmware image\r
292 before FmpDeviceSetImage() is called.\r
293\r
294 @param[in] Image Points to a new firmware image.\r
295 @param[in] ImageSize Size, in bytes, of a new firmware image.\r
296 @param[out] ImageUpdatable Indicates if a new firmware image is valid for\r
297 a firmware update to the firmware device. The\r
298 following values from the Firmware Management\r
299 Protocol are supported:\r
300 IMAGE_UPDATABLE_VALID\r
301 IMAGE_UPDATABLE_INVALID\r
302 IMAGE_UPDATABLE_INVALID_TYPE\r
303 IMAGE_UPDATABLE_INVALID_OLD\r
304 IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE\r
305\r
306 @retval EFI_SUCCESS The image was successfully checked. Additional\r
307 status information is returned in\r
a6d73269 308 ImageUpdatable.\r
cec7b8fb 309 @retval EFI_INVALID_PARAMETER Image is NULL.\r
a6d73269 310 @retval EFI_INVALID_PARAMETER ImageUpdatable is NULL.\r
cec7b8fb
KM
311\r
312**/\r
313EFI_STATUS\r
314EFIAPI\r
315FmpDeviceCheckImage (\r
316 IN CONST VOID *Image,\r
317 IN UINTN ImageSize,\r
a6d73269 318 OUT UINT32 *ImageUpdatable\r
cec7b8fb
KM
319 );\r
320\r
321/**\r
322 Updates a firmware device with a new firmware image. This function returns\r
323 EFI_UNSUPPORTED if the firmware image is not updatable. If the firmware image\r
324 is updatable, the function should perform the following minimal validations\r
325 before proceeding to do the firmware image update.\r
326 - Validate that the image is a supported image for this firmware device.\r
327 Return EFI_ABORTED if the image is not supported. Additional details\r
328 on why the image is not a supported image may be returned in AbortReason.\r
329 - Validate the data from VendorCode if is not NULL. Firmware image\r
330 validation must be performed before VendorCode data validation.\r
331 VendorCode data is ignored or considered invalid if image validation\r
332 fails. Return EFI_ABORTED if the VendorCode data is invalid.\r
333\r
334 VendorCode enables vendor to implement vendor-specific firmware image update\r
335 policy. Null if the caller did not specify the policy or use the default\r
336 policy. As an example, vendor can implement a policy to allow an option to\r
337 force a firmware image update when the abort reason is due to the new firmware\r
338 image version is older than the current firmware image version or bad image\r
339 checksum. Sensitive operations such as those wiping the entire firmware image\r
340 and render the device to be non-functional should be encoded in the image\r
341 itself rather than passed with the VendorCode. AbortReason enables vendor to\r
342 have the option to provide a more detailed description of the abort reason to\r
343 the caller.\r
344\r
345 @param[in] Image Points to the new firmware image.\r
346 @param[in] ImageSize Size, in bytes, of the new firmware image.\r
347 @param[in] VendorCode This enables vendor to implement vendor-specific\r
348 firmware image update policy. NULL indicates\r
349 the caller did not specify the policy or use the\r
350 default policy.\r
351 @param[in] Progress A function used to report the progress of\r
352 updating the firmware device with the new\r
353 firmware image.\r
354 @param[in] CapsuleFwVersion The version of the new firmware image from the\r
355 update capsule that provided the new firmware\r
356 image.\r
357 @param[out] AbortReason A pointer to a pointer to a Null-terminated\r
358 Unicode string providing more details on an\r
359 aborted operation. The buffer is allocated by\r
360 this function with\r
361 EFI_BOOT_SERVICES.AllocatePool(). It is the\r
362 caller's responsibility to free this buffer with\r
363 EFI_BOOT_SERVICES.FreePool().\r
364\r
365 @retval EFI_SUCCESS The firmware device was successfully updated\r
366 with the new firmware image.\r
367 @retval EFI_ABORTED The operation is aborted. Additional details\r
368 are provided in AbortReason.\r
369 @retval EFI_INVALID_PARAMETER The Image was NULL.\r
370 @retval EFI_UNSUPPORTED The operation is not supported.\r
371\r
372**/\r
373EFI_STATUS\r
374EFIAPI\r
375FmpDeviceSetImage (\r
376 IN CONST VOID *Image,\r
377 IN UINTN ImageSize,\r
378 IN CONST VOID *VendorCode, OPTIONAL\r
379 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL\r
380 IN UINT32 CapsuleFwVersion,\r
381 OUT CHAR16 **AbortReason\r
382 );\r
383\r
384/**\r
385 Lock the firmware device that contains a firmware image. Once a firmware\r
386 device is locked, any attempts to modify the firmware image contents in the\r
387 firmware device must fail.\r
388\r
389 @note It is recommended that all firmware devices support a lock method to\r
390 prevent modifications to a stored firmware image.\r
391\r
392 @note A firmware device lock mechanism is typically only cleared by a full\r
393 system reset (not just sleep state/low power mode).\r
394\r
395 @retval EFI_SUCCESS The firmware device was locked.\r
396 @retval EFI_UNSUPPORTED The firmware device does not support locking\r
397\r
398**/\r
399EFI_STATUS\r
400EFIAPI\r
401FmpDeviceLock (\r
402 VOID\r
403 );\r
404\r
405#endif\r