SystemFirmwareDescriptorPei.c 1.9 KB

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