Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
6f914f98
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,发现更多精彩内容 >>
提交
6f914f98
编写于
3月 12, 2021
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Utilities: Let CPU decoder be tested externally
上级
c6f4de9e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
113 addition
and
25 deletion
+113
-25
.gitignore
.gitignore
+1
-0
Include/Acidanthera/Library/OcCpuLib.h
Include/Acidanthera/Library/OcCpuLib.h
+13
-0
Library/OcCpuLib/AppleCpuSupport.c
Library/OcCpuLib/AppleCpuSupport.c
+28
-0
Library/OcSmbiosLib/SmbiosPatch.c
Library/OcSmbiosLib/SmbiosPatch.c
+1
-25
Utilities/TestCpuFrequency/CpuFrequency.c
Utilities/TestCpuFrequency/CpuFrequency.c
+59
-0
Utilities/TestCpuFrequency/Makefile
Utilities/TestCpuFrequency/Makefile
+10
-0
build_oc.tool
build_oc.tool
+1
-0
未找到文件。
.gitignore
浏览文件 @
6f914f98
...
...
@@ -18,6 +18,7 @@ Utilities/ocvalidate/ocvalidate
Utilities/LogoutHook/nvramdump
Utilities/RsaTool/RsaTool
Utilities/TestBmf/Bmf
Utilities/TestCpuFrequency/CpuFrequency
Utilities/TestDiskImage/DiskImage
Utilities/TestHelloWorld/HelloWorld
Utilities/TestImg4/Img4
...
...
Include/Acidanthera/Library/OcCpuLib.h
浏览文件 @
6f914f98
...
...
@@ -211,6 +211,19 @@ OcCpuModelToAppleFamily (
IN
CPUID_VERSION_INFO_EAX
VersionEax
);
/**
Converts calculated CPU frequency in Hz to rounded
value in MHz.
@param[in] Frequency CPU frequency in Hz.
@return Rounded CPU frequency in MHz.
**/
UINT16
OcCpuFrequencyToDisplayFrequency
(
IN
UINT64
Frequency
);
/**
Obtain CPU's invariant TSC frequency.
...
...
Library/OcCpuLib/AppleCpuSupport.c
浏览文件 @
6f914f98
...
...
@@ -658,3 +658,31 @@ OcCpuModelToAppleFamily (
return
CPUFAMILY_UNKNOWN
;
}
}
UINT16
OcCpuFrequencyToDisplayFrequency
(
IN
UINT64
Frequency
)
{
UINT16
MhzSpeed
;
UINT16
MhzRemainder
;
//
// Round to nearest in MHz
//
MhzSpeed
=
(
UINT16
)
DivU64x32
(
Frequency
+
500000
,
1000000
);
MhzRemainder
=
MhzSpeed
%
100
;
//
// Round to two digits when the second digit is above zero or to one otherwise.
// REF: https://github.com/acidanthera/bugtracker/issues/1521
//
if
(
MhzRemainder
>=
60
&&
MhzRemainder
<
90
)
{
MhzSpeed
=
(
MhzSpeed
)
/
10
*
10
;
}
else
if
(
MhzRemainder
>=
12
&&
MhzRemainder
<
90
)
{
MhzSpeed
=
(
MhzSpeed
+
5
)
/
10
*
10
;
}
else
{
MhzSpeed
=
(
MhzSpeed
+
50
)
/
100
*
100
;
}
return
MhzSpeed
;
}
Library/OcSmbiosLib/SmbiosPatch.c
浏览文件 @
6f914f98
...
...
@@ -388,7 +388,6 @@ PatchProcessorInformation (
UINT8
StringIndex
;
UINT8
TmpCount
;
UINT16
MhzSpeed
;
UINT16
MhzRemainder
;
Original
=
SmbiosGetOriginalStructure
(
SMBIOS_TYPE_PROCESSOR_INFORMATION
,
1
);
MinLength
=
sizeof
(
*
Original
.
Standard
.
Type4
);
...
...
@@ -407,30 +406,7 @@ PatchProcessorInformation (
SMBIOS_OVERRIDE_V
(
Table
,
Standard
.
Type4
->
Voltage
,
Original
,
NULL
,
NULL
);
Table
->
CurrentPtr
.
Standard
.
Type4
->
ExternalClock
=
CpuInfo
->
ExternalClock
;
//
// Round to nearest in MHz
//
MhzSpeed
=
(
UINT16
)
DivU64x32
(
CpuInfo
->
CPUFrequency
+
500000
,
1000000
);
MhzRemainder
=
MhzSpeed
%
100
;
//
// Round to two digits when the second digit is above zero or to one otherwise.
// REF: https://github.com/acidanthera/bugtracker/issues/1521
// 3506084610 Hz -> 3506 MHz i7 4770k (3.5)
// 3324999575 Hz -> 3325 MHz Xeon X5680 (3.33)
// 3324999977 Hz -> 3325 MHz Xeon X5680 (3.33)
// 3457999888 Hz -> 3458 MHz Xeon X5690 (3.46)
// 2666362112 Hz -> 2666 MHz C2Q Q9450 (2.66)
// 3058999712 Hz -> 3059 MHz Xeon X5675 (3.06)
// 1992617296 Hz -> 1993 MHz i7 2630QM (2.0)
// 3010680273 Hz -> 3011 MHz P4 530 (3.0)
//
if
(
MhzRemainder
>=
60
&&
MhzRemainder
<
90
)
{
MhzSpeed
=
(
MhzSpeed
)
/
10
*
10
;
}
else
if
(
MhzRemainder
>=
12
&&
MhzRemainder
<
90
)
{
MhzSpeed
=
(
MhzSpeed
+
5
)
/
10
*
10
;
}
else
{
MhzSpeed
=
(
MhzSpeed
+
50
)
/
100
*
100
;
}
MhzSpeed
=
OcCpuFrequencyToDisplayFrequency
(
CpuInfo
->
CPUFrequency
);
DEBUG
((
DEBUG_INFO
,
"OCSMB: CPU display frequency is %uMHz
\n
"
,
MhzSpeed
));
...
...
Utilities/TestCpuFrequency/CpuFrequency.c
0 → 100644
浏览文件 @
6f914f98
/** @file
Copyright (C) 2021, vit9696. All rights reserved.
All rights reserved.
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.
**/
#include <Library/OcCpuLib.h>
#include <Library/DebugLib.h>
#include <sys/time.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
typedef
struct
FREQUENCY_TEST_
{
UINT64
FrequencyHz
;
UINT16
FrequencyMHz
;
CONST
CHAR8
*
Model
;
}
FREQUENCY_TEST
;
int
main
()
{
STATIC
FREQUENCY_TEST
mTests
[]
=
{
{
3506084610
/* Hz */
,
3500
/* MHz, Raw 3506 MHz */
,
"i7 4770K"
},
{
3324999575
/* Hz */
,
3330
/* MHz, Raw 3325 MHz */
,
"Xeon X5680"
},
{
3324999977
/* Hz */
,
3330
/* MHz, Raw 3325 MHz */
,
"Xeon X5680"
},
{
3457999888
/* Hz */
,
3460
/* MHz, Raw 3458 MHz */
,
"Xeon X5690"
},
{
2666362112
/* Hz */
,
2660
/* MHz, Raw 2666 MHz */
,
"C2Q Q9450"
},
{
3058999712
/* Hz */
,
3060
/* MHz, Raw 3059 MHz */
,
"Xeon X5675"
},
{
1992617296
/* Hz */
,
2000
/* MHz, Raw 1993 MHz */
,
"i7 2630QM"
},
{
3010680273
/* Hz */
,
3000
/* MHz, Raw 3011 MHz */
,
"P4 530"
},
};
int
code
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
mTests
)
/
sizeof
(
mTests
[
0
]);
++
i
)
{
UINT16
Read
=
OcCpuFrequencyToDisplayFrequency
(
mTests
[
i
].
FrequencyHz
);
if
(
Read
!=
mTests
[
i
].
FrequencyMHz
)
{
DEBUG
((
DEBUG_WARN
,
"Frequency %04u instead if %04u for %a
\n
"
,
Read
,
mTests
[
i
].
FrequencyMHz
,
mTests
[
i
].
Model
));
code
=
1
;
}
}
return
code
;
}
Utilities/TestCpuFrequency/Makefile
0 → 100644
浏览文件 @
6f914f98
## @file
# Copyright (c) 2020, PMheart. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
##
PROJECT
=
CpuFrequency
PRODUCT
=
$(PROJECT)$(SUFFIX)
OBJS
=
$(PROJECT)
.o
include
../../User/Makefile
build_oc.tool
浏览文件 @
6f914f98
...
...
@@ -12,6 +12,7 @@ buildutil() {
"ocpasswordgen"
"ocvalidate"
"TestBmf"
"TestCpuFrequency"
"TestDiskImage"
"TestHelloWorld"
"TestImg4"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录