提交 e981bb5c 编写于 作者: V vit9696

OcCpuLib: Support fallback frequency

上级 9cfde530
......@@ -18,6 +18,11 @@
#include <IndustryStandard/CpuId.h>
#include <IndustryStandard/AppleIntelCpuInfo.h>
/**
Assumed CPU frequency when it cannot be detected.
**/
#define OC_FALLBACK_CPU_FREQUENCY 1000000000
typedef struct {
//
// Note, Vendor and BrandString are reordered for proper alignment.
......@@ -182,7 +187,7 @@ OcCpuGetGeneration (
/**
Obtain CPU's invariant TSC frequency.
@retval CPU's TSC frequency.
@retval CPU's TSC frequency or OC_FALLBACK_CPU_FREQUENCY.
**/
UINT64
OcGetTSCFrequency (
......
......@@ -484,6 +484,12 @@ OcGetTSCFrequency (
CPUFrequency = InternalCalculateVMTFrequency (NULL, NULL);
if (CPUFrequency == 0) {
CPUFrequency = InternalCalculateTSCFromPMTimer (FALSE);
if (CPUFrequency == 0) {
//
// Assume at least some frequency, so that we always work.
//
CPUFrequency = OC_FALLBACK_CPU_FREQUENCY;
}
}
}
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册