Allow native Macs to use OpenCore

Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/178
This commit is contained in:
Mykola Grymalyuk
2021-04-30 23:27:43 -06:00
parent d5ff1edc44
commit d40e9c869d
7 changed files with 79 additions and 61 deletions

View File

@@ -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

View File

@@ -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}")

View File

@@ -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],

View File

@@ -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")

View File

@@ -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")

View File

@@ -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

View File

@@ -884,7 +884,7 @@
<key>Count</key>
<integer>1</integer>
<key>Enabled</key>
<true/>
<false/>
<key>Find</key>
<data>c21jLXZlcnNpb24=</data>
<key>Identifier</key>
@@ -904,36 +904,6 @@
<key>Skip</key>
<integer>0</integer>
</dict>
<dict>
<key>Arch</key>
<string>x86_64</string>
<key>Base</key>
<string></string>
<key>Comment</key>
<string>Patch AppleIntelSNBGraphicsFB</string>
<key>Count</key>
<integer>0</integer>
<key>Enabled</key>
<false/>
<key>Find</key>
<data></data>
<key>Identifier</key>
<string>com.apple.driver.AppleIntelSNBGraphicsFB</string>
<key>Limit</key>
<integer>0</integer>
<key>Mask</key>
<data></data>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string>20.0.0</string>
<key>Replace</key>
<data></data>
<key>ReplaceMask</key>
<data></data>
<key>Skip</key>
<integer>0</integer>
</dict>
</array>
<key>Quirks</key>
<dict>
@@ -1124,10 +1094,12 @@
</dict>
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
<dict>
<key>rtc-blacklist</key>
<data></data>
<key>OCLP-Version</key>
<string></string>
<key>revcpu</key>
<string></string>
<key>revcpuname</key>
<string></string>
</dict>
<key>7C436110-AB2A-4BBB-A880-FE41995C9F82</key>
<dict>
@@ -1152,8 +1124,9 @@
</array>
<key>4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102</key>
<array>
<string>rtc-blacklist</string>
<string>OCLP-Version</string>
<string>revcpu</string>
<string>revcpuname</string>
</array>
<key>7C436110-AB2A-4BBB-A880-FE41995C9F82</key>
<array>
@@ -1334,7 +1307,7 @@
<key>UpdateNVRAM</key>
<false/>
<key>UpdateSMBIOS</key>
<true/>
<false/>
<key>UpdateSMBIOSMode</key>
<string>Create</string>
<key>UseRawUuidEncoding</key>