Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
b7734fc3
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b7734fc3
编写于
3月 20, 2019
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix FSBFrequency and thread count detection on Penryn
上级
30fb8799
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
71 addition
and
34 deletion
+71
-34
Include/Library/OcCpuLib.h
Include/Library/OcCpuLib.h
+14
-4
Library/OcCpuLib/OcCpuLib.c
Library/OcCpuLib/OcCpuLib.c
+45
-7
STATUS.md
STATUS.md
+2
-2
Tests/DataHubTest/DataHubTest.c
Tests/DataHubTest/DataHubTest.c
+1
-21
TestsUser/Include/Base.h
TestsUser/Include/Base.h
+9
-0
未找到文件。
Include/Library/OcCpuLib.h
浏览文件 @
b7734fc3
...
...
@@ -47,7 +47,6 @@ typedef struct {
UINT8
CurBusRatio
;
///< Current Multiplier
UINT8
MinBusRatio
;
///< Min Bus Ratio
UINT8
MaxBusRatio
;
///< Max Bus Ratio
UINT8
MaxBusRatioDiv
;
UINT8
TurboBusRatio1
;
UINT8
TurboBusRatio2
;
...
...
@@ -65,14 +64,25 @@ typedef struct {
}
OC_CPU_INFO
;
/
/ OcCpuScanProcessor
/** Scan the processor and fill the cpu info structure with results
/
**
Scan the processor and fill the cpu info structure with results.
@param[in] Cpu A pointer to the cpu info structure to fill with results
@param[in] Cpu A pointer to the cpu info structure to fill with results
.
**/
VOID
OcCpuScanProcessor
(
IN
OUT
OC_CPU_INFO
*
Cpu
);
/**
Disable flex ratio if it has invalid value.
Commonly fixes early reboot on APTIO IV (Ivy/Haswell).
@param[in] Cpu A pointer to the cpu info.
**/
VOID
OcCpuCorrectFlexRatio
(
IN
OC_CPU_INFO
*
Cpu
);
#endif // OC_CPU_LIB_H_
Library/OcCpuLib/OcCpuLib.c
浏览文件 @
b7734fc3
...
...
@@ -587,12 +587,21 @@ ScanIntelProcessor (
//
if
(
Cpu
->
Model
>=
CPU_MODEL_NEHALEM
)
{
PerfStatus
.
Uint64
=
AsmReadMsr64
(
MSR_IA32_PERF_STATUS
);
Cpu
->
CurBusRatio
=
(
UINT8
)
(
PerfStatus
.
Bits
.
State
>>
8U
);
PlatformInfo
.
Uint64
=
AsmReadMsr64
(
MSR_NEHALEM_PLATFORM_INFO
);
Cpu
->
MinBusRatio
=
(
UINT8
)
PlatformInfo
.
Bits
.
MaximumEfficiencyRatio
;
Cpu
->
MaxBusRatio
=
(
UINT8
)
PlatformInfo
.
Bits
.
MaximumNonTurboRatio
;
}
else
if
(
Cpu
->
Model
>=
CPU_MODEL_PENRYN
)
{
PerfStatus
.
Uint64
=
AsmReadMsr64
(
MSR_IA32_PERF_STATUS
);
Cpu
->
MaxBusRatio
=
(
UINT8
)
(
PerfStatus
.
Uint64
>>
8U
)
&
0x1FU
;
//
// Undocumented values:
// Non-integer bus ratio for the max-multi.
// Non-integer bus ratio for the current-multi.
//
// MaxBusRatioDiv = (UINT8)(PerfStatus.Uint64 >> 46U) & 0x01U;
// CurrDiv = (UINT8)(PerfStatus.Uint64 >> 14U) & 0x01U;
//
}
if
(
Cpu
->
Model
>=
CPU_MODEL_NEHALEM
...
...
@@ -659,9 +668,10 @@ ScanIntelProcessor (
));
//
// Both checked to workaround virtual cpu
// There may be some quirks with virtual CPUs (VMware is fine).
// Formerly we checked Cpu->MinBusRatio > 0, but we have no MinBusRatio on Penryn.
//
if
(
Cpu
->
MinBusRatio
>
0
&&
Cpu
->
MaxBusRatio
>
Cpu
->
MinBusRatio
)
{
if
(
Cpu
->
TSCFrequency
>
0
&&
Cpu
->
MaxBusRatio
>
Cpu
->
MinBusRatio
)
{
Cpu
->
FSBFrequency
=
DivU64x32
(
Cpu
->
TSCFrequency
,
Cpu
->
MaxBusRatio
);
Cpu
->
CPUFrequency
=
MultU64x32
(
Cpu
->
FSBFrequency
,
Cpu
->
MaxBusRatio
);
}
else
{
...
...
@@ -699,9 +709,12 @@ ScanIntelProcessor (
CoreCount
*=
2
;
}
Cpu
->
CoreCount
=
CoreCount
;
Cpu
->
ThreadCount
=
Cpu
->
CoreCount
;
if
(
Cpu
->
Features
&
CPUID_FEATURE_HTT
)
{
Cpu
->
ThreadCount
*=
2
;
//
// We should not be blindly relying on Cpu->Features & CPUID_FEATURE_HTT.
// On Penryn CPUs it is set even without Hyper Threading.
//
if
(
Cpu
->
ThreadCount
<
Cpu
->
CoreCount
)
{
Cpu
->
ThreadCount
=
Cpu
->
CoreCount
;
}
}
}
else
if
(
Cpu
->
Model
==
CPU_MODEL_WESTMERE
)
{
...
...
@@ -847,3 +860,28 @@ OcCpuScanProcessor (
ScanIntelProcessor
(
Cpu
);
}
}
VOID
OcCpuCorrectFlexRatio
(
IN
OC_CPU_INFO
*
Cpu
)
{
UINT64
Msr
;
UINT64
FlexRatio
;
if
(
Cpu
->
Vendor
[
0
]
==
CPUID_VENDOR_INTEL
&&
Cpu
->
Model
!=
CPU_MODEL_GOLDMONT
&&
Cpu
->
Model
!=
CPU_MODEL_AIRMONT
&&
Cpu
->
Model
!=
CPU_MODEL_AVOTON
)
{
Msr
=
AsmReadMsr64
(
MSR_FLEX_RATIO
);
if
(
Msr
&
FLEX_RATIO_EN
)
{
FlexRatio
=
BitFieldRead64
(
Msr
,
8
,
15
);
if
(
FlexRatio
==
0
)
{
//
// Disable Flex Ratio if current value is 0.
//
AsmWriteMsr64
(
MSR_FLEX_RATIO
,
Msr
&
~
((
UINT64
)
FLEX_RATIO_EN
));
}
}
}
}
STATUS.md
浏览文件 @
b7734fc3
...
...
@@ -18,7 +18,8 @@ listed here.
1.
No dmg boot detection.
*
OcAppleKernelLib
**Status**
: functional
**Issues**
: none
**Issues**
:
1.
No executable kext injection.
*
OcCompressionLib
**Status**
: functional
**Issues**
: none
...
...
@@ -36,7 +37,6 @@ listed here.
1.
No package count detection.
1.
No AMD CPU support.
1.
Apple processor type detection is incomplete.
1.
FSBFrequency calculation is sometimes incorrect, e.g. for Core 2 Quad Q9450.
*
OcCryptoLib
**Status**
: functional
**Issues**
: none
...
...
Tests/DataHubTest/DataHubTest.c
浏览文件 @
b7734fc3
...
...
@@ -132,27 +132,7 @@ TestDataHub (
gBS
->
SetWatchdogTimer
(
0
,
0
,
0
,
NULL
);
//TODO: put this elsewhere, fixes early reboot on APTIO IV (Ivy/Haswell).
{
UINT64
Msr
;
UINT64
FlexRatio
;
if
(
CpuInfo
.
Vendor
[
0
]
==
CPUID_VENDOR_INTEL
&&
CpuInfo
.
Model
!=
CPU_MODEL_GOLDMONT
&&
CpuInfo
.
Model
!=
CPU_MODEL_AIRMONT
&&
CpuInfo
.
Model
!=
CPU_MODEL_AVOTON
)
{
Msr
=
AsmReadMsr64
(
MSR_FLEX_RATIO
);
if
(
Msr
&
FLEX_RATIO_EN
)
{
FlexRatio
=
BitFieldRead64
(
Msr
,
8
,
15
);
if
(
FlexRatio
==
0
)
{
//
// Disable Flex Ratio if current value is 0.
//
AsmWriteMsr64
(
MSR_FLEX_RATIO
,
Msr
&
~
((
UINT64
)
FLEX_RATIO_EN
));
}
}
}
}
OcCpuCorrectFlexRatio
(
&
CpuInfo
);
return
EFI_SUCCESS
;
}
...
...
TestsUser/Include/Base.h
浏览文件 @
b7734fc3
...
...
@@ -696,6 +696,15 @@ AsmReadMsr64 (
return
0
;
}
STATIC
VOID
AsmWriteMsr64
(
UINT32
Index
,
UINT64
Value
)
{
}
STATIC
UINT64
EFIAPI
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录