PeiSaPolicyUpdate.c 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /** @file
  2. Do Platform Stage System Agent initialization.
  3. Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "PeiSaPolicyUpdate.h"
  7. #include <Guid/MemoryTypeInformation.h>
  8. #include <Library/HobLib.h>
  9. #include <PchAccess.h>
  10. #include <SaAccess.h>
  11. #include <Pi/PiFirmwareFile.h>
  12. #include <Pi/PiPeiCis.h>
  13. #include <Library/BaseMemoryLib.h>
  14. #include <Library/MemoryAllocationLib.h>
  15. #include <Library/PeiSaPolicyLib.h>
  16. #include <Library/PeiLib.h>
  17. #include <Library/PeiServicesLib.h>
  18. /**
  19. Performs FSP SA PEI Policy initialization.
  20. @param[in][out] FspsUpd Pointer to FSP UPD Data.
  21. @retval EFI_SUCCESS FSP UPD Data is updated.
  22. @retval EFI_NOT_FOUND Fail to locate required PPI.
  23. @retval Other FSP UPD Data update process fail.
  24. **/
  25. EFI_STATUS
  26. EFIAPI
  27. PeiFspSaPolicyUpdate (
  28. IN OUT FSPS_UPD *FspsUpd
  29. )
  30. {
  31. EFI_STATUS Status;
  32. EFI_BOOT_MODE BootMode;
  33. VOID *Buffer;
  34. VOID *MemBuffer;
  35. UINT32 Size;
  36. DEBUG((DEBUG_INFO, "\nUpdating SA Policy in Post Mem\n"));
  37. Status = PeiServicesGetBootMode (&BootMode);
  38. ASSERT_EFI_ERROR (Status);
  39. FspsUpd->FspsConfig.PeiGraphicsPeimInit = 1;
  40. Size = 0;
  41. Buffer = NULL;
  42. PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RAW, 0, &Buffer, &Size);
  43. if (Buffer == NULL) {
  44. DEBUG((DEBUG_WARN, "Could not locate VBT\n"));
  45. //
  46. // Graphics initialization is unnecessary,
  47. // OS has present framebuffer.
  48. //
  49. } else if (BootMode != BOOT_ON_S3_RESUME) {
  50. MemBuffer = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size));
  51. if ((MemBuffer != NULL) && (Buffer != NULL)) {
  52. CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size);
  53. FspsUpd->FspsConfig.GraphicsConfigPtr = (UINT32)(UINTN)MemBuffer;
  54. } else {
  55. DEBUG((DEBUG_WARN, "Error in locating / copying VBT.\n"));
  56. FspsUpd->FspsConfig.GraphicsConfigPtr = 0;
  57. }
  58. }
  59. DEBUG((DEBUG_INFO, "Vbt Pointer from PeiGetSectionFromFv is 0x%x\n", FspsUpd->FspsConfig.GraphicsConfigPtr));
  60. DEBUG((DEBUG_INFO, "Vbt Size from PeiGetSectionFromFv is 0x%x\n", Size));
  61. Size = 0;
  62. Buffer = NULL;
  63. PeiGetSectionFromAnyFv (&gTianoLogoGuid, EFI_SECTION_RAW, 0, &Buffer, &Size);
  64. if (Buffer == NULL) {
  65. DEBUG((DEBUG_WARN, "Could not locate Logo\n"));
  66. } else {
  67. MemBuffer = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size));
  68. if ((MemBuffer != NULL) && (Buffer != NULL)) {
  69. CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size);
  70. FspsUpd->FspsConfig.LogoPtr = (UINT32)(UINTN)MemBuffer;
  71. FspsUpd->FspsConfig.LogoSize = Size;
  72. } else {
  73. DEBUG((DEBUG_WARN, "Error in locating / copying LogoPtr.\n"));
  74. FspsUpd->FspsConfig.LogoPtr = 0;
  75. FspsUpd->FspsConfig.LogoSize = 0;
  76. }
  77. }
  78. DEBUG((DEBUG_INFO, "LogoPtr from PeiGetSectionFromFv is 0x%x\n", FspsUpd->FspsConfig.LogoPtr));
  79. DEBUG((DEBUG_INFO, "LogoSize from PeiGetSectionFromFv is 0x%x\n", FspsUpd->FspsConfig.LogoSize));
  80. return EFI_SUCCESS;
  81. }