summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit
diff options
context:
space:
mode:
authorraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
committerraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
commitb7c51c9cf4864df6aabb99a1ae843becd577237c (patch)
treeeebe9b0d0ca03062955223097e57da84dd618b9a /ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit
downloadzprj-master.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit')
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.c247
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.dxs31
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.h59
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.inf84
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.c548
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.dxs42
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.h57
-rw-r--r--ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.inf95
8 files changed, 1163 insertions, 0 deletions
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.c b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.c
new file mode 100644
index 0000000..f907f4f
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.c
@@ -0,0 +1,247 @@
+/** @file
+ This file is a wrapper for Intel SA Platform Policy driver.
+ Get Setup Value to initilize Intel SA DXE Platform Policy.
+
+@copyright
+ Copyright (c) 1999 - 2014 Intel Corporation. All rights reserved
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+ the additional terms of the license agreement
+
+**/
+#include "SaDxePolicyInit.h"
+
+DXE_PLATFORM_SA_POLICY_PROTOCOL mDxePlatformSaPolicy;
+
+PCIE_ASPM_DEV_INFO mPcieAspmDevsOverride[] = {
+ ///
+ /// Tekoa w/o iAMT
+ ///
+ {0x8086, 0x108b, 0xff, 2, 2},
+ ///
+ /// Tekoa A2
+ ///
+ {0x8086, 0x108c, 0x00, 0, 0},
+ ///
+ /// Tekoa others
+ ///
+ {0x8086, 0x108c, 0xff, 2, 2},
+ ///
+ /// Vidalia
+ ///
+ {0x8086, 0x109a, 0xff, 2, 2},
+ ///
+ /// 3945ABG
+ ///
+ {0x8086, 0x4222, 0xff, 2, 3},
+ ///
+ /// 3945ABG
+ ///
+ {0x8086, 0x4227, 0xff, 2, 3},
+ ///
+ /// 3945ABG
+ ///
+ {0x8086, 0x4228, 0xff, 2, 3},
+ ///
+ /// End of table
+ ///
+ {SA_PCIE_DEV_END_OF_TABLE, 0, 0, 0, 0}
+};
+
+PCIE_LTR_DEV_INFO mPcieLtrDevsOverride[] = {
+ ///
+ /// Place holder for PCIe devices with correct LTR requirements
+ ///
+ ///
+ /// End of table
+ ///
+ {SA_PCIE_DEV_END_OF_TABLE, 0, 0, 0, 0}
+};
+///
+/// Function implementations
+///
+/**
+ Initilize Intel SA DXE Platform Policy
+
+ @param[in] ImageHandle Image handle of this driver.
+ @param[in] SystemTable Global system service table.
+
+ @retval EFI_SUCCESS Initialization complete.
+ @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
+ @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
+**/
+EFI_STATUS
+EFIAPI
+SaDxePolicyInitEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ UINT8 pegFn;
+ UINT8 Index;
+
+ SetMem (&mDxePlatformSaPolicy, sizeof (DXE_PLATFORM_SA_POLICY_PROTOCOL), 0);
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_VTD_CONFIGURATION), &(mDxePlatformSaPolicy.Vtd));
+ ASSERT_EFI_ERROR (Status);
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_MEMORY_CONFIGURATION), &(mDxePlatformSaPolicy.MemoryConfig));
+ ASSERT_EFI_ERROR (Status);
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_PCIE_CONFIGURATION), &(mDxePlatformSaPolicy.PcieConfig));
+ ASSERT_EFI_ERROR (Status);
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_IGD_CONFIGURATION), &(mDxePlatformSaPolicy.IgdConfig));
+ ASSERT_EFI_ERROR (Status);
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_MISC_CONFIGURATION), &(mDxePlatformSaPolicy.MiscConfig));
+ ASSERT_EFI_ERROR (Status);
+#ifdef SG_SUPPORT
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_SG_VBIOS_CONFIGURATION), &(mDxePlatformSaPolicy.VbiosConfig));
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+ ///
+ /// SA DXE Policy Init
+ ///
+ mDxePlatformSaPolicy.Revision = DXE_SA_PLATFORM_POLICY_PROTOCOL_REVISION_8;
+
+ ///
+ /// Initialize the VTD Configuration
+ ///
+ mDxePlatformSaPolicy.Vtd->VtdEnable = 0;
+ mDxePlatformSaPolicy.Vtd->BaseAddress[0] = 0xFED90000;
+ mDxePlatformSaPolicy.Vtd->BaseAddress[1] = 0xFED91000;
+ ///
+ /// RMRR Base and Limit Address for USB
+ ///
+ Status = (gBS->AllocatePool) (EfiBootServicesData, (sizeof (EFI_PHYSICAL_ADDRESS) * 2), (VOID **) &mDxePlatformSaPolicy.Vtd->RmrrUsbBaseAddress);
+ ASSERT_EFI_ERROR (Status);
+ ///
+ /// BIOS must update USB RMRR base address
+ ///
+ mDxePlatformSaPolicy.Vtd->RmrrUsbBaseAddress[0] = 0x3E2E0000;
+ mDxePlatformSaPolicy.Vtd->RmrrUsbBaseAddress[1] = 0x3E2FFFFF;
+
+ ///
+ /// Initialize the PCIE Configuration
+ ///
+ mDxePlatformSaPolicy.PcieConfig->DmiAspm = PcieAspmL0sL1;
+ ///
+ /// PEG ASPM per port configuration. 3 PEG controllers i.e. 0,1,2
+ ///
+ for (pegFn = 0; pegFn < 3; pegFn++) {
+ mDxePlatformSaPolicy.PcieConfig->PegAspm[pegFn] = PcieAspmAutoConfig;
+ mDxePlatformSaPolicy.PcieConfig->PegAspmL0s[pegFn] = 0;
+ mDxePlatformSaPolicy.PcieConfig->PegDeEmphasis[pegFn] = 1;
+ }
+
+ mDxePlatformSaPolicy.PcieConfig->DmiExtSync = 0;
+ mDxePlatformSaPolicy.PcieConfig->DmiDeEmphasis = 0;
+ mDxePlatformSaPolicy.PcieConfig->DmiIot = 0;
+ mDxePlatformSaPolicy.PcieConfig->C7Allowed = 0;
+ for (Index = 0; Index < SA_PEG_MAX_FUN; Index++) {
+ mDxePlatformSaPolicy.PcieConfig->PegPwrOpt[Index].LtrEnable = 1;
+ mDxePlatformSaPolicy.PcieConfig->PegPwrOpt[Index].LtrMaxSnoopLatency = V_SA_LTR_MAX_SNOOP_LATENCY_VALUE;
+ mDxePlatformSaPolicy.PcieConfig->PegPwrOpt[Index].LtrMaxNoSnoopLatency = V_SA_LTR_MAX_NON_SNOOP_LATENCY_VALUE;
+ mDxePlatformSaPolicy.PcieConfig->PegPwrOpt[Index].ObffEnable = 1;
+ }
+
+ mDxePlatformSaPolicy.PcieConfig->PcieAspmDevsOverride = mPcieAspmDevsOverride;
+ mDxePlatformSaPolicy.PcieConfig->PcieLtrDevsOverride = mPcieLtrDevsOverride;
+
+ ///
+ /// Initialize the Memory Configuration
+ ///
+ ///
+ /// DIMM SMBus addresses info
+ /// Refer to the SpdAddressTable[] mapping rule in SaPlatformPolicy.h
+ ///
+ Status = (gBS->AllocatePool) (EfiBootServicesData, (sizeof (UINT8) * 4), (VOID **) &mDxePlatformSaPolicy.MemoryConfig->SpdAddressTable);
+ ASSERT_EFI_ERROR (Status);
+
+ mDxePlatformSaPolicy.MemoryConfig->SpdAddressTable[0] = DIMM_SMB_SPD_P0C0D0;
+ mDxePlatformSaPolicy.MemoryConfig->SpdAddressTable[1] = DIMM_SMB_SPD_P0C0D1;
+ mDxePlatformSaPolicy.MemoryConfig->SpdAddressTable[2] = DIMM_SMB_SPD_P0C1D0;
+ mDxePlatformSaPolicy.MemoryConfig->SpdAddressTable[3] = DIMM_SMB_SPD_P0C1D1;
+
+ mDxePlatformSaPolicy.MemoryConfig->ChannelASlotMap = 0x01;
+ mDxePlatformSaPolicy.MemoryConfig->ChannelBSlotMap = 0x01;
+ mDxePlatformSaPolicy.MemoryConfig->RmtBdatEnable = 0x00;
+
+ ///
+ /// Initialize the Graphics configuration
+ ///
+ mDxePlatformSaPolicy.IgdConfig->RenderStandby = 1;
+ mDxePlatformSaPolicy.IgdConfig->VbtAddress = 0x00000000;
+ mDxePlatformSaPolicy.IgdConfig->Size = 0;
+ mDxePlatformSaPolicy.IgdConfig->CdClk = 0;
+ mDxePlatformSaPolicy.IgdConfig->PlatformConfig = 1;
+
+ ///
+ /// SA internal devices and misc configuration
+ ///
+ mDxePlatformSaPolicy.MiscConfig->ChapDeviceEnable = FALSE;
+ mDxePlatformSaPolicy.MiscConfig->Device4Enable = FALSE;
+ mDxePlatformSaPolicy.MiscConfig->CridEnable = FALSE;
+ mDxePlatformSaPolicy.MiscConfig->AudioEnable = TRUE;
+ mDxePlatformSaPolicy.MiscConfig->FviReport = 1;
+ ///
+ /// Default Enable FVI SMBIOS Report
+ ///
+ mDxePlatformSaPolicy.MiscConfig->FviSmbiosType = 0xDD;
+ ///
+ /// Default SMBIOS Type 221
+ ///
+ Status = (gBS->AllocatePool) (EfiBootServicesData, sizeof (SA_DEFAULT_SVID_SID), (VOID **) &mDxePlatformSaPolicy.MiscConfig->DefaultSvidSid);
+ ASSERT_EFI_ERROR (Status);
+ mDxePlatformSaPolicy.MiscConfig->DefaultSvidSid->SubSystemVendorId = V_SA_MC_VID;
+ ///
+ /// 0x8086;
+ ///
+ mDxePlatformSaPolicy.MiscConfig->DefaultSvidSid->SubSystemId = 0x2010;
+
+
+#ifdef SG_SUPPORT
+ ///
+ /// Initialize the Switchable Graphics DXE Policies
+ ///
+
+ ///
+ /// 1 = Load secondary display device VBIOS
+ /// 0 = Do not load
+ ///
+ mDxePlatformSaPolicy.VbiosConfig->LoadVbios = 0;
+ ///
+ /// 1 = Execute the secondary display device VBIOS (only if LoadVbios == 1)
+ /// 0 = Do no execute
+ ///
+ mDxePlatformSaPolicy.VbiosConfig->ExecuteVbios = 0;
+ ///
+ /// 1 = secondary display device VBIOS Source is PCI Card
+ /// 0 = secondary display device VBIOS Source is FW Volume
+ ///
+ mDxePlatformSaPolicy.VbiosConfig->VbiosSource = 1;
+#endif
+
+ UpdateDxeSaPlatformPolicy (&mDxePlatformSaPolicy);
+
+ ///
+ /// Install protocol to to allow access to this Policy.
+ ///
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gDxePlatformSaPolicyGuid,
+ &mDxePlatformSaPolicy,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.dxs b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.dxs
new file mode 100644
index 0000000..21fcf4c
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.dxs
@@ -0,0 +1,31 @@
+/** @file
+ Dependency expression source file.
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+ the additional terms of the license agreement
+
+**/
+
+
+#include "EfiDepex.h"
+#include EFI_PROTOCOL_DEFINITION (PchPlatformPolicy)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+
+DEPENDENCY_START
+ DXE_PCH_PLATFORM_POLICY_PROTOCOL_GUID AND
+ EFI_VARIABLE_ARCH_PROTOCOL_GUID
+DEPENDENCY_END
+
+
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.h b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.h
new file mode 100644
index 0000000..8f87761
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.h
@@ -0,0 +1,59 @@
+/** @file
+ Header file for the SaDxePolicyInit Driver.
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+ the additional terms of the license agreement
+**/
+#ifndef _SA_DXE_PLATFORM_POLICY_H_
+#define _SA_DXE_PLATFORM_POLICY_H_
+
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGlueDxe.h"
+#include "EfiScriptLib.h"
+#include EFI_PROTOCOL_PRODUCER (SaPlatformPolicy)
+#endif
+
+#include "SaAccess.h"
+#include "SaPlatformPolicyUpdateDxeLib.h"
+
+///
+/// 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
+
+/**
+ Initilize Intel SA DXE Platform Policy
+
+ @param[in] ImageHandle - Image handle of this driver.
+ @param[in] SystemTable - Global system service table.
+
+ @retval EFI_SUCCESS Initialization complete.
+ @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
+ @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
+**/
+EFI_STATUS
+SaDxePolicyInitEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN OUT EFI_SYSTEM_TABLE *SystemTable
+ )
+;
+
+#endif
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.inf b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.inf
new file mode 100644
index 0000000..8ee2520
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Dxe/SaDxePolicyInit.inf
@@ -0,0 +1,84 @@
+## @file
+# Component description file for the SaDxePolicyInit DXE driver.
+#
+#@copyright
+# Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+# This software and associated documentation (if any) is furnished
+# under a license and may only be used or copied in accordance
+# with the terms of the license. Except as permitted by such
+# license, no part of this software or documentation may be
+# reproduced, stored in a retrieval system, or transmitted in any
+# form or by any means without the express written consent of
+# Intel Corporation.
+#
+# This file contains a 'Sample Driver' and is licensed as such
+# under the terms of your license agreement with Intel or your
+# vendor. This file may be modified by the user, subject to
+# the additional terms of the license agreement
+#
+
+
+[defines]
+BASE_NAME = SaDxePolicyInit
+FILE_GUID = 67a54a24-3f4f-4048-8787-3e5aa2a0b7d2
+COMPONENT_TYPE = BS_DRIVER
+
+[sources.common]
+ SaDxePolicyInit.c
+ SaDxePolicyInit.h
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGlueDxeDriverEntryPoint.c
+
+[includes.common]
+ .
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include/Pcd
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(EDK_SOURCE)/Foundation/Cpu/Pentium/Include
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Include
+ $(PLATFORM_ECP_PACKAGE)/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include
+
+[libraries.common]
+ EdkGuidLib
+ EdkFrameworkGuidLib
+ EdkFrameworkProtocolLib
+ EdkProtocolLib
+ EfiGuidLib
+ EfiCommonLib
+ $(PROJECT_SA_FAMILY)ProtocolLib
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGlueBasePciLibPciExpress
+ EdkIIGlueDxeReportStatusCodeLib
+ EdkIIGlueDxeDebugLibReportStatusCode
+ EdkIIGlueUefiBootServicesTableLib
+ EdkIIGlueUefiRuntimeServicesTableLib
+ EdkIIGlueDxeServicesTableLib
+ PlatformPolicyUpdateDxeLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT= _ModuleEntryPoint
+ DPX_SOURCE=SaDxePolicyInit.dxs
+ C_FLAGS = $(C_FLAGS) -D"__EDKII_GLUE_MODULE_ENTRY_POINT__=SaDxePolicyInitEntryPoint" \
+ -D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ -D __EDKII_GLUE_BASE_LIB__ \
+ -D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ -D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ -D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ -D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\
+ -D __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ \
+ -D __EDKII_GLUE_UEFI_LIB__
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.c b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.c
new file mode 100644
index 0000000..7317fb4
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.c
@@ -0,0 +1,548 @@
+/** @file
+ This file is SampleCode for Intel SA PEI Platform Policy initialzation.
+
+@copyright
+ Copyright (c) 1999 - 2014 Intel Corporation. All rights reserved
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+ the additional terms of the license agreement
+
+**/
+#include "SaPeiPolicyInit.h"
+
+///
+/// This IO Trap address can be overridden by defining it
+/// in compiling environment variable
+/// It must not conflict with other IO address in platform
+///
+#ifndef SA_IOTRAP_SMI_ADDRESS
+#define SA_IOTRAP_SMI_ADDRESS 0x2000
+#endif
+
+EFI_STATUS
+SaPeiPolicyInitEntryPoint (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/**
+ This PEIM performs SA PEI Platform Policy initialzation.
+
+ @param[in] FfsHeader - Pointer to Firmware File System file header.
+ @param[in] PeiServices - General purpose services available to every PEIM.
+
+ @retval EFI_SUCCESS - The PPI is installed and initialized.
+ @retval EFI ERRORS - The PPI is not successfully installed.
+**/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *SaPlatformPolicyPpiDesc;
+ SA_PLATFORM_POLICY_PPI *SaPlatformPolicyPpi;
+ SA_PLATFORM_DATA *PlatformData;
+ GT_CONFIGURATION *GtConfig;
+ MEMORY_CONFIGURATION *MemConfig;
+ PCIE_CONFIGURATION *PcieConfig;
+ OVERCLOCKING_CONFIGURATION *OcConfig;
+ PEG_GPIO_DATA *PegGpioData;
+ CPU_FAMILY CpuFamilyId;
+#ifdef SG_SUPPORT
+ SG_GPIO_DATA *SgGpioData;
+#endif
+ UINT8 Index;
+ ///
+ /// Allocate descriptor and PPI structures
+ ///
+ SaPlatformPolicyPpi = (SA_PLATFORM_POLICY_PPI *) AllocatePool (sizeof (SA_PLATFORM_POLICY_PPI));
+ ASSERT (SaPlatformPolicyPpi != NULL);
+ EfiCommonLibZeroMem (SaPlatformPolicyPpi, sizeof (SA_PLATFORM_POLICY_PPI));
+
+ SaPlatformPolicyPpiDesc = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));
+ ASSERT (SaPlatformPolicyPpiDesc != NULL);
+ EfiCommonLibZeroMem (SaPlatformPolicyPpiDesc, sizeof (EFI_PEI_PPI_DESCRIPTOR));
+
+ PlatformData = (SA_PLATFORM_DATA *) AllocatePool (sizeof (SA_PLATFORM_DATA));
+ ASSERT (PlatformData != NULL);
+ EfiCommonLibZeroMem (PlatformData, sizeof (SA_PLATFORM_DATA));
+
+ GtConfig = (GT_CONFIGURATION *) AllocatePool (sizeof (GT_CONFIGURATION));
+ ASSERT (GtConfig != NULL);
+ EfiCommonLibZeroMem (GtConfig, sizeof (GT_CONFIGURATION));
+
+ MemConfig = (MEMORY_CONFIGURATION *) AllocatePool (sizeof (MEMORY_CONFIGURATION));
+ ASSERT (MemConfig != NULL);
+ EfiCommonLibZeroMem (MemConfig, sizeof (MEMORY_CONFIGURATION));
+
+ PcieConfig = (PCIE_CONFIGURATION *) AllocatePool (sizeof (PCIE_CONFIGURATION));
+ ASSERT (PcieConfig != NULL);
+ EfiCommonLibZeroMem (PcieConfig, sizeof (PCIE_CONFIGURATION));
+
+ PegGpioData = (PEG_GPIO_DATA *) AllocatePool (sizeof (PEG_GPIO_DATA));
+ ASSERT (PegGpioData != NULL);
+ EfiCommonLibZeroMem (PegGpioData, sizeof (PEG_GPIO_DATA));
+
+ OcConfig = (OVERCLOCKING_CONFIGURATION *) AllocatePool (sizeof (OVERCLOCKING_CONFIGURATION));
+ ASSERT (OcConfig != NULL);
+ EfiCommonLibZeroMem (OcConfig, sizeof (OVERCLOCKING_CONFIGURATION));
+
+#ifdef SG_SUPPORT
+ SgGpioData = (SG_GPIO_DATA *) AllocatePool (sizeof (SG_GPIO_DATA));
+ ASSERT (SgGpioData != NULL);
+ EfiCommonLibZeroMem (SgGpioData, sizeof (SG_GPIO_DATA));
+#endif
+
+ SetMem ((VOID *) SaPlatformPolicyPpi, sizeof (SA_PLATFORM_POLICY_PPI), 0);
+
+ ///
+ /// Initialize the PPI
+ ///
+ SaPlatformPolicyPpiDesc->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+ SaPlatformPolicyPpiDesc->Guid = &gSaPlatformPolicyPpiGuid;
+ SaPlatformPolicyPpiDesc->Ppi = SaPlatformPolicyPpi;
+
+ ///
+ /// Update the REVISION number
+ ///
+ SaPlatformPolicyPpi->Revision = SA_PLATFORM_POLICY_PPI_REVISION_15;
+
+ CpuFamilyId = GetCpuFamily();
+
+ ///
+ /// Initialize the Platform Configuration
+ ///
+ PlatformData->SpdAddressTable[0] = 0xA0;
+ PlatformData->SpdAddressTable[1] = 0xA2;
+ PlatformData->SpdAddressTable[2] = 0xA4;
+ PlatformData->SpdAddressTable[3] = 0xA6;
+ PlatformData->MchBar = 0xfed10000;
+ PlatformData->DmiBar = 0xfed18000;
+ PlatformData->EpBar = 0xfed19000;
+ PlatformData->EdramBar = 0xfed80000;
+ PlatformData->PciExpressBar = (UINTN) PcdGet64 (PcdPciExpressBaseAddress);
+ PlatformData->SmbusBar = 0xEFA0;
+ PlatformData->TsegSize = 0x800000;
+ PlatformData->IedSize = 0x400000;
+ PlatformData->FastBoot = 0;
+ PlatformData->GdxcBar = 0xFED84000;
+ PlatformData->BoardId = 0;
+
+ SaPlatformPolicyPpi->PlatformData = PlatformData;
+ ///
+ /// Initialize the Graphics configuration
+ ///
+ GtConfig->GttSize = 2;
+ GtConfig->IgdDvmt50PreAlloc = 1;
+ GtConfig->InternalGraphics = 2;
+ GtConfig->PrimaryDisplay = 3;
+ GtConfig->ApertureSize = 2;
+ GtConfig->PanelPowerEnable = 0;
+ SaPlatformPolicyPpi->GtConfig = GtConfig;
+
+ ///
+ /// Initialize the Memory Configuration
+ ///
+ MemConfig->EccSupport = 1;
+ MemConfig->DdrFreqLimit = 0;
+ MemConfig->MaxTolud = 0;
+ MemConfig->SpdProfileSelected = 0;
+ MemConfig->NModeSupport = 0;
+ MemConfig->ScramblerSupport = 1;
+ MemConfig->PowerDownMode = 0xFF;
+ MemConfig->PwdwnIdleCounter = 0x80;
+ MemConfig->RankInterleave = TRUE;
+ MemConfig->EnhancedInterleave = TRUE;
+ MemConfig->WeaklockEn = TRUE;
+ MemConfig->EnCmdRate = 7;
+ MemConfig->CmdTriStateDis = FALSE;
+ MemConfig->RefreshRate2x = FALSE;
+ MemConfig->AutoSelfRefreshSupport = TRUE;
+ MemConfig->ExtTemperatureSupport = TRUE;
+
+ ///
+ /// Thermal Management Configuration
+ ///
+ MemConfig->ThermalManagement = 1;
+ MemConfig->PeciInjectedTemp = 0;
+ MemConfig->ExttsViaTsOnBoard = 0;
+ MemConfig->ExttsViaTsOnDimm = 0;
+ MemConfig->VirtualTempSensor = 0;
+ ///
+ /// Channel DIMM Disable
+ ///
+ MemConfig->DisableDimmChannel[0] = 0;
+ MemConfig->DisableDimmChannel[1] = 0;
+ ///
+ /// Channel Hash Configuration
+ ///
+ MemConfig->ChHashEnable = TRUE;
+ MemConfig->ChHashMask = 0x30CE;
+ MemConfig->ChHashInterleaveBit = 1;
+ ///
+ /// Options for Thermal settings
+ ///
+ MemConfig->EnableExtts = 0;
+ MemConfig->EnableCltm = 0;
+ MemConfig->EnableOltm = 0;
+ MemConfig->EnablePwrDn = 1;
+ if (CpuFamilyId == EnumCpuHswUlt) {
+ MemConfig->EnablePwrDnLpddr = 0;
+ }
+ MemConfig->Refresh2X = 0;
+ MemConfig->LpddrThermalSensor = 1;
+ MemConfig->LockPTMregs = 0;
+ MemConfig->UserPowerWeightsEn = 0;
+
+ MemConfig->EnergyScaleFact = 3;
+ MemConfig->RaplPwrFlCh1 = 0;
+ MemConfig->RaplPwrFlCh0 = 0;
+
+ MemConfig->RaplLim2Lock = 0;
+ MemConfig->RaplLim2WindX = 0;
+ MemConfig->RaplLim2WindY = 0;
+ MemConfig->RaplLim2Ena = 0;
+ MemConfig->RaplLim2Pwr = 0;
+ MemConfig->RaplLim1WindX = 0;
+ MemConfig->RaplLim1WindY = 0;
+ MemConfig->RaplLim1Ena = 0;
+ MemConfig->RaplLim1Pwr = 0;
+
+ MemConfig->WarmThresholdCh0Dimm0 = 0xFF;
+ MemConfig->WarmThresholdCh0Dimm1 = 0xFF;
+ MemConfig->WarmThresholdCh1Dimm0 = 0xFF;
+ MemConfig->WarmThresholdCh1Dimm1 = 0xFF;
+ MemConfig->HotThresholdCh0Dimm0 = 0xFF;
+ MemConfig->HotThresholdCh0Dimm1 = 0xFF;
+ MemConfig->HotThresholdCh1Dimm0 = 0xFF;
+ MemConfig->HotThresholdCh1Dimm1 = 0xFF;
+ MemConfig->WarmBudgetCh0Dimm0 = 0xFF;
+ MemConfig->WarmBudgetCh0Dimm1 = 0xFF;
+ MemConfig->WarmBudgetCh1Dimm0 = 0xFF;
+ MemConfig->WarmBudgetCh1Dimm1 = 0xFF;
+ MemConfig->HotBudgetCh0Dimm0 = 0xFF;
+ MemConfig->HotBudgetCh0Dimm1 = 0xFF;
+ MemConfig->HotBudgetCh1Dimm0 = 0xFF;
+ MemConfig->HotBudgetCh1Dimm1 = 0xFF;
+
+ MemConfig->IdleEnergyCh0Dimm1 = 0;
+ MemConfig->IdleEnergyCh0Dimm0 = 0;
+ MemConfig->PdEnergyCh0Dimm1 = 0;
+ MemConfig->PdEnergyCh0Dimm0 = 0;
+ MemConfig->ActEnergyCh0Dimm1 = 0;
+ MemConfig->ActEnergyCh0Dimm0 = 0;
+ MemConfig->RdEnergyCh0Dimm1 = 0;
+ MemConfig->RdEnergyCh0Dimm0 = 0;
+ MemConfig->WrEnergyCh0Dimm1 = 0;
+ MemConfig->WrEnergyCh0Dimm0 = 0;
+
+ MemConfig->IdleEnergyCh1Dimm1 = 0;
+ MemConfig->IdleEnergyCh1Dimm0 = 0;
+ MemConfig->PdEnergyCh1Dimm1 = 0;
+ MemConfig->PdEnergyCh1Dimm0 = 0;
+ MemConfig->ActEnergyCh1Dimm1 = 0;
+ MemConfig->ActEnergyCh1Dimm0 = 0;
+ MemConfig->RdEnergyCh1Dimm1 = 0;
+ MemConfig->RdEnergyCh1Dimm0 = 0;
+ MemConfig->WrEnergyCh1Dimm1 = 0;
+ MemConfig->WrEnergyCh1Dimm0 = 0;
+
+ MemConfig->SrefCfgEna = 1;
+ MemConfig->SrefCfgIdleTmr = 0x200;
+ MemConfig->ThrtCkeMinDefeat = 0;
+ MemConfig->ThrtCkeMinTmr = 0x30;
+ if (CpuFamilyId == EnumCpuHswUlt) {
+ MemConfig->ThrtCkeMinDefeatLpddr = 1;
+ MemConfig->ThrtCkeMinTmrLpddr = 0x40;
+ }
+
+
+ MemConfig->McLock = TRUE;
+
+ MemConfig->GdxcEnable = TRUE;
+ MemConfig->GdxcIotSize = 4;
+ MemConfig->GdxcMotSize = 12;
+
+ MemConfig->MemoryTrace = 0;
+
+ MemConfig->ECT = 0;
+ MemConfig->SOT = 1;
+ MemConfig->RDMPRT = 1;
+ MemConfig->RCVET = 1;
+ MemConfig->JWRL = 1;
+ MemConfig->FWRL = 0;
+ MemConfig->WRTC1D = 1;
+ MemConfig->RDTC1D = 1;
+ MemConfig->DIMMODTT = 1;
+ MemConfig->WRDST = 0;
+ MemConfig->WREQT = 1;
+ MemConfig->RDODTT = 1;
+ MemConfig->RDEQT = 0;
+ MemConfig->RDAPT = 1;
+ MemConfig->WRTC2D = 1;
+ MemConfig->RDTC2D = 1;
+ MemConfig->CMDVC = 1;
+ MemConfig->WRVC2D = 1;
+ MemConfig->RDVC2D = 1;
+ MemConfig->LCT = 1;
+ MemConfig->RTL = 1;
+ MemConfig->TAT = 1;
+ MemConfig->RMT = 0;
+ MemConfig->MEMTST = 0;
+ MemConfig->DIMMODTT1D = 0;
+ MemConfig->WRSRT = 0;
+ MemConfig->DIMMRONT = 1;
+ MemConfig->ALIASCHK = 1;
+ MemConfig->RCVENC1D = 1;
+ MemConfig->RMC = 1;
+
+ MemConfig->RemapEnable = TRUE;
+ MemConfig->RmtBdatEnable = FALSE;
+ MemConfig->MrcTimeMeasure = FALSE;
+ MemConfig->MrcFastBoot = TRUE;
+ MemConfig->DDR3Voltage = 0;
+ MemConfig->DDR3VoltageWaitTime = 0;
+ MemConfig->RefClk = 0;
+ MemConfig->Ratio = 0;
+ MemConfig->BClkFrequency = 100 * 1000 * 1000;
+ MemConfig->MaxRttWr = 0;
+ ///
+ /// MrcUltPoSafeConfig
+ /// 1 to enable, 0 to disable
+ ///
+ MemConfig->MrcUltPoSafeConfig = 0;
+
+ if (CpuFamilyId == EnumCpuHswUlt) {
+ ///
+ /// Interleaving mode of DQ/DQS pins - depends on board routing
+ ///
+ MemConfig->DqPinsInterleaved = FALSE;
+ }
+
+ SaPlatformPolicyPpi->MemConfig = MemConfig;
+
+ ///
+ /// Initialize the PciExpress Configuration
+ ///
+ PcieConfig->DmiVc1 = 0;
+ PcieConfig->DmiVcp = 1;
+ PcieConfig->DmiVcm = 1;
+ PcieConfig->DmiGen2 = 1;
+ PcieConfig->AlwaysEnablePeg = 0;
+ for (Index = 0; Index < SA_PEG_MAX_FUN; Index++) {
+ PcieConfig->PegGenx[Index] = 0;
+ }
+
+ for (Index = 0; Index < SA_PEG_MAX_FUN; Index++) {
+ PcieConfig->PowerDownUnusedBundles[Index] = 0xFF;
+ }
+
+ PcieConfig->PegGen3Equalization = 1;
+ PcieConfig->PegSamplerCalibrate = 0;
+ PcieConfig->PegSwingControl = 2;
+ PcieConfig->PegComplianceTestingMode = 0;
+
+ ///
+ /// PEG Gen3 Preset Search: 0 = Disabled, 1 = Enabled (default)
+ /// PEG Gen3 Force Preset Search (always re-search): 0 = Disabled (default), 1 = Enabled
+ /// PEG Gen3 Preset Search Dwell Time: 400 usec
+ /// PEG Gen3 Preset Search Timing Margin Steps: 2
+ /// PEG Gen3 Preset Search Timing Start Margin: 15
+ /// PEG Gen3 Preset Search Voltage Margin Steps: 2
+ /// PEG Gen3 Preset Search Voltage Start Margin: 20
+ /// PEG Gen3 Preset Search Favor Timing: 0 = Timing + Voltage (default), 1 = Timing only
+ /// PEG Gen3 Preset Search Error Target: 4
+ ///
+ PcieConfig->PegGen3PresetSearch = 1;
+ PcieConfig->PegGen3ForcePresetSearch = 0;
+ PcieConfig->PegGen3PresetSearchDwellTime = STALL_ONE_MILLI_SECOND;
+ PcieConfig->PegGen3PresetSearchStartMargin = 15;
+ PcieConfig->PegGen3PresetSearchVoltageStartMargin = 20;
+ PcieConfig->PegGen3PresetSearchErrorTarget = 1;
+
+ for (Index = 0; Index < SA_PEG_MAX_LANE; Index++) {
+ PcieConfig->Gen3RootPortPreset[Index] = 8;
+ PcieConfig->Gen3EndPointPreset[Index] = 7;
+ PcieConfig->Gen3EndPointHint[Index] = 2;
+ }
+
+ ///
+ /// Parameters for PCIe ASPM flow control
+ /// InitPcieAspmAfterOprom:
+ /// 0 (default) - PCIe ASPM will be initialized Before Oprom
+ /// 1 - PCIe ASPM will be initialized After Oprom (required IOTRAP SMI handler)
+ /// Note: This setting should match supported mode!
+ ///
+ /// SaIotrapSmiAddress:
+ /// IOTRAP SMI address for SA SMI callback handler. This should be given if platform supports InitPcieAspmAfterOprom = 1 scenario (SaLateInitSmm driver was compiled)
+ ///
+ PcieConfig->InitPcieAspmAfterOprom = FALSE;
+ PcieConfig->SaIotrapSmiAddress = SA_IOTRAP_SMI_ADDRESS;
+
+ ///
+ /// Parameters for PCIe Gen3 device reset
+ /// Note: Refer to the Platform Design Guide (PDG) for additional information about this GPIO.
+ ///
+ PegGpioData->GpioSupport = TRUE;
+ if (PegGpioData->GpioSupport) {
+ PegGpioData->SaPegReset = (SA_GPIO_INFO *) AllocatePool (sizeof (SA_GPIO_INFO));
+ ASSERT (PegGpioData->SaPegReset != NULL);
+ if (PegGpioData->SaPegReset == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ ///
+ /// PEG Reset: GPIO 50, Active Low (Mobile PDG)
+ ///
+ PegGpioData->SaPegReset->Value = 50;
+ PegGpioData->SaPegReset->Active = 0;
+ PcieConfig->PegGpioData = PegGpioData;
+ }
+
+ ///
+ /// Enable/Disable RxCEM Loop back
+ /// 1=Enable, 0=Disable (default)
+ /// When enabled, Lane for loop back should be selected (0 ~ 15 and default is Lane 0)
+ ///
+ PcieConfig->RxCEMLoopback = 0;
+ PcieConfig->RxCEMLoopbackLane = 0;
+
+ ///
+ /// Gen3 RxCTLE peaking default is 8
+ ///
+ for (Index = 0; Index < SA_PEG_MAX_BUNDLE; Index++) {
+ PcieConfig->Gen3RxCtleP[Index] = 8;
+ }
+
+ ///
+ /// Initialize the SA PEG Data pointer for saved preset search results
+ ///
+ PcieConfig->PegDataPtr = NULL;
+
+ SaPlatformPolicyPpi->PcieConfig = PcieConfig;
+
+ ///
+ /// Initialize the Overclocking Configuration
+ ///
+ OcConfig->GtVoltageOffset = 0;
+ OcConfig->GtVoltageOverride = 0;
+ OcConfig->GtExtraTurboVoltage = 0;
+ OcConfig->GtMaxOcTurboRatio = 0;
+ OcConfig->SaVoltageOffset = 0;
+ OcConfig->GtVoltageMode = 0;
+ OcConfig->OcSupport = 0;
+ OcConfig->IoaVoltageOffset = 0;
+ OcConfig->IodVoltageOffset = 0;
+
+ SaPlatformPolicyPpi->OcConfig = OcConfig;
+
+
+#ifdef SG_SUPPORT
+ ///
+ /// Initialize the Switchable Graphics Configuration
+ ///
+ ///
+ /// Switchable Graphics mode set as MUXLESS (By default)
+ ///
+ PlatformData->SgMode = SgModeMuxless;
+ PlatformData->SgSubSystemId = 0x2112;
+
+ SaPlatformPolicyPpi->PlatformData = PlatformData;
+
+ ///
+ /// Configure below based on the OEM platfrom design
+ /// Switchable Graphics GPIO support - 1=Supported, 0=Not Supported
+ ///
+ SgGpioData->GpioSupport = TRUE;
+
+ if (SgGpioData->GpioSupport) {
+ ///
+ /// Initialzie the GPIO Configuration
+ ///
+ ///
+ /// dGPU PWROK GPIO assigned
+ ///
+ SgGpioData->SgDgpuPwrOK = (SA_GPIO_INFO *) AllocatePool (sizeof (SA_GPIO_INFO));
+ ASSERT (SgGpioData->SgDgpuPwrOK != NULL);
+ if (SgGpioData->SgDgpuPwrOK == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ SgGpioData->SgDgpuPwrOK->Value = 17;
+ ///
+ /// dGPU PWROK Active High
+ ///
+ SgGpioData->SgDgpuPwrOK->Active = 1;
+
+ ///
+ /// dGPU HLD RST GPIO assigned
+ ///
+ SgGpioData->SgDgpuHoldRst = (SA_GPIO_INFO *) AllocatePool (sizeof (SA_GPIO_INFO));
+ ASSERT (SgGpioData->SgDgpuHoldRst != NULL);
+ if (SgGpioData->SgDgpuHoldRst == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ SgGpioData->SgDgpuHoldRst->Value = 50;
+ ///
+ /// dGPU HLD RST Active Low
+ ///
+ SgGpioData->SgDgpuHoldRst->Active = 0;
+
+ if (CpuFamilyId == EnumCpuHswUlt) {
+ SgGpioData->SgDgpuHoldRst->Value = 48;
+ }
+
+ ///
+ /// dGPU PWR Enable GPIO assigned
+ ///
+ SgGpioData->SgDgpuPwrEnable = (SA_GPIO_INFO *) AllocatePool (sizeof (SA_GPIO_INFO));
+ ASSERT (SgGpioData->SgDgpuPwrEnable != NULL);
+ if (SgGpioData->SgDgpuPwrEnable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ SgGpioData->SgDgpuPwrEnable->Value = 54;
+ ///
+ /// dGPU PWR Enable Active Low
+ ///
+ SgGpioData->SgDgpuPwrEnable->Active = 0;
+
+ if (CpuFamilyId == EnumCpuHswUlt) {
+ SgGpioData->SgDgpuPwrEnable->Value = 84;
+ }
+
+ ///
+ /// dGPU_PRSNT# GPIO assigned
+ ///
+ SgGpioData->SgDgpuPrsnt = (SA_GPIO_INFO *) AllocatePool (sizeof (SA_GPIO_INFO));
+ ASSERT (SgGpioData->SgDgpuPrsnt != NULL);
+ if (SgGpioData->SgDgpuPrsnt == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ SgGpioData->SgDgpuPrsnt->Value = 67;
+ ///
+ /// dGPU_PRSNT# Active Low
+ ///
+ SgGpioData->SgDgpuPrsnt->Active = 0;
+
+ SaPlatformPolicyPpi->SgGpioData = SgGpioData;
+ }
+#endif
+
+ ///
+ /// Initialize the DataPtr for S3 resume
+ ///
+ SaPlatformPolicyPpi->S3DataPtr = NULL;
+
+ UpdatePeiSaPlatformPolicy (PeiServices, SaPlatformPolicyPpi);
+
+ ///
+ /// Install SA Platform Policy PPI
+ ///
+ Status = (**PeiServices).InstallPpi (PeiServices, SaPlatformPolicyPpiDesc);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.dxs b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.dxs
new file mode 100644
index 0000000..b3b2c70
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.dxs
@@ -0,0 +1,42 @@
+/** @file
+ Dependency expression source file.
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+ the additional terms of the license agreement
+
+**/
+
+
+//
+// Common for R8 and R9 codebase
+//
+#include "AutoGen.h"
+#include "PeimDepex.h"
+
+//
+// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are both "defined" in R8 codebase;
+// BUILD_WITH_EDKII_GLUE_LIB is defined in Edk-Dev-Snapshot-20070228 and later version
+// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are "not defined" in R9 codebase.
+//
+#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB)
+#include "EfiDepex.h"
+#include EFI_PPI_DEPENDENCY (Variable)
+#endif
+
+
+DEPENDENCY_START
+
+ PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID
+DEPENDENCY_END
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.h b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.h
new file mode 100644
index 0000000..2cfb8e3
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.h
@@ -0,0 +1,57 @@
+/** @file
+ Header file for the SaPeiPolicyInit PEIM.
+
+@copyright
+ Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+ This software and associated documentation (if any) is furnished
+ under a license and may only be used or copied in accordance
+ with the terms of the license. Except as permitted by such
+ license, no part of this software or documentation may be
+ reproduced, stored in a retrieval system, or transmitted in any
+ form or by any means without the express written consent of
+ Intel Corporation.
+
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+ the additional terms of the license agreement
+**/
+#ifndef _SA_PEI_PLATFORM_POLICY_H_
+#define _SA_PEI_PLATFORM_POLICY_H_
+
+///
+/// External include files do NOT need to be explicitly specified in real EDKII
+/// environment
+///
+#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
+#include "EdkIIGluePeim.h"
+#include "SaAccess.h"
+#include "MrcApi.h"
+#include "CpuRegs.h"
+#include "CpuPlatformLib.h"
+
+#include EFI_PPI_PRODUCER (SaPlatformPolicy)
+#include EFI_GUID_DEFINITION (SaDataHob)
+#endif
+
+#include "SaPlatformPolicyUpdatePeiLib.h"
+
+///
+/// Functions
+///
+/**
+ This PEIM performs SA PEI Platform Policy initialzation.
+
+ @param[in] FfsHeader - Pointer to Firmware File System file header.
+ @param[in] PeiServices - General purpose services available to every PEIM.
+
+ @retval EFI_SUCCESS - The PPI is installed and initialized.
+ @retval EFI ERRORS - The PPI is not successfully installed.
+**/
+EFI_STATUS
+SaPeiPolicyInitEntryPoint (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+;
+#endif
diff --git a/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.inf b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.inf
new file mode 100644
index 0000000..175d1ba
--- /dev/null
+++ b/ReferenceCode/Chipset/SystemAgent/SampleCode/SaPolicyInit/Pei/SaPeiPolicyInit.inf
@@ -0,0 +1,95 @@
+## @file
+# Component description file for the SaPeiPolicyInit PEIM.
+#
+#@copyright
+# Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
+# This software and associated documentation (if any) is furnished
+# under a license and may only be used or copied in accordance
+# with the terms of the license. Except as permitted by such
+# license, no part of this software or documentation may be
+# reproduced, stored in a retrieval system, or transmitted in any
+# form or by any means without the express written consent of
+# Intel Corporation.
+#
+# This file contains a 'Sample Driver' and is licensed as such
+# under the terms of your license agreement with Intel or your
+# vendor. This file may be modified by the user, subject to
+# the additional terms of the license agreement
+#
+
+[defines]
+BASE_NAME = SaPeiPolicyInit
+FILE_GUID = FD236AE7-0791-48c4-B29E-29BDEEE1A822
+COMPONENT_TYPE = PE32_PEIM
+
+[sources.common]
+ SaPeiPolicyInit.h
+ SaPeiPolicyInit.c
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGluePeimEntryPoint.c
+
+
+[includes.common]
+ .
+ ../Common
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/Include
+
+#
+# EDK II Glue Library utilizes some standard headers from EDK
+#
+ $(EFI_SOURCE)
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Framework
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(EDK_SOURCE)/Foundation/Include/Pei
+ $(EDK_SOURCE)/Foundation/Library/Pei/Include
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include/Pcd
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/$(PROJECT_SA_MRC)/Pei/Source/Api
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/$(PROJECT_SA_MRC)/Pei/Source/Include
+ $(EFI_SOURCE)/$(PROJECT_SA_ROOT)/$(PROJECT_SA_MRC)/Pei/Source/Include/MrcRegisters
+ $(EFI_SOURCE)/$(PROJECT_CPU_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_CPU_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_CPU_ROOT)/Include/Library
+ $(PLATFORM_ECP_PACKAGE)/Include
+
+[libraries.common]
+ $(PROJECT_PCH_FAMILY)PpiLib
+ EdkFrameworkPpiLib
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGlueBaseMemoryLib
+ EdkIIGluePeiDebugLibReportStatusCode
+ EdkIIGluePeiReportStatusCodeLib
+ EdkIIGluePeiServicesLib
+ EdkIIGluePeiMemoryAllocationLib
+ EdkIIGlueBasePciExpressLib
+ PeiLib
+ $(PROJECT_SA_FAMILY)PpiLib
+ PlatformPolicyUpdatePeiLib
+ CpuPlatformLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = _ModuleEntryPoint
+ DPX_SOURCE = SaPeiPolicyInit.dxs
+#
+# Module Entry Point
+#
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=SaPeiPolicyInitEntryPoint
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ -D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ -D __EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ -D __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__ \
+ -D __EDKII_GLUE_PEI_SERVICES_LIB__ \
+ -D __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__ \
+ -D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \ No newline at end of file