Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
ca8046be
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,发现更多精彩内容 >>
未验证
提交
ca8046be
编写于
3月 12, 2021
作者:
P
PMheart
提交者:
GitHub
3月 12, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcCpuLib: Implement TSC frequency reading from Apple Platform Info (#233)
上级
46e0528d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
474 addition
and
43 deletion
+474
-43
Include/Acidanthera/Library/OcCpuLib.h
Include/Acidanthera/Library/OcCpuLib.h
+6
-0
Include/Acidanthera/Library/OcMiscLib.h
Include/Acidanthera/Library/OcMiscLib.h
+39
-0
Library/OcCpuLib/FrequencyDetect.c
Library/OcCpuLib/FrequencyDetect.c
+80
-5
Library/OcCpuLib/OcCpuInternals.h
Library/OcCpuLib/OcCpuInternals.h
+26
-0
Library/OcCpuLib/OcCpuLib.c
Library/OcCpuLib/OcCpuLib.c
+128
-23
Library/OcCpuLib/OcCpuLib.inf
Library/OcCpuLib/OcCpuLib.inf
+3
-0
Library/OcMiscLib/OcMiscLib.inf
Library/OcMiscLib/OcMiscLib.inf
+2
-0
Library/OcMiscLib/PlatformInfo.c
Library/OcMiscLib/PlatformInfo.c
+160
-0
User/Include/UserGlobalVar.h
User/Include/UserGlobalVar.h
+4
-1
User/Library/UserGlobalVar.c
User/Library/UserGlobalVar.c
+16
-13
User/Library/UserMisc.c
User/Library/UserMisc.c
+9
-0
User/Makefile
User/Makefile
+1
-1
未找到文件。
Include/Acidanthera/Library/OcCpuLib.h
浏览文件 @
ca8046be
...
...
@@ -138,6 +138,12 @@ typedef struct {
//
UINT64
TscAdjust
;
//
// The CPU frequency derived from Apple Platform Info.
// 0 if Apple Platform Info is not present.
//
UINT64
CPUFrequencyFromApple
;
//
// The CPU frequency derived from the CPUID VMWare Timing leaf.
// 0 if VMWare Timing leaf is not present.
...
...
Include/Acidanthera/Library/OcMiscLib.h
浏览文件 @
ca8046be
...
...
@@ -17,6 +17,7 @@
#include <Uefi.h>
#include <Library/OcStringLib.h>
#include <Protocol/ApplePlatformInfoDatabase.h>
/**
The size, in Bits, of one Byte.
...
...
@@ -122,6 +123,44 @@ OcLoadAndRunImage (
OUT
EFI_HANDLE
*
ImageHandle
OPTIONAL
);
/**
Read first data from Apple Platform Info protocol.
@param[in] PlatformInfo Apple Platform Info protocol.
@param[in] DataGuid Resource GUID identifier.
@param[in,out] Size Maximum size allowed.
@param[out] Data Data read from Apple Platform Info protocol.
@retval EFI_SUCCESS on success.
**/
EFI_STATUS
OcReadApplePlatformFirstData
(
IN
APPLE_PLATFORM_INFO_DATABASE_PROTOCOL
*
PlatformInfo
,
IN
EFI_GUID
*
DataGuid
,
IN
OUT
UINT32
*
Size
,
OUT
VOID
*
Data
);
/**
Read data from Apple Platform Info protocol.
@param[in] PlatformInfo Apple Platform Info protocol.
@param[in] DataGuid Resource GUID identifier.
@param[in] HobGuid Hob GUID identifier.
@param[in,out] Size Maximum size allowed.
@param[out] Data Data read from Apple Platform Info protocol.
@retval EFI_SUCCESS on success.
**/
EFI_STATUS
OcReadApplePlatformData
(
IN
APPLE_PLATFORM_INFO_DATABASE_PROTOCOL
*
PlatformInfo
,
IN
EFI_GUID
*
DataGuid
,
IN
EFI_GUID
*
HobGuid
,
IN
OUT
UINT32
*
Size
,
OUT
VOID
*
Data
);
/**
Internal worker macro that calls DebugPrint().
...
...
Library/OcCpuLib/FrequencyDetect.c
浏览文件 @
ca8046be
...
...
@@ -24,6 +24,7 @@
#include <Library/IoLib.h>
#include <Library/OcCpuLib.h>
#include <Library/PciLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcGuardLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
...
...
@@ -225,6 +226,77 @@ InternalCalculateTSCFromPMTimer (
return
TSCFrequency
;
}
UINT64
InternalCalculateTSCFromApplePlatformInfo
(
OUT
UINT64
*
FSBFrequency
OPTIONAL
,
IN
BOOLEAN
Recalculate
)
{
//
// Cache the result to speed up multiple calls.
//
STATIC
BOOLEAN
ObtainedFreqs
=
FALSE
;
STATIC
UINT64
FsbFreq
=
0
;
STATIC
UINT64
TscFreq
=
0
;
EFI_STATUS
Status
;
APPLE_PLATFORM_INFO_DATABASE_PROTOCOL
*
PlatformInfo
;
UINT32
Size
;
if
(
Recalculate
)
{
ObtainedFreqs
=
FALSE
;
FsbFreq
=
0
;
TscFreq
=
0
;
}
if
(
!
ObtainedFreqs
)
{
ObtainedFreqs
=
TRUE
;
Size
=
sizeof
(
FsbFreq
);
Status
=
gBS
->
LocateProtocol
(
&
gApplePlatformInfoDatabaseProtocolGuid
,
NULL
,
(
VOID
**
)
&
PlatformInfo
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_VERBOSE
,
"OCCPU: Failed to locate ApplePlatformInfo protocol - %r
\n
"
,
Status
));
return
0
;
}
Status
=
OcReadApplePlatformFirstData
(
PlatformInfo
,
&
gAppleFsbFrequencyPlatformInfoGuid
,
&
Size
,
&
FsbFreq
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: Failed to get FSBFrequency first data - %r, trying HOB method
\n
"
,
Status
));
Status
=
OcReadApplePlatformData
(
PlatformInfo
,
&
gAppleFsbFrequencyPlatformInfoGuid
,
&
gAppleFsbFrequencyPlatformInfoIndexHobGuid
,
&
Size
,
&
FsbFreq
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: Failed to get FSBFrequency data using HOB method - %r
\n
"
,
Status
));
return
0
;
}
}
TscFreq
=
InternalConvertAppleFSBToTSCFrequency
(
FsbFreq
);
}
//
// Optionally update FSBFrequency.
//
if
(
FSBFrequency
!=
NULL
)
{
*
FSBFrequency
=
FsbFreq
;
}
return
TscFreq
;
}
UINT64
InternalCalculateARTFrequencyIntel
(
OUT
UINT64
*
CPUFrequency
,
...
...
@@ -488,12 +560,15 @@ OcGetTSCFrequency (
if
(
CPUFrequency
==
0
)
{
CPUFrequency
=
InternalCalculateVMTFrequency
(
NULL
,
NULL
);
if
(
CPUFrequency
==
0
)
{
CPUFrequency
=
InternalCalculateTSCFrom
PMTimer
(
FALSE
);
CPUFrequency
=
InternalCalculateTSCFrom
ApplePlatformInfo
(
NULL
,
FALSE
);
if
(
CPUFrequency
==
0
)
{
//
// Assume at least some frequency, so that we always work.
//
CPUFrequency
=
OC_FALLBACK_CPU_FREQUENCY
;
CPUFrequency
=
InternalCalculateTSCFromPMTimer
(
FALSE
);
if
(
CPUFrequency
==
0
)
{
//
// Assume at least some frequency, so that we always work.
//
CPUFrequency
=
OC_FALLBACK_CPU_FREQUENCY
;
}
}
}
}
...
...
Library/OcCpuLib/OcCpuInternals.h
浏览文件 @
ca8046be
...
...
@@ -129,6 +129,20 @@ InternalCalculateTSCFromPMTimer (
IN
BOOLEAN
Recalculate
);
/**
Calculate the TSC frequency via Apple Platform Info
@param[out] FSBFrequency Updated FSB frequency, optional.
@param[in] Recalculate Do not re-use previously cached information.
@retval The calculated TSC frequency.
**/
UINT64
InternalCalculateTSCFromApplePlatformInfo
(
OUT
UINT64
*
FSBFrequency
OPTIONAL
,
IN
BOOLEAN
Recalculate
);
/**
Calculate the ART frequency and derieve the CPU frequency for Intel CPUs
...
...
@@ -159,6 +173,18 @@ InternalCalculateVMTFrequency (
OUT
BOOLEAN
*
UnderHypervisor
OPTIONAL
);
/**
Convert Apple FSB frequency to TSC frequency
@param[in] FSBFrequency Frequency in Apple FSB format.
@retval Converted TSC frequency.
**/
UINT64
InternalConvertAppleFSBToTSCFrequency
(
IN
UINT64
FSBFrequency
);
/**
Atomically increment 32-bit integer.
This is required to be locally implemented as we cannot use SynchronizationLib,
...
...
Library/OcCpuLib/OcCpuLib.c
浏览文件 @
ca8046be
...
...
@@ -273,38 +273,87 @@ ScanThreadCount (
STATIC
VOID
ScanIntelFSBFrequency
(
IN
OC_CPU_INFO
*
CpuInfo
SetMaxBusRatioAndMaxBusRatioDiv
(
IN
OC_CPU_INFO
*
CpuInfo
OPTIONAL
,
OUT
UINT8
*
MaxBusRatio
,
OUT
UINT8
*
MaxBusRatioDiv
)
{
MSR_IA32_PERF_STATUS_REGISTER
PerfStatus
;
MSR_NEHALEM_PLATFORM_INFO_REGISTER
PlatformInfo
;
UINT8
MaxBusRatio
;
UINT8
MaxBusRatioDiv
;
CPUID_VERSION_INFO_EAX
Eax
;
UINT8
CpuModel
;
ASSERT
(
MaxBusRatio
!=
NULL
);
ASSERT
(
MaxBusRatioDiv
!=
NULL
);
if
(
CpuInfo
!=
NULL
)
{
CpuModel
=
CpuInfo
->
Model
;
}
else
{
//
// Assuming Intel machines used on Apple hardware.
//
AsmCpuid
(
CPUID_VERSION_INFO
,
&
Eax
.
Uint32
,
NULL
,
NULL
,
NULL
);
CpuModel
=
(
UINT8
)
Eax
.
Bits
.
Model
|
(
UINT8
)
(
Eax
.
Bits
.
ExtendedModelId
<<
4U
);
}
//
// TODO: this may not be accurate on some older processors.
//
if
(
Cpu
Info
->
CpuGeneration
>=
OcCpuGenerationNehalem
)
{
if
(
Cpu
Model
>=
CPU_MODEL_NEHALEM
)
{
PlatformInfo
.
Uint64
=
AsmReadMsr64
(
MSR_NEHALEM_PLATFORM_INFO
);
MaxBusRatio
=
(
UINT8
)
PlatformInfo
.
Bits
.
MaximumNonTurboRatio
;
MaxBusRatioDiv
=
0
;
*
MaxBusRatio
=
(
UINT8
)
PlatformInfo
.
Bits
.
MaximumNonTurboRatio
;
*
MaxBusRatioDiv
=
0
;
}
else
{
PerfStatus
.
Uint64
=
AsmReadMsr64
(
MSR_IA32_PERF_STATUS
);
MaxBusRatio
=
(
UINT8
)
(
RShiftU64
(
PerfStatus
.
Uint64
,
8
)
&
0x1FU
);
*
MaxBusRatio
=
(
UINT8
)
(
RShiftU64
(
PerfStatus
.
Uint64
,
8
)
&
0x1FU
);
//
// Undocumented values:
// Non-integer bus ratio for the max-multi.
// Non-integer bus ratio for the current-multi.
//
MaxBusRatioDiv
=
(
UINT8
)
(
RShiftU64
(
PerfStatus
.
Uint64
,
46
)
&
BIT0
);
*
MaxBusRatioDiv
=
(
UINT8
)
(
RShiftU64
(
PerfStatus
.
Uint64
,
46
)
&
BIT0
);
}
//
// Fall back to 1 if *MaxBusRatio has zero.
//
if
(
*
MaxBusRatio
==
0
)
{
*
MaxBusRatio
=
1
;
}
}
STATIC
VOID
ScanIntelFSBFrequency
(
IN
OC_CPU_INFO
*
CpuInfo
)
{
UINT8
MaxBusRatio
;
UINT8
MaxBusRatioDiv
;
ASSERT
(
CpuInfo
!=
NULL
);
//
// Do not reset if CpuInfo->FSBFrequency is already set.
//
if
(
CpuInfo
->
FSBFrequency
>
0
)
{
return
;
}
SetMaxBusRatioAndMaxBusRatioDiv
(
CpuInfo
,
&
MaxBusRatio
,
&
MaxBusRatioDiv
);
//
// There may be some quirks with virtual CPUs (VMware is fine).
// Formerly we checked Cpu->MinBusRatio > 0,
but we have no MinBusRatio on Penryn
.
// Formerly we checked Cpu->MinBusRatio > 0,
and MaxBusRatio falls back to 1 if it is 0
.
//
if
(
CpuInfo
->
CPUFrequency
>
0
&&
MaxBusRatio
>
0
)
{
if
(
CpuInfo
->
CPUFrequency
>
0
)
{
if
(
MaxBusRatioDiv
==
0
)
{
CpuInfo
->
FSBFrequency
=
DivU64x32
(
CpuInfo
->
CPUFrequency
,
MaxBusRatio
);
}
else
{
...
...
@@ -334,6 +383,25 @@ ScanIntelFSBFrequency (
));
}
UINT64
InternalConvertAppleFSBToTSCFrequency
(
IN
UINT64
FSBFrequency
)
{
UINT8
MaxBusRatio
;
UINT8
MaxBusRatioDiv
;
SetMaxBusRatioAndMaxBusRatioDiv
(
NULL
,
&
MaxBusRatio
,
&
MaxBusRatioDiv
);
//
// When MaxBusRatioDiv is 1, the multiplier is MaxBusRatio + 0.5.
//
if
(
MaxBusRatioDiv
==
1
)
{
return
FSBFrequency
*
MaxBusRatio
+
FSBFrequency
/
2
;
}
return
FSBFrequency
*
MaxBusRatio
;
}
STATIC
VOID
ScanIntelProcessorApple
(
...
...
@@ -344,12 +412,12 @@ ScanIntelProcessorApple (
AppleMajorType
=
InternalDetectAppleMajorType
(
Cpu
->
BrandString
);
Cpu
->
AppleProcessorType
=
InternalDetectAppleProcessorType
(
Cpu
->
Model
,
Cpu
->
Stepping
,
AppleMajorType
,
Cpu
->
CoreCount
,
(
Cpu
->
ExtFeatures
&
CPUID_EXTFEATURE_EM64T
)
!=
0
);
Cpu
->
Model
,
Cpu
->
Stepping
,
AppleMajorType
,
Cpu
->
CoreCount
,
(
Cpu
->
ExtFeatures
&
CPUID_EXTFEATURE_EM64T
)
!=
0
);
DEBUG
((
DEBUG_INFO
,
"OCCPU: Detected Apple Processor Type: %02X -> %04X
\n
"
,
AppleMajorType
,
Cpu
->
AppleProcessorType
));
}
...
...
@@ -424,16 +492,33 @@ ScanIntelProcessor (
TimerAddr
=
InternalGetPmTimerAddr
(
&
TimerSourceType
);
DEBUG
((
DEBUG_INFO
,
"OCCPU: Timer address is %Lx from %a
\n
"
,
(
UINT64
)
TimerAddr
,
TimerSourceType
));
DEBUG_CODE_END
();
Cpu
->
CPUFrequencyFromTSC
=
InternalCalculateTSCFromPMTimer
(
Recalculate
);
Cpu
->
CPUFrequencyFromApple
=
InternalCalculateTSCFromApplePlatformInfo
(
NULL
,
Recalculate
);
if
(
Cpu
->
CPUFrequencyFromApple
==
0
||
Recalculate
)
{
Cpu
->
CPUFrequencyFromTSC
=
InternalCalculateTSCFromPMTimer
(
Recalculate
);
}
}
//
// Calculate CPU frequency
based on ART if present, otherwise TSC
// Calculate CPU frequency
firstly based on ART if present.
//
Cpu
->
CPUFrequency
=
Cpu
->
CPUFrequencyFromART
!=
0
?
Cpu
->
CPUFrequencyFromART
:
Cpu
->
CPUFrequencyFromTSC
;
if
(
Cpu
->
CPUFrequencyFromART
!=
0
)
{
Cpu
->
CPUFrequency
=
Cpu
->
CPUFrequencyFromART
;
}
else
{
//
// If ART is not available, then try the value from Apple Platform Info.
//
if
(
Cpu
->
CPUFrequencyFromApple
!=
0
)
{
Cpu
->
CPUFrequency
=
Cpu
->
CPUFrequencyFromApple
;
}
else
{
//
// If still not available, finally use TSC.
//
Cpu
->
CPUFrequency
=
Cpu
->
CPUFrequencyFromTSC
;
}
}
//
// Verify that
our two
CPU frequency calculations do not differ substantially.
// Verify that
ART/TSC
CPU frequency calculations do not differ substantially.
//
if
(
Cpu
->
CPUFrequencyFromART
>
0
&&
Cpu
->
CPUFrequencyFromTSC
>
0
&&
ABS
((
INT64
)
Cpu
->
CPUFrequencyFromART
-
(
INT64
)
Cpu
->
CPUFrequencyFromTSC
)
>
OC_CPU_FREQUENCY_TOLERANCE
)
{
...
...
@@ -444,6 +529,18 @@ ScanIntelProcessor (
Cpu
->
CPUFrequencyFromTSC
));
}
//
// Verify that Apple/TSC CPU frequency calculations do not differ substantially.
//
if
(
Cpu
->
CPUFrequencyFromApple
>
0
&&
Cpu
->
CPUFrequencyFromTSC
>
0
&&
ABS
((
INT64
)
Cpu
->
CPUFrequencyFromApple
-
(
INT64
)
Cpu
->
CPUFrequencyFromTSC
)
>
OC_CPU_FREQUENCY_TOLERANCE
)
{
DEBUG
((
DEBUG_WARN
,
"OCCPU: Apple based CPU frequency differs substantially from TSC: %11LuHz != %11LuHz
\n
"
,
Cpu
->
CPUFrequencyFromApple
,
Cpu
->
CPUFrequencyFromTSC
));
}
ScanIntelFSBFrequency
(
Cpu
);
}
...
...
@@ -582,8 +679,7 @@ ScanAmdProcessor (
//
if
(
Cpu
->
MaxExtId
>=
0x8000001E
)
{
AsmCpuid
(
0x8000001E
,
NULL
,
&
CpuidEbx
,
NULL
,
NULL
);
Cpu
->
CoreCount
=
(
UINT16
)
DivU64x32
(
Cpu
->
CoreCount
=
(
UINT16
)
DivU64x32
(
Cpu
->
ThreadCount
,
(
BitFieldRead32
(
CpuidEbx
,
8
,
15
)
+
1
)
);
...
...
@@ -834,6 +930,15 @@ OcCpuScanProcessor (
DivU64x32
(
Cpu
->
CPUFrequencyFromTSC
,
1000000
)
));
if
(
Cpu
->
CPUFrequencyFromApple
>
0
)
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: CPUFrequencyFromApple %11LuHz %5LuMHz
\n
"
,
Cpu
->
CPUFrequencyFromApple
,
DivU64x32
(
Cpu
->
CPUFrequencyFromApple
,
1000000
)
));
}
DEBUG
((
DEBUG_INFO
,
"OCCPU: CPUFrequency %11LuHz %5LuMHz
\n
"
,
...
...
Library/OcCpuLib/OcCpuLib.inf
浏览文件 @
ca8046be
...
...
@@ -39,9 +39,12 @@
UefiRuntimeServicesTableLib
[Guids]
gAppleFsbFrequencyPlatformInfoGuid
gAppleFsbFrequencyPlatformInfoIndexHobGuid
gOcVendorVariableGuid
[Protocols]
gApplePlatformInfoDatabaseProtocolGuid
gEfiMpServiceProtocolGuid
gFrameworkEfiMpServiceProtocolGuid
...
...
Library/OcMiscLib/OcMiscLib.inf
浏览文件 @
ca8046be
...
...
@@ -39,6 +39,7 @@
[LibraryClasses]
BaseLib
HobLib
IoLib
UefiLib
OcFileLib
...
...
@@ -48,4 +49,5 @@
[Sources]
DataPatcher.c
ImageRunner.c
PlatformInfo.c
ProtocolSupport.c
Library/OcMiscLib/PlatformInfo.c
0 → 100644
浏览文件 @
ca8046be
/** @file
Copyright (C) 2021, PMheart. All rights reserved.
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/OcMiscLib.h>
#include <Guid/AppleHob.h>
#include <Pi/PiBootMode.h>
#include <Pi/PiHob.h>
#include <Library/HobLib.h>
#include <Library/DebugLib.h>
EFI_STATUS
OcReadApplePlatformFirstData
(
IN
APPLE_PLATFORM_INFO_DATABASE_PROTOCOL
*
PlatformInfo
,
IN
EFI_GUID
*
DataGuid
,
IN
OUT
UINT32
*
Size
,
OUT
VOID
*
Data
)
{
EFI_STATUS
Status
;
UINT32
DataSize
;
ASSERT
(
Size
!=
NULL
);
ASSERT
(
Data
!=
NULL
);
ASSERT
(
DataGuid
!=
NULL
);
Status
=
PlatformInfo
->
GetFirstDataSize
(
PlatformInfo
,
DataGuid
,
&
DataSize
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: No first platform data size for %g up to %u - %r
\n
"
,
DataGuid
,
*
Size
,
Status
));
return
Status
;
}
if
(
DataSize
>
*
Size
)
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: Invalid first platform data size %u for %g up to %u - %r
\n
"
,
DataSize
,
DataGuid
,
*
Size
,
Status
));
return
EFI_INVALID_PARAMETER
;
}
Status
=
PlatformInfo
->
GetFirstData
(
PlatformInfo
,
DataGuid
,
Data
,
&
DataSize
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: No first platform data for %g up to %u - %r
\n
"
,
DataGuid
,
*
Size
,
Status
));
return
Status
;
}
*
Size
=
DataSize
;
return
Status
;
}
EFI_STATUS
OcReadApplePlatformData
(
IN
APPLE_PLATFORM_INFO_DATABASE_PROTOCOL
*
PlatformInfo
,
IN
EFI_GUID
*
DataGuid
,
IN
EFI_GUID
*
HobGuid
,
IN
OUT
UINT32
*
Size
,
OUT
VOID
*
Data
)
{
EFI_STATUS
Status
;
VOID
*
FsbHob
;
UINT32
DataSize
;
ASSERT
(
Size
!=
NULL
);
ASSERT
(
Data
!=
NULL
);
ASSERT
(
DataGuid
!=
NULL
);
ASSERT
(
HobGuid
!=
NULL
);
FsbHob
=
GetFirstGuidHob
(
HobGuid
);
if
(
FsbHob
==
NULL
)
{
return
EFI_UNSUPPORTED
;
}
Status
=
PlatformInfo
->
GetDataSize
(
PlatformInfo
,
DataGuid
,
*
(
UINT8
*
)
GET_GUID_HOB_DATA
(
FsbHob
),
&
DataSize
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: No platform data size for %g up to %u - %r
\n
"
,
DataGuid
,
*
Size
,
Status
));
return
Status
;
}
if
(
DataSize
>
*
Size
)
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: Invalid platform data size %u for %g up to %u - %r
\n
"
,
DataSize
,
DataGuid
,
*
Size
,
Status
));
return
EFI_INVALID_PARAMETER
;
}
Status
=
PlatformInfo
->
GetData
(
PlatformInfo
,
DataGuid
,
*
(
UINT8
*
)
GET_GUID_HOB_DATA
(
FsbHob
),
Data
,
&
DataSize
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_INFO
,
"OCCPU: No platform data for %g up to %u - %r
\n
"
,
DataGuid
,
*
Size
,
Status
));
return
Status
;
}
*
Size
=
DataSize
;
return
Status
;
}
User/Include/UserGlobalVar.h
浏览文件 @
ca8046be
...
...
@@ -33,7 +33,10 @@ extern EFI_GUID gAppleBlessedSystemFolderInfoGuid;
extern
EFI_GUID
gAppleBootPolicyProtocolGuid
;
extern
EFI_GUID
gAppleVendorVariableGuid
;
extern
EFI_GUID
gAppleImg4VerificationProtocolGuid
;
extern
EFI_GUID
gAppleBeepGenProtocolGuid
;
extern
EFI_GUID
gAppleBeepGenProtocolGuid
;
extern
EFI_GUID
gApplePlatformInfoDatabaseProtocolGuid
;
extern
EFI_GUID
gAppleFsbFrequencyPlatformInfoGuid
;
extern
EFI_GUID
gAppleFsbFrequencyPlatformInfoIndexHobGuid
;
extern
CONST
CHAR8
*
gEfiCallerBaseName
;
extern
EFI_GUID
gEfiGraphicsOutputProtocolGuid
;
...
...
User/Library/UserGlobalVar.c
浏览文件 @
ca8046be
...
...
@@ -5,19 +5,22 @@
#include <UserGlobalVar.h>
EFI_GUID
gAppleBootVariableGuid
=
{
0X7C436110
,
0XAB2A
,
0X4BBB
,
{
0XA8
,
0X80
,
0XFE
,
0X41
,
0X99
,
0X5C
,
0X9F
,
0X82
}};
EFI_GUID
gAppleEventProtocolGuid
=
{
0X33BE0EF1
,
0X89C9
,
0X4A6D
,
{
0XBB
,
0X9F
,
0X69
,
0XDC
,
0X8D
,
0XD5
,
0X16
,
0XB9
}};
EFI_GUID
gAppleKeyMapAggregatorProtocolGuid
=
{
0X5B213447
,
0X6E73
,
0X4901
,
{
0XA4
,
0XF1
,
0XB8
,
0X64
,
0XF3
,
0XB7
,
0XA1
,
0X72
}};
EFI_GUID
gAppleKeyMapDatabaseProtocolGuid
=
{
0X584B9EBE
,
0X80C1
,
0X4BD6
,
{
0X98
,
0XB0
,
0XA7
,
0X78
,
0X6E
,
0XC2
,
0XF2
,
0XE2
}};
EFI_GUID
gAppleApfsContainerInfoGuid
=
{
0x3533CF0D
,
0x685F
,
0x5EBF
,
{
0x8D
,
0xC6
,
0x73
,
0x93
,
0x48
,
0x5B
,
0xAF
,
0xA2
}};
EFI_GUID
gAppleApfsVolumeInfoGuid
=
{
0x900C7693
,
0x8C14
,
0x58BA
,
{
0xB4
,
0x4E
,
0x97
,
0x45
,
0x15
,
0xD2
,
0x7C
,
0x78
}};
EFI_GUID
gAppleBlessedOsxFolderInfoGuid
=
{
0x893CA450
,
0x5F5E
,
0x48BA
,
{
0x85
,
0x8F
,
0x08
,
0xC4
,
0x5D
,
0x80
,
0x23
,
0x18
}};
EFI_GUID
gAppleBlessedSystemFileInfoGuid
=
{
0xCA7E4814
,
0x2ADC
,
0x4ADD
,
{
0xAB
,
0xFF
,
0x73
,
0x4E
,
0x3C
,
0xFE
,
0x13
,
0xF3
}};
EFI_GUID
gAppleBlessedSystemFolderInfoGuid
=
{
0x7BD1F02D
,
0x9C2F
,
0x4581
,
{
0xBF
,
0x12
,
0xD5
,
0x4a
,
0xBA
,
0x0D
,
0x98
,
0xD6
}};
EFI_GUID
gAppleBootPolicyProtocolGuid
=
{
0x62257758
,
0x350C
,
0x4D0A
,
{
0xB0
,
0xBD
,
0xF6
,
0xBE
,
0x2E
,
0x1E
,
0x27
,
0x2C
}};
EFI_GUID
gAppleVendorVariableGuid
=
{
0x4D1EDE05
,
0x38C7
,
0x4A6A
,
{
0x9C
,
0xC6
,
0x4B
,
0xCC
,
0xA8
,
0xB3
,
0x8C
,
0x14
}};
EFI_GUID
gAppleImg4VerificationProtocolGuid
=
{
0x314735F0
,
0x26FE
,
0x11E8
,
{
0xA4
,
0x70
,
0xB8
,
0xE8
,
0x56
,
0x2C
,
0xBA
,
0xFA
}};
EFI_GUID
gAppleBeepGenProtocolGuid
=
{
0xC32332DF
,
0xFC56
,
0x4FE1
,
{
0x93
,
0x58
,
0xBA
,
0x0D
,
0x52
,
0x9B
,
0x24
,
0xCD
}};
EFI_GUID
gAppleBootVariableGuid
=
{
0X7C436110
,
0XAB2A
,
0X4BBB
,
{
0XA8
,
0X80
,
0XFE
,
0X41
,
0X99
,
0X5C
,
0X9F
,
0X82
}};
EFI_GUID
gAppleEventProtocolGuid
=
{
0X33BE0EF1
,
0X89C9
,
0X4A6D
,
{
0XBB
,
0X9F
,
0X69
,
0XDC
,
0X8D
,
0XD5
,
0X16
,
0XB9
}};
EFI_GUID
gAppleKeyMapAggregatorProtocolGuid
=
{
0X5B213447
,
0X6E73
,
0X4901
,
{
0XA4
,
0XF1
,
0XB8
,
0X64
,
0XF3
,
0XB7
,
0XA1
,
0X72
}};
EFI_GUID
gAppleKeyMapDatabaseProtocolGuid
=
{
0X584B9EBE
,
0X80C1
,
0X4BD6
,
{
0X98
,
0XB0
,
0XA7
,
0X78
,
0X6E
,
0XC2
,
0XF2
,
0XE2
}};
EFI_GUID
gAppleApfsContainerInfoGuid
=
{
0x3533CF0D
,
0x685F
,
0x5EBF
,
{
0x8D
,
0xC6
,
0x73
,
0x93
,
0x48
,
0x5B
,
0xAF
,
0xA2
}};
EFI_GUID
gAppleApfsVolumeInfoGuid
=
{
0x900C7693
,
0x8C14
,
0x58BA
,
{
0xB4
,
0x4E
,
0x97
,
0x45
,
0x15
,
0xD2
,
0x7C
,
0x78
}};
EFI_GUID
gAppleBlessedOsxFolderInfoGuid
=
{
0x893CA450
,
0x5F5E
,
0x48BA
,
{
0x85
,
0x8F
,
0x08
,
0xC4
,
0x5D
,
0x80
,
0x23
,
0x18
}};
EFI_GUID
gAppleBlessedSystemFileInfoGuid
=
{
0xCA7E4814
,
0x2ADC
,
0x4ADD
,
{
0xAB
,
0xFF
,
0x73
,
0x4E
,
0x3C
,
0xFE
,
0x13
,
0xF3
}};
EFI_GUID
gAppleBlessedSystemFolderInfoGuid
=
{
0x7BD1F02D
,
0x9C2F
,
0x4581
,
{
0xBF
,
0x12
,
0xD5
,
0x4a
,
0xBA
,
0x0D
,
0x98
,
0xD6
}};
EFI_GUID
gAppleBootPolicyProtocolGuid
=
{
0x62257758
,
0x350C
,
0x4D0A
,
{
0xB0
,
0xBD
,
0xF6
,
0xBE
,
0x2E
,
0x1E
,
0x27
,
0x2C
}};
EFI_GUID
gAppleVendorVariableGuid
=
{
0x4D1EDE05
,
0x38C7
,
0x4A6A
,
{
0x9C
,
0xC6
,
0x4B
,
0xCC
,
0xA8
,
0xB3
,
0x8C
,
0x14
}};
EFI_GUID
gAppleImg4VerificationProtocolGuid
=
{
0x314735F0
,
0x26FE
,
0x11E8
,
{
0xA4
,
0x70
,
0xB8
,
0xE8
,
0x56
,
0x2C
,
0xBA
,
0xFA
}};
EFI_GUID
gAppleBeepGenProtocolGuid
=
{
0xC32332DF
,
0xFC56
,
0x4FE1
,
{
0x93
,
0x58
,
0xBA
,
0x0D
,
0x52
,
0x9B
,
0x24
,
0xCD
}};
EFI_GUID
gApplePlatformInfoDatabaseProtocolGuid
=
{
0xAC5E4829
,
0xA8FD
,
0x440B
,
{
0xAF
,
0x33
,
0x9F
,
0xFE
,
0x01
,
0x3B
,
0x12
,
0xD8
}};
EFI_GUID
gAppleFsbFrequencyPlatformInfoGuid
=
{
0xD1A04D55
,
0x75B9
,
0x41A3
,
{
0x90
,
0x36
,
0x8F
,
0x4A
,
0x26
,
0x1C
,
0xBB
,
0xA2
}};
EFI_GUID
gAppleFsbFrequencyPlatformInfoIndexHobGuid
=
{
0xEF56B861
,
0x03CD
,
0x4991
,
{
0x99
,
0xF2
,
0x2A
,
0xD3
,
0x1B
,
0xE8
,
0x6B
,
0x22
}};
CONST
CHAR8
*
gEfiCallerBaseName
=
"OpenCore"
;
EFI_GUID
gEfiGraphicsOutputProtocolGuid
=
{
0x9042A9DE
,
0x23DC
,
0x4A38
,
{
0x96
,
0xFB
,
0x7A
,
0xDE
,
0xD0
,
0x80
,
0x51
,
0x6A
}};
...
...
User/Library/UserMisc.c
浏览文件 @
ca8046be
...
...
@@ -653,3 +653,12 @@ MmioWrite8 (
{
return
0
;
}
VOID
*
EFIAPI
GetFirstGuidHob
(
IN
CONST
EFI_GUID
*
Guid
)
{
return
NULL
;
}
User/Makefile
浏览文件 @
ca8046be
...
...
@@ -176,7 +176,7 @@ ifneq ($(STANDALONE),1)
#
# OcMiscLib targets.
#
OBJS
+=
Math.o ProtocolSupport.o DataPatcher.o
OBJS
+=
Math.o ProtocolSupport.o DataPatcher.o
PlatformInfo.o
#
# OcAppleKernelLib targets.
#
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录