PeiSaPolicyUpdate.c 2.9 KB

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