SystemFirmwareDescriptorPei.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /** @file
  2. System Firmware descriptor producer.
  3. Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <Library/PcdLib.h>
  8. #include <Library/PeiServicesLib.h>
  9. #include <Library/DebugLib.h>
  10. #include <Protocol/FirmwareManagement.h>
  11. #include <Guid/EdkiiSystemFmpCapsule.h>
  12. /**
  13. Entrypoint for SystemFirmwareDescriptor PEIM.
  14. @param[in] FileHandle Handle of the file being invoked.
  15. @param[in] PeiServices Describes the list of possible PEI Services.
  16. @retval EFI_SUCCESS PPI successfully installed.
  17. **/
  18. EFI_STATUS
  19. EFIAPI
  20. SystemFirmwareDescriptorPeimEntry (
  21. IN EFI_PEI_FILE_HANDLE FileHandle,
  22. IN CONST EFI_PEI_SERVICES **PeiServices
  23. )
  24. {
  25. EFI_STATUS Status;
  26. EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor;
  27. UINTN Size;
  28. UINTN Index;
  29. UINT32 AuthenticationStatus;
  30. //
  31. // Search RAW section.
  32. //
  33. Index = 0;
  34. while (TRUE) {
  35. Status = PeiServicesFfsFindSectionData3(EFI_SECTION_RAW, Index, FileHandle, (VOID **)&Descriptor, &AuthenticationStatus);
  36. if (EFI_ERROR(Status)) {
  37. // Should not happen, must something wrong in FDF.
  38. ASSERT(FALSE);
  39. return EFI_NOT_FOUND;
  40. }
  41. if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) {
  42. break;
  43. }
  44. Index++;
  45. }
  46. DEBUG((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", Descriptor->Length));
  47. Size = Descriptor->Length;
  48. PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor);
  49. return EFI_SUCCESS;
  50. }