Skip to content

Commit

Permalink
OcAppleKernelLib: Added ForceAquantiaEthernet quirk
Browse files Browse the repository at this point in the history
  • Loading branch information
PMheart committed Mar 20, 2022
1 parent 719507f commit 41882d9
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -3,6 +3,7 @@ OpenCore Changelog
#### v0.8.0
- Added support for early log preservation
- Switched to Python 3 in scripts (use `python /path/to/script` to force Python 2)
- Added `ForceAquantiaEthernet` for Aquantia AQtion AQC-107s based 10GbE network cards support, thx @Mieze

#### v0.7.9
- Added auto-detect `macOS Installer` volume name for use when `.disk_label` file cannot be displayed
Expand Down
2 changes: 1 addition & 1 deletion Docs/Configuration.md5
@@ -1 +1 @@
889e4083fc23ff23b71c1ebfc6ef7c88
bd9caa75d299d8a25ef88fd4d6833b83
Binary file modified Docs/Configuration.pdf
Binary file not shown.
10 changes: 10 additions & 0 deletions Docs/Configuration.tex
Expand Up @@ -2647,6 +2647,16 @@ \subsection{Quirks Properties}\label{kernelpropsquirks}
\emph{Note}: This option should be avoided whenever possible. Modern firmware
typically have compatible AHCI controllers.

\item
\texttt{ForceAquantiaEthernet}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Requirement}: 10.15.4\\
\textbf{Description}: Enable Aquantia AQtion AQC-107s based 10GbE network cards support.

This option enables Aquantia AQtion AQC-107s based 10GbE network cards support,
which used to work natively before macOS 10.15.4.

\item
\texttt{ForceSecureBootScheme}\\
\textbf{Type}: \texttt{plist\ boolean}\\
Expand Down
Binary file modified Docs/Differences/Differences.pdf
Binary file not shown.
20 changes: 16 additions & 4 deletions Docs/Differences/Differences.tex
@@ -1,7 +1,7 @@
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Wed Mar 9 13:03:27 2022
%DIF ADD ../Configuration.tex Sun Mar 20 14:02:15 2022
%DIF DEL PreviousConfiguration.tex Thu Mar 10 21:36:27 2022
%DIF ADD ../Configuration.tex Sun Mar 20 12:27:38 2022

