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