From d40e9c869d25a54a7d7c5ba76d779e9bd54a137b Mon Sep 17 00:00:00 2001
From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com>
Date: Fri, 30 Apr 2021 23:27:43 -0600
Subject: [PATCH] Allow native Macs to use OpenCore
Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/178
---
CHANGELOG.md | 3 ++
OCLP-CLI.command | 11 +++++++
OpenCore-Patcher.command | 3 +-
Resources/Build.py | 61 +++++++++++++++++++++---------------
Resources/CliMenu.py | 18 +++++++++++
Resources/Constants.py | 1 +
payloads/Config/config.plist | 43 +++++--------------------
7 files changed, 79 insertions(+), 61 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45cd18ab6..d6cca6d0a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,9 @@
- Add 3rd Party NVMe Power Management Patches
- NVMeFix fafc52d (1.0.7 rolling - 04-29-2021)
- Strip unused ACPI and Kernel entries during build
+- Allow native Macs to use OpenCore
+ - Better 3rd party NVMe support
+ - Better Wireless networking support
## 0.1.1
- Fix iMac11,3 GFX0 pathing
diff --git a/OCLP-CLI.command b/OCLP-CLI.command
index bee79dc98..48116d273 100755
--- a/OCLP-CLI.command
+++ b/OCLP-CLI.command
@@ -71,6 +71,8 @@ class OpenCoreLegacyPatcher():
parser.add_argument('--disable_sip', help='Disable SIP', action='store_true', required=False)
parser.add_argument('--disable_smb', help='Disable SecureBootModel', action='store_true', required=False)
parser.add_argument('--vault', help='Enable OpenCore Vaulting', action='store_true', required=False)
+ parser.add_argument('--support_all', help='Allow OpenCore on natively supported Models', action='store_true', required=False)
+ parser.add_argument('--force_legacy', help='Allow acceleration on Mac Pros and Xserves', action='store_true', required=False)
# Building args requiring value values
parser.add_argument('--model', action='store', help='Set custom model', required=False)
@@ -140,6 +142,15 @@ class OpenCoreLegacyPatcher():
else:
print(f"- Unknown SMBIOS arg passed: {args.smbios_spoof}")
+ if args.support_all:
+ print("- Building for natively supported model")
+ self.constants.allow_oc_everywhere = True
+ self.constants.serial_settings = "None"
+
+ if args.force_legacy:
+ print("- Allowing legacy acceleration patches on newer models")
+ self.constants.assume_legacy = True
+
if args.build:
if args.model:
print(f"- Using custom model: {args.model}")
diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command
index 12e12e462..8066a5963 100755
--- a/OpenCore-Patcher.command
+++ b/OpenCore-Patcher.command
@@ -110,6 +110,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
[f"Set Generic Bootstrap:\t\t{self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).bootstrap_setting],
[f"Set Acceleration Patches:\t\t{self.constants.legacy_acceleration_patch}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).accel_setting],
[f"Assume Legacy GPU:\t\t\t{self.constants.assume_legacy}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).force_accel_setting],
+ [f"Allow OpenCore on native Models:\t{self.constants.allow_oc_everywhere}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).allow_native_models],
]
for option in options:
@@ -191,7 +192,7 @@ B. Exit
menu = Utilities.TUIMenu(title, "Please select an option: ", in_between=in_between, auto_number=True, top_level=True)
options = (
- [["Build OpenCore", self.build_opencore]] if ((self.constants.custom_model or self.current_model) in ModelArray.SupportedSMBIOS) else []) + [
+ [["Build OpenCore", self.build_opencore]] if ((self.constants.custom_model or self.current_model) in ModelArray.SupportedSMBIOS) or self.constants.allow_oc_everywhere is True else []) + [
["Install OpenCore to USB/internal drive", self.install_opencore],
["Post-Install Volume Patch", self.PatchVolume],
["Change Model", self.change_model],
diff --git a/Resources/Build.py b/Resources/Build.py
index 5f019034b..2da8c6988 100644
--- a/Resources/Build.py
+++ b/Resources/Build.py
@@ -109,16 +109,16 @@ class BuildOpenCore:
for name, version, path, check in [
# Essential kexts
("Lilu.kext", self.constants.lilu_version, self.constants.lilu_path, lambda: True),
- ("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path, lambda: True),
+ ("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path, lambda: self.constants.allow_oc_everywhere is False),
("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path, lambda: self.model in ModelArray.MacPro71),
("RestrictEvents.kext", self.constants.restrictevents_mbp_version, self.constants.restrictevents_mbp_path, lambda: self.model == "MacBookPro9,1"),
- ("NightShiftEnabler.kext", self.constants.nightshift_version, self.constants.nightshift_path, lambda: self.model not in ModelArray.NightShiftExclude),
- ("SMC-Spoof.kext", self.constants.smcspoof_version, self.constants.smcspoof_path, lambda: True),
+ ("NightShiftEnabler.kext", self.constants.nightshift_version, self.constants.nightshift_path, lambda: self.model not in ModelArray.NightShiftExclude and self.constants.allow_oc_everywhere is False),
+ ("SMC-Spoof.kext", self.constants.smcspoof_version, self.constants.smcspoof_path, lambda: self.constants.allow_oc_everywhere is False),
# CPU patches
("AppleMCEReporterDisabler.kext", self.constants.mce_version, self.constants.mce_path, lambda: self.model in ModelArray.DualSocket),
("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path, lambda: self.model in ModelArray.SSEEmulator),
("telemetrap.kext", self.constants.telemetrap_version, self.constants.telemetrap_path, lambda: self.model in ModelArray.MissingSSE42),
- ("CPUFriend.kext", self.constants.cpufriend_version, self.constants.cpufriend_path, lambda: self.model not in ModelArray.NoAPFSsupport),
+ ("CPUFriend.kext", self.constants.cpufriend_version, self.constants.cpufriend_path, lambda: self.model not in ModelArray.NoAPFSsupport and self.constants.allow_oc_everywhere is False),
# Ethernet patches
("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path, lambda: self.model in ModelArray.EthernetNvidia),
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: self.model in ModelArray.EthernetMarvell),
@@ -130,6 +130,9 @@ class BuildOpenCore:
]:
self.enable_kext(name, version, path, check)
+ if self.constants.allow_oc_everywhere is False:
+ self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleSMC")["Enabled"] = True
+
if not self.constants.custom_model:
nvme_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
@@ -261,7 +264,7 @@ class BuildOpenCore:
# CPUFriend
pp_map_path = Path(self.constants.platform_plugin_plist_path) / Path(f"{self.model}/Info.plist")
- if self.model not in ModelArray.NoAPFSsupport:
+ if self.model not in ModelArray.NoAPFSsupport and self.constants.allow_oc_everywhere is False:
Path(self.constants.pp_kext_folder).mkdir()
Path(self.constants.pp_contents_folder).mkdir()
shutil.copy(pp_map_path, self.constants.pp_contents_folder)
@@ -288,7 +291,7 @@ class BuildOpenCore:
# USB Map
usb_map_path = Path(self.constants.plist_folder_path) / Path("AppleUSBMaps/Info.plist")
# iMac7,1 kernel panics with USB map installed, remove for time being until properly debugged
- if usb_map_path.exists():
+ if usb_map_path.exists() and self.constants.allow_oc_everywhere is False:
print(f"- Adding USB-Map.kext")
Path(self.constants.map_kext_folder).mkdir()
Path(self.constants.map_contents_folder).mkdir()
@@ -559,20 +562,26 @@ class BuildOpenCore:
print("- Spoofing to MacPro7,1")
spoofed_model = "MacPro7,1"
spoofed_board = "Mac-27AD2F918AE68F61"
+ else:
+ spoofed_model = self.model
+ spoofed_board = ""
self.spoofed_model = spoofed_model
self.spoofed_board = spoofed_board
- self.config["#Revision"]["Spoofed-Model"] = f"{self.spoofed_model} - {self.constants.serial_settings}"
+ if self.constants.allow_oc_everywhere is False:
+ self.config["#Revision"]["Spoofed-Model"] = f"{self.spoofed_model} - {self.constants.serial_settings}"
# Setup menu
def minimal_serial_patch(self):
self.config["PlatformInfo"]["PlatformNVRAM"]["BID"] = self.spoofed_board
self.config["PlatformInfo"]["SMBIOS"]["BoardProduct"] = self.spoofed_board
self.config["PlatformInfo"]["UpdateNVRAM"] = True
+ self.config["PlatformInfo"]["UpdateSMBIOS"] = True
def moderate_serial_patch(self):
self.config["PlatformInfo"]["Automatic"] = True
self.config["PlatformInfo"]["UpdateDataHub"] = True
self.config["PlatformInfo"]["UpdateNVRAM"] = True
+ self.config["PlatformInfo"]["UpdateSMBIOS"] = True
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
@@ -582,6 +591,7 @@ class BuildOpenCore:
self.config["PlatformInfo"]["Automatic"] = True
self.config["PlatformInfo"]["UpdateDataHub"] = True
self.config["PlatformInfo"]["UpdateNVRAM"] = True
+ self.config["PlatformInfo"]["UpdateSMBIOS"] = True
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("0016CB445566")
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
@@ -601,28 +611,29 @@ class BuildOpenCore:
minimal_serial_patch(self)
# USB Map Patching
- new_map_ls = Path(self.constants.map_contents_folder) / Path("Info.plist")
- map_config = plistlib.load(Path(new_map_ls).open("rb"))
+ if self.constants.allow_oc_everywhere is False:
+ new_map_ls = Path(self.constants.map_contents_folder) / Path("Info.plist")
+ map_config = plistlib.load(Path(new_map_ls).open("rb"))
- for model_controller in ModelArray.ControllerTypes:
- model_patch = f"{self.model}{model_controller}"
- try:
- # Avoid erroring out when specific identity not found
- map_config["IOKitPersonalities_x86_64"][model_patch]["model"] = self.spoofed_model
+ for model_controller in ModelArray.ControllerTypes:
+ model_patch = f"{self.model}{model_controller}"
+ try:
+ # Avoid erroring out when specific identity not found
+ map_config["IOKitPersonalities_x86_64"][model_patch]["model"] = self.spoofed_model
- # Avoid ACPI renaming when not required
- if self.constants.serial_settings == "Minimal":
- if map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] == "EH01":
- map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] = "EHC1"
- if map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] == "EH02":
- map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] = "EHC2"
- if map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] == "SHC1":
- map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] = "XHC1"
+ # Avoid ACPI renaming when not required
+ if self.constants.serial_settings == "Minimal":
+ if map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] == "EH01":
+ map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] = "EHC1"
+ if map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] == "EH02":
+ map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] = "EHC2"
+ if map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] == "SHC1":
+ map_config["IOKitPersonalities_x86_64"][model_patch]["IONameMatch"] = "XHC1"
- except KeyError:
- continue
+ except KeyError:
+ continue
- plistlib.dump(map_config, Path(new_map_ls).open("wb"), sort_keys=True)
+ plistlib.dump(map_config, Path(new_map_ls).open("wb"), sort_keys=True)
if self.model == "MacBookPro9,1":
new_agdp_ls = Path(self.constants.agdp_contents_folder) / Path("Info.plist")
diff --git a/Resources/CliMenu.py b/Resources/CliMenu.py
index 97415a0a4..2b4424126 100644
--- a/Resources/CliMenu.py
+++ b/Resources/CliMenu.py
@@ -310,5 +310,23 @@ DO NOT RUN IF METAL GPU IS INSTALLED
self.constants.assume_legacy = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.assume_legacy = False
+ else:
+ print("Invalid option")
+
+ def allow_native_models(self):
+ Utilities.cls()
+ Utilities.header(["Allow OpenCore on native Models"])
+ print("""Allows natively supported Macs to use OpenCore. Recommended
+for users with 3rd Party NVMe SSDs to achieve improved overall
+power usage.
+
+ """)
+ change_menu = input("Allow OpenCore on all Models(y/n): ")
+ if change_menu in {"y", "Y", "yes", "Yes"}:
+ self.constants.allow_oc_everywhere = True
+ self.constants.serial_settings = "None"
+ elif change_menu in {"n", "N", "no", "No"}:
+ self.constants.allow_oc_everywhere = False
+ self.constants.serial_settings = "Minimal"
else:
print("Invalid option")
\ No newline at end of file
diff --git a/Resources/Constants.py b/Resources/Constants.py
index 4cb71f604..67ee742be 100644
--- a/Resources/Constants.py
+++ b/Resources/Constants.py
@@ -73,6 +73,7 @@ class Constants:
self.drm_support = False
self.legacy_acceleration_patch = True
self.assume_legacy = False
+ self.allow_oc_everywhere = False
# OS Versions
self.tiger = 8
diff --git a/payloads/Config/config.plist b/payloads/Config/config.plist
index 1d06357b8..e158f46bd 100644
--- a/payloads/Config/config.plist
+++ b/payloads/Config/config.plist
@@ -884,7 +884,7 @@
Count
1
Enabled
-
+
Find
c21jLXZlcnNpb24=
Identifier
@@ -904,36 +904,6 @@
Skip
0
-
- Arch
- x86_64
- Base
-
- Comment
- Patch AppleIntelSNBGraphicsFB
- Count
- 0
- Enabled
-
- Find
-
- Identifier
- com.apple.driver.AppleIntelSNBGraphicsFB
- Limit
- 0
- Mask
-
- MaxKernel
-
- MinKernel
- 20.0.0
- Replace
-
- ReplaceMask
-
- Skip
- 0
-
Quirks
@@ -1124,10 +1094,12 @@
4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102
- rtc-blacklist
-
OCLP-Version
+ revcpu
+
+ revcpuname
+
7C436110-AB2A-4BBB-A880-FE41995C9F82
@@ -1152,8 +1124,9 @@
4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102
- rtc-blacklist
OCLP-Version
+ revcpu
+ revcpuname
7C436110-AB2A-4BBB-A880-FE41995C9F82
@@ -1334,7 +1307,7 @@
UpdateNVRAM
UpdateSMBIOS
-
+
UpdateSMBIOSMode
Create
UseRawUuidEncoding