summaryrefslogtreecommitdiff
path: root/Vlv2TbltDevicePkg/PpmPolicy
diff options
context:
space:
mode:
authorDavid Wei <david.wei@intel.com>2015-01-12 09:37:20 +0000
committerzwei4 <zwei4@Edk2>2015-01-12 09:37:20 +0000
commit3cbfba02fef9dae07a041fdbf2e89611d72d6f90 (patch)
tree0b3bf0783124d38a191e09736492c0141aa36c15 /Vlv2TbltDevicePkg/PpmPolicy
parent6f785cfcc304c48ec04e542ee429df95e7b51bc5 (diff)
downloadedk2-platforms-3cbfba02fef9dae07a041fdbf2e89611d72d6f90.tar.xz
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
https://svn.code.sf.net/p/edk2/code/trunk/edk2/, which are for MinnowBoard MAX open source project. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: David Wei <david.wei@intel.com> Reviewed-by: Mike Wu <mike.wu@intel.com> Reviewed-by: Hot Tian <hot.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16599 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Vlv2TbltDevicePkg/PpmPolicy')
-rw-r--r--Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.c160
-rw-r--r--Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.h46
-rw-r--r--Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.inf55
3 files changed, 261 insertions, 0 deletions
diff --git a/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.c b/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.c
new file mode 100644
index 0000000000..2f8996bc1a
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.c
@@ -0,0 +1,160 @@
+/**
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+
+ PpmPolicy.c
+
+Abstract:
+
+ This file is a wrapper for Intel PPM Platform Policy driver.
+ Get Setup Value to initilize Intel PPM DXE Platform Policy.
+
+--*/
+#include "PpmPolicy.h"
+#include <Protocol/MpService.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/CpuIA32.h>
+
+#include <PchRegs.h>
+#include <Library/PchPlatformLib.h>
+
+#define EFI_CPUID_FAMILY 0x0F00
+#define EFI_CPUID_MODEL 0x00F0
+#define EFI_CPUID_STEPPING 0x000F
+
+
+
+EFI_STATUS
+EFIAPI
+PpmPolicyEntry(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+)
+{
+ EFI_MP_SERVICES_PROTOCOL *MpService;
+ EFI_CPUID_REGISTER Cpuid01 = { 0, 0, 0, 0};
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN CpuCount;
+ UINT64 MaxRatio;
+ UINT8 CPUMobileFeature;
+
+ PCH_STEPPING Stepping;
+
+
+ gBS = SystemTable->BootServices;
+ pBS = SystemTable->BootServices;
+ pRS = SystemTable->RuntimeServices;
+
+ //
+ // Set PPM policy structure to known value
+ //
+ gBS->SetMem (&mDxePlatformPpmPolicy, sizeof(PPM_PLATFORM_POLICY_PROTOCOL), 0);
+
+ //
+ // Find the MpService Protocol
+ //
+ Status = pBS->LocateProtocol (&gEfiMpServiceProtocolGuid,
+ NULL,
+ (void **)&MpService
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get processor count from MP service.
+ //
+ Status = MpService->GetNumberOfProcessors (MpService, &CpuCount, NULL);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Store the CPUID for use by SETUP items.
+ //
+ AsmCpuid (EFI_CPUID_VERSION_INFO, &Cpuid01.RegEax, &Cpuid01.RegEbx, &Cpuid01.RegEcx, &Cpuid01.RegEdx);
+ MaxRatio = ((RShiftU64 (AsmReadMsr64(EFI_MSR_IA32_PLATFORM_ID), 8)) & 0x1F);
+
+
+ mDxePlatformPpmPolicy.Revision = PPM_PLATFORM_POLICY_PROTOCOL_REVISION_4;
+
+ //Read CPU Mobile feature from PLATFORM_ID_MSR MSR(0x17) NOTFB_I_AM_NOT_MOBILE_FUSE_CLIAMC00H Bit 28
+ //Bit Description: { Disables Mobile features 0 = I am NOT a mobile part 1 = I am a mobile part (default)"}
+ CPUMobileFeature = ((RShiftU64 (AsmReadMsr64(EFI_MSR_IA32_PLATFORM_ID), 28)) & 0x1);
+
+ if (!EFI_ERROR(Status)) {
+ if (CPUMobileFeature == 1){//CPU mobile feature
+ mDxePlatformPpmPolicy.FunctionEnables.EnableGv = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCx = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCxe = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTm = ICH_DEVICE_ENABLE;
+ //MaxC7
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC7 = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC6 = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC4 = ICH_DEVICE_ENABLE;
+
+
+ }else{//CPU desktop feature
+ mDxePlatformPpmPolicy.FunctionEnables.EnableGv = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCx = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCxe = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTm = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC4 = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC6 = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC7 = ICH_DEVICE_DISABLE;
+ }
+
+
+ mDxePlatformPpmPolicy.FunctionEnables.EnableProcHot = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.TStatesEnable = ICH_DEVICE_ENABLE;
+
+
+ Stepping = PchStepping();
+ if (Stepping < PchB3) {
+ // If SoC is B0~B2 Stepping, disable the Turbo
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTurboMode= ICH_DEVICE_DISABLE;
+ } else {
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTurboMode= ICH_DEVICE_ENABLE;
+ }
+
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTm = ICH_DEVICE_ENABLE;
+
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCMP = ICH_DEVICE_ENABLE;
+
+ } else {
+ mDxePlatformPpmPolicy.FunctionEnables.EnableGv = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCx = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCxe = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTm = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableProcHot = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableCMP = ICH_DEVICE_DISABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.TStatesEnable = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableTurboMode= ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC4 = ICH_DEVICE_ENABLE;
+ mDxePlatformPpmPolicy.FunctionEnables.EnableC6 = ICH_DEVICE_ENABLE;
+ }
+
+
+
+ mDxePlatformPpmPolicy.S3RestoreMsrSwSmiNumber = S3_RESTORE_MSR_SW_SMI;
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gPpmPlatformPolicyProtocolGuid,
+ &mDxePlatformPpmPolicy,
+ NULL
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
diff --git a/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.h b/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.h
new file mode 100644
index 0000000000..cd3676b3d8
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.h
@@ -0,0 +1,46 @@
+/**
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+
+Module Name:
+
+ PpmPolicy.h
+
+Abstract:
+
+ Header file for the PpmPolicyInitDxe Driver.
+
+--*/
+#include <PiDxe.h>
+//
+// Driver Produced Protocol Prototypes
+//
+#include <Protocol/PpmPlatformPolicy.h>
+
+PPM_PLATFORM_POLICY_PROTOCOL mDxePlatformPpmPolicy;
+
+// Function Definition
+#define ICH_DEVICE_ENABLE 1
+#define ICH_DEVICE_DISABLE 0
+
+EFI_BOOT_SERVICES *gBS;
+EFI_BOOT_SERVICES *pBS;
+EFI_RUNTIME_SERVICES *pRS;
+
+#define POWER_STATE_SWITCH_SMI 43
+#define ENABLE_C_STATE_IO_REDIRECTION_SMI 70
+#define DISABLE_C_STATE_IO_REDIRECTION_SMI 71
+#define ENABLE_SMI_C_STATE_COORDINATION_SMI 72
+#define DISABLE_SMI_C_STATE_COORDINATION_SMI 73
+#define ENABLE_P_STATE_HARDWARE_COORDINATION_SMI 74
+#define DISABLE_P_STATE_HARDWARE_COORDINATION_SMI 75
+#define S3_RESTORE_MSR_SW_SMI 48
+#define ENABLE_C6_RESIDENCY_SMI 76 \ No newline at end of file
diff --git a/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.inf b/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.inf
new file mode 100644
index 0000000000..c5c6076a26
--- /dev/null
+++ b/Vlv2TbltDevicePkg/PpmPolicy/PpmPolicy.inf
@@ -0,0 +1,55 @@
+#/*++
+#
+# Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License that accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+# Module Name:
+#
+# PpmPolicy.inf
+#
+# Abstract:
+#
+# Implement platform power management policy
+#
+#--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PpmPolicy
+ FILE_GUID = 2EE72E7C-FB9E-4318-B888-33A315C7A91D
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PpmPolicyEntry
+
+[Sources]
+ PpmPolicy.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ Vlv2TbltDevicePkg/PlatformPkg.dec
+ IA32FamilyCpuPkg/IA32FamilyCpuPkg.dec #CpuConfigLib.h
+ Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseLib
+ PchPlatformLib
+ UefiDriverEntryPoint
+
+[Protocols]
+ gEfiMpServiceProtocolGuid
+ gPpmPlatformPolicyProtocolGuid
+
+[Guids]
+ gEfiSetupVariableGuid
+
+[Depex]
+ gEfiMpServiceProtocolGuid