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