PeiSaPolicyUpdate.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <Library/BaseMemoryLib.h>
  8. #include <Library/MemoryAllocationLib.h>
  9. #include <Library/PeiSaPolicyLib.h>
  10. #include <Library/PeiLib.h>
  11. #include <Library/PeiServicesLib.h>
  12. /**
  13. Performs FSP SA PEI Policy initialization.
  14. @param[in][out] FspsUpd Pointer to FSP UPD Data.
  15. @retval EFI_SUCCESS FSP UPD Data is updated.
  16. @retval EFI_NOT_FOUND Fail to locate required PPI.
  17. @retval Other FSP UPD Data update process fail.
  18. **/
  19. EFI_STATUS
  20. EFIAPI
  21. PeiFspSaPolicyUpdate (
  22. IN OUT FSPS_UPD *FspsUpd
  23. )
  24. {
  25. EFI_STATUS Status;
  26. EFI_BOOT_MODE BootMode;
  27. VOID *Buffer;
  28. VOID *MemBuffer;
  29. UINT32 Size;
  30. DEBUG((DEBUG_INFO, "\nUpdating SA Policy in Post Mem\n"));
  31. Status = PeiServicesGetBootMode (&BootMode);
  32. ASSERT_EFI_ERROR (Status);
  33. FspsUpd->FspsConfig.PeiGraphicsPeimInit = 1;
  34. Size = 0;
  35. Buffer = NULL;
  36. PeiGetSectionFromAnyFv (PcdGetPtr (PcdGraphicsVbtGuid), EFI_SECTION_RAW, 0, &Buffer, &Size);
  37. if (Buffer == NULL) {
  38. DEBUG((DEBUG_WARN, "Could not locate VBT\n"));
  39. //
  40. // Graphics initialization is unnecessary,
  41. // OS has present framebuffer.
  42. //
  43. } else if (BootMode != BOOT_ON_S3_RESUME) {
  44. MemBuffer = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size));
  45. if ((MemBuffer != NULL) && (Buffer != NULL)) {
  46. CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size);
  47. FspsUpd->FspsConfig.GraphicsConfigPtr = (UINT32)(UINTN)MemBuffer;
  48. } else {
  49. DEBUG((DEBUG_WARN, "Error in locating / copying VBT.\n"));
  50. FspsUpd->FspsConfig.GraphicsConfigPtr = 0;
  51. }
  52. }
  53. DEBUG((DEBUG_INFO, "Vbt Pointer from PeiGetSectionFromFv is 0x%x\n", FspsUpd->FspsConfig.GraphicsConfigPtr));
  54. DEBUG((DEBUG_INFO, "Vbt Size from PeiGetSectionFromFv is 0x%x\n", Size));
  55. Size = 0;
  56. Buffer = NULL;
  57. PeiGetSectionFromAnyFv (&gTianoLogoGuid, EFI_SECTION_RAW, 0, &Buffer, &Size);
  58. if (Buffer == NULL) {
  59. DEBUG((DEBUG_WARN, "Could not locate Logo\n"));
  60. } else {
  61. MemBuffer = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)Size));
  62. if ((MemBuffer != NULL) && (Buffer != NULL)) {
  63. CopyMem (MemBuffer, (VOID *)Buffer, (UINTN)Size);
  64. FspsUpd->FspsConfig.LogoPtr = (UINT32)(UINTN)MemBuffer;
  65. FspsUpd->FspsConfig.LogoSize = Size;
  66. } else {
  67. DEBUG((DEBUG_WARN, "Error in locating / copying LogoPtr.\n"));
  68. FspsUpd->FspsConfig.LogoPtr = 0;
  69. FspsUpd->FspsConfig.LogoSize = 0;
  70. }
  71. }
  72. DEBUG((DEBUG_INFO, "LogoPtr from PeiGetSectionFromFv is 0x%x\n", FspsUpd->FspsConfig.LogoPtr));
  73. DEBUG((DEBUG_INFO, "LogoSize from PeiGetSectionFromFv is 0x%x\n", FspsUpd->FspsConfig.LogoSize));
  74. return EFI_SUCCESS;
  75. }