From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Fri, 16 Aug 2019 17:53:13 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Aug 2019 17:53:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,395,1559545200"; d="scan'208";a="168201836" Received: from orsmsx109.amr.corp.intel.com ([10.22.240.7]) by orsmga007.jf.intel.com with ESMTP; 16 Aug 2019 17:53:12 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.96]) by ORSMSX109.amr.corp.intel.com ([169.254.11.170]) with mapi id 14.03.0439.000; Fri, 16 Aug 2019 17:53:12 -0700 From: "Nate DeSimone" To: "Kubacki, Michael A" , "devel@edk2.groups.io" CC: "Chaganty, Rangasai V" , "Chiu, Chasel" , "Gao, Liming" , "Kinney, Michael D" , "Sinha, Ankit" Subject: Re: [edk2-platforms][PATCH V1 25/37] CoffeelakeSiliconPkg/SystemAgent: Add library instances Thread-Topic: [edk2-platforms][PATCH V1 25/37] CoffeelakeSiliconPkg/SystemAgent: Add library instances Thread-Index: AQHVVJEZWyCNXDeh90i7xyE3Jy4Z6ab+gyKA Date: Sat, 17 Aug 2019 00:53:11 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAEE12A4F@ORSMSX114.amr.corp.intel.com> References: <20190817001603.30632-1-michael.a.kubacki@intel.com> <20190817001603.30632-26-michael.a.kubacki@intel.com> In-Reply-To: <20190817001603.30632-26-michael.a.kubacki@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzEzZjk3NjktNGYzZS00YTc1LTk5MDQtMGZmM2JlOTgxOGQwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZ1NRNjU2ZnlTM1NBVFo2YVNOZlJMcnJ5d2lHNkViOFBweDA0WFE3K3NWM09iQ0pkRHFwVndtV1JiYXhWd2tiVSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: Kubacki, Michael A=20 Sent: Friday, August 16, 2019 5:16 PM To: devel@edk2.groups.io Cc: Chaganty, Rangasai V ; Chiu, Chasel ; Desimone, Nathaniel L = ; Gao, Liming ; Kinney, Michael D ; Sinha, Ankit Subject: [edk2-platforms][PATCH V1 25/37] CoffeelakeSiliconPkg/SystemAgent:= Add library instances REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2082 Adds System Agent (SA) library class instances. * DxeSaPolicyLib - DXE SA policy configuration services. * PeiDxeSmmSaPlatformLib - SA platform generation services. * PeiSaPolicyLib - PEI SA policy configuration services. Cc: Sai Chaganty Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Michael D Kinney Cc: Ankit Sinha Signed-off-by: Michael Kubacki --- Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPolicyLib/DxeS= aPolicyLib.inf | 43 ++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeSmmSaPlatform= Lib/PeiDxeSmmSaPlatformLib.inf | 38 + Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/PeiS= aPolicyLib.inf | 74 ++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPolicyLib/DxeS= aPolicyLibrary.h | 37 + Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeSmmSaPlatform= Lib/SaPlatformLibrary.h | 21 + Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/MrcO= emPlatform.h | 323 +++++++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/PeiS= aPolicyLibrary.h | 39 + Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPolicyLib/DxeS= aPolicyLib.c | 473 +++++++++++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeSmmSaPlatform= Lib/SaPlatformLibrary.c | 128 ++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/MrcO= emPlatform.c | 745 ++++++++++++++++++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/PeiS= aPolicyLib.c | 656 +++++++++++++++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/PeiS= aPolicyLibSample.c | 284 ++++++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/SaPr= intPolicy.c | 559 +++++++++++++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/Ia32= /MrcOemPlatform.S | 114 +++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/Ia32= /MrcOemPlatform.asm | 126 ++++ Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib/Ia32= /MrcOemPlatform.nasm | 118 ++++ 16 files changed, 3778 insertions(+) diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPo= licyLib/DxeSaPolicyLib.inf b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent= /Library/DxeSaPolicyLib/DxeSaPolicyLib.inf new file mode 100644 index 0000000000..8a5092e199 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPolicyLib= /DxeSaPolicyLib.inf @@ -0,0 +1,43 @@ +## @file +# Component description file for the PeiSaPolicy library. +# +# Copyright (c) 2019 Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] +INF_VERSION =3D 0x00010017 +BASE_NAME =3D DxeSaPolicyLib +FILE_GUID =3D B402A3A4-4B82-410E-B79C-5914880A05E7 +VERSION_STRING =3D 1.0 +MODULE_TYPE =3D BASE +LIBRARY_CLASS =3D DxeSaPolicyLib + +[LibraryClasses] +BaseMemoryLib +UefiRuntimeServicesTableLib +UefiBootServicesTableLib +DebugLib +PostCodeLib +ConfigBlockLib +HobLib + +[Packages] +MdePkg/MdePkg.dec +CoffeelakeSiliconPkg/SiPkg.dec + +[Sources] +DxeSaPolicyLib.c +DxeSaPolicyLibrary.h + +[Guids] +gGraphicsDxeConfigGuid +gMiscDxeConfigGuid +gPcieDxeConfigGuid +gMemoryDxeConfigGuid +gVbiosDxeConfigGuid + +[Protocols] +gSaPolicyProtocolGuid ## PRODUCES diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeS= mmSaPlatformLib/PeiDxeSmmSaPlatformLib.inf b/Silicon/Intel/CoffeelakeSilico= nPkg/SystemAgent/Library/PeiDxeSmmSaPlatformLib/PeiDxeSmmSaPlatformLib.inf new file mode 100644 index 0000000000..ffc4043e7a --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeSmmSaPla= tformLib/PeiDxeSmmSaPlatformLib.inf @@ -0,0 +1,38 @@ +## @file +# Component description file for SA Platform Lib +# +# Copyright (c) 2019 Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] +INF_VERSION =3D 0x00010017 +BASE_NAME =3D PeiDxeSmmSaPlatformLib +FILE_GUID =3D 9DB5ACB4-DB23-43AE-A283-2ABEF365CBE0 +VERSION_STRING =3D 1.0 +MODULE_TYPE =3D BASE +LIBRARY_CLASS =3D SaPlatformLib + + +[LibraryClasses] +BaseLib +BaseMemoryLib +DebugLib +IoLib +CpuPlatformLib + + +[Packages] +MdePkg/MdePkg.dec +CoffeelakeSiliconPkg/SiPkg.dec + + +[Pcd] +gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress + + +[Sources] +SaPlatformLibrary.h +SaPlatformLibrary.c diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/PeiSaPolicyLib.inf b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent= /Library/PeiSaPolicyLib/PeiSaPolicyLib.inf new file mode 100644 index 0000000000..22d0f0c945 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /PeiSaPolicyLib.inf @@ -0,0 +1,74 @@ +## @file +# Component description file for the PeiSaPolicy library. +# +# Copyright (c) 2019 Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] +INF_VERSION =3D 0x00010017 +BASE_NAME =3D PeiSaPolicyLib +FILE_GUID =3D d7022865-ef1b-449d-8c3f-ac36488c408b +VERSION_STRING =3D 1.0 +MODULE_TYPE =3D PEIM +LIBRARY_CLASS =3D PeiSaPolicyLib + + +[LibraryClasses] +DebugLib +IoLib +PeiServicesLib +BaseMemoryLib +MemoryAllocationLib +ConfigBlockLib +CpuMailboxLib +SiConfigBlockLib +RngLib +PmcPrivateLib +GpioLib +PchInfoLib + +[Packages] +MdePkg/MdePkg.dec +UefiCpuPkg/UefiCpuPkg.dec +CoffeelakeSiliconPkg/SiPkg.dec + +[Pcd] +gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress +gSiPkgTokenSpaceGuid.PcdTsegSize +gSiPkgTokenSpaceGuid.PcdRegBarBaseAddress +gSiPkgTokenSpaceGuid.PcdIpuEnable ## CONSUMES + +[Sources] +PeiSaPolicyLib.c +PeiSaPolicyLibrary.h +MrcOemPlatform.c +MrcOemPlatform.h +SaPrintPolicy.c +PeiSaPolicyLibSample.c + +[Sources.IA32] +Ia32/MrcOemPlatform.nasm +Ia32/MrcOemPlatform.S + +[Ppis] +gSiPreMemPolicyPpiGuid ## CONSUMES +gSiPolicyPpiGuid ## CONSUMES + +[Guids] +gSaMiscPeiPreMemConfigGuid ## PRODUCES +gSaMiscPeiConfigGuid ## PRODUCES +gSaPciePeiPreMemConfigGuid ## PRODUCES +gSaPciePeiConfigGuid ## PRODUCES +gGraphicsPeiPreMemConfigGuid ## CONSUMES +gGraphicsPeiConfigGuid ## CONSUMES +gSwitchableGraphicsConfigGuid ## PRODUCES +gCpuTraceHubConfigGuid ## PRODUCES +gMemoryConfigGuid ## PRODUCES +gMemoryConfigNoCrcGuid ## PRODUCES +gIpuPreMemConfigGuid ## PRODUCES +gGnaConfigGuid ## PRODUCES +gVtdConfigGuid ## PRODUCES +gSaOverclockingPreMemConfigGuid ## PRODUCES diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPo= licyLib/DxeSaPolicyLibrary.h b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAge= nt/Library/DxeSaPolicyLib/DxeSaPolicyLibrary.h new file mode 100644 index 0000000000..449b67798c --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPolicyLib= /DxeSaPolicyLibrary.h @@ -0,0 +1,37 @@ +/** @file + Header file for the DxeSaPolicy library. + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _DXE_SA_POLICY_LIBRARY_H_ +#define _DXE_SA_POLICY_LIBRARY_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define WORD_FIELD_VALID_BIT BIT15 +/// +/// DIMM SMBus addresses +/// +#define DIMM_SMB_SPD_P0C0D0 0xA0 +#define DIMM_SMB_SPD_P0C0D1 0xA2 +#define DIMM_SMB_SPD_P0C1D0 0xA4 +#define DIMM_SMB_SPD_P0C1D1 0xA6 +#define DIMM_SMB_SPD_P0C0D2 0xA8 +#define DIMM_SMB_SPD_P0C1D2 0xAA + +#endif // _DXE_SA_POLICY_LIBRARY_H_ diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeS= mmSaPlatformLib/SaPlatformLibrary.h b/Silicon/Intel/CoffeelakeSiliconPkg/Sy= stemAgent/Library/PeiDxeSmmSaPlatformLib/SaPlatformLibrary.h new file mode 100644 index 0000000000..07d4c6e666 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeSmmSaPla= tformLib/SaPlatformLibrary.h @@ -0,0 +1,21 @@ +/** @file + Header file for SA Platform Lib implementation. + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _SA_PLATFORM_LIBRARY_IMPLEMENTATION_H_ +#define _SA_PLATFORM_LIBRARY_IMPLEMENTATION_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/MrcOemPlatform.h b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/L= ibrary/PeiSaPolicyLib/MrcOemPlatform.h new file mode 100644 index 0000000000..61a6e2a691 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /MrcOemPlatform.h @@ -0,0 +1,323 @@ +/** @file + This file contains functions that read the SPD data for each DIMM slot o= ver + the SMBus interface. + This file is SampleCode for Intel SA PEI Policy initialization. + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "PeiSaPolicyLibrary.h" +#include "MrcInterface.h" + +#define RTC_INDEX_REGISTER (0x70) +#define RTC_TARGET_REGISTER (0x71) + +#define RTC_INDEX_MASK (0x7F) +#define RTC_BANK_SIZE (0x80) + +#define RTC_SECONDS (0x00) +#define RTC_MINUTES (0x02) +#define RTC_HOURS (0x04) +#define RTC_DAY_OF_MONTH (0x07) +#define RTC_MONTH (0x08) +#define RTC_YEAR (0x09) +#define CMOS_REGA (0x0A) +#define CMOS_REGB (0x0B) +#define CMOS_REGC (0x0C) +#define CMOS_REGD (0x0D) + +#define RTC_UPDATE_IN_PROGRESS (0x80) +#define RTC_HOLD (0x80) +#define RTC_MODE_24HOUR (0x02) +#define RTC_CLOCK_DIVIDER (0x20) +#define RTC_RATE_SELECT (0x06) + +#define BCD2BINARY(A) (((((A) >> 4) & 0xF) * 10) + ((A) & 0xF)= ) +#define CENTURY_OFFSET (2000) + +/** + Read the SPD data over the SMBus, at the given SmBus SPD address and cop= y the data to the data structure. + The SPD data locations read is controlled by the current boot mode. + + @param[in] BootMode - The current MRC boot mode. + @param[in] Address - SPD SmBus address offset. + @param[in] Buffer - Buffer that contains the data read from = the SPD. + @param[in] SpdDdr3Table - Indicates which SPD bytes to read. + @param[in] SpdDdr3TableSize - Size of SpdDdr3Table in bytes. + @param[in] SpdDdr4Table - Indicates which SPD bytes to read. + @param[in] SpdDdr4TableSize - Size of SpdDdr4Table in bytes. + @param[in] SpdLpddrTable - Indicates which SPD bytes to read. + @param[in] SpdLpddrTableSize - Size of SpdLpddrTable in bytes. + + @retval TRUE if the read is successful, otherwise FALSE on error. +**/ +BOOLEAN +GetSpdData ( + IN SPD_BOOT_MODE BootMode, + IN UINT8 Address, + IN OUT UINT8 *Buffer, + IN UINT8 *SpdDdr3Table, + IN UINT32 SpdDdr3TableSize, + IN UINT8 *SpdDdr4Table, + IN UINT32 SpdDdr4TableSize, + IN UINT8 *SpdLpddrTable, + IN UINT32 SpdLpddrTableSize + ); + +/** + Output a string to the debug stream/device. + + @param[in] String - The string to output. +**/ +VOID +SaDebugPrint ( + VOID *String + ); + +/** + Calculate the PCI device address for the given Bus/Device/Function/Offse= t. + + @param[in] Bus - PCI bus + @param[in] Device - PCI device + @param[in] Function - PCI function + @param[in] Offset - Offset + + @retval The PCI device address. +**/ +UINT32 +GetPciDeviceAddress ( + IN const UINT8 Bus, + IN const UINT8 Device, + IN const UINT8 Function, + IN const UINT8 Offset + ); + +/** + Calculate the PCIE device address for the given Bus/Device/Function/Offs= et. + + @param[in] Bus - PCI bus + @param[in] Device - PCI device + @param[in] Function - PCI function + @param[in] Offset - Offset + + The PCIE device address. + + @retval The PCIe device address +**/ +UINT32 +GetPcieDeviceAddress ( + IN const UINT8 Bus, + IN const UINT8 Device, + IN const UINT8 Function, + IN const UINT8 Offset + ); + +/** + Read specific RTC/CMOS RAM + + @param[in] Location Point to RTC/CMOS RAM offset for read + + @retval The data of specific location in RTC/CMOS RAM. +**/ +UINT8 +PeiRtcRead ( + IN const UINT8 Location + ); + +/** + Returns the current time, as determined by reading the Real Time Clock (= RTC) on the platform. + Since RTC time is stored in BCD, convert each value to binary. + + @param[out] Seconds - The current second (0-59). + @param[out] Minutes - The current minute (0-59). + @param[out] Hours - The current hour (0-23). + @param[out] DayOfMonth - The current day of the month (1-31). + @param[out] Month - The current month (1-12). + @param[out] Year - The current year (2000-2099). +**/ +VOID +GetRtcTime ( + OUT UINT8 *const Seconds, + OUT UINT8 *const Minutes, + OUT UINT8 *const Hours, + OUT UINT8 *const DayOfMonth, + OUT UINT8 *const Month, + OUT UINT16 *const Year + ); + +/** + Gets CPU current time. + + @param[in] GlobalData - Pointer to global MRC data struct. + + @retval The current CPU time in milliseconds. +**/ +UINT64 +GetCpuTime ( + IN VOID *GlobalData + ); + +/** + Sets the specified number of memory words, a word at a time, at the + specified destination. + + @param[in, out] Dest - Destination pointer. + @param[in] NumWords - The number of dwords to set. + @param[in] Value - The value to set. + + @retval Pointer to the buffer. +**/ +VOID * +SetMemWord ( + IN OUT VOID *Dest, + IN UINTN NumWords, + IN const UINT16 Value + ); + +/** + Sets the specified number of memory dwords, a dword at a time, at the + specified destination. + + @param[in, out] Dest - Destination pointer. + @param[in] NumDwords - The number of dwords to set. + @param[in] Value - The value to set. + + @retval Pointer to the buffer. +**/ +VOID * +SetMemDword ( + IN OUT VOID *Dest, + IN UINT32 NumDwords, + IN const UINT32 Value + ); + +/** + Read 64 bits from the Memory Mapped I/O space. + Use MMX instruction for atomic access, because some MC registers have si= de effect. + + @param[in] Address - Memory mapped I/O address. +**/ +UINT64 +SaMmioRead64 ( + IN UINTN Address + ); + +/** + Write 64 bits to the Memory Mapped I/O space. + Use MMX instruction for atomic access, because some MC registers have si= de effect. + + @param[in] Address - Memory mapped I/O address. + @param[in] Value - The value to write. +**/ +UINT64 +SaMmioWrite64 ( + IN UINTN Address, + IN UINT64 Value + ); + +/** + Intel Silicon View Technology check point interface based on IO port rea= ding + + @param CheckPoint Check point AH value. + AH =3D 0x10: End of MRC State + AH =3D 0x20: End of DXE State + AH =3D 0x30: Ready to boot before INT-19h or U= EFI boot + AH =3D 0x40: After OS booting, need a timer SM= I trigger to implement (TBD) + + @param PortReading IO port reading address used for breakpoints +**/ +VOID +EFIAPI +IsvtCheckPoint ( + IN UINT32 CheckPoint, + IN UINT32 PortReading + ); + +/** + Gets the current memory voltage (VDD). + + @param[in] GlobalData - Pointer to global MRC data struct. + @param[in] DefaultVdd - Default Vdd for the given platform. + + @retval The current memory voltage (VDD), in millivolts. 0 means platfor= m default. +**/ +UINT32 +GetMemoryVdd ( + IN VOID *GlobalData, + IN UINT32 DefaultVdd + ); + +/** + Sets the memory voltage (VDD) to the specified value. + + @param[in] GlobalData - Pointer to global MRC data struct. + @param[in] DefaultVdd - Default Vdd for the given platform. + @param[in] Voltage - The new memory voltage to set. + + @retval The actual memory voltage (VDD), in millivolts, that is closest = to what the caller passed in. +**/ +UINT32 +SetMemoryVdd ( + IN VOID *GlobalData, + IN UINT32 DefaultVdd, + IN UINT32 Voltage + ); + +/** + Check point that is called at various points in the MRC. + + @param[in] GlobalData - MRC global data. + @param[in] Command - OEM command. + @param[in] Pointer - Command specific data. + + @retval MrcStatus value. +**/ +UINT32 +CheckPoint ( + VOID *GlobalData, + UINT32 Command, + VOID *Pointer + ); + +/** + Typically used to display to the I/O port 80h. + + @param[in] GlobalData - Mrc Global Data + @param[in] DisplayDebugNumber - the number to display on port 80. + + @retval Nothing. +**/ +VOID +DebugHook ( + VOID *GlobalData, + UINT16 DisplayDebugNumber + ); + +/** + Hook to take any action after returning from MrcStartMemoryConfiguration= () + and prior to taking any action regarding MrcStatus. Pre-populated with = issuing + Intel Silicon View Technology (ISVT) checkpoint 0x01. + + @param[in] GlobalData - Mrc Global Data + @param[in] MrcStatus - Mrc status variable +**/ +VOID +ReturnFromSmc ( + VOID *GlobalData, + UINT32 MrcStatus + ); + +/** + Assert or deassert DRAM_RESET# pin; this is used in JEDEC Reset. + + @param[in] PciEBaseAddress - PCI express base address. + @param[in] ResetValue - desired value of DRAM_RESET#. 1 - reset de= asserted, 0 - reset asserted. +**/ +VOID +SaDramReset ( + IN UINT32 PciEBaseAddress, + IN UINT32 ResetValue + ); + diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/PeiSaPolicyLibrary.h b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAge= nt/Library/PeiSaPolicyLib/PeiSaPolicyLibrary.h new file mode 100644 index 0000000000..124ca6a57f --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /PeiSaPolicyLibrary.h @@ -0,0 +1,39 @@ +/** @file + Header file for the PeiSaPolicy library. + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _PEI_SA_POLICY_LIBRARY_H_ +#define _PEI_SA_POLICY_LIBRARY_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + SaLoadSamplePolicyPreMem - Load some policy default for reference board. + + @param[in] ConfigBlockTableAddress The pointer for SA config blocks + +**/ +VOID +SaLoadSamplePolicyPreMem ( + IN VOID *ConfigBlockTableAddress + ); +#endif // _PEI_SA_POLICY_LIBRARY_H_ diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPo= licyLib/DxeSaPolicyLib.c b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/L= ibrary/DxeSaPolicyLib/DxeSaPolicyLib.c new file mode 100644 index 0000000000..0e8d518fe7 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/DxeSaPolicyLib= /DxeSaPolicyLib.c @@ -0,0 +1,473 @@ +/** @file + This file provide services for DXE phase policy default initialization + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "DxeSaPolicyLibrary.h" + + +GLOBAL_REMOVE_IF_UNREFERENCED PCIE_ASPM_OVERRIDE_LIST mPcieAspmDevsOverrid= e[] =3D { + {0x8086, 0x108b, 0xff, 2, 2}, ///< Tekoa w/o iAMT + {0x8086, 0x108c, 0x00, 0, 0}, ///< Tekoa A2 + {0x8086, 0x108c, 0xff, 2, 2}, ///< Tekoa others + {0x8086, 0x109a, 0xff, 2, 2}, ///< Vidalia + {0x8086, 0x4222, 0xff, 2, 3}, ///< 3945ABG + {0x8086, 0x4227, 0xff, 2, 3}, ///< 3945ABG + {0x8086, 0x4228, 0xff, 2, 3}, ///< 3945ABG + /// + /// Place structures for known bad OEM/IHV devices here + /// + {SA_PCIE_DEV_END_OF_TABLE, 0, 0, 0, 0} ///< End of table +}; + +GLOBAL_REMOVE_IF_UNREFERENCED PCIE_LTR_DEV_INFO mPcieLtrDevsOverride[] =3D= { + /// + /// Place holder for PCIe devices with correct LTR requirements + /// + {SA_PCIE_DEV_END_OF_TABLE, 0, 0, 0, 0} ///< End of table +}; + +extern EFI_GUID gGraphicsDxeConfigGuid; +extern EFI_GUID gMemoryDxeConfigGuid; +extern EFI_GUID gMiscDxeConfigGuid; +extern EFI_GUID gPcieDxeConfigGuid; +extern EFI_GUID gVbiosDxeConfigGuid; + +/** + This function prints the SA DXE phase policy. + + @param[in] SaPolicy - SA DXE Policy protocol +**/ +VOID +SaPrintPolicyProtocol ( + IN SA_POLICY_PROTOCOL *SaPolicy + ) +{ + EFI_STATUS Status; + GRAPHICS_DXE_CONFIG *GraphicsDxeConfig; + PCIE_DXE_CONFIG *PcieDxeConfig; + MISC_DXE_CONFIG *MiscDxeConfig; + MEMORY_DXE_CONFIG *MemoryDxeConfig; + VBIOS_DXE_CONFIG *VbiosDxeConfig; + + // + // Get requisite IP Config Blocks which needs to be used here + // + Status =3D GetConfigBlock ((VOID *) SaPolicy, &gGraphicsDxeConfigGuid, (= VOID *)&GraphicsDxeConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SaPolicy, &gMiscDxeConfigGuid, (VOID= *)&MiscDxeConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SaPolicy, &gPcieDxeConfigGuid, (VOID= *)&PcieDxeConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SaPolicy, &gMemoryDxeConfigGuid, (VO= ID *)&MemoryDxeConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SaPolicy, &gVbiosDxeConfigGuid, (VOI= D *)&VbiosDxeConfig); + ASSERT_EFI_ERROR (Status); + + DEBUG_CODE_BEGIN (); + INTN i; + + DEBUG ((DEBUG_INFO, "\n------------------------ SA Policy (DXE) print BE= GIN -----------------\n")); + DEBUG ((DEBUG_INFO, "Revision : %x\n", SaPolicy->TableHeader.Header.Revi= sion)); + ASSERT (SaPolicy->TableHeader.Header.Revision =3D=3D SA_POLICY_PROTOCOL_= REVISION); + + DEBUG ((DEBUG_INFO, "------------------------ SA_MEMORY_CONFIGURATION --= ---------------\n")); + DEBUG ((DEBUG_INFO, " SpdAddressTable[%d] :", SA_MC_MAX_SOCKETS)); + for (i =3D 0; i < SA_MC_MAX_SOCKETS; i++) { + DEBUG ((DEBUG_INFO, " %x", MemoryDxeConfig->SpdAddressTable[i])); + } + DEBUG ((DEBUG_INFO, "\n")); + + DEBUG ((DEBUG_INFO, " ChannelASlotMap : %x\n", MemoryDxeConfig->ChannelA= SlotMap)); + DEBUG ((DEBUG_INFO, " ChannelBSlotMap : %x\n", MemoryDxeConfig->ChannelB= SlotMap)); + DEBUG ((DEBUG_INFO, " MrcTimeMeasure : %x\n", MemoryDxeConfig->MrcTimeM= easure)); + DEBUG ((DEBUG_INFO, " MrcFastBoot : %x\n", MemoryDxeConfig->MrcFastB= oot)); + + DEBUG ((DEBUG_INFO, "------------------------ SA_PCIE_CONFIGURATION ----= -------------\n")); + DEBUG ((DEBUG_INFO, " PegAspm[%d] :", SA_PEG_MAX_FUN)); + for (i =3D 0; i < SA_PEG_MAX_FUN; i++) { + DEBUG ((DEBUG_INFO, " %x", PcieDxeConfig->PegAspm[i])); + } + DEBUG ((DEBUG_INFO, "\n")); + + DEBUG ((DEBUG_INFO, " PegAspmL0s[%d] :", SA_PEG_MAX_FUN)); + for (i =3D 0; i < SA_PEG_MAX_FUN; i++) { + DEBUG ((DEBUG_INFO, " %x", PcieDxeConfig->PegAspmL0s[i])); + } + DEBUG ((DEBUG_INFO, "\n")); + + DEBUG ((DEBUG_INFO, " PegRootPortHPE[%d] :", SA_PEG_MAX_FUN)); + for (i =3D 0; i < SA_PEG_MAX_FUN; i++) { + DEBUG ((DEBUG_INFO, " %x", PcieDxeConfig->PegRootPortHPE[i])); + } + DEBUG ((DEBUG_INFO, "\n")); + + if (PcieDxeConfig->PcieAspmDevsOverride !=3D NULL) { + DEBUG ((DEBUG_INFO, "------------------------ PCIE_ASPM_OVERRIDE_LIST = -----------------\n")); + DEBUG ((DEBUG_INFO, " VendorId DeviceId RevId RootApmcMask EndpointApm= cMask\n")); + i =3D 0; + while ((PcieDxeConfig->PcieAspmDevsOverride[i].VendorId !=3D SA_PCIE_D= EV_END_OF_TABLE) && + (i < MAX_PCIE_ASPM_OVERRIDE)) { + DEBUG ((DEBUG_INFO, " %04x %04x %02x %01x %01x= \n", + PcieDxeConfig->PcieAspmDevsOverride[i].VendorId, + PcieDxeConfig->PcieAspmDevsOverride[i].DeviceId, + PcieDxeConfig->PcieAspmDevsOverride[i].RevId, + PcieDxeConfig->PcieAspmDevsOverride[i].RootApmcMask, + PcieDxeConfig->PcieAspmDevsOverride[i].EndpointApmcMask)); + i++; + } + DEBUG ((DEBUG_INFO, "------------------------ END_OF_TABLE -----------= ------------\n")); + } + if (PcieDxeConfig->PcieLtrDevsOverride !=3D NULL) { + DEBUG ((DEBUG_INFO, "------------------------ PCIE_LTR_DEV_INFO ------= -----------\n")); + DEBUG ((DEBUG_INFO, " VendorId DeviceId RevId SnoopLatency NonSnoopLat= ency\n")); + i =3D 0; + while ((PcieDxeConfig->PcieLtrDevsOverride[i].VendorId !=3D SA_PCIE_DE= V_END_OF_TABLE) && + (i < MAX_PCIE_LTR_OVERRIDE)) { + DEBUG ((DEBUG_INFO, " %04x %04x %02x %01x %01x= \n", + PcieDxeConfig->PcieLtrDevsOverride[i].VendorId, + PcieDxeConfig->PcieLtrDevsOverride[i].DeviceId, + PcieDxeConfig->PcieLtrDevsOverride[i].RevId, + PcieDxeConfig->PcieLtrDevsOverride[i].SnoopLatency, + PcieDxeConfig->PcieLtrDevsOverride[i].NonSnoopLatency)); + i++; + } + DEBUG ((DEBUG_INFO, "------------------------ END_OF_TABLE -----------= -----------\n")); + } + + for (i =3D 0; i < SA_PEG_MAX_FUN; i++) { + DEBUG ((DEBUG_INFO, " PegPwrOpt[%d].LtrEnable : %x\n", i, P= cieDxeConfig->PegPwrOpt[i].LtrEnable)); + DEBUG ((DEBUG_INFO, " PegPwrOpt[%d].LtrMaxSnoopLatency : %x\n", i, P= cieDxeConfig->PegPwrOpt[i].LtrMaxSnoopLatency)); + DEBUG ((DEBUG_INFO, " PegPwrOpt[%d].ObffEnable : %x\n", i, P= cieDxeConfig->PegPwrOpt[i].ObffEnable)); + DEBUG ((DEBUG_INFO, " PegPwrOpt[%d].LtrMaxNoSnoopLatency : %x\n", i, P= cieDxeConfig->PegPwrOpt[i].LtrMaxNoSnoopLatency)); + } + + + if (VbiosDxeConfig !=3D NULL) { + DEBUG ((DEBUG_INFO, "------------------------ SA_SG_VBIOS_CONFIGURATIO= N -----------------\n")); + DEBUG ((DEBUG_INFO, " LoadVbios : %x\n", VbiosDxeConfig->LoadVbios)= ); + DEBUG ((DEBUG_INFO, " ExecuteVbios : %x\n", VbiosDxeConfig->ExecuteVbi= os)); + DEBUG ((DEBUG_INFO, " VbiosSource : %x\n", VbiosDxeConfig->VbiosSourc= e)); + } + + + DEBUG ((DEBUG_INFO, "------------------------ SA_MISC_CONFIGURATION ----= -------------\n")); + DEBUG ((DEBUG_INFO, " EnableAbove4GBMmio : %x\n", MiscDxeConfig->EnableA= bove4GBMmio)); + DEBUG ((DEBUG_INFO, "\n------------------------ SA Policy (DXE) print EN= D -----------------\n")); + DEBUG_CODE_END (); + + return; +} + +EFI_STATUS +EFIAPI +LoadIgdDxeDefault ( + IN VOID *ConfigBlockPointer + ) +{ + GRAPHICS_DXE_CONFIG *GraphicsDxeConfig; + + GraphicsDxeConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "GraphicsDxeConfig->Header.GuidHob.Name =3D %g\n", &= GraphicsDxeConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "GraphicsDxeConfig->Header.GuidHob.Header.HobLength = =3D 0x%x\n", GraphicsDxeConfig->Header.GuidHob.Header.HobLength)); + /// + /// Initialize the Graphics configuration + /// + GraphicsDxeConfig->PlatformConfig =3D 1; + GraphicsDxeConfig->AlsEnable =3D 2; + GraphicsDxeConfig->BacklightControlSupport =3D 2; + GraphicsDxeConfig->IgdBlcConfig =3D 2; + GraphicsDxeConfig->IgdDvmtMemSize =3D 1; + GraphicsDxeConfig->GfxTurboIMON =3D 31; + /// + /// Create a static Backlight Brightness Level Duty cycle Mapp= ing Table + /// Possible 20 entries (example used 11), each 16 bits as follows: + /// [15] =3D Field Valid bit, [14:08] =3D Level in Percentage (0-64h), [= 07:00] =3D Desired duty cycle (0 - FFh). + /// + GraphicsDxeConfig->BCLM[0] =3D (0x0000 + WORD_FIELD_VALID_BIT); ///< 0% + GraphicsDxeConfig->BCLM[1] =3D (0x0A19 + WORD_FIELD_VALID_BIT); ///< 10= % + GraphicsDxeConfig->BCLM[2] =3D (0x1433 + WORD_FIELD_VALID_BIT); ///< 20= % + GraphicsDxeConfig->BCLM[3] =3D (0x1E4C + WORD_FIELD_VALID_BIT); ///< 30= % + GraphicsDxeConfig->BCLM[4] =3D (0x2866 + WORD_FIELD_VALID_BIT); ///< 40= % + GraphicsDxeConfig->BCLM[5] =3D (0x327F + WORD_FIELD_VALID_BIT); ///< 50= % + GraphicsDxeConfig->BCLM[6] =3D (0x3C99 + WORD_FIELD_VALID_BIT); ///< 60= % + GraphicsDxeConfig->BCLM[7] =3D (0x46B2 + WORD_FIELD_VALID_BIT); ///< 70= % + GraphicsDxeConfig->BCLM[8] =3D (0x50CC + WORD_FIELD_VALID_BIT); ///< 80= % + GraphicsDxeConfig->BCLM[9] =3D (0x5AE5 + WORD_FIELD_VALID_BIT); ///< 90= % + GraphicsDxeConfig->BCLM[10] =3D (0x64FF + WORD_FIELD_VALID_BIT); ///< 1= 00% + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +LoadPcieDxeDefault ( + IN VOID *ConfigBlockPointer + ) +{ + UINT8 pegFn; + UINT8 Index; + PCIE_DXE_CONFIG *PcieDxeConfig; + + PcieDxeConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "PcieDxeConfig->Header.GuidHob.Name =3D %g\n", &Pcie= DxeConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "PcieDxeConfig->Header.GuidHob.Header.HobLength =3D = 0x%x\n", PcieDxeConfig->Header.GuidHob.Header.HobLength)); + /// + /// Initialize the PCIE Configuration + /// PEG ASPM per port configuration. 4 PEG controllers i.e. 0,1,2,3 + /// + for (pegFn =3D 0; pegFn < SA_PEG_MAX_FUN; pegFn++) { + PcieDxeConfig->PegAspm[pegFn] =3D PcieAspmAutoConfig; + PcieDxeConfig->PegAspmL0s[pegFn] =3D 0; + } + + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + PcieDxeConfig->PegPwrOpt[Index].LtrEnable =3D 1; + PcieDxeConfig->PegPwrOpt[Index].LtrMaxSnoopLatency =3D V_SA_LTR_MAX_= SNOOP_LATENCY_VALUE; + PcieDxeConfig->PegPwrOpt[Index].LtrMaxNoSnoopLatency =3D V_SA_LTR_MAX_= NON_SNOOP_LATENCY_VALUE; + PcieDxeConfig->PegPwrOpt[Index].ObffEnable =3D 1; + } + + PcieDxeConfig->PcieAspmDevsOverride =3D mPcieAspmDevsOverride; + PcieDxeConfig->PcieLtrDevsOverride =3D mPcieLtrDevsOverride; + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +LoadMiscDxeDefault ( + IN VOID *ConfigBlockPointer + ) +{ + MISC_DXE_CONFIG *MiscDxeConfig; + + MiscDxeConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "MiscDxeConfig->Header.GuidHob.Name =3D %g\n", &Misc= DxeConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "MiscDxeConfig->Header.GuidHob.Header.HobLength =3D = 0x%x\n", MiscDxeConfig->Header.GuidHob.Header.HobLength)); + /// + /// RMRR Base and Limit Address for USB + /// + MiscDxeConfig->RmrrUsbBaseAddress =3D AllocateZeroPool (sizeof (EFI_PHYS= ICAL_ADDRESS) * 2); + ASSERT (MiscDxeConfig->RmrrUsbBaseAddress !=3D NULL); + if (MiscDxeConfig->RmrrUsbBaseAddress !=3D NULL) { + /// + /// BIOS must update USB RMRR base address + /// + MiscDxeConfig->RmrrUsbBaseAddress[0] =3D 0; + MiscDxeConfig->RmrrUsbBaseAddress[1] =3D 0; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +LoadMemoryDxeDefault ( + IN VOID *ConfigBlockPointer + ) +{ + MEMORY_DXE_CONFIG *MemoryDxeConfig; + + MemoryDxeConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "MemoryDxeConfig->Header.GuidHob.Name =3D %g\n", &Me= moryDxeConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "MemoryDxeConfig->Header.GuidHob.Header.HobLength = =3D 0x%x\n", MemoryDxeConfig->Header.GuidHob.Header.HobLength)); + /// + /// Initialize the Memory Configuration + /// + /// + /// DIMM SMBus addresses info + /// Refer to the SpdAddressTable[] mapping rule in DxeSaPolicyLibrary.h + /// + MemoryDxeConfig->SpdAddressTable =3D AllocateZeroPool (sizeof (UINT8) * = 4); + ASSERT (MemoryDxeConfig->SpdAddressTable !=3D NULL); + if (MemoryDxeConfig->SpdAddressTable !=3D NULL) { + MemoryDxeConfig->SpdAddressTable[0] =3D DIMM_SMB_SPD_P0C0D0; + MemoryDxeConfig->SpdAddressTable[1] =3D DIMM_SMB_SPD_P0C0D1; + MemoryDxeConfig->SpdAddressTable[2] =3D DIMM_SMB_SPD_P0C1D0; + MemoryDxeConfig->SpdAddressTable[3] =3D DIMM_SMB_SPD_P0C1D1; + } + MemoryDxeConfig->ChannelASlotMap =3D 0x01; + MemoryDxeConfig->ChannelBSlotMap =3D 0x01; + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +LoadVbiosDxeDefault ( + IN VOID *ConfigBlockPointer + ) +{ + VBIOS_DXE_CONFIG *VbiosDxeConfig; + + VbiosDxeConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "VbiosDxeConfig->Header.GuidHob.Name =3D %g\n", &Vbi= osDxeConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "VbiosDxeConfig->Header.GuidHob.Header.HobLength =3D= 0x%x\n", VbiosDxeConfig->Header.GuidHob.Header.HobLength)); + /// + /// Initialize the SG VBIOS DXE Policies + /// + /// + /// 1 =3D secondary display device VBIOS Source is PCI Card + /// 0 =3D secondary display device VBIOS Source is FW Volume + /// + VbiosDxeConfig->VbiosSource =3D 1; + return EFI_SUCCESS; +} + +/** + LoadSaDxeConfigBlockDefault - Initialize default settings for each SA Co= nfig block + + @param[in] ConfigBlockPointer The buffer pointer that will be in= itialized as specific config block + @param[in] BlockId Request to initialize defaults of = specified config block by given Block ID + + @retval EFI_SUCCESS The given buffer has contained the= defaults of requested config block + @retval EFI_NOT_FOUND Block ID is not defined so no defa= ult Config block will be initialized +**/ +EFI_STATUS +EFIAPI +LoadSaDxeConfigBlockDefault ( + IN VOID *ConfigBlockPointer, + IN EFI_GUID BlockGuid + ) +{ + if (CompareGuid (&BlockGuid, &gGraphicsDxeConfigGuid)) { + LoadIgdDxeDefault (ConfigBlockPointer); + } else if (CompareGuid (&BlockGuid, &gMiscDxeConfigGuid)) { + LoadMiscDxeDefault (ConfigBlockPointer); + } else if (CompareGuid (&BlockGuid, &gPcieDxeConfigGuid)) { + LoadPcieDxeDefault (ConfigBlockPointer); + } else if (CompareGuid (&BlockGuid, &gMemoryDxeConfigGuid)) { + LoadMemoryDxeDefault (ConfigBlockPointer); + } else if (CompareGuid (&BlockGuid, &gVbiosDxeConfigGuid)) { + LoadVbiosDxeDefault (ConfigBlockPointer); + } else { + return EFI_NOT_FOUND; + } + return EFI_SUCCESS; +} + + +/** + CreateSaDxeConfigBlocks generates the config blocksg of SA DXE Policy. + It allocates and zero out buffer, and fills in the Intel default setting= s. + + @param[out] SaPolicy The pointer to get SA DXE Protocol i= nstance + + @retval EFI_SUCCESS The policy default is initialized. + @retval EFI_OUT_OF_RESOURCES Insufficient resources to create b= uffer +**/ +EFI_STATUS +EFIAPI +CreateSaDxeConfigBlocks ( + IN OUT SA_POLICY_PROTOCOL **SaPolicy + ) +{ + UINT16 TotalBlockSize; + UINT16 TotalBlockCount; + UINT16 BlockCount; + VOID *ConfigBlockPointer; + EFI_STATUS Status; + SA_POLICY_PROTOCOL *SaInitPolicy; + UINT16 RequiredSize; + STATIC CONFIG_BLOCK_HEADER SaDxeIpBlocks [] =3D { + {{{0, sizeof (GRAPHICS_DXE_CONFIG), 0}, {0}}, GRAPHICS_DXE_= CONFIG_REVISION, 0, {0, 0}}, + {{{0, sizeof (MEMORY_DXE_CONFIG), 0}, {0}}, MEMORY_DXE_CONFIG_= REVISION, 0, {0, 0}}, + {{{0, sizeof (MISC_DXE_CONFIG), 0}, {0}}, MISC_DXE_CONFIG_RE= VISION, 0, {0, 0}}, + {{{0, sizeof (PCIE_DXE_CONFIG), 0}, {0}}, PCIE_DXE_CONFIG_RE= VISION, 0, {0, 0}}, + {{{0, sizeof (VBIOS_DXE_CONFIG), 0}, {0}}, VBIOS_DXE_CONFIG_R= EVISION, 0, {0, 0}} + }; + + SaInitPolicy =3D NULL; + TotalBlockCount =3D sizeof (SaDxeIpBlocks) / sizeof (CONFIG_BLOCK_HEADER= ); + DEBUG ((DEBUG_INFO, "TotalBlockCount =3D 0x%x\n", TotalBlockCount)); + + TotalBlockSize =3D 0; + for (BlockCount =3D 0 ; BlockCount < TotalBlockCount; BlockCount++) { + TotalBlockSize +=3D (UINT32) SaDxeIpBlocks[BlockCount].GuidHob.Header.= HobLength; + DEBUG ((DEBUG_INFO, "TotalBlockSize after adding Block[0x%x]=3D 0x%x\= n", BlockCount, TotalBlockSize)); + } + + RequiredSize =3D sizeof (CONFIG_BLOCK_TABLE_HEADER) + TotalBlockSize; + + Status =3D CreateConfigBlockTable (RequiredSize, (VOID *)&SaInitPolicy); + ASSERT_EFI_ERROR (Status); + // + // Initalize SklSaIpBlocks table GUID + // + CopyMem (&SaDxeIpBlocks[0].GuidHob.Name, &gGraphicsDxeConfigGuid, sizeo= f (EFI_GUID)); + CopyMem (&SaDxeIpBlocks[1].GuidHob.Name, &gMemoryDxeConfigGuid, sizeo= f (EFI_GUID)); + CopyMem (&SaDxeIpBlocks[2].GuidHob.Name, &gMiscDxeConfigGuid, sizeo= f (EFI_GUID)); + CopyMem (&SaDxeIpBlocks[3].GuidHob.Name, &gPcieDxeConfigGuid, sizeo= f (EFI_GUID)); + CopyMem (&SaDxeIpBlocks[4].GuidHob.Name, &gVbiosDxeConfigGuid, sizeo= f (EFI_GUID)); + + // + // Initialize Policy Revision + // + SaInitPolicy->TableHeader.Header.Revision =3D SA_POLICY_PROTOCOL_REVISIO= N; + // + // Initialize ConfigBlockPointer to NULL + // + ConfigBlockPointer =3D NULL; + // + // Loop to identify each config block from SaDxeIpBlocks[] Table and add= each of them + // + for (BlockCount =3D 0 ; BlockCount < TotalBlockCount; BlockCount++) { + ConfigBlockPointer =3D (VOID *)&SaDxeIpBlocks[BlockCount]; + Status =3D AddConfigBlock ((VOID *) SaInitPolicy, (VOID *)&ConfigBlock= Pointer); + ASSERT_EFI_ERROR (Status); + LoadSaDxeConfigBlockDefault ((VOID *) ConfigBlockPointer, SaDxeIpBlock= s[BlockCount].GuidHob.Name); + } + // + // Assignment for returning SaPolicy config block base address + // + *SaPolicy =3D SaInitPolicy; + return EFI_SUCCESS; +} + + +/** + SaInstallPolicyProtocol installs SA Policy. + While installed, RC assumes the Policy is ready and finalized. So please= update and override + any setting before calling this function. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SaPolicy The pointer to SA Policy Protocol = instance + + @retval EFI_SUCCESS The policy is installed. + @retval EFI_OUT_OF_RESOURCES Insufficient resources to create b= uffer + +**/ +EFI_STATUS +EFIAPI +SaInstallPolicyProtocol ( + IN EFI_HANDLE ImageHandle, + IN SA_POLICY_PROTOCOL *SaPolicy + ) +{ + EFI_STATUS Status; + + /// + /// Print SA DXE Policy + /// + SaPrintPolicyProtocol (SaPolicy); + + /// + /// Install protocol to to allow access to this Policy. + /// + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &ImageHandle, + &gSaPolicyProtocolGuid, + SaPolicy, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeS= mmSaPlatformLib/SaPlatformLibrary.c b/Silicon/Intel/CoffeelakeSiliconPkg/Sy= stemAgent/Library/PeiDxeSmmSaPlatformLib/SaPlatformLibrary.c new file mode 100644 index 0000000000..fc6e469ae3 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiDxeSmmSaPla= tformLib/SaPlatformLibrary.c @@ -0,0 +1,128 @@ +/** @file + SA Platform Lib implementation. + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "SaPlatformLibrary.h" +#include +#include +#include + +/** + Determine if PCH Link is DMI/OPI + + @param[in] CpuModel CPU model + + @retval TRUE DMI + @retval FALSE OPI +**/ +BOOLEAN +IsPchLinkDmi ( + IN CPU_FAMILY CpuModel + ) +{ + if ((CpuModel =3D=3D EnumCpuCflDtHalo) || (CpuModel =3D=3D EnumCpuCnlDtH= alo)) { + return TRUE; // DMI + } + return FALSE; // OPI +} + + +/** + Returns the number of DMI lanes for current CPU + + @retval UINT8 +**/ +UINT8 +GetMaxDmiLanes ( + ) +{ + return SA_DMI_CFL_MAX_LANE; +} + + +/** + Returns the number of DMI bundles for current CPU + + @retval UINT8 +**/ +UINT8 +GetMaxDmiBundles ( + ) +{ + return SA_DMI_CFL_MAX_BUNDLE; +} + + +/** + Returns the function numbers for current CPU + + @retval UINT8 +**/ +UINT8 +GetMaxPegFuncs ( + ) +{ + if (GetCpuFamily() =3D=3D EnumCpuCnlDtHalo) { + return SA_PEG_CNL_H_MAX_FUN; + } else { + return SA_PEG_NON_CNL_H_MAX_FUN; + } +} + + +/** + Returns the number of PEG lanes for current CPU + + @retval UINT8 +**/ +UINT8 +GetMaxPegLanes ( + ) +{ + if (GetCpuFamily() =3D=3D EnumCpuCnlDtHalo) { + return SA_PEG_CNL_H_MAX_LANE; + } else { + return SA_PEG_NON_CNL_H_MAX_LANE; + } +} + + +/** + Returns the number of PEG bundles for current CPU + + @retval UINT8 +**/ +UINT8 +GetMaxPegBundles ( + ) +{ + if (GetCpuFamily() =3D=3D EnumCpuCnlDtHalo) { + return SA_PEG_CNL_H_MAX_BUNDLE; + } else { + return SA_PEG_NON_CNL_H_MAX_BUNDLE; + } +} + +/** + Checks if PEG port is present + + @retval TRUE PEG is presented + @retval FALSE PEG is not presented +**/ +BOOLEAN +IsPegPresent ( + VOID + ) +{ + UINT64 PegBaseAddress; + + PegBaseAddress =3D PCI_SEGMENT_LIB_ADDRESS (SA_SEG_NUM, SA_PEG_BUS_NUM,= SA_PEG_DEV_NUM, 0, 0); + if (PciSegmentRead16 (PegBaseAddress) !=3D 0xFFFF) { + return TRUE; + } + return FALSE; +} diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/MrcOemPlatform.c b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/L= ibrary/PeiSaPolicyLib/MrcOemPlatform.c new file mode 100644 index 0000000000..b7aec77842 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /MrcOemPlatform.c @@ -0,0 +1,745 @@ +/** @file + This file is SampleCode for Intel SA PEI Policy initialization. + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "MrcOemPlatform.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma pack (push, 1) +typedef union { + struct { + UINT32 : 8; + UINT32 MAX_NON_TURBO_LIM_RATIO : 8; + UINT32 : 16; + UINT32 : 32; + } Bits; + UINT64 Data; + UINT32 Data32[2]; + UINT16 Data16[4]; + UINT8 Data8[8]; +} PCU_CR_PLATFORM_INFO_STRUCT; + +#pragma pack (pop) + +#define SA_SYSTEM_BCLK (100) +#define PCU_CR_PLATFORM_INFO (0xCE) +#define MRC_POST_CODE_LOW_BYTE_ADDR (0x48) +#define MRC_POST_CODE_HIGH_BYTE_ADDR (0x49) +#define MAX_SPD_PAGE_COUNT (2) +#define MAX_SPD_PAGE_SIZE (256) +#define MAX_SPD_DDR3_SIZE (MAX_SPD_PAGE_SIZE * 1) +#define MAX_SPD_DDR4_SIZE (MAX_SPD_PAGE_SIZE * 2) +#define MAX_SPD_SIZE (MAX_SPD_PAGE_SIZE * MAX_SPD_PAGE_CO= UNT) +#define SPD_PAGE_ADDRESS_0 (0x6C) +#define SPD_PAGE_ADDRESS_1 (0x6E) +#define SPD_DDR3_XMP_OFFSET (176) +#define SPD_DDR4_XMP_OFFSET (384) +#define SPD_DDR3_SDRAM_TYPE_OFFSET (0x02) +#define SPD_DDR3_SDRAM_TYPE_NUMBER (0x0B) +#define SPD_DDR4_SDRAM_TYPE_NUMBER (0x0C) +#define SPD_LPDDR3_SDRAM_TYPE_NUMBER (0x0F) +#define SPD_LPDDR4_SDRAM_TYPE_NUMBER (0x10) +#define SPD_LPDDR4X_SDRAM_TYPE_NUMBER (0x11) +#define ISVT_END_OF_MRC_STATE (0x10) + +/** + Read the SPD data over the SMBus, at the specified SPD address, starting= at + the specified starting offset and read the given amount of data. + + @param[in] SpdAddress - SPD SMBUS address + @param[in, out] Buffer - Buffer to store the data. + @param[in] Start - Starting SPD offset + @param[in] Size - The number of bytes of data to read and also th= e size of the buffer. + @param[in, out] Page - The final page that is being pointed to. + + @retval RETURN_SUCCESS if the read is successful, otherwise error status= . +**/ +static +RETURN_STATUS +DoSpdRead ( + IN const UINT8 SpdAddress, + IN OUT UINT8 *const Buffer, + IN const UINT16 Start, + IN UINT16 Size, + IN OUT UINT8 *const Page + ) +{ + RETURN_STATUS EfiStatus; + BOOLEAN PageUpdate; + UINT16 Count; + UINT16 Index; + + EfiStatus =3D RETURN_DEVICE_ERROR; + if ((Buffer !=3D NULL) && (Start < MAX_SPD_SIZE) && ((Start + Size) < MA= X_SPD_SIZE)) { + Count =3D 0; + PageUpdate =3D FALSE; + while (Size--) { + Index =3D Start + Count; + if ((Index / MAX_SPD_PAGE_SIZE) !=3D *Page) { + *Page =3D (UINT8) (Index / MAX_SPD_PAGE_SIZE); + PageUpdate =3D TRUE; + } + Index %=3D MAX_SPD_PAGE_SIZE; + if (PageUpdate =3D=3D TRUE) { + PageUpdate =3D FALSE; + SmBusWriteDataByte ((*Page =3D=3D 0) ? SPD_PAGE_ADDRESS_0 : SPD_PA= GE_ADDRESS_1, 0, &EfiStatus); + } + Buffer[Count] =3D SmBusReadDataByte (SpdAddress | ((UINT32) Index <<= 8), &EfiStatus); + if (RETURN_SUCCESS !=3D EfiStatus) { + Buffer[Count] =3D 0; + break; + } + Count++; + } + EfiStatus =3D RETURN_SUCCESS; + } + return (EfiStatus); +} + +/** + See if there is valid XMP SPD data. + + @param[in] Debug - Mrc debug structure. + @param[in, out] Spd - Mrc SPD structure. + @param[in] XmpStart - The current offset in the SPD. + + @retval TRUE if valid, FALSE in not. +**/ +static +BOOLEAN +VerifyXmp ( + IN OUT MrcSpd *const Spd, + IN const UINT16 XmpStart + ) +{ + SPD_EXTREME_MEMORY_PROFILE_HEADER *Header1; + SPD_EXTREME_MEMORY_PROFILE_HEADER_2_0 *Header2; + BOOLEAN Xmp; + + Xmp =3D FALSE; + + switch (((UINT8 *) Spd) [2]) { + case SPD_DDR3_SDRAM_TYPE_NUMBER: + Header1 =3D &Spd->Ddr3.Xmp.Header; + if (XmpStart =3D=3D ((UINT32) (Header1) - (UINT32) Spd)) { + Xmp =3D TRUE; + if ((Header1->XmpRevision.Data & 0xFE) =3D=3D 0x12) { + return (TRUE); + } else { + Header1->XmpId =3D 0; + Header1->XmpOrgConf.Data =3D 0; + Header1->XmpRevision.Data =3D 0; + } + } + break; + case SPD_DDR4_SDRAM_TYPE_NUMBER: + Header2 =3D &Spd->Ddr4.EndUser.Xmp.Header; + if (XmpStart =3D=3D ((UINT32) (Header2) - (UINT32) Spd)) { + Xmp =3D TRUE; + if ((Header2->XmpRevision.Data) =3D=3D 0x20) { + return (TRUE); + } else { + Header2->XmpId =3D 0; + Header2->XmpOrgConf.Data =3D 0; + Header2->XmpRevision.Data =3D 0; + } + } + break; + case SPD_LPDDR3_SDRAM_TYPE_NUMBER: + case SPD_LPDDR4_SDRAM_TYPE_NUMBER: + case SPD_LPDDR4X_SDRAM_TYPE_NUMBER: + return (TRUE); + default: + return (FALSE); + } + if (!Xmp) { + return (TRUE); + } + return (FALSE); +} + +/** + Read the SPD data over the SMBus, at the given SmBus SPD address and cop= y the data to the data structure. + The SPD data locations read is controlled by the current boot mode. + + @param[in] BootMode - The current MRC boot mode. + @param[in] Address - SPD SmBus address offset. + @param[in] Buffer - Buffer that contains the data read from = the SPD. + @param[in] SpdDdr3Table - Indicates which SPD bytes to read. + @param[in] SpdDdr3TableSize - Size of SpdDdr3Table in bytes. + @param[in] SpdDdr4Table - Indicates which SPD bytes to read. + @param[in] SpdDdr4TableSize - Size of SpdDdr4Table in bytes. + @param[in] SpdLpddrTable - Indicates which SPD bytes to read. + @param[in] SpdLpddrTableSize - Size of SpdLpddrTable in bytes. + + @retval TRUE if the read is successful, otherwise FALSE on error. +**/ +BOOLEAN +GetSpdData ( + IN SPD_BOOT_MODE BootMode, + IN UINT8 Address, + IN OUT UINT8 *Buffer, + IN UINT8 *SpdDdr3Table, + IN UINT32 SpdDdr3TableSize, + IN UINT8 *SpdDdr4Table, + IN UINT32 SpdDdr4TableSize, + IN UINT8 *SpdLpddrTable, + IN UINT32 SpdLpddrTableSize + ) +{ + const SPD_OFFSET_TABLE *Tbl; + const SPD_OFFSET_TABLE *TableSelect; + RETURN_STATUS Status; + UINT32 Byte; + UINT32 Stop; + UINT8 Page; + + Page =3D (UINT8) (~0); + Status =3D DoSpdRead (Address, &Buffer[SPD_DDR3_SDRAM_TYPE_OFFSET], 2, 1= , &Page); + if (RETURN_SUCCESS =3D=3D Status) { + switch (Buffer[SPD_DDR3_SDRAM_TYPE_OFFSET]) { + case SPD_DDR3_SDRAM_TYPE_NUMBER: + default: + TableSelect =3D (SPD_OFFSET_TABLE *) SpdDdr3Table; + Stop =3D (SpdDdr3TableSize / sizeof (SPD_OFFSET_TABLE)); + break; + case SPD_DDR4_SDRAM_TYPE_NUMBER: + TableSelect =3D (SPD_OFFSET_TABLE *) SpdDdr4Table; + Stop =3D (SpdDdr4TableSize / sizeof (SPD_OFFSET_TABLE)); + break; + case SPD_LPDDR3_SDRAM_TYPE_NUMBER: + case SPD_LPDDR4_SDRAM_TYPE_NUMBER: + case SPD_LPDDR4X_SDRAM_TYPE_NUMBER: + TableSelect =3D (SPD_OFFSET_TABLE *) SpdLpddrTable; + Stop =3D (SpdLpddrTableSize / sizeof (SPD_OFFSET_TABLE)); + break; + } + for (Byte =3D 0; (RETURN_SUCCESS =3D=3D Status) && (Byte < Stop); Byte= ++) { + Tbl =3D &TableSelect[Byte]; + if ((1 << BootMode) & Tbl->BootMode) { + Status =3D DoSpdRead (Address, &Buffer[Tbl->Start], Tbl->Start, Tb= l->End - Tbl->Start + 1, &Page); + if (Status =3D=3D RETURN_SUCCESS) { + if (SpdCold =3D=3D BootMode) { + if (FALSE =3D=3D VerifyXmp ((MrcSpd *) Buffer, Tbl->Start)) { + break; + } + } + } else { + break; + } + } + } + } + + return ((RETURN_SUCCESS =3D=3D Status) ? TRUE : FALSE); +} + +// +// This is from MdeModulePkg\Include\Guid\StatusCodeDataTypeDebug.h +// Might need to be adjusted for a particular BIOS core +// +#ifndef EFI_STATUS_CODE_DATA_MAX_SIZE +#define EFI_STATUS_CODE_DATA_MAX_SIZE 200 +#endif + +/** + Output a string to the debug stream/device. + If there is a '%' sign in the string, convert it to '%%', so that DEBUG(= ) macro will print it properly. + + @param[in] String - The string to output. + + @retval Nothing. +**/ +VOID +SaDebugPrint ( + VOID *String + ) +{ + CHAR8 Str[EFI_STATUS_CODE_DATA_MAX_SIZE]; + CHAR8 *InputStr; + CHAR8 *OutputStr; + UINT32 i; + + InputStr =3D (CHAR8 *) String; + OutputStr =3D Str; + i =3D 0; + while (*InputStr !=3D 0) { + if (i < (EFI_STATUS_CODE_DATA_MAX_SIZE - 2)) { + *OutputStr++ =3D *InputStr; + i++; + if (*InputStr++ =3D=3D '%') { + *OutputStr++ =3D '%'; + i++; + } + } + } + *OutputStr =3D 0; // Terminating NULL + DEBUG ((DEBUG_INFO, Str)); + return; +} + +/** + Calculate the PCI device address for the given Bus/Device/Function/Offse= t. + + @param[in] Bus - PCI bus + @param[in] Device - PCI device + @param[in] Function - PCI function + @param[in] Offset - Offset + + @retval The PCI device address. +**/ +UINT32 +GetPciDeviceAddress ( + IN const UINT8 Bus, + IN const UINT8 Device, + IN const UINT8 Function, + IN const UINT8 Offset + ) +{ + return ( + ((UINT32) ((Bus) & 0xFF) << 16) | + ((UINT32) ((Device) & 0x1F) << 11) | + ((UINT32) ((Function) & 0x07) << 8) | + ((UINT32) ((Offset) & 0xFF) << 0) | + (1UL << 31)); +} + +/** + Calculate the PCIE device address for the given Bus/Device/Function/Offs= et. + + @param[in] Bus - PCI bus + @param[in] Device - PCI device + @param[in] Function - PCI function + @param[in] Offset - Offset + + The PCIE device address. + + @retval The PCIe device address +**/ +UINT32 +GetPcieDeviceAddress ( + IN const UINT8 Bus, + IN const UINT8 Device, + IN const UINT8 Function, + IN const UINT8 Offset + ) +{ + return ( + ((UINT32) Bus << 20) + + ((UINT32) Device << 15) + + ((UINT32) Function << 12) + + ((UINT32) Offset << 0)); +} + +/** + Read specific RTC/CMOS RAM + + @param[in] Location Point to RTC/CMOS RAM offset for read + + @retval The data of specific location in RTC/CMOS RAM. +**/ +UINT8 +PeiRtcRead ( + IN const UINT8 Location + ) +{ + UINT8 RtcIndexPort; + UINT8 RtcDataPort; + + // + // CMOS access registers (using alternative access not to handle NMI bit= ) + // + if (Location < RTC_BANK_SIZE) { + // + // First bank + // + RtcIndexPort =3D R_RTC_IO_INDEX_ALT; + RtcDataPort =3D R_RTC_IO_TARGET_ALT; + } else { + // + // Second bank + // + RtcIndexPort =3D R_RTC_IO_EXT_INDEX_ALT; + RtcDataPort =3D R_RTC_IO_EXT_TARGET_ALT; + } + + IoWrite8 (RtcIndexPort, Location & RTC_INDEX_MASK); + return IoRead8 (RtcDataPort); +} + +/** + Returns the current time, as determined by reading the Real Time Clock (= RTC) on the platform. + Since RTC time is stored in BCD, convert each value to binary. + + @param[out] Seconds - The current second (0-59). + @param[out] Minutes - The current minute (0-59). + @param[out] Hours - The current hour (0-23). + @param[out] DayOfMonth - The current day of the month (1-31). + @param[out] Month - The current month (1-12). + @param[out] Year - The current year (2000-2099). + + @retval Nothing. +**/ +VOID +GetRtcTime ( + OUT UINT8 *const Seconds, + OUT UINT8 *const Minutes, + OUT UINT8 *const Hours, + OUT UINT8 *const DayOfMonth, + OUT UINT8 *const Month, + OUT UINT16 *const Year + ) +{ + UINT32 Timeout; + + // + // Wait until RTC "update in progress" bit goes low. + // + Timeout =3D 0x0FFFFF; + do { + IoWrite8 (RTC_INDEX_REGISTER, CMOS_REGA); + if ((IoRead8 (RTC_TARGET_REGISTER) & RTC_UPDATE_IN_PROGRESS) !=3D RTC_= UPDATE_IN_PROGRESS) { + break; + } + } while (--Timeout > 0); + + if (0 =3D=3D Timeout) { + IoWrite8 (RTC_INDEX_REGISTER, CMOS_REGB); + IoWrite8 (RTC_TARGET_REGISTER, RTC_HOLD | RTC_MODE_24HOUR); + + IoWrite8 (RTC_INDEX_REGISTER, CMOS_REGA); + IoWrite8 (RTC_TARGET_REGISTER, RTC_CLOCK_DIVIDER | RTC_RATE_SELECT); + + IoWrite8 (RTC_INDEX_REGISTER, CMOS_REGC); + IoRead8 (RTC_TARGET_REGISTER); + + IoWrite8 (RTC_INDEX_REGISTER, CMOS_REGD); + IoRead8 (RTC_TARGET_REGISTER); + + IoWrite8 (RTC_INDEX_REGISTER, CMOS_REGB); + IoWrite8 (RTC_TARGET_REGISTER, RTC_MODE_24HOUR); + } + // + // Read seconds + // + IoWrite8 (RTC_INDEX_REGISTER, RTC_SECONDS); + *Seconds =3D IoRead8 (RTC_TARGET_REGISTER); + + // + // Read minutes + // + IoWrite8 (RTC_INDEX_REGISTER, RTC_MINUTES); + *Minutes =3D IoRead8 (RTC_TARGET_REGISTER); + + // + // Read hours + // + IoWrite8 (RTC_INDEX_REGISTER, RTC_HOURS); + *Hours =3D IoRead8 (RTC_TARGET_REGISTER); + + // + // Read day of month + // + IoWrite8 (RTC_INDEX_REGISTER, RTC_DAY_OF_MONTH); + *DayOfMonth =3D IoRead8 (RTC_TARGET_REGISTER); + + // + // Read month + // + IoWrite8 (RTC_INDEX_REGISTER, RTC_MONTH); + *Month =3D IoRead8 (RTC_TARGET_REGISTER); + + // + // Read year and add current century. + // + IoWrite8 (RTC_INDEX_REGISTER, RTC_YEAR); + *Year =3D IoRead8 (RTC_TARGET_REGISTER); + + *Seconds =3D BCD2BINARY (*Seconds); + *Minutes =3D BCD2BINARY (*Minutes); + *Hours =3D BCD2BINARY (*Hours); + *DayOfMonth =3D BCD2BINARY (*DayOfMonth); + *Month =3D BCD2BINARY (*Month); + *Year =3D BCD2BINARY (*Year) + CENTURY_OFFSET; +} + +/** + Gets CPU current time. + + @param[in] GlobalData - Pointer to global MRC data struct. + + @retval The current CPU time in milliseconds. +**/ +UINT64 +GetCpuTime ( + IN VOID *GlobalData + ) +{ + MrcParameters *MrcData; + MrcInput *Inputs; + PCU_CR_PLATFORM_INFO_STRUCT Msr; + UINT32 TimeBase; + + MrcData =3D (MrcParameters *) GlobalData; + Inputs =3D &MrcData->Inputs; + + Msr.Data =3D AsmReadMsr64 (PCU_CR_PLATFORM_INFO); + TimeBase =3D (Inputs->BClkFrequency / 1000) * Msr.Bits.MAX_NON_TURBO_LIM= _RATIO; //In Millisec + return ((TimeBase =3D=3D 0) ? 0 : DivU64x32 (AsmReadTsc (), TimeBase)); +} + +/** + Sets the specified number of memory words, a word at a time, at the + specified destination. + + @param[in, out] Dest - Destination pointer. + @param[in] NumWords - The number of dwords to set. + @param[in] Value - The value to set. + + @retval Pointer to the buffer. +**/ +VOID * +SetMemWord ( + IN OUT VOID *Dest, + IN UINTN NumWords, + IN const UINT16 Value + ) +{ + UINT16 *Buffer; + + Buffer =3D (UINT16 *) Dest; + while (0 !=3D NumWords--) { + *Buffer++ =3D Value; + } + + return (Dest); +} + +/** + Sets the specified number of memory dwords, a dword at a time, at the + specified destination. + + @param[in, out] Dest - Destination pointer. + @param[in] NumDwords - The number of dwords to set. + @param[in] Value - The value to set. + + @retval Pointer to the buffer. +**/ +VOID * +SetMemDword ( + IN OUT VOID *Dest, + IN UINT32 NumDwords, + IN const UINT32 Value + ) +{ + UINT32 *Buffer; + + Buffer =3D (UINT32 *) Dest; + while (0 !=3D NumDwords--) { + *Buffer++ =3D Value; + } + + return (Dest); +} + + +/** + Gets the current memory voltage (VDD). + + @param[in] GlobalData - Pointer to global MRC data struct. + @param[in] DefaultVdd - Default Vdd for the given platform. + + @retval The current memory voltage (VDD), in millivolts. 0 means platfor= m default. +**/ +UINT32 +GetMemoryVdd ( + IN VOID *GlobalData, + IN UINT32 DefaultVdd + ) +{ + UINT32 CurrentVoltage; + + CurrentVoltage =3D DefaultVdd; + + return CurrentVoltage; +} + +/** + Sets the memory voltage (VDD) to the specified value. + + @param[in] GlobalData - Pointer to global MRC data struct. + @param[in] DefaultVdd - Default Vdd for the given platform. + @param[in] Voltage - The new memory voltage to set. + + @retval The actual memory voltage (VDD), in millivolts, that is closest = to what the caller passed in. +**/ +UINT32 +SetMemoryVdd ( + IN VOID *GlobalData, + IN UINT32 DefaultVdd, + IN UINT32 Voltage + ) +{ + + return Voltage; +} + +/** + This function is used by the OEM to do a dedicated task during the MRC. + + @param[in] GlobalData - include all the MRC data + @param[in] OemStatusCommand - A command that indicates the task to perf= orm. + @param[in] Pointer - general ptr for general use. + + @retval The status of the task. +**/ +MrcStatus +CheckPoint ( + IN VOID *GlobalData, + IN MrcOemStatusCommand OemStatusCommand, + IN VOID *Pointer + ) +{ + MrcParameters *MrcData; + MrcInput *Inputs; + MrcStatus Status; + SI_PREMEM_POLICY_PPI *SiPreMemPolicyPpi; + MEMORY_CONFIG_NO_CRC *MemConfigNoCrc; + EFI_STATUS Status1; + + // + // Locate SiPreMemPolicyPpi to do a GetConfigBlock() to access platform = data + // + Status1 =3D PeiServicesLocatePpi ( + &gSiPreMemPolicyPpiGuid, + 0, + NULL, + (VOID **) &SiPreMemPolicyPpi + ); + ASSERT_EFI_ERROR (Status1); + + Status1 =3D GetConfigBlock ((VOID *) SiPreMemPolicyPpi, &gMemoryConfigNo= CrcGuid, (VOID *) &MemConfigNoCrc); + ASSERT_EFI_ERROR (Status1); + MrcData =3D (MrcParameters *) GlobalData; + Inputs =3D &MrcData->Inputs; + SiPreMemPolicyPpi =3D (SI_PREMEM_POLICY_PPI *) Inputs->SiPreMemPolicyPpi= ; + Status =3D mrcSuccess; + + switch (OemStatusCommand) { + default: + break; + } + + return (Status); +} + +/** + Typically used to display to the I/O port 80h. + + @param[in] GlobalData - Mrc Global Data + @param[in] DisplayDebugNumber - the number to display on port 80. + + @retval Nothing. +**/ +VOID +DebugHook ( + IN VOID *GlobalData, + UINT16 DisplayDebugNumber + ) +{ + MrcParameters *MrcData; + MrcOutput *Outputs; + MrcDebug *Debug; + EFI_STATUS Status; + SI_PREMEM_POLICY_PPI *SiPreMemPolicyPpi; + SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig; + + MrcData =3D (MrcParameters *) GlobalData; + Outputs =3D &MrcData->Outputs; + Debug =3D &Outputs->Debug; + + Debug->PostCode[MRC_POST_CODE] =3D DisplayDebugNumber; + IoWrite16 (0x80, DisplayDebugNumber); + DEBUG ((DEBUG_INFO, "Post Code: %04Xh\n", DisplayDebugNumber)); + + // + // Locate SiPreMemPolicyPpi to do a GetConfigBlock() to access platform = data + // + Status =3D PeiServicesLocatePpi (&gSiPreMemPolicyPpiGuid, 0, NULL, (VOID= **) &SiPreMemPolicyPpi); + ASSERT_EFI_ERROR (Status); + if (Status =3D=3D EFI_SUCCESS) { + Status =3D GetConfigBlock ((VOID *) SiPreMemPolicyPpi, &gSaMiscPeiPreM= emConfigGuid, (VOID *) &MiscPeiPreMemConfig); + if (Status =3D=3D EFI_SUCCESS) { + // + // Put the Port80 code also here: + // #define BIOS_POST_CODE_PCU_CNL_REG (0x00005824) + // + MmioWrite16 (MiscPeiPreMemConfig->MchBar + 0x5824, DisplayDebugNumbe= r); + } + } + return; +} + +/** + Hook to take any action after returning from MrcStartMemoryConfiguration= () + and prior to taking any action regarding MrcStatus. Pre-populated with = issuing + Intel Silicon View Technology (ISVT) checkpoint 0x10. + + @param[in] GlobalData - Mrc Global Data + @param[in] MrcStatus - Mrc status variable +**/ +void +ReturnFromSmc ( + IN VOID *GlobalData, + IN UINT32 MrcStatus + ) +{ + MrcInput *Inputs; + MrcParameters *MrcData; + UINT32 CheckPoint; + UINT32 PortReading; + + MrcData =3D (MrcParameters *) GlobalData; + Inputs =3D &MrcData->Inputs; + + DEBUG ((DEBUG_INFO, "Returned From MrcStartMemoryConfiguration(). MrcSta= tus =3D %08Xh\n", MrcStatus)); + + // + // Intel Silicon View Technology (ISVT) IO Reading port with EAX =3D 0x1= 0 for End of MRC + // + CheckPoint =3D ISVT_END_OF_MRC_STATE; + PortReading =3D (UINT32) Inputs->IsvtIoPort; + IsvtCheckPoint (CheckPoint, PortReading); + + return; +} + +/** + Assert or deassert DRAM_RESET# pin; this is used in JEDEC Reset. + + @param[in] PciEBaseAddress - PCI express base address. + @param[in] ResetValue - desired value of DRAM_RESET#. 1 - reset de= asserted, 0 - reset asserted. +**/ +VOID +SaDramReset ( + IN UINT32 PciEBaseAddress, + IN UINT32 ResetValue + ) +{ + PmcSetDramResetCtlState (ResetValue); + + return; +} + diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/PeiSaPolicyLib.c b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/L= ibrary/PeiSaPolicyLib/PeiSaPolicyLib.c new file mode 100644 index 0000000000..2ac3543f93 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /PeiSaPolicyLib.c @@ -0,0 +1,656 @@ +/** @file + This file provides services for PEI policy default initialization + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "PeiSaPolicyLibrary.h" +#include +#include +#include "MrcInterface.h" +#include + +#define DEFAULT_OPTION_ROM_TEMP_BAR 0x80000000 +#define DEFAULT_OPTION_ROM_TEMP_MEM_LIMIT 0xC0000000 +// +// Need minimum of 48MB during PEI phase for IAG and some buffer for boot. +// +#define PEI_MIN_MEMORY_SIZE (10 * 0x800000 + 0x10000000) = // 80MB + 256MB + +// +// Function call to Load defaults for Individial IP Blocks +// +VOID +LoadSaMiscPeiPreMemDefault ( + IN VOID *ConfigBlockPointer + ) +{ + SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig; + + MiscPeiPreMemConfig =3D ConfigBlockPointer; + + DEBUG ((DEBUG_INFO, "MiscPeiPreMemConfig->Header.GuidHob.Name =3D %g\n",= &MiscPeiPreMemConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "MiscPeiPreMemConfig->Header.GuidHob.Header.HobLengt= h =3D 0x%x\n", MiscPeiPreMemConfig->Header.GuidHob.Header.HobLength)); + // + // Policy initialization commented out here is because it's the same wit= h default 0 and no need to re-do again. + // + MiscPeiPreMemConfig->LockPTMregs =3D 1; + + // + // Initialize the Platform Configuration + // + MiscPeiPreMemConfig->MchBar =3D 0xFED10000; + MiscPeiPreMemConfig->DmiBar =3D 0xFED18000; + MiscPeiPreMemConfig->EpBar =3D 0xFED19000; + MiscPeiPreMemConfig->EdramBar =3D 0xFED80000; + MiscPeiPreMemConfig->SmbusBar =3D 0xEFA0; + MiscPeiPreMemConfig->TsegSize =3D PcdGet32 (PcdTsegSize); + MiscPeiPreMemConfig->GdxcBar =3D 0xFED84000; + + // + // Initialize the Switchable Graphics Default Configuration + // + MiscPeiPreMemConfig->SgDelayAfterHoldReset =3D 100; //100ms + MiscPeiPreMemConfig->SgDelayAfterPwrEn =3D 300; //300ms + + /// + /// Initialize the DataPtr for S3 resume + /// + MiscPeiPreMemConfig->S3DataPtr =3D NULL; + MiscPeiPreMemConfig->OpRomScanTempMmioBar =3D DEFAULT_OPTION_ROM_TE= MP_BAR; + MiscPeiPreMemConfig->OpRomScanTempMmioLimit =3D DEFAULT_OPTION_ROM_TE= MP_MEM_LIMIT; +} + +VOID +LoadSaMiscPeiDefault ( + IN VOID *ConfigBlockPointer + ) +{ + SA_MISC_PEI_CONFIG *MiscPeiConfig; + + MiscPeiConfig =3D ConfigBlockPointer; + + DEBUG ((DEBUG_INFO, "MiscPeiConfig->Header.GuidHob.Name =3D %g\n", &Misc= PeiConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "MiscPeiConfig->Header.GuidHob.Header.HobLength =3D = 0x%x\n", MiscPeiConfig->Header.GuidHob.Header.HobLength)); + + /// + /// EDRAM H/W Mode by default (0- EDRAM SW Disable, 1- EDRAM SW Enable, = 2- EDRAM HW Mode) + /// + MiscPeiConfig->EdramTestMode =3D 2; + + if (IsWhlCpu()) { + MiscPeiConfig->Device4Enable =3D 1; + } +} + +VOID +LoadVtdDefault ( + IN VOID *ConfigBlockPointer + ) +{ + VTD_CONFIG *Vtd; + + Vtd =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "Vtd->Header.GuidHob.Name =3D %g\n", &Vtd->Header.Gu= idHob.Name)); + DEBUG ((DEBUG_INFO, "Vtd->Header.GuidHob.Header.HobLength =3D 0x%x\n", V= td->Header.GuidHob.Header.HobLength)); + + // + // Initialize the Vtd Configuration + // + Vtd->VtdDisable =3D 0; + Vtd->BaseAddress[0] =3D 0xFED90000; + Vtd->BaseAddress[1] =3D 0xFED92000; + Vtd->BaseAddress[2] =3D 0xFED91000; +} + +VOID +LoadIpuPreMemDefault ( + IN VOID *ConfigBlockPointer + ) +{ + IPU_PREMEM_CONFIG *IpuPreMemPolicy; + + IpuPreMemPolicy =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "IpuPreMemPolicy->Header.GuidHob.Name =3D %g\n", &Ip= uPreMemPolicy->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "IpuPreMemPolicy->Header.GuidHob.Header.HobLength = =3D 0x%x\n", IpuPreMemPolicy->Header.GuidHob.Header.HobLength)); + +} + +VOID +LoadPciePeiPreMemDefault ( + IN VOID *ConfigBlockPointer + ) +{ + UINT8 Index; + PCIE_PEI_PREMEM_CONFIG *PciePeiPreMemConfig; + + PciePeiPreMemConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "PciePeiPreMemConfig->Header.GuidHob.Name =3D %g\n",= &PciePeiPreMemConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "PciePeiPreMemConfig->Header.GuidHob.Header.HobLengt= h =3D 0x%x\n", PciePeiPreMemConfig->Header.GuidHob.Header.HobLength)); + // + // Initialize the PciExpress Configuration + // + PciePeiPreMemConfig->DmiGen3EqPh2Enable =3D 2; + PciePeiPreMemConfig->DmiGen3ProgramStaticEq =3D 1; + PciePeiPreMemConfig->Peg0Enable =3D 2; + PciePeiPreMemConfig->Peg1Enable =3D 2; + PciePeiPreMemConfig->Peg2Enable =3D 2; + PciePeiPreMemConfig->Peg3Enable =3D 2; + PciePeiPreMemConfig->Peg0PowerDownUnusedLanes =3D 1; + PciePeiPreMemConfig->Peg1PowerDownUnusedLanes =3D 1; + PciePeiPreMemConfig->Peg2PowerDownUnusedLanes =3D 1; + PciePeiPreMemConfig->Peg3PowerDownUnusedLanes =3D 1; + PciePeiPreMemConfig->Peg0Gen3EqPh2Enable =3D 2; + PciePeiPreMemConfig->Peg1Gen3EqPh2Enable =3D 2; + PciePeiPreMemConfig->Peg2Gen3EqPh2Enable =3D 2; + PciePeiPreMemConfig->Peg3Gen3EqPh2Enable =3D 2; + PciePeiPreMemConfig->PegGen3ProgramStaticEq =3D 1; + PciePeiPreMemConfig->Gen3SwEqNumberOfPresets =3D 2; + PciePeiPreMemConfig->Gen3SwEqEnableVocTest =3D 2; + + if (IsCnlPch() && IsPchH() && (PchStepping() =3D=3D PCH_A0)) { + PciePeiPreMemConfig->DmiMaxLinkSpeed =3D 1; + } + + for (Index =3D 0; Index < SA_DMI_MAX_LANE; Index++) { + PciePeiPreMemConfig->DmiGen3RootPortPreset[Index] =3D 4; + PciePeiPreMemConfig->DmiGen3EndPointPreset[Index] =3D 7; + PciePeiPreMemConfig->DmiGen3EndPointHint[Index] =3D 2; + } + for (Index =3D 0; Index < SA_DMI_MAX_BUNDLE; Index++) { + /// + /// Gen3 RxCTLE peaking default is 0 for DMI + /// + PciePeiPreMemConfig->DmiGen3RxCtlePeaking[Index] =3D 0; + } + for (Index =3D 0; Index < SA_PEG_MAX_LANE; Index++) { + PciePeiPreMemConfig->PegGen3RootPortPreset[Index] =3D 7; + PciePeiPreMemConfig->PegGen3EndPointPreset[Index] =3D 7; + PciePeiPreMemConfig->PegGen3EndPointHint[Index] =3D 2; + } + PciePeiPreMemConfig->DmiDeEmphasis =3D 1; + /// + /// Gen3 Software Equalization Jitter Dwell Time: 1 msec + /// Gen3 Software Equalization Jitter Error Target: 1 + /// Gen3 Software Equalization VOC Dwell Time: 10 msec + /// Gen3 Software Equalization VOC Error Target: 2 + /// + PciePeiPreMemConfig->Gen3SwEqJitterDwellTime =3D 3 * STALL_ONE_MI= LLI_SECOND; + PciePeiPreMemConfig->Gen3SwEqJitterErrorTarget =3D 2; + PciePeiPreMemConfig->Gen3SwEqVocDwellTime =3D 10 * STALL_ONE_M= ILLI_SECOND; + PciePeiPreMemConfig->Gen3SwEqVocErrorTarget =3D 2; + + /** + Parameters for PCIe Gen3 device reset + @note Refer to the Platform Design Guide (PDG) for additional informatio= n about this GPIO. + **/ + PciePeiPreMemConfig->PegGpioData.GpioSupport =3D FALSE; + PciePeiPreMemConfig->PegGpioData.SaPeg0ResetGpio.GpioPad =3D 0; + PciePeiPreMemConfig->PegGpioData.SaPeg0ResetGpio.Active =3D FALSE; + PciePeiPreMemConfig->PegGpioData.SaPeg3ResetGpio.GpioPad =3D 0; + PciePeiPreMemConfig->PegGpioData.SaPeg3ResetGpio.Active =3D FALSE; +} + +VOID +LoadPciePeiDefault ( + IN VOID *ConfigBlockPointer + ) +{ + UINT8 Index; + PCIE_PEI_CONFIG *PciePeiConfig; + + PciePeiConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "PciePeiConfig->Header.GuidHob.Name =3D %g\n", &Pcie= PeiConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "PciePeiConfig->Header.GuidHob.Header.HobLength =3D = 0x%x\n", PciePeiConfig->Header.GuidHob.Header.HobLength)); + // + // Initialize the PciExpress Configuration + // + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + PciePeiConfig->PegDeEmphasis[Index] =3D 1; + PciePeiConfig->PegMaxPayload[Index] =3D 0xFF; + } + /// + /// Slot Power Limit Value: 75 W + /// Slot Power Limit Scale: 1.0x + /// Physical Slot Number: Peg Index + 1 (1,2,3) + /// + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + PciePeiConfig->PegSlotPowerLimitValue[Index] =3D 75; + PciePeiConfig->PegPhysicalSlotNumber[Index] =3D Index + 1; + } + +} + +VOID +LoadGraphichsPeiPreMemDefault ( + IN VOID *ConfigBlockPointer + ) +{ + GRAPHICS_PEI_PREMEM_CONFIG *GtPreMemConfig; + + GtPreMemConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "GtPreMemConfig->Header.GuidHob.Name =3D %g\n", &GtP= reMemConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "GtPreMemConfig->Header.GuidHob.Header.HobLength =3D= 0x%x\n", GtPreMemConfig->Header.GuidHob.Header.HobLength)); + + /// + /// Initialize Graphics Pre-Mem Configurations. + /// + GtPreMemConfig->GmAdr =3D 0xD0000000; + GtPreMemConfig->GttMmAdr =3D 0xCF000000; + GtPreMemConfig->GttSize =3D 3; + GtPreMemConfig->IgdDvmt50PreAlloc =3D 1; + GtPreMemConfig->InternalGraphics =3D 2; + GtPreMemConfig->PrimaryDisplay =3D 3; + GtPreMemConfig->ApertureSize =3D SA_GT_APERTURE_SIZE_256MB; + GtPreMemConfig->PanelPowerEnable =3D 1; +} + +VOID +LoadGraphichsPeiDefault ( + IN VOID *ConfigBlockPointer + ) +{ + GRAPHICS_PEI_CONFIG *GtConfig; + + GtConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "GtConfig->Header.GuidHob.Name =3D %g\n", &GtConfig-= >Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "GtConfig->Header.GuidHob.Header.HobLength =3D 0x%x\= n", GtConfig->Header.GuidHob.Header.HobLength)); + + // + // Initialize the Graphics configuration + // + GtConfig->RenderStandby =3D 1; + GtConfig->PavpEnable =3D 1; + GtConfig->PmSupport =3D 1; + GtConfig->CdynmaxClampEnable =3D 1; + GtConfig->GtFreqMax =3D 0xFF; + // + // Initialize the default VBT settings + // + GtConfig->DdiConfiguration.DdiPortEdp =3D 1; + GtConfig->DdiConfiguration.DdiPortBHpd =3D 1; + GtConfig->DdiConfiguration.DdiPortCHpd =3D 1; + GtConfig->DdiConfiguration.DdiPortDHpd =3D 1; + GtConfig->DdiConfiguration.DdiPortFHpd =3D 0; + GtConfig->DdiConfiguration.DdiPortBDdc =3D 1; + GtConfig->DdiConfiguration.DdiPortCDdc =3D 1; + GtConfig->DdiConfiguration.DdiPortDDdc =3D 1; + GtConfig->DdiConfiguration.DdiPortFDdc =3D 0; + + /// + /// Initialize the CdClock to 675 Mhz + /// + GtConfig->CdClock =3D 3; +} + +VOID +LoadSwitchableGraphichsDefault ( + IN VOID *ConfigBlockPointer + ) +{ + SWITCHABLE_GRAPHICS_CONFIG *SgConfig; + SgConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "SgConfig->Header.GuidHob.Name =3D %g\n", &SgConfig-= >Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "SgConfig->Header.GuidHob.Header.HobLength =3D 0x%x\= n", SgConfig->Header.GuidHob.Header.HobLength)); + SgConfig->SaRtd3Pcie0Gpio.GpioSupport =3D NotSupported; + SgConfig->SaRtd3Pcie1Gpio.GpioSupport =3D NotSupported; + SgConfig->SaRtd3Pcie2Gpio.GpioSupport =3D NotSupported; +} + +VOID +LoadMemConfigNoCrcDefault ( + IN VOID *ConfigBlockPointer + ) +{ + + MEMORY_CONFIG_NO_CRC *MemConfigNoCrc; + + MemConfigNoCrc =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "MemConfigNoCrc->Header.GuidHob.Name =3D %g\n", &Mem= ConfigNoCrc->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "MemConfigNoCrc->Header.GuidHob.Header.HobLength =3D= 0x%x\n", MemConfigNoCrc->Header.GuidHob.Header.HobLength)); + // + // Allocating memory space for pointer structures inside MemConfigNoCrc + // + MemConfigNoCrc->SpdData =3D (SPD_DATA_BUFFER *) AllocateZeroPool (sizeof= (SPD_DATA_BUFFER)); + ASSERT (MemConfigNoCrc->SpdData !=3D NULL); + if (MemConfigNoCrc->SpdData =3D=3D NULL) { + return; + } + + MemConfigNoCrc->DqByteMap =3D (SA_MEMORY_DQ_MAPPING *) AllocateZeroPool = (sizeof (SA_MEMORY_DQ_MAPPING)); + ASSERT (MemConfigNoCrc->DqByteMap !=3D NULL); + if (MemConfigNoCrc->DqByteMap =3D=3D NULL) { + return; + } + + MemConfigNoCrc->DqsMap =3D (SA_MEMORY_DQS_MAPPING *) AllocateZeroPool (s= izeof (SA_MEMORY_DQS_MAPPING)); + ASSERT (MemConfigNoCrc->DqsMap !=3D NULL); + if (MemConfigNoCrc->DqsMap =3D=3D NULL) { + return; + } + + MemConfigNoCrc->RcompData =3D (SA_MEMORY_RCOMP *) AllocateZeroPool (size= of (SA_MEMORY_RCOMP)); + ASSERT (MemConfigNoCrc->RcompData !=3D NULL); + if (MemConfigNoCrc->RcompData =3D=3D NULL) { + return; + } + + // + // Set PlatformMemory Size + // + + MemConfigNoCrc->PlatformMemorySize =3D PEI_MIN_MEMORY_SIZE; + + MemConfigNoCrc->SerialDebugLevel =3D 3; //< Enable MRC debug message + + MemConfigNoCrc->MemTestOnWarmBoot =3D 1; //< Enable to run BaseMemoryTe= st on warm boot by default + +} + +VOID +LoadGnaDefault ( + IN VOID *ConfigBlockPointer + ) +{ + GNA_CONFIG *GnaConfig; + GnaConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "GnaConfig->Header.GuidHob.Name =3D %g\n", &GnaConfi= g->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "GnaConfig->Header.GuidHob.Header.HobLength =3D 0x%x= \n", GnaConfig->Header.GuidHob.Header.HobLength)); + GnaConfig->GnaEnable =3D TRUE; +} + +VOID +LoadMemConfigDefault ( + IN VOID *ConfigBlockPointer + ) +{ + MEMORY_CONFIGURATION *MemConfig; + CPU_FAMILY CpuFamily; + UINT16 DeviceId; + + CPU_SKU CpuSku; + CpuSku =3D GetCpuSku (); + CpuFamily =3D GetCpuFamily (); + DeviceId =3D PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SA_SEG_NUM, S= A_MC_BUS, 0, 0, R_SA_MC_DEVICE_ID)); + + MemConfig =3D ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "MemConfig->Header.GuidHob.Name =3D %g\n", &MemConfi= g->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "MemConfig->Header.GuidHob.Header.HobLength =3D 0x%x= \n", MemConfig->Header.GuidHob.Header.HobLength)); + // + // Initialize the Memory Configuration + // + MemConfig->EnBER =3D 1; + MemConfig->EccSupport =3D 1; + MemConfig->ScramblerSupport =3D 1; + MemConfig->PowerDownMode =3D 0xFF; + MemConfig->RankInterleave =3D TRUE; + MemConfig->EnhancedInterleave =3D TRUE; + MemConfig->EnCmdRate =3D 3; + MemConfig->AutoSelfRefreshSupport =3D TRUE; + MemConfig->ExtTemperatureSupport =3D TRUE; + MemConfig->WeaklockEn =3D 1; + MemConfig->Ddr4MixedUDimm2DpcLimit =3D 1; + + MemConfig->DualDimmPerChannelBoardType =3D (CpuFamily =3D=3D EnumCpuCflD= tHalo) ? TRUE : FALSE; + + // + // Channel Hash Configuration + // + MemConfig->ChHashEnable =3D TRUE; + MemConfig->ChHashMask =3D 0; + MemConfig->ChHashInterleaveBit =3D 2; + MemConfig->PerBankRefresh =3D TRUE; + // + // Options for Thermal settings + // + MemConfig->EnablePwrDn =3D 1; + MemConfig->EnablePwrDnLpddr =3D 1; + MemConfig->DdrThermalSensor =3D 1; + + MemConfig->EnergyScaleFact =3D 4; + MemConfig->IdleEnergyCh0Dimm0 =3D 0xA; + MemConfig->IdleEnergyCh0Dimm1 =3D 0xA; + MemConfig->IdleEnergyCh1Dimm0 =3D 0xA; + MemConfig->IdleEnergyCh1Dimm1 =3D 0xA; + MemConfig->PdEnergyCh0Dimm0 =3D 0x6; + MemConfig->PdEnergyCh0Dimm1 =3D 0x6; + MemConfig->PdEnergyCh1Dimm0 =3D 0x6; + MemConfig->PdEnergyCh1Dimm1 =3D 0x6; + MemConfig->ActEnergyCh0Dimm0 =3D 0xAC; + MemConfig->ActEnergyCh0Dimm1 =3D 0xAC; + MemConfig->ActEnergyCh1Dimm0 =3D 0xAC; + MemConfig->ActEnergyCh1Dimm1 =3D 0xAC; + MemConfig->RdEnergyCh0Dimm0 =3D 0xD4; + MemConfig->RdEnergyCh0Dimm1 =3D 0xD4; + MemConfig->RdEnergyCh1Dimm0 =3D 0xD4; + MemConfig->RdEnergyCh1Dimm1 =3D 0xD4; + MemConfig->WrEnergyCh0Dimm0 =3D 0xDD; + MemConfig->WrEnergyCh0Dimm1 =3D 0xDD; + MemConfig->WrEnergyCh1Dimm0 =3D 0xDD; + MemConfig->WrEnergyCh1Dimm1 =3D 0xDD; + MemConfig->WarmThresholdCh0Dimm0 =3D 0xFF; + MemConfig->WarmThresholdCh0Dimm1 =3D 0xFF; + MemConfig->WarmThresholdCh1Dimm0 =3D 0xFF; + MemConfig->WarmThresholdCh1Dimm1 =3D 0xFF; + MemConfig->HotThresholdCh0Dimm0 =3D 0xFF; + MemConfig->HotThresholdCh0Dimm1 =3D 0xFF; + MemConfig->HotThresholdCh1Dimm0 =3D 0xFF; + MemConfig->HotThresholdCh1Dimm1 =3D 0xFF; + MemConfig->WarmBudgetCh0Dimm0 =3D 0xFF; + MemConfig->WarmBudgetCh0Dimm1 =3D 0xFF; + MemConfig->WarmBudgetCh1Dimm0 =3D 0xFF; + MemConfig->WarmBudgetCh1Dimm1 =3D 0xFF; + MemConfig->HotBudgetCh0Dimm0 =3D 0xFF; + MemConfig->HotBudgetCh0Dimm1 =3D 0xFF; + MemConfig->HotBudgetCh1Dimm0 =3D 0xFF; + MemConfig->HotBudgetCh1Dimm1 =3D 0xFF; + + MemConfig->SrefCfgEna =3D 1; + MemConfig->SrefCfgIdleTmr =3D 0x200; + MemConfig->ThrtCkeMinTmr =3D 0x30; + MemConfig->ThrtCkeMinDefeatLpddr =3D 1; + MemConfig->ThrtCkeMinTmrLpddr =3D 0x40; + + MemConfig->RaplLim2WindX =3D 1; + MemConfig->RaplLim2WindY =3D 1; + MemConfig->RaplLim2Pwr =3D 0xDE; + + // + // CA Vref routing: board-dependent + // 0 - VREF_CA goes to both CH_A and CH_B (LPDDR3/DDR3L) + // 1 - VREF_CA to CH_A, VREF_DQ_A to CH_B (should not be used) + // 2 - VREF_CA to CH_A, VREF_DQ_B to CH_B (DDR4) + // + //MemConfig->CaVrefConfig =3D 0; + MemConfig->VttTermination =3D ((CpuSku =3D=3D EnumCpuUlx) || (CpuSku= =3D=3D EnumCpuUlt)); + MemConfig->VttCompForVsshi =3D 0; + +#ifdef UP_SERVER_FLAG + MemConfig->TsodTcritmax =3D 0x69; + MemConfig->TsodThigMax =3D 0x5D; +#endif + + + // + // MRC training steps + // + MemConfig->ECT =3D 1; + MemConfig->ERDMPRTC2D =3D 1; + MemConfig->SOT =3D 1; + MemConfig->RDMPRT =3D 1; + MemConfig->RCVET =3D 1; + MemConfig->JWRL =3D 1; + MemConfig->EWRTC2D =3D 1; + MemConfig->ERDTC2D =3D 1; + MemConfig->WRTC1D =3D 1; + MemConfig->WRVC1D =3D 1; + MemConfig->RDTC1D =3D 1; + MemConfig->DIMMODTT =3D 1; + MemConfig->DIMMRONT =3D 1; + MemConfig->WRSRT =3D 1; + MemConfig->RDODTT =3D 1; + MemConfig->RDAPT =3D 1; + MemConfig->WRTC2D =3D 1; + MemConfig->RDTC2D =3D 1; + MemConfig->CMDVC =3D 1; + MemConfig->WRVC2D =3D 1; + MemConfig->RDVC2D =3D 1; + MemConfig->LCT =3D 1; + MemConfig->RTL =3D 1; + MemConfig->TAT =3D 1; + MemConfig->ALIASCHK =3D 1; + MemConfig->RCVENC1D =3D 1; + MemConfig->RMC =3D 1; + MemConfig->CMDSR =3D 1; + MemConfig->CMDDSEQ =3D 1; + MemConfig->CMDNORM =3D 1; + MemConfig->EWRDSEQ =3D 1; + MemConfig->McLock =3D TRUE; + MemConfig->GdxcIotSize =3D 4; + MemConfig->GdxcMotSize =3D 12; + MemConfig->RDEQT =3D 1; + + MemConfig->MrcFastBoot =3D TRUE; + MemConfig->MrcTrainOnWarm =3D FALSE; + MemConfig->RemapEnable =3D TRUE; + MemConfig->BClkFrequency =3D 100 * 1000 * 1000; + +#ifdef EMBEDDED_FLAG + MemConfig->Force1Dpc =3D TRUE; +#endif + MemConfig->Vc1ReadMeter =3D TRUE; + MemConfig->Vc1ReadMeterTimeWindow =3D 0x320; + MemConfig->Vc1ReadMeterThreshold =3D 0x118; + MemConfig->StrongWkLeaker =3D 7; + + MemConfig->MobilePlatform =3D (IS_SA_DEVICE_ID_MOBILE (DeviceId)) ? = TRUE : FALSE; + MemConfig->PciIndex =3D 0xCF8; + MemConfig->PciData =3D 0xCFC; + MemConfig->CkeRankMapping =3D 0xAA; + + // This only affects ULX/ULT; otherwise SA GV is disabled. + // CFL SA GV: 0 - Disabled, 1 - FixedLow, 2 - FixedHigh, 3 - Enabled + MemConfig->SaGv =3D 3; + MemConfig->SimicsFlag =3D 0; + + MemConfig->Idd3n =3D 26; + MemConfig->Idd3p =3D 11; + + MemConfig->RhPrevention =3D TRUE; // Row Hammer prevention= . + MemConfig->RhSolution =3D HardwareRhp; // Type of solution to b= e used for RHP - 0/1 =3D HardwareRhp/Refresh2x + MemConfig->RhActProbability =3D OneIn2To11; // Activation probabili= ty for Hardware RHP + + MemConfig->LpddrMemWriteLatencySet =3D 1; // Enable LPDDR3 WL Set B if = supported by DRAM + + MemConfig->DllBwEn1 =3D 1; + MemConfig->DllBwEn2 =3D 2; + MemConfig->DllBwEn3 =3D 2; + + MemConfig->RetrainOnFastFail =3D 1; // Restart MRC in Cold mode if SW = MemTest fails during Fast flow. 0 =3D Disabled, 1 =3D Enabled + MemConfig->Lp4DqsOscEn =3D 1; + MemConfig->IsvtIoPort =3D 0x99; +} + + +VOID +LoadOverClockConfigDefault ( + IN VOID *ConfigBlockPointer + ) +{ + OVERCLOCKING_PREMEM_CONFIG *OcPreMemConfig; + OcPreMemConfig =3D (OVERCLOCKING_PREMEM_CONFIG *)ConfigBlockPointer; + DEBUG ((DEBUG_INFO, "OcPreMemConfig->Header.GuidHob.Name =3D %g\n", &OcP= reMemConfig->Header.GuidHob.Name)); + DEBUG ((DEBUG_INFO, "OcPreMemConfig->Header.GuidHob.Header.HobLength =3D= 0x%x\n", OcPreMemConfig->Header.GuidHob.Header.HobLength)); +} + +static COMPONENT_BLOCK_ENTRY mSaIpBlocksPreMem [] =3D { + {&gSaMiscPeiPreMemConfigGuid, sizeof (SA_MISC_PEI_PREMEM_CONFIG), = SA_MISC_PEI_PREMEM_CONFIG_REVISION, LoadSaMiscPeiPreMemDefault}, + {&gSaPciePeiPreMemConfigGuid, sizeof (PCIE_PEI_PREMEM_CONFIG), = SA_PCIE_PEI_PREMEM_CONFIG_REVISION, LoadPciePeiPreMemDefault}, + {&gGraphicsPeiPreMemConfigGuid, sizeof (GRAPHICS_PEI_PREMEM_CONFIG),= GRAPHICS_PEI_PREMEM_CONFIG_REVISION, LoadGraphichsPeiPreMemDefault}, + {&gSwitchableGraphicsConfigGuid, sizeof (SWITCHABLE_GRAPHICS_CONFIG),= SWITCHABLE_GRAPHICS_CONFIG_REVISION, LoadSwitchableGraphichsDefault}, + {&gMemoryConfigGuid, sizeof (MEMORY_CONFIGURATION), = MEMORY_CONFIG_REVISION, LoadMemConfigDefault}, + {&gMemoryConfigNoCrcGuid, sizeof (MEMORY_CONFIG_NO_CRC), = MEMORY_CONFIG_REVISION, LoadMemConfigNoCrcDefault}, + {&gSaOverclockingPreMemConfigGuid, sizeof (OVERCLOCKING_PREMEM_CONFIG),= SA_OVERCLOCKING_CONFIG_REVISION, LoadOverClockConfigDefault}, + {&gVtdConfigGuid, sizeof (VTD_CONFIG), = VTD_CONFIG_REVISION, LoadVtdDefault}, + {&gIpuPreMemConfigGuid, sizeof (IPU_PREMEM_CONFIG), = IPU_PREMEM_CONFIG_REVISION, LoadIpuPreMemDefault} +}; + +static COMPONENT_BLOCK_ENTRY mSaIpBlocks [] =3D { + {&gSaMiscPeiConfigGuid, sizeof (SA_MISC_PEI_CONFIG), SA_MISC_PEI= _CONFIG_REVISION, LoadSaMiscPeiDefault}, + {&gSaPciePeiConfigGuid, sizeof (PCIE_PEI_CONFIG), SA_PCIE_PEI= _CONFIG_REVISION, LoadPciePeiDefault}, + {&gGraphicsPeiConfigGuid, sizeof (GRAPHICS_PEI_CONFIG), GRAPHICS_PE= I_CONFIG_REVISION, LoadGraphichsPeiDefault}, + {&gGnaConfigGuid, sizeof (GNA_CONFIG), GNA_CONFIG_= REVISION, LoadGnaDefault} +}; + +/** + Get SA config block table total size. + + @retval Size of SA config block table +**/ +UINT16 +EFIAPI +SaGetConfigBlockTotalSize ( + VOID + ) +{ + return GetComponentConfigBlockTotalSize (&mSaIpBlocks[0], sizeof (mSaIpB= locks) / sizeof (COMPONENT_BLOCK_ENTRY)); +} + +/** + Get SA config block table total size. + + @retval Size of SA config block table +**/ +UINT16 +EFIAPI +SaGetConfigBlockTotalSizePreMem ( + VOID + ) +{ + return GetComponentConfigBlockTotalSize (&mSaIpBlocksPreMem[0], sizeof (= mSaIpBlocksPreMem) / sizeof (COMPONENT_BLOCK_ENTRY)); +} + +/** + SaAddConfigBlocksPreMem add all SA config blocks. + + @param[in] ConfigBlockTableAddress The pointer to add SA config block= s + + @retval EFI_SUCCESS The policy default is initialized. + @retval EFI_OUT_OF_RESOURCES Insufficient resources to create b= uffer +**/ +EFI_STATUS +EFIAPI +SaAddConfigBlocksPreMem ( + IN VOID *ConfigBlockTableAddress + ) +{ + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO, "SA AddConfigBlocks. TotalBlockCount =3D 0x%x\n", s= izeof (mSaIpBlocksPreMem) / sizeof (COMPONENT_BLOCK_ENTRY))); + Status =3D AddComponentConfigBlocks (ConfigBlockTableAddress, &mSaIpBloc= ksPreMem[0], sizeof (mSaIpBlocksPreMem) / sizeof (COMPONENT_BLOCK_ENTRY)); + if (Status =3D=3D EFI_SUCCESS) { + SaLoadSamplePolicyPreMem (ConfigBlockTableAddress); + } + return Status; +} + +/** + SaAddConfigBlocks add all SA config blocks. + + @param[in] ConfigBlockTableAddress The pointer to add SA config block= s + + @retval EFI_SUCCESS The policy default is initialized. + @retval EFI_OUT_OF_RESOURCES Insufficient resources to create b= uffer +**/ +EFI_STATUS +EFIAPI +SaAddConfigBlocks ( + IN VOID *ConfigBlockTableAddress + ) +{ + DEBUG ((DEBUG_INFO, "SA AddConfigBlocks. TotalBlockCount =3D 0x%x\n", s= izeof (mSaIpBlocks) / sizeof (COMPONENT_BLOCK_ENTRY))); + + return AddComponentConfigBlocks (ConfigBlockTableAddress, &mSaIpBlocks[0= ], sizeof (mSaIpBlocks) / sizeof (COMPONENT_BLOCK_ENTRY)); +} diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/PeiSaPolicyLibSample.c b/Silicon/Intel/CoffeelakeSiliconPkg/SystemA= gent/Library/PeiSaPolicyLib/PeiSaPolicyLibSample.c new file mode 100644 index 0000000000..463e75702d --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /PeiSaPolicyLibSample.c @@ -0,0 +1,284 @@ +/** @file + This file provides services for Sample PEI policy default initialization= . + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include "PeiSaPolicyLibrary.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "MrcOemPlatform.h" +#include +#include +#include +#include + +// +// DQ byte mapping to CMD/CTL/CLK, from the CPU side +// +GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 mDqByteMapSkl[2][6][2] =3D { + // Channel 0: + { + { 0x0F, 0xF0 }, // CLK0 goes to package 0 - Bytes[3:0], CLK1 goes to p= ackage 1 - Bytes[7:4] + { 0x00, 0xF0 }, // CmdN does not have CAA, CAB goes to Bytes[7:4] + { 0x0F, 0xF0 }, // CmdS CAA goes to Bytes[3:0], CmdS CAB goes to Byte[= 7:4] + { 0x0F, 0x00 }, // CKE CAA goes to Bytes[3:0], CKE does not have CAB + { 0xFF, 0x00 }, // CTL (CS) goes to all bytes + { 0xFF, 0x00 } // CA Vref is one for all bytes + }, + // Channel 1: + { + { 0x33, 0xCC }, // CLK0 goes to package 0 - Bytes[3:0], CLK1 goes to p= ackage 1 - Bytes[7:4] + { 0x00, 0xCC }, // CmdN does not have CAA, CAB goes to Bytes[7:4] + { 0x33, 0xCC }, // CmdS CAA goes to Bytes[3:0], CmdS CAB goes to Byte[= 7:4] + { 0x33, 0x00 }, // CKE CAA goes to Bytes[3:0], CKE does not have CAB + { 0xFF, 0x00 }, // CTL (CS) goes to all bytes + { 0xFF, 0x00 } // CA Vref is one for all bytes + } +}; + +// +// DQS byte swizzling between CPU and DRAM +// +GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 mDqsMapCpu2DramSklRvp[2][8] =3D = { + { 0, 1, 3, 2, 4, 5, 6, 7 }, // Channel 0 + { 1, 0, 4, 5, 2, 3, 6, 7 } // Channel 1 +}; + +// +// Reference RCOMP resistors on motherboard +// +GLOBAL_REMOVE_IF_UNREFERENCED const UINT16 mRcompResistorSklRvp1[SA_MRC_MA= X_RCOMP] =3D { 200, 81, 162 }; +// +// RCOMP target values for RdOdt, WrDS, WrDSCmd, WrDSCtl, WrDSClk +// +GLOBAL_REMOVE_IF_UNREFERENCED const UINT16 mRcompTargetSklRvp1[SA_MRC_MAX_= RCOMP_TARGETS] =3D { 100, 40, 40, 23, 40 }; + +/** + Hynix H9CCNNN8JTMLAR-NTM_178b_DDP LPDDR3, 4Gb die (128Mx32), x32 + or Elpida EDF8132A1MC-GD-F + or Samsung K4E8E304EB-EGCE + 1600, 12-15-15-34 + 2 rank per channel, 2 SDRAMs per rank, 4x4Gb =3D 2GB total per channel +**/ +GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 mSkylakeRvp3Spd[] =3D { + 0x24, ///< 0 Number of Serial PD Bytes= Written / SPD Device Size + 0x20, ///< 1 SPD Revision + 0x0F, ///< 2 DRAM Device Type + 0x0E, ///< 3 Module Type + 0x14, ///< 4 SDRAM Density and Banks: = 8 Banks, 4 Gb SDRAM density + 0x11, ///< 5 SDRAM Addressing: 14 Rows= , 10 Columns + 0x90, ///< 6 SDRAM Package Type: Non-M= onolithic, DDP, 1 Channel per package + 0x00, ///< 7 SDRAM Optional Features + 0x00, ///< 8 SDRAM Thermal and Refresh= Options + 0x00, ///< 9 Other SDRAM Optional Feat= ures + 0x00, ///< 10 Reserved - must be coded = as 0x00 + 0x03, ///< 11 Module Nominal Voltage, V= DD + 0x0B, ///< 12 Module Organization, SDRA= M width: 32 bits, 2 Ranks + 0x03, ///< 13 Module Memory Bus Width: = 1 Channel, 64 bits channel width + 0x00, ///< 14 Module Thermal Sensor + 0x00, ///< 15 Extended Module Type + 0x00, ///< 16 Reserved - must be coded = as 0x00 + 0x00, ///< 17 Timebases + 0x0A, ///< 18 SDRAM Minimum Cycle Time = (tCKmin) + 0xFF, ///< 19 SDRAM Minimum Cycle Time = (tCKmax) + 0x54, ///< 20 CAS Latencies Supported, = First Byte (tCk): 12 10 8 + 0x00, ///< 21 CAS Latencies Supported, = Second Byte + 0x00, ///< 22 CAS Latencies Supported, = Third Byte + 0x00, ///< 23 CAS Latencies Supported, = Fourth Byte + 0x78, ///< 24 Minimum CAS Latency Time = (tAAmin) + 0x00, ///< 25 Read and Write Latency Se= t Options + 0x90, ///< 26 Minimum RAS# to CAS# Dela= y Time (tRCDmin) + 0xA8, ///< 27 Minimum Row Precharge Del= ay Time for all banks (tRPab) + 0x90, ///< 28 Minimum Row Precharge Del= ay Time per bank (tRPpb) + 0x10, ///< 29 Minimum Refresh Recovery = Delay Time for all banks (tRFCab), Least Significant Byte + 0x04, ///< 30 Minimum Refresh Recovery = Delay Time for all banks (tRFCab), Most Significant Byte + 0xE0, ///< 31 Minimum Refresh Recovery = Delay Time for per bank (tRFCpb), Least Significant Byte + 0x01, ///< 32 Minimum Refresh Recovery = Delay Time for per bank (tRFCpb), Most Significant Byte + 0, 0, 0, 0, 0, 0, 0, ///< 33 - 39 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 40 - 49 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 50 - 59 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 60 - 69 Connector to SDRAM Bi= t Mapping + 0, 0, 0, 0, 0, 0, 0, 0, ///< 70 - 77 Connector to SDRAM Bi= t Mapping + 0, 0, ///< 78 - 79 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 80 - 89 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 90 - 99 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 100 - 109 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 110 - 119 + 0x00, ///< 120 Fine Offset for Minimum R= ow Precharge Delay Time per bank (tRPpb) + 0x00, ///< 121 Fine Offset for Minimum R= ow Precharge Delay Time for all banks (tRPab) + 0x00, ///< 122 Fine Offset for Minimum R= AS# to CAS# Delay Time (tRCDmin) + 0x00, ///< 123 Fine Offset for Minimum C= AS Latency Time (tAAmin) + 0x7F, ///< 124 Fine Offset for SDRAM Min= imum Cycle Time (tCKmax) + 0x00, ///< 125 Fine Offset for SDRAM Min= imum Cycle Time (tCKmin) + 0x00, ///< 126 CRC A + 0x00, ///< 127 CRC B + 0, 0, ///< 128 - 129 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 130 - 139 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 140 - 149 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 150 - 159 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 160 - 169 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 170 - 179 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 180 - 189 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 190 - 199 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 200 - 209 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 210 - 219 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 220 - 229 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 230 - 239 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 240 - 249 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 250 - 259 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 260 - 269 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 270 - 279 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 280 - 289 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 290 - 299 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 300 - 309 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 310 - 319 + 0x00, ///< 320 Module Manufacturer ID Co= de, Least Significant Byte + 0x00, ///< 321 Module Manufacturer ID Co= de, Most Significant Byte + 0x00, ///< 322 Module Manufacturing Loca= tion + 0x00, ///< 323 Module Manufacturing Date= Year + 0x00, ///< 324 Module Manufacturing Date= Week + 0x55, ///< 325 Module Serial Number A + 0x00, ///< 326 Module Serial Number B + 0x00, ///< 327 Module Serial Number C + 0x00, ///< 328 Module Serial Number D + 0x20, 0x20, 0x20, 0x20, 0x20, ///< 329 - 333 Module Part Number:= Unused bytes coded as ASCII Blanks (0x20) + 0x20, 0x20, 0x20, 0x20, 0x20, ///< 334 - 338 Module Part Number + 0x20, 0x20, 0x20, 0x20, 0x20, ///< 339 - 343 Module Part Number + 0x20, 0x20, 0x20, 0x20, 0x20, ///< 344 - 348 Module Part Number + 0x00, ///< 349 Module Revision Code + 0x00, ///< 350 DRAM Manufacturer ID Code= , Least Significant Byte + 0x00, ///< 351 DRAM Manufacturer ID Code= , Most Significant Byte + 0x00, ///< 352 DRAM Stepping + 0, 0, 0, 0, 0, 0, 0, ///< 353 - 359 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 360 - 369 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 370 - 379 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 380 - 389 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 390 - 399 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 400 - 409 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 410 - 419 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 420 - 429 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 430 - 439 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 440 - 449 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 450 - 459 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 460 - 469 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 470 - 479 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 480 - 489 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 490 - 499 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ///< 500 - 509 + 0, 0 ///< 510 - 511 +}; + +#define SaIoRead8 IoRead8 +#define SaIoRead16 IoRead16 +#define SaIoRead32 IoRead32 +#define SaIoWrite8 IoWrite8 +#define SaIoWrite16 IoWrite16 +#define SaIoWrite32 IoWrite32 +#define SaCopyMem CopyMem +#define SaSetMem SetMem +#define SaLShiftU64 LShiftU64 +#define SaRShiftU64 RShiftU64 +#define SaMultU64x32 MultU64x32 + +/** + SaLoadSamplePolicyPreMem - Load some policy default for reference board. + + @param[in] ConfigBlockTableAddress The pointer for SA config blocks + +**/ +VOID +SaLoadSamplePolicyPreMem ( + IN VOID *ConfigBlockTableAddress + ) +{ + SA_FUNCTION_CALLS *MemCall; + EFI_STATUS Status; + MEMORY_CONFIG_NO_CRC *MemConfigNoCrc; + CPU_FAMILY CpuFamilyId; + UINT8 *DqByteMap; + BOOLEAN KblCpu; + + MemConfigNoCrc =3D NULL; + Status =3D GetConfigBlock (ConfigBlockTableAddress, &gMemoryConfigNoCrcG= uid, (VOID *) &MemConfigNoCrc); + ASSERT_EFI_ERROR (Status); + + if (MemConfigNoCrc =3D=3D NULL) { + return; + } + CpuFamilyId =3D GetCpuFamily (); + KblCpu =3D ((CpuFamilyId =3D=3D EnumCpuCflUltUlx) || (CpuFamilyId =3D=3D= EnumCpuCflDtHalo)); + + DEBUG ((DEBUG_INFO, "Applying Sample policy defaults for RVP3\n")); + MemCall =3D &MemConfigNoCrc->SaCall; + MemCall->IoRead8 =3D &SaIoRead8; + MemCall->IoRead16 =3D &SaIoRead16; + MemCall->IoRead32 =3D &SaIoRead32; + MemCall->IoWrite8 =3D &SaIoWrite8; + MemCall->IoWrite16 =3D &SaIoWrite16; + MemCall->IoWrite32 =3D &SaIoWrite32; + MemCall->MmioRead8 =3D &MmioRead8; + MemCall->MmioRead16 =3D &MmioRead16; + MemCall->MmioRead32 =3D &MmioRead32; + MemCall->MmioRead64 =3D &SaMmioRead64; + MemCall->MmioWrite8 =3D &MmioWrite8; + MemCall->MmioWrite16 =3D &MmioWrite16; + MemCall->MmioWrite32 =3D &MmioWrite32; + MemCall->MmioWrite64 =3D &SaMmioWrite64; + MemCall->SmbusRead8 =3D &SmBusReadDataByte; + MemCall->SmbusRead16 =3D &SmBusReadDataWord; + MemCall->SmbusWrite8 =3D &SmBusWriteDataByte; + MemCall->SmbusWrite16 =3D &SmBusWriteDataWord; + MemCall->GetPciDeviceAddress =3D &GetPciDeviceAddress; + MemCall->GetPcieDeviceAddress =3D &GetPcieDeviceAddress; + MemCall->GetRtcTime =3D &GetRtcTime; + MemCall->GetCpuTime =3D &GetCpuTime; + MemCall->CopyMem =3D &SaCopyMem; + MemCall->SetMem =3D &SaSetMem; + MemCall->SetMemWord =3D &SetMemWord; + MemCall->SetMemDword =3D &SetMemDword; + MemCall->LeftShift64 =3D &SaLShiftU64; + MemCall->RightShift64 =3D &SaRShiftU64; + MemCall->MultU64x32 =3D &SaMultU64x32; + MemCall->DivU64x64 =3D &DivU64x64Remainder; + MemCall->GetSpdData =3D &GetSpdData; + MemCall->GetRandomNumber =3D &GetRandomNumber32; + MemCall->CpuMailboxRead =3D &MailboxRead; + MemCall->CpuMailboxWrite =3D &MailboxWrite; + MemCall->GetMemoryVdd =3D &GetMemoryVdd; + MemCall->SetMemoryVdd =3D &SetMemoryVdd; + MemCall->CheckPoint =3D &CheckPoint; + MemCall->DebugHook =3D &DebugHook; + MemCall->DebugPrint =3D &SaDebugPrint; + MemCall->GetRtcCmos =3D &PeiRtcRead; + MemCall->ReadMsr64 =3D &AsmReadMsr64; + MemCall->WriteMsr64 =3D &AsmWriteMsr64; + MemCall->MrcReturnFromSmc =3D &ReturnFromSmc; + MemCall->MrcDramReset =3D &SaDramReset; + + // + // RCOMP resistors and target values: board-dependent + // + if (KblCpu) { + CopyMem ((VOID *) MemConfigNoCrc->RcompData->RcompResistor, mRcompResi= storSklRvp1, sizeof (mRcompResistorSklRvp1)); + CopyMem ((VOID *) MemConfigNoCrc->RcompData->RcompTarget, mRcompTarg= etSklRvp1, sizeof (mRcompTargetSklRvp1)); + } + + CopyMem ((VOID *) MemConfigNoCrc->SpdData->SpdData[0][0], mSkylakeRvp3Sp= d, sizeof (mSkylakeRvp3Spd)); + CopyMem ((VOID *) MemConfigNoCrc->SpdData->SpdData[1][0], mSkylakeRvp3Sp= d, sizeof (mSkylakeRvp3Spd)); + + DqByteMap =3D (UINT8 *) mDqByteMapSkl; + + CopyMem ((VOID *) MemConfigNoCrc->DqByteMap, DqByteMap, sizeof (UINT8) *= SA_MC_MAX_CHANNELS * SA_MRC_ITERATION_MAX * 2); + CopyMem ((VOID *) MemConfigNoCrc->DqsMap, mDqsMapCpu2DramSklRvp, sizeof = (UINT8) * SA_MC_MAX_CHANNELS * SA_MC_MAX_BYTES_NO_ECC); +} + diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/SaPrintPolicy.c b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Li= brary/PeiSaPolicyLib/SaPrintPolicy.c new file mode 100644 index 0000000000..ce3ef52733 --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /SaPrintPolicy.c @@ -0,0 +1,559 @@ +/** @file + This file provides service for PEI phase policy printing + + Copyright (c) 2019 Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "PeiSaPolicyLibrary.h" +#include + +/** + This function prints the PEI phase PreMem policy. + + @param[in] SiPolicyPreMemPpi - Instance of SI_PREMEM_POLICY_PPI +**/ +VOID +EFIAPI +SaPrintPolicyPpiPreMem ( + IN SI_PREMEM_POLICY_PPI *SiPolicyPreMemPpi + ) +{ + DEBUG_CODE_BEGIN (); + INTN Index; + INTN Index2; + EFI_STATUS Status; + SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig; + GRAPHICS_PEI_PREMEM_CONFIG *GtPreMemConfig; + MEMORY_CONFIGURATION *MemConfig; + PCIE_PEI_PREMEM_CONFIG *PciePeiPreMemConfig; + SWITCHABLE_GRAPHICS_CONFIG *SgConfig; + MEMORY_CONFIG_NO_CRC *MemConfigNoCrc; + VTD_CONFIG *Vtd; + OVERCLOCKING_PREMEM_CONFIG *OcPreMemConfig; + IPU_PREMEM_CONFIG *IpuPreMemPolicy; + + // + // Get requisite IP Config Blocks which needs to be used here + // + Status =3D GetConfigBlock ((VOID *)SiPolicyPreMemPpi, &gSaMiscPeiPreMemC= onfigGuid, (VOID *) &MiscPeiPreMemConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *)SiPolicyPreMemPpi, &gGraphicsPeiPreMe= mConfigGuid, (VOID *) &GtPreMemConfig); + ASSERT_EFI_ERROR (Status); + Status =3D GetConfigBlock ((VOID *) SiPolicyPreMemPpi, &gVtdConfigGuid, = (VOID *) &Vtd); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *)SiPolicyPreMemPpi, &gMemoryConfigGuid= , (VOID *) &MemConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *)SiPolicyPreMemPpi, &gSaPciePeiPreMemC= onfigGuid, (VOID *) &PciePeiPreMemConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *)SiPolicyPreMemPpi, &gSwitchableGraphi= csConfigGuid, (VOID *) &SgConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *)SiPolicyPreMemPpi, &gMemoryConfigNoCr= cGuid, (VOID *) &MemConfigNoCrc); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SiPolicyPreMemPpi, &gSaOverclockingP= reMemConfigGuid, (VOID *) &OcPreMemConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SiPolicyPreMemPpi, &gIpuPreMemConfig= Guid, (VOID *) &IpuPreMemPolicy); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INFO, "\n------------------------ SA Policy (PEI PreMem) P= rint BEGIN -----------------\n")); + DEBUG ((DEBUG_INFO, "Revision : 0x%x\n", SiPolicyPreMemPpi->TableHeader.= Header.Revision)); + ASSERT (SiPolicyPreMemPpi->TableHeader.Header.Revision =3D=3D SI_PREMEM_= POLICY_REVISION); + + DEBUG ((DEBUG_INFO, "------------------------ SA_MISC_PEI_PREMEM_CONFIG = -----------------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", MiscPeiPreMemConfig->Header.Revi= sion)); + ASSERT (MiscPeiPreMemConfig->Header.Revision =3D=3D SA_MISC_PEI_PREMEM_C= ONFIG_REVISION); + DEBUG ((DEBUG_INFO, " SpdAddressTable[%d] :", SA_MC_MAX_SOCKETS)); + for (Index =3D 0; Index < SA_MC_MAX_SOCKETS; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", MiscPeiPreMemConfig->SpdAddressTable[Inde= x])); + } + + DEBUG ((DEBUG_INFO, "\n MchBar : 0x%x\n", MiscPeiPreMemConfig->MchBar)); + DEBUG ((DEBUG_INFO, " DmiBar : 0x%x\n", MiscPeiPreMemConfig->DmiBar)); + DEBUG ((DEBUG_INFO, " EpBar : 0x%x\n", MiscPeiPreMemConfig->EpBar)); + DEBUG ((DEBUG_INFO, " SmbusBar : 0x%x\n", MiscPeiPreMemConfig->SmbusBar)= ); + DEBUG ((DEBUG_INFO, " GdxcBar : 0x%x\n", MiscPeiPreMemConfig->GdxcBar)); + DEBUG ((DEBUG_INFO, " TsegSize : 0x%x\n", MiscPeiPreMemConfig->TsegSize)= ); + DEBUG ((DEBUG_INFO, " UserBd : 0x%x\n", MiscPeiPreMemConfig->UserBd)); + DEBUG ((DEBUG_INFO, " EdramBar : 0x%x\n", MiscPeiPreMemConfig->EdramBar)= ); + DEBUG ((DEBUG_INFO, " MmioSize : %d MB\n", MiscPeiPreMemConfig->MmioSize= )); + DEBUG ((DEBUG_INFO, " MmioSizeAdjustment : %d MB\n", MiscPeiPreMemConfig= ->MmioSizeAdjustment)); + DEBUG ((DEBUG_INFO, " SkipExtGfxScan: 0x%x\n", MiscPeiPreMemConfig->Skip= ExtGfxScan)); + DEBUG ((DEBUG_INFO, " S3DataPtr : 0x%x\n", MiscPeiPreMemConfig->S3DataPt= r)); + DEBUG ((DEBUG_INFO, "------------------------ SG_DELAY_OPTIMIZATION_DATA= -----------------\n")); + DEBUG ((DEBUG_INFO, " SaRtd3.SgDelayAfterHoldReset : 0x%x\n", MiscPeiPre= MemConfig->SgDelayAfterHoldReset)); + DEBUG ((DEBUG_INFO, " SaRtd3.SgDelayAfterPwrEn : 0x%x\n", MiscPeiPre= MemConfig->SgDelayAfterPwrEn)); + + DEBUG ((DEBUG_INFO, " ScanExtGfxForLegacyOpRom : 0x%x\n", MiscPeiPreMemC= onfig->ScanExtGfxForLegacyOpRom)); + DEBUG ((DEBUG_INFO, " AcpiReservedMemoryBase : 0x%x\n", MiscPeiPreMemCon= fig->AcpiReservedMemoryBase)); + DEBUG ((DEBUG_INFO, " AcpiReservedMemorySize : 0x%x\n", MiscPeiPreMemCon= fig->AcpiReservedMemorySize)); + DEBUG ((DEBUG_INFO, " SystemMemoryLength : 0x%x\n", MiscPeiPreMemConfig-= >SystemMemoryLength)); + DEBUG ((DEBUG_INFO, " OpRomScanTempMmioBar : 0x%x\n", MiscPeiPreMemConfi= g->OpRomScanTempMmioBar)); + DEBUG ((DEBUG_INFO, " OpRomScanTempMmioLimit : 0x%x\n", MiscPeiPreMemCon= fig->OpRomScanTempMmioLimit)); + + DEBUG ((DEBUG_INFO, "------------------------ GRAPHICS_PEI_PREMEM_CONFIG= -----------------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", GtPreMemConfig->Header.Revision)= ); + ASSERT (GtPreMemConfig->Header.Revision =3D=3D GRAPHICS_PEI_PREMEM_CONFI= G_REVISION); + DEBUG ((DEBUG_INFO, " PanelPowerEnable : 0x%x\n", GtPreMemConfig->PanelP= owerEnable)); + DEBUG ((DEBUG_INFO, " GttSize : %d MB\n", GtPreMemConfig->GttSize)); + DEBUG ((DEBUG_INFO, " IgdDvmt50PreAlloc : 0x%x\n", GtPreMemConfig->IgdDv= mt50PreAlloc)); + DEBUG ((DEBUG_INFO, " InternalGraphics : 0x%x\n", GtPreMemConfig->Intern= alGraphics)); + DEBUG ((DEBUG_INFO, " PrimaryDisplay : 0x%x\n", GtPreMemConfig->PrimaryD= isplay)); + DEBUG ((DEBUG_INFO, " ApertureSize : 0x%x\n", GtPreMemConfig->ApertureSi= ze)); + DEBUG ((DEBUG_INFO, " GtPsmiSupport : 0x%x\n", GtPreMemConfig->GtPsmiSup= port)); + DEBUG ((DEBUG_INFO, " PsmiRegionSize : 0x%x\n", GtPreMemConfig->PsmiRegi= onSize)); + DEBUG ((DEBUG_INFO, " GttMmAdr : 0x%x\n", GtPreMemConfig->GttMmAdr)); + DEBUG ((DEBUG_INFO, " GmAdr : 0x%x\n", GtPreMemConfig->GmAdr)); + DEBUG ((DEBUG_INFO, " DeltaT12PowerCycleDelayPreMem : 0x%x\n", GtPreMemC= onfig->DeltaT12PowerCycleDelayPreMem)); + + DEBUG ((DEBUG_INFO, "------------------------ PCIE_PEI_PREMEM_CONFIG ---= --------------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", PciePeiPreMemConfig->Header.Revi= sion)); + ASSERT (PciePeiPreMemConfig->Header.Revision =3D=3D SA_PCIE_PEI_PREMEM_C= ONFIG_REVISION); + DEBUG ((DEBUG_INFO, " DmiMaxLinkSpeed : 0x%x\n", PciePeiPreMemConfig->Dm= iMaxLinkSpeed)); + DEBUG ((DEBUG_INFO, " DmiGen3EqPh2Enable : 0x%x\n", PciePeiPreMemConfig-= >DmiGen3EqPh2Enable)); + DEBUG ((DEBUG_INFO, " DmiGen3EqPh3Method : 0x%x\n", PciePeiPreMemConfig-= >DmiGen3EqPh3Method)); + DEBUG ((DEBUG_INFO, " DmiGen3ProgramStaticEq : 0x%x\n", PciePeiPreMemCon= fig->DmiGen3ProgramStaticEq)); + DEBUG ((DEBUG_INFO, " Peg0Enable : 0x%x\n", PciePeiPreMemConfig->Peg0Ena= ble)); + DEBUG ((DEBUG_INFO, " Peg1Enable : 0x%x\n", PciePeiPreMemConfig->Peg1Ena= ble)); + DEBUG ((DEBUG_INFO, " Peg2Enable : 0x%x\n", PciePeiPreMemConfig->Peg2Ena= ble)); + DEBUG ((DEBUG_INFO, " Peg3Enable : 0x%x\n", PciePeiPreMemConfig->Peg3Ena= ble)); + DEBUG ((DEBUG_INFO, " Peg0MaxLinkSpeed : 0x%x\n", PciePeiPreMemConfig->P= eg0MaxLinkSpeed)); + DEBUG ((DEBUG_INFO, " Peg1MaxLinkSpeed : 0x%x\n", PciePeiPreMemConfig->P= eg1MaxLinkSpeed)); + DEBUG ((DEBUG_INFO, " Peg2MaxLinkSpeed : 0x%x\n", PciePeiPreMemConfig->P= eg2MaxLinkSpeed)); + DEBUG ((DEBUG_INFO, " Peg3MaxLinkSpeed : 0x%x\n", PciePeiPreMemConfig->P= eg3MaxLinkSpeed)); + DEBUG ((DEBUG_INFO, " Peg0MaxLinkWidth : 0x%x\n", PciePeiPreMemConfig->P= eg0MaxLinkWidth)); + DEBUG ((DEBUG_INFO, " Peg1MaxLinkWidth : 0x%x\n", PciePeiPreMemConfig->P= eg1MaxLinkWidth)); + DEBUG ((DEBUG_INFO, " Peg2MaxLinkWidth : 0x%x\n", PciePeiPreMemConfig->P= eg2MaxLinkWidth)); + DEBUG ((DEBUG_INFO, " Peg3MaxLinkWidth : 0x%x\n", PciePeiPreMemConfig->P= eg3MaxLinkWidth)); + DEBUG ((DEBUG_INFO, " Peg0PowerDownUnusedLanes : 0x%x\n", PciePeiPreMemC= onfig->Peg0PowerDownUnusedLanes)); + DEBUG ((DEBUG_INFO, " Peg1PowerDownUnusedLanes : 0x%x\n", PciePeiPreMemC= onfig->Peg1PowerDownUnusedLanes)); + DEBUG ((DEBUG_INFO, " Peg2PowerDownUnusedLanes : 0x%x\n", PciePeiPreMemC= onfig->Peg2PowerDownUnusedLanes)); + DEBUG ((DEBUG_INFO, " Peg3PowerDownUnusedLanes : 0x%x\n", PciePeiPreMemC= onfig->Peg3PowerDownUnusedLanes)); + DEBUG ((DEBUG_INFO, " Peg0Gen3EqPh2Enable : 0x%x\n", PciePeiPreMemConfig= ->Peg0Gen3EqPh2Enable)); + DEBUG ((DEBUG_INFO, " Peg1Gen3EqPh2Enable : 0x%x\n", PciePeiPreMemConfig= ->Peg1Gen3EqPh2Enable)); + DEBUG ((DEBUG_INFO, " Peg2Gen3EqPh2Enable : 0x%x\n", PciePeiPreMemConfig= ->Peg2Gen3EqPh2Enable)); + DEBUG ((DEBUG_INFO, " Peg3Gen3EqPh2Enable : 0x%x\n", PciePeiPreMemConfig= ->Peg3Gen3EqPh2Enable)); + DEBUG ((DEBUG_INFO, " Peg0Gen3EqPh3Method : 0x%x\n", PciePeiPreMemConfig= ->Peg0Gen3EqPh3Method)); + DEBUG ((DEBUG_INFO, " Peg1Gen3EqPh3Method : 0x%x\n", PciePeiPreMemConfig= ->Peg1Gen3EqPh3Method)); + DEBUG ((DEBUG_INFO, " Peg2Gen3EqPh3Method : 0x%x\n", PciePeiPreMemConfig= ->Peg2Gen3EqPh3Method)); + DEBUG ((DEBUG_INFO, " Peg3Gen3EqPh3Method : 0x%x\n", PciePeiPreMemConfig= ->Peg3Gen3EqPh3Method)); + DEBUG ((DEBUG_INFO, " PegGen3ProgramStaticEq : 0x%x\n", PciePeiPreMemCon= fig->PegGen3ProgramStaticEq)); + DEBUG ((DEBUG_INFO, " Gen3SwEqAlwaysAttempt : 0x%x\n", PciePeiPreMemConf= ig->Gen3SwEqAlwaysAttempt)); + DEBUG ((DEBUG_INFO, " Gen3SwEqNumberOfPresets : 0x%x\n", PciePeiPreMemCo= nfig->Gen3SwEqNumberOfPresets)); + DEBUG ((DEBUG_INFO, " Gen3SwEqEnableVocTest : 0x%x\n", PciePeiPreMemConf= ig->Gen3SwEqEnableVocTest)); + DEBUG ((DEBUG_INFO, " InitPcieAspmAfterOprom : 0x%x\n", PciePeiPreMemCon= fig->InitPcieAspmAfterOprom)); + DEBUG ((DEBUG_INFO, " PegRxCemTestingMode : 0x%x\n", PciePeiPreMemConfig= ->PegRxCemTestingMode)); + DEBUG ((DEBUG_INFO, " PegRxCemLoopbackLane : 0x%x\n", PciePeiPreMemConfi= g->PegRxCemLoopbackLane)); + DEBUG ((DEBUG_INFO, " PegRxCemNonProtocolAwareness : 0x%x\n", PciePeiPre= MemConfig->PegRxCemNonProtocolAwareness)); + DEBUG ((DEBUG_INFO, " PegDisableSpreadSpectrumClocking : 0x%x\n", PciePe= iPreMemConfig->PegDisableSpreadSpectrumClocking)); + DEBUG ((DEBUG_INFO, " PegGenerateBdatMarginTable : 0x%x\n", PciePeiPreMe= mConfig->PegGenerateBdatMarginTable)); + DEBUG ((DEBUG_INFO, " DmiGen3RootPortPreset[%d] :", SA_DMI_MAX_LANE)); + for (Index =3D 0; Index < SA_DMI_MAX_LANE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->DmiGen3RootPortPrese= t[Index])); + } + DEBUG ((DEBUG_INFO, "\n DmiGen3EndPointPreset[%d] :", SA_DMI_MAX_LANE)); + for (Index =3D 0; Index < SA_DMI_MAX_LANE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->DmiGen3EndPointPrese= t[Index])); + } + DEBUG ((DEBUG_INFO, "\n DmiGen3EndPointHint[%d] :", SA_DMI_MAX_LANE)); + for (Index =3D 0; Index < SA_DMI_MAX_LANE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->DmiGen3EndPointHint[= Index])); + } + DEBUG ((DEBUG_INFO, "\n DmiGen3RxCtlePeaking[%d] :", SA_DMI_MAX_BUNDLE))= ; + for (Index =3D 0; Index < SA_DMI_MAX_BUNDLE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->DmiGen3RxCtlePeaking= [Index])); + } + DEBUG ((DEBUG_INFO, "\n PegGen3RootPortPreset[%d] :", SA_PEG_MAX_LANE)); + for (Index =3D 0; Index < SA_PEG_MAX_LANE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->PegGen3RootPortPrese= t[Index])); + } + DEBUG ((DEBUG_INFO, "\n PegRootPortHPE[%d] :", SA_PEG_MAX_FUN)); + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->PegRootPortHPE[Index= ])); + } + DEBUG ((DEBUG_INFO, "\n PegGen3EndPointPreset[%d] :", SA_PEG_MAX_LANE)); + for (Index =3D 0; Index < SA_PEG_MAX_LANE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->PegGen3EndPointPrese= t[Index])); + } + DEBUG ((DEBUG_INFO, "\n PegGen3EndPointHint[%d] :", SA_PEG_MAX_LANE)); + for (Index =3D 0; Index < SA_PEG_MAX_LANE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->PegGen3EndPointHint[= Index])); + } + DEBUG ((DEBUG_INFO, "\n PegGen3RxCtlePeaking[%d] :", SA_PEG_MAX_BUNDLE))= ; + for (Index =3D 0; Index < SA_PEG_MAX_BUNDLE; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiPreMemConfig->PegGen3RxCtlePeaking= [Index])); + } + DEBUG ((DEBUG_INFO, "\n PegGen3RxCtleOverride : 0x%x\n", PciePeiPreMemCo= nfig->PegGen3RxCtleOverride)); + DEBUG ((DEBUG_INFO, " DmiDeEmphasis : 0x%x\n", PciePeiPreMemConfig->DmiD= eEmphasis)); + DEBUG ((DEBUG_INFO, "\n Gen3SwEqJitterDwellTime : 0x%x\n", PciePeiPreMem= Config->Gen3SwEqJitterDwellTime)); + DEBUG ((DEBUG_INFO, " Gen3SwEqJitterErrorTarget : 0x%x\n", PciePeiPreMem= Config->Gen3SwEqJitterErrorTarget)); + DEBUG ((DEBUG_INFO, " Gen3SwEqVocDwellTime : 0x%x\n", PciePeiPreMemConfi= g->Gen3SwEqVocDwellTime)); + DEBUG ((DEBUG_INFO, " Gen3SwEqVocErrorTarget : 0x%x\n", PciePeiPreMemCon= fig->Gen3SwEqVocErrorTarget)); + DEBUG ((DEBUG_INFO, " PegDataPtr : %p\n", PciePeiPreMemConfig->PegDataPt= r)); + DEBUG ((DEBUG_INFO, " PegGpioData->GpioSupport : 0x%x\n", PciePeiPreMemC= onfig->PegGpioData.GpioSupport)); + DEBUG ((DEBUG_INFO, " PegGpioData.SaPeg0ResetGpio.GpioPad Group:%d, PadN= umber:%d\n", GpioGetGroupIndexFromGpioPad (PciePeiPreMemConfig->PegGpioData= .SaPeg0ResetGpio.GpioPad), GpioGetPadNumberFromGpioPad (PciePeiPreMemConfig= ->PegGpioData.SaPeg0ResetGpio.GpioPad))); + DEBUG ((DEBUG_INFO, " PegGpioData.SaPeg0ResetGpio.Active : 0x%x\n", Pcie= PeiPreMemConfig->PegGpioData.SaPeg0ResetGpio.Active)); + DEBUG ((DEBUG_INFO, " PegGpioData.SaPeg3ResetGpio.GpioPad Group:%d, PadN= umber:%d\n", GpioGetGroupIndexFromGpioPad (PciePeiPreMemConfig->PegGpioData= .SaPeg3ResetGpio.GpioPad), GpioGetPadNumberFromGpioPad (PciePeiPreMemConfig= ->PegGpioData.SaPeg3ResetGpio.GpioPad))); + DEBUG ((DEBUG_INFO, " PegGpioData.SaPeg3ResetGpio.Active : 0x%x\n", Pcie= PeiPreMemConfig->PegGpioData.SaPeg3ResetGpio.Active)); + + DEBUG ((DEBUG_INFO, "------------------------ VTD_CONFIG ---------------= --\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", Vtd->Header.Revision)); + ASSERT (Vtd->Header.Revision =3D=3D VTD_CONFIG_REVISION); + DEBUG ((DEBUG_INFO, " VtdDisable : 0x%x\n", Vtd->VtdDisable)); + DEBUG ((DEBUG_INFO, " X2ApicOptOut : 0x%x\n", Vtd->X2ApicOptOut)); + DEBUG ((DEBUG_INFO, " VtdBaseAddress[%d] :", SA_VTD_ENGINE_NUMBER)); + for (Index =3D 0; Index < SA_VTD_ENGINE_NUMBER; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", Vtd->BaseAddress[Index])); + } + DEBUG ((DEBUG_INFO, "\n")); + DEBUG ((DEBUG_INFO, "------------------------ SWITCHABLE_GRAPHICS_CONFIG= -----------------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", SgConfig->Header.Revision)); + ASSERT (SgConfig->Header.Revision =3D=3D SWITCHABLE_GRAPHICS_CONFIG_REVI= SION); + DEBUG ((DEBUG_INFO, " SgConfig->SaRtd3Pcie0Gpio.GpioSupport : 0x%x\n", S= gConfig->SaRtd3Pcie0Gpio.GpioSupport)); + + DEBUG ((DEBUG_INFO, "------------------------ IPU_PREMEM_CONFIG --------= ---------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", IpuPreMemPolicy->Header.Revision= )); + ASSERT (IpuPreMemPolicy->Header.Revision =3D=3D IPU_PREMEM_CONFIG_REVISI= ON); + DEBUG ((DEBUG_INFO, " SaIpuEnable : 0x%x\n", IpuPreMemPolicy->SaIpuEnabl= e)); + DEBUG ((DEBUG_INFO, " SaIpuImrConfiguration : 0x%x\n", IpuPreMemPolicy->= SaIpuImrConfiguration)); + + DEBUG ((DEBUG_INFO, "------------------------ MEMORY_CONFIG ------------= ------------------\n")); + DEBUG ((DEBUG_INFO, " Guid : %g\n", &MemConfig->Header= .GuidHob.Name)); + DEBUG ((DEBUG_INFO, " Revision : %d\n", MemConfig->Heade= r.Revision)); + ASSERT (MemConfig->Header.Revision =3D=3D MEMORY_CONFIG_REVISION); + DEBUG ((DEBUG_INFO, " Size : 0x%x\n", MemConfig->Heade= r.GuidHob.Header.HobLength)); + DEBUG ((DEBUG_INFO, " HobBufferSize : 0x%x\n", MemConfig->HobBu= fferSize)); + DEBUG ((DEBUG_INFO, " EccSupport : 0x%x\n", MemConfig->EccSu= pport)); + DEBUG ((DEBUG_INFO, " DdrFreqLimit : %d\n", MemConfig->DdrFr= eqLimit)); + DEBUG ((DEBUG_INFO, " SpdProfileSelected : 0x%x\n", MemConfig->SpdPr= ofileSelected)); + DEBUG ((DEBUG_INFO, " tCL : 0x%x\n", MemConfig->tCL))= ; + DEBUG ((DEBUG_INFO, " tRCDtRP : 0x%x\n", MemConfig->tRCDt= RP)); + DEBUG ((DEBUG_INFO, " tRAS : 0x%x\n", MemConfig->tRAS)= ); + DEBUG ((DEBUG_INFO, " tWR : 0x%x\n", MemConfig->tWR))= ; + DEBUG ((DEBUG_INFO, " tRFC : 0x%x\n", MemConfig->tRFC)= ); + DEBUG ((DEBUG_INFO, " tRRD : 0x%x\n", MemConfig->tRRD)= ); + DEBUG ((DEBUG_INFO, " tWTR : 0x%x\n", MemConfig->tWTR)= ); + DEBUG ((DEBUG_INFO, " tRTP : 0x%x\n", MemConfig->tRTP)= ); + DEBUG ((DEBUG_INFO, " tFAW : 0x%x\n", MemConfig->tFAW)= ); + DEBUG ((DEBUG_INFO, " tCWL : 0x%x\n", MemConfig->tCWL)= ); + DEBUG ((DEBUG_INFO, " tREFI : 0x%x\n", MemConfig->tREFI= )); + DEBUG ((DEBUG_INFO, " NModeSupport : 0x%x\n", MemConfig->NMode= Support)); + DEBUG ((DEBUG_INFO, " VddVoltage : %d\n", MemConfig->VddVolt= age)); + + DEBUG ((DEBUG_INFO, " DisableDimmChannel[%d] :", SA_MC_MAX_CHANNELS)); + for (Index =3D 0; Index < SA_MC_MAX_CHANNELS; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", MemConfig->DisableDimmChannel[Index])); + } + DEBUG ((DEBUG_INFO, "\n RemapEnable : 0x%x\n", MemConfig->Rem= apEnable)); + DEBUG ((DEBUG_INFO, " ScramblerSupport : 0x%x\n", MemConfig->Scram= blerSupport)); + DEBUG ((DEBUG_INFO, " SerialDebug : 0x%x\n", MemConfigNoCrc->= SerialDebugLevel)); + DEBUG ((DEBUG_INFO, " ProbelessTrace : 0x%x\n", MemConfig->Probeles= sTrace)); + DEBUG ((DEBUG_INFO, " ECT : 0x%x\n", MemConfig->ECT))= ; + DEBUG ((DEBUG_INFO, " SOT : 0x%x\n", MemConfig->SOT))= ; + DEBUG ((DEBUG_INFO, " ERDMPRTC2D : 0x%x\n", MemConfig->ERDMP= RTC2D)); + DEBUG ((DEBUG_INFO, " RDMPRT : 0x%x\n", MemConfig->RDMPR= T)); + DEBUG ((DEBUG_INFO, " RCVET : 0x%x\n", MemConfig->RCVET= )); + DEBUG ((DEBUG_INFO, " JWRL : 0x%x\n", MemConfig->JWRL)= ); + DEBUG ((DEBUG_INFO, " EWRTC2D : 0x%x\n", MemConfig->EWRTC= 2D)); + DEBUG ((DEBUG_INFO, " ERDTC2D : 0x%x\n", MemConfig->ERDTC= 2D)); + DEBUG ((DEBUG_INFO, " WRTC1D : 0x%x\n", MemConfig->WRTC1= D)); + DEBUG ((DEBUG_INFO, " WRVC1D : 0x%x\n", MemConfig->WRVC1= D)); + DEBUG ((DEBUG_INFO, " RDTC1D : 0x%x\n", MemConfig->RDTC1= D)); + DEBUG ((DEBUG_INFO, " DIMMODTT : 0x%x\n", MemConfig->DIMMO= DTT)); + DEBUG ((DEBUG_INFO, " DIMMRONT : 0x%x\n", MemConfig->DIMMR= ONT)); + DEBUG ((DEBUG_INFO, " WRDSEQT : 0x%x\n", MemConfig->WRDSE= QT)); + DEBUG ((DEBUG_INFO, " WRSRT : 0x%x\n", MemConfig->WRSRT= )); + DEBUG ((DEBUG_INFO, " RDODTT : 0x%x\n", MemConfig->RDODT= T)); + DEBUG ((DEBUG_INFO, " RDEQT : 0x%x\n", MemConfig->RDEQT= )); + DEBUG ((DEBUG_INFO, " RDAPT : 0x%x\n", MemConfig->RDAPT= )); + DEBUG ((DEBUG_INFO, " WRTC2D : 0x%x\n", MemConfig->WRTC2= D)); + DEBUG ((DEBUG_INFO, " RDTC2D : 0x%x\n", MemConfig->RDTC2= D)); + DEBUG ((DEBUG_INFO, " WRVC2D : 0x%x\n", MemConfig->WRVC2= D)); + DEBUG ((DEBUG_INFO, " RDVC2D : 0x%x\n", MemConfig->RDVC2= D)); + DEBUG ((DEBUG_INFO, " CMDVC : 0x%x\n", MemConfig->CMDVC= )); + DEBUG ((DEBUG_INFO, " LCT : 0x%x\n", MemConfig->LCT))= ; + DEBUG ((DEBUG_INFO, " RTL : 0x%x\n", MemConfig->RTL))= ; + DEBUG ((DEBUG_INFO, " TAT : 0x%x\n", MemConfig->TAT))= ; + DEBUG ((DEBUG_INFO, " RMT : 0x%x\n", MemConfig->RMT))= ; + DEBUG ((DEBUG_INFO, " MEMTST : 0x%x\n", MemConfig->MEMTS= T)); + DEBUG ((DEBUG_INFO, " ALIASCHK : 0x%x\n", MemConfig->ALIAS= CHK)); + DEBUG ((DEBUG_INFO, " RCVENC1D : 0x%x\n", MemConfig->RCVEN= C1D)); + DEBUG ((DEBUG_INFO, " RMC : 0x%x\n", MemConfig->RMC))= ; + DEBUG ((DEBUG_INFO, " WRDSUDT : 0x%x\n", MemConfig->WRDSU= DT)); + + DEBUG ((DEBUG_INFO, " VddSettleWaitTime : 0x%x\n", MemConfig->VddSe= ttleWaitTime)); + DEBUG ((DEBUG_INFO, " RefClk : 0x%x\n", MemConfig->RefCl= k)); + DEBUG ((DEBUG_INFO, " Ratio : 0x%x\n", MemConfig->Ratio= )); + DEBUG ((DEBUG_INFO, " OddRatioMode : 0x%x\n", MemConfig->OddRa= tioMode)); + DEBUG ((DEBUG_INFO, " MrcTimeMeasure : 0x%x\n", MemConfig->MrcTi= meMeasure)); + DEBUG ((DEBUG_INFO, " MrcFastBoot : 0x%x\n", MemConfig->MrcFa= stBoot)); + DEBUG ((DEBUG_INFO, " DqPinsInterleaved : 0x%x\n", MemConfig->DqPin= sInterleaved)); + DEBUG ((DEBUG_INFO, " MrcSafeConfig : 0x%x\n", MemConfig->MrcSa= feConfig)); + DEBUG ((DEBUG_INFO, " SafeMode : 0x%x\n", MemConfig->SafeM= ode)); + DEBUG ((DEBUG_INFO, " Lp4DqsOscEn : 0x%x\n", MemConfig->Lp4Dq= sOscEn)); + DEBUG ((DEBUG_INFO, " EnBER : 0x%x\n", MemConfig->EnBER= )); + DEBUG ((DEBUG_INFO, " Ddr4MixedUDimm2DpcLimit: 0x%x\n", MemConfig->Ddr4M= ixedUDimm2DpcLimit)); + DEBUG ((DEBUG_INFO, " PowerDownMode : 0x%x\n", MemConfig->Power= DownMode)); + DEBUG ((DEBUG_INFO, " PwdwnIdleCounter : 0x%x\n", MemConfig->Pwdwn= IdleCounter)); + DEBUG ((DEBUG_INFO, " RankInterleave : 0x%x\n", MemConfig->RankI= nterleave)); + DEBUG ((DEBUG_INFO, " EnhancedInterleave : 0x%x\n", MemConfig->Enhan= cedInterleave)); + DEBUG ((DEBUG_INFO, " WeaklockEn : 0x%x\n", MemConfig->Weakl= ockEn)); + DEBUG ((DEBUG_INFO, " EnCmdRate : 0x%x\n", MemConfig->EnCmd= Rate)); + DEBUG ((DEBUG_INFO, " CmdTriStateDis : 0x%x\n", MemConfig->CmdTr= iStateDis)); + DEBUG ((DEBUG_INFO, " BClkFrequency : 0x%x\n", MemConfig->BClkF= requency)); + DEBUG ((DEBUG_INFO, " MemoryTrace : 0x%x\n", MemConfig->Memor= yTrace)); + DEBUG ((DEBUG_INFO, " ChHashEnable : 0x%x\n", MemConfig->ChHas= hEnable)); + DEBUG ((DEBUG_INFO, " ChHashMask : 0x%x\n", MemConfig->ChHas= hMask)); + DEBUG ((DEBUG_INFO, " ChHashInterleaveBit : 0x%x\n", MemConfig->ChHas= hInterleaveBit)); + DEBUG ((DEBUG_INFO, " PerBankRefresh : 0x%x\n", MemConfig->PerBa= nkRefresh)); + DEBUG ((DEBUG_INFO, " EnableExtts : 0x%x\n", MemConfig->Enabl= eExtts)); + DEBUG ((DEBUG_INFO, " EnableCltm : 0x%x\n", MemConfig->Enabl= eCltm)); + DEBUG ((DEBUG_INFO, " EnableOltm : 0x%x\n", MemConfig->Enabl= eOltm)); + DEBUG ((DEBUG_INFO, " EnablePwrDn : 0x%x\n", MemConfig->Enabl= ePwrDn)); + DEBUG ((DEBUG_INFO, " EnablePwrDnLpddr : 0x%x\n", MemConfig->Enabl= ePwrDnLpddr)); + DEBUG ((DEBUG_INFO, " Refresh2X : 0x%x\n", MemConfig->Refre= sh2X)); + DEBUG ((DEBUG_INFO, " DdrThermalSensor : 0x%x\n", MemConfig->DdrTh= ermalSensor)); + DEBUG ((DEBUG_INFO, " LockPTMregs : 0x%x\n", MemConfig->LockP= TMregs)); + DEBUG ((DEBUG_INFO, " UserPowerWeightsEn : 0x%x\n", MemConfig->UserP= owerWeightsEn)); + DEBUG ((DEBUG_INFO, " EnergyScaleFact : 0x%x\n", MemConfig->Energ= yScaleFact)); + DEBUG ((DEBUG_INFO, " RaplPwrFlCh1 : 0x%x\n", MemConfig->RaplP= wrFlCh1)); + DEBUG ((DEBUG_INFO, " RaplPwrFlCh0 : 0x%x\n", MemConfig->RaplP= wrFlCh0)); + DEBUG ((DEBUG_INFO, " RaplLim2Lock : 0x%x\n", MemConfig->RaplL= im2Lock)); + DEBUG ((DEBUG_INFO, " RaplLim2WindX : 0x%x\n", MemConfig->RaplL= im2WindX)); + DEBUG ((DEBUG_INFO, " RaplLim2WindY : 0x%x\n", MemConfig->RaplL= im2WindY)); + DEBUG ((DEBUG_INFO, " RaplLim2Ena : 0x%x\n", MemConfig->RaplL= im2Ena)); + DEBUG ((DEBUG_INFO, " RaplLim2Pwr : 0x%x\n", MemConfig->RaplL= im2Pwr)); + DEBUG ((DEBUG_INFO, " RaplLim1WindX : 0x%x\n", MemConfig->RaplL= im1WindX)); + DEBUG ((DEBUG_INFO, " RaplLim1WindY : 0x%x\n", MemConfig->RaplL= im1WindY)); + DEBUG ((DEBUG_INFO, " RaplLim1Ena : 0x%x\n", MemConfig->RaplL= im1Ena)); + DEBUG ((DEBUG_INFO, " RaplLim1Pwr : 0x%x\n", MemConfig->RaplL= im1Pwr)); + DEBUG ((DEBUG_INFO, " WarmThresholdCh0Dimm0 : 0x%x\n", MemConfig->WarmT= hresholdCh0Dimm0)); + DEBUG ((DEBUG_INFO, " WarmThresholdCh0Dimm1 : 0x%x\n", MemConfig->WarmT= hresholdCh0Dimm1)); + DEBUG ((DEBUG_INFO, " WarmThresholdCh1Dimm0 : 0x%x\n", MemConfig->WarmT= hresholdCh1Dimm0)); + DEBUG ((DEBUG_INFO, " WarmThresholdCh1Dimm1 : 0x%x\n", MemConfig->WarmT= hresholdCh1Dimm1)); + DEBUG ((DEBUG_INFO, " HotThresholdCh0Dimm0 : 0x%x\n", MemConfig->HotTh= resholdCh0Dimm0)); + DEBUG ((DEBUG_INFO, " HotThresholdCh0Dimm1 : 0x%x\n", MemConfig->HotTh= resholdCh0Dimm1)); + DEBUG ((DEBUG_INFO, " HotThresholdCh1Dimm0 : 0x%x\n", MemConfig->HotTh= resholdCh1Dimm0)); + DEBUG ((DEBUG_INFO, " HotThresholdCh1Dimm1 : 0x%x\n", MemConfig->HotTh= resholdCh1Dimm1)); + DEBUG ((DEBUG_INFO, " WarmBudgetCh0Dimm0 : 0x%x\n", MemConfig->WarmB= udgetCh0Dimm0)); + DEBUG ((DEBUG_INFO, " WarmBudgetCh0Dimm1 : 0x%x\n", MemConfig->WarmB= udgetCh0Dimm1)); + DEBUG ((DEBUG_INFO, " WarmBudgetCh1Dimm0 : 0x%x\n", MemConfig->WarmB= udgetCh1Dimm0)); + DEBUG ((DEBUG_INFO, " WarmBudgetCh1Dimm1 : 0x%x\n", MemConfig->WarmB= udgetCh1Dimm1)); + DEBUG ((DEBUG_INFO, " HotBudgetCh0Dimm0 : 0x%x\n", MemConfig->HotBu= dgetCh0Dimm0)); + DEBUG ((DEBUG_INFO, " HotBudgetCh0Dimm1 : 0x%x\n", MemConfig->HotBu= dgetCh0Dimm1)); + DEBUG ((DEBUG_INFO, " HotBudgetCh1Dimm0 : 0x%x\n", MemConfig->HotBu= dgetCh1Dimm0)); + DEBUG ((DEBUG_INFO, " HotBudgetCh1Dimm1 : 0x%x\n", MemConfig->HotBu= dgetCh1Dimm1)); + DEBUG ((DEBUG_INFO, " IdleEnergyCh0Dimm0 : 0x%x\n", MemConfig->IdleE= nergyCh0Dimm0)); + DEBUG ((DEBUG_INFO, " IdleEnergyCh0Dimm1 : 0x%x\n", MemConfig->IdleE= nergyCh0Dimm1)); + DEBUG ((DEBUG_INFO, " IdleEnergyCh1Dimm0 : 0x%x\n", MemConfig->IdleE= nergyCh1Dimm0)); + DEBUG ((DEBUG_INFO, " IdleEnergyCh1Dimm1 : 0x%x\n", MemConfig->IdleE= nergyCh1Dimm1)); + DEBUG ((DEBUG_INFO, " PdEnergyCh0Dimm0 : 0x%x\n", MemConfig->PdEne= rgyCh0Dimm0)); + DEBUG ((DEBUG_INFO, " PdEnergyCh0Dimm1 : 0x%x\n", MemConfig->PdEne= rgyCh0Dimm1)); + DEBUG ((DEBUG_INFO, " PdEnergyCh1Dimm0 : 0x%x\n", MemConfig->PdEne= rgyCh1Dimm0)); + DEBUG ((DEBUG_INFO, " PdEnergyCh1Dimm1 : 0x%x\n", MemConfig->PdEne= rgyCh1Dimm1)); + DEBUG ((DEBUG_INFO, " ActEnergyCh0Dimm0 : 0x%x\n", MemConfig->ActEn= ergyCh0Dimm0)); + DEBUG ((DEBUG_INFO, " ActEnergyCh0Dimm1 : 0x%x\n", MemConfig->ActEn= ergyCh0Dimm1)); + DEBUG ((DEBUG_INFO, " ActEnergyCh1Dimm0 : 0x%x\n", MemConfig->ActEn= ergyCh1Dimm0)); + DEBUG ((DEBUG_INFO, " ActEnergyCh1Dimm1 : 0x%x\n", MemConfig->ActEn= ergyCh1Dimm1)); + DEBUG ((DEBUG_INFO, " RdEnergyCh0Dimm0 : 0x%x\n", MemConfig->RdEne= rgyCh0Dimm0)); + DEBUG ((DEBUG_INFO, " RdEnergyCh0Dimm1 : 0x%x\n", MemConfig->RdEne= rgyCh0Dimm1)); + DEBUG ((DEBUG_INFO, " RdEnergyCh1Dimm0 : 0x%x\n", MemConfig->RdEne= rgyCh1Dimm0)); + DEBUG ((DEBUG_INFO, " RdEnergyCh1Dimm1 : 0x%x\n", MemConfig->RdEne= rgyCh1Dimm1)); + DEBUG ((DEBUG_INFO, " WrEnergyCh0Dimm0 : 0x%x\n", MemConfig->WrEne= rgyCh0Dimm0)); + DEBUG ((DEBUG_INFO, " WrEnergyCh0Dimm1 : 0x%x\n", MemConfig->WrEne= rgyCh0Dimm1)); + DEBUG ((DEBUG_INFO, " WrEnergyCh1Dimm0 : 0x%x\n", MemConfig->WrEne= rgyCh1Dimm0)); + DEBUG ((DEBUG_INFO, " WrEnergyCh1Dimm1 : 0x%x\n", MemConfig->WrEne= rgyCh1Dimm1)); + DEBUG ((DEBUG_INFO, " SrefCfgEna : 0x%x\n", MemConfig->SrefC= fgEna)); + DEBUG ((DEBUG_INFO, " SrefCfgIdleTmr : 0x%x\n", MemConfig->SrefC= fgIdleTmr)); + DEBUG ((DEBUG_INFO, " ThrtCkeMinDefeat : 0x%x\n", MemConfig->ThrtC= keMinDefeat)); + DEBUG ((DEBUG_INFO, " ThrtCkeMinTmr : 0x%x\n", MemConfig->ThrtC= keMinTmr)); + DEBUG ((DEBUG_INFO, " ThrtCkeMinDefeatLpddr : 0x%x\n", MemConfig->ThrtC= keMinDefeatLpddr)); + DEBUG ((DEBUG_INFO, " ThrtCkeMinTmrLpddr : 0x%x\n", MemConfig->ThrtC= keMinTmrLpddr)); + DEBUG ((DEBUG_INFO, " AutoSelfRefreshSupport : 0x%x\n", MemConfig->AutoS= elfRefreshSupport)); + DEBUG ((DEBUG_INFO, " ExtTemperatureSupport : 0x%x\n", MemConfig->ExtTe= mperatureSupport)); + DEBUG ((DEBUG_INFO, " MaxRttWr : 0x%x\n", MemConfig->MaxRt= tWr)); + DEBUG ((DEBUG_INFO, " MobilePlatform : 0x%x\n", MemConfig->Mobil= ePlatform)); + DEBUG ((DEBUG_INFO, " Force1Dpc : 0x%x\n", MemConfig->Force= 1Dpc)); + + + DEBUG ((DEBUG_INFO, " ForceSingleRank : 0x%x\n", MemConfig->Force= SingleRank)); + DEBUG ((DEBUG_INFO, " PciIndex : 0x%x\n", MemConfig->PciIn= dex)); + DEBUG ((DEBUG_INFO, " PciData : 0x%x\n", MemConfig->PciDa= ta)); + DEBUG ((DEBUG_INFO, " CkeRankMapping : 0x%x\n", MemConfig->CkeRa= nkMapping)); + DEBUG ((DEBUG_INFO, " RhPrevention : 0x%x\n", MemConfig->RhPre= vention)); + DEBUG ((DEBUG_INFO, " RhSolution : 0x%x\n", MemConfig->RhSol= ution)); + DEBUG ((DEBUG_INFO, " RhActProbability : 0x%x\n", MemConfig->RhAct= Probability)); + DEBUG ((DEBUG_INFO, " VttTermination : 0x%x\n", MemConfig->VttTe= rmination)); + DEBUG ((DEBUG_INFO, " VttCompForVsshi : 0x%x\n", MemConfig->VttCo= mpForVsshi)); + DEBUG ((DEBUG_INFO, " BerEnable : 0x%x\n", MemConfig->BerEn= able)); + for (Index =3D 0; Index < 4; Index++) { + DEBUG ((DEBUG_INFO, " BerAddress[%d] : 0x%x\n",Index , MemConfig-= >BerAddress[Index])); + } + DEBUG ((DEBUG_INFO, " CleanMemory : 0x%x\n", MemConfigNoCrc->= CleanMemory)); + DEBUG ((DEBUG_INFO, " MemTestOnWarmBoot : 0x%x\n", MemConfigNoCrc->= MemTestOnWarmBoot)); + DEBUG ((DEBUG_INFO, " ExitOnFailure : 0x%x\n", MemConfig->ExitO= nFailure)); + DEBUG ((DEBUG_INFO, " Vc1ReadMeter : 0x%x\n", MemConfig->Vc1Re= adMeter)); + DEBUG ((DEBUG_INFO, " SaGv : 0x%x\n", MemConfig->SaGv)= ); + DEBUG ((DEBUG_INFO, " FreqSaGvLow : 0x%x\n FreqSaGvMid = : 0x%x\n", + MemConfig->FreqSaGvLow, MemConfig->FreqSaGvMid)); + DEBUG ((DEBUG_INFO, " StrongWkLeaker : 0x%x\n", MemConfig->Stron= gWkLeaker)); + DEBUG ((DEBUG_INFO, " CaVrefConfig : 0x%x\n", MemConfig->CaVre= fConfig)); + DEBUG ((DEBUG_INFO, " SimicsFlag : 0x%x\n", MemConfig->Simic= sFlag)); + DEBUG ((DEBUG_INFO, " PlatformMemorySize : 0x%x\n", MemConfigNoCrc->= PlatformMemorySize)); + DEBUG ((DEBUG_INFO, " SmramMask : 0x%x\n", MemConfig->Smram= Mask)); + DEBUG ((DEBUG_INFO, " DllBwEn0: %d\n DllBwEn1: %d\n DllBwEn2: %d\n DllBw= En3: %d\n", + MemConfig->DllBwEn0, MemConfig->DllBwEn1, MemConfig->DllBwEn2, M= emConfig->DllBwEn3)); + DEBUG ((DEBUG_INFO, " RetrainOnFastFail: %d\n ForceOltmOrRefresh2x: %d\n= ", + MemConfig->RetrainOnFastFail, MemConfig->ForceOltmOrRefresh2x)); + DEBUG ((DEBUG_INFO, " RmtPerTask: %u\n TrainTrace: %u\n", MemConfig->Rmt= PerTask, MemConfig->TrainTrace)); + DEBUG ((DEBUG_INFO, " tRd2RdSG : 0x%x\n tRd2RdDG = : 0x%x\n", MemConfig->tRd2RdSG, MemConfig->tRd2RdDG)); + DEBUG ((DEBUG_INFO, " tRd2RdDR : 0x%x\n tRd2RdDD = : 0x%x\n", MemConfig->tRd2RdDR, MemConfig->tRd2RdDD)); + DEBUG ((DEBUG_INFO, " tRd2WrSG : 0x%x\n tRd2WrDG = : 0x%x\n", MemConfig->tRd2WrSG, MemConfig->tRd2WrDG)); + DEBUG ((DEBUG_INFO, " tRd2WrDR : 0x%x\n tRd2WrDD = : 0x%x\n", MemConfig->tRd2WrDR, MemConfig->tRd2WrDD)); + DEBUG ((DEBUG_INFO, " tWr2RdSG : 0x%x\n tWr2RdDG = : 0x%x\n", MemConfig->tWr2RdSG, MemConfig->tWr2RdDG)); + DEBUG ((DEBUG_INFO, " tWr2RdDR : 0x%x\n tWr2RdDD = : 0x%x\n", MemConfig->tWr2RdDR, MemConfig->tWr2RdDD)); + DEBUG ((DEBUG_INFO, " tWr2WrSG : 0x%x\n tWr2WrDG = : 0x%x\n", MemConfig->tWr2WrSG, MemConfig->tWr2WrDG)); + DEBUG ((DEBUG_INFO, " tWr2WrDR : 0x%x\n tWr2WrDD = : 0x%x\n", MemConfig->tWr2WrDR, MemConfig->tWr2WrDD)); + DEBUG ((DEBUG_INFO, "------------------------ OVERCLOCKING_CONFIG ------= -----------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", OcPreMemConfig->Header.Revision)= ); + ASSERT (OcPreMemConfig->Header.Revision =3D=3D SA_OVERCLOCKING_CONFIG_RE= VISION); + DEBUG ((DEBUG_INFO, " OcSupport : 0x%x\n", OcPreMemConfig->OcSupport)); + DEBUG ((DEBUG_INFO, " GtMaxOcRatio : 0x%x\n", OcPreMemConfig->GtMaxOcRat= io)); + DEBUG ((DEBUG_INFO, " GtVoltageMode : 0x%x\n", OcPreMemConfig->GtVoltage= Mode)); + DEBUG ((DEBUG_INFO, " GtVoltageOffset : 0x%x\n", OcPreMemConfig->GtVolta= geOffset)); + DEBUG ((DEBUG_INFO, " GtVoltageOverride : 0x%x\n", OcPreMemConfig->GtVol= tageOverride)); + DEBUG ((DEBUG_INFO, " GtExtraTurboVoltage : 0x%x\n", OcPreMemConfig->GtE= xtraTurboVoltage)); + DEBUG ((DEBUG_INFO, " SaVoltageOffset : 0x%x\n", OcPreMemConfig->SaVolta= geOffset)); + DEBUG ((DEBUG_INFO, " GtusMaxOcRatio : 0x%x\n", OcPreMemConfig->GtusMaxO= cRatio)); + DEBUG ((DEBUG_INFO, " GtusVoltageMode : 0x%x\n", OcPreMemConfig->GtusVol= tageMode)); + DEBUG ((DEBUG_INFO, " GtusVoltageOffset : 0x%x\n", OcPreMemConfig->GtusV= oltageOffset)); + DEBUG ((DEBUG_INFO, " GtusVoltageOverride : 0x%x\n", OcPreMemConfig->Gtu= sVoltageOverride)); + DEBUG ((DEBUG_INFO, " GtusExtraTurboVoltage : 0x%x\n", OcPreMemConfig->G= tusExtraTurboVoltage)); + for (Index =3D 0; Index < SA_MC_MAX_CHANNELS; Index++) { + DEBUG ((DEBUG_INFO, " DqByteMapCh%d : ", Index)); + for (Index2 =3D 0; Index2 < SA_MRC_ITERATION_MAX; Index2++) { + DEBUG ((DEBUG_INFO, "0x%02x ", MemConfigNoCrc->DqByteMap->DqByteMap[= Index][Index2][0])); + DEBUG ((DEBUG_INFO, "0x%02x ", MemConfigNoCrc->DqByteMap->DqByteMap[= Index][Index2][1])); + } + DEBUG ((DEBUG_INFO, "\n")); + } + for (Index =3D 0; Index < SA_MC_MAX_CHANNELS; Index++) { + DEBUG ((DEBUG_INFO, " DqsMapCpu2DramCh%d : ", Index)); + for (Index2 =3D 0; Index2 < SA_MC_MAX_BYTES_NO_ECC; Index2++) { + DEBUG ((DEBUG_INFO, "%d ", MemConfigNoCrc->DqsMap->DqsMapCpu2Dram[In= dex][Index2])); + } + DEBUG ((DEBUG_INFO, "\n")); + } + DEBUG ((DEBUG_INFO, "\n------------------------ SA Policy (PEI PreMem) P= rint END -----------------\n")); + DEBUG_CODE_END (); + return; +} + +/** + This function prints the PEI phase policy. + + @param[in] SiPolicyPpi - Instance of SI_POLICY_PPI +**/ +VOID +EFIAPI +SaPrintPolicyPpi ( + IN SI_POLICY_PPI *SiPolicyPpi + ) +{ + DEBUG_CODE_BEGIN (); + INTN Index; + EFI_STATUS Status; + GRAPHICS_PEI_CONFIG *GtConfig; + PCIE_PEI_CONFIG *PciePeiConfig; + SA_MISC_PEI_CONFIG *MiscPeiConfig; + // + // Get requisite IP Config Blocks which needs to be used here + // + Status =3D GetConfigBlock ((VOID *) SiPolicyPpi, &gGraphicsPeiConfigGuid= , (VOID *) &GtConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SiPolicyPpi, &gSaPciePeiConfigGuid, = (VOID *) &PciePeiConfig); + ASSERT_EFI_ERROR (Status); + + Status =3D GetConfigBlock ((VOID *) SiPolicyPpi, &gSaMiscPeiConfigGuid, = (VOID *) &MiscPeiConfig); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INFO, "\n------------------------ SA Policy (PEI) Print BE= GIN -----------------\n")); + DEBUG ((DEBUG_INFO, "Revision : 0x%x\n", SiPolicyPpi->TableHeader.Header= .Revision)); + ASSERT (SiPolicyPpi->TableHeader.Header.Revision =3D=3D SI_POLICY_REVISI= ON); + + DEBUG ((DEBUG_INFO, "------------------------ SA_MISC_PEI_CONFIG ------= -----------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", MiscPeiConfig->Header.Revision))= ; + ASSERT (MiscPeiConfig->Header.Revision =3D=3D SA_MISC_PEI_CONFIG_REVISIO= N); + DEBUG ((DEBUG_INFO, " ChapDeviceEnable : 0x%x\n", MiscPeiConfig->ChapDev= iceEnable)); + DEBUG ((DEBUG_INFO, " Device4Enable : 0x%x\n", MiscPeiConfig->Device4Ena= ble)); + DEBUG ((DEBUG_INFO, " CridEnable : 0x%x\n", MiscPeiConfig->CridEnable)); + DEBUG ((DEBUG_INFO, " SkipPamLock : 0x%x\n", MiscPeiConfig->SkipPamLock)= ); + DEBUG ((DEBUG_INFO, " EdramTestMode : 0x%x\n", MiscPeiConfig->EdramTestM= ode)); + + DEBUG ((DEBUG_INFO, "------------------------ GRAPHICS_PEI_CONFIG ------= -----------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", GtConfig->Header.Revision)); + ASSERT (GtConfig->Header.Revision =3D=3D GRAPHICS_PEI_CONFIG_REVISION); + DEBUG ((DEBUG_INFO, " RenderStandby : 0x%x\n", GtConfig->RenderStandby))= ; + DEBUG ((DEBUG_INFO, " PmSupport : 0x%x\n", GtConfig->PmSupport)); + DEBUG ((DEBUG_INFO, " PavpEnable : 0x%x\n", GtConfig->PavpEnable)); + DEBUG ((DEBUG_INFO, " CdClock : 0x%x\n", GtConfig->CdClock)); + DEBUG ((DEBUG_INFO, " PeiGraphicsPeimInit : 0x%x\n", GtConfig->PeiGraphi= csPeimInit)); + DEBUG ((DEBUG_INFO, " LogoPtr : 0x%x\n", GtConfig->LogoPtr)); + DEBUG ((DEBUG_INFO, " LogoSize : 0x%x\n", GtConfig->LogoSize)); + DEBUG ((DEBUG_INFO, " BltBufferAddress : 0x%x\n", GtConfig->BltBufferAdd= ress)); + DEBUG ((DEBUG_INFO, " BltBufferSize : 0x%x\n", GtConfig->BltBufferSize))= ; + DEBUG ((DEBUG_INFO, " GraphicsConfigPtr : 0x%x\n", GtConfig->GraphicsCon= figPtr)); + DEBUG ((DEBUG_INFO, " CdynmaxClampEnable : 0x%x\n", GtConfig->CdynmaxCla= mpEnable)); + DEBUG ((DEBUG_INFO, " GtFreqMax : 0x%x\n", GtConfig->GtFreqMax)); + DEBUG ((DEBUG_INFO, " DisableTurboGt : 0x%x\n", GtConfig->DisableTurboGt= )); + DEBUG ((DEBUG_INFO, " DdiPortEdp : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortEdp)); + DEBUG ((DEBUG_INFO, " DdiPortBHpd : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortBHpd)); + DEBUG ((DEBUG_INFO, " DdiPortCHpd : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortCHpd)); + DEBUG ((DEBUG_INFO, " DdiPortDHpd : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortDHpd)); + DEBUG ((DEBUG_INFO, " DdiPortFHpd : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortFHpd)); + DEBUG ((DEBUG_INFO, " DdiPortBDdc : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortBDdc)); + DEBUG ((DEBUG_INFO, " DdiPortCDdc : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortCDdc)); + DEBUG ((DEBUG_INFO, " DdiPortDDdc : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortDDdc)); + DEBUG ((DEBUG_INFO, " DdiPortFDdc : 0x%x\n", GtConfig->DdiConfiguration.= DdiPortFDdc)); + DEBUG ((DEBUG_INFO, " SkipS3CdClockInit : 0x%x\n", GtConfig->SkipS3CdClo= ckInit)); + + DEBUG ((DEBUG_INFO, "------------------------ PCIE_PEI_CONFIG ----------= -------\n")); + DEBUG ((DEBUG_INFO, " Revision : %d\n", PciePeiConfig->Header.Revision))= ; + ASSERT (PciePeiConfig->Header.Revision =3D=3D SA_PCIE_PEI_CONFIG_REVISIO= N); + DEBUG ((DEBUG_INFO, " DmiExtSync : 0x%x\n", PciePeiConfig->DmiExtSync)); + DEBUG ((DEBUG_INFO, " DmiIot : 0x%x\n", PciePeiConfig->DmiIot)); + DEBUG ((DEBUG_INFO, " DmiAspm : 0x%x\n", PciePeiConfig->DmiAspm)); + DEBUG ((DEBUG_INFO, "\n PegSlotPowerLimitValue[%d] :", SA_PEG_MAX_FUN)); + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiConfig->PegSlotPowerLimitValue[Ind= ex])); + } + DEBUG ((DEBUG_INFO, "\n PegSlotPowerLimitScale[%d] :", SA_PEG_MAX_FUN)); + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiConfig->PegSlotPowerLimitScale[Ind= ex])); + } + DEBUG ((DEBUG_INFO, "\n PegPhysicalSlotNumber[%d] :", SA_PEG_MAX_FUN)); + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiConfig->PegPhysicalSlotNumber[Inde= x])); + } + DEBUG ((DEBUG_INFO, "\n PegDeEmphasis[%d] :", SA_PEG_MAX_FUN)); + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiConfig->PegDeEmphasis[Index])); + } + DEBUG ((DEBUG_INFO, "\n PegMaxPayload[%d] :", SA_PEG_MAX_FUN)); + for (Index =3D 0; Index < SA_PEG_MAX_FUN; Index++) { + DEBUG ((DEBUG_INFO, " 0x%x", PciePeiConfig->PegMaxPayload[Index])); + } + DEBUG ((DEBUG_INFO, "\n")); + + DEBUG ((DEBUG_INFO, "\n------------------------ SA Policy (PEI) Print EN= D -----------------\n")); + DEBUG_CODE_END (); + return; +} diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/Ia32/MrcOemPlatform.S b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAg= ent/Library/PeiSaPolicyLib/Ia32/MrcOemPlatform.S new file mode 100644 index 0000000000..97b58c460f --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /Ia32/MrcOemPlatform.S @@ -0,0 +1,114 @@ +## @file +// +# Copyright (c) 2019 Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +//------------------------------------------------------------------------= ----- +// +// Section: SaMmioRead64 +// +// Description: Read 64 bits from the Memory Mapped I/O space. +// Use MMX instruction for atomic access, because some MC registers have = side effect. +// +// @param[in] Address - Memory mapped I/O address. +// +//------------------------------------------------------------------------= ----- +//UINT64 +//SaMmioRead64 ( +// IN UINTN Address +// ) + +ASM_GLOBAL ASM_PFX(SaMmioRead64) +ASM_PFX(SaMmioRead64): + subl $16, %esp + movq %mm0, (%esp) //Save mm0 on stack + movl 20(%esp), %edx //edx =3D Address + movq (%edx), %mm0 //mm0 =3D [Address] + movq %mm0, 8(%esp) //Store mm0 on Stack + movq (%esp), %mm0 //Restore mm0 + emms + movl 8(%esp), %eax //eax =3D [Address][31:0] + movl 12(%esp), %edx //edx =3D [Address][64:32] + addl $16, %esp + ret + +//------------------------------------------------------------------------= ----- +// +// Section: SaMmioWrite64 +// +// Description: Write 64 bits to the Memory Mapped I/O space. +// Use MMX instruction for atomic access, because some MC registers have = side effect. +// +// @param[in] Address - Memory mapped I/O address. +// @param[in] Value - The value to write. +// +//------------------------------------------------------------------------= ----- + +//UINT64 +//SaMmioWrite64 ( +// IN UINTN Address, +// IN UINT64 Value +// ) + +ASM_GLOBAL ASM_PFX(SaMmioWrite64) +ASM_PFX(SaMmioWrite64): + subl $8, %esp + movq %mm0, (%esp) //Save mm0 on Stack + movl 12(%esp), %edx //edx =3D Address + movq 16(%esp), %mm0 //mm0 =3D Value + movq %mm0, (%edx) //[Address] =3D Value + movq (%esp), %mm0 //Restore mm0 + emms + movl 16(%esp), %eax //eax =3D Value[31:0] + movl 20(%esp), %edx //edx =3D Value[64:32] + addl $8, %esp + ret + +//------------------------------------------------------------------------= ----- +// Intel Silicon View Technology check point interface based on IO port r= eading +// +// @param CheckPoint Check point AH value. +// AH =3D 0x10: End of MRC State +// AH =3D 0x20: End of DXE State +// AH =3D 0x30: Ready to boot before INT-19h or= UEFI boot +// AH =3D 0x40: After OS booting, need a timer = SMI trigger to implement (TBD); +// +// @param PortReading IO port reading address used for breakpoints +//------------------------------------------------------------------------= ----- + +//VOID +//EFIAPI +//IsvtCheckPoint ( +// IN UINT32 CheckPoint, +// IN UINT32 PortReading +// ) + +ASM_GLOBAL ASM_PFX(IsvtCheckPoint) +ASM_PFX(IsvtCheckPoint): + pushl %eax + pushl %edx + + // Stack layout at this point: + //------------- + // PortReading ESP + 16 + //------------- + // CheckPoint ESP + 12 + //------------- + // EIP ESP + 8 + //------------- + // EAX ESP + 4 + //------------- + // EDX <-- ESP + //------------- + + mov 12(%esp), %ah // CheckPoint + mov 16(%esp), %dx // PortReading + in %dx, %al // signal debugger + + popl %edx + popl %eax + ret + diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/Ia32/MrcOemPlatform.asm b/Silicon/Intel/CoffeelakeSiliconPkg/System= Agent/Library/PeiSaPolicyLib/Ia32/MrcOemPlatform.asm new file mode 100644 index 0000000000..288fe7a2fe --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /Ia32/MrcOemPlatform.asm @@ -0,0 +1,126 @@ +; @file +; This file provides assembly 64-bit atomic reads/writes required for mem= ory initialization. +; +; Copyright (c) 2019 Intel Corporation. All rights reserved.
+; +; SPDX-License-Identifier: BSD-2-Clause-Patent +; + +.686p +.xmm +.model small, c + +.CODE + +;-------------------------------------------------------------------------= ---- +; +; Section: SaMmioRead64 +; +; Description: Read 64 bits from the Memory Mapped I/O space. +; Use MMX instruction for atomic access, because some MC registers have s= ide effect. +; +; @param[in] Address - Memory mapped I/O address. +; +;-------------------------------------------------------------------------= ---- + +;UINT64 +;SaMmioRead64 ( +; IN UINTN Address +; ) + +SaMmioRead64 PROC NEAR PUBLIC + sub esp, 16 + movq [esp], mm0 ;Save mm0 on stack + mov edx, [esp + 20] ;edx =3D Address + movq mm0, [edx] ;mm0 =3D [Address] + movq [esp + 8], mm0 ;Store mm0 on Stack + movq mm0, [esp] ;Restore mm0 + emms + mov eax, [esp + 8] ;eax =3D [Address][31:0] + mov edx, [esp + 12] ;edx =3D [Address][64:32] + add esp, 16 + ret +SaMmioRead64 ENDP + +;-------------------------------------------------------------------------= ---- +; +; Section: SaMmioWrite64 +; +; Description: Write 64 bits to the Memory Mapped I/O space. +; Use MMX instruction for atomic access, because some MC registers have s= ide effect. +; +; @param[in] Address - Memory mapped I/O address. +; @param[in] Value - The value to write. +; +;-------------------------------------------------------------------------= ---- + +;UINT64 +;SaMmioWrite64 ( +; IN UINTN Address, +; IN UINT64 Value +; ) + +SaMmioWrite64 PROC NEAR PUBLIC + sub esp, 8 + movq [esp], mm0 ;Save mm0 on Stack + mov edx, [esp + 12] ;edx =3D Address + movq mm0, [esp + 16] ;mm0 =3D Value + movq [edx], mm0 ;[Address] =3D Value + movq mm0, [esp] ;Restore mm0 + emms + mov eax, [esp + 16] ;eax =3D Value[31:0] + mov edx, [esp + 20] ;edx =3D Value[64:32] + add esp, 8 + ret +SaMmioWrite64 ENDP + + +;-------------------------------------------------------------------------= ---- +; Intel Silicon View Technology check point interface based on IO port re= ading +; +; @param CheckPoint Check point AH value. +; AH =3D 0x10: End of MRC State +; AH =3D 0x20: End of DXE State +; AH =3D 0x30: Ready to boot before INT-19h or = UEFI boot +; AH =3D 0x40: After OS booting, need a timer S= MI trigger to implement (TBD); +; +; @param PortReading IO port reading address used for breakpoints +;-------------------------------------------------------------------------= ---- + +;VOID +;EFIAPI +;IsvtCheckPoint ( +; IN UINT32 CheckPoint, +; IN UINT32 PortReading +; ) + +IsvtCheckPoint PROC NEAR PUBLIC + push eax + push edx + + ; Stack layout at this point: + ;------------- + ; PortReading ESP + 16 + ;------------- + ; CheckPoint ESP + 12 + ;------------- + ; EIP ESP + 8 + ;------------- + ; EAX ESP + 4 + ;------------- + ; EDX <-- ESP + ;------------- + + mov ah, BYTE PTR [esp + 12] ; CheckPoint + mov dx, WORD PTR [esp + 16] ; PortReading + in al, dx ; signal debugger + + pop edx + pop eax + ret +IsvtCheckPoint ENDP + + +end + + diff --git a/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPo= licyLib/Ia32/MrcOemPlatform.nasm b/Silicon/Intel/CoffeelakeSiliconPkg/Syste= mAgent/Library/PeiSaPolicyLib/Ia32/MrcOemPlatform.nasm new file mode 100644 index 0000000000..da7ef004ad --- /dev/null +++ b/Silicon/Intel/CoffeelakeSiliconPkg/SystemAgent/Library/PeiSaPolicyLib= /Ia32/MrcOemPlatform.nasm @@ -0,0 +1,118 @@ +; @file +; This file provides assembly 64-bit atomic reads/writes required for mem= ory initialization. +; +; Copyright (c) 2019 Intel Corporation. All rights reserved.
+; +; SPDX-License-Identifier: BSD-2-Clause-Patent +; + +SECTION .text + +;-------------------------------------------------------------------------= ---- +; +; Section: SaMmioRead64 +; +; Description: Read 64 bits from the Memory Mapped I/O space. +; Use MMX instruction for atomic access, because some MC registers have s= ide effect. +; +; @param[in] Address - Memory mapped I/O address. +; +;-------------------------------------------------------------------------= ---- + +;UINT64 +;SaMmioRead64 ( +; IN UINTN Address +; ) + +global ASM_PFX(SaMmioRead64) +ASM_PFX(SaMmioRead64): + sub esp, 16 + movq [esp], mm0 ;Save mm0 on stack + mov edx, [esp + 20] ;edx =3D Address + movq mm0, [edx] ;mm0 =3D [Address] + movq [esp + 8], mm0 ;Store mm0 on Stack + movq mm0, [esp] ;Restore mm0 + emms + mov eax, [esp + 8] ;eax =3D [Address][31:0] + mov edx, [esp + 12] ;edx =3D [Address][64:32] + add esp, 16 + ret + +;-------------------------------------------------------------------------= ---- +; +; Section: SaMmioWrite64 +; +; Description: Write 64 bits to the Memory Mapped I/O space. +; Use MMX instruction for atomic access, because some MC registers have s= ide effect. +; +; @param[in] Address - Memory mapped I/O address. +; @param[in] Value - The value to write. +; +;-------------------------------------------------------------------------= ---- + +;UINT64 +;SaMmioWrite64 ( +; IN UINTN Address, +; IN UINT64 Value +; ) + +global ASM_PFX(SaMmioWrite64) +ASM_PFX(SaMmioWrite64): + sub esp, 8 + movq [esp], mm0 ;Save mm0 on Stack + mov edx, [esp + 12] ;edx =3D Address + movq mm0, [esp + 16] ;mm0 =3D Value + movq [edx], mm0 ;[Address] =3D Value + movq mm0, [esp] ;Restore mm0 + emms + mov eax, [esp + 16] ;eax =3D Value[31:0] + mov edx, [esp + 20] ;edx =3D Value[64:32] + add esp, 8 + ret + +;-------------------------------------------------------------------------= ---- +; Intel Silicon View Technology check point interface based on IO port re= ading +; +; @param CheckPoint Check point AH value. +; AH =3D 0x10: End of MRC State +; AH =3D 0x20: End of DXE State +; AH =3D 0x30: Ready to boot before INT-19h or = UEFI boot +; AH =3D 0x40: After OS booting, need a timer S= MI trigger to implement (TBD); +; +; @param PortReading IO port reading address used for breakpoints +;-------------------------------------------------------------------------= ---- + +;VOID +;EFIAPI +;IsvtCheckPoint ( +; IN UINT32 CheckPoint, +; IN UINT32 PortReading +; ) + +global ASM_PFX(IsvtCheckPoint) +ASM_PFX(IsvtCheckPoint): + push eax + push edx + + ; Stack layout at this point: + ;------------- + ; PortReading ESP + 16 + ;------------- + ; CheckPoint ESP + 12 + ;------------- + ; EIP ESP + 8 + ;------------- + ; EAX ESP + 4 + ;------------- + ; EDX <-- ESP + ;------------- + + mov ah, BYTE [esp + 12] ; CheckPoint + mov dx, WORD [esp + 16] ; PortReading + in al, dx ; signal debugger + + pop edx + pop eax + ret + + --=20 2.16.2.windows.1