Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
b3351908
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,发现更多精彩内容 >>
提交
b3351908
编写于
4月 18, 2019
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OpenCoreMisc: Separate from main OC
上级
8a42786c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
218 addition
and
138 deletion
+218
-138
Include/OpenCore.h
Include/OpenCore.h
+32
-0
Platform/OpenCore/OpenCore.c
Platform/OpenCore/OpenCore.c
+9
-138
Platform/OpenCore/OpenCore.inf
Platform/OpenCore/OpenCore.inf
+1
-0
Platform/OpenCore/OpenCoreMisc.c
Platform/OpenCore/OpenCoreMisc.c
+176
-0
未找到文件。
Include/OpenCore.h
浏览文件 @
b3351908
...
...
@@ -128,4 +128,36 @@ OcLoadUefiSupport (
IN
OC_CPU_INFO
*
CpuInfo
);
/**
Load early miscellaneous support like configuration.
@param[in] Storage OpenCore storage.
@param[out] Config OpenCore configuration.
@param[in] VaultKey Vault key.
@retval EFI_SUCCESS when allowed to continue.
**/
EFI_STATUS
OcMiscEarlyInit
(
IN
OC_STORAGE_CONTEXT
*
Storage
,
OUT
OC_GLOBAL_CONFIG
*
Config
,
IN
RSA_PUBLIC_KEY
*
VaultKey
OPTIONAL
);
/**
Load late miscellaneous support like boot screen config.
@param[in] Config OpenCore configuration.
@param[in] LoadPath OpenCore loading path.
@param[out] LoadHandle OpenCore loading handle.
@retval EFI_SUCCESS on success, informational.
**/
EFI_STATUS
OcMiscLateInit
(
IN
OC_GLOBAL_CONFIG
*
Config
,
IN
EFI_DEVICE_PATH_PROTOCOL
*
LoadPath
OPTIONAL
,
OUT
EFI_HANDLE
*
LoadHandle
OPTIONAL
);
#endif // OPEN_CORE_H
Platform/OpenCore/OpenCore.c
浏览文件 @
b3351908
...
...
@@ -172,116 +172,6 @@ OcStartImage (
return
Status
;
}
STATIC
VOID
OcStoreLoadPath
(
IN
EFI_DEVICE_PATH_PROTOCOL
*
LoadPath
OPTIONAL
)
{
EFI_STATUS
Status
;
CHAR16
*
DevicePath
;
CHAR8
OutPath
[
256
];
if
(
LoadPath
!=
NULL
)
{
DevicePath
=
ConvertDevicePathToText
(
LoadPath
,
FALSE
,
FALSE
);
if
(
DevicePath
!=
NULL
)
{
AsciiSPrint
(
OutPath
,
sizeof
(
OutPath
),
"%s"
,
DevicePath
);
FreePool
(
DevicePath
);
}
else
{
LoadPath
=
NULL
;
}
}
if
(
LoadPath
==
NULL
)
{
AsciiSPrint
(
OutPath
,
sizeof
(
OutPath
),
"Unknown"
);
}
Status
=
gRT
->
SetVariable
(
OC_LOG_VARIABLE_PATH
,
&
gOcLogVariableGuid
,
OPEN_CORE_NVRAM_ATTR
,
AsciiStrSize
(
OutPath
),
OutPath
);
DEBUG
((
EFI_ERROR
(
Status
)
?
DEBUG_WARN
:
DEBUG_INFO
,
"OC: Setting NVRAM %g:%a = %a - %r
\n
"
,
&
gOcLogVariableGuid
,
OC_LOG_VARIABLE_PATH
,
OutPath
,
Status
));
}
STATIC
EFI_STATUS
OcMiscEarlyInit
(
IN
OC_STORAGE_CONTEXT
*
Storage
,
IN
OC_GLOBAL_CONFIG
*
Configuration
)
{
EFI_STATUS
Status
;
CHAR8
*
Config
;
UINT32
ConfigSize
;
Config
=
OcStorageReadFileUnicode
(
Storage
,
OPEN_CORE_CONFIG_PATH
,
&
ConfigSize
);
if
(
Config
!=
NULL
)
{
DEBUG
((
DEBUG_INFO
,
"OC: Loaded configuration of %u bytes
\n
"
,
ConfigSize
));
Status
=
OcConfigurationInit
(
Configuration
,
Config
,
ConfigSize
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_ERROR
,
"OC: Failed to parse configuration!
\n
"
));
CpuDeadLoop
();
return
EFI_UNSUPPORTED
;
///< Should be unreachable.
}
FreePool
(
Config
);
}
else
{
DEBUG
((
DEBUG_ERROR
,
"OC: Failed to load configuration!
\n
"
));
CpuDeadLoop
();
return
EFI_UNSUPPORTED
;
///< Should be unreachable.
}
//
// Sanity check that the configuration is adequate.
//
if
(
!
Storage
->
HasVault
&&
Configuration
->
Misc
.
Security
.
RequireVault
)
{
DEBUG
((
DEBUG_ERROR
,
"OC: Configuration requires vault but no vault provided!
\n
"
));
CpuDeadLoop
();
return
EFI_SECURITY_VIOLATION
;
///< Should be unreachable.
}
if
(
mOpenCoreVaultKey
==
NULL
&&
Configuration
->
Misc
.
Security
.
RequireSignature
)
{
DEBUG
((
DEBUG_ERROR
,
"OC: Configuration requires signed vault but no public key provided!
\n
"
));
CpuDeadLoop
();
return
EFI_SECURITY_VIOLATION
;
///< Should be unreachable.
}
OcConfigureLogProtocol
(
Configuration
->
Misc
.
Debug
.
Target
,
Configuration
->
Misc
.
Debug
.
Delay
,
(
UINTN
)
Configuration
->
Misc
.
Debug
.
DisplayLevel
,
(
UINTN
)
Configuration
->
Misc
.
Security
.
HaltLevel
);
DEBUG
((
DEBUG_INFO
,
"OC: OpenCore is now loading (Vault: %d/%d, Sign %d/%d)...
\n
"
,
Storage
->
HasVault
,
Configuration
->
Misc
.
Security
.
RequireVault
,
mOpenCoreVaultKey
!=
NULL
,
Configuration
->
Misc
.
Security
.
RequireSignature
));
return
EFI_SUCCESS
;
}
STATIC
VOID
OcMain
(
...
...
@@ -294,7 +184,13 @@ OcMain (
OC_CPU_INFO
CpuInfo
;
EFI_HANDLE
LoadHandle
;
Status
=
OcMiscEarlyInit
(
Storage
,
&
mOpenCoreConfiguration
);
DEBUG
((
DEBUG_INFO
,
"OC: OcMiscEarlyInit...
\n
"
));
Status
=
OcMiscEarlyInit
(
Storage
,
&
mOpenCoreConfiguration
,
mOpenCoreVaultKey
);
if
(
EFI_ERROR
(
Status
))
{
return
;
}
...
...
@@ -309,26 +205,8 @@ OcMain (
OcLoadDevPropsSupport
(
&
mOpenCoreConfiguration
);
DEBUG
((
DEBUG_INFO
,
"OC: OcLoadNvramSupport...
\n
"
));
OcLoadNvramSupport
(
&
mOpenCoreConfiguration
);
if
(
mOpenCoreConfiguration
.
Misc
.
Debug
.
ExposeBootPath
)
{
OcStoreLoadPath
(
LoadPath
);
}
if
(
mOpenCoreConfiguration
.
Misc
.
Boot
.
ReinstallProtocol
)
{
if
(
OcAppleBootPolicyInstallProtocol
(
TRUE
)
==
NULL
)
{
DEBUG
((
DEBUG_ERROR
,
"OC: Failed to reinstall boot policy protocol
\n
"
));
}
}
LoadHandle
=
NULL
;
if
(
LoadPath
!=
NULL
)
{
Status
=
gBS
->
LocateDevicePath
(
&
gEfiSimpleFileSystemProtocolGuid
,
&
LoadPath
,
&
LoadHandle
);
DEBUG
((
DEBUG_INFO
,
"OC: LoadHandle is %p - %r
\n
"
,
LoadHandle
,
Status
));
}
DEBUG
((
DEBUG_INFO
,
"OC: OcMiscLateInit...
\n
"
));
OcMiscLateInit
(
&
mOpenCoreConfiguration
,
LoadPath
,
&
LoadHandle
);
//
// This is required to catch UEFI Shell boot if any.
...
...
@@ -341,13 +219,6 @@ OcMain (
DEBUG
((
DEBUG_INFO
,
"OC: OpenCore is loaded, showing boot menu...
\n
"
));
//
// Do not hide self entry unless asked.
//
if
(
!
mOpenCoreConfiguration
.
Misc
.
Boot
.
HideSelf
)
{
LoadHandle
=
NULL
;
}
Status
=
OcRunSimpleBootPicker
(
OC_SCAN_DEFAULT_POLICY
,
OC_LOAD_DEFAULT_POLICY
,
...
...
Platform/OpenCore/OpenCore.inf
浏览文件 @
b3351908
...
...
@@ -39,6 +39,7 @@
OpenCoreAcpi.c
OpenCoreDevProps.c
OpenCoreKernel.c
OpenCoreMisc.c
OpenCoreNvram.c
OpenCorePlatform.c
OpenCoreUefi.c
...
...
Platform/OpenCore/OpenCoreMisc.c
0 → 100644
浏览文件 @
b3351908
/** @file
OpenCore driver.
Copyright (c) 2019, vit9696. All rights reserved.<BR>
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 <OpenCore.h>
#include <Guid/OcLogVariable.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcAppleBootPolicyLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
STATIC
VOID
OcStoreLoadPath
(
IN
EFI_DEVICE_PATH_PROTOCOL
*
LoadPath
OPTIONAL
)
{
EFI_STATUS
Status
;
CHAR16
*
DevicePath
;
CHAR8
OutPath
[
256
];
if
(
LoadPath
!=
NULL
)
{
DevicePath
=
ConvertDevicePathToText
(
LoadPath
,
FALSE
,
FALSE
);
if
(
DevicePath
!=
NULL
)
{
AsciiSPrint
(
OutPath
,
sizeof
(
OutPath
),
"%s"
,
DevicePath
);
FreePool
(
DevicePath
);
}
else
{
LoadPath
=
NULL
;
}
}
if
(
LoadPath
==
NULL
)
{
AsciiSPrint
(
OutPath
,
sizeof
(
OutPath
),
"Unknown"
);
}
Status
=
gRT
->
SetVariable
(
OC_LOG_VARIABLE_PATH
,
&
gOcLogVariableGuid
,
OPEN_CORE_NVRAM_ATTR
,
AsciiStrSize
(
OutPath
),
OutPath
);
DEBUG
((
EFI_ERROR
(
Status
)
?
DEBUG_WARN
:
DEBUG_INFO
,
"OC: Setting NVRAM %g:%a = %a - %r
\n
"
,
&
gOcLogVariableGuid
,
OC_LOG_VARIABLE_PATH
,
OutPath
,
Status
));
}
EFI_STATUS
OcMiscEarlyInit
(
IN
OC_STORAGE_CONTEXT
*
Storage
,
OUT
OC_GLOBAL_CONFIG
*
Config
,
IN
RSA_PUBLIC_KEY
*
VaultKey
OPTIONAL
)
{
EFI_STATUS
Status
;
CHAR8
*
ConfigData
;
UINT32
ConfigDataSize
;
ConfigData
=
OcStorageReadFileUnicode
(
Storage
,
OPEN_CORE_CONFIG_PATH
,
&
ConfigDataSize
);
if
(
ConfigData
!=
NULL
)
{
DEBUG
((
DEBUG_INFO
,
"OC: Loaded configuration of %u bytes
\n
"
,
ConfigDataSize
));
Status
=
OcConfigurationInit
(
Config
,
ConfigData
,
ConfigDataSize
);
if
(
EFI_ERROR
(
Status
))
{
DEBUG
((
DEBUG_ERROR
,
"OC: Failed to parse configuration!
\n
"
));
CpuDeadLoop
();
return
EFI_UNSUPPORTED
;
///< Should be unreachable.
}
FreePool
(
ConfigData
);
}
else
{
DEBUG
((
DEBUG_ERROR
,
"OC: Failed to load configuration!
\n
"
));
CpuDeadLoop
();
return
EFI_UNSUPPORTED
;
///< Should be unreachable.
}
//
// Sanity check that the configuration is adequate.
//
if
(
!
Storage
->
HasVault
&&
Config
->
Misc
.
Security
.
RequireVault
)
{
DEBUG
((
DEBUG_ERROR
,
"OC: Configuration requires vault but no vault provided!
\n
"
));
CpuDeadLoop
();
return
EFI_SECURITY_VIOLATION
;
///< Should be unreachable.
}
if
(
VaultKey
==
NULL
&&
Config
->
Misc
.
Security
.
RequireSignature
)
{
DEBUG
((
DEBUG_ERROR
,
"OC: Configuration requires signed vault but no public key provided!
\n
"
));
CpuDeadLoop
();
return
EFI_SECURITY_VIOLATION
;
///< Should be unreachable.
}
OcConfigureLogProtocol
(
Config
->
Misc
.
Debug
.
Target
,
Config
->
Misc
.
Debug
.
Delay
,
(
UINTN
)
Config
->
Misc
.
Debug
.
DisplayLevel
,
(
UINTN
)
Config
->
Misc
.
Security
.
HaltLevel
);
DEBUG
((
DEBUG_INFO
,
"OC: OpenCore is now loading (Vault: %d/%d, Sign %d/%d)...
\n
"
,
Storage
->
HasVault
,
Config
->
Misc
.
Security
.
RequireVault
,
VaultKey
!=
NULL
,
Config
->
Misc
.
Security
.
RequireSignature
));
return
EFI_SUCCESS
;
}
EFI_STATUS
OcMiscLateInit
(
IN
OC_GLOBAL_CONFIG
*
Config
,
IN
EFI_DEVICE_PATH_PROTOCOL
*
LoadPath
OPTIONAL
,
OUT
EFI_HANDLE
*
LoadHandle
OPTIONAL
)
{
EFI_STATUS
Status
;
if
(
Config
->
Misc
.
Debug
.
ExposeBootPath
)
{
OcStoreLoadPath
(
LoadPath
);
}
if
(
Config
->
Misc
.
Boot
.
ReinstallProtocol
)
{
if
(
OcAppleBootPolicyInstallProtocol
(
TRUE
)
==
NULL
)
{
DEBUG
((
DEBUG_ERROR
,
"OC: Failed to reinstall boot policy protocol
\n
"
));
}
}
Status
=
EFI_SUCCESS
;
if
(
LoadHandle
!=
NULL
)
{
*
LoadHandle
=
NULL
;
//
// Do not disclose self entry unless asked.
//
if
(
LoadPath
!=
NULL
&&
Config
->
Misc
.
Boot
.
HideSelf
)
{
Status
=
gBS
->
LocateDevicePath
(
&
gEfiSimpleFileSystemProtocolGuid
,
&
LoadPath
,
LoadHandle
);
DEBUG
((
DEBUG_INFO
,
"OC: LoadHandle is %p - %r
\n
"
,
*
LoadHandle
,
Status
));
}
}
return
Status
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录