UefiCpuPkg: Adding a new TSC library by using CPUID(0x15) TSC leaf

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1909

Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Signed-off-by: Donald Kuo <donald.kuo@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
This commit is contained in:
Donald Kuo
2019-08-12 12:34:39 +08:00
committed by Liming Gao
parent 9c90d39b60
commit 30781febe2
13 changed files with 643 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
/** @file
CPUID Leaf 0x15 for Core Crystal Clock frequency instance as Base Timer Library.
Copyright (c) 2019 Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Base.h>
#include <Library/TimerLib.h>
#include <Library/BaseLib.h>
/**
CPUID Leaf 0x15 for Core Crystal Clock Frequency.
The TSC counting frequency is determined by using CPUID leaf 0x15. Frequency in MHz = Core XTAL frequency * EBX/EAX.
In newer flavors of the CPU, core xtal frequency is returned in ECX or 0 if not supported.
@return The number of TSC counts per second.
**/
UINT64
CpuidCoreClockCalculateTscFrequency (
VOID
);
/**
Internal function to retrieves the 64-bit frequency in Hz.
Internal function to retrieves the 64-bit frequency in Hz.
@return The frequency in Hz.
**/
UINT64
InternalGetPerformanceCounterFrequency (
VOID
)
{
return CpuidCoreClockCalculateTscFrequency ();
}