]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/FirmwareManagement.h
Add IMAGE_ATTRIBUTE_UEFI_IMAGE definition from UEFI 2.4 specification.
[mirror_edk2.git] / MdePkg / Include / Protocol / FirmwareManagement.h
1 /** @file
2 UEFI Firmware Management Protocol definition
3 Firmware Management Protocol provides an abstraction for device to provide firmware
4 management support. The base requirements for managing device firmware images include
5 identifying firmware image revision level and programming the image into the device.
6
7 GetImageInfo() is the only required function. GetImage(), SetImage(),
8 CheckImage(), GetPackageInfo(), and SetPackageInfo() shall return
9 EFI_UNSUPPORTED if not supported by the driver.
10
11 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
12 Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.<BR>
13 This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php
17
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20
21 @par Revision Reference:
22 This Protocol is introduced in UEFI Specification 2.3
23
24 **/
25
26 #ifndef __EFI_FIRMWARE_MANAGEMENT_PROTOCOL_H__
27 #define __EFI_FIRMWARE_MANAGEMENT_PROTOCOL_H__
28
29
30 #define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \
31 { \
32 0x86c77a67, 0xb97, 0x4633, {0xa1, 0x87, 0x49, 0x10, 0x4d, 0x6, 0x85, 0xc7 } \
33 }
34
35 typedef struct _EFI_FIRMWARE_MANAGEMENT_PROTOCOL EFI_FIRMWARE_MANAGEMENT_PROTOCOL;
36
37 ///
38 /// EFI_FIRMWARE_IMAGE_DESCRIPTOR
39 ///
40 typedef struct {
41 ///
42 /// A unique number identifying the firmware image within the device. The number is
43 /// between 1 and DescriptorCount.
44 ///
45 UINT8 ImageIndex;
46 ///
47 /// A unique number identifying the firmware image type.
48 ///
49 EFI_GUID ImageTypeId;
50 ///
51 /// A unique number identifying the firmware image.
52 ///
53 UINT64 ImageId;
54 ///
55 /// A pointer to a null-terminated string representing the firmware image name.
56 ///
57 CHAR16 *ImageIdName;
58 ///
59 /// Identifies the version of the device firmware. The format is vendor specific and new
60 /// version must have a greater value than an old version.
61 ///
62 UINT32 Version;
63 ///
64 /// A pointer to a null-terminated string representing the firmware image version name.
65 ///
66 CHAR16 *VersionName;
67 ///
68 /// Size of the image in bytes. If size=0, then only ImageIndex and ImageTypeId are valid.
69 ///
70 UINTN Size;
71 ///
72 /// Image attributes that are supported by this device. See 'Image Attribute Definitions'
73 /// for possible returned values of this parameter. A value of 1 indicates the attribute is
74 /// supported and the current setting value is indicated in AttributesSetting. A
75 /// value of 0 indicates the attribute is not supported and the current setting value in
76 /// AttributesSetting is meaningless.
77 ///
78 UINT64 AttributesSupported;
79 ///
80 /// Image attributes. See 'Image Attribute Definitions' for possible returned values of
81 /// this parameter.
82 ///
83 UINT64 AttributesSetting;
84 ///
85 /// Image compatibilities. See 'Image Compatibility Definitions' for possible returned
86 /// values of this parameter.
87 ///
88 UINT64 Compatibilities;
89 ///
90 /// Describes the lowest ImageDescriptor version that the device will accept. Only
91 /// present in version 2 or higher.
92 ///
93 UINT32 LowestSupportedImageVersion;
94 } EFI_FIRMWARE_IMAGE_DESCRIPTOR;
95
96
97 //
98 // Image Attribute Definitions
99 //
100 ///
101 /// The attribute IMAGE_ATTRIBUTE_IMAGE_UPDATABLE indicates this device supports firmware
102 /// image update.
103 ///
104 #define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001
105 ///
106 /// The attribute IMAGE_ATTRIBUTE_RESET_REQUIRED indicates a reset of the device is required
107 /// for the new firmware image to take effect after a firmware update. The device is the device hosting
108 /// the firmware image.
109 ///
110 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002
111 ///
112 /// The attribute IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED indicates authentication is
113 /// required to perform the following image operations: GetImage(), SetImage(), and
114 /// CheckImage(). See 'Image Attribute - Authentication'.
115 ///
116 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004
117 ///
118 /// The attribute IMAGE_ATTRIBUTE_IN_USE indicates the current state of the firmware image.
119 /// This distinguishes firmware images in a device that supports redundant images.
120 ///
121 #define IMAGE_ATTRIBUTE_IN_USE 0x0000000000000008
122 ///
123 /// The attribute IMAGE_ATTRIBUTE_UEFI_IMAGE indicates that this image is an EFI compatible image.
124 ///
125 #define IMAGE_ATTRIBUTE_UEFI_IMAGE 0x0000000000000010
126
127
128 //
129 // Image Compatibility Definitions
130 //
131 /// Values from 0x0000000000000002 thru 0x000000000000FFFF are reserved for future assignments.
132 /// Values from 0x0000000000010000 thru 0xFFFFFFFFFFFFFFFF are used by firmware vendor for
133 /// compatibility check.
134 ///
135 #define IMAGE_COMPATIBILITY_CHECK_SUPPORTED 0x0000000000000001
136
137 ///
138 /// Descriptor Version exposed by GetImageInfo() function
139 ///
140 #define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION 2
141
142
143 ///
144 /// Image Attribute -Authentication Required
145 ///
146 typedef struct {
147 ///
148 /// It is included in the signature of AuthInfo. It is used to ensure freshness/no replay.
149 /// It is incremented during each firmware image operation.
150 ///
151 UINT64 MonotonicCount;
152 ///
153 /// Provides the authorization for the firmware image operations. It is a signature across
154 /// the image data and the Monotonic Count value. Caller uses the private key that is
155 /// associated with a public key that has been provisioned via the key exchange.
156 /// Because this is defined as a signature, WIN_CERTIFICATE_UEFI_GUID.CertType must
157 /// be EFI_CERT_TYPE_PKCS7_GUID.
158 ///
159 WIN_CERTIFICATE_UEFI_GUID AuthInfo;
160 } EFI_FIRMWARE_IMAGE_AUTHENTICATION;
161
162
163 //
164 // ImageUpdatable Definitions
165 //
166 ///
167 /// IMAGE_UPDATABLE_VALID indicates SetImage() will accept the new image and update the
168 /// device with the new image.
169 ///
170 #define IMAGE_UPDATABLE_VALID 0x0000000000000001
171 ///
172 /// IMAGE_UPDATABLE_INVALID indicates SetImage() will reject the new image. No additional
173 /// information is provided for the rejection.
174 ///
175 #define IMAGE_UPDATABLE_INVALID 0x0000000000000002
176 ///
177 /// IMAGE_UPDATABLE_INVALID_TYPE indicates SetImage() will reject the new image. The
178 /// rejection is due to the new image is not a firmware image recognized for this device.
179 ///
180 #define IMAGE_UPDATABLE_INVALID_TYPE 0x0000000000000004
181 ///
182 /// IMAGE_UPDATABLE_INVALID_OLD indicates SetImage() will reject the new image. The
183 /// rejection is due to the new image version is older than the current firmware image
184 /// version in the device. The device firmware update policy does not support firmware
185 /// version downgrade.
186 ///
187 #define IMAGE_UPDATABLE_INVALID_OLD 0x0000000000000008
188
189
190 //
191 // Package Attribute Definitions
192 //
193 ///
194 /// The attribute PACKAGE_ATTRIBUTE_VERSION_UPDATABLE indicates this device supports the
195 /// update of the firmware package version.
196 ///
197 #define PACKAGE_ATTRIBUTE_VERSION_UPDATABLE 0x0000000000000001
198 ///
199 /// The attribute PACKAGE_ATTRIBUTE_RESET_REQUIRED indicates a reset of the device is
200 /// required for the new package info to take effect after an update.
201 ///
202 #define PACKAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002
203 ///
204 /// The attribute PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED indicates authentication
205 /// is required to update the package info.
206 ///
207 #define PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004
208
209 /**
210 Callback funtion to report the process of the firmware updating.
211
212 @param[in] Completion A value between 1 and 100 indicating the current completion
213 progress of the firmware update. Completion progress is
214 reported as from 1 to 100 percent. A value of 0 is used by
215 the driver to indicate that progress reporting is not supported.
216
217 @retval EFI_SUCCESS SetImage() continues to do the callback if supported.
218 @retval other SetImage() discontinues the callback and completes
219 the update and returns.
220
221 **/
222 typedef
223 EFI_STATUS
224 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS)(
225 IN UINTN Completion
226 );
227
228 /**
229 Returns information about the current firmware image(s) of the device.
230
231 This function allows a copy of the current firmware image to be created and saved.
232 The saved copy could later been used, for example, in firmware image recovery or rollback.
233
234 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
235 @param[in, out] ImageInfoSize A pointer to the size, in bytes, of the ImageInfo buffer.
236 On input, this is the size of the buffer allocated by the caller.
237 On output, it is the size of the buffer returned by the firmware
238 if the buffer was large enough, or the size of the buffer needed
239 to contain the image(s) information if the buffer was too small.
240 @param[in, out] ImageInfo A pointer to the buffer in which firmware places the current image(s)
241 information. The information is an array of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
242 @param[out] DescriptorVersion A pointer to the location in which firmware returns the version number
243 associated with the EFI_FIRMWARE_IMAGE_DESCRIPTOR.
244 @param[out] DescriptorCount A pointer to the location in which firmware returns the number of
245 descriptors or firmware images within this device.
246 @param[out] DescriptorSize A pointer to the location in which firmware returns the size, in bytes,
247 of an individual EFI_FIRMWARE_IMAGE_DESCRIPTOR.
248 @param[out] PackageVersion A version number that represents all the firmware images in the device.
249 The format is vendor specific and new version must have a greater value
250 than the old version. If PackageVersion is not supported, the value is
251 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version comparison
252 is to be performed using PackageVersionName. A value of 0xFFFFFFFD indicates
253 that package version update is in progress.
254 @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing the
255 package version name. The buffer is allocated by this function with
256 AllocatePool(), and it is the caller's responsibility to free it with a call
257 to FreePool().
258
259 @retval EFI_SUCCESS The device was successfully updated with the new image.
260 @retval EFI_BUFFER_TOO_SMALL The ImageInfo buffer was too small. The current buffer size
261 needed to hold the image(s) information is returned in ImageInfoSize.
262 @retval EFI_INVALID_PARAMETER ImageInfoSize is NULL.
263 @retval EFI_DEVICE_ERROR Valid information could not be returned. Possible corrupted image.
264
265 **/
266 typedef
267 EFI_STATUS
268 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GET_IMAGE_INFO)(
269 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
270 IN OUT UINTN *ImageInfoSize,
271 IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
272 OUT UINT32 *DescriptorVersion,
273 OUT UINT8 *DescriptorCount,
274 OUT UINTN *DescriptorSize,
275 OUT UINT32 *PackageVersion,
276 OUT CHAR16 **PackageVersionName
277 );
278
279 /**
280 Retrieves a copy of the current firmware image of the device.
281
282 This function allows a copy of the current firmware image to be created and saved.
283 The saved copy could later been used, for example, in firmware image recovery or rollback.
284
285 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
286 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.
287 The number is between 1 and DescriptorCount.
288 @param[out] Image Points to the buffer where the current image is copied to.
289 @param[out] ImageSize On entry, points to the size of the buffer pointed to by Image, in bytes.
290 On return, points to the length of the image, in bytes.
291
292 @retval EFI_SUCCESS The device was successfully updated with the new image.
293 @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to hold the
294 image. The current buffer size needed to hold the image is returned
295 in ImageSize.
296 @retval EFI_INVALID_PARAMETER The Image was NULL.
297 @retval EFI_NOT_FOUND The current image is not copied to the buffer.
298 @retval EFI_UNSUPPORTED The operation is not supported.
299 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
300
301 **/
302 typedef
303 EFI_STATUS
304 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GET_IMAGE)(
305 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
306 IN UINT8 ImageIndex,
307 IN OUT VOID *Image,
308 IN OUT UINTN *ImageSize
309 );
310
311 /**
312 Updates the firmware image of the device.
313
314 This function updates the hardware with the new firmware image.
315 This function returns EFI_UNSUPPORTED if the firmware image is not updatable.
316 If the firmware image is updatable, the function should perform the following minimal validations
317 before proceeding to do the firmware image update.
318 - Validate the image authentication if image has attribute
319 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED. The function returns
320 EFI_SECURITY_VIOLATION if the validation fails.
321 - Validate the image is a supported image for this device. The function returns EFI_ABORTED if
322 the image is unsupported. The function can optionally provide more detailed information on
323 why the image is not a supported image.
324 - Validate the data from VendorCode if not null. Image validation must be performed before
325 VendorCode data validation. VendorCode data is ignored or considered invalid if image
326 validation failed. The function returns EFI_ABORTED if the data is invalid.
327
328 VendorCode enables vendor to implement vendor-specific firmware image update policy. Null if
329 the caller did not specify the policy or use the default policy. As an example, vendor can implement
330 a policy to allow an option to force a firmware image update when the abort reason is due to the new
331 firmware image version is older than the current firmware image version or bad image checksum.
332 Sensitive operations such as those wiping the entire firmware image and render the device to be
333 non-functional should be encoded in the image itself rather than passed with the VendorCode.
334 AbortReason enables vendor to have the option to provide a more detailed description of the abort
335 reason to the caller.
336
337 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
338 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.
339 The number is between 1 and DescriptorCount.
340 @param[in] Image Points to the new image.
341 @param[in] ImageSize Size of the new image in bytes.
342 @param[in] VendorCode This enables vendor to implement vendor-specific firmware image update policy.
343 Null indicates the caller did not specify the policy or use the default policy.
344 @param[in] Progress A function used by the driver to report the progress of the firmware update.
345 @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more
346 details for the aborted operation. The buffer is allocated by this function
347 with AllocatePool(), and it is the caller's responsibility to free it with a
348 call to FreePool().
349
350 @retval EFI_SUCCESS The device was successfully updated with the new image.
351 @retval EFI_ABORTED The operation is aborted.
352 @retval EFI_INVALID_PARAMETER The Image was NULL.
353 @retval EFI_UNSUPPORTED The operation is not supported.
354 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
355
356 **/
357 typedef
358 EFI_STATUS
359 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_PROTOCOL_SET_IMAGE)(
360 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
361 IN UINT8 ImageIndex,
362 IN CONST VOID *Image,
363 IN UINTN ImageSize,
364 IN CONST VOID *VendorCode,
365 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
366 OUT CHAR16 **AbortReason
367 );
368
369 /**
370 Checks if the firmware image is valid for the device.
371
372 This function allows firmware update application to validate the firmware image without
373 invoking the SetImage() first.
374
375 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
376 @param[in] ImageIndex A unique number identifying the firmware image(s) within the device.
377 The number is between 1 and DescriptorCount.
378 @param[in] Image Points to the new image.
379 @param[in] ImageSize Size of the new image in bytes.
380 @param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides,
381 if available, additional information if the image is invalid.
382
383 @retval EFI_SUCCESS The image was successfully checked.
384 @retval EFI_INVALID_PARAMETER The Image was NULL.
385 @retval EFI_UNSUPPORTED The operation is not supported.
386 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
387
388 **/
389 typedef
390 EFI_STATUS
391 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_PROTOCOL_CHECK_IMAGE)(
392 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
393 IN UINT8 ImageIndex,
394 IN CONST VOID *Image,
395 IN UINTN ImageSize,
396 OUT UINT32 *ImageUpdatable
397 );
398
399 /**
400 Returns information about the firmware package.
401
402 This function returns package information.
403
404 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
405 @param[out] PackageVersion A version number that represents all the firmware images in the device.
406 The format is vendor specific and new version must have a greater value
407 than the old version. If PackageVersion is not supported, the value is
408 0xFFFFFFFF. A value of 0xFFFFFFFE indicates that package version
409 comparison is to be performed using PackageVersionName. A value of
410 0xFFFFFFFD indicates that package version update is in progress.
411 @param[out] PackageVersionName A pointer to a pointer to a null-terminated string representing
412 the package version name. The buffer is allocated by this function with
413 AllocatePool(), and it is the caller's responsibility to free it with a
414 call to FreePool().
415 @param[out] PackageVersionNameMaxLen The maximum length of package version name if device supports update of
416 package version name. A value of 0 indicates the device does not support
417 update of package version name. Length is the number of Unicode characters,
418 including the terminating null character.
419 @param[out] AttributesSupported Package attributes that are supported by this device. See 'Package Attribute
420 Definitions' for possible returned values of this parameter. A value of 1
421 indicates the attribute is supported and the current setting value is
422 indicated in AttributesSetting. A value of 0 indicates the attribute is not
423 supported and the current setting value in AttributesSetting is meaningless.
424 @param[out] AttributesSetting Package attributes. See 'Package Attribute Definitions' for possible returned
425 values of this parameter
426
427 @retval EFI_SUCCESS The package information was successfully returned.
428 @retval EFI_UNSUPPORTED The operation is not supported.
429
430 **/
431 typedef
432 EFI_STATUS
433 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GET_PACKAGE_INFO)(
434 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
435 OUT UINT32 *PackageVersion,
436 OUT CHAR16 **PackageVersionName,
437 OUT UINT32 *PackageVersionNameMaxLen,
438 OUT UINT64 *AttributesSupported,
439 OUT UINT64 *AttributesSetting
440 );
441
442 /**
443 Updates information about the firmware package.
444
445 This function updates package information.
446 This function returns EFI_UNSUPPORTED if the package information is not updatable.
447 VendorCode enables vendor to implement vendor-specific package information update policy.
448 Null if the caller did not specify this policy or use the default policy.
449
450 @param[in] This A pointer to the EFI_FIRMWARE_MANAGEMENT_PROTOCOL instance.
451 @param[in] Image Points to the authentication image.
452 Null if authentication is not required.
453 @param[in] ImageSize Size of the authentication image in bytes.
454 0 if authentication is not required.
455 @param[in] VendorCode This enables vendor to implement vendor-specific firmware
456 image update policy.
457 Null indicates the caller did not specify this policy or use
458 the default policy.
459 @param[in] PackageVersion The new package version.
460 @param[in] PackageVersionName A pointer to the new null-terminated Unicode string representing
461 the package version name.
462 The string length is equal to or less than the value returned in
463 PackageVersionNameMaxLen.
464
465 @retval EFI_SUCCESS The device was successfully updated with the new package
466 information.
467 @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value
468 returned in PackageVersionNameMaxLen.
469 @retval EFI_UNSUPPORTED The operation is not supported.
470 @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure.
471
472 **/
473 typedef
474 EFI_STATUS
475 (EFIAPI *EFI_FIRMWARE_MANAGEMENT_PROTOCOL_SET_PACKAGE_INFO)(
476 IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
477 IN CONST VOID *Image,
478 IN UINTN ImageSize,
479 IN CONST VOID *VendorCode,
480 IN UINT32 PackageVersion,
481 IN CONST CHAR16 *PackageVersionName
482 );
483
484 ///
485 /// EFI_FIRMWARE_MANAGEMENT_PROTOCOL
486 /// The protocol for managing firmware provides the following services.
487 /// - Get the attributes of the current firmware image. Attributes include revision level.
488 /// - Get a copy of the current firmware image. As an example, this service could be used by a
489 /// management application to facilitate a firmware roll-back.
490 /// - Program the device with a firmware image supplied by the user.
491 /// - Label all the firmware images within a device with a single version.
492 ///
493 struct _EFI_FIRMWARE_MANAGEMENT_PROTOCOL {
494 EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GET_IMAGE_INFO GetImageInfo;
495 EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GET_IMAGE GetImage;
496 EFI_FIRMWARE_MANAGEMENT_PROTOCOL_SET_IMAGE SetImage;
497 EFI_FIRMWARE_MANAGEMENT_PROTOCOL_CHECK_IMAGE CheckImage;
498 EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GET_PACKAGE_INFO GetPackageInfo;
499 EFI_FIRMWARE_MANAGEMENT_PROTOCOL_SET_PACKAGE_INFO SetPackageInfo;
500 };
501
502 extern EFI_GUID gEfiFirmwareManagementProtocolGuid;
503
504 #endif