]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/Feature/Capsule/Library/FmpDeviceLib/FmpDeviceLib.c
Vlv2TbltDevicePkg/Capsule: Do not clear UEFI varstore
[mirror_edk2.git] / Vlv2TbltDevicePkg / Feature / Capsule / Library / FmpDeviceLib / FmpDeviceLib.c
CommitLineData
dc65dd5b
MK
1/**\r
2\r
447597f1
MK
3Copyright (c) 2016, Microsoft Corporation. All rights reserved.\r
4Copyright (c) 2019, Intel Corporation. All rights reserved.\r
dc65dd5b 5\r
9dc8036d 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
dc65dd5b
MK
7\r
8**/\r
9\r
10#include <PiDxe.h>\r
11\r
12#include <Library/FmpDeviceLib.h>\r
13\r
14#include <Library/DebugLib.h>\r
15#include <Library/BaseLib.h>\r
16#include <Library/BaseMemoryLib.h>\r
17#include <Library/MemoryAllocationLib.h>\r
18#include <Library/UefiBootServicesTableLib.h>\r
19\r
20#include <Library/PlatformFlashAccessLib.h>\r
21\r
22//#include <Protocol/FirmwareManagement.h>\r
23\r
24//#include <Guid/SystemResourceTable.h>\r
25\r
26typedef struct {\r
27 PLATFORM_FIRMWARE_TYPE FirmwareType;\r
28 FLASH_ADDRESS_TYPE AddressType;\r
29 EFI_PHYSICAL_ADDRESS BaseAddress;\r
30 UINTN Length;\r
31 UINTN ImageOffset;\r
32} UPDATE_CONFIG_DATA;\r
33\r
34UPDATE_CONFIG_DATA mUpdateConfigData[] = {\r
35 { PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00000000, 0x00040000, 0x00000000 },\r
36 { PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x000C0000, 0x00050000, 0x000C0000 },\r
37 { PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00110000, 0x00210000, 0x00110000 },\r
38 { PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00320000, 0x00070000, 0x00320000 },\r
447597f1 39 { PlatformFirmwareTypeSystemFirmware, FlashAddressTypeRelativeAddress, 0x00390000, 0x00070000, 0x00390000 }\r
dc65dd5b
MK
40};\r
41\r
42/**\r
43 Used to pass the FMP install function to this lib. This allows the library to\r
44 have control of the handle that the FMP instance is installed on. This allows\r
45 the library to use DriverBinding protocol model to locate its device(s) in the\r
46 system.\r
47\r
48 @param[in] Func Function pointer to FMP install function.\r
49\r
50 @retval EFI_SUCCESS Library has saved function pointer and will call\r
51 function pointer on each DriverBinding Start.\r
52 @retval EFI_UNSUPPORTED Library doesn't use driver binding and only supports\r
53 a single instance.\r
54 @retval other error Error occurred. Don't install FMP\r
55\r
56**/\r
57EFI_STATUS\r
58EFIAPI\r
59RegisterFmpInstaller (\r
60 IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER Func\r
61 )\r
62{\r
63 //\r
64 // This is a system firmware update that does not use Driver Binding Protocol\r
65 //\r
66 return EFI_UNSUPPORTED;\r
67}\r
68\r
69\r
70/**\r
71 Returns the size, in bytes, of the firmware image currently stored in the\r
72 firmware device. This function is used to by the GetImage() and\r
73 GetImageInfo() services of the Firmware Management Protocol. If the image\r
74 size can not be determined from the firmware device, then 0 must be returned.\r
75\r
76 @param[out] Size Pointer to the size, in bytes, of the firmware image\r
77 currently stored in the firmware device.\r
78\r
79 @retval EFI_SUCCESS The size of the firmware image currently\r
80 stored in the firmware device was returned.\r
81 @retval EFI_INVALID_PARAMETER Size is NULL.\r
82 @retval EFI_UNSUPPORTED The firmware device does not support reporting\r
83 the size of the currently stored firmware image.\r
84 @retval EFI_DEVICE_ERROR An error occured attempting to determine the\r
85 size of the firmware image currently stored in\r
86 in the firmware device.\r
87\r
88**/\r
89EFI_STATUS\r
90EFIAPI\r
91FmpDeviceGetSize (\r
92 IN UINTN *Size\r
93 )\r
94{\r
95 if (Size == NULL) {\r
96 return EFI_INVALID_PARAMETER;\r
97 }\r
98 *Size = PcdGet32 (PcdBiosRomBase);\r
99 return EFI_SUCCESS;\r
100}\r
101\r
102/**\r
103 Used to return a library supplied guid that will be the ImageTypeId guid of\r
104 the FMP descriptor. This is optional but can be used if at runtime the guid\r
105 needs to be determined.\r
106\r
107 @param[out] Guid Double Guid Ptr that will be updated to point to guid.\r
108 This should be from static memory and will not be freed.\r
109\r
110 @return EFI_UNSUPPORTED Library instance doesn't need dynamic guid.\r
111 @return Error Any error will cause the wrapper to use the GUID\r
112 defined by PCD.\r
113 @return EFI_SUCCESS Guid ptr should be updated to point to static memeory\r
114 which contains a valid guid.\r
115\r
116**/\r
117EFI_STATUS\r
118EFIAPI\r
119FmpDeviceGetImageTypeIdGuidPtr (\r
120 OUT EFI_GUID **Guid\r
121 )\r
122{\r
123 return EFI_UNSUPPORTED;\r
124}\r
125\r
126/**\r
127 Returns values used to fill in the AttributesSupported and AttributesSettings\r
128 fields of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the\r
129 GetImageInfo() service of the Firmware Management Protocol. The following\r
130 bit values from the Firmware Management Protocol may be combined:\r
131 IMAGE_ATTRIBUTE_IMAGE_UPDATABLE\r
132 IMAGE_ATTRIBUTE_RESET_REQUIRED\r
133 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED\r
134 IMAGE_ATTRIBUTE_IN_USE\r
135 IMAGE_ATTRIBUTE_UEFI_IMAGE\r
136\r
137 @param[out] Supported Attributes supported by this firmware device.\r
138 @param[out] Setting Attributes settings for this firmware device.\r
139\r
140 @retval EFI_SUCCESS The attributes supported by the firmware\r
141 device were returned.\r
142 @retval EFI_INVALID_PARAMETER Supported is NULL.\r
143 @retval EFI_INVALID_PARAMETER Setting is NULL.\r
144\r
145**/\r
146EFI_STATUS\r
147EFIAPI\r
148FmpDeviceGetAttributes (\r
149 IN OUT UINT64 *Supported,\r
150 IN OUT UINT64 *Setting\r
151 )\r
152{\r
153 if (Supported == NULL || Setting == NULL) {\r
154 return EFI_INVALID_PARAMETER;\r
155 }\r
156 *Supported = (IMAGE_ATTRIBUTE_IMAGE_UPDATABLE |\r
157 IMAGE_ATTRIBUTE_RESET_REQUIRED |\r
158 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED |\r
159 IMAGE_ATTRIBUTE_IN_USE\r
160 );\r
161 *Setting = (IMAGE_ATTRIBUTE_IMAGE_UPDATABLE |\r
162 IMAGE_ATTRIBUTE_RESET_REQUIRED |\r
163 IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED |\r
164 IMAGE_ATTRIBUTE_IN_USE\r
165 );\r
166 return EFI_SUCCESS;\r
167}\r
168\r
169/**\r
170 Gets the current Lowest Supported Version.\r
171\r
172 This is a protection mechanism so that a previous version with known issue is\r
173 not applied. ONLY implement this if your running firmware has a method to\r
174 return this at runtime. If EFI_UNSUPPORTED is returned, then the Lowest\r
175 Supported Version is stored in a UEFI Variable.\r
176\r
177 @param[out] Version On return this value represents the current Lowest\r
178 Supported Version (in same format as GetVersion).\r
179\r
180 @retval EFI_SUCCESS The Lowest Supported Version was correctly retrieved\r
181 @retval EFI_UNSUPPORTED Device firmware doesn't support reporting LSV\r
182 @retval EFI_DEVICE_ERROR Error occurred when trying to get the LSV\r
183**/\r
184EFI_STATUS\r
185EFIAPI\r
186FmpDeviceGetLowestSupportedVersion (\r
187 IN OUT UINT32 *LowestSupportedVersion\r
188 )\r
189{\r
190 //\r
191 // Retrieve the lowest support version from a PCD\r
192 // NOTE: This method of using a PCD can only be used for the system firmware\r
193 // FMP instance that is updated every time the system firmware is\r
194 // updated. If system firmware updates support partial updates that\r
195 // would not include the system firmware FMP instance, then a PCD can\r
196 // not be used and the value must come from the currently running system\r
197 // firmware image.\r
198 //\r
199 *LowestSupportedVersion = PcdGet32 (PcdSystemFirmwareFmpLowestSupportedVersion);\r
200 return EFI_SUCCESS;\r
201}\r
202\r
203\r
204/**\r
205 Returns the Null-terminated Unicode string that is used to fill in the\r
206 VersionName field of the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is\r
207 returned by the GetImageInfo() service of the Firmware Management Protocol.\r
208 The returned string must be allocated using EFI_BOOT_SERVICES.AllocatePool().\r
209\r
210 @note It is recommended that all firmware devices support a method to report\r
211 the VersionName string from the currently stored firmware image.\r
212\r
213 @param[out] VersionString The version string retrieved from the currently\r
214 stored firmware image.\r
215\r
216 @retval EFI_SUCCESS The version string of currently stored\r
217 firmware image was returned in Version.\r
218 @retval EFI_INVALID_PARAMETER VersionString is NULL.\r
219 @retval EFI_UNSUPPORTED The firmware device does not support a method\r
220 to report the version string of the currently\r
221 stored firmware image.\r
222 @retval EFI_DEVICE_ERROR An error occurred attempting to retrieve the\r
223 version string of the currently stored\r
224 firmware image.\r
225 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the\r
226 buffer for the version string of the currently\r
227 stored firmware image.\r
228\r
229**/\r
230EFI_STATUS\r
231EFIAPI\r
232FmpDeviceGetVersionString (\r
233 OUT CHAR16 **VersionString\r
234 )\r
235{\r
236 if (VersionString == NULL) {\r
237 return EFI_INVALID_PARAMETER;\r
238 }\r
239\r
240 //\r
241 // Retrieve the version string from a PCD\r
242 // NOTE: This method of using a PCD can only be used for the system firmware\r
243 // FMP instance that is updated every time the system firmware is\r
244 // updated. If system firmware updates support partial updates that\r
245 // would not include the system firmware FMP instance, then a PCD can\r
246 // not be used and the value must come from the currently running system\r
247 // firmware image.\r
248 //\r
249 *VersionString = (CHAR16 *)AllocateCopyPool (\r
250 PcdGetSize (PcdSystemFirmwareFmpVersionString),\r
251 PcdGetPtr (PcdSystemFirmwareFmpVersionString)\r
252 );\r
253 if (*VersionString == NULL) {\r
254 return EFI_OUT_OF_RESOURCES;\r
255 }\r
256 return EFI_SUCCESS;\r
257}\r
258\r
259/**\r
260 Gets the current running version.\r
261\r
262 ONLY implement this if your running firmware has a method to return this at\r
263 runtime.\r
264\r
265 @param[out] Version On return this value represents the current running\r
266 version.\r
267\r
268 @retval EFI_SUCCESS The version was correctly retrieved.\r
269 @retval EFI_UNSUPPORTED Device firmware doesn't support reporting current\r
270 version.\r
271 @retval EFI_DEVICE_ERROR Error occurred when trying to get the version.\r
272**/\r
273EFI_STATUS\r
274EFIAPI\r
275FmpDeviceGetVersion (\r
276 IN OUT UINT32 *Version\r
277 )\r
278{\r
279 //\r
280 // Retrieve the version string from a PCD\r
281 // NOTE: This method of using a PCD can only be used for the system firmware\r
282 // FMP instance that is updated every time the system firmware is\r
283 // updated. If system firmware updates support partial updates that\r
284 // would not include the system firmware FMP instance, then a PCD can\r
285 // not be used and the value must come from the currently running system\r
286 // firmware image.\r
287 //\r
288 *Version = PcdGet32 (PcdSystemFirmwareFmpVersion);\r
289 return EFI_SUCCESS;\r
290}\r
291\r
292\r
293/**\r
294 Retrieves a copy of the current firmware image of the device.\r
295\r
296 This function allows a copy of the current firmware image to be created and\r
297 saved. The saved copy could later been used, for example, in firmware image\r
298 recovery or rollback.\r
299\r
300 @param[out] Image Points to the buffer where the current image is copied\r
301 to.\r
302 @param[out] ImageSize On entry, points to the size of the buffer pointed to\r
303 by Image, in bytes. On return, points to the length of\r
304 the image, in bytes.\r
305\r
306 @retval EFI_SUCCESS The image was successfully read from the device.\r
307 @retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small\r
308 to hold the image. The current buffer size\r
309 needed to hold the image is returned in\r
310 ImageSize.\r
311 @retval EFI_INVALID_PARAMETER The Image was NULL.\r
312 @retval EFI_NOT_FOUND The current image is not copied to the buffer.\r
313 @retval EFI_UNSUPPORTED The operation is not supported.\r
314\r
315**/\r
316EFI_STATUS\r
317EFIAPI\r
318FmpDeviceGetImage (\r
319 IN OUT VOID *Image,\r
320 IN OUT UINTN *ImageSize\r
321 )\r
322{\r
323 //\r
324 // Check for invalid p;arameters\r
325 //\r
326 if (Image == NULL || ImageSize == NULL) {\r
327 return EFI_INVALID_PARAMETER;\r
328 }\r
329\r
330 //\r
331 // Make sure the buffer is big enough to hold the device image\r
332 //\r
333 if (*ImageSize < PcdGet32 (PcdBiosRomSize)) {\r
334 *ImageSize = PcdGet32 (PcdBiosRomSize);\r
335 return EFI_BUFFER_TOO_SMALL;\r
336 }\r
337\r
338 //\r
339 // Copy the device image to the buffer\r
340 //\r
341 *ImageSize = PcdGet32 (PcdBiosRomSize);\r
342 CopyMem (\r
343 Image,\r
344 (VOID *)(UINTN)PcdGet32 (PcdBiosRomBase),\r
345 *ImageSize\r
346 );\r
347\r
348 return EFI_SUCCESS;\r
349}\r
350\r
351/**\r
352 Updates the firmware image of the device.\r
353\r
354 This function updates the hardware with the new firmware image. This function\r
355 returns EFI_UNSUPPORTED if the firmware image is not updatable. If the\r
356 firmware image is updatable, the function should perform the following minimal\r
357 validations before proceeding to do the firmware image update.\r
358 - Validate the image is a supported image for this device. The function\r
359 returns EFI_ABORTED if the image is unsupported. The function can\r
360 optionally provide more detailed information on why the image is not a\r
361 supported image.\r
362 - Validate the data from VendorCode if not null. Image validation must be\r
363 performed before VendorCode data validation. VendorCode data is ignored\r
364 or considered invalid if image validation failed. The function returns\r
365 EFI_ABORTED if the data is invalid.\r
366\r
367 VendorCode enables vendor to implement vendor-specific firmware image update\r
368 policy. Null if the caller did not specify the policy or use the default\r
369 policy. As an example, vendor can implement a policy to allow an option to\r
370 force a firmware image update when the abort reason is due to the new firmware\r
371 image version is older than the current firmware image version or bad image\r
372 checksum. Sensitive operations such as those wiping the entire firmware image\r
373 and render the device to be non-functional should be encoded in the image\r
374 itself rather than passed with the VendorCode. AbortReason enables vendor to\r
375 have the option to provide a more detailed description of the abort reason to\r
376 the caller.\r
377\r
378 @param[in] Image Points to the new image.\r
379 @param[in] ImageSize Size of the new image in bytes.\r
380 @param[in] VendorCode This enables vendor to implement vendor-specific\r
381 firmware image update policy. Null indicates the\r
382 caller did not specify the policy or use the\r
383 default policy.\r
384 @param[in] Progress A function used by the driver to report the\r
385 progress of the firmware update.\r
386 @param[in] CapsuleFwVersion FMP Payload Header version of the image.\r
387 @param[out] AbortReason A pointer to a pointer to a null-terminated\r
388 string providing more details for the aborted\r
389 operation. The buffer is allocated by this\r
390 function with AllocatePool(), and it is the\r
391 caller's responsibility to free it with a call\r
392 to FreePool().\r
393\r
394 @retval EFI_SUCCESS The device was successfully updated with the\r
395 new image.\r
396 @retval EFI_ABORTED The operation is aborted.\r
397 @retval EFI_INVALID_PARAMETER The Image was NULL.\r
398 @retval EFI_UNSUPPORTED The operation is not supported.\r
399\r
400**/\r
401EFI_STATUS\r
402EFIAPI\r
403FmpDeviceSetImage (\r
404 IN CONST VOID *Image,\r
405 IN UINTN ImageSize,\r
406 IN CONST VOID *VendorCode,\r
407 IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,\r
408 IN UINT32 CapsuleFwVersion,\r
409 OUT CHAR16 **AbortReason\r
410 )\r
411{\r
412 EFI_STATUS Status;\r
413 UINT32 Updateable;\r
414 UINTN Percentage;\r
415 UINTN Index;\r
416 UPDATE_CONFIG_DATA *ConfigData;\r
417 UINTN TotalSize;\r
418 UINTN BytesWritten;\r
419\r
420 Updateable = 0;\r
421 Status = FmpDeviceCheckImage (Image, ImageSize, &Updateable);\r
422 if (EFI_ERROR (Status)) {\r
423 DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Check Image failed with %r.\n", Status));\r
424 return Status;\r
425 }\r
426\r
427 if (Updateable != IMAGE_UPDATABLE_VALID) {\r
428 DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Check Image returned that the Image was not valid for update. Updatable value = 0x%X.\n", Updateable));\r
429 return EFI_ABORTED;\r
430 }\r
431\r
432 if (Progress == NULL) {\r
433 DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Invalid progress callback\n"));\r
434 return EFI_INVALID_PARAMETER;\r
435 }\r
436\r
437 Status = Progress (15);\r
438 if (EFI_ERROR (Status)) {\r
439 DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Progress Callback failed with Status %r.\n", Status));\r
440 }\r
441\r
442 //\r
443 // Write the image to the firmware device\r
444 //\r
445 Progress (20);\r
446 if (EFI_ERROR (Status)) {\r
447 DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Progress Callback failed with Status %r.\n", Status));\r
448 }\r
449\r
450 //\r
451 // Simulate update with delays between progress updates\r
452 //\r
453 for (Percentage = 20; Percentage <= 100; Percentage++) {\r
454 //\r
455 // Wait 0.05 seconds\r
456 //\r
457// gBS->Stall (50000);\r
458\r
459// Progress (Percentage);\r
460// if (EFI_ERROR (Status)) {\r
461// DEBUG((DEBUG_ERROR, "FmpDeviceSetImage - Progress Callback failed with Status %r.\n", Status));\r
462// }\r
463 }\r
464\r
465 DEBUG ((DEBUG_INFO, "FmpDeviceSetImage - %d Images ...\n", ARRAY_SIZE (mUpdateConfigData)));\r
466\r
467 if (ARRAY_SIZE (mUpdateConfigData) == 0) {\r
468 DEBUG((DEBUG_INFO, "PlatformUpdate: BaseAddress - 0x%lx ImageOffset - 0x%x Length - 0x%x\n", 0, 0, ImageSize));\r
469 Status = PerformFlashWriteWithProgress (\r
470 PlatformFirmwareTypeSystemFirmware, // FirmwareType\r
471 0x00000000, // FlashAddress\r
472 FlashAddressTypeRelativeAddress, // FlashAddressType\r
473 (VOID *)(UINTN)Image, // Buffer\r
474 ImageSize, // BufferLength\r
475 Progress, // Progress\r
476 20, // StartPercentage\r
477 100 // EndPercentage\r
478 );\r
479 }\r
480\r
481\r
482 //\r
483 // Compute total size of update\r
484 //\r
485 for (Index = 0, TotalSize = 0; Index < ARRAY_SIZE (mUpdateConfigData); Index++) {\r
486 TotalSize += mUpdateConfigData[Index].Length;\r
487 }\r
488\r
489 BytesWritten = 0;\r
490 for (Index = 0, ConfigData = mUpdateConfigData; Index < ARRAY_SIZE (mUpdateConfigData); Index++, ConfigData++) {\r
491 DEBUG((DEBUG_INFO, "PlatformUpdate(%d): BaseAddress - 0x%lx ImageOffset - 0x%x Length - 0x%x\n",\r
492 Index,\r
493 ConfigData->BaseAddress,\r
494 ConfigData->ImageOffset,\r
495 ConfigData->Length\r
496 ));\r
497 Status = PerformFlashWriteWithProgress (\r
498 ConfigData->FirmwareType, // FirmwareType\r
499 ConfigData->BaseAddress, // FlashAddress\r
500 ConfigData->AddressType, // FlashAddressType\r
501 (VOID *)((UINTN)Image + (UINTN)ConfigData->ImageOffset), // Buffer\r
502 ConfigData->Length, // BufferLength\r
503 Progress, // Progress\r
504 20 + (BytesWritten * 80) / TotalSize, // StartPercentage\r
505 20 + ((BytesWritten + ConfigData->Length) * 80) / TotalSize // EndPercentage\r
506 );\r
507 if (EFI_ERROR(Status)) {\r
508 break;\r
509 }\r
510 BytesWritten += ConfigData->Length;\r
511 }\r
512\r
513 DEBUG ((DEBUG_INFO, "FmpDeviceSetImage - %r\n", Status));\r
514\r
515 return Status;\r
516}\r
517\r
518/**\r
519Checks if the firmware image is valid for the device.\r
520\r
521This function allows firmware update application to validate the firmware image without\r
522invoking the SetImage() first.\r
523\r
524@param[in] Image Points to the new image.\r
525@param[in] ImageSize Size of the new image in bytes.\r
526@param[out] ImageUpdatable Indicates if the new image is valid for update. It also provides,\r
527if available, additional information if the image is invalid.\r
528\r
529@retval EFI_SUCCESS The image was successfully checked.\r
530@retval EFI_INVALID_PARAMETER The Image was NULL.\r
531\r
532**/\r
533EFI_STATUS\r
534EFIAPI\r
535FmpDeviceCheckImage (\r
536 IN CONST VOID *Image,\r
537 IN UINTN ImageSize,\r
538 OUT UINT32 *ImageUpdateable\r
539 )\r
540{\r
541 if (ImageUpdateable == NULL) {\r
542 DEBUG((DEBUG_ERROR, "CheckImage - ImageUpdateable Pointer Parameter is NULL.\n"));\r
543 return EFI_INVALID_PARAMETER;\r
544 }\r
545\r
546 //\r
547 //Set to valid and then if any tests fail it will update this flag.\r
548 //\r
549 *ImageUpdateable = IMAGE_UPDATABLE_VALID;\r
550\r
551 if (Image == NULL) {\r
552 DEBUG((DEBUG_ERROR, "CheckImage - Image Pointer Parameter is NULL.\n"));\r
553 //\r
554 // Not sure if this is needed\r
555 //\r
556 *ImageUpdateable = IMAGE_UPDATABLE_INVALID;\r
557 return EFI_INVALID_PARAMETER;\r
558 }\r
559\r
560 //\r
561 // Make sure the image size is correct\r
562 //\r
563 if (ImageSize != PcdGet32 (PcdBiosRomSize)) {\r
564 *ImageUpdateable = IMAGE_UPDATABLE_INVALID;\r
565 return EFI_INVALID_PARAMETER;\r
566 }\r
567\r
568 return EFI_SUCCESS;\r
569}\r
570\r
571/**\r
572 Device firmware should trigger lock mechanism so that device fw can not be\r
573 updated or tampered with. This lock mechanism is generally only cleared by a\r
574 full system reset (not just sleep state/low power mode)\r
575\r
576 @retval EFI_SUCCESS The device was successfully locked.\r
577 @retval EFI_UNSUPPORTED The hardware device/firmware doesn't support locking\r
578\r
579**/\r
580EFI_STATUS\r
581EFIAPI\r
582FmpDeviceLock (\r
583 VOID\r
584 )\r
585{\r
586 DEBUG ((DEBUG_INFO, "VLV2: FmpDeviceLock() for system FLASH\n"));\r
587 // TODO: Add lock logic\r
588 return EFI_UNSUPPORTED;\r
589}\r