TianoCore EDK2 master
Loading...
Searching...
No Matches
FmpDxe.c
Go to the documentation of this file.
1
13#include "FmpDxe.h"
14#include "VariableSupport.h"
15
24 0x78ef0a56, 0x1cf0, 0x4535, { 0xb5, 0xda, 0xf6, 0xfd, 0x2f, 0x40, 0x5a, 0x11 }
25};
26
31
37
38//
39// Template of the private context structure for the Firmware Management
40// Protocol instance
41//
42const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate = {
43 FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE, // Signature
44 NULL, // Handle
45 { // Fmp
52 },
53 FALSE, // DescriptorPopulated
54 { // Desc
55 1, // ImageIndex
56 //
57 // ImageTypeId
58 //
59 { 0x00000000, 0x0000,0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
60 },
61 1, // ImageId
62 NULL, // ImageIdName
63 0, // Version
64 NULL, // VersionName
65 0, // Size
66 0, // AttributesSupported
67 0, // AttributesSetting
68 0, // Compatibilities
69 0, // LowestSupportedImageVersion
70 0, // LastAttemptVersion
71 0, // LastAttemptStatus
72 0 // HardwareInstance
73 },
74 NULL, // ImageIdName
75 NULL, // VersionName
76 TRUE, // RuntimeVersionSupported
77 NULL, // FmpDeviceLockEvent
78 FALSE, // FmpDeviceLocked
79 NULL, // FmpDeviceContext
80 NULL, // VersionVariableName
81 NULL, // LsvVariableName
82 NULL, // LastAttemptStatusVariableName
83 NULL, // LastAttemptVersionVariableName
84 NULL, // FmpStateVariableName
85 TRUE // DependenciesSatisfied
86};
87
92
97
102
124EFIAPI
126 IN UINTN Completion
127 )
128{
129 EFI_STATUS Status;
130
131 Status = EFI_UNSUPPORTED;
132
133 if (mProgressFunc == NULL) {
134 return Status;
135 }
136
137 //
138 // Reserve 6% - 98% for the FmpDeviceLib. Call the real progress function.
139 //
140 Status = mProgressFunc (((Completion * 92) / 100) + 6);
141
142 if (Status == EFI_UNSUPPORTED) {
144 }
145
146 return Status;
147}
148
159EFI_GUID *
161 VOID
162 )
163{
164 EFI_STATUS Status;
165 EFI_GUID *FmpDeviceLibGuid;
166 UINTN ImageTypeIdGuidSize;
167
168 FmpDeviceLibGuid = NULL;
169 Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid);
170 if (EFI_ERROR (Status)) {
171 if (Status != EFI_UNSUPPORTED) {
172 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", mImageIdName, Status));
173 }
174 } else if (FmpDeviceLibGuid == NULL) {
175 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n", mImageIdName));
176 Status = EFI_NOT_FOUND;
177 }
178
179 if (EFI_ERROR (Status)) {
180 ImageTypeIdGuidSize = PcdGetSize (PcdFmpDeviceImageTypeIdGuid);
181 if (ImageTypeIdGuidSize == sizeof (EFI_GUID)) {
182 FmpDeviceLibGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceImageTypeIdGuid);
183 } else {
184 DEBUG ((
185 DEBUG_ERROR,
186 "FmpDxe(%s): Fall back to ImageTypeIdGuid of gEfiCallerIdGuid. FmpDxe error: misconfiguration\n",
188 ));
189 ASSERT (FALSE);
190 FmpDeviceLibGuid = &gEfiCallerIdGuid;
191 }
192 }
193
194 return FmpDeviceLibGuid;
195}
196
203CHAR16 *
205 VOID
206 )
207{
208 return mImageIdName;
209}
210
223UINT32
226 )
227{
228 EFI_STATUS Status;
229 UINT32 DeviceLibLowestSupportedVersion;
230 UINT32 VariableLowestSupportedVersion;
231 UINT32 ReturnLsv;
232
233 //
234 // Get the LowestSupportedVersion.
235 //
236
238 //
239 // Any Version can pass the 0 LowestSupportedVersion check.
240 //
241 return 0;
242 }
243
244 ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
245
246 //
247 // Check the FmpDeviceLib
248 //
249 DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
250 Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion);
251 if (EFI_ERROR (Status)) {
252 DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
253 }
254
255 if (DeviceLibLowestSupportedVersion > ReturnLsv) {
256 ReturnLsv = DeviceLibLowestSupportedVersion;
257 }
258
259 //
260 // Check the lowest supported version UEFI variable for this device
261 //
262 VariableLowestSupportedVersion = GetLowestSupportedVersionFromVariable (Private);
263 if (VariableLowestSupportedVersion > ReturnLsv) {
264 ReturnLsv = VariableLowestSupportedVersion;
265 }
266
267 //
268 // Return the largest value
269 //
270 return ReturnLsv;
271}
272
281VOID
284 )
285{
286 EFI_STATUS Status;
287 UINT32 DependenciesSize;
288
289 if (Private == NULL) {
290 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): PopulateDescriptor() - Private is NULL.\n", mImageIdName));
291 return;
292 }
293
294 if (Private->DescriptorPopulated) {
295 return;
296 }
297
298 Private->Descriptor.ImageIndex = 1;
299 CopyGuid (&Private->Descriptor.ImageTypeId, GetImageTypeIdGuid ());
300 Private->Descriptor.ImageId = Private->Descriptor.ImageIndex;
301 Private->Descriptor.ImageIdName = GetImageTypeNameString ();
302
303 //
304 // Get the hardware instance from FmpDeviceLib
305 //
306 Status = FmpDeviceGetHardwareInstance (&Private->Descriptor.HardwareInstance);
307 if (Status == EFI_UNSUPPORTED) {
308 Private->Descriptor.HardwareInstance = 0;
309 }
310
311 //
312 // Generate UEFI Variable names used to store status information for this
313 // FMP instance.
314 //
315 GenerateFmpVariableNames (Private);
316
317 //
318 // Get the version. Some devices don't support getting the firmware version
319 // at runtime. If FmpDeviceLib does not support returning a version, then
320 // it is stored in a UEFI variable.
321 //
322 Status = FmpDeviceGetVersion (&Private->Descriptor.Version);
323 if (Status == EFI_UNSUPPORTED) {
324 Private->RuntimeVersionSupported = FALSE;
325 Private->Descriptor.Version = GetVersionFromVariable (Private);
326 } else if (EFI_ERROR (Status)) {
327 //
328 // Unexpected error. Use default version.
329 //
330 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetVersion() from FmpDeviceLib (%s) returned %r\n", mImageIdName, GetImageTypeNameString (), Status));
331 Private->Descriptor.Version = DEFAULT_VERSION;
332 }
333
334 //
335 // Free the current version name. Shouldn't really happen but this populate
336 // function could be called multiple times (to refresh).
337 //
338 if (Private->Descriptor.VersionName != NULL) {
339 FreePool (Private->Descriptor.VersionName);
340 Private->Descriptor.VersionName = NULL;
341 }
342
343 //
344 // Attempt to get the version string from the FmpDeviceLib
345 //
346 Status = FmpDeviceGetVersionString (&Private->Descriptor.VersionName);
347 if (Status == EFI_UNSUPPORTED) {
348 DEBUG ((DEBUG_INFO, "FmpDxe(%s): GetVersionString() unsupported in FmpDeviceLib.\n", mImageIdName));
349 Private->Descriptor.VersionName = AllocateCopyPool (
350 sizeof (VERSION_STRING_NOT_SUPPORTED),
351 VERSION_STRING_NOT_SUPPORTED
352 );
353 } else if (EFI_ERROR (Status)) {
354 DEBUG ((DEBUG_INFO, "FmpDxe(%s): GetVersionString() not available in FmpDeviceLib.\n", mImageIdName));
355 Private->Descriptor.VersionName = AllocateCopyPool (
356 sizeof (VERSION_STRING_NOT_AVAILABLE),
357 VERSION_STRING_NOT_AVAILABLE
358 );
359 }
360
361 Private->Descriptor.LowestSupportedImageVersion = GetLowestSupportedVersion (Private);
362
363 //
364 // Get attributes from the FmpDeviceLib
365 //
367 &Private->Descriptor.AttributesSupported,
368 &Private->Descriptor.AttributesSetting
369 );
370
371 //
372 // Force set the updatable bits in the attributes;
373 //
376
377 //
378 // Force set the authentication bits in the attributes;
379 //
382
383 Private->Descriptor.Compatibilities = 0;
384
385 //
386 // Get the size of the firmware image from the FmpDeviceLib
387 //
388 Status = FmpDeviceGetSize (&Private->Descriptor.Size);
389 if (EFI_ERROR (Status)) {
390 Private->Descriptor.Size = 0;
391 }
392
393 Private->Descriptor.LastAttemptVersion = GetLastAttemptVersionFromVariable (Private);
394 Private->Descriptor.LastAttemptStatus = GetLastAttemptStatusFromVariable (Private);
395
396 //
397 // Get the dependency from the FmpDependencyDeviceLib.
398 //
399 Private->Descriptor.Dependencies = NULL;
400
401 //
402 // Check the attribute IMAGE_ATTRIBUTE_DEPENDENCY
403 //
404 if (Private->Descriptor.AttributesSetting & IMAGE_ATTRIBUTE_DEPENDENCY) {
405 Private->Descriptor.Dependencies = GetFmpDependency (&DependenciesSize);
406 }
407
408 Private->DescriptorPopulated = TRUE;
409}
410
450EFIAPI
453 IN OUT UINTN *ImageInfoSize,
455 OUT UINT32 *DescriptorVersion,
456 OUT UINT8 *DescriptorCount,
457 OUT UINTN *DescriptorSize,
458 OUT UINT32 *PackageVersion,
459 OUT CHAR16 **PackageVersionName
460 )
461{
462 EFI_STATUS Status;
464
465 Status = EFI_SUCCESS;
466
467 if (This == NULL) {
468 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - This is NULL.\n", mImageIdName));
469 Status = EFI_INVALID_PARAMETER;
470 goto cleanup;
471 }
472
473 //
474 // Retrieve the private context structure
475 //
476 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
477 FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
478
479 //
480 // Check for valid pointer
481 //
482 if (ImageInfoSize == NULL) {
483 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - ImageInfoSize is NULL.\n", mImageIdName));
484 Status = EFI_INVALID_PARAMETER;
485 goto cleanup;
486 }
487
488 //
489 // Check the buffer size
490 // NOTE: Check this first so caller can get the necessary memory size it must allocate.
491 //
492 if (*ImageInfoSize < (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR))) {
493 *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
494 DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): GetImageInfo() - ImageInfoSize is to small.\n", mImageIdName));
495 Status = EFI_BUFFER_TOO_SMALL;
496 goto cleanup;
497 }
498
499 //
500 // Confirm that buffer isn't null
501 //
502 if ( (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount == NULL) || (DescriptorSize == NULL)
503 || (PackageVersion == NULL))
504 {
505 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - Pointer Parameter is NULL.\n", mImageIdName));
506 Status = EFI_INVALID_PARAMETER;
507 goto cleanup;
508 }
509
510 //
511 // Set the size to whatever we need
512 //
513 *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
514
515 //
516 // Make sure the descriptor has already been loaded or refreshed
517 //
518 PopulateDescriptor (Private);
519
520 //
521 // Copy the image descriptor
522 //
523 CopyMem (ImageInfo, &Private->Descriptor, sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR));
524
525 *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
526 *DescriptorCount = 1;
527 *DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
528 //
529 // means unsupported
530 //
531 *PackageVersion = 0xFFFFFFFF;
532
533 //
534 // Do not update PackageVersionName since it is not supported in this instance.
535 //
536
537cleanup:
538
539 return Status;
540}
541
566EFIAPI
569 IN UINT8 ImageIndex,
570 IN OUT VOID *Image,
571 IN OUT UINTN *ImageSize
572 )
573{
574 EFI_STATUS Status;
576 UINTN Size;
577
578 if (!FeaturePcdGet (PcdFmpDeviceStorageAccessEnable)) {
579 return EFI_UNSUPPORTED;
580 }
581
582 Status = EFI_SUCCESS;
583
584 if (This == NULL) {
585 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - This is NULL.\n", mImageIdName));
586 Status = EFI_INVALID_PARAMETER;
587 goto cleanup;
588 }
589
590 //
591 // Retrieve the private context structure
592 //
593 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
594 FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
595
596 //
597 // Check to make sure index is 1 (only 1 image for this device)
598 //
599 if (ImageIndex != 1) {
600 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - Image Index Invalid.\n", mImageIdName));
601 Status = EFI_INVALID_PARAMETER;
602 goto cleanup;
603 }
604
605 if (ImageSize == NULL) {
606 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - ImageSize Pointer Parameter is NULL.\n", mImageIdName));
607 Status = EFI_INVALID_PARAMETER;
608 goto cleanup;
609 }
610
611 //
612 // Check the buffer size
613 //
614 Status = FmpDeviceGetSize (&Size);
615 if (EFI_ERROR (Status)) {
616 Size = 0;
617 }
618
619 if (*ImageSize < Size) {
620 *ImageSize = Size;
621 DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): GetImage() - ImageSize is to small.\n", mImageIdName));
622 Status = EFI_BUFFER_TOO_SMALL;
623 goto cleanup;
624 }
625
626 if (Image == NULL) {
627 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - Image Pointer Parameter is NULL.\n", mImageIdName));
628 Status = EFI_INVALID_PARAMETER;
629 goto cleanup;
630 }
631
632 Status = FmpDeviceGetImage (Image, ImageSize);
633cleanup:
634
635 return Status;
636}
637
652VOID *
655 IN CONST UINTN ImageSize,
656 IN CONST UINTN AdditionalHeaderSize,
657 OUT UINTN *PayloadSize OPTIONAL
658 )
659{
660 //
661 // Check to make sure that operation can be safely performed.
662 //
663 if ((((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize < (UINTN)Image) || \
664 (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize >= (UINTN)Image + ImageSize))
665 {
666 //
667 // Pointer overflow. Invalid image.
668 //
669 return NULL;
670 }
671
672 if (PayloadSize != NULL) {
673 *PayloadSize = ImageSize - (sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength + AdditionalHeaderSize);
674 }
675
676 return (VOID *)((UINT8 *)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength + AdditionalHeaderSize);
677}
678
690UINT32
693 IN UINT32 AdditionalHeaderSize
694 )
695{
696 UINT32 CalculatedSize;
697
698 if (Image == NULL) {
699 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetAllHeaderSize() - Image is NULL.\n", mImageIdName));
700 return 0;
701 }
702
703 CalculatedSize = sizeof (Image->MonotonicCount) +
704 AdditionalHeaderSize +
705 Image->AuthInfo.Hdr.dwLength;
706
707 //
708 // Check to make sure that operation can be safely performed.
709 //
710 if ((CalculatedSize < sizeof (Image->MonotonicCount)) ||
711 (CalculatedSize < AdditionalHeaderSize) ||
712 (CalculatedSize < Image->AuthInfo.Hdr.dwLength))
713 {
714 //
715 // Integer overflow. Invalid image.
716 //
717 return 0;
718 }
719
720 return CalculatedSize;
721}
722
762EFIAPI
765 IN UINT8 ImageIndex,
766 IN CONST VOID *Image,
767 IN UINTN ImageSize,
768 OUT UINT32 *ImageUpdatable,
769 OUT UINT32 *LastAttemptStatus
770 )
771{
772 EFI_STATUS Status;
773 UINT32 LocalLastAttemptStatus;
775 UINTN RawSize;
776 VOID *FmpPayloadHeader;
777 UINTN FmpPayloadSize;
778 UINT32 Version;
779 UINT32 FmpHeaderSize;
780 UINTN AllHeaderSize;
781 UINT32 Index;
782 VOID *PublicKeyData;
783 UINTN PublicKeyDataLength;
784 UINT8 *PublicKeyDataXdr;
785 UINT8 *PublicKeyDataXdrEnd;
786 EFI_FIRMWARE_IMAGE_DEP *Dependencies;
787 UINT32 DependenciesSize;
788
789 Status = EFI_SUCCESS;
790 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
791 RawSize = 0;
792 FmpPayloadHeader = NULL;
793 FmpPayloadSize = 0;
794 Version = 0;
795 FmpHeaderSize = 0;
796 AllHeaderSize = 0;
797 Dependencies = NULL;
798 DependenciesSize = 0;
799
800 if (!FeaturePcdGet (PcdFmpDeviceStorageAccessEnable)) {
801 return EFI_UNSUPPORTED;
802 }
803
804 if (LastAttemptStatus == NULL) {
805 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImageInternal() - LastAttemptStatus is NULL.\n", mImageIdName));
806 Status = EFI_INVALID_PARAMETER;
807 goto cleanup;
808 }
809
810 //
811 // A last attempt status error code will always override the success
812 // value before returning from the function
813 //
814 *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
815
816 if (This == NULL) {
817 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - This is NULL.\n", mImageIdName));
818 Status = EFI_INVALID_PARAMETER;
819 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
820 goto cleanup;
821 }
822
823 //
824 // Retrieve the private context structure
825 //
826 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
827 FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
828
829 //
830 // Make sure the descriptor has already been loaded or refreshed
831 //
832 PopulateDescriptor (Private);
833
834 if (ImageUpdatable == NULL) {
835 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - ImageUpdatable Pointer Parameter is NULL.\n", mImageIdName));
836 Status = EFI_INVALID_PARAMETER;
837 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_UPDATABLE;
838 goto cleanup;
839 }
840
841 //
842 // Set to valid and then if any tests fail it will update this flag.
843 //
844 *ImageUpdatable = IMAGE_UPDATABLE_VALID;
845
846 //
847 // Set to satisfied and then if dependency evaluates to false it will update this flag.
848 //
849 Private->DependenciesSatisfied = TRUE;
850
851 if (Image == NULL) {
852 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - Image Pointer Parameter is NULL.\n", mImageIdName));
853 //
854 // not sure if this is needed
855 //
856 *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
857 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_PROVIDED;
858 return EFI_INVALID_PARAMETER;
859 }
860
861 PublicKeyDataXdr = PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
862 PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr);
863
864 if ((PublicKeyDataXdr == NULL) || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) {
865 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Invalid certificate, skipping it.\n", mImageIdName));
866 Status = EFI_ABORTED;
867 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_CERTIFICATE;
868 } else {
869 //
870 // Try each key from PcdFmpDevicePkcs7CertBufferXdr
871 //
872 for (Index = 1; PublicKeyDataXdr < PublicKeyDataXdrEnd; Index++) {
873 Index++;
874 DEBUG (
875 (DEBUG_INFO,
876 "FmpDxe(%s): Certificate #%d [%p..%p].\n",
878 Index,
879 PublicKeyDataXdr,
880 PublicKeyDataXdrEnd
881 )
882 );
883
884 if ((PublicKeyDataXdr + sizeof (UINT32)) > PublicKeyDataXdrEnd) {
885 //
886 // Key data extends beyond end of PCD
887 //
888 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Certificate size extends beyond end of PCD, skipping it.\n", mImageIdName));
889 Status = EFI_ABORTED;
890 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH_VALUE;
891 break;
892 }
893
894 //
895 // Read key length stored in big-endian format
896 //
897 PublicKeyDataLength = SwapBytes32 (*(UINT32 *)(PublicKeyDataXdr));
898 //
899 // Point to the start of the key data
900 //
901 PublicKeyDataXdr += sizeof (UINT32);
902 if (PublicKeyDataXdr + PublicKeyDataLength > PublicKeyDataXdrEnd) {
903 //
904 // Key data extends beyond end of PCD
905 //
906 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Certificate extends beyond end of PCD, skipping it.\n", mImageIdName));
907 Status = EFI_ABORTED;
908 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH;
909 break;
910 }
911
912 PublicKeyData = PublicKeyDataXdr;
913 Status = AuthenticateFmpImage (
915 ImageSize,
916 PublicKeyData,
917 PublicKeyDataLength
918 );
919 if (!EFI_ERROR (Status)) {
920 break;
921 }
922
923 PublicKeyDataXdr += PublicKeyDataLength;
924 PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
925 }
926 }
927
928 if (EFI_ERROR (Status)) {
929 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - Authentication Failed %r.\n", mImageIdName, Status));
930 if (LocalLastAttemptStatus != LAST_ATTEMPT_STATUS_SUCCESS) {
931 *LastAttemptStatus = LocalLastAttemptStatus;
932 } else {
933 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_AUTH_FAILURE;
934 }
935
936 goto cleanup;
937 }
938
939 //
940 // Check to make sure index is 1
941 //
942 if (ImageIndex != 1) {
943 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - Image Index Invalid.\n", mImageIdName));
944 *ImageUpdatable = IMAGE_UPDATABLE_INVALID_TYPE;
945 Status = EFI_INVALID_PARAMETER;
946 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_IMAGE_INDEX;
947 goto cleanup;
948 }
949
950 //
951 // Get the dependency from Image.
952 //
953 Dependencies = GetImageDependency (
955 ImageSize,
956 &DependenciesSize,
957 LastAttemptStatus
958 );
959 if (*LastAttemptStatus != LAST_ATTEMPT_STATUS_SUCCESS) {
960 Status = EFI_ABORTED;
961 goto cleanup;
962 }
963
964 //
965 // Check the FmpPayloadHeader
966 //
967 FmpPayloadHeader = GetFmpHeader ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize);
968 if (FmpPayloadHeader == NULL) {
969 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetFmpHeader failed.\n", mImageIdName));
970 Status = EFI_ABORTED;
972 goto cleanup;
973 }
974
975 Status = GetFmpPayloadHeaderVersion (FmpPayloadHeader, FmpPayloadSize, &Version);
976 if (EFI_ERROR (Status)) {
977 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetFmpPayloadHeaderVersion failed %r.\n", mImageIdName, Status));
978 *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
979 Status = EFI_SUCCESS;
980 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_VERSION;
981 goto cleanup;
982 }
983
984 //
985 // Check the lowest supported version
986 //
987 if (Version < Private->Descriptor.LowestSupportedImageVersion) {
988 DEBUG (
989 (DEBUG_ERROR,
990 "FmpDxe(%s): CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n",
991 mImageIdName, Version, Private->Descriptor.LowestSupportedImageVersion)
992 );
993 *ImageUpdatable = IMAGE_UPDATABLE_INVALID_OLD;
994 Status = EFI_SUCCESS;
995 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_VERSION_TOO_LOW;
996 goto cleanup;
997 }
998
999 //
1000 // Evaluate dependency expression
1001 //
1002 Private->DependenciesSatisfied = CheckFmpDependency (
1003 Private->Descriptor.ImageTypeId,
1004 Version,
1005 Dependencies,
1006 DependenciesSize,
1007 &LocalLastAttemptStatus
1008 );
1009 if (!Private->DependenciesSatisfied) {
1010 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - Dependency check failed.\n", mImageIdName));
1011 *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
1012 Status = EFI_SUCCESS;
1013 *LastAttemptStatus = LocalLastAttemptStatus;
1014 goto cleanup;
1015 }
1016
1017 //
1018 // Get the FmpHeaderSize so we can determine the real payload size
1019 //
1020 Status = GetFmpPayloadHeaderSize (FmpPayloadHeader, FmpPayloadSize, &FmpHeaderSize);
1021 if (EFI_ERROR (Status)) {
1022 DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpPayloadHeaderSize failed %r.\n", Status));
1023 *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
1024 Status = EFI_SUCCESS;
1025 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;
1026 goto cleanup;
1027 }
1028
1029 //
1030 // Call FmpDevice Lib Check Image on the
1031 // Raw payload. So all headers need stripped off
1032 //
1033 AllHeaderSize = GetAllHeaderSize ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize + DependenciesSize);
1034 if (AllHeaderSize == 0) {
1035 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetAllHeaderSize failed.\n", mImageIdName));
1036 Status = EFI_ABORTED;
1037 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
1038 goto cleanup;
1039 }
1040
1041 RawSize = ImageSize - AllHeaderSize;
1042
1043 //
1044 // FmpDeviceLib CheckImage function to do any specific checks
1045 //
1046 Status = FmpDeviceCheckImageWithStatus ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);
1047 if (EFI_ERROR (Status)) {
1048 // The image cannot be valid if an error occurred checking the image
1049 if (*ImageUpdatable == IMAGE_UPDATABLE_VALID) {
1050 *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
1051 }
1052
1053 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));
1054 }
1055
1056 //
1057 // Only validate the library last attempt status code if the image is not updatable.
1058 // This specifically avoids converting LAST_ATTEMPT_STATUS_SUCCESS if it set for an updatable image.
1059 //
1060 if (*ImageUpdatable != IMAGE_UPDATABLE_VALID) {
1061 //
1062 // LastAttemptStatus returned from the device library should fall within the designated error range
1063 // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]
1064 //
1067 {
1068 DEBUG ((
1069 DEBUG_ERROR,
1070 "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",
1072 *LastAttemptStatus
1073 ));
1074 *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
1075 }
1076 }
1077
1078cleanup:
1079 return Status;
1080}
1081
1104EFIAPI
1107 IN UINT8 ImageIndex,
1108 IN CONST VOID *Image,
1109 IN UINTN ImageSize,
1110 OUT UINT32 *ImageUpdatable
1111 )
1112{
1113 UINT32 LastAttemptStatus;
1114
1115 return CheckTheImageInternal (This, ImageIndex, Image, ImageSize, ImageUpdatable, &LastAttemptStatus);
1116}
1117
1165EFIAPI
1168 IN UINT8 ImageIndex,
1169 IN CONST VOID *Image,
1170 IN UINTN ImageSize,
1171 IN CONST VOID *VendorCode,
1173 OUT CHAR16 **AbortReason
1174 )
1175{
1176 EFI_STATUS Status;
1178 UINT32 Updateable;
1179 BOOLEAN BooleanValue;
1180 UINT32 FmpHeaderSize;
1181 VOID *FmpHeader;
1182 UINTN FmpPayloadSize;
1183 UINT32 AllHeaderSize;
1184 UINT32 IncomingFwVersion;
1185 UINT32 LastAttemptStatus;
1186 UINT32 Version;
1187 UINT32 LowestSupportedVersion;
1188 EFI_FIRMWARE_IMAGE_DEP *Dependencies;
1189 UINT32 DependenciesSize;
1190
1191 Status = EFI_SUCCESS;
1192 Private = NULL;
1193 Updateable = 0;
1194 BooleanValue = FALSE;
1195 FmpHeaderSize = 0;
1196 FmpHeader = NULL;
1197 FmpPayloadSize = 0;
1198 AllHeaderSize = 0;
1199 IncomingFwVersion = 0;
1200 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
1201 Dependencies = NULL;
1202 DependenciesSize = 0;
1203
1204 if (!FeaturePcdGet (PcdFmpDeviceStorageAccessEnable)) {
1205 return EFI_UNSUPPORTED;
1206 }
1207
1208 if (This == NULL) {
1209 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - This is NULL.\n", mImageIdName));
1210 Status = EFI_INVALID_PARAMETER;
1211 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
1212 goto cleanup;
1213 }
1214
1215 //
1216 // Retrieve the private context structure
1217 //
1218 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
1219 FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
1220
1221 //
1222 // Make sure the descriptor has already been loaded or refreshed
1223 //
1224 PopulateDescriptor (Private);
1225
1226 //
1227 // Set to 0 to clear any previous results.
1228 //
1229 SetLastAttemptVersionInVariable (Private, IncomingFwVersion);
1230
1231 //
1232 // if we have locked the device, then skip the set operation.
1233 // it should be blocked by hardware too but we can catch here even faster
1234 //
1235 if (Private->FmpDeviceLocked) {
1236 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Device is already locked. Can't update.\n", mImageIdName));
1237 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED;
1238 Status = EFI_UNSUPPORTED;
1239 goto cleanup;
1240 }
1241
1242 //
1243 // Call check image to verify the image
1244 //
1245 Status = CheckTheImageInternal (This, ImageIndex, Image, ImageSize, &Updateable, &LastAttemptStatus);
1246 if (EFI_ERROR (Status)) {
1247 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Check The Image failed with %r.\n", mImageIdName, Status));
1248 goto cleanup;
1249 }
1250
1251 //
1252 // Get the dependency from Image.
1253 //
1254 Dependencies = GetImageDependency ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, &DependenciesSize, &LastAttemptStatus);
1255
1256 //
1257 // No functional error in CheckTheImage. Attempt to get the Version to
1258 // support better error reporting.
1259 //
1260 FmpHeader = GetFmpHeader ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize);
1261 if (FmpHeader == NULL) {
1262 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpHeader failed.\n", mImageIdName));
1264 Status = EFI_ABORTED;
1265 goto cleanup;
1266 }
1267
1268 Status = GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &IncomingFwVersion);
1269 if (!EFI_ERROR (Status)) {
1270 //
1271 // Set to actual value
1272 //
1273 SetLastAttemptVersionInVariable (Private, IncomingFwVersion);
1274 }
1275
1276 if (Updateable != IMAGE_UPDATABLE_VALID) {
1277 DEBUG (
1278 (DEBUG_ERROR,
1279 "FmpDxe(%s): SetTheImage() - Check The Image returned that the Image was not valid for update. Updatable value = 0x%X.\n",
1280 mImageIdName, Updateable)
1281 );
1282 if (Private->DependenciesSatisfied == FALSE) {
1283 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES;
1284 }
1285
1286 Status = EFI_ABORTED;
1287 goto cleanup;
1288 }
1289
1290 if (Progress == NULL) {
1291 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Invalid progress callback\n", mImageIdName));
1292 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR;
1293 Status = EFI_INVALID_PARAMETER;
1294 goto cleanup;
1295 }
1296
1297 mProgressFunc = Progress;
1298
1299 //
1300 // Checking the image is at least 1%
1301 //
1302 Status = Progress (1);
1303 if (EFI_ERROR (Status)) {
1304 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Progress Callback failed with Status %r.\n", mImageIdName, Status));
1305 }
1306
1307 //
1308 // Check System Power
1309 //
1310 Status = CheckSystemPower (&BooleanValue);
1311 if (EFI_ERROR (Status)) {
1312 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemPower - API call failed %r.\n", mImageIdName, Status));
1313 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API;
1314 goto cleanup;
1315 }
1316
1317 if (!BooleanValue) {
1318 Status = EFI_ABORTED;
1319 DEBUG (
1320 (DEBUG_ERROR,
1321 "FmpDxe(%s): SetTheImage() - CheckSystemPower - returned False. Update not allowed due to System Power.\n", mImageIdName)
1322 );
1323 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT;
1324 goto cleanup;
1325 }
1326
1327 Progress (2);
1328
1329 //
1330 // Check System Thermal
1331 //
1332 Status = CheckSystemThermal (&BooleanValue);
1333 if (EFI_ERROR (Status)) {
1334 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemThermal - API call failed %r.\n", mImageIdName, Status));
1335 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API;
1336 goto cleanup;
1337 }
1338
1339 if (!BooleanValue) {
1340 Status = EFI_ABORTED;
1341 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL;
1342 DEBUG (
1343 (DEBUG_ERROR,
1344 "FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n", mImageIdName)
1345 );
1346 goto cleanup;
1347 }
1348
1349 Progress (3);
1350
1351 //
1352 // Check System Environment
1353 //
1354 Status = CheckSystemEnvironment (&BooleanValue);
1355 if (EFI_ERROR (Status)) {
1356 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - API call failed %r.\n", mImageIdName, Status));
1357 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API;
1358 goto cleanup;
1359 }
1360
1361 if (!BooleanValue) {
1362 Status = EFI_ABORTED;
1363 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV;
1364 DEBUG (
1365 (DEBUG_ERROR,
1366 "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n", mImageIdName)
1367 );
1368 goto cleanup;
1369 }
1370
1371 Progress (4);
1372
1373 //
1374 // Save LastAttemptStatus as error so that if SetImage never returns the error
1375 // state is recorded.
1376 //
1377 SetLastAttemptStatusInVariable (Private, LastAttemptStatus);
1378
1379 //
1380 // Strip off all the headers so the device can process its firmware
1381 //
1382 Status = GetFmpPayloadHeaderSize (FmpHeader, FmpPayloadSize, &FmpHeaderSize);
1383 if (EFI_ERROR (Status)) {
1384 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n", mImageIdName, Status));
1385 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;
1386 goto cleanup;
1387 }
1388
1389 AllHeaderSize = GetAllHeaderSize ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize + DependenciesSize);
1390 if (AllHeaderSize == 0) {
1391 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetAllHeaderSize failed.\n", mImageIdName));
1392 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
1393 Status = EFI_ABORTED;
1394 goto cleanup;
1395 }
1396
1397 //
1398 // Indicate that control is handed off to FmpDeviceLib
1399 //
1400 Progress (5);
1401
1402 //
1403 // Copy the requested image to the firmware using the FmpDeviceLib
1404 //
1406 (((UINT8 *)Image) + AllHeaderSize),
1407 ImageSize - AllHeaderSize,
1408 VendorCode,
1410 IncomingFwVersion,
1411 AbortReason,
1412 &LastAttemptStatus
1413 );
1414 if (EFI_ERROR (Status)) {
1415 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SetImage from FmpDeviceLib failed. Status = %r.\n", mImageIdName, Status));
1416
1417 //
1418 // LastAttemptStatus returned from the device library should fall within the designated error range
1419 // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]
1420 //
1423 {
1424 DEBUG (
1425 (DEBUG_ERROR,
1426 "FmpDxe(%s): SetTheImage() - LastAttemptStatus %d from FmpDeviceSetImageWithStatus() is invalid.\n",
1428 LastAttemptStatus)
1429 );
1430 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
1431 }
1432
1433 goto cleanup;
1434 }
1435
1436 //
1437 // Store the dependency
1438 //
1439 if (Private->Descriptor.AttributesSetting & IMAGE_ATTRIBUTE_DEPENDENCY) {
1440 Status = SaveFmpDependency (Dependencies, DependenciesSize);
1441 if (EFI_ERROR (Status)) {
1442 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SaveFmpDependency from FmpDependencyCheckLib failed. (%r)\n", mImageIdName, Status));
1443 }
1444
1445 Status = EFI_SUCCESS;
1446 }
1447
1448 //
1449 // Finished the update without error
1450 // Indicate that control has been returned from FmpDeviceLib
1451 //
1452 Progress (99);
1453
1454 //
1455 // Update the version stored in variable
1456 //
1457 if (!Private->RuntimeVersionSupported) {
1458 Version = DEFAULT_VERSION;
1459 GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &Version);
1460 SetVersionInVariable (Private, Version);
1461 }
1462
1463 //
1464 // Update lowest supported variable
1465 //
1466 LowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
1467 GetFmpPayloadHeaderLowestSupportedVersion (FmpHeader, FmpPayloadSize, &LowestSupportedVersion);
1468 SetLowestSupportedVersionInVariable (Private, LowestSupportedVersion);
1469
1470 LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
1471
1472cleanup:
1474
1475 if (Private != NULL) {
1476 DEBUG ((DEBUG_INFO, "FmpDxe(%s): SetTheImage() LastAttemptStatus: %u.\n", mImageIdName, LastAttemptStatus));
1477 SetLastAttemptStatusInVariable (Private, LastAttemptStatus);
1478 }
1479
1480 if (Progress != NULL) {
1481 //
1482 // Set progress to 100 after everything is done including recording Status.
1483 //
1484 Progress (100);
1485 }
1486
1487 //
1488 // Need repopulate after SetImage is called to
1489 // update LastAttemptVersion and LastAttemptStatus.
1490 //
1491 if (Private != NULL) {
1492 Private->DescriptorPopulated = FALSE;
1493 }
1494
1495 return Status;
1496}
1497
1531EFIAPI
1534 OUT UINT32 *PackageVersion,
1535 OUT CHAR16 **PackageVersionName,
1536 OUT UINT32 *PackageVersionNameMaxLen,
1537 OUT UINT64 *AttributesSupported,
1538 OUT UINT64 *AttributesSetting
1539 )
1540{
1541 return EFI_UNSUPPORTED;
1542}
1543
1576EFIAPI
1579 IN CONST VOID *Image,
1580 IN UINTN ImageSize,
1581 IN CONST VOID *VendorCode,
1582 IN UINT32 PackageVersion,
1583 IN CONST CHAR16 *PackageVersionName
1584 )
1585{
1586 return EFI_UNSUPPORTED;
1587}
1588
1597VOID
1598EFIAPI
1600 IN EFI_EVENT Event,
1601 IN VOID *Context
1602 )
1603{
1604 EFI_STATUS Status;
1606
1607 if (Context == NULL) {
1608 ASSERT (Context != NULL);
1609 return;
1610 }
1611
1612 Private = (FIRMWARE_MANAGEMENT_PRIVATE_DATA *)Context;
1613
1614 if (!Private->FmpDeviceLocked) {
1615 //
1616 // Lock the firmware device
1617 //
1618 FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
1619 Status = FmpDeviceLock ();
1620 if (EFI_ERROR (Status)) {
1621 if (Status != EFI_UNSUPPORTED) {
1622 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n", mImageIdName, Status));
1623 } else {
1624 DEBUG ((DEBUG_WARN, "FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n", mImageIdName, Status));
1625 }
1626 }
1627
1628 Private->FmpDeviceLocked = TRUE;
1629 }
1630}
1631
1643EFIAPI
1645 IN EFI_HANDLE Handle
1646 )
1647{
1648 EFI_STATUS Status;
1651
1652 //
1653 // Only allow a single FMP Protocol instance to be installed
1654 //
1655 Status = gBS->OpenProtocol (
1656 Handle,
1657 &gEfiFirmwareManagementProtocolGuid,
1658 (VOID **)&Fmp,
1659 NULL,
1660 NULL,
1661 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1662 );
1663 if (!EFI_ERROR (Status)) {
1664 return EFI_ALREADY_STARTED;
1665 }
1666
1667 //
1668 // Allocate FMP Protocol instance
1669 //
1670 Private = AllocateCopyPool (
1671 sizeof (mFirmwareManagementPrivateDataTemplate),
1672 &mFirmwareManagementPrivateDataTemplate
1673 );
1674 if (Private == NULL) {
1675 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to allocate memory for private structure.\n", mImageIdName));
1676 Status = EFI_OUT_OF_RESOURCES;
1677 goto cleanup;
1678 }
1679
1680 //
1681 // Initialize private context data structure
1682 //
1683 Private->Handle = Handle;
1684 Private->FmpDeviceContext = NULL;
1685 Status = FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
1686 if (Status == EFI_UNSUPPORTED) {
1687 Private->FmpDeviceContext = NULL;
1688 } else if (EFI_ERROR (Status)) {
1689 goto cleanup;
1690 }
1691
1692 //
1693 // Make sure the descriptor has already been loaded or refreshed
1694 //
1695 PopulateDescriptor (Private);
1696
1698 //
1699 // Register all UEFI Variables used by this module to be locked.
1700 //
1701 Status = LockAllFmpVariables (Private);
1702 if (EFI_ERROR (Status)) {
1703 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to register variables to lock. Status = %r.\n", mImageIdName, Status));
1704 } else {
1705 DEBUG ((DEBUG_INFO, "FmpDxe(%s): All variables registered to lock\n", mImageIdName));
1706 }
1707
1708 //
1709 // Create and register notify function to lock the FMP device.
1710 //
1711 Status = gBS->CreateEventEx (
1712 EVT_NOTIFY_SIGNAL,
1713 TPL_CALLBACK,
1715 Private,
1716 mLockGuid,
1717 &Private->FmpDeviceLockEvent
1718 );
1719 if (EFI_ERROR (Status)) {
1720 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to register notification. Status = %r\n", mImageIdName, Status));
1721 }
1722
1723 ASSERT_EFI_ERROR (Status);
1724 } else {
1725 DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): Not registering notification to call FmpDeviceLock() because mfg mode\n", mImageIdName));
1726 }
1727
1728 //
1729 // Install FMP Protocol and FMP Progress Protocol
1730 //
1731 Status = gBS->InstallMultipleProtocolInterfaces (
1732 &Private->Handle,
1733 &gEfiFirmwareManagementProtocolGuid,
1734 &Private->Fmp,
1736 &mFmpProgress,
1737 NULL
1738 );
1739 if (EFI_ERROR (Status)) {
1740 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol install error. Status = %r.\n", mImageIdName, Status));
1741 goto cleanup;
1742 }
1743
1744cleanup:
1745
1746 if (EFI_ERROR (Status)) {
1747 if (Private != NULL) {
1748 if (Private->FmpDeviceLockEvent != NULL) {
1749 gBS->CloseEvent (Private->FmpDeviceLockEvent);
1750 }
1751
1752 if (Private->Descriptor.VersionName != NULL) {
1753 FreePool (Private->Descriptor.VersionName);
1754 }
1755
1756 if (Private->FmpDeviceContext != NULL) {
1757 FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
1758 }
1759
1760 if (Private->VersionVariableName != NULL) {
1761 FreePool (Private->VersionVariableName);
1762 }
1763
1764 if (Private->LsvVariableName != NULL) {
1765 FreePool (Private->LsvVariableName);
1766 }
1767
1768 if (Private->LastAttemptStatusVariableName != NULL) {
1769 FreePool (Private->LastAttemptStatusVariableName);
1770 }
1771
1772 if (Private->LastAttemptVersionVariableName != NULL) {
1773 FreePool (Private->LastAttemptVersionVariableName);
1774 }
1775
1776 if (Private->FmpStateVariableName != NULL) {
1777 FreePool (Private->FmpStateVariableName);
1778 }
1779
1780 FreePool (Private);
1781 }
1782 }
1783
1784 return Status;
1785}
1786
1798EFIAPI
1800 IN EFI_HANDLE Handle
1801 )
1802{
1803 EFI_STATUS Status;
1806
1807 Status = gBS->OpenProtocol (
1808 Handle,
1809 &gEfiFirmwareManagementProtocolGuid,
1810 (VOID **)&Fmp,
1811 NULL,
1812 NULL,
1813 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1814 );
1815 if (EFI_ERROR (Status)) {
1816 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol open error. Status = %r.\n", mImageIdName, Status));
1817 return Status;
1818 }
1819
1820 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (Fmp);
1821 FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
1822
1823 if (Private->FmpDeviceLockEvent != NULL) {
1824 gBS->CloseEvent (Private->FmpDeviceLockEvent);
1825 }
1826
1827 Status = gBS->UninstallMultipleProtocolInterfaces (
1828 Private->Handle,
1829 &gEfiFirmwareManagementProtocolGuid,
1830 &Private->Fmp,
1832 &mFmpProgress,
1833 NULL
1834 );
1835 if (EFI_ERROR (Status)) {
1836 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol uninstall error. Status = %r.\n", mImageIdName, Status));
1837 return Status;
1838 }
1839
1840 if (Private->Descriptor.VersionName != NULL) {
1841 FreePool (Private->Descriptor.VersionName);
1842 }
1843
1844 if (Private->FmpDeviceContext != NULL) {
1845 FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
1846 }
1847
1848 if (Private->VersionVariableName != NULL) {
1849 FreePool (Private->VersionVariableName);
1850 }
1851
1852 if (Private->LsvVariableName != NULL) {
1853 FreePool (Private->LsvVariableName);
1854 }
1855
1856 if (Private->LastAttemptStatusVariableName != NULL) {
1857 FreePool (Private->LastAttemptStatusVariableName);
1858 }
1859
1860 if (Private->LastAttemptVersionVariableName != NULL) {
1861 FreePool (Private->LastAttemptVersionVariableName);
1862 }
1863
1864 if (Private->FmpStateVariableName != NULL) {
1865 FreePool (Private->FmpStateVariableName);
1866 }
1867
1868 FreePool (Private);
1869
1870 return EFI_SUCCESS;
1871}
1872
1883EFIAPI
1885 IN EFI_HANDLE ImageHandle,
1886 IN EFI_SYSTEM_TABLE *SystemTable
1887 )
1888{
1889 if (mFmpSingleInstance) {
1890 return UninstallFmpInstance (ImageHandle);
1891 }
1892
1893 return EFI_SUCCESS;
1894}
1895
1904EFIAPI
1906 IN EFI_HANDLE ImageHandle,
1907 IN EFI_SYSTEM_TABLE *SystemTable
1908 )
1909{
1910 EFI_STATUS Status;
1911
1912 //
1913 // Verify that a new FILE_GUID value has been provided in the <Defines>
1914 // section of this module. The FILE_GUID is the ESRT GUID that must be
1915 // unique for each updatable firmware image.
1916 //
1917 if (CompareGuid (&mDefaultModuleFileGuid, &gEfiCallerIdGuid)) {
1918 DEBUG ((DEBUG_ERROR, "FmpDxe: Use of default FILE_GUID detected. FILE_GUID must be set to a unique value.\n"));
1919 ASSERT (FALSE);
1920 return EFI_UNSUPPORTED;
1921 }
1922
1923 //
1924 // Get the ImageIdName value for the EFI_FIRMWARE_IMAGE_DESCRIPTOR from a PCD.
1925 //
1926 mImageIdName = (CHAR16 *)PcdGetPtr (PcdFmpDeviceImageIdName);
1927 if ((PcdGetSize (PcdFmpDeviceImageIdName) <= 2) || (mImageIdName[0] == 0)) {
1928 //
1929 // PcdFmpDeviceImageIdName must be set to a non-empty Unicode string
1930 //
1931 DEBUG ((DEBUG_ERROR, "FmpDxe(%g): PcdFmpDeviceImageIdName is an empty string.\n", &gEfiCallerIdGuid));
1932 ASSERT (FALSE);
1933 return EFI_UNSUPPORTED;
1934 }
1935
1936 //
1937 // Detects if PcdFmpDevicePkcs7CertBufferXdr contains a test key.
1938 //
1939 DetectTestKey ();
1940
1941 //
1942 // Fill in FMP Progress Protocol fields for Version 1
1943 //
1945 mFmpProgress.ProgressBarForegroundColor.Raw = PcdGet32 (PcdFmpDeviceProgressColor);
1946 mFmpProgress.WatchdogSeconds = PcdGet8 (PcdFmpDeviceProgressWatchdogTimeInSeconds);
1947
1948 // The lock event GUID is retrieved from PcdFmpDeviceLockEventGuid.
1949 // If PcdFmpDeviceLockEventGuid is not the size of an EFI_GUID, then
1950 // gEfiEndOfDxeEventGroupGuid is used.
1951 //
1952 mLockGuid = &gEfiEndOfDxeEventGroupGuid;
1953 if (PcdGetSize (PcdFmpDeviceLockEventGuid) == sizeof (EFI_GUID)) {
1954 mLockGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceLockEventGuid);
1955 }
1956
1957 DEBUG ((DEBUG_INFO, "FmpDxe(%s): Lock GUID: %g\n", mImageIdName, mLockGuid));
1958
1959 //
1960 // Register with library the install function so if the library uses
1961 // UEFI driver model/driver binding protocol it can install FMP on its device handle
1962 // If library is simple lib that does not use driver binding then it should return
1963 // unsupported and this will install the FMP instance on the ImageHandle
1964 //
1966 if (Status == EFI_UNSUPPORTED) {
1968 DEBUG ((DEBUG_INFO, "FmpDxe(%s): FmpDeviceLib registration returned EFI_UNSUPPORTED. Installing single FMP instance.\n", mImageIdName));
1970 if (Status == EFI_UNSUPPORTED) {
1971 Status = InstallFmpInstance (ImageHandle);
1972 } else {
1973 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n", mImageIdName));
1974 Status = EFI_UNSUPPORTED;
1975 }
1976 } else if (EFI_ERROR (Status)) {
1977 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib registration returned %r. No FMP installed.\n", mImageIdName, Status));
1978 } else {
1979 DEBUG ((
1980 DEBUG_INFO,
1981 "FmpDxe(%s): FmpDeviceLib registration returned EFI_SUCCESS. Expect FMP to be installed during the BDS/Device connection phase.\n",
1983 ));
1985 if (EFI_ERROR (Status)) {
1986 DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n", mImageIdName));
1987 }
1988 }
1989
1990 return Status;
1991}
UINT64 UINTN
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition: SwapBytes32.c:25
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
EFI_STATUS EFIAPI CheckSystemThermal(OUT BOOLEAN *Good)
BOOLEAN EFIAPI IsLowestSupportedVersionCheckRequired(VOID)
EFI_STATUS EFIAPI CheckSystemPower(OUT BOOLEAN *Good)
BOOLEAN EFIAPI IsLockFmpDeviceAtLockEventGuidRequired(VOID)
EFI_STATUS EFIAPI CheckSystemEnvironment(OUT BOOLEAN *Good)
VOID DetectTestKey(VOID)
Definition: DetectTestKey.c:23
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define IMAGE_UPDATABLE_INVALID
#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
#define IMAGE_UPDATABLE_INVALID_OLD
#define IMAGE_UPDATABLE_INVALID_TYPE
#define IMAGE_ATTRIBUTE_DEPENDENCY
#define IMAGE_UPDATABLE_VALID
EFI_STATUS(EFIAPI * EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS)(IN UINTN Completion)
EFI_GUID gEdkiiFirmwareManagementProgressProtocolGuid
RETURN_STATUS EFIAPI AuthenticateFmpImage(IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength)
BOOLEAN EFIAPI CheckFmpDependency(IN EFI_GUID ImageTypeId, IN UINT32 Version, IN EFI_FIRMWARE_IMAGE_DEP *Dependencies OPTIONAL, IN UINT32 DependenciesSize, OUT UINT32 *LastAttemptStatus OPTIONAL)
EFI_FIRMWARE_IMAGE_DEP *EFIAPI GetFmpDependency(OUT UINT32 *DepexSize)
EFI_STATUS EFIAPI SaveFmpDependency(IN EFI_FIRMWARE_IMAGE_DEP *Depex, IN UINT32 DepexSize)
EFI_FIRMWARE_IMAGE_DEP *EFIAPI GetImageDependency(IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, OUT UINT32 *DepexSize, OUT UINT32 *LastAttemptStatus OPTIONAL)
EFI_STATUS EFIAPI FmpDeviceGetImage(OUT VOID *Image, IN OUT UINTN *ImageSize)
Definition: FmpDeviceLib.c:374
EFI_STATUS EFIAPI FmpDeviceSetImageWithStatus(IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode OPTIONAL, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL, IN UINT32 CapsuleFwVersion, OUT CHAR16 **AbortReason, OUT UINT32 *LastAttemptStatus)
Definition: FmpDeviceLib.c:608
EFI_STATUS EFIAPI FmpDeviceGetSize(OUT UINTN *Size)
Definition: FmpDeviceLib.c:127
EFI_STATUS EFIAPI FmpDeviceLock(VOID)
Definition: FmpDeviceLib.c:640
EFI_STATUS EFIAPI FmpDeviceGetVersion(OUT UINT32 *Version)
Definition: FmpDeviceLib.c:306
EFI_STATUS EFIAPI FmpDeviceCheckImageWithStatus(IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable, OUT UINT32 *LastAttemptStatus)
Definition: FmpDeviceLib.c:455
EFI_STATUS EFIAPI FmpDeviceGetAttributes(OUT UINT64 *Supported, OUT UINT64 *Setting)
Definition: FmpDeviceLib.c:187
EFI_STATUS EFIAPI RegisterFmpInstaller(IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER FmpInstaller)
Definition: FmpDeviceLib.c:37
EFI_STATUS EFIAPI FmpDeviceGetHardwareInstance(OUT UINT64 *HardwareInstance)
Definition: FmpDeviceLib.c:335
EFI_STATUS EFIAPI FmpDeviceSetContext(IN EFI_HANDLE Handle, IN OUT VOID **Context)
Definition: FmpDeviceLib.c:98
EFI_STATUS EFIAPI FmpDeviceGetLowestSupportedVersion(OUT UINT32 *LowestSupportedVersion)
Definition: FmpDeviceLib.c:231
EFI_STATUS EFIAPI FmpDeviceGetVersionString(OUT CHAR16 **VersionString)
Definition: FmpDeviceLib.c:266
EFI_STATUS EFIAPI FmpDeviceGetImageTypeIdGuidPtr(OUT EFI_GUID **Guid)
Definition: FmpDeviceLib.c:158
EFI_STATUS EFIAPI RegisterFmpUninstaller(IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER FmpUninstaller)
Definition: FmpDeviceLib.c:65
BOOLEAN mFmpSingleInstance
Definition: FmpDxe.c:30
EFI_STATUS EFIAPI SetTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OUT CHAR16 **AbortReason)
Definition: FmpDxe.c:1166
EFI_STATUS EFIAPI FmpDxeLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: FmpDxe.c:1884
EFI_STATUS EFIAPI CheckTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable)
Definition: FmpDxe.c:1105
EFI_STATUS EFIAPI SetPackageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN UINT32 PackageVersion, IN CONST CHAR16 *PackageVersionName)
Definition: FmpDxe.c:1577
CHAR16 * mImageIdName
Definition: FmpDxe.c:101
EFI_STATUS EFIAPI GetTheImageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN OUT UINTN *ImageInfoSize, IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, OUT UINT32 *DescriptorVersion, OUT UINT8 *DescriptorCount, OUT UINTN *DescriptorSize, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName)
Definition: FmpDxe.c:451
EFI_STATUS EFIAPI UninstallFmpInstance(IN EFI_HANDLE Handle)
Definition: FmpDxe.c:1799
EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS mProgressFunc
Definition: FmpDxe.c:96
VOID EFIAPI FmpDxeLockEventNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: FmpDxe.c:1599
EFI_STATUS EFIAPI GetPackageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName, OUT UINT32 *PackageVersionNameMaxLen, OUT UINT64 *AttributesSupported, OUT UINT64 *AttributesSetting)
Definition: FmpDxe.c:1532
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL mFmpProgress
Definition: FmpDxe.c:36
EFI_STATUS EFIAPI FmpDxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: FmpDxe.c:1905
EFI_STATUS EFIAPI InstallFmpInstance(IN EFI_HANDLE Handle)
Definition: FmpDxe.c:1644
EFI_STATUS EFIAPI GetTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN OUT VOID *Image, IN OUT UINTN *ImageSize)
Definition: FmpDxe.c:567
const EFI_GUID mDefaultModuleFileGuid
Definition: FmpDxe.c:23
UINT32 GetLowestSupportedVersion(FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
Definition: FmpDxe.c:224
EFI_STATUS EFIAPI FmpDxeProgress(IN UINTN Completion)
Definition: FmpDxe.c:125
VOID PopulateDescriptor(FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
Definition: FmpDxe.c:282
CHAR16 * GetImageTypeNameString(VOID)
Definition: FmpDxe.c:204
EFI_STATUS EFIAPI CheckTheImageInternal(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable, OUT UINT32 *LastAttemptStatus)
Definition: FmpDxe.c:763
UINT32 GetAllHeaderSize(IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINT32 AdditionalHeaderSize)
Definition: FmpDxe.c:691
EFI_GUID * mLockGuid
Definition: FmpDxe.c:91
EFI_GUID * GetImageTypeIdGuid(VOID)
Definition: FmpDxe.c:160
VOID * GetFmpHeader(IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN CONST UINTN ImageSize, IN CONST UINTN AdditionalHeaderSize, OUT UINTN *PayloadSize OPTIONAL)
Definition: FmpDxe.c:653
@ LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER
EFI_STATUS EFIAPI GetFmpPayloadHeaderLowestSupportedVersion(IN CONST VOID *Header, IN CONST UINTN FmpPayloadSize, OUT UINT32 *LowestSupportedVersion)
EFI_STATUS EFIAPI GetFmpPayloadHeaderVersion(IN CONST VOID *Header, IN CONST UINTN FmpPayloadSize, OUT UINT32 *Version)
EFI_STATUS EFIAPI GetFmpPayloadHeaderSize(IN CONST VOID *Header, IN CONST UINTN FmpPayloadSize, OUT UINT32 *Size)
#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE
#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define ALIGN_POINTER(Pointer, Alignment)
Definition: Base.h:963
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGetSize(TokenName)
Definition: PcdLib.h:440
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
#define LAST_ATTEMPT_STATUS_SUCCESS
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
UINT32 GetLastAttemptStatusFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetVersionInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 Version)
UINT32 GetLastAttemptVersionFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
UINT32 GetLowestSupportedVersionFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetLowestSupportedVersionInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 LowestSupportedVersion)
VOID GenerateFmpVariableNames(IN OUT FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
UINT32 GetVersionFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetLastAttemptStatusInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 LastAttemptStatus)
EFI_STATUS LockAllFmpVariables(FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetLastAttemptVersionInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 LastAttemptVersion)
#define DEFAULT_VERSION
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION ProgressBarForegroundColor
Definition: Base.h:213