提交 73533f88 编写于 作者: G Goldfish64

OpenCoreKernel: Implement arch filtering for Block

上级 d5a3013d
......@@ -30,7 +30,7 @@ OpenCore Changelog
- Added `KernelCache` option to specify kernel caching preference for older kernels
- Added `Force` section to provide support for injecting drivers in older macOS
- Changed kernel driver injection to happen prior to kernel driver patching
- Added `Arch` filtering option to `Add`, `Force`, and `Patch` sections
- Added `Arch` filtering option to `Add`, 'Block`, `Force`, and `Patch` sections
#### v0.6.0
- Fixed sound corruption with AudioDxe
......
......@@ -154,6 +154,7 @@ VOID
OcKernelBlockKexts (
IN OC_GLOBAL_CONFIG *Config,
IN UINT32 DarwinVersion,
IN BOOLEAN Is32Bit,
IN PRELINKED_CONTEXT *Context
);
......
......@@ -567,7 +567,7 @@ OcKernelInjectKext (
MaxKernel = OcParseDarwinVersion (OC_BLOB_GET (&Kext->MaxKernel));
MinKernel = OcParseDarwinVersion (OC_BLOB_GET (&Kext->MinKernel));
if (Arch != NULL && AsciiStrCmp (Arch, Is32Bit ? "x86_64" : "i386") == 0) {
if (AsciiStrCmp (Arch, Is32Bit ? "x86_64" : "i386") == 0) {
DEBUG ((
DEBUG_INFO,
"OC: %a%a injection skips %a (%a) kext at %u due to arch %a != %a\n",
......@@ -763,7 +763,7 @@ OcKernelProcessPrelinked (
OcKernelApplyPatches (Config, mOcCpuInfo, DarwinVersion, Is32Bit, CacheTypePrelinked, &Context, NULL, 0);
OcKernelBlockKexts (Config, DarwinVersion, &Context);
OcKernelBlockKexts (Config, DarwinVersion, Is32Bit, &Context);
*KernelSize = Context.PrelinkedSize;
......
......@@ -103,15 +103,17 @@ OcKernelApplyPatches (
for (Index = 0; Index < Config->Kernel.Patch.Count; ++Index) {
UserPatch = Config->Kernel.Patch.Values[Index];
Target = OC_BLOB_GET (&UserPatch->Identifier);
Comment = OC_BLOB_GET (&UserPatch->Comment);
if (!UserPatch->Enabled || (AsciiStrCmp (Target, "kernel") == 0) != IsKernelPatch) {
continue;
}
Arch = OC_BLOB_GET (&UserPatch->Arch);
Comment = OC_BLOB_GET (&UserPatch->Comment);
Arch = OC_BLOB_GET (&UserPatch->Arch);
MaxKernel = OcParseDarwinVersion (OC_BLOB_GET (&UserPatch->MaxKernel));
MinKernel = OcParseDarwinVersion (OC_BLOB_GET (&UserPatch->MinKernel));
if (Arch != NULL && AsciiStrCmp (Arch, Is32Bit ? "x86_64" : "i386") == 0) {
if (AsciiStrCmp (Arch, Is32Bit ? "x86_64" : "i386") == 0) {
DEBUG ((
DEBUG_INFO,
"OC: Kernel patcher skips %a (%a) patch at %u due to arch %a != %a\n",
......@@ -124,9 +126,6 @@ OcKernelApplyPatches (
return;
}
MaxKernel = OcParseDarwinVersion (OC_BLOB_GET (&UserPatch->MaxKernel));
MinKernel = OcParseDarwinVersion (OC_BLOB_GET (&UserPatch->MinKernel));
if (!OcMatchDarwinVersion (DarwinVersion, MinKernel, MaxKernel)) {
DEBUG ((
DEBUG_INFO,
......@@ -289,6 +288,7 @@ VOID
OcKernelBlockKexts (
IN OC_GLOBAL_CONFIG *Config,
IN UINT32 DarwinVersion,
IN BOOLEAN Is32Bit,
IN PRELINKED_CONTEXT *Context
)
{
......@@ -298,20 +298,35 @@ OcKernelBlockKexts (
OC_KERNEL_BLOCK_ENTRY *Kext;
CONST CHAR8 *Target;
CONST CHAR8 *Comment;
CONST CHAR8 *Arch;
UINT32 MaxKernel;
UINT32 MinKernel;
for (Index = 0; Index < Config->Kernel.Block.Count; ++Index) {
Kext = Config->Kernel.Block.Values[Index];
Target = OC_BLOB_GET (&Kext->Identifier);
Comment = OC_BLOB_GET (&Kext->Comment);
Kext = Config->Kernel.Block.Values[Index];
if (!Kext->Enabled) {
continue;
}
MaxKernel = OcParseDarwinVersion (OC_BLOB_GET (&Kext->MaxKernel));
MinKernel = OcParseDarwinVersion (OC_BLOB_GET (&Kext->MinKernel));
Target = OC_BLOB_GET (&Kext->Identifier);
Comment = OC_BLOB_GET (&Kext->Comment);
Arch = OC_BLOB_GET (&Kext->Arch);
MaxKernel = OcParseDarwinVersion (OC_BLOB_GET (&Kext->MaxKernel));
MinKernel = OcParseDarwinVersion (OC_BLOB_GET (&Kext->MinKernel));
if (AsciiStrCmp (Arch, Is32Bit ? "x86_64" : "i386") == 0) {
DEBUG ((
DEBUG_INFO,
"OC: Prelink blocker skips %a (%a) block at %u due to arch %a != %a\n",
Target,
Comment,
Index,
Arch,
Is32Bit ? "i386" : "x86_64"
));
return;
}
if (!OcMatchDarwinVersion (DarwinVersion, MinKernel, MaxKernel)) {
DEBUG ((
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册