PeiFspPolicyUpdateLib.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /** @file
  2. Provide FSP wrapper platform related function.
  3. ` Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <Library/PcdLib.h>
  8. #include <Library/DebugLib.h>
  9. #include <Library/BaseMemoryLib.h>
  10. #include <Library/MemoryAllocationLib.h>
  11. #include <Library/FspWrapperApiLib.h>
  12. #include <Library/SiliconPolicyUpdateLib.h>
  13. #include <FspEas.h>
  14. #include <FspmUpd.h>
  15. #include <FspsUpd.h>
  16. #include "PeiMiscPolicyUpdate.h"
  17. /**
  18. Performs FSP PCH 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. PeiFspPchPolicyUpdate (
  27. IN OUT FSPS_UPD *FspsUpd
  28. );
  29. VOID
  30. InternalPrintVariableData (
  31. IN UINT8 *Data8,
  32. IN UINTN DataSize
  33. )
  34. {
  35. UINTN Index;
  36. for (Index = 0; Index < DataSize; Index++) {
  37. if (Index % 0x10 == 0) {
  38. DEBUG ((DEBUG_INFO, "\n%08X:", Index));
  39. }
  40. DEBUG ((DEBUG_INFO, " %02X", *Data8++));
  41. }
  42. DEBUG ((DEBUG_INFO, "\n"));
  43. }
  44. /**
  45. Performs silicon pre-mem policy update.
  46. The meaning of Policy is defined by silicon code.
  47. It could be the raw data, a handle, a PPI, etc.
  48. The input Policy must be returned by SiliconPolicyDonePreMem().
  49. 1) In FSP path, the input Policy should be FspmUpd.
  50. A platform may use this API to update the FSPM UPD policy initialized
  51. by the silicon module or the default UPD data.
  52. The output of FSPM UPD data from this API is the final UPD data.
  53. 2) In non-FSP path, the board may use additional way to get
  54. the silicon policy data field based upon the input Policy.
  55. @param[in, out] Policy Pointer to policy.
  56. @return the updated policy.
  57. **/
  58. VOID *
  59. EFIAPI
  60. SiliconPolicyUpdatePreMem (
  61. IN OUT VOID *FspmUpd
  62. )
  63. {
  64. FSPM_UPD *FspmUpdDataPtr;
  65. FspmUpdDataPtr = FspmUpd;
  66. PeiFspMiscUpdUpdatePreMem (FspmUpdDataPtr);
  67. InternalPrintVariableData ((VOID *) FspmUpdDataPtr, sizeof (FSPM_UPD));
  68. return FspmUpd;
  69. }
  70. /**
  71. Performs silicon post-mem policy update.
  72. The meaning of Policy is defined by silicon code.
  73. It could be the raw data, a handle, a PPI, etc.
  74. The input Policy must be returned by SiliconPolicyDonePostMem().
  75. 1) In FSP path, the input Policy should be FspsUpd.
  76. A platform may use this API to update the FSPS UPD policy initialized
  77. by the silicon module or the default UPD data.
  78. The output of FSPS UPD data from this API is the final UPD data.
  79. 2) In non-FSP path, the board may use additional way to get
  80. the silicon policy data field based upon the input Policy.
  81. @param[in, out] Policy Pointer to policy.
  82. @return the updated policy.
  83. **/
  84. VOID *
  85. EFIAPI
  86. SiliconPolicyUpdatePostMem (
  87. IN OUT VOID *FspsUpd
  88. )
  89. {
  90. FSPS_UPD *FspsUpdDataPtr;
  91. FspsUpdDataPtr = FspsUpd;
  92. PeiFspPchPolicyUpdate (FspsUpd);
  93. InternalPrintVariableData ((VOID * )FspsUpdDataPtr, sizeof (FSPS_UPD));
  94. return FspsUpd;
  95. }