PeiFspCpuPolicyInitLib.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. /** @file
  2. Implementation of Fsp CPU Policy Initialization.
  3. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PeiFspPolicyInitLib.h>
  7. #include <Ppi/SiPolicy.h>
  8. #include <Ppi/SecPlatformInformation2.h>
  9. #include <CpuAccess.h>
  10. #include <Library/HobLib.h>
  11. #include <Library/BaseMemoryLib.h>
  12. #include <Library/ConfigBlockLib.h>
  13. #include <Library/MemoryAllocationLib.h>
  14. #include <Library/PeiServicesLib.h>
  15. #include <Library/PeiServicesTablePointerLib.h>
  16. #include <Library/PcdLib.h>
  17. #include <FspEas.h>
  18. /**
  19. Performs FSP CPU PEI Policy initialization.
  20. @param[in][out] FspmUpd 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. PeiFspCpuPolicyInitPreMem (
  28. IN OUT FSPM_UPD *FspmUpd
  29. )
  30. {
  31. EFI_STATUS Status;
  32. SI_PREMEM_POLICY_PPI *SiPreMemPolicyPpi;
  33. CPU_OVERCLOCKING_PREMEM_CONFIG *CpuOverClockingPreMemConfig;
  34. CPU_CONFIG_LIB_PREMEM_CONFIG *CpuConfigLibPreMemConfig;
  35. DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP Update SiCpuPolicy Pre-Mem Start\n"));
  36. //
  37. // Locate SiPreMemPolicyPpi
  38. //
  39. SiPreMemPolicyPpi = NULL;
  40. Status = PeiServicesLocatePpi (
  41. &gSiPreMemPolicyPpiGuid,
  42. 0,
  43. NULL,
  44. (VOID **) &SiPreMemPolicyPpi
  45. );
  46. if (EFI_ERROR (Status)) {
  47. return EFI_NOT_FOUND;
  48. }
  49. Status = GetConfigBlock ((VOID *) SiPreMemPolicyPpi, &gCpuOverclockingPreMemConfigGuid, (VOID *) &CpuOverClockingPreMemConfig);
  50. ASSERT_EFI_ERROR (Status);
  51. Status = GetConfigBlock ((VOID *) SiPreMemPolicyPpi, &gCpuConfigLibPreMemConfigGuid, (VOID *) &CpuConfigLibPreMemConfig);
  52. ASSERT_EFI_ERROR (Status);
  53. ///
  54. ///
  55. DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP Update SiCpuPolicy Pre-Mem End\n"));
  56. //
  57. // Overclocking PreMem policies
  58. //
  59. FspmUpd->FspmConfig.OcSupport = (UINT8) CpuOverClockingPreMemConfig->OcSupport;
  60. FspmUpd->FspmConfig.OcLock = (UINT8) CpuOverClockingPreMemConfig->OcLock;
  61. FspmUpd->FspmConfig.CoreMaxOcRatio = (UINT8) CpuOverClockingPreMemConfig->CoreMaxOcRatio;
  62. FspmUpd->FspmConfig.CoreVoltageMode = (UINT8) CpuOverClockingPreMemConfig->CoreVoltageMode;
  63. FspmUpd->FspmConfig.CoreVoltageOverride = (UINT16) CpuOverClockingPreMemConfig->CoreVoltageOverride;
  64. FspmUpd->FspmConfig.CoreVoltageAdaptive = (UINT16) CpuOverClockingPreMemConfig->CoreVoltageAdaptive;
  65. FspmUpd->FspmConfig.CoreVoltageOffset = (UINT16) CpuOverClockingPreMemConfig->CoreVoltageOffset;
  66. FspmUpd->FspmConfig.CorePllVoltageOffset = (UINT8) CpuOverClockingPreMemConfig->CorePllVoltageOffset;
  67. FspmUpd->FspmConfig.RingMaxOcRatio = (UINT8) CpuOverClockingPreMemConfig->RingMaxOcRatio;
  68. FspmUpd->FspmConfig.RingVoltageOverride = (UINT16) CpuOverClockingPreMemConfig->RingVoltageOverride;
  69. FspmUpd->FspmConfig.RingVoltageAdaptive = (UINT16) CpuOverClockingPreMemConfig->RingVoltageAdaptive;
  70. FspmUpd->FspmConfig.RingVoltageOffset = (UINT16) CpuOverClockingPreMemConfig->RingVoltageOffset;
  71. FspmUpd->FspmConfig.RingPllVoltageOffset = (UINT8) CpuOverClockingPreMemConfig->RingPllVoltageOffset;
  72. FspmUpd->FspmConfig.GtPllVoltageOffset = (UINT8) CpuOverClockingPreMemConfig->GtPllVoltageOffset;
  73. FspmUpd->FspmConfig.RingPllVoltageOffset = (UINT8) CpuOverClockingPreMemConfig->RingPllVoltageOffset;
  74. FspmUpd->FspmConfig.SaPllVoltageOffset = (UINT8) CpuOverClockingPreMemConfig->SaPllVoltageOffset;
  75. FspmUpd->FspmConfig.McPllVoltageOffset = (UINT8) CpuOverClockingPreMemConfig->McPllVoltageOffset;
  76. FspmUpd->FspmConfig.RingDownBin = (UINT8) CpuOverClockingPreMemConfig->RingDownBin;
  77. FspmUpd->FspmConfig.RingVoltageMode = (UINT8) CpuOverClockingPreMemConfig->RingVoltageMode;
  78. FspmUpd->FspmConfig.Avx2RatioOffset = (UINT8) CpuOverClockingPreMemConfig->Avx2RatioOffset;
  79. FspmUpd->FspmConfig.Avx3RatioOffset = (UINT8) CpuOverClockingPreMemConfig->Avx3RatioOffset;
  80. FspmUpd->FspmConfig.BclkAdaptiveVoltage = (UINT8) CpuOverClockingPreMemConfig->BclkAdaptiveVoltage;
  81. FspmUpd->FspmConfig.TjMaxOffset = (UINT8) CpuOverClockingPreMemConfig->TjMaxOffset;
  82. FspmUpd->FspmConfig.TvbRatioClipping = (UINT8) CpuOverClockingPreMemConfig->TvbRatioClipping;
  83. FspmUpd->FspmConfig.TvbVoltageOptimization = (UINT8) CpuOverClockingPreMemConfig->TvbVoltageOptimization;
  84. //
  85. // Cpu Config Lib policies
  86. //
  87. FspmUpd->FspmConfig.HyperThreading = (UINT8) CpuConfigLibPreMemConfig->HyperThreading;
  88. FspmUpd->FspmConfig.BootFrequency = (UINT8) CpuConfigLibPreMemConfig->BootFrequency;
  89. FspmUpd->FspmConfig.ActiveCoreCount = (UINT8) CpuConfigLibPreMemConfig->ActiveCoreCount;
  90. FspmUpd->FspmConfig.JtagC10PowerGateDisable = (UINT8) CpuConfigLibPreMemConfig->JtagC10PowerGateDisable;
  91. FspmUpd->FspmConfig.FClkFrequency = (UINT8) CpuConfigLibPreMemConfig->FClkFrequency;
  92. FspmUpd->FspmConfig.BistOnReset = (UINT8) CpuConfigLibPreMemConfig->BistOnReset;
  93. FspmUpd->FspmConfig.VmxEnable = (UINT8) CpuConfigLibPreMemConfig->VmxEnable;
  94. FspmUpd->FspmConfig.CpuRatio = (UINT8) CpuConfigLibPreMemConfig->CpuRatio;
  95. FspmUpd->FspmConfig.PeciSxReset = (UINT8) CpuConfigLibPreMemConfig->PeciSxReset;
  96. FspmUpd->FspmConfig.PeciC10Reset = (UINT8) CpuConfigLibPreMemConfig->PeciC10Reset;
  97. FspmUpd->FspmConfig.SkipMpInit = (UINT8) CpuConfigLibPreMemConfig->SkipMpInit;
  98. FspmUpd->FspmConfig.DpSscMarginEnable = (UINT8) CpuConfigLibPreMemConfig->DpSscMarginEnable;
  99. //
  100. // DisableMtrrProgram <1> Disable Mtrrs program. <0> Program Mtrrs in FSP
  101. //
  102. FspmUpd->FspmConfig.DisableMtrrProgram = (UINT8) 0;
  103. return EFI_SUCCESS;
  104. }
  105. /**
  106. This routine is used to get Sec Platform Information Record2 Pointer.
  107. @param[in] PeiServices Pointer to the PEI services table
  108. @retval GetSecPlatformInformation2 - The pointer of Sec Platform Information Record2 Pointer.
  109. **/
  110. EFI_SEC_PLATFORM_INFORMATION_RECORD2 * GetSecPlatformInformation2(
  111. IN EFI_PEI_SERVICES **PeiServices
  112. )
  113. {
  114. EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi;
  115. EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2 = NULL;
  116. UINT64 InformationSize;
  117. EFI_STATUS Status;
  118. //
  119. // Get BIST information from Sec Platform Information2 Ppi firstly
  120. //
  121. Status = PeiServicesLocatePpi (
  122. &gEfiSecPlatformInformation2PpiGuid, // GUID
  123. 0, // Instance
  124. NULL, // EFI_PEI_PPI_DESCRIPTOR
  125. (VOID ** ) &SecPlatformInformation2Ppi // PPI
  126. );
  127. DEBUG((DEBUG_INFO, "LocatePpi SecPlatformInformationPpi2 Status - %x\n", Status));
  128. if (EFI_ERROR(Status)) {
  129. return NULL;
  130. }
  131. InformationSize = 0;
  132. Status = SecPlatformInformation2Ppi->PlatformInformation2 (
  133. (CONST EFI_PEI_SERVICES **) PeiServices,
  134. &InformationSize,
  135. SecPlatformInformation2
  136. );
  137. ASSERT (Status == EFI_BUFFER_TOO_SMALL);
  138. if (Status != EFI_BUFFER_TOO_SMALL) {
  139. return NULL;
  140. }
  141. SecPlatformInformation2 = AllocatePool((UINTN)InformationSize);
  142. ASSERT (SecPlatformInformation2 != NULL);
  143. if (SecPlatformInformation2 == NULL) {
  144. return NULL;
  145. }
  146. //
  147. // Retrieve BIST data from SecPlatform2
  148. //
  149. Status = SecPlatformInformation2Ppi->PlatformInformation2 (
  150. (CONST EFI_PEI_SERVICES **) PeiServices,
  151. &InformationSize,
  152. SecPlatformInformation2
  153. );
  154. DEBUG((DEBUG_INFO, "SecPlatformInformation2Ppi->PlatformInformation2 Status - %x\n", Status));
  155. ASSERT_EFI_ERROR (Status);
  156. if (EFI_ERROR (Status)) {
  157. return NULL;
  158. }
  159. return SecPlatformInformation2;
  160. }
  161. /**
  162. This routine is used to get Sec Platform Information Record Pointer.
  163. @param[in] PeiServices Pointer to the PEI services table
  164. @retval GetSecPlatformInformation2 - The pointer of Sec Platform Information Record Pointer.
  165. **/
  166. EFI_SEC_PLATFORM_INFORMATION_RECORD2 * GetSecPlatformInformationInfoInFormat2(
  167. IN EFI_PEI_SERVICES **PeiServices
  168. )
  169. {
  170. EFI_SEC_PLATFORM_INFORMATION_PPI *SecPlatformInformationPpi;
  171. EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation = NULL;
  172. EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;
  173. UINT64 InformationSize;
  174. EFI_STATUS Status;
  175. //
  176. // Get BIST information from Sec Platform Information
  177. //
  178. Status = PeiServicesLocatePpi (
  179. &gEfiSecPlatformInformationPpiGuid, // GUID
  180. 0, // Instance
  181. NULL, // EFI_PEI_PPI_DESCRIPTOR
  182. (VOID ** ) &SecPlatformInformationPpi // PPI
  183. );
  184. DEBUG((DEBUG_INFO, "LocatePpi SecPlatformInformationPpi Status - %x\n", Status));
  185. if (EFI_ERROR(Status)) {
  186. return NULL;
  187. }
  188. InformationSize = 0;
  189. Status = SecPlatformInformationPpi->PlatformInformation (
  190. (CONST EFI_PEI_SERVICES **) PeiServices,
  191. &InformationSize,
  192. SecPlatformInformation
  193. );
  194. ASSERT (Status == EFI_BUFFER_TOO_SMALL);
  195. if (Status != EFI_BUFFER_TOO_SMALL) {
  196. return NULL;
  197. }
  198. SecPlatformInformation = AllocatePool((UINTN)InformationSize);
  199. ASSERT (SecPlatformInformation != NULL);
  200. if (SecPlatformInformation == NULL) {
  201. return NULL;
  202. }
  203. //
  204. // Retrieve BIST data from SecPlatform
  205. //
  206. Status = SecPlatformInformationPpi->PlatformInformation (
  207. (CONST EFI_PEI_SERVICES **) PeiServices,
  208. &InformationSize,
  209. SecPlatformInformation
  210. );
  211. DEBUG((DEBUG_INFO, "FSP SecPlatformInformation2Ppi->PlatformInformation Status - %x\n", Status));
  212. ASSERT_EFI_ERROR (Status);
  213. if (EFI_ERROR (Status)) {
  214. return NULL;
  215. }
  216. SecPlatformInformation2 = AllocatePool(sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2));
  217. ASSERT (SecPlatformInformation2 != NULL);
  218. if (SecPlatformInformation2 == NULL) {
  219. return NULL;
  220. }
  221. SecPlatformInformation2->NumberOfCpus = 1;
  222. SecPlatformInformation2->CpuInstance[0].CpuLocation = 0;
  223. SecPlatformInformation2->CpuInstance[0].InfoRecord.x64HealthFlags.Uint32 = SecPlatformInformation->x64HealthFlags.Uint32;
  224. FreePool(SecPlatformInformation);
  225. return SecPlatformInformation2;
  226. }
  227. /**
  228. Performs FSP CPU PEI Policy post memory initialization.
  229. @param[in][out] FspsUpd Pointer to FSP UPD Data.
  230. @retval EFI_SUCCESS FSP UPD Data is updated.
  231. @retval EFI_NOT_FOUND Fail to locate required PPI.
  232. @retval Other FSP UPD Data update process fail.
  233. **/
  234. EFI_STATUS
  235. EFIAPI
  236. PeiFspCpuPolicyInit (
  237. IN OUT FSPS_UPD *FspsUpd
  238. )
  239. {
  240. EFI_STATUS Status;
  241. SI_POLICY_PPI *SiPolicyPpi;
  242. CPU_CONFIG *CpuConfig;
  243. CPU_POWER_MGMT_BASIC_CONFIG *CpuPowerMgmtBasicConfig;
  244. CPU_POWER_MGMT_CUSTOM_CONFIG *CpuPowerMgmtCustomConfig;
  245. CPU_TEST_CONFIG *CpuTestConfig;
  246. CPU_POWER_MGMT_TEST_CONFIG *CpuPowerMgmtTestConfig;
  247. UINTN Index;
  248. EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;
  249. EFI_PEI_SERVICES **PeiServices;
  250. DEBUG ((DEBUG_INFO | DEBUG_INIT, "FSP Update SiCpuPolicy\n"));
  251. PeiServices = (EFI_PEI_SERVICES **)GetPeiServicesTablePointer ();
  252. //
  253. // Locate gSiPolicyPpiGuid
  254. //
  255. SiPolicyPpi = NULL;
  256. Status = PeiServicesLocatePpi (
  257. &gSiPolicyPpiGuid,
  258. 0,
  259. NULL,
  260. (VOID **) &SiPolicyPpi
  261. );
  262. if (EFI_ERROR (Status)) {
  263. return EFI_NOT_FOUND;
  264. }
  265. Status = GetConfigBlock ((VOID *) SiPolicyPpi, &gCpuConfigGuid, (VOID *) &CpuConfig);
  266. ASSERT_EFI_ERROR (Status);
  267. Status = GetConfigBlock ((VOID *) SiPolicyPpi, &gCpuPowerMgmtBasicConfigGuid, (VOID *) &CpuPowerMgmtBasicConfig);
  268. ASSERT_EFI_ERROR (Status);
  269. Status = GetConfigBlock ((VOID *) SiPolicyPpi, &gCpuPowerMgmtCustomConfigGuid, (VOID *) &CpuPowerMgmtCustomConfig);
  270. ASSERT_EFI_ERROR (Status);
  271. Status = GetConfigBlock ((VOID *) SiPolicyPpi, &gCpuTestConfigGuid, (VOID *) &CpuTestConfig);
  272. ASSERT_EFI_ERROR (Status);
  273. Status = GetConfigBlock ((VOID *) SiPolicyPpi, &gCpuPowerMgmtTestConfigGuid, (VOID *) &CpuPowerMgmtTestConfig);
  274. ASSERT_EFI_ERROR (Status);
  275. ///
  276. ///Production RC Policies
  277. ///
  278. FspsUpd->FspsConfig.AesEnable = (UINT8) CpuConfig->AesEnable;
  279. FspsUpd->FspsConfig.DebugInterfaceEnable = (UINT8) CpuConfig->DebugInterfaceEnable;
  280. FspsUpd->FspsConfig.TurboMode = (UINT8) CpuPowerMgmtBasicConfig->TurboMode;
  281. ///
  282. /// Test RC Policies
  283. ///
  284. FspsUpd->FspsTestConfig.MlcStreamerPrefetcher = (UINT8) CpuTestConfig->MlcStreamerPrefetcher;
  285. FspsUpd->FspsTestConfig.MlcSpatialPrefetcher = (UINT8) CpuTestConfig->MlcSpatialPrefetcher;
  286. FspsUpd->FspsTestConfig.MonitorMwaitEnable = (UINT8) CpuTestConfig->MonitorMwaitEnable;
  287. FspsUpd->FspsTestConfig.DebugInterfaceLockEnable = (UINT8) CpuTestConfig->DebugInterfaceLockEnable;
  288. FspsUpd->FspsTestConfig.ApIdleManner = PcdGet8 (PcdCpuApLoopMode);
  289. FspsUpd->FspsTestConfig.ProcessorTraceOutputScheme = (UINT8) CpuTestConfig->ProcessorTraceOutputScheme;
  290. FspsUpd->FspsTestConfig.ProcessorTraceEnable = (UINT8) CpuTestConfig->ProcessorTraceEnable;
  291. FspsUpd->FspsTestConfig.ProcessorTraceMemBase = CpuTestConfig->ProcessorTraceMemBase;
  292. FspsUpd->FspsTestConfig.ProcessorTraceMemLength = (UINT32) CpuTestConfig->ProcessorTraceMemLength;
  293. FspsUpd->FspsTestConfig.VoltageOptimization = (UINT8) CpuTestConfig->VoltageOptimization;
  294. FspsUpd->FspsTestConfig.ThreeStrikeCounterDisable = (UINT8) CpuTestConfig->ThreeStrikeCounterDisable;
  295. FspsUpd->FspsTestConfig.MachineCheckEnable = (UINT8) CpuTestConfig->MachineCheckEnable;
  296. FspsUpd->FspsTestConfig.CpuWakeUpTimer = (UINT8) CpuTestConfig->CpuWakeUpTimer;
  297. FspsUpd->FspsTestConfig.OneCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->OneCoreRatioLimit;
  298. FspsUpd->FspsTestConfig.TwoCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->TwoCoreRatioLimit;
  299. FspsUpd->FspsTestConfig.ThreeCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->ThreeCoreRatioLimit;
  300. FspsUpd->FspsTestConfig.FourCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->FourCoreRatioLimit;
  301. FspsUpd->FspsTestConfig.FiveCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->FiveCoreRatioLimit;
  302. FspsUpd->FspsTestConfig.SixCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->SixCoreRatioLimit;
  303. FspsUpd->FspsTestConfig.SevenCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->SevenCoreRatioLimit;
  304. FspsUpd->FspsTestConfig.EightCoreRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->EightCoreRatioLimit;
  305. FspsUpd->FspsTestConfig.Hwp = (UINT8) CpuPowerMgmtBasicConfig->Hwp;
  306. FspsUpd->FspsTestConfig.HdcControl = (UINT8) CpuPowerMgmtBasicConfig->HdcControl;
  307. FspsUpd->FspsTestConfig.PowerLimit1Time = (UINT8) CpuPowerMgmtBasicConfig->PowerLimit1Time;
  308. FspsUpd->FspsTestConfig.PowerLimit2 = (UINT8) CpuPowerMgmtBasicConfig->PowerLimit2;
  309. FspsUpd->FspsTestConfig.TurboPowerLimitLock = (UINT8) CpuPowerMgmtBasicConfig->TurboPowerLimitLock;
  310. FspsUpd->FspsTestConfig.PowerLimit3Time = (UINT8) CpuPowerMgmtBasicConfig->PowerLimit3Time;
  311. FspsUpd->FspsTestConfig.PowerLimit3DutyCycle = (UINT8) CpuPowerMgmtBasicConfig->PowerLimit3DutyCycle;
  312. FspsUpd->FspsTestConfig.PowerLimit3Lock = (UINT8) CpuPowerMgmtBasicConfig->PowerLimit3Lock;
  313. FspsUpd->FspsTestConfig.PowerLimit4Lock = (UINT8) CpuPowerMgmtBasicConfig->PowerLimit4Lock;
  314. FspsUpd->FspsTestConfig.TccActivationOffset = (UINT8) CpuPowerMgmtBasicConfig->TccActivationOffset;
  315. FspsUpd->FspsTestConfig.TccOffsetClamp = (UINT8) CpuPowerMgmtBasicConfig->TccOffsetClamp;
  316. FspsUpd->FspsTestConfig.TccOffsetLock = (UINT8) CpuPowerMgmtBasicConfig->TccOffsetLock;
  317. FspsUpd->FspsTestConfig.PowerLimit1 = (UINT32) (CpuPowerMgmtBasicConfig->PowerLimit1 * 125);
  318. FspsUpd->FspsTestConfig.PowerLimit2Power = (UINT32) (CpuPowerMgmtBasicConfig->PowerLimit2Power * 125);
  319. FspsUpd->FspsTestConfig.PowerLimit3 = (UINT32) (CpuPowerMgmtBasicConfig->PowerLimit3 * 125);
  320. FspsUpd->FspsTestConfig.PowerLimit4 = (UINT32) (CpuPowerMgmtBasicConfig->PowerLimit4 * 125);
  321. FspsUpd->FspsTestConfig.TccOffsetTimeWindowForRatl = (UINT32) CpuPowerMgmtBasicConfig->TccOffsetTimeWindowForRatl;
  322. FspsUpd->FspsTestConfig.HwpInterruptControl = (UINT8) CpuPowerMgmtBasicConfig->HwpInterruptControl;
  323. FspsUpd->FspsTestConfig.EnableItbm = (UINT8) CpuPowerMgmtBasicConfig->EnableItbm;
  324. FspsUpd->FspsTestConfig.EnableItbmDriver = (UINT8) CpuPowerMgmtBasicConfig->EnableItbmDriver;
  325. FspsUpd->FspsTestConfig.MinRingRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->MinRingRatioLimit;
  326. FspsUpd->FspsTestConfig.MaxRingRatioLimit = (UINT8) CpuPowerMgmtBasicConfig->MaxRingRatioLimit;
  327. FspsUpd->FspsTestConfig.NumberOfEntries = (UINT8) CpuPowerMgmtCustomConfig->CustomRatioTable.NumberOfEntries;
  328. FspsUpd->FspsTestConfig.Custom1PowerLimit1Time = (UINT8) CpuPowerMgmtCustomConfig->CustomConfigTdpTable[0].CustomPowerLimit1Time;
  329. FspsUpd->FspsTestConfig.Custom2PowerLimit1Time = (UINT8) CpuPowerMgmtCustomConfig->CustomConfigTdpTable[1].CustomPowerLimit1Time;
  330. FspsUpd->FspsTestConfig.Custom3PowerLimit1Time = (UINT8) CpuPowerMgmtCustomConfig->CustomConfigTdpTable[2].CustomPowerLimit1Time;
  331. FspsUpd->FspsTestConfig.Custom1TurboActivationRatio = (UINT8) CpuPowerMgmtCustomConfig->CustomConfigTdpTable[0].CustomTurboActivationRatio;
  332. FspsUpd->FspsTestConfig.Custom2TurboActivationRatio = (UINT8) CpuPowerMgmtCustomConfig->CustomConfigTdpTable[1].CustomTurboActivationRatio;
  333. FspsUpd->FspsTestConfig.Custom3TurboActivationRatio = (UINT8) CpuPowerMgmtCustomConfig->CustomConfigTdpTable[2].CustomTurboActivationRatio;
  334. FspsUpd->FspsTestConfig.ConfigTdpLock = (UINT8) CpuPowerMgmtCustomConfig->ConfigTdpLock;
  335. FspsUpd->FspsTestConfig.ConfigTdpBios = (UINT8) CpuPowerMgmtCustomConfig->ConfigTdpBios;
  336. FspsUpd->FspsTestConfig.MaxRatio = (UINT8) CpuPowerMgmtCustomConfig->CustomRatioTable.MaxRatio;
  337. for (Index = 0; Index < CpuPowerMgmtCustomConfig->CustomRatioTable.NumberOfEntries; Index++) {
  338. FspsUpd->FspsTestConfig.StateRatio[Index] = (UINT8) CpuPowerMgmtCustomConfig->CustomRatioTable.StateRatio[Index];
  339. }
  340. for (Index = 0; Index < MAX_16_CUSTOM_RATIO_TABLE_ENTRIES; Index++) {
  341. FspsUpd->FspsTestConfig.StateRatioMax16[Index] = (UINT8) CpuPowerMgmtCustomConfig->CustomRatioTable.StateRatioMax16[Index];
  342. }
  343. FspsUpd->FspsTestConfig.Custom1PowerLimit1 = (UINT32) (CpuPowerMgmtCustomConfig->CustomConfigTdpTable[0].CustomPowerLimit1 * 125);
  344. FspsUpd->FspsTestConfig.Custom1PowerLimit2 = (UINT32) (CpuPowerMgmtCustomConfig->CustomConfigTdpTable[0].CustomPowerLimit2 * 125);
  345. FspsUpd->FspsTestConfig.Custom2PowerLimit1 = (UINT32) (CpuPowerMgmtCustomConfig->CustomConfigTdpTable[1].CustomPowerLimit1 * 125);
  346. FspsUpd->FspsTestConfig.Custom2PowerLimit2 = (UINT32) (CpuPowerMgmtCustomConfig->CustomConfigTdpTable[1].CustomPowerLimit2 * 125);
  347. FspsUpd->FspsTestConfig.Custom3PowerLimit1 = (UINT32) (CpuPowerMgmtCustomConfig->CustomConfigTdpTable[2].CustomPowerLimit1 * 125);
  348. FspsUpd->FspsTestConfig.Custom3PowerLimit2 = (UINT32) (CpuPowerMgmtCustomConfig->CustomConfigTdpTable[2].CustomPowerLimit2 * 125);
  349. FspsUpd->FspsTestConfig.Eist = (UINT8) CpuPowerMgmtTestConfig->Eist;
  350. FspsUpd->FspsTestConfig.EnergyEfficientPState = (UINT8) CpuPowerMgmtTestConfig->EnergyEfficientPState;
  351. FspsUpd->FspsTestConfig.EnergyEfficientTurbo = (UINT8) CpuPowerMgmtTestConfig->EnergyEfficientTurbo;
  352. FspsUpd->FspsTestConfig.TStates = (UINT8) CpuPowerMgmtTestConfig->TStates;
  353. FspsUpd->FspsTestConfig.BiProcHot = (UINT8) CpuPowerMgmtTestConfig->BiProcHot;
  354. FspsUpd->FspsTestConfig.DisableProcHotOut = (UINT8) CpuPowerMgmtTestConfig->DisableProcHotOut;
  355. FspsUpd->FspsTestConfig.ProcHotResponse = (UINT8) CpuPowerMgmtTestConfig->ProcHotResponse;
  356. FspsUpd->FspsTestConfig.DisableVrThermalAlert = (UINT8) CpuPowerMgmtTestConfig->DisableVrThermalAlert;
  357. FspsUpd->FspsTestConfig.AutoThermalReporting = (UINT8) CpuPowerMgmtTestConfig->AutoThermalReporting;
  358. FspsUpd->FspsTestConfig.ThermalMonitor = (UINT8) CpuPowerMgmtTestConfig->ThermalMonitor;
  359. FspsUpd->FspsTestConfig.Cx = (UINT8) CpuPowerMgmtTestConfig->Cx;
  360. FspsUpd->FspsTestConfig.PmgCstCfgCtrlLock = (UINT8) CpuPowerMgmtTestConfig->PmgCstCfgCtrlLock;
  361. FspsUpd->FspsTestConfig.C1e = (UINT8) CpuPowerMgmtTestConfig->C1e;
  362. FspsUpd->FspsTestConfig.C1StateAutoDemotion = (UINT8) CpuPowerMgmtTestConfig->C1AutoDemotion;
  363. FspsUpd->FspsTestConfig.C1StateUnDemotion = (UINT8) CpuPowerMgmtTestConfig->C1UnDemotion;
  364. FspsUpd->FspsTestConfig.C3StateAutoDemotion = (UINT8) CpuPowerMgmtTestConfig->C3AutoDemotion;
  365. FspsUpd->FspsTestConfig.C3StateUnDemotion = (UINT8) CpuPowerMgmtTestConfig->C3UnDemotion;
  366. FspsUpd->FspsTestConfig.CstateLatencyControl0TimeUnit = (UINT8) CpuPowerMgmtTestConfig->CstateLatencyControl0TimeUnit;
  367. FspsUpd->FspsTestConfig.CstateLatencyControl0Irtl = (UINT16) CpuPowerMgmtTestConfig->CstateLatencyControl0Irtl;
  368. FspsUpd->FspsTestConfig.PkgCStateDemotion = (UINT8) CpuPowerMgmtTestConfig->PkgCStateDemotion;
  369. FspsUpd->FspsTestConfig.PkgCStateUnDemotion = (UINT8) CpuPowerMgmtTestConfig->PkgCStateUnDemotion;
  370. FspsUpd->FspsTestConfig.CStatePreWake = (UINT8) CpuPowerMgmtTestConfig->CStatePreWake;
  371. FspsUpd->FspsTestConfig.TimedMwait = (UINT8) CpuPowerMgmtTestConfig->TimedMwait;
  372. FspsUpd->FspsTestConfig.CstCfgCtrIoMwaitRedirection = (UINT8) CpuPowerMgmtTestConfig->CstCfgCtrIoMwaitRedirection;
  373. FspsUpd->FspsTestConfig.PkgCStateLimit = (UINT8) CpuPowerMgmtTestConfig->PkgCStateLimit;
  374. FspsUpd->FspsTestConfig.CstateLatencyControl1TimeUnit = (UINT8) CpuPowerMgmtTestConfig->CstateLatencyControl1TimeUnit;
  375. FspsUpd->FspsTestConfig.CstateLatencyControl2TimeUnit = (UINT8) CpuPowerMgmtTestConfig->CstateLatencyControl2TimeUnit;
  376. FspsUpd->FspsTestConfig.CstateLatencyControl3TimeUnit = (UINT8) CpuPowerMgmtTestConfig->CstateLatencyControl3TimeUnit;
  377. FspsUpd->FspsTestConfig.CstateLatencyControl4TimeUnit = (UINT8) CpuPowerMgmtTestConfig->CstateLatencyControl4TimeUnit;
  378. FspsUpd->FspsTestConfig.CstateLatencyControl5TimeUnit = (UINT8) CpuPowerMgmtTestConfig->CstateLatencyControl5TimeUnit;
  379. FspsUpd->FspsTestConfig.PpmIrmSetting = (UINT8) CpuPowerMgmtTestConfig->PpmIrmSetting;
  380. FspsUpd->FspsTestConfig.ProcHotLock = (UINT8) CpuPowerMgmtTestConfig->ProcHotLock;
  381. FspsUpd->FspsTestConfig.RaceToHalt = (UINT8) CpuPowerMgmtTestConfig->RaceToHalt;
  382. FspsUpd->FspsTestConfig.ConfigTdpLevel = (UINT8) CpuPowerMgmtTestConfig->ConfigTdpLevel;
  383. FspsUpd->FspsTestConfig.CstateLatencyControl1Irtl = (UINT16) CpuPowerMgmtTestConfig->CstateLatencyControl1Irtl;
  384. FspsUpd->FspsTestConfig.CstateLatencyControl2Irtl = (UINT16) CpuPowerMgmtTestConfig->CstateLatencyControl2Irtl;
  385. FspsUpd->FspsTestConfig.CstateLatencyControl3Irtl = (UINT16) CpuPowerMgmtTestConfig->CstateLatencyControl3Irtl;
  386. FspsUpd->FspsTestConfig.CstateLatencyControl4Irtl = (UINT16) CpuPowerMgmtTestConfig->CstateLatencyControl4Irtl;
  387. FspsUpd->FspsTestConfig.CstateLatencyControl5Irtl = (UINT16) CpuPowerMgmtTestConfig->CstateLatencyControl5Irtl;
  388. //
  389. // Get BIST information from Sec Platform Information
  390. //
  391. SecPlatformInformation2 = GetSecPlatformInformation2 (PeiServices);
  392. if (SecPlatformInformation2 == NULL) {
  393. SecPlatformInformation2 = GetSecPlatformInformationInfoInFormat2 (PeiServices);
  394. }
  395. ASSERT (SecPlatformInformation2 != NULL);
  396. if (SecPlatformInformation2 != NULL) {
  397. FspsUpd->FspsConfig.CpuBistData = (UINT32)SecPlatformInformation2;
  398. DEBUG((DEBUG_INFO, "SecPlatformInformation NumberOfCpus - %x\n", SecPlatformInformation2->NumberOfCpus));
  399. DEBUG ((DEBUG_INFO, "SecPlatformInformation BIST - %x\n", SecPlatformInformation2->CpuInstance[0].InfoRecord.x64HealthFlags.Uint32));
  400. }
  401. return EFI_SUCCESS;
  402. }