SystemFirmwareDescriptorPei.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <Guid/EdkiiSystemFmpCapsule.h>
  8. #include <Library/DebugLib.h>
  9. #include <Library/PcdLib.h>
  10. #include <Library/PeiServicesLib.h>
  11. #include <Protocol/FirmwareManagement.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,
  36. (VOID **)&Descriptor, &AuthenticationStatus);
  37. if (EFI_ERROR(Status)) {
  38. // Should not happen, must something wrong in FDF.
  39. ASSERT(FALSE);
  40. return EFI_NOT_FOUND;
  41. }
  42. if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) {
  43. break;
  44. }
  45. Index++;
  46. }
  47. DEBUG((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n",
  48. Descriptor->Length));
  49. Size = Descriptor->Length;
  50. PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor);
  51. return EFI_SUCCESS;
  52. }