PeiFspMiscUpdUpdateLib.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /** @file
  2. Implementation of Fsp Misc UPD Initialization.
  3. Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <Library/DebugLib.h>
  8. #include <Library/PeiLib.h>
  9. #include <Library/ConfigBlockLib.h>
  10. #include <FspEas.h>
  11. #include <FspmUpd.h>
  12. #include <FspsUpd.h>
  13. #include <Library/MemoryAllocationLib.h>
  14. #include <Library/DebugLib.h>
  15. #include <Library/DebugPrintErrorLevelLib.h>
  16. #include <Library/PciLib.h>
  17. #include <Guid/MemoryOverwriteControl.h>
  18. #include <PchAccess.h>
  19. /**
  20. Performs FSP Misc UPD initialization.
  21. @param[in][out] FspmUpd Pointer to FSPM_UPD Data.
  22. @retval EFI_SUCCESS FSP UPD Data is updated.
  23. **/
  24. EFI_STATUS
  25. EFIAPI
  26. PeiFspMiscUpdUpdatePreMem (
  27. IN OUT FSPM_UPD *FspmUpd
  28. )
  29. {
  30. EFI_STATUS Status;
  31. UINTN VariableSize;
  32. VOID *MemorySavedData;
  33. UINT8 MorControl;
  34. VOID *MorControlPtr;
  35. //
  36. // Initialize S3 Data variable (S3DataPtr). It may be used for warm and fast boot paths.
  37. //
  38. VariableSize = 0;
  39. MemorySavedData = NULL;
  40. Status = PeiGetVariable (
  41. L"MemoryConfig",
  42. &gFspNonVolatileStorageHobGuid,
  43. &MemorySavedData,
  44. &VariableSize
  45. );
  46. DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid - %r\n", Status));
  47. DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));
  48. FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
  49. if (FspmUpd->FspmArchUpd.NvsBufferPtr != NULL) {
  50. //
  51. // Set the DISB bit in PCH (DRAM Initialization Scratchpad Bit - GEN_PMCON_A[23]),
  52. // after memory Data is saved to NVRAM.
  53. //
  54. PciOr32 ((UINTN)PCI_LIB_ADDRESS (0, PCI_DEVICE_NUMBER_PCH_PMC, PCI_FUNCTION_NUMBER_PCH_PMC, R_PCH_PMC_GEN_PMCON_A), B_PCH_PMC_GEN_PMCON_A_DISB);
  55. }
  56. //
  57. // MOR
  58. //
  59. MorControl = 0;
  60. MorControlPtr = &MorControl;
  61. VariableSize = sizeof (MorControl);
  62. Status = PeiGetVariable (
  63. MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
  64. &gEfiMemoryOverwriteControlDataGuid,
  65. &MorControlPtr,
  66. &VariableSize
  67. );
  68. DEBUG ((DEBUG_INFO, "MorControl - 0x%x (%r)\n", MorControl, Status));
  69. if (MOR_CLEAR_MEMORY_VALUE (MorControl)) {
  70. FspmUpd->FspmConfig.CleanMemory = (BOOLEAN)(MorControl & MOR_CLEAR_MEMORY_BIT_MASK);
  71. }
  72. return EFI_SUCCESS;
  73. }