\usepackage{lmodern}
\usepackage{amssymb,amsmath}
Expand Down Expand Up @@ -122,7 +122,7 @@
%DIF HYPERREF PREAMBLE %DIF PREAMBLE
\providecommand{\DIFadd}[1]{\texorpdfstring{\DIFaddtex{#1}}{#1}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\texorpdfstring{\DIFdeltex{#1}}{}} %DIF PREAMBLE
%DIF LISTINGS PREAMBLE %DIF PREAMBLE
%DIF COLORLISTINGS PREAMBLE %DIF PREAMBLE
\RequirePackage{listings} %DIF PREAMBLE
\RequirePackage{color} %DIF PREAMBLE
\lstdefinelanguage{DIFcode}{ %DIF PREAMBLE
Expand Down Expand Up @@ -2712,7 +2712,19 @@ \subsection{Quirks Properties}\label{kernelpropsquirks}
typically have compatible AHCI controllers.

\item
\texttt{ForceSecureBootScheme}\\
\DIFaddbegin \texttt{\DIFadd{ForceAquantiaEthernet}}\\
\textbf{\DIFadd{Type}}\DIFadd{: }\texttt{\DIFadd{plist\ boolean}}\\
\textbf{\DIFadd{Failsafe}}\DIFadd{: }\texttt{\DIFadd{false}}\\
\textbf{\DIFadd{Requirement}}\DIFadd{: 10.15.4}\\
\textbf{\DIFadd{Description}}\DIFadd{: Enable Aquantia AQtion AQC-107s based 10GbE network cards support.
}

\DIFadd{This option enables Aquantia AQtion AQC-107s based 10GbE network cards support,
which used to work natively before macOS 10.15.4.
}

\item
\DIFaddend \texttt{ForceSecureBootScheme}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Requirement}: 11\\
Expand Down
Binary file modified Docs/Errata/Errata.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions Docs/Sample.plist
Expand Up @@ -1013,6 +1013,8 @@
<false/>
<key>ExternalDiskIcons</key>
<false/>
<key>ForceAquantiaEthernet</key>
<false/>
<key>ForceSecureBootScheme</key>
<false/>
<key>IncreasePciBarSize</key>
Expand Down
2 changes: 2 additions & 0 deletions Docs/SampleCustom.plist
Expand Up @@ -1013,6 +1013,8 @@
<false/>
<key>ExternalDiskIcons</key>
<false/>
<key>ForceAquantiaEthernet</key>
<false/>
<key>ForceSecureBootScheme</key>
<false/>
<key>IncreasePciBarSize</key>
Expand Down
4 changes: 4 additions & 0 deletions Include/Acidanthera/Library/OcAppleKernelLib.h
Expand Up @@ -583,6 +583,10 @@ typedef enum {
// Set custom APFS trim timeout.
//
KernelQuirkSetApfsTrimTimeout,
//
// Enable Aquantia AQtion AQC-107s support.
//
KernelQuirkForceAquantiaEthernet,

KernelQuirkMax
} KERNEL_QUIRK_NAME;
Expand Down
1 change: 1 addition & 0 deletions Include/Acidanthera/Library/OcConfigurationLib.h
Expand Up @@ -290,6 +290,7 @@
_(BOOLEAN , DisableRtcChecksum , , FALSE , ()) \
_(BOOLEAN , ExtendBTFeatureFlags , , FALSE , ()) \
_(BOOLEAN , ExternalDiskIcons , , FALSE , ()) \
_(BOOLEAN , ForceAquantiaEthernet , , FALSE , ()) \
_(BOOLEAN , ForceSecureBootScheme , , FALSE , ()) \
_(BOOLEAN , IncreasePciBarSize , , FALSE , ()) \
_(BOOLEAN , LapicKernelPanic , , FALSE , ()) \
Expand Down
69 changes: 68 additions & 1 deletion Library/OcAppleKernelLib/CommonPatches.c
Expand Up @@ -627,7 +627,7 @@ PatchUsbXhciPortLimit1 (
// On 10.14.4 and newer IOUSBHostFamily also needs limit removal.
// Thanks to ydeng discovering this.
//
if (!OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION(18, 5, 0), 0)) {
if (!OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION (18, 5, 0), 0)) {
DEBUG ((DEBUG_INFO, "OCAK: Skipping port patch IOUSBHostFamily on %u\n", KernelVersion));
return EFI_SUCCESS;
}
Expand Down Expand Up @@ -1889,6 +1889,72 @@ PatchLegacyCommpage (
return EFI_NOT_FOUND;
}

STATIC
CONST UINT8
mAquantiaEthernetPatchFind[] = {
0x41, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ///< mov dword ptr [whatever], 0
0xE9 ///< jmp
};

STATIC
CONST UINT8
mAquantiaEthernetPatchReplace[] = {
0x41, 0xC7, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, ///< mov dword ptr [whatever], 1
0xE9 ///< jmp
};

STATIC
CONST UINT8
mAquantiaEthernetPatchMask[] = {
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0xFF
};

STATIC
PATCHER_GENERIC_PATCH
mAquantiaEthernetPatch = {
.Comment = DEBUG_POINTER ("ForceAquantiaEthernet"),
.Base = "__ZN30AppleEthernetAquantiaAqtion10718checkConfigSupportERiS0_",
.Find = mAquantiaEthernetPatchFind,
.Mask = mAquantiaEthernetPatchMask,
.Replace = mAquantiaEthernetPatchReplace,
.ReplaceMask = mAquantiaEthernetPatchMask,
.Size = sizeof (mAquantiaEthernetPatchFind),
.Count = 1,
.Skip = 0
};

STATIC
EFI_STATUS
PatchAquantiaEthernet (
IN OUT PATCHER_CONTEXT *Patcher,
IN UINT32 KernelVersion
)
{
EFI_STATUS Status;

//
// This patch is not required before macOS 10.15.4.
//
if (!OcMatchDarwinVersion (KernelVersion, 0, KERNEL_VERSION (19, 4, 0))) {
DEBUG ((DEBUG_INFO, "OCAK: Skipping patching AquantiaEthernet before %u\n", KernelVersion));
return EFI_SUCCESS;
}

if (Patcher == NULL) {
return EFI_NOT_FOUND;
}

Status = PatcherApplyGenericPatch (Patcher, &mAquantiaEthernetPatch);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCAK: Failed to apply Aquantia Ethernet patch - %r\n", Status));
} else {
DEBUG ((DEBUG_INFO, "OCAK: Patch success Aquantia Ethernet\n"));
}

return Status;
}

STATIC
EFI_STATUS
PatchForceSecureBootScheme (
Expand Down Expand Up @@ -2085,6 +2151,7 @@ KERNEL_QUIRK gKernelQuirks[] = {
[KernelQuirkLegacyCommpage] = { NULL, PatchLegacyCommpage },
[KernelQuirkForceSecureBootScheme] = { "com.apple.security.AppleImage4", PatchForceSecureBootScheme },
[KernelQuirkSetApfsTrimTimeout] = { "com.apple.filesystems.apfs", PatchSetApfsTrimTimeout },
[KernelQuirkForceAquantiaEthernet] = { "com.apple.driver.AppleEthernetAquantiaAqtion", PatchAquantiaEthernet },
};

EFI_STATUS
Expand Down
1 change: 1 addition & 0 deletions Library/OcConfigurationLib/OcConfigurationLib.c
Expand Up @@ -359,6 +359,7 @@ mKernelQuirksSchema[] = {
OC_SCHEMA_BOOLEAN_IN ("DisableRtcChecksum", OC_GLOBAL_CONFIG, Kernel.Quirks.DisableRtcChecksum),
OC_SCHEMA_BOOLEAN_IN ("ExtendBTFeatureFlags", OC_GLOBAL_CONFIG, Kernel.Quirks.ExtendBTFeatureFlags),
OC_SCHEMA_BOOLEAN_IN ("ExternalDiskIcons", OC_GLOBAL_CONFIG, Kernel.Quirks.ExternalDiskIcons),
OC_SCHEMA_BOOLEAN_IN ("ForceAquantiaEthernet", OC_GLOBAL_CONFIG, Kernel.Quirks.ForceAquantiaEthernet),
OC_SCHEMA_BOOLEAN_IN ("ForceSecureBootScheme", OC_GLOBAL_CONFIG, Kernel.Quirks.ForceSecureBootScheme),
OC_SCHEMA_BOOLEAN_IN ("IncreasePciBarSize", OC_GLOBAL_CONFIG, Kernel.Quirks.IncreasePciBarSize),
OC_SCHEMA_BOOLEAN_IN ("LapicKernelPanic", OC_GLOBAL_CONFIG, Kernel.Quirks.LapicKernelPanic),
Expand Down
4 changes: 4 additions & 0 deletions Library/OcMainLib/OpenCoreKernelPatch.c
Expand Up @@ -256,6 +256,10 @@ OcKernelApplyPatches (
OcKernelApplyQuirk (KernelQuirkExtendBTFeatureFlags, CacheType, DarwinVersion, Context, NULL);
}

if (Config->Kernel.Quirks.ForceAquantiaEthernet) {
OcKernelApplyQuirk (KernelQuirkForceAquantiaEthernet, CacheType, DarwinVersion, Context, NULL);
}

if (Config->Kernel.Quirks.ForceSecureBootScheme) {
OcKernelApplyQuirk (KernelQuirkForceSecureBootScheme, CacheType, DarwinVersion, Context, NULL);
}
Expand Down

0 comments on commit 41882d9

Please sign in to comment.