]> git.proxmox.com Git - mirror_edk2.git/blame - FmpDevicePkg/Include/Library/FmpDeviceLib.h
FmpDevicePkg: Fix spelling errors
[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
8d01f2f4 6 Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>\r
cec7b8fb 7\r
bcef758c 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
cec7b8fb
KM
9\r
10**/\r
11\r
12#ifndef __FMP_DEVICE_LIB__\r
13#define __FMP_DEVICE_LIB__\r
14\r
15#include <Protocol/FirmwareManagement.h>\r
16\r
17/**\r
18 Callback function that installs a Firmware Management Protocol instance onto\r
19 a handle.\r
20\r
21 @param[in] Handle The device handle to install a Firmware Management\r
22 Protocol instance.\r
23\r
24 @retval EFI_SUCCESS A Firmware Management Protocol instance was\r
25 installed onto Handle.\r
26 @retval EFI_INVALID_PARAMETER Handle is invalid\r
27 @retval other A Firmware Management Protocol instance could\r
28 not be installed onto Handle.\r
29\r
30**/\r
31typedef\r
32EFI_STATUS\r
33(EFIAPI *FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER)(\r
34 IN EFI_HANDLE Handle\r
35 );\r
36\r
8d01f2f4
EJ
37/**\r
38 Callback function that uninstalls a Firmware Management Protocol instance from\r
39 a handle.\r
40\r
41 @param[in] Handle The device handle to uninstall a Firmware Management\r
42 Protocol instance.\r
43\r
44 @retval EFI_SUCCESS A Firmware Management Protocol instance was\r
45 uninstalled from Handle.\r
46 @retval EFI_INVALID_PARAMETER Handle is invalid\r
47 @retval other A Firmware Management Protocol instance could\r
48 not be uninstalled from Handle.\r
49\r
50**/\r
51typedef\r
52EFI_STATUS\r
53(EFIAPI *FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER)(\r
54 IN EFI_HANDLE Handle\r
55 );\r
56\r
cec7b8fb
KM
57/**\r
58 Provide a function to install the Firmware Management Protocol instance onto a\r
59 device handle when the device is managed by a driver that follows the UEFI\r
60 Driver Model. If the device is not managed by a driver that follows the UEFI\r
61 Driver Model, then EFI_UNSUPPORTED is returned.\r
62\r
63 @param[in] FmpInstaller Function that installs the Firmware Management\r
64 Protocol.\r
65\r
66 @retval EFI_SUCCESS The device is managed by a driver that follows the\r
67 UEFI Driver Model. FmpInstaller must be called on\r
68 each Driver Binding Start().\r
69 @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r
70 the UEFI Driver Model.\r
71 @retval other The Firmware Management Protocol for this firmware\r
72 device is not installed. The firmware device is\r
73 still locked using FmpDeviceLock().\r
74\r
75**/\r
76EFI_STATUS\r
77EFIAPI\r
78RegisterFmpInstaller (\r
79 IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER FmpInstaller\r
80 );\r
81\r
8d01f2f4
EJ
82/**\r
83 Provide a function to uninstall the Firmware Management Protocol instance from a\r
84 device handle when the device is managed by a driver that follows the UEFI\r
85 Driver Model. If the device is not managed by a driver that follows the UEFI\r
86 Driver Model, then EFI_UNSUPPORTED is returned.\r
87\r
88 @param[in] FmpUninstaller Function that installs the Firmware Management\r
89 Protocol.\r
90\r
91 @retval EFI_SUCCESS The device is managed by a driver that follows the\r
95d28836 92 UEFI Driver Model. FmpUninstaller must be called on\r
8d01f2f4
EJ
93 each Driver Binding Stop().\r
94 @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r
95 the UEFI Driver Model.\r
96 @retval other The Firmware Management Protocol for this firmware\r
97 device is not installed. The firmware device is\r
98 still locked using FmpDeviceLock().\r
99\r
100**/\r
101EFI_STATUS\r
102EFIAPI\r
103RegisterFmpUninstaller (\r
104 IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER FmpUninstaller\r
105 );\r
106\r
107/**\r
108 Set the device context for the FmpDeviceLib services when the device is\r
109 managed by a driver that follows the UEFI Driver Model. If the device is not\r
110 managed by a driver that follows the UEFI Driver Model, then EFI_UNSUPPORTED\r
111 is returned. Once a device context is set, the FmpDeviceLib services\r
112 operate on the currently set device context.\r
113\r
114 @param[in] Handle Device handle for the FmpDeviceLib services.\r
115 If Handle is NULL, then Context is freed.\r
116 @param[in, out] Context Device context for the FmpDeviceLib services.\r
117 If Context is NULL, then a new context is allocated\r
118 for Handle and the current device context is set and\r
119 returned in Context. If Context is not NULL, then\r
120 the current device context is set.\r
121\r
122 @retval EFI_SUCCESS The device is managed by a driver that follows the\r
123 UEFI Driver Model.\r
124 @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r
125 the UEFI Driver Model.\r
126 @retval other The Firmware Management Protocol for this firmware\r
127 device is not installed. The firmware device is\r
128 still locked using FmpDeviceLock().\r
129\r
130**/\r
131EFI_STATUS\r
132EFIAPI\r
133FmpDeviceSetContext (\r
134 IN EFI_HANDLE Handle,\r
135 IN OUT VOID **Context\r
136 );\r
137\r
cec7b8fb
KM
138/**\r
139 Returns the size, in bytes, of the firmware image currently stored in the\r
140 firmware device. This function is used to by the GetImage() and\r
141 GetImageInfo() services of the Firmware Management Protocol. If the image\r
142 size can not be determined from the firmware device, then 0 must be returned.\r
143\r
144 @param[out] Size Pointer to the size, in bytes, of the firmware image\r
145 currently stored in the firmware device.\r
146\r
147 @retval EFI_SUCCESS The size of the firmware image currently\r
148 stored in the firmware device was returned.\r
149 @retval EFI_INVALID_PARAMETER Size is NULL.\r
150 @retval EFI_UNSUPPORTED The firmware device does not support reporting\r
151 the size of the currently stored firmware image.\r
43622317 152 @retval EFI_DEVICE_ERROR An error occurred attempting to determine the\r
cec7b8fb
KM
153 size of the firmware image currently stored in\r
154 in the firmware device.\r
155\r
156**/\r
157EFI_STATUS\r
158EFIAPI\r
159FmpDeviceGetSize (\r
160 OUT UINTN *Size\r
161 );\r
162\r
163/**\r
164 Returns the GUID value used to fill in the ImageTypeId field of the\r
165 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
166 service of the Firmware Management Protocol. If EFI_UNSUPPORTED is returned,\r
167 then the ImageTypeId field is set to gEfiCallerIdGuid. If EFI_SUCCESS is\r
168 returned, then ImageTypeId is set to the Guid returned from this function.\r
169\r
170 @param[out] Guid Double pointer to a GUID value that is updated to point to\r
171 to a GUID value. The GUID value is not allocated and must\r
172 not be modified or freed by the caller.\r
173\r
174 @retval EFI_SUCCESS EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set\r
175 to the returned Guid value.\r
176 @retval EFI_UNSUPPORTED EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set\r
177 to gEfiCallerIdGuid.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182FmpDeviceGetImageTypeIdGuidPtr (\r
183 OUT EFI_GUID **Guid\r
184 );\r
185\r
186/**\r
187 Returns values used to fill in the AttributesSupported and AttributesSettings\r
188 fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the\r
189 GetImageInfo() service of the Firmware Management Protocol. The following\r
190 bit values from the Firmware Management Protocol may be combined:\r
191 IMAGE_ATTRIBUTE_IMAGE_UPDATABLE\r
192 IMAGE_ATTRIBUTE_RESET_REQUIRED\r
193 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED\r
194 IMAGE_ATTRIBUTE_IN_USE\r
195 IMAGE_ATTRIBUTE_UEFI_IMAGE\r
196\r
197 @param[out] Supported Attributes supported by this firmware device.\r
198 @param[out] Setting Attributes settings for this firmware device.\r
199\r
200 @retval EFI_SUCCESS The attributes supported by the firmware\r
201 device were returned.\r
202 @retval EFI_INVALID_PARAMETER Supported is NULL.\r
203 @retval EFI_INVALID_PARAMETER Setting is NULL.\r
204\r
205**/\r
206EFI_STATUS\r
207EFIAPI\r
208FmpDeviceGetAttributes (\r
a6d73269
SZ
209 OUT UINT64 *Supported,\r
210 OUT UINT64 *Setting\r
cec7b8fb
KM
211 );\r
212\r
213/**\r
214 Returns the value used to fill in the LowestSupportedVersion field of the\r
215 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
216 service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r
217 the firmware device supports a method to report the LowestSupportedVersion\r
218 value from the currently stored firmware image. If the value can not be\r
219 reported for the firmware image currently stored in the firmware device, then\r
220 EFI_UNSUPPORTED must be returned. EFI_DEVICE_ERROR is returned if an error\r
221 occurs attempting to retrieve the LowestSupportedVersion value for the\r
222 currently stored firmware image.\r
223\r
224 @note It is recommended that all firmware devices support a method to report\r
225 the LowestSupportedVersion value from the currently stored firmware\r
226 image.\r
227\r
228 @param[out] LowestSupportedVersion LowestSupportedVersion value retrieved\r
229 from the currently stored firmware image.\r
230\r
231 @retval EFI_SUCCESS The lowest supported version of currently stored\r
232 firmware image was returned in LowestSupportedVersion.\r
233 @retval EFI_UNSUPPORTED The firmware device does not support a method to\r
234 report the lowest supported version of the currently\r
235 stored firmware image.\r
236 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the lowest\r
237 supported version of the currently stored firmware\r
238 image.\r
239\r
240**/\r
241EFI_STATUS\r
242EFIAPI\r
243FmpDeviceGetLowestSupportedVersion (\r
244 OUT UINT32 *LowestSupportedVersion\r
245 );\r
246\r
247/**\r
248 Returns the Null-terminated Unicode string that is used to fill in the\r
249 VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is\r
250 returned by the GetImageInfo() service of the Firmware Management Protocol.\r
251 The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().\r
252\r
253 @note It is recommended that all firmware devices support a method to report\r
254 the VersionName string from the currently stored firmware image.\r
255\r
256 @param[out] VersionString The version string retrieved from the currently\r
257 stored firmware image.\r
258\r
259 @retval EFI_SUCCESS The version string of currently stored\r
260 firmware image was returned in Version.\r
261 @retval EFI_INVALID_PARAMETER VersionString is NULL.\r
262 @retval EFI_UNSUPPORTED The firmware device does not support a method\r
263 to report the version string of the currently\r
264 stored firmware image.\r
265 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r
266 version string of the currently stored\r
267 firmware image.\r
268 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the\r
269 buffer for the version string of the currently\r
270 stored firmware image.\r
271\r
272**/\r
273EFI_STATUS\r
274EFIAPI\r
275FmpDeviceGetVersionString (\r
276 OUT CHAR16 **VersionString\r
277 );\r
278\r
279/**\r
280 Returns the value used to fill in the Version field of the\r
281 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
282 service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r
283 the firmware device supports a method to report the Version value from the\r
284 currently stored firmware image. If the value can not be reported for the\r
285 firmware image currently stored in the firmware device, then EFI_UNSUPPORTED\r
286 must be returned. EFI_DEVICE_ERROR is returned if an error occurs attempting\r
287 to retrieve the LowestSupportedVersion value for the currently stored firmware\r
288 image.\r
289\r
290 @note It is recommended that all firmware devices support a method to report\r
291 the Version value from the currently stored firmware image.\r
292\r
293 @param[out] Version The version value retrieved from the currently stored\r
294 firmware image.\r
295\r
296 @retval EFI_SUCCESS The version of currently stored firmware image was\r
297 returned in Version.\r
298 @retval EFI_UNSUPPORTED The firmware device does not support a method to\r
299 report the version of the currently stored firmware\r
300 image.\r
301 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the version\r
302 of the currently stored firmware image.\r
303\r
304**/\r
305EFI_STATUS\r
306EFIAPI\r
307FmpDeviceGetVersion (\r
308 OUT UINT32 *Version\r
309 );\r
310\r
8d01f2f4
EJ
311/**\r
312 Returns the value used to fill in the HardwareInstance field of the\r
313 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
314 service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r
315 the firmware device supports a method to report the HardwareInstance value.\r
316 If the value can not be reported for the firmware device, then EFI_UNSUPPORTED\r
317 must be returned. EFI_DEVICE_ERROR is returned if an error occurs attempting\r
318 to retrieve the HardwareInstance value for the firmware device.\r
319\r
320 @param[out] HardwareInstance The hardware instance value for the firmware\r
321 device.\r
322\r
323 @retval EFI_SUCCESS The hardware instance for the current firmware\r
95d28836 324 device is returned in HardwareInstance.\r
8d01f2f4
EJ
325 @retval EFI_UNSUPPORTED The firmware device does not support a method to\r
326 report the hardware instance value.\r
327 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the hardware\r
328 instance value.\r
329\r
330**/\r
331EFI_STATUS\r
332EFIAPI\r
333FmpDeviceGetHardwareInstance (\r
334 OUT UINT64 *HardwareInstance\r
335 );\r
336\r
cec7b8fb
KM
337/**\r
338 Returns a copy of the firmware image currently stored in the firmware device.\r
339\r
340 @note It is recommended that all firmware devices support a method to retrieve\r
341 a copy currently stored firmware image. This can be used to support\r
342 features such as recovery and rollback.\r
343\r
a6d73269 344 @param[out] Image Pointer to a caller allocated buffer where the\r
cec7b8fb 345 currently stored firmware image is copied to.\r
a6d73269 346 @param[in, out] ImageSize Pointer the size, in bytes, of the Image buffer.\r
cec7b8fb
KM
347 On return, points to the size, in bytes, of firmware\r
348 image currently stored in the firmware device.\r
349\r
350 @retval EFI_SUCCESS Image contains a copy of the firmware image\r
351 currently stored in the firmware device, and\r
352 ImageSize contains the size, in bytes, of the\r
353 firmware image currently stored in the\r
354 firmware device.\r
355 @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small\r
356 to hold the firmware image currently stored in\r
357 the firmware device. The buffer size required\r
358 is returned in ImageSize.\r
359 @retval EFI_INVALID_PARAMETER The Image is NULL.\r
360 @retval EFI_INVALID_PARAMETER The ImageSize is NULL.\r
361 @retval EFI_UNSUPPORTED The operation is not supported.\r
362 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r
363 firmware image currently stored in the firmware\r
364 device.\r
365\r
366**/\r
367EFI_STATUS\r
368EFIAPI\r
369FmpDeviceGetImage (\r
a6d73269
SZ
370 OUT VOID *Image,\r
371 IN OUT UINTN *ImageSize\r
cec7b8fb
KM
372 );\r
373\r
374/**\r
375 Checks if a new firmware image is valid for the firmware device. This\r
376 function allows firmware update operation to validate the firmware image\r
377 before FmpDeviceSetImage() is called.\r
378\r
379 @param[in] Image Points to a new firmware image.\r
380 @param[in] ImageSize Size, in bytes, of a new firmware image.\r
381 @param[out] ImageUpdatable Indicates if a new firmware image is valid for\r
382 a firmware update to the firmware device. The\r
383 following values from the Firmware Management\r
384 Protocol are supported:\r
385 IMAGE_UPDATABLE_VALID\r
386 IMAGE_UPDATABLE_INVALID\r
387 IMAGE_UPDATABLE_INVALID_TYPE\r
388 IMAGE_UPDATABLE_INVALID_OLD\r
389 IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE\r
390\r
391 @retval EFI_SUCCESS The image was successfully checked. Additional\r
392 status information is returned in\r
a6d73269 393 ImageUpdatable.\r
cec7b8fb 394 @retval EFI_INVALID_PARAMETER Image is NULL.\r
a6d73269 395 @retval EFI_INVALID_PARAMETER ImageUpdatable is NULL.\r
cec7b8fb
KM
396\r
397**/\r
398EFI_STATUS\r
399EFIAPI\r
400FmpDeviceCheckImage (\r
401 IN CONST VOID *Image,\r
402 IN UINTN ImageSize,\r
a6d73269 403 OUT UINT32 *ImageUpdatable\r
cec7b8fb
KM
404 );\r
405\r
406/**\r
407 Updates a firmware device with a new firmware image. This function returns\r
408 EFI_UNSUPPORTED if the firmware image is not updatable. If the firmware image\r
409 is updatable, the function should perform the following minimal validations\r
410 before proceeding to do the firmware image update.\r
411 - Validate that the image is a supported image for this firmware device.\r
412 Return EFI_ABORTED if the image is not supported. Additional details\r
413 on why the image is not a supported image may be returned in AbortReason.\r
414 - Validate the data from VendorCode if is not NULL. Firmware image\r
415 validation must be performed before VendorCode data validation.\r
416 VendorCode data is ignored or considered invalid if image validation\r
417 fails. Return EFI_ABORTED if the VendorCode data is invalid.\r
418\r
419 VendorCode enables vendor to implement vendor-specific firmware image update\r
420 policy. Null if the caller did not specify the policy or use the default\r
421 policy. As an example, vendor can implement a policy to allow an option to\r
422 force a firmware image update when the abort reason is due to the new firmware\r
423 image version is older than the current firmware image version or bad image\r
424 checksum. Sensitive operations such as those wiping the entire firmware image\r
425 and render the device to be non-functional should be encoded in the image\r
426 itself rather than passed with the VendorCode. AbortReason enables vendor to\r
427 have the option to provide a more detailed description of the abort reason to\r
428 the caller.\r
429\r
430 @param[in] Image Points to the new firmware image.\r
431 @param[in] ImageSize Size, in bytes, of the new firmware image.\r
432 @param[in] VendorCode This enables vendor to implement vendor-specific\r
433 firmware image update policy. NULL indicates\r
434 the caller did not specify the policy or use the\r
435 default policy.\r
436 @param[in] Progress A function used to report the progress of\r
437 updating the firmware device with the new\r
438 firmware image.\r
439 @param[in] CapsuleFwVersion The version of the new firmware image from the\r
440 update capsule that provided the new firmware\r
441 image.\r
442 @param[out] AbortReason A pointer to a pointer to a Null-terminated\r
443 Unicode string providing more details on an\r
444 aborted operation. The buffer is allocated by\r
445 this function with\r
446 EFI_BOOT_SERVICES.AllocatePool(). It is the\r
447 caller's responsibility to free this buffer with\r
448 EFI_BOOT_SERVICES.FreePool().\r
449\r
450 @retval EFI_SUCCESS The firmware device was successfully updated\r
451 with the new firmware image.\r
452 @retval EFI_ABORTED The operation is aborted. Additional details\r
453 are provided in AbortReason.\r
454 @retval EFI_INVALID_PARAMETER The Image was NULL.\r
455 @retval EFI_UNSUPPORTED The operation is not supported.\r
456\r
457**/\r
458EFI_STATUS\r
459EFIAPI\r
460FmpDeviceSetImage (\r
461 IN CONST VOID *Image,\r
462 IN UINTN ImageSize,\r
463 IN CONST VOID *VendorCode, OPTIONAL\r
464 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL\r
465 IN UINT32 CapsuleFwVersion,\r
466 OUT CHAR16 **AbortReason\r
467 );\r
468\r
469/**\r
470 Lock the firmware device that contains a firmware image. Once a firmware\r
471 device is locked, any attempts to modify the firmware image contents in the\r
472 firmware device must fail.\r
473\r
474 @note It is recommended that all firmware devices support a lock method to\r
475 prevent modifications to a stored firmware image.\r
476\r
477 @note A firmware device lock mechanism is typically only cleared by a full\r
478 system reset (not just sleep state/low power mode).\r
479\r
480 @retval EFI_SUCCESS The firmware device was locked.\r
481 @retval EFI_UNSUPPORTED The firmware device does not support locking\r
482\r
483**/\r
484EFI_STATUS\r
485EFIAPI\r
486FmpDeviceLock (\r
487 VOID\r
488 );\r
489\r
490#endif\r