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