SystemFirmwareDescriptorPei.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. This program and the accompanying materials
  7. are licensed and made available under the terms and conditions of the BSD License
  8. which accompanies this distribution. The full text of the license may be found at
  9. http://opensource.org/licenses/bsd-license.php
  10. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  12. **/
  13. #include <PiPei.h>
  14. #include <Guid/EdkiiSystemFmpCapsule.h>
  15. #include <Library/DebugLib.h>
  16. #include <Library/PcdLib.h>
  17. #include <Library/PeiServicesLib.h>
  18. #include <Protocol/FirmwareManagement.h>
  19. /**
  20. Entrypoint for SystemFirmwareDescriptor PEIM.
  21. @param[in] FileHandle Handle of the file being invoked.
  22. @param[in] PeiServices Describes the list of possible PEI Services.
  23. @retval EFI_SUCCESS PPI successfully installed.
  24. **/
  25. EFI_STATUS
  26. EFIAPI
  27. SystemFirmwareDescriptorPeimEntry (
  28. IN EFI_PEI_FILE_HANDLE FileHandle,
  29. IN CONST EFI_PEI_SERVICES **PeiServices
  30. )
  31. {
  32. EFI_STATUS Status;
  33. EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *Descriptor;
  34. UINTN Size;
  35. UINTN Index;
  36. UINT32 AuthenticationStatus;
  37. //
  38. // Search RAW section.
  39. //
  40. Index = 0;
  41. while (TRUE) {
  42. Status = PeiServicesFfsFindSectionData3 (EFI_SECTION_RAW, Index, FileHandle, (VOID **)&Descriptor, &AuthenticationStatus);
  43. if (EFI_ERROR (Status)) {
  44. // Should not happen, must something wrong in FDF.
  45. DEBUG ((DEBUG_ERROR, "Not found SystemFirmwareDescriptor in fdf !\n"));
  46. return EFI_NOT_FOUND;
  47. }
  48. if (Descriptor->Signature == EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) {
  49. break;
  50. }
  51. Index++;
  52. }
  53. DEBUG ((DEBUG_INFO, "EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR size - 0x%x\n", Descriptor->Length));
  54. Size = Descriptor->Length;
  55. PcdSetPtrS (PcdEdkiiSystemFirmwareImageDescriptor, &Size, Descriptor);
  56. return EFI_SUCCESS;
  57. }