]>
Commit | Line | Data |
---|---|---|
a6d73269 | 1 | /** @file\r |
403d4bcd KM |
2 | Provides firmware device specific services to support updates of a firmware\r |
3 | image stored in a firmware device.\r | |
4 | \r | |
6ad819c1 | 5 | Copyright (c) Microsoft Corporation.<BR>\r |
1f06aa24 | 6 | Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>\r |
403d4bcd | 7 | \r |
bcef758c | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
403d4bcd KM |
9 | \r |
10 | **/\r | |
11 | \r | |
12 | #include <PiDxe.h>\r | |
6ad819c1 | 13 | #include <Guid/SystemResourceTable.h>\r |
403d4bcd KM |
14 | #include <Library/FmpDeviceLib.h>\r |
15 | \r | |
16 | /**\r | |
17 | Provide a function to install the Firmware Management Protocol instance onto a\r | |
18 | device handle when the device is managed by a driver that follows the UEFI\r | |
19 | Driver Model. If the device is not managed by a driver that follows the UEFI\r | |
20 | Driver Model, then EFI_UNSUPPORTED is returned.\r | |
21 | \r | |
22 | @param[in] FmpInstaller Function that installs the Firmware Management\r | |
23 | Protocol.\r | |
24 | \r | |
25 | @retval EFI_SUCCESS The device is managed by a driver that follows the\r | |
26 | UEFI Driver Model. FmpInstaller must be called on\r | |
27 | each Driver Binding Start().\r | |
28 | @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r | |
29 | the UEFI Driver Model.\r | |
30 | @retval other The Firmware Management Protocol for this firmware\r | |
31 | device is not installed. The firmware device is\r | |
32 | still locked using FmpDeviceLock().\r | |
33 | \r | |
34 | **/\r | |
35 | EFI_STATUS\r | |
36 | EFIAPI\r | |
37 | RegisterFmpInstaller (\r | |
38 | IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER Function\r | |
39 | )\r | |
40 | {\r | |
41 | return EFI_UNSUPPORTED;\r | |
42 | }\r | |
43 | \r | |
1f06aa24 EJ |
44 | /**\r |
45 | Provide a function to uninstall the Firmware Management Protocol instance from a\r | |
46 | device handle when the device is managed by a driver that follows the UEFI\r | |
47 | Driver Model. If the device is not managed by a driver that follows the UEFI\r | |
48 | Driver Model, then EFI_UNSUPPORTED is returned.\r | |
49 | \r | |
50 | @param[in] FmpUninstaller Function that installs the Firmware Management\r | |
51 | Protocol.\r | |
52 | \r | |
53 | @retval EFI_SUCCESS The device is managed by a driver that follows the\r | |
95d28836 | 54 | UEFI Driver Model. FmpUninstaller must be called on\r |
1f06aa24 EJ |
55 | each Driver Binding Stop().\r |
56 | @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r | |
57 | the UEFI Driver Model.\r | |
58 | @retval other The Firmware Management Protocol for this firmware\r | |
59 | device is not installed. The firmware device is\r | |
60 | still locked using FmpDeviceLock().\r | |
61 | \r | |
62 | **/\r | |
63 | EFI_STATUS\r | |
64 | EFIAPI\r | |
65 | RegisterFmpUninstaller (\r | |
66 | IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER Function\r | |
67 | )\r | |
68 | {\r | |
69 | return EFI_UNSUPPORTED;\r | |
70 | }\r | |
71 | \r | |
72 | /**\r | |
73 | Set the device context for the FmpDeviceLib services when the device is\r | |
74 | managed by a driver that follows the UEFI Driver Model. If the device is not\r | |
75 | managed by a driver that follows the UEFI Driver Model, then EFI_UNSUPPORTED\r | |
76 | is returned. Once a device context is set, the FmpDeviceLib services\r | |
77 | operate on the currently set device context.\r | |
78 | \r | |
79 | @param[in] Handle Device handle for the FmpDeviceLib services.\r | |
80 | If Handle is NULL, then Context is freed.\r | |
81 | @param[in, out] Context Device context for the FmpDeviceLib services.\r | |
82 | If Context is NULL, then a new context is allocated\r | |
83 | for Handle and the current device context is set and\r | |
84 | returned in Context. If Context is not NULL, then\r | |
85 | the current device context is set.\r | |
86 | \r | |
87 | @retval EFI_SUCCESS The device is managed by a driver that follows the\r | |
88 | UEFI Driver Model.\r | |
89 | @retval EFI_UNSUPPORTED The device is not managed by a driver that follows\r | |
90 | the UEFI Driver Model.\r | |
91 | @retval other The Firmware Management Protocol for this firmware\r | |
92 | device is not installed. The firmware device is\r | |
93 | still locked using FmpDeviceLock().\r | |
94 | \r | |
95 | **/\r | |
96 | EFI_STATUS\r | |
97 | EFIAPI\r | |
98 | FmpDeviceSetContext (\r | |
99 | IN EFI_HANDLE Handle,\r | |
100 | IN OUT VOID **Context\r | |
101 | )\r | |
102 | {\r | |
103 | return EFI_UNSUPPORTED;\r | |
104 | }\r | |
105 | \r | |
403d4bcd KM |
106 | /**\r |
107 | Returns the size, in bytes, of the firmware image currently stored in the\r | |
108 | firmware device. This function is used to by the GetImage() and\r | |
109 | GetImageInfo() services of the Firmware Management Protocol. If the image\r | |
110 | size can not be determined from the firmware device, then 0 must be returned.\r | |
111 | \r | |
112 | @param[out] Size Pointer to the size, in bytes, of the firmware image\r | |
113 | currently stored in the firmware device.\r | |
114 | \r | |
115 | @retval EFI_SUCCESS The size of the firmware image currently\r | |
116 | stored in the firmware device was returned.\r | |
117 | @retval EFI_INVALID_PARAMETER Size is NULL.\r | |
118 | @retval EFI_UNSUPPORTED The firmware device does not support reporting\r | |
119 | the size of the currently stored firmware image.\r | |
120 | @retval EFI_DEVICE_ERROR An error occurred attempting to determine the\r | |
121 | size of the firmware image currently stored in\r | |
122 | in the firmware device.\r | |
123 | \r | |
124 | **/\r | |
125 | EFI_STATUS\r | |
126 | EFIAPI\r | |
127 | FmpDeviceGetSize (\r | |
a6d73269 | 128 | OUT UINTN *Size\r |
403d4bcd KM |
129 | )\r |
130 | {\r | |
131 | if (Size == NULL) {\r | |
132 | return EFI_INVALID_PARAMETER;\r | |
133 | }\r | |
45ce0a67 | 134 | \r |
403d4bcd KM |
135 | *Size = 0;\r |
136 | return EFI_SUCCESS;\r | |
137 | }\r | |
138 | \r | |
139 | /**\r | |
140 | Returns the GUID value used to fill in the ImageTypeId field of the\r | |
141 | EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r | |
142 | service of the Firmware Management Protocol. If EFI_UNSUPPORTED is returned,\r | |
143 | then the ImageTypeId field is set to gEfiCallerIdGuid. If EFI_SUCCESS is\r | |
144 | returned, then ImageTypeId is set to the Guid returned from this function.\r | |
145 | \r | |
146 | @param[out] Guid Double pointer to a GUID value that is updated to point to\r | |
147 | to a GUID value. The GUID value is not allocated and must\r | |
148 | not be modified or freed by the caller.\r | |
149 | \r | |
150 | @retval EFI_SUCCESS EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set\r | |
151 | to the returned Guid value.\r | |
152 | @retval EFI_UNSUPPORTED EFI_FIRMWARE_IMAGE_DESCRIPTOR ImageTypeId GUID is set\r | |
153 | to gEfiCallerIdGuid.\r | |
154 | \r | |
155 | **/\r | |
156 | EFI_STATUS\r | |
157 | EFIAPI\r | |
158 | FmpDeviceGetImageTypeIdGuidPtr (\r | |
159 | OUT EFI_GUID **Guid\r | |
160 | )\r | |
161 | {\r | |
162 | return EFI_UNSUPPORTED;\r | |
163 | }\r | |
164 | \r | |
165 | /**\r | |
166 | Returns values used to fill in the AttributesSupported and AttributesSettings\r | |
167 | fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the\r | |
168 | GetImageInfo() service of the Firmware Management Protocol. The following\r | |
169 | bit values from the Firmware Management Protocol may be combined:\r | |
170 | IMAGE_ATTRIBUTE_IMAGE_UPDATABLE\r | |
171 | IMAGE_ATTRIBUTE_RESET_REQUIRED\r | |
172 | IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED\r | |
173 | IMAGE_ATTRIBUTE_IN_USE\r | |
174 | IMAGE_ATTRIBUTE_UEFI_IMAGE\r | |
175 | \r | |
176 | @param[out] Supported Attributes supported by this firmware device.\r | |
177 | @param[out] Setting Attributes settings for this firmware device.\r | |
178 | \r | |
179 | @retval EFI_SUCCESS The attributes supported by the firmware\r | |
180 | device were returned.\r | |
181 | @retval EFI_INVALID_PARAMETER Supported is NULL.\r | |
182 | @retval EFI_INVALID_PARAMETER Setting is NULL.\r | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | EFIAPI\r | |
187 | FmpDeviceGetAttributes (\r | |
45ce0a67 MK |
188 | OUT UINT64 *Supported,\r |
189 | OUT UINT64 *Setting\r | |
403d4bcd KM |
190 | )\r |
191 | {\r | |
45ce0a67 | 192 | if ((Supported == NULL) || (Setting == NULL)) {\r |
403d4bcd KM |
193 | return EFI_INVALID_PARAMETER;\r |
194 | }\r | |
45ce0a67 | 195 | \r |
403d4bcd KM |
196 | *Supported = 0;\r |
197 | *Setting = 0;\r | |
198 | return EFI_SUCCESS;\r | |
199 | }\r | |
200 | \r | |
201 | /**\r | |
202 | Returns the value used to fill in the LowestSupportedVersion field of the\r | |
203 | EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r | |
204 | service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r | |
205 | the firmware device supports a method to report the LowestSupportedVersion\r | |
206 | value from the currently stored firmware image. If the value can not be\r | |
207 | reported for the firmware image currently stored in the firmware device, then\r | |
208 | EFI_UNSUPPORTED must be returned. EFI_DEVICE_ERROR is returned if an error\r | |
209 | occurs attempting to retrieve the LowestSupportedVersion value for the\r | |
210 | currently stored firmware image.\r | |
211 | \r | |
212 | @note It is recommended that all firmware devices support a method to report\r | |
213 | the LowestSupportedVersion value from the currently stored firmware\r | |
214 | image.\r | |
215 | \r | |
216 | @param[out] LowestSupportedVersion LowestSupportedVersion value retrieved\r | |
217 | from the currently stored firmware image.\r | |
218 | \r | |
219 | @retval EFI_SUCCESS The lowest supported version of currently stored\r | |
220 | firmware image was returned in LowestSupportedVersion.\r | |
221 | @retval EFI_UNSUPPORTED The firmware device does not support a method to\r | |
222 | report the lowest supported version of the currently\r | |
223 | stored firmware image.\r | |
224 | @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the lowest\r | |
225 | supported version of the currently stored firmware\r | |
226 | image.\r | |
227 | \r | |
228 | **/\r | |
229 | EFI_STATUS\r | |
230 | EFIAPI\r | |
231 | FmpDeviceGetLowestSupportedVersion (\r | |
232 | OUT UINT32 *LowestSupportedVersion\r | |
233 | )\r | |
234 | {\r | |
235 | return EFI_UNSUPPORTED;\r | |
236 | }\r | |
237 | \r | |
238 | /**\r | |
239 | Returns the Null-terminated Unicode string that is used to fill in the\r | |
240 | VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is\r | |
241 | returned by the GetImageInfo() service of the Firmware Management Protocol.\r | |
242 | The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().\r | |
243 | \r | |
244 | @note It is recommended that all firmware devices support a method to report\r | |
245 | the VersionName string from the currently stored firmware image.\r | |
246 | \r | |
247 | @param[out] VersionString The version string retrieved from the currently\r | |
248 | stored firmware image.\r | |
249 | \r | |
250 | @retval EFI_SUCCESS The version string of currently stored\r | |
251 | firmware image was returned in Version.\r | |
252 | @retval EFI_INVALID_PARAMETER VersionString is NULL.\r | |
253 | @retval EFI_UNSUPPORTED The firmware device does not support a method\r | |
254 | to report the version string of the currently\r | |
255 | stored firmware image.\r | |
256 | @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r | |
257 | version string of the currently stored\r | |
258 | firmware image.\r | |
259 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the\r | |
260 | buffer for the version string of the currently\r | |
261 | stored firmware image.\r | |
262 | \r | |
263 | **/\r | |
264 | EFI_STATUS\r | |
265 | EFIAPI\r | |
266 | FmpDeviceGetVersionString (\r | |
267 | OUT CHAR16 **VersionString\r | |
268 | )\r | |
269 | {\r | |
270 | if (VersionString == NULL) {\r | |
271 | return EFI_INVALID_PARAMETER;\r | |
272 | }\r | |
45ce0a67 | 273 | \r |
403d4bcd KM |
274 | *VersionString = NULL;\r |
275 | return EFI_UNSUPPORTED;\r | |
276 | }\r | |
277 | \r | |
278 | /**\r | |
279 | Returns the value used to fill in the Version field of the\r | |
280 | EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r | |
281 | service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r | |
282 | the firmware device supports a method to report the Version value from the\r | |
283 | currently stored firmware image. If the value can not be reported for the\r | |
284 | firmware image currently stored in the firmware device, then EFI_UNSUPPORTED\r | |
285 | must be returned. EFI_DEVICE_ERROR is returned if an error occurs attempting\r | |
286 | to retrieve the LowestSupportedVersion value for the currently stored firmware\r | |
287 | image.\r | |
288 | \r | |
289 | @note It is recommended that all firmware devices support a method to report\r | |
290 | the Version value from the currently stored firmware image.\r | |
291 | \r | |
292 | @param[out] Version The version value retrieved from the currently stored\r | |
293 | firmware image.\r | |
294 | \r | |
295 | @retval EFI_SUCCESS The version of currently stored firmware image was\r | |
296 | returned in Version.\r | |
297 | @retval EFI_UNSUPPORTED The firmware device does not support a method to\r | |
298 | report the version of the currently stored firmware\r | |
299 | image.\r | |
300 | @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the version\r | |
301 | of the currently stored firmware image.\r | |
302 | \r | |
303 | **/\r | |
304 | EFI_STATUS\r | |
305 | EFIAPI\r | |
306 | FmpDeviceGetVersion (\r | |
307 | OUT UINT32 *Version\r | |
308 | )\r | |
309 | {\r | |
310 | return EFI_UNSUPPORTED;\r | |
311 | }\r | |
312 | \r | |
1f06aa24 EJ |
313 | /**\r |
314 | Returns the value used to fill in the HardwareInstance field of the\r | |
315 | EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r | |
316 | service of the Firmware Management Protocol. If EFI_SUCCESS is returned, then\r | |
317 | the firmware device supports a method to report the HardwareInstance value.\r | |
318 | If the value can not be reported for the firmware device, then EFI_UNSUPPORTED\r | |
319 | must be returned. EFI_DEVICE_ERROR is returned if an error occurs attempting\r | |
320 | to retrieve the HardwareInstance value for the firmware device.\r | |
321 | \r | |
322 | @param[out] HardwareInstance The hardware instance value for the firmware\r | |
323 | device.\r | |
324 | \r | |
325 | @retval EFI_SUCCESS The hardware instance for the current firmware\r | |
95d28836 | 326 | device is returned in HardwareInstance.\r |
1f06aa24 EJ |
327 | @retval EFI_UNSUPPORTED The firmware device does not support a method to\r |
328 | report the hardware instance value.\r | |
329 | @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the hardware\r | |
330 | instance value.\r | |
331 | \r | |
332 | **/\r | |
333 | EFI_STATUS\r | |
334 | EFIAPI\r | |
335 | FmpDeviceGetHardwareInstance (\r | |
336 | OUT UINT64 *HardwareInstance\r | |
337 | )\r | |
338 | {\r | |
339 | return EFI_UNSUPPORTED;\r | |
340 | }\r | |
341 | \r | |
403d4bcd KM |
342 | /**\r |
343 | Returns a copy of the firmware image currently stored in the firmware device.\r | |
344 | \r | |
345 | @note It is recommended that all firmware devices support a method to retrieve\r | |
346 | a copy currently stored firmware image. This can be used to support\r | |
347 | features such as recovery and rollback.\r | |
348 | \r | |
a6d73269 | 349 | @param[out] Image Pointer to a caller allocated buffer where the\r |
403d4bcd | 350 | currently stored firmware image is copied to.\r |
a6d73269 | 351 | @param[in, out] ImageSize Pointer the size, in bytes, of the Image buffer.\r |
403d4bcd KM |
352 | On return, points to the size, in bytes, of firmware\r |
353 | image currently stored in the firmware device.\r | |
354 | \r | |
355 | @retval EFI_SUCCESS Image contains a copy of the firmware image\r | |
356 | currently stored in the firmware device, and\r | |
357 | ImageSize contains the size, in bytes, of the\r | |
358 | firmware image currently stored in the\r | |
359 | firmware device.\r | |
360 | @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small\r | |
361 | to hold the firmware image currently stored in\r | |
362 | the firmware device. The buffer size required\r | |
363 | is returned in ImageSize.\r | |
364 | @retval EFI_INVALID_PARAMETER The Image is NULL.\r | |
365 | @retval EFI_INVALID_PARAMETER The ImageSize is NULL.\r | |
366 | @retval EFI_UNSUPPORTED The operation is not supported.\r | |
367 | @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r | |
368 | firmware image currently stored in the firmware\r | |
369 | device.\r | |
370 | \r | |
371 | **/\r | |
372 | EFI_STATUS\r | |
373 | EFIAPI\r | |
374 | FmpDeviceGetImage (\r | |
a6d73269 SZ |
375 | OUT VOID *Image,\r |
376 | IN OUT UINTN *ImageSize\r | |
403d4bcd KM |
377 | )\r |
378 | {\r | |
379 | return EFI_UNSUPPORTED;\r | |
380 | }\r | |
381 | \r | |
382 | /**\r | |
383 | Checks if a new firmware image is valid for the firmware device. This\r | |
384 | function allows firmware update operation to validate the firmware image\r | |
385 | before FmpDeviceSetImage() is called.\r | |
386 | \r | |
387 | @param[in] Image Points to a new firmware image.\r | |
388 | @param[in] ImageSize Size, in bytes, of a new firmware image.\r | |
389 | @param[out] ImageUpdatable Indicates if a new firmware image is valid for\r | |
390 | a firmware update to the firmware device. The\r | |
391 | following values from the Firmware Management\r | |
392 | Protocol are supported:\r | |
393 | IMAGE_UPDATABLE_VALID\r | |
394 | IMAGE_UPDATABLE_INVALID\r | |
395 | IMAGE_UPDATABLE_INVALID_TYPE\r | |
396 | IMAGE_UPDATABLE_INVALID_OLD\r | |
397 | IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE\r | |
398 | \r | |
399 | @retval EFI_SUCCESS The image was successfully checked. Additional\r | |
400 | status information is returned in\r | |
a6d73269 | 401 | ImageUpdatable.\r |
403d4bcd | 402 | @retval EFI_INVALID_PARAMETER Image is NULL.\r |
a6d73269 | 403 | @retval EFI_INVALID_PARAMETER ImageUpdatable is NULL.\r |
403d4bcd KM |
404 | \r |
405 | **/\r | |
406 | EFI_STATUS\r | |
407 | EFIAPI\r | |
408 | FmpDeviceCheckImage (\r | |
409 | IN CONST VOID *Image,\r | |
410 | IN UINTN ImageSize,\r | |
a6d73269 | 411 | OUT UINT32 *ImageUpdatable\r |
403d4bcd KM |
412 | )\r |
413 | {\r | |
6ad819c1 MK |
414 | UINT32 LastAttemptStatus;\r |
415 | \r | |
416 | return FmpDeviceCheckImageWithStatus (Image, ImageSize, ImageUpdatable, &LastAttemptStatus);\r | |
417 | }\r | |
418 | \r | |
419 | /**\r | |
420 | Checks if a new firmware image is valid for the firmware device. This\r | |
421 | function allows firmware update operation to validate the firmware image\r | |
422 | before FmpDeviceSetImage() is called.\r | |
423 | \r | |
424 | @param[in] Image Points to a new firmware image.\r | |
425 | @param[in] ImageSize Size, in bytes, of a new firmware image.\r | |
426 | @param[out] ImageUpdatable Indicates if a new firmware image is valid for\r | |
427 | a firmware update to the firmware device. The\r | |
428 | following values from the Firmware Management\r | |
429 | Protocol are supported:\r | |
430 | IMAGE_UPDATABLE_VALID\r | |
431 | IMAGE_UPDATABLE_INVALID\r | |
432 | IMAGE_UPDATABLE_INVALID_TYPE\r | |
433 | IMAGE_UPDATABLE_INVALID_OLD\r | |
434 | IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE\r | |
435 | @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt\r | |
436 | status to report back to the ESRT table in case\r | |
772c5bb8 | 437 | of error.\r |
6ad819c1 MK |
438 | \r |
439 | The return status code must fall in the range of\r | |
440 | LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to\r | |
441 | LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE.\r | |
442 | \r | |
443 | If the value falls outside this range, it will be converted\r | |
444 | to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL.\r | |
445 | \r | |
446 | @retval EFI_SUCCESS The image was successfully checked. Additional\r | |
447 | status information is returned in\r | |
448 | ImageUpdatable.\r | |
449 | @retval EFI_INVALID_PARAMETER Image is NULL.\r | |
450 | @retval EFI_INVALID_PARAMETER ImageUpdatable is NULL.\r | |
451 | \r | |
452 | **/\r | |
453 | EFI_STATUS\r | |
454 | EFIAPI\r | |
455 | FmpDeviceCheckImageWithStatus (\r | |
456 | IN CONST VOID *Image,\r | |
457 | IN UINTN ImageSize,\r | |
458 | OUT UINT32 *ImageUpdatable,\r | |
459 | OUT UINT32 *LastAttemptStatus\r | |
460 | )\r | |
461 | {\r | |
462 | *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;\r | |
463 | \r | |
403d4bcd KM |
464 | return EFI_SUCCESS;\r |
465 | }\r | |
466 | \r | |
467 | /**\r | |
468 | Updates a firmware device with a new firmware image. This function returns\r | |
469 | EFI_UNSUPPORTED if the firmware image is not updatable. If the firmware image\r | |
470 | is updatable, the function should perform the following minimal validations\r | |
471 | before proceeding to do the firmware image update.\r | |
472 | - Validate that the image is a supported image for this firmware device.\r | |
473 | Return EFI_ABORTED if the image is not supported. Additional details\r | |
474 | on why the image is not a supported image may be returned in AbortReason.\r | |
475 | - Validate the data from VendorCode if is not NULL. Firmware image\r | |
476 | validation must be performed before VendorCode data validation.\r | |
477 | VendorCode data is ignored or considered invalid if image validation\r | |
478 | fails. Return EFI_ABORTED if the VendorCode data is invalid.\r | |
479 | \r | |
480 | VendorCode enables vendor to implement vendor-specific firmware image update\r | |
481 | policy. Null if the caller did not specify the policy or use the default\r | |
482 | policy. As an example, vendor can implement a policy to allow an option to\r | |
483 | force a firmware image update when the abort reason is due to the new firmware\r | |
484 | image version is older than the current firmware image version or bad image\r | |
485 | checksum. Sensitive operations such as those wiping the entire firmware image\r | |
486 | and render the device to be non-functional should be encoded in the image\r | |
487 | itself rather than passed with the VendorCode. AbortReason enables vendor to\r | |
488 | have the option to provide a more detailed description of the abort reason to\r | |
489 | the caller.\r | |
490 | \r | |
491 | @param[in] Image Points to the new firmware image.\r | |
492 | @param[in] ImageSize Size, in bytes, of the new firmware image.\r | |
493 | @param[in] VendorCode This enables vendor to implement vendor-specific\r | |
494 | firmware image update policy. NULL indicates\r | |
495 | the caller did not specify the policy or use the\r | |
496 | default policy.\r | |
497 | @param[in] Progress A function used to report the progress of\r | |
498 | updating the firmware device with the new\r | |
499 | firmware image.\r | |
500 | @param[in] CapsuleFwVersion The version of the new firmware image from the\r | |
501 | update capsule that provided the new firmware\r | |
502 | image.\r | |
503 | @param[out] AbortReason A pointer to a pointer to a Null-terminated\r | |
504 | Unicode string providing more details on an\r | |
505 | aborted operation. The buffer is allocated by\r | |
506 | this function with\r | |
507 | EFI_BOOT_SERVICES.AllocatePool(). It is the\r | |
508 | caller's responsibility to free this buffer with\r | |
509 | EFI_BOOT_SERVICES.FreePool().\r | |
510 | \r | |
511 | @retval EFI_SUCCESS The firmware device was successfully updated\r | |
512 | with the new firmware image.\r | |
513 | @retval EFI_ABORTED The operation is aborted. Additional details\r | |
514 | are provided in AbortReason.\r | |
515 | @retval EFI_INVALID_PARAMETER The Image was NULL.\r | |
516 | @retval EFI_UNSUPPORTED The operation is not supported.\r | |
517 | \r | |
518 | **/\r | |
519 | EFI_STATUS\r | |
520 | EFIAPI\r | |
521 | FmpDeviceSetImage (\r | |
522 | IN CONST VOID *Image,\r | |
523 | IN UINTN ImageSize,\r | |
9c721071 MK |
524 | IN CONST VOID *VendorCode OPTIONAL,\r |
525 | IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL,\r | |
403d4bcd KM |
526 | IN UINT32 CapsuleFwVersion,\r |
527 | OUT CHAR16 **AbortReason\r | |
528 | )\r | |
529 | {\r | |
6ad819c1 MK |
530 | UINT32 LastAttemptStatus;\r |
531 | \r | |
45ce0a67 MK |
532 | return FmpDeviceSetImageWithStatus (\r |
533 | Image,\r | |
534 | ImageSize,\r | |
535 | VendorCode,\r | |
536 | Progress,\r | |
537 | CapsuleFwVersion,\r | |
538 | AbortReason,\r | |
539 | &LastAttemptStatus\r | |
540 | );\r | |
6ad819c1 MK |
541 | }\r |
542 | \r | |
543 | /**\r | |
544 | Updates a firmware device with a new firmware image. This function returns\r | |
545 | EFI_UNSUPPORTED if the firmware image is not updatable. If the firmware image\r | |
546 | is updatable, the function should perform the following minimal validations\r | |
547 | before proceeding to do the firmware image update.\r | |
548 | - Validate that the image is a supported image for this firmware device.\r | |
549 | Return EFI_ABORTED if the image is not supported. Additional details\r | |
550 | on why the image is not a supported image may be returned in AbortReason.\r | |
551 | - Validate the data from VendorCode if is not NULL. Firmware image\r | |
552 | validation must be performed before VendorCode data validation.\r | |
553 | VendorCode data is ignored or considered invalid if image validation\r | |
554 | fails. Return EFI_ABORTED if the VendorCode data is invalid.\r | |
555 | \r | |
556 | VendorCode enables vendor to implement vendor-specific firmware image update\r | |
557 | policy. Null if the caller did not specify the policy or use the default\r | |
558 | policy. As an example, vendor can implement a policy to allow an option to\r | |
559 | force a firmware image update when the abort reason is due to the new firmware\r | |
560 | image version is older than the current firmware image version or bad image\r | |
561 | checksum. Sensitive operations such as those wiping the entire firmware image\r | |
562 | and render the device to be non-functional should be encoded in the image\r | |
563 | itself rather than passed with the VendorCode. AbortReason enables vendor to\r | |
564 | have the option to provide a more detailed description of the abort reason to\r | |
565 | the caller.\r | |
566 | \r | |
567 | @param[in] Image Points to the new firmware image.\r | |
568 | @param[in] ImageSize Size, in bytes, of the new firmware image.\r | |
569 | @param[in] VendorCode This enables vendor to implement vendor-specific\r | |
570 | firmware image update policy. NULL indicates\r | |
571 | the caller did not specify the policy or use the\r | |
572 | default policy.\r | |
573 | @param[in] Progress A function used to report the progress of\r | |
574 | updating the firmware device with the new\r | |
575 | firmware image.\r | |
576 | @param[in] CapsuleFwVersion The version of the new firmware image from the\r | |
577 | update capsule that provided the new firmware\r | |
578 | image.\r | |
579 | @param[out] AbortReason A pointer to a pointer to a Null-terminated\r | |
580 | Unicode string providing more details on an\r | |
581 | aborted operation. The buffer is allocated by\r | |
582 | this function with\r | |
583 | EFI_BOOT_SERVICES.AllocatePool(). It is the\r | |
584 | caller's responsibility to free this buffer with\r | |
585 | EFI_BOOT_SERVICES.FreePool().\r | |
586 | @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt\r | |
587 | status to report back to the ESRT table in case\r | |
588 | of error. This value will only be checked when this\r | |
589 | function returns an error.\r | |
590 | \r | |
591 | The return status code must fall in the range of\r | |
592 | LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to\r | |
593 | LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE.\r | |
594 | \r | |
595 | If the value falls outside this range, it will be converted\r | |
596 | to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL.\r | |
597 | \r | |
598 | @retval EFI_SUCCESS The firmware device was successfully updated\r | |
599 | with the new firmware image.\r | |
600 | @retval EFI_ABORTED The operation is aborted. Additional details\r | |
601 | are provided in AbortReason.\r | |
602 | @retval EFI_INVALID_PARAMETER The Image was NULL.\r | |
603 | @retval EFI_UNSUPPORTED The operation is not supported.\r | |
604 | \r | |
605 | **/\r | |
606 | EFI_STATUS\r | |
607 | EFIAPI\r | |
608 | FmpDeviceSetImageWithStatus (\r | |
609 | IN CONST VOID *Image,\r | |
610 | IN UINTN ImageSize,\r | |
9c721071 MK |
611 | IN CONST VOID *VendorCode OPTIONAL,\r |
612 | IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL,\r | |
6ad819c1 MK |
613 | IN UINT32 CapsuleFwVersion,\r |
614 | OUT CHAR16 **AbortReason,\r | |
615 | OUT UINT32 *LastAttemptStatus\r | |
616 | )\r | |
617 | {\r | |
618 | *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;\r | |
619 | \r | |
403d4bcd KM |
620 | return EFI_UNSUPPORTED;\r |
621 | }\r | |
622 | \r | |
623 | /**\r | |
624 | Lock the firmware device that contains a firmware image. Once a firmware\r | |
625 | device is locked, any attempts to modify the firmware image contents in the\r | |
626 | firmware device must fail.\r | |
627 | \r | |
628 | @note It is recommended that all firmware devices support a lock method to\r | |
629 | prevent modifications to a stored firmware image.\r | |
630 | \r | |
631 | @note A firmware device lock mechanism is typically only cleared by a full\r | |
632 | system reset (not just sleep state/low power mode).\r | |
633 | \r | |
634 | @retval EFI_SUCCESS The firmware device was locked.\r | |
635 | @retval EFI_UNSUPPORTED The firmware device does not support locking\r | |
636 | \r | |
637 | **/\r | |
638 | EFI_STATUS\r | |
639 | EFIAPI\r | |
640 | FmpDeviceLock (\r | |
641 | VOID\r | |
642 | )\r | |
643 | {\r | |
644 | return EFI_UNSUPPORTED;\r | |
645 | }\r |