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