diff --git a/.flake8 b/.flake8 index 83c619e6e..81016e515 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] -ignore = E501 +extend-ignore = E501, E203 per-file-ignores = Resources/Constants.py:E704 \ No newline at end of file diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 40fe1a839..6ac20bcae 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -3,120 +3,129 @@ from __future__ import print_function -import plistlib +import platform import subprocess import sys -import platform -from Resources import Build, ModelArray, PCIIDArray, Constants, SysPatch, Utilities, CliMenu, DeviceProbe +from Resources import (Build, CliMenu, Constants, ModelArray, SysPatch, + Utilities, device_probe) -class OpenCoreLegacyPatcher(): +class OpenCoreLegacyPatcher: def __init__(self): + print("Loading...") self.constants = Constants.Constants() - self.current_model: str = None - self.current_model = DeviceProbe.smbios_probe().model_detect(False) + self.constants.computer = device_probe.Computer.probe() + self.computer = self.constants.computer self.constants.detected_os = int(platform.uname().release.partition(".")[0]) - self.check_default_settings(self.current_model, False) + self.set_defaults(self.computer.real_model, True) - custom_cpu_model_value: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:revcpuname".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - if not custom_cpu_model_value.startswith("nvram: Error getting variable"): - custom_cpu_model_value = [line.strip().split(":revcpuname ", 1)[1] for line in custom_cpu_model_value.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0] - if custom_cpu_model_value.split("%00")[0] != "": - self.constants.custom_cpu_model = 1 - self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0] + custom_cpu_model_value = Utilities.get_nvram("revcpuname", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) + if custom_cpu_model_value is not None: + # TODO: Fix to not use two separate variables + self.constants.custom_cpu_model = 1 + self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0] - if "-v" in (Utilities.get_nvram("boot-args", decode=False) or ""): + if "-v" in (Utilities.get_nvram("boot-args") or ""): self.constants.verbose_debug = True # Check if running in RecoveryOS - self.check_recovery() + self.constants.recovery_status = Utilities.check_recovery() - def check_default_settings(self, model, custom): + def set_defaults(self, model, host_is_target): + # Defaults self.constants.sip_status = True + self.constants.secure_status = False # Default false for Monterey self.constants.disable_amfi = False + if model in ModelArray.LegacyGPU: - if custom is False: - dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - if (dgpu_vendor == self.constants.pci_amd_ati and (dgpu_device in PCIIDArray.amd_ids().polaris_ids or dgpu_device in PCIIDArray.amd_ids().vega_ids or dgpu_device in PCIIDArray.amd_ids().navi_ids or dgpu_device in PCIIDArray.amd_ids().legacy_gcn_ids)) or (dgpu_vendor == self.constants.pci_nvidia and dgpu_device in PCIIDArray.nvidia_ids().kepler_ids): - self.constants.sip_status = True - self.constants.secure_status = False - self.constants.disable_amfi = False - else: - self.constants.sip_status = False - self.constants.secure_status = False - self.constants.disable_amfi = True + if ( + host_is_target + and self.computer.dgpu.arch + in [ + device_probe.AMD.Archs.Legacy_GCN, + device_probe.AMD.Archs.Polaris, + device_probe.AMD.Archs.Vega, + device_probe.AMD.Archs.Navi, + device_probe.NVIDIA.Archs.Kepler, + ] + ): + # Building on device and we have a native, supported GPU + self.constants.sip_status = True + # self.constants.secure_status = True # Monterey + self.constants.disable_amfi = False else: - self.constants.sip_status = False - self.constants.secure_status = False - self.constants.disable_amfi = True + self.constants.sip_status = False # Unsigned kexts + self.constants.secure_status = False # Root volume modified + self.constants.disable_amfi = True # Unsigned binaries if model in ModelArray.ModernGPU: - if model in ["iMac13,1", "iMac13,3"]: - - if custom is False: - dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - if not dgpu_vendor: - self.constants.sip_status = False - self.constants.secure_status = False + if host_is_target and model in ["iMac13,1", "iMac13,3"] and self.computer.dgpu: + # Some models have a supported dGPU, others don't + self.constants.sip_status = True + # self.constants.secure_status = True # Monterey + #self.constants.disable_amfi = False # Signed bundles, Don't need to explicitly set currently else: - self.constants.sip_status = False - self.constants.secure_status = False - - def check_recovery(self): - root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - if root_partition_info["VolumeName"] == "macOS Base System" and \ - root_partition_info["FilesystemType"] == "apfs" and \ - root_partition_info["BusProtocol"] == "Disk Image": - self.constants.recovery_status = True - else: - self.constants.recovery_status = False + self.constants.sip_status = False # Unsigned kexts + self.constants.secure_status = False # Modified root volume + #self.constants.disable_amfi = False # Signed bundles, Don't need to explicitly set currently def build_opencore(self): - Build.BuildOpenCore(self.constants.custom_model or self.current_model, self.constants).build_opencore() + Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore() def install_opencore(self): - Build.BuildOpenCore(self.constants.custom_model or self.current_model, self.constants).copy_efi() + Build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).copy_efi() def change_model(self): Utilities.cls() Utilities.header(["Select Different Model"]) - print(""" + print( + """ Tip: Run the following command on the target machine to find the model identifier: system_profiler SPHardwareDataType | grep 'Model Identifier' - """) + """ + ) self.constants.custom_model = input("Please enter the model identifier of the target machine: ").strip() if self.constants.custom_model not in ModelArray.SupportedSMBIOS: - print(f""" - {self.constants.custom_model} is not a valid SMBIOS Identifier for macOS {self.constants.os_support}! - """) + print( + f""" +{self.constants.custom_model} is not a valid SMBIOS Identifier for macOS {self.constants.os_support}! +""" + ) print_models = input(f"Print list of valid options for macOS {self.constants.os_support}? (y/n)") - if print_models in {"y", "Y", "yes", "Yes"}: + if print_models.lower() in {"y", "yes"}: print("\n".join(ModelArray.SupportedSMBIOS)) input("\nPress [ENTER] to continue") else: - self.check_default_settings(self.constants.custom_model, True) + self.set_defaults(self.constants.custom_model, False) def patcher_settings(self): response = None while not (response and response == -1): - title = [ - "Adjust Patcher Settings" - ] + title = ["Adjust Patcher Settings"] menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) options = [ - [f"Enable Verbose Mode:\t\tCurrently {self.constants.verbose_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_verbose], - [f"Enable OpenCore DEBUG:\t\tCurrently {self.constants.opencore_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_oc], - [f"Enable Kext DEBUG:\t\t\tCurrently {self.constants.kext_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_kext], - [f"Set ShowPicker Mode:\t\tCurrently {self.constants.showpicker}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_showpicker], - [f"Set Vault Mode:\t\t\tCurrently {self.constants.vault}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_vault], - [f"Allow FireWire Boot:\t\tCurrently {self.constants.firewire_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).allow_firewire], - [f"Allow NVMe Boot:\t\t\tCurrently {self.constants.nvme_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).allow_nvme], - [f"Enable TeraScale 2 Acceleration:\tCurrently {self.constants.terscale_2_patch}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).enable_terascale], - [f"Disable AMFI:\t\t\tCurrently {self.constants.disable_amfi}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).set_amfi], - [f"Set SIP and SecureBootModel:\tSIP: {self.constants.sip_status} SBM: {self.constants.secure_status}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_sip], - [f"Allow OpenCore on native Models:\tCurrently {self.constants.allow_oc_everywhere}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).allow_native_models], - [f"Advanced Patch Settings, for developers only", self.advanced_patcher_settings], + [f"Enable Verbose Mode:\t\tCurrently {self.constants.verbose_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_verbose], + [f"Enable OpenCore DEBUG:\t\tCurrently {self.constants.opencore_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_oc], + [f"Enable Kext DEBUG:\t\t\tCurrently {self.constants.kext_debug}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_kext], + [f"Set ShowPicker Mode:\t\tCurrently {self.constants.showpicker}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_showpicker], + [f"Set Vault Mode:\t\t\tCurrently {self.constants.vault}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_vault], + [f"Allow FireWire Boot:\t\tCurrently {self.constants.firewire_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_firewire], + [f"Allow NVMe Boot:\t\t\tCurrently {self.constants.nvme_boot}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_nvme], + [ + f"Enable TeraScale 2 Acceleration:\tCurrently {self.constants.terascale_2_patch}", + CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).enable_terascale, + ], + [f"Disable AMFI:\t\t\tCurrently {self.constants.disable_amfi}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).set_amfi], + [ + f"Set SIP and SecureBootModel:\tSIP: {self.constants.sip_status} SBM: {self.constants.secure_status}", + CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_sip, + ], + [ + f"Allow OpenCore on native Models:\tCurrently {self.constants.allow_oc_everywhere}", + CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).allow_native_models, + ], + ["Advanced Patch Settings, for developers only", self.advanced_patcher_settings], ] for option in options: @@ -127,21 +136,22 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' def advanced_patcher_settings(self): response = None while not (response and response == -1): - title = [ - "Adjust Advanced Patcher Settings, for developers ONLY" - ] + title = ["Adjust Advanced Patcher Settings, for developers ONLY"] menu = Utilities.TUIMenu(title, "Please select an option: ", auto_number=True, top_level=True) options = [ - [f"Assume Metal GPU Always:\t\tCurrently {self.constants.imac_vendor}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_metal], - #[f"Assume Upgraded Wifi Always:\tCurrently {self.constants.wifi_build}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_wifi], - [f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_serial], - [f"DRM Preferences:\t\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).drm_setting], - [f"Set Generic Bootstrap:\t\tCurrently {self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).bootstrap_setting], - #[f"Assume Legacy GPU:\t\t\tCurrently {self.constants.assume_legacy}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).force_accel_setting], - [f"Disable CPU Friend:\t\t\tCurrently {self.constants.disallow_cpufriend}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).disable_cpufriend], - [f"Override SMBIOS Spoof:\t\tCurrently {self.constants.override_smbios}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).set_smbios], - [f"Set Custom name {self.constants.custom_cpu_model_value}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).custom_cpu], - [f"Set SeedUtil Status", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).set_seedutil], + [f"Assume Metal GPU Always:\t\tCurrently {self.constants.imac_vendor}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_metal], + # [f"Assume Upgraded Wifi Always:\tCurrently {self.constants.wifi_build}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_wifi], + [f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).change_serial], + [f"DRM Preferences:\t\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).drm_setting], + [f"Set Generic Bootstrap:\t\tCurrently {self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).bootstrap_setting], + # [f"Assume Legacy GPU:\t\t\tCurrently {self.constants.assume_legacy}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).force_accel_setting], + [ + f"Disable CPU Friend:\t\t\tCurrently {self.constants.disallow_cpufriend}", + CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).disable_cpufriend, + ], + [f"Override SMBIOS Spoof:\t\tCurrently {self.constants.override_smbios}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).set_smbios], + [f"Set Custom name {self.constants.custom_cpu_model_value}", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).custom_cpu], + ["Set SeedUtil Status", CliMenu.MenuOptions(self.constants.custom_model or self.computer.real_model, self.constants).set_seedutil], ] for option in options: @@ -150,8 +160,11 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' response = menu.start() def credits(self): - Utilities.TUIOnlyPrint(["Credits"], "Press [Enter] to go back.\n", - ["""Many thanks to the following: + Utilities.TUIOnlyPrint( + ["Credits"], + "Press [Enter] to go back.\n", + [ + """Many thanks to the following: - Acidanthera:\tOpenCore, kexts and other tools - Khronokernel:\tWriting and maintaining this patcher @@ -159,7 +172,9 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' - ASentientBot:\tLegacy Acceleration Patches - Ausdauersportler:\tLinking fixes for SNBGraphicsFB and AMDX3000 - Syncretic:\t\tAAAMouSSE and telemetrap - - cdf:\t\tNightShiftEnabler and Innie"""]).start() + - cdf:\t\tNightShiftEnabler and Innie""" + ], + ).start() def PatchVolume(self): Utilities.cls() @@ -223,9 +238,9 @@ B. Exit no_patch = True change_menu = input("Patch System Volume?: ") if no_patch is not True and change_menu == "1": - SysPatch.PatchSysVolume(self.constants.custom_model or self.current_model, self.constants).start_patch() + SysPatch.PatchSysVolume(self.constants.custom_model or self.computer.real_model, self.constants).start_patch() elif no_patch is not True and change_menu == "2": - SysPatch.PatchSysVolume(self.constants.custom_model or self.current_model, self.constants).start_unpatch() + SysPatch.PatchSysVolume(self.constants.custom_model or self.computer.real_model, self.constants).start_unpatch() else: print("Returning to main menu") @@ -234,38 +249,38 @@ B. Exit while not (response and response == -1): title = [ f"OpenCore Legacy Patcher v{self.constants.patcher_version}", - f"Selected Model: {self.constants.custom_model or self.current_model}", + f"Selected Model: {self.constants.custom_model or self.computer.real_model}", ] - if (self.constants.custom_model or self.current_model) not in ModelArray.SupportedSMBIOS and self.constants.allow_oc_everywhere is False: + if (self.constants.custom_model or self.computer.real_model) not in ModelArray.SupportedSMBIOS and self.constants.allow_oc_everywhere is False: in_between = [ - 'Your model is not supported by this patcher for running unsupported OSes!', - '', - 'If you plan to create the USB for another machine, please select the "Change Model" option in the menu.' + "Your model is not supported by this patcher for running unsupported OSes!", + "", + 'If you plan to create the USB for another machine, please select the "Change Model" option in the menu.', ] - elif not self.constants.custom_model and self.current_model == "iMac7,1" and \ - DeviceProbe.pci_probe().cpu_feature("SSE4.1") is False: + elif not self.constants.custom_model and self.computer.real_model == "iMac7,1" and "SSE4.1" not in self.computer.cpu.flags: in_between = [ - 'Your model requires a CPU upgrade to a CPU supporting SSE4.1+ to be supported by this patcher!', - '', - f'If you plan to create the USB for another {self.current_model} with SSE4.1+, please select the "Change Model" option in the menu.' + "Your model requires a CPU upgrade to a CPU supporting SSE4.1+ to be supported by this patcher!", + "", + f'If you plan to create the USB for another {self.computer.real_model} with SSE4.1+, please select the "Change Model" option in the menu.', ] elif self.constants.custom_model == "iMac7,1": - in_between = ["This model is supported", - "However please ensure the CPU has been upgraded to support SSE4.1+" - ] + in_between = ["This model is supported", "However please ensure the CPU has been upgraded to support SSE4.1+"] else: in_between = ["This model is supported"] 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) or self.constants.allow_oc_everywhere is True else []) + [ + [["Build OpenCore", self.build_opencore]] + if ((self.constants.custom_model or self.computer.real_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], ["Patcher Settings", self.patcher_settings], - ["Credits", self.credits] + ["Credits", self.credits], ] for option in options: diff --git a/Resources/Build.py b/Resources/Build.py index 9f256afd7..c8c777bf1 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -3,6 +3,8 @@ from __future__ import print_function import binascii +import copy +import pickle import plistlib import shutil import subprocess @@ -12,7 +14,7 @@ import ast from pathlib import Path from datetime import date -from Resources import Constants, ModelArray, PCIIDArray, Utilities, DeviceProbe +from Resources import Constants, ModelArray, Utilities, device_probe def human_fmt(num): @@ -34,6 +36,9 @@ class BuildOpenCore: self.model = model self.config = None self.constants: Constants.Constants = versions + self.computer = self.constants.computer + + self.gfx0_path = None def smbios_set(self): print("- Setting macOS Monterey Supported SMBIOS") @@ -83,14 +88,14 @@ class BuildOpenCore: # Additionally, APFS bit(19) flipped # https://github.com/acidanthera/OpenCorePkg/blob/0.6.9/Include/Apple/IndustryStandard/AppleFeatures.h#L136 if model == "iMac7,1": - fw_feature = b'\x07\x14\x08\xc0\x00\x00\x00\x00' - fw_mask = b'\xff\x1f\x08\xc0\x00\x00\x00\x00' + fw_feature = b"\x07\x14\x08\xc0\x00\x00\x00\x00" + fw_mask = b"\xff\x1f\x08\xc0\x00\x00\x00\x00" elif model in ["MacPro4,1", "Xserve3,1"]: - fw_feature = b'7\xf5\t\xe0\x00\x00\x00\x00' - fw_mask = b'7\xff\x0b\xc0\x00\x00\x00\x00' + fw_feature = b"7\xf5\t\xe0\x00\x00\x00\x00" + fw_mask = b"7\xff\x0b\xc0\x00\x00\x00\x00" else: - fw_feature = b'\x03\x14\x08\xc0\x00\x00\x00\x00' - fw_mask = b'\xff\x3f\x08\xc0\x00\x00\x00\x00' + fw_feature = b"\x03\x14\x08\xc0\x00\x00\x00\x00" + fw_mask = b"\xff\x3f\x08\xc0\x00\x00\x00\x00" return fw_feature, fw_mask def build_efi(self): @@ -126,6 +131,9 @@ class BuildOpenCore: self.config["#Revision"]["Build-Version"] = f"{self.constants.patcher_version} - {date.today()}" if not self.constants.custom_model: self.config["#Revision"]["Build-Type"] = "OpenCore Built on Target Machine" + computer_copy = copy.copy(self.computer) + computer_copy.ioregistry = None + self.config["#Revision"]["Hardware-Probe"] = pickle.dumps(computer_copy) else: self.config["#Revision"]["Build-Type"] = "OpenCore Built for External Machine" self.config["#Revision"]["OpenCore-Version"] = f"{self.constants.opencore_version} - {self.constants.opencore_build} - {self.constants.opencore_commit}" @@ -138,13 +146,23 @@ class BuildOpenCore: ("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 in ["MacBookPro6,1", "MacBookPro6,2", "MacBookPro9,1"]), - ("NightShiftEnabler.kext", self.constants.nightshift_version, self.constants.nightshift_path, lambda: self.model in ModelArray.NightShift and self.constants.allow_oc_everywhere is False and self.constants.serial_settings == "Minimal"), + ( + "NightShiftEnabler.kext", + self.constants.nightshift_version, + self.constants.nightshift_path, + lambda: self.model in ModelArray.NightShift and self.constants.allow_oc_everywhere is False and self.constants.serial_settings == "Minimal", + ), ("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 ["iMac7,1", "Xserve2,1"] and self.constants.allow_oc_everywhere is False and self.constants.disallow_cpufriend is False), + ( + "CPUFriend.kext", + self.constants.cpufriend_version, + self.constants.cpufriend_path, + lambda: self.model not in ["iMac7,1", "Xserve2,1"] and self.constants.allow_oc_everywhere is False and self.constants.disallow_cpufriend 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), @@ -162,87 +180,51 @@ class BuildOpenCore: 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 and (self.constants.allow_oc_everywhere is True or self.model in ModelArray.MacPro71): # Use Innie's same logic: # https://github.com/cdf/Innie/blob/v1.3.0/Innie/Innie.cpp#L90-L97 - storage_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - storage_devices = [i for i in storage_devices if i["class-code"] == binascii.unhexlify(self.constants.classcode_sata) or i["class-code"] == binascii.unhexlify(self.constants.classcode_nvme)] - storage_path_gfx: str = subprocess.run([self.constants.gfxutil_path] + f"-v".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - try: - x = 1 - for i in storage_devices: - storage_vendor = Utilities.hexswap(binascii.hexlify(i["vendor-id"]).decode()[:4]) - storage_device = Utilities.hexswap(binascii.hexlify(i["device-id"]).decode()[:4]) - print(f'- Fixing PCIe Storage Controller ({x}) reporting') - try: - storage_path = [line.strip().split("= ", 1)[1] for line in storage_path_gfx.split("\n") if f'{storage_vendor}:{storage_device}'.lower() in line.strip()][0] - self.config["DeviceProperties"]["Add"][storage_path] = { "built-in": 1} - except IndexError: - print(f"- Failed to find Device path for PCIe Storage Controller {x}, falling back to Innie") - if self.get_kext_by_bundle_path("Innie.kext")["Enabled"] is False: - self.enable_kext("Innie.kext", self.constants.innie_version, self.constants.innie_path) - x = x + 1 - except ValueError: - print("- No PCIe Storage Controllers found to fix(V)") - except IndexError: - print("- No PCIe Storage Controllers found to fix(I)") + for i, controller in enumerate(self.computer.storage): + print(f"- Fixing PCIe Storage Controller ({i + 1}) reporting") + if controller.pci_path: + self.config["DeviceProperties"]["Add"][controller.pci_path] = {"built-in": 1} + else: + print(f"- Failed to find Device path for PCIe Storage Controller {i}, falling back to Innie") + if self.get_kext_by_bundle_path("Innie.kext")["Enabled"] is False: + self.enable_kext("Innie.kext", self.constants.innie_version, self.constants.innie_path) + if not self.computer.storage: + print("- No PCIe Storage Controllers found to fix") 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()) - nvme_devices = [i for i in nvme_devices if i.get("IORegistryEntryChildren", None) and i["vendor-id"] != binascii.unhexlify("6B100000") and i["IORegistryEntryChildren"][0]["IORegistryEntryName"] == "IONVMeController"] - try: - x = 1 - for i in nvme_devices: - nvme_vendor = Utilities.hexswap(binascii.hexlify(i["vendor-id"]).decode()[:4]) - nvme_device = Utilities.hexswap(binascii.hexlify(i["device-id"]).decode()[:4]) - print(f'- Found 3rd Party NVMe SSD ({x}): {nvme_vendor}:{nvme_device}') - nvme_aspm = i["pci-aspm-default"] - try: - nvme_acpi = i["acpi-path"] - nvme_acpi = DeviceProbe.pci_probe().acpi_strip(nvme_acpi) - except KeyError: - print(f"- No ACPI entry found for NVMe SSD ({x})") - nvme_acpi = "" - # Disable Bit 0 (L0s), enable Bit 1 (L1) - if not isinstance(nvme_aspm, int): - nvme_aspm = int.from_bytes(nvme_aspm, byteorder='little') - nvme_aspm = (nvme_aspm & (~3)) | 2 - #nvme_aspm &= ~1 # Turn off bit 1 - #nvme_aspm |= 2 # Turn on bit 2 - self.config["#Revision"][f"Hardware-NVMe-{x}"] = f'{nvme_vendor}:{nvme_device}' - try: - nvme_path = DeviceProbe.pci_probe().deviceproperty_probe(nvme_vendor, nvme_device, nvme_acpi) - if nvme_path == "": - raise IndexError - nvme_path_parent = DeviceProbe.pci_probe().device_property_parent(nvme_path) - print(f"- Found NVMe ({x}) at {nvme_path}") - self.config["DeviceProperties"]["Add"][nvme_path] = {"pci-aspm-default": nvme_aspm, "built-in": 1} - self.config["DeviceProperties"]["Add"][nvme_path_parent] = {"pci-aspm-default": nvme_aspm} - except IndexError: - if "-nvmefaspm" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: - print("- Falling back to -nvmefaspm") - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -nvmefaspm" - if self.get_kext_by_bundle_path("NVMeFix.kext")["Enabled"] is False: - self.enable_kext("NVMeFix.kext", self.constants.nvmefix_version, self.constants.nvmefix_path) - x = x + 1 - except ValueError: - print("- No 3rd Party NVMe drive found(V)") - except IndexError: - print("- No 3rd Party NVMe drive found(I)") + nvme_devices = [i for i in self.computer.storage if isinstance(i, device_probe.NVMeController)] + for i, controller in enumerate(nvme_devices): + print(f"- Found 3rd Party NVMe SSD ({i + 1}): {Utilities.friendly_hex(controller.vendor_id)}:{Utilities.friendly_hex(controller.device_id)}") + self.config["#Revision"][f"Hardware-NVMe-{i}"] = f"{Utilities.friendly_hex(controller.vendor_id)}:{Utilities.friendly_hex(controller.device_id)}" + + # Disable Bit 0 (L0s), enable Bit 1 (L1) + nvme_aspm = (controller.aspm & (~3)) | 2 + + if controller.pci_path: + print(f"- Found NVMe ({i}) at {controller.pci_path}") + self.config["DeviceProperties"]["Add"][controller.pci_path]["pci-aspm-default"] = nvme_aspm + self.config["DeviceProperties"]["Add"][controller.pci_path.rpartition("/")[0]] = {"pci-aspm-default": nvme_aspm} + else: + if "-nvmefaspm" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + print("- Falling back to -nvmefaspm") + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -nvmefaspm" + + if self.get_kext_by_bundle_path("NVMeFix.kext")["Enabled"] is False: + self.enable_kext("NVMeFix.kext", self.constants.nvmefix_version, self.constants.nvmefix_path) + + if not nvme_devices: + print("- No 3rd Party NVMe drives found") def wifi_fake_id(self): - default_path = True self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path) - #self.get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True - if not self.constants.custom_model: - arpt_path = DeviceProbe.pci_probe().deviceproperty_probe(wifi_vendor, wifi_device, wifi_acpi) - if arpt_path: - print(f"- Found ARPT device at {arpt_path}") - default_path = False - else: - default_path = True - if default_path is True: + # self.get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True + if not self.constants.custom_model and self.computer.wifi and self.computer.wifi.pci_path: + arpt_path = self.computer.wifi.pci_path + print(f"- Found ARPT device at {arpt_path}") + else: if self.model in ModelArray.nvidiaHDEF: # Nvidia chipsets all have the same path to ARPT arpt_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)" @@ -263,30 +245,29 @@ class BuildOpenCore: # WiFi patches # TODO: -a is not supported in Lion and older, need to add proper fix if self.constants.detected_os > self.constants.lion and not self.constants.custom_model: - wifi_vendor,wifi_device,wifi_ioname,wifi_acpi = DeviceProbe.pci_probe().wifi_probe() - if wifi_vendor: - print(f"- Found Wireless Device {wifi_vendor}:{wifi_device} ({wifi_ioname})") - self.config["#Revision"]["Hardware-Wifi"] = f"{wifi_vendor}:{wifi_device} ({wifi_ioname})" + if self.computer.wifi: + print(f"- Found Wireless Device {Utilities.friendly_hex(self.computer.wifi.vendor_id)}:{Utilities.friendly_hex(self.computer.wifi.device_id)}") + self.config["#Revision"]["Hardware-Wifi"] = f"{Utilities.friendly_hex(self.computer.wifi.vendor_id)}:{Utilities.friendly_hex(self.computer.wifi.device_id)}" else: - wifi_vendor = "" print("- Unable to run Wireless hardware detection") + if self.constants.wifi_build is True: print("- Skipping Wifi patches on request") - elif not self.constants.custom_model and wifi_vendor: - if wifi_vendor == self.constants.pci_broadcom: + elif not self.constants.custom_model and self.computer.wifi: + if isinstance(self.computer.wifi, device_probe.Broadcom): # This works around OCLP spoofing the Wifi card and therefore unable to actually detect the correct device - if wifi_device in PCIIDArray.broadcom_ids().BCM4360Wifi and wifi_ioname not in ["pci14e4,4353", "pci14e4,4331"]: + if self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirportBrcmNIC: self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path) - elif wifi_ioname in ["pci14e4,4353", "pci14e4,4331"] or wifi_device in PCIIDArray.broadcom_ids().BCM94331Wifi: + elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4360: wifi_fake_id(self) - elif wifi_device in PCIIDArray.broadcom_ids().BCM94322Wifi: + elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4331: self.enable_kext("IO80211Mojave.kext", self.constants.io80211mojave_version, self.constants.io80211mojave_path) self.get_kext_by_bundle_path("IO80211Mojave.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True - elif wifi_device in PCIIDArray.broadcom_ids().BCM94328Wifi: + elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm43224: self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path) self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path) self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True - elif wifi_vendor == self.constants.pci_atheros and wifi_device in PCIIDArray.atheros_ids().AtherosWifi: + elif isinstance(self.computer.wifi, device_probe.Atheros) and self.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40: self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path) self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True else: @@ -335,13 +316,12 @@ class BuildOpenCore: 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() and self.constants.allow_oc_everywhere is False and self.model not in ["iMac7,1", "Xserve2,1"]: - print(f"- Adding USB-Map.kext") + print("- Adding USB-Map.kext") Path(self.constants.map_kext_folder).mkdir() Path(self.constants.map_contents_folder).mkdir() shutil.copy(usb_map_path, self.constants.map_contents_folder) self.get_kext_by_bundle_path("USB-Map.kext")["Enabled"] = True - if self.constants.allow_oc_everywhere is False: if self.model == "MacBookPro9,1": print("- Adding AppleMuxControl Override") @@ -371,28 +351,33 @@ class BuildOpenCore: # AGPM Patch if self.model in ModelArray.DualGPUPatch: print("- Adding dual GPU patch") - if not self.constants.custom_model: - dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - self.gfx0_path = DeviceProbe.pci_probe().deviceproperty_probe(dgpu_vendor,dgpu_device,dgpu_acpi) - if self.gfx0_path == "": - print("- Failed to find GFX0 Device path, falling back on known logic") - self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)" - else: - print(f"- Found GFX0 Device Path: {self.gfx0_path}") + if not self.constants.custom_model and self.computer.dgpu and self.computer.dgpu.pci_path: + self.gfx0_path = self.computer.dgpu.pci_path + print(f"- Found GFX0 Device Path: {self.gfx0_path}") else: + if not self.constants.custom_model: + print("- Failed to find GFX0 Device path, falling back on known logic") self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)" + if self.model in ModelArray.IntelNvidiaDRM and self.constants.drm_support is True: print("- Prioritizing DRM support over Intel QuickSync") self.config["DeviceProperties"]["Add"][self.gfx0_path] = {"agdpmod": "vit9696", "shikigva": 256} - self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")} + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = { + "name": binascii.unhexlify("23646973706C6179"), + "IOName": "#display", + "class-code": binascii.unhexlify("FFFFFFFF"), + } else: self.config["DeviceProperties"]["Add"][self.gfx0_path] = {"agdpmod": "vit9696"} if self.model in ["iMac13,1", "iMac13,2", "iMac13,3"]: - dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - if dgpu_vendor: + if self.computer.dgpu: print("- Fixing sleep support in macOS 12") - self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")} + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = { + "name": binascii.unhexlify("23646973706C6179"), + "IOName": "#display", + "class-code": binascii.unhexlify("FFFFFFFF"), + } # Audio Patch if self.model in ModelArray.LegacyAudio: @@ -400,9 +385,17 @@ class BuildOpenCore: hdef_path = "PciRoot(0x0)/Pci(0x8,0x0)" if self.model in ModelArray.nvidiaHDEF else "PciRoot(0x0)/Pci(0x1b,0x0)" # In AppleALC, MacPro3,1's original layout is already in use, forcing layout 13 instead if self.model == "MacPro3,1": - self.config["DeviceProperties"]["Add"][hdef_path] = {"apple-layout-id": 90, "use-apple-layout-id": 1, "alc-layout-id": 13, } + self.config["DeviceProperties"]["Add"][hdef_path] = { + "apple-layout-id": 90, + "use-apple-layout-id": 1, + "alc-layout-id": 13, + } else: - self.config["DeviceProperties"]["Add"][hdef_path] = {"apple-layout-id": 90, "use-apple-layout-id": 1, "use-layout-id": 1, } + self.config["DeviceProperties"]["Add"][hdef_path] = { + "apple-layout-id": 90, + "use-apple-layout-id": 1, + "use-layout-id": 1, + } # Enable FireWire Boot Support if self.constants.firewire_boot is True and self.model not in ModelArray.NoFireWireSupport: @@ -413,44 +406,55 @@ class BuildOpenCore: self.get_kext_by_bundle_path("IOFireWireFamily.kext/Contents/PlugIns/AppleFWOHCI.kext")["Enabled"] = True def backlight_path_detection(self): - if not self.constants.custom_model: - dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - self.gfx0_path = DeviceProbe.pci_probe().deviceproperty_probe(dgpu_vendor,dgpu_device,dgpu_acpi) - if self.gfx0_path == "": - print("- Failed to find GFX0 Device path, falling back on known logic") - if self.model in ["iMac11,1", "iMac11,3"]: - self.gfx0_path = "PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)" - elif self.model == "iMac10,1": - self.gfx0_path = "PciRoot(0x0)/Pci(0xc,0x0)/Pci(0x0,0x0)" - else: - self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)" - else: - print(f"- Found GFX0 Device Path: {self.gfx0_path}") - + if not self.constants.custom_model and self.computer.dgpu and self.computer.dgpu.pci_path: + self.gfx0_path = self.computer.dgpu.pci_path + print(f"- Found GFX0 Device Path: {self.gfx0_path}") else: + if not self.constants.custom_model: + print("- Failed to find GFX0 Device path, falling back on known logic") if self.model in ["iMac11,1", "iMac11,3"]: self.gfx0_path = "PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)" elif self.model == "iMac10,1": self.gfx0_path = "PciRoot(0x0)/Pci(0xc,0x0)/Pci(0x0,0x0)" else: self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)" - print(f"- Using known GFX0 path: {self.gfx0_path}") - def nvidia_patch(self, backlight_path): self.constants.custom_mxm_gpu = True if self.model in ["iMac11,1", "iMac11,2", "iMac11,3", "iMac10,1"]: print("- Adding Nvidia Brightness Control and DRM patches") - self.config["DeviceProperties"]["Add"][backlight_path] = {"applbkl": binascii.unhexlify("01000000"), "@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000"), "shikigva": 256, "agdpmod": "vit9696"} + self.config["DeviceProperties"]["Add"][backlight_path] = { + "applbkl": binascii.unhexlify("01000000"), + "@0,backlight-control": binascii.unhexlify("01000000"), + "@0,built-in": binascii.unhexlify("01000000"), + "shikigva": 256, + "agdpmod": "vit9696", + } if self.constants.custom_model and self.model == "iMac11,2": # iMac11,2 can have either PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0) or PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0) # Set both properties when we cannot run hardware detection - self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"applbkl": binascii.unhexlify("01000000"), "@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000"), "shikigva": 256, "agdpmod": "vit9696"} + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = { + "applbkl": binascii.unhexlify("01000000"), + "@0,backlight-control": binascii.unhexlify("01000000"), + "@0,built-in": binascii.unhexlify("01000000"), + "shikigva": 256, + "agdpmod": "vit9696", + } elif self.model in ["iMac12,1", "iMac12,2"]: print("- Adding Nvidia Brightness Control and DRM patches") - self.config["DeviceProperties"]["Add"][backlight_path] = {"applbkl": binascii.unhexlify("01000000"), "@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000"), "shikigva": 256, "agdpmod": "vit9696"} + self.config["DeviceProperties"]["Add"][backlight_path] = { + "applbkl": binascii.unhexlify("01000000"), + "@0,backlight-control": binascii.unhexlify("01000000"), + "@0,built-in": binascii.unhexlify("01000000"), + "shikigva": 256, + "agdpmod": "vit9696", + } print("- Disabling unsupported iGPU") - self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")} + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = { + "name": binascii.unhexlify("23646973706C6179"), + "IOName": "#display", + "class-code": binascii.unhexlify("FFFFFFFF"), + } shutil.copy(self.constants.backlight_injector_path, self.constants.kexts_path) self.get_kext_by_bundle_path("BacklightInjector.kext")["Enabled"] = True self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True @@ -461,12 +465,16 @@ class BuildOpenCore: print("- Adding AMD DRM patches") self.config["DeviceProperties"]["Add"][backlight_path] = {"shikigva": 80, "unfairgva": 1} if self.constants.custom_model and self.model == "iMac11,2": - # iMac11,2 can have either PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0) or PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0) - # Set both properties when we cannot run hardware detection - self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1} + # iMac11,2 can have either PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0) or PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0) + # Set both properties when we cannot run hardware detection + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1} if self.model in ["iMac12,1", "iMac12,2"]: print("- Disabling unsupported iGPU") - self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")} + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = { + "name": binascii.unhexlify("23646973706C6179"), + "IOName": "#display", + "class-code": binascii.unhexlify("FFFFFFFF"), + } elif self.model == "iMac10,1": self.enable_kext("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path) @@ -480,67 +488,60 @@ class BuildOpenCore: nvidia_patch(self, self.gfx0_path) else: print("- Failed to find vendor") - elif not self.constants.custom_model and self.model in ModelArray.LegacyGPU: - dgpu_vendor,dgpu_device,dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - if dgpu_vendor: - print(f"- Detected dGPU: {dgpu_vendor}:{dgpu_device}") - if dgpu_vendor == self.constants.pci_amd_ati and (dgpu_device in PCIIDArray.amd_ids().polaris_ids or dgpu_device in PCIIDArray.amd_ids().vega_ids or dgpu_device in PCIIDArray.amd_ids().navi_ids or dgpu_device in PCIIDArray.amd_ids().legacy_gcn_ids): - backlight_path_detection(self) - amd_patch(self, self.gfx0_path) - elif dgpu_vendor == self.constants.pci_nvidia and dgpu_device in PCIIDArray.nvidia_ids().kepler_ids: - backlight_path_detection(self) - nvidia_patch(self, self.gfx0_path) + elif not self.constants.custom_model and self.model in ModelArray.LegacyGPU and self.computer.dgpu: + print(f"- Detected dGPU: {Utilities.friendly_hex(self.computer.dgpu.vendor_id)}:{Utilities.friendly_hex(self.computer.dgpu.device_id)}") + if self.computer.dgpu.arch in [ + device_probe.AMD.Archs.Legacy_GCN, + device_probe.AMD.Archs.Polaris, + device_probe.AMD.Archs.Vega, + device_probe.AMD.Archs.Navi, + ]: + backlight_path_detection(self) + amd_patch(self, self.gfx0_path) + elif self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler: + backlight_path_detection(self) + nvidia_patch(self, self.gfx0_path) if self.model in ModelArray.MacPro71: if not self.constants.custom_model: - mp_dgpu_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - mp_dgpu_devices = [i for i in mp_dgpu_devices if i["class-code"] == binascii.unhexlify("00000300") or i["class-code"] == binascii.unhexlify("00800300")] - mp_dgpu_devices_gfx: str = subprocess.run([self.constants.gfxutil_path] + f"-v".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - try: - x = 1 - for i in mp_dgpu_devices: - mp_dgpu_vendor = Utilities.hexswap(binascii.hexlify(i["vendor-id"]).decode()[:4]) - mp_dgpu_device = Utilities.hexswap(binascii.hexlify(i["device-id"]).decode()[:4]) + for i, device in enumerate(self.computer.gpus): + print(f"- Found dGPU ({i + 1}): {Utilities.friendly_hex(device.vendor_id)}:{Utilities.friendly_hex(device.device_id)}") + self.config["#Revision"][f"Hardware-MacPro-dGPU-{i + 1}"] = f"{Utilities.friendly_hex(device.vendor_id)}:{Utilities.friendly_hex(device.device_id)}" - print(f'- Found dGPU ({x}): {mp_dgpu_vendor}:{mp_dgpu_device}') - self.config["#Revision"][f"Hardware-MacPro-dGPU-{x}"] = f'{mp_dgpu_vendor}:{mp_dgpu_device}' + if device.pci_path: + print(f"- Found dGPU ({i + 1}) at {device.pci_path}") + if isinstance(device, device_probe.AMD): + print("- Adding Mac Pro, Xserve DRM patches") + self.config["DeviceProperties"]["Add"][device.pci_path] = {"shikigva": 128, "unfairgva": 1, "rebuild-device-tree": 1} + elif isinstance(device, device_probe.NVIDIA): + print("- Enabling Nvidia Output Patch") + self.config["DeviceProperties"]["Add"][device.pci_path] = {"rebuild-device-tree": 1} + self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True + self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - try: - mp_dgpu_path = [line.strip().split("= ", 1)[1] for line in mp_dgpu_devices_gfx.split("\n") if f'{mp_dgpu_vendor}:{mp_dgpu_device}'.lower() in line.strip()][0] - print(f"- Found dGPU ({x}) at {mp_dgpu_path}") - if mp_dgpu_vendor == self.constants.pci_amd_ati: - print("- Adding Mac Pro, Xserve DRM patches") - self.config["DeviceProperties"]["Add"][mp_dgpu_path] = {"shikigva": 128, "unfairgva": 1, "rebuild-device-tree": 1} - elif mp_dgpu_vendor == self.constants.pci_nvidia: - print("- Enabling Nvidia Output Patch") - self.config["DeviceProperties"]["Add"][mp_dgpu_path] = {"rebuild-device-tree": 1} - self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True - self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True + else: + print(f"- Failed to find Device path for dGPU {i + 1}") + if isinstance(device, device_probe.AMD): + print("- Adding Mac Pro, Xserve DRM patches") + if "shikigva=128 unfairgva=1" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + print("- Falling back to boot-args") + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " shikigva=128 unfairgva=1" + (" -wegtree" if "-wegtree" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] else "") + elif isinstance(device, device_probe.NVIDIA): + print("- Enabling Nvidia Output Patch") + if "-wegtree" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + print("- Falling back to boot-args") + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -wegtree" + self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True + self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - except IndexError: - print(f"- Failed to find Device path for NVMe {x}") - if mp_dgpu_vendor == self.constants.pci_amd_ati: - print("- Adding Mac Pro, Xserve DRM patches") - if "shikigva=128 unfairgva=1 -wegtree" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: - print("- Falling back to boot-args") - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " shikigva=128 unfairgva=1 -wegtree" - elif mp_dgpu_vendor == self.constants.pci_nvidia: - print("- Enabling Nvidia Output Patch") - if "-wegtree" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: - print("- Falling back to boot-args") - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -wegtree" - self.config["UEFI"]["Quirks"]["ForgeUefiSupport"] = True - self.config["UEFI"]["Quirks"]["ReloadOptionRoms"] = True - x = x + 1 - except ValueError: - print("- No socketed dGPU found") - except IndexError: + if not self.computer.gpus: print("- No socketed dGPU found") + else: print("- Adding Mac Pro, Xserve DRM patches") self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " shikigva=128 unfairgva=1 -wegtree" # Add XhciDxe if firmware doesn't have XHCI controller support and XCHI controller detected - #if self.model not in ModelArray.XhciSupport and not self.constants.custom_model: + # if self.model not in ModelArray.XhciSupport and not self.constants.custom_model: # devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) # try: # devices = [i for i in devices if i["class-code"] == binascii.unhexlify(self.constants.classcode_xhci)] @@ -587,11 +588,11 @@ class BuildOpenCore: if self.constants.kext_debug is True: print("- Enabling DEBUG Kexts") self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -liludbgall" - #self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " msgbuf=1048576" + # self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " msgbuf=1048576" if self.constants.opencore_debug is True: print("- Enabling DEBUG OpenCore") - self.config["Misc"]["Debug"]["Target"] = 67 - self.config["Misc"]["Debug"]["DisplayLevel"] = 672151678018 + self.config["Misc"]["Debug"]["Target"] = 0x43 + self.config["Misc"]["Debug"]["DisplayLevel"] = 0x80000042 if self.constants.showpicker is True: print("- Enabling ShowPicker") self.config["Misc"]["Boot"]["ShowPicker"] = True @@ -651,7 +652,7 @@ class BuildOpenCore: if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1: self.config["PlatformInfo"]["SMBIOS"]["ProcessorType"] = 1537 if self.model in ModelArray.NoAPFSsupport: - fw_feature,fw_mask = self.fw_feature_detect(self.model) + fw_feature, fw_mask = self.fw_feature_detect(self.model) self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeatures"] = fw_feature self.config["PlatformInfo"]["SMBIOS"]["FirmwareFeatures"] = fw_feature self.config["PlatformInfo"]["PlatformNVRAM"]["FirmwareFeaturesMask"] = fw_mask @@ -739,7 +740,6 @@ class BuildOpenCore: cpu_config["IOKitPersonalities"]["CPUFriendDataProvider"]["cf-frequency-data"] = string_stuff plistlib.dump(cpu_config, Path(new_cpu_ls).open("wb"), sort_keys=True) - if self.constants.allow_oc_everywhere is False: if self.model == "MacBookPro9,1": new_amc_ls = Path(self.constants.amc_contents_folder) / Path("Info.plist") @@ -754,10 +754,11 @@ class BuildOpenCore: if self.model in ModelArray.AGDPSupport: new_agdp_ls = Path(self.constants.agdp_contents_folder) / Path("Info.plist") agdp_config = plistlib.load(Path(new_agdp_ls).open("rb")) - agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"][self.spoofed_board] = agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"].pop(self.model) + agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"][self.spoofed_board] = agdp_config["IOKitPersonalities"]["AppleGraphicsDevicePolicy"]["ConfigMap"].pop( + self.model + ) plistlib.dump(agdp_config, Path(new_agdp_ls).open("wb"), sort_keys=True) - @staticmethod def get_item_by_kv(iterable, key, value): item = None @@ -819,7 +820,7 @@ class BuildOpenCore: zip_file.extractall(self.constants.oc_folder) item.unlink() - if self.constants.recovery_status == False: + if not self.constants.recovery_status: # Crashes in RecoveryOS for unknown reason for i in self.constants.build_path.rglob("__MACOSX"): shutil.rmtree(i) @@ -829,7 +830,7 @@ class BuildOpenCore: def sign_files(self): if self.constants.vault is True: print("- Vaulting EFI") - subprocess.run([self.constants.vault_path] + f"{self.constants.oc_folder}/".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + subprocess.run([str(self.constants.vault_path), f"{self.constants.oc_folder}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) def build_opencore(self): self.build_efi() @@ -919,7 +920,7 @@ Please build OpenCore first!""" selected_disk["partitions"][partition]["type"] == "Microsoft Basic Data" and selected_disk["partitions"][partition]["size"] < 1024 * 1024 * 512 ): # 512 megabytes: text += " *" - menu.add_menu_option(text, key=partition[len(disk_identifier) + 1:]) + menu.add_menu_option(text, key=partition[len(disk_identifier) + 1 :]) response = menu.start() @@ -936,7 +937,7 @@ Please build OpenCore first!""" " without altering line endings", ] - if self.constants.detected_os > self.constants.yosemite and self.constants.recovery_status == False: + if self.constants.detected_os >= self.constants.el_capitan and not self.constants.recovery_status: result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: result = subprocess.run(f"diskutil mount {disk_identifier}s{response}".split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -996,10 +997,10 @@ Please build OpenCore first!""" print("- Adding Internal Drive icon") shutil.copy(self.constants.icon_path_internal, mount_path) print("- Cleaning install location") - if self.constants.recovery_status == False: + if not self.constants.recovery_status: # RecoveryOS doesn't support dot_clean # Remove dot_clean, requires full disk access - #subprocess.run(["dot_clean", mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() + # subprocess.run(["dot_clean", mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() print("- Unmounting EFI partition") subprocess.run(["diskutil", "umount", mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() print("- OpenCore transfer complete") diff --git a/Resources/CliMenu.py b/Resources/CliMenu.py index da946a052..7c4cac68d 100644 --- a/Resources/CliMenu.py +++ b/Resources/CliMenu.py @@ -3,7 +3,7 @@ from __future__ import print_function import subprocess -from Resources import ModelArray, Constants, Utilities +from Resources import Constants, Utilities class MenuOptions: @@ -49,7 +49,8 @@ class MenuOptions: def change_metal(self): Utilities.cls() Utilities.header(["Assume Metal GPU Always in iMac"]) - print("""This is for iMacs that have upgraded Metal GPUs, otherwise + print( + """This is for iMacs that have upgraded Metal GPUs, otherwise Patcher assumes based on stock configuration (ie. iMac10,x-12,x) Valid Options: @@ -60,7 +61,8 @@ Valid Options: Note: Patcher will detect whether hardware has been upgraded regardless, this option is for those patching on a different machine or OCLP cannot detect. - """) + """ + ) change_menu = input("Set GPU Patch type(ie. 1): ") if change_menu == "1": self.constants.metal_build = False @@ -77,11 +79,13 @@ option is for those patching on a different machine or OCLP cannot detect. def change_wifi(self): Utilities.cls() Utilities.header(["Assume Upgraded Wifi Always"]) - print("""This is for Macs with upgraded wifi cards(ie. BCM94360/2) + print( + """This is for Macs with upgraded wifi cards(ie. BCM94360/2) Note: Patcher will detect whether hardware has been upgraded regardless, this option is for those patching on a different machine or cannot detect. - """) + """ + ) change_menu = input("Enable Upgraded Wifi build algorithm?(y/n): ") if change_menu in {"y", "Y", "yes", "Yes"}: self.constants.wifi_build = True @@ -93,7 +97,8 @@ option is for those patching on a different machine or cannot detect. def change_serial(self): Utilities.cls() Utilities.header(["Set SMBIOS Mode"]) - print("""This section is for setting how OpenCore generates the SMBIOS + print( + """This section is for setting how OpenCore generates the SMBIOS Recommended for adanced users who want control how serials are handled Valid options: @@ -103,7 +108,8 @@ Valid options: 3. Advanced:\tReplace entire SMBIOS and generate new serials Note: For new users we recommend leaving as default(1. Minimal) - """) + """ + ) change_menu = input("Set SMBIOS Mode(ie. 1): ") if change_menu == "1": self.constants.serial_settings = "Minimal" @@ -117,10 +123,12 @@ Note: For new users we recommend leaving as default(1. Minimal) def change_showpicker(self): Utilities.cls() Utilities.header(["Set OpenCore Picker mode"]) - print("""By default, OpenCore will show its boot picker each time on boot up, + print( + """By default, OpenCore will show its boot picker each time on boot up, however this can be disabled by default and be shown on command by repeatedly pressing the "Esc" key - """) + """ + ) change_menu = input("Show OpenCore Picker by default(y/n): ") if change_menu in {"y", "Y", "yes", "Yes"}: self.constants.showpicker = True @@ -132,13 +140,15 @@ pressing the "Esc" key def change_vault(self): Utilities.cls() Utilities.header(["Set OpenCore Vaulting"]) - print("""By default, this patcher will sign all your files and ensure none of the + print( + """By default, this patcher will sign all your files and ensure none of the contents can be tampered with. However for more advanced users, you may want to be able to freely edit the config.plist and files. Note: For security reasons, OpenShell will be disabled when Vault is set. - """) + """ + ) change_menu = input("Enable Vault(y/n): ") if change_menu in {"y", "Y", "yes", "Yes"}: self.constants.vault = True @@ -150,7 +160,8 @@ Note: For security reasons, OpenShell will be disabled when Vault is set. def change_sip(self): Utilities.cls() Utilities.header(["Set SIP and SecureBootModel"]) - print("""SIP and SecureBootModel are used to ensure proper OTA functionality, + print( + """SIP and SecureBootModel are used to ensure proper OTA functionality, however to patch the root volume both of these must be disabled. Only disable is absolutely necessary. SIP value = 0xFEF @@ -161,7 +172,8 @@ Valid options: 3. Disable SecureBootModel Only 4. Disable Both - """) + """ + ) change_menu = input("Set SIP and SecureBootModel(ie. 1): ") if change_menu == "1": self.constants.sip_status = True @@ -181,10 +193,12 @@ Valid options: def set_amfi(self): Utilities.cls() Utilities.header(["Disable AMFI"]) - print("""Required for Root Patching non-Metal GPUs + print( + """Required for Root Patching non-Metal GPUs in macOS Big Sur. Without this, will receive kernel panic once Patcher finishes installing legacy acceleration patches. - """) + """ + ) change_menu = input("Disable AMFI(y/n): ") if change_menu in {"y", "Y", "yes", "Yes"}: self.constants.disable_amfi = True @@ -193,25 +207,11 @@ Patcher finishes installing legacy acceleration patches. else: print("Invalid option") - def change_imac_nvidia(self): - Utilities.cls() - Utilities.header(["Assume Metal GPU Always"]) - print("""Specifically for iMac10,x-12,x with Metal Nvidia GPU upgrades -By default the patcher will try to detect what hardware is -running, however this will enforce iMac Nvidia Build Patches. - """) - change_menu = input("Assume iMac Nvidia patches(y/n): ") - if change_menu in {"y", "Y", "yes", "Yes"}: - self.constants.imac_nvidia_build = True - elif change_menu in {"n", "N", "no", "No"}: - self.constants.imac_nvidia_build = False - else: - print("Invalid option") - def bootstrap_setting(self): Utilities.cls() Utilities.header(["Set Bootstrap method"]) - print("""Sets OpenCore's bootstrap method, currently the patcher supports the + print( + """Sets OpenCore's bootstrap method, currently the patcher supports the following options. Valid options: @@ -226,7 +226,8 @@ and not to macOS itself. Recommended to set to BOOTx64.efi in situations where your Mac cannot see the EFI Boot entry in the boot picker. - """) + """ + ) change_menu = input("Set Bootstrap method: ") if change_menu == "1": self.constants.boot_efi = False @@ -235,11 +236,11 @@ see the EFI Boot entry in the boot picker. else: print("Invalid option") - def drm_setting(self): Utilities.cls() Utilities.header(["Set DRM preferences"]) - print("""Sets OpenCore's DRM preferences for iMac13,x and iMac14,x. + print( + """Sets OpenCore's DRM preferences for iMac13,x and iMac14,x. In Big Sur, some DRM based content may be broken by default in AppleTV, Photobooth, etc. @@ -249,7 +250,8 @@ greatly hampers Video rendering performance in Final Cut Pro and other programs relying on such features. Recommend only disabling if absolutely required. - """) + """ + ) change_menu = input("Enable Nvidia's Software DRM rendering(y/n): ") if change_menu in {"y", "Y", "yes", "Yes"}: self.constants.drm_support = True @@ -261,11 +263,13 @@ Recommend only disabling if absolutely required. def force_accel_setting(self): Utilities.cls() Utilities.header(["Assume Legacy GPU"]) - print("""Allows any model to force install Legacy Acceleration + print( + """Allows any model to force install Legacy Acceleration patches. Only required for Mac Pro and Xserve users. DO NOT RUN IF METAL GPU IS INSTALLED - """) + """ + ) change_menu = input("Enable Beta Acceleration Patches(y/n): ") if change_menu in {"y", "Y", "yes", "Yes"}: self.constants.assume_legacy = True @@ -277,11 +281,13 @@ DO NOT RUN IF METAL GPU IS INSTALLED def allow_native_models(self): Utilities.cls() Utilities.header(["Allow OpenCore on native Models"]) - print("""Allows natively supported Macs to use OpenCore. Recommended + 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 @@ -295,13 +301,15 @@ power usage. def custom_cpu(self): Utilities.cls() Utilities.header(["Set custom CPU Model Name"]) - print("""Change reported CPU Model name in About This Mac + print( + """Change reported CPU Model name in About This Mac Custom names will report as follows: 1: Original Name: 2.5 Ghz Dual-Core Intel Core i5 2. CPU name: Intel(R) Core(TM) i5-3210M CPU @ 2.50Ghz 3. Custom Name: 2.5Ghz Cotton Candy (example) - """) + """ + ) if self.constants.custom_cpu_model_value == "": if self.constants.custom_cpu_model == 0: print("Currently using original name") @@ -325,19 +333,21 @@ Custom names will report as follows: def custom_color_thing(self): Utilities.cls() Utilities.header(["Set custom CPU Model Name"]) - print("""Change reported CPU Model name in About This Mac + print( + """Change reported CPU Model name in About This Mac Custom names will report as follows: 1: Custom Color 2. Reset - """) + """ + ) change_menu = input("Set custom CPU Name(1,2,3): ") if change_menu == "1": print("") - #temp_tk_root = tk.Tk() - #temp_tk_root.wm_withdraw() - #self.constants.custom_color = colorchooser.askcolor(title="Choose color") - #temp_tk_root.destroy() + # temp_tk_root = tk.Tk() + # temp_tk_root.wm_withdraw() + # self.constants.custom_color = colorchooser.askcolor(title="Choose color") + # temp_tk_root.destroy() elif change_menu == "2": self.constants.custom_color = "" else: @@ -346,9 +356,11 @@ Custom names will report as follows: def download_more_ram_dot_com(self): Utilities.cls() Utilities.header(["Download more RAM"]) - print("""Downloads more RAM to your Mac! + print( + """Downloads more RAM to your Mac! Currently only offers 1.5TB bundles - """) + """ + ) change_menu = input("Download more RAM?(y/n): ") if change_menu == "y": self.constants.download_ram = True @@ -360,11 +372,13 @@ Currently only offers 1.5TB bundles def disable_cpufriend(self): Utilities.cls() Utilities.header(["Disable CPU Friend?"]) - print("""Only recommended for advanced users + print( + """Only recommended for advanced users Disabling CPUFriend forces macOS into using a different Mac's power profile for CPUs and GPUs, which can harm the hardware - """) + """ + ) change_menu = input("Disable CPU Friend?(y/n): ") if change_menu == "y": self.constants.disallow_cpufriend = True @@ -376,24 +390,30 @@ hardware def set_seedutil(self): Utilities.cls() Utilities.header(["Set SeedUtil Status"]) - print("""Used for setting OS Update Preferences + print( + """Used for setting OS Update Preferences Valid options: 1. Public Release Seed (Default) 2. Public Beta Seed 3. Developer Beta Seed 4. Check SeedUtil's current status - """) + """ + ) change_menu = input("Set update status(Press [ENTER] to exit): ") if change_menu == "1": subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "unenroll"], stdout=subprocess.PIPE).stdout.decode().strip().encode() elif change_menu == "2": subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "unenroll"], stdout=subprocess.PIPE).stdout.decode().strip().encode() - subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "PublicSeed"], stdout=subprocess.PIPE).stdout.decode().strip().encode() + subprocess.run( + ["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "PublicSeed"], stdout=subprocess.PIPE + ).stdout.decode().strip().encode() elif change_menu == "3": subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "unenroll"], stdout=subprocess.PIPE).stdout.decode().strip().encode() - subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "DeveloperSeed"], stdout=subprocess.PIPE).stdout.decode().strip().encode() + subprocess.run( + ["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "enroll", "DeveloperSeed"], stdout=subprocess.PIPE + ).stdout.decode().strip().encode() elif change_menu == "4": result = subprocess.run(["sudo", "/System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil", "current"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = [i.partition(":")[2] for i in result.stdout.decode().split("\n") if "Currently enrolled in" in i][0] @@ -406,13 +426,15 @@ Valid options: def set_smbios(self): Utilities.cls() Utilities.header(["Override SMBIOS Spoof"]) - print("""Change model OpenCore spoofs Mac too + print( + """Change model OpenCore spoofs Mac too Valid options: 1. Default set by OpenCore (Default) 2. User Override 3. Disable all spoofing (unsupported configuration) - """) + """ + ) change_menu = input("Set SMBIOS status: ") if change_menu == "1": @@ -435,7 +457,8 @@ Valid options: def allow_firewire(self): Utilities.cls() Utilities.header(["Allow FireWire Boot Support"]) - print(""" + print( + """ In macOS Catalina and newer, Apple restricted usage of FireWire devices to boot macOS for security concerns relating to DMA access. @@ -445,7 +468,8 @@ you can re-enable FireWire support for Catalina and newer. Note: MacBook5,x-7,1 don't support FireWire boot - """) + """ + ) change_menu = input("Enable FireWire Boot support?(y/n): ") if change_menu == "y": @@ -458,7 +482,8 @@ Note: MacBook5,x-7,1 don't support FireWire boot def allow_nvme(self): Utilities.cls() Utilities.header(["Allow NVMe UEFI Support"]) - print(""" + print( + """ For machines not natively supporting NVMe, this option allows you to see and boot NVMe drive in OpenCore's picker @@ -468,7 +493,8 @@ Not required if your machine natively supports NVMe Note: You must have OpenCore on a bootable volume first, ie. USB or SATA drive. Once loaded, OpenCore will enable NVMe support in it's picker - """) + """ + ) change_menu = input("Enable NVMe Boot support?(y/n): ") if change_menu == "y": @@ -478,11 +504,11 @@ OpenCore will enable NVMe support in it's picker else: print("Invalid option") - def enable_terascale(self): Utilities.cls() Utilities.header(["Enable TeraScale 2 Acceleration"]) - print(""" + print( + """ Currently TeraScale 2 graphics acceleration is in beta with some unfortunate bugs on login including strobing colours until the user forces Million Colours on the Display with @@ -493,12 +519,13 @@ patches or ask someone to handle inital setup to ensure no issues Note: Acceleration only applies to macOS Big Sur - """) + """ + ) change_menu = input("Enable TS2 Acceleration?(y/n): ") if change_menu == "y": - self.constants.terscale_2_patch = True + self.constants.terascale_2_patch = True elif change_menu == "n": - self.constants.terscale_2_patch = False + self.constants.terascale_2_patch = False else: - print("Invalid option") \ No newline at end of file + print("Invalid option") diff --git a/Resources/Constants.py b/Resources/Constants.py index 0c39dedfe..1592f9aad 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -5,6 +5,9 @@ from __future__ import print_function from pathlib import Path +from typing import Optional + +from Resources import device_probe class Constants: @@ -41,16 +44,17 @@ class Constants: self.debugenhancer_version = "1.0.3" self.innie_version = "1.3.0" self.fw_kext = "1.0.0" - self.payload_version = "0.0.18" # Apple-Binaries-OCLP + self.payload_version = "0.0.18" # Apple-Binaries-OCLP # Get resource path self.current_path = Path(__file__).parent.parent.resolve() self.payload_path = self.current_path / Path("payloads") - self.custom_model: str = None - self.custom_mxm_gpu: str = None - self.current_gpuv: str = None - self.current_gpud: str = None + # Hardware + self.computer: device_probe.Computer = None # type: ignore + + self.custom_model: Optional[str] = None + self.custom_mxm_gpu: bool = False # Patcher Settings self.opencore_debug = False @@ -86,7 +90,7 @@ class Constants: self.firewire_boot = False self.nvme_boot = False self.disable_amfi = False - self.terscale_2_patch = False + self.terascale_2_patch = False # OS Versions self.tiger = 8 @@ -133,252 +137,440 @@ class Constants: # Payload Location # OpenCore @property - def opencore_zip_source(self): return self.payload_path / Path(f"OpenCore/OpenCore-{self.opencore_build}.zip") + def opencore_zip_source(self): + return self.payload_path / Path(f"OpenCore/OpenCore-{self.opencore_build}.zip") + @property - def plist_template(self): return self.payload_path / Path(f"Config/config.plist") + def plist_template(self): + return self.payload_path / Path("Config/config.plist") # Mount Location @property - def payload_mnt1_path(self): return self.payload_path / Path("mnt1") + def payload_mnt1_path(self): + return self.payload_path / Path("mnt1") # ACPI @property - def pci_ssdt_path(self): return self.payload_path / Path("ACPI/SSDT-CPBG.aml") + def pci_ssdt_path(self): + return self.payload_path / Path("ACPI/SSDT-CPBG.aml") + @property - def windows_ssdt_path(self): return self.payload_path / Path("ACPI/SSDT-PCI.aml") + def windows_ssdt_path(self): + return self.payload_path / Path("ACPI/SSDT-PCI.aml") # Drivers @property - def nvme_driver_path(self): return self.payload_path / Path("Drivers/NvmExpressDxe.efi") + def nvme_driver_path(self): + return self.payload_path / Path("Drivers/NvmExpressDxe.efi") + @property - def exfat_legacy_driver_path(self): return self.payload_path / Path("Drivers/ExFatDxeLegacy.efi") + def exfat_legacy_driver_path(self): + return self.payload_path / Path("Drivers/ExFatDxeLegacy.efi") + @property - def xhci_driver_path(self): return self.payload_path / Path("Drivers/XhciDxe.efi") + def xhci_driver_path(self): + return self.payload_path / Path("Drivers/XhciDxe.efi") # Kexts @property - def payload_kexts_path(self): return self.payload_path / Path("Kexts") + def payload_kexts_path(self): + return self.payload_path / Path("Kexts") + @property - def lilu_path(self): return self.payload_kexts_path / Path(f"Acidanthera/Lilu-v{self.lilu_version}.zip") + def lilu_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/Lilu-v{self.lilu_version}.zip") + @property - def whatevergreen_path(self): return self.payload_kexts_path / Path(f"Acidanthera/WhateverGreen-v{self.whatevergreen_version}.zip") + def whatevergreen_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/WhateverGreen-v{self.whatevergreen_version}.zip") + @property - def airportbcrmfixup_path(self): return self.payload_kexts_path / Path(f"Acidanthera/AirportBrcmFixup-v{self.airportbcrmfixup_version}.zip") + def airportbcrmfixup_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/AirportBrcmFixup-v{self.airportbcrmfixup_version}.zip") + @property - def restrictevents_path(self): return self.payload_kexts_path / Path(f"Acidanthera/RestrictEvents-v{self.restrictevents_version}.zip") + def restrictevents_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/RestrictEvents-v{self.restrictevents_version}.zip") + @property - def restrictevents_mbp_path(self): return self.payload_kexts_path / Path(f"Acidanthera/RestrictEvents-MBP91-v{self.restrictevents_mbp_version}.zip") + def restrictevents_mbp_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/RestrictEvents-MBP91-v{self.restrictevents_mbp_version}.zip") + @property - def bcm570_path(self): return self.payload_kexts_path / Path(f"Ethernet/CatalinaBCM5701Ethernet-v{self.bcm570_version}.zip") + def bcm570_path(self): + return self.payload_kexts_path / Path(f"Ethernet/CatalinaBCM5701Ethernet-v{self.bcm570_version}.zip") + @property - def marvel_path(self): return self.payload_kexts_path / Path(f"Ethernet/MarvelYukonEthernet-v{self.marvel_version}.zip") + def marvel_path(self): + return self.payload_kexts_path / Path(f"Ethernet/MarvelYukonEthernet-v{self.marvel_version}.zip") + @property - def nforce_path(self): return self.payload_kexts_path / Path(f"Ethernet/nForceEthernet-v{self.nforce_version}.zip") + def nforce_path(self): + return self.payload_kexts_path / Path(f"Ethernet/nForceEthernet-v{self.nforce_version}.zip") + @property - def mce_path(self): return self.payload_kexts_path / Path(f"Misc/AppleMCEReporterDisabler-v{self.mce_version}.zip") + def mce_path(self): + return self.payload_kexts_path / Path(f"Misc/AppleMCEReporterDisabler-v{self.mce_version}.zip") + @property - def mousse_path(self): return self.payload_kexts_path / Path(f"SSE/AAAMouSSE-v{self.mousse_version}.zip") + def mousse_path(self): + return self.payload_kexts_path / Path(f"SSE/AAAMouSSE-v{self.mousse_version}.zip") + @property - def telemetrap_path(self): return self.payload_kexts_path / Path(f"SSE/telemetrap-v{self.telemetrap_version}.zip") + def telemetrap_path(self): + return self.payload_kexts_path / Path(f"SSE/telemetrap-v{self.telemetrap_version}.zip") + @property - def corecaptureelcap_path(self): return self.payload_kexts_path / Path(f"Wifi/corecaptureElCap-v{self.corecaptureelcap_version}.zip") + def corecaptureelcap_path(self): + return self.payload_kexts_path / Path(f"Wifi/corecaptureElCap-v{self.corecaptureelcap_version}.zip") + @property - def io80211elcap_path(self): return self.payload_kexts_path / Path(f"Wifi/IO80211ElCap-v{self.io80211elcap_version}.zip") + def io80211elcap_path(self): + return self.payload_kexts_path / Path(f"Wifi/IO80211ElCap-v{self.io80211elcap_version}.zip") + @property - def io80211high_sierra_path(self): return self.payload_kexts_path / Path(f"Wifi/IO80211HighSierra-v{self.io80211high_sierra_version}.zip") + def io80211high_sierra_path(self): + return self.payload_kexts_path / Path(f"Wifi/IO80211HighSierra-v{self.io80211high_sierra_version}.zip") + @property - def io80211mojave_path(self): return self.payload_kexts_path / Path(f"Wifi/IO80211Mojave-v{self.io80211mojave_version}.zip") + def io80211mojave_path(self): + return self.payload_kexts_path / Path(f"Wifi/IO80211Mojave-v{self.io80211mojave_version}.zip") + @property - def applealc_path(self): return self.payload_kexts_path / Path(f"Acidanthera/AppleALC-v{self.applealc_version}.zip") + def applealc_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/AppleALC-v{self.applealc_version}.zip") + @property - def piixata_path(self): return self.payload_kexts_path / Path(f"Misc/AppleIntelPIIXATA-v{self.piixata_version}.zip") + def piixata_path(self): + return self.payload_kexts_path / Path(f"Misc/AppleIntelPIIXATA-v{self.piixata_version}.zip") + @property - def backlight_path(self): return self.payload_kexts_path / Path(f"Misc/AppleBacklightFixup-v{self.backlight_version}.zip") + def backlight_path(self): + return self.payload_kexts_path / Path(f"Misc/AppleBacklightFixup-v{self.backlight_version}.zip") + @property - def backlight_injector_path(self): return self.payload_kexts_path / Path(f"Misc/BacklightInjector-v{self.backlight_injector_version}.zip") + def backlight_injector_path(self): + return self.payload_kexts_path / Path(f"Misc/BacklightInjector-v{self.backlight_injector_version}.zip") + @property - def cpufriend_path(self): return self.payload_kexts_path / Path(f"Acidanthera/CPUFriend-v{self.cpufriend_version}.zip") + def cpufriend_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/CPUFriend-v{self.cpufriend_version}.zip") + @property - def nightshift_path(self): return self.payload_kexts_path / Path(f"Misc/NightShiftEnabler-v{self.nightshift_version}.zip") + def nightshift_path(self): + return self.payload_kexts_path / Path(f"Misc/NightShiftEnabler-v{self.nightshift_version}.zip") + @property - def smcspoof_path(self): return self.payload_kexts_path / Path(f"Misc/SMC-Spoof-v{self.smcspoof_version}.zip") + def smcspoof_path(self): + return self.payload_kexts_path / Path(f"Misc/SMC-Spoof-v{self.smcspoof_version}.zip") + @property - def cputscsync_path(self): return self.payload_kexts_path / Path(f"Acidanthera/CpuTscSync-v{self.cputscsync}.zip") + def cputscsync_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/CpuTscSync-v{self.cputscsync}.zip") + @property - def hibernationfixup_path(self): return self.payload_kexts_path / Path(f"Acidanthera/HibernationFixup-v{self.hibernationfixup}.zip") + def hibernationfixup_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/HibernationFixup-v{self.hibernationfixup}.zip") + @property - def nvmefix_path(self): return self.payload_kexts_path / Path(f"Acidanthera/NVMeFix-v{self.nvmefix_version}.zip") + def nvmefix_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/NVMeFix-v{self.nvmefix_version}.zip") + @property - def sidecarfixup_path(self): return self.payload_kexts_path / Path(f"Acidanthera/SidecarFixup-v{self.sidecarfixup_version}.zip") + def sidecarfixup_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/SidecarFixup-v{self.sidecarfixup_version}.zip") + @property - def debugenhancer_path(self): return self.payload_kexts_path / Path(f"Acidanthera/DebugEnhancer-v{self.debugenhancer_version}.zip") + def debugenhancer_path(self): + return self.payload_kexts_path / Path(f"Acidanthera/DebugEnhancer-v{self.debugenhancer_version}.zip") + @property - def innie_path(self): return self.payload_kexts_path / Path(f"Misc/Innie-v{self.innie_version}.zip") + def innie_path(self): + return self.payload_kexts_path / Path(f"Misc/Innie-v{self.innie_version}.zip") + @property - def plist_folder_path(self): return self.payload_kexts_path / Path(f"Plists") + def plist_folder_path(self): + return self.payload_kexts_path / Path("Plists") + @property - def platform_plugin_plist_path(self): return self.plist_folder_path / Path(f"PlatformPlugin") + def platform_plugin_plist_path(self): + return self.plist_folder_path / Path("PlatformPlugin") + @property - def fw_family_path(self): return self.payload_kexts_path / Path(f"FireWire/IOFireWireFamily-v{self.fw_kext}.zip") + def fw_family_path(self): + return self.payload_kexts_path / Path(f"FireWire/IOFireWireFamily-v{self.fw_kext}.zip") + @property - def fw_sbp2_path(self): return self.payload_kexts_path / Path(f"FireWire/IOFireWireSBP2-v{self.fw_kext}.zip") + def fw_sbp2_path(self): + return self.payload_kexts_path / Path(f"FireWire/IOFireWireSBP2-v{self.fw_kext}.zip") + @property - def fw_bus_path(self): return self.payload_kexts_path / Path(f"FireWire/IOFireWireSerialBusProtocolTransport-v{self.fw_kext}.zip") + def fw_bus_path(self): + return self.payload_kexts_path / Path(f"FireWire/IOFireWireSerialBusProtocolTransport-v{self.fw_kext}.zip") # Build Location @property - def build_path(self): return self.current_path / Path("Build-Folder/") - @property - def opencore_release_folder(self): return self.build_path / Path(f"OpenCore-{self.opencore_build}") - @property - def opencore_zip_copied(self): return self.build_path / Path(f"OpenCore-{self.opencore_build}.zip") + def build_path(self): + return self.current_path / Path("Build-Folder/") @property - def oc_folder(self): return self.opencore_release_folder / Path("EFI/OC/") + def opencore_release_folder(self): + return self.build_path / Path(f"OpenCore-{self.opencore_build}") + @property - def plist_path(self): return self.oc_folder / Path("config.plist") + def opencore_zip_copied(self): + return self.build_path / Path(f"OpenCore-{self.opencore_build}.zip") + @property - def acpi_path(self): return self.oc_folder / Path("ACPI") + def oc_folder(self): + return self.opencore_release_folder / Path("EFI/OC/") + @property - def drivers_path(self): return self.oc_folder / Path("Drivers") + def plist_path(self): + return self.oc_folder / Path("config.plist") + @property - def kexts_path(self): return self.oc_folder / Path("Kexts") + def acpi_path(self): + return self.oc_folder / Path("ACPI") + @property - def resources_path(self): return self.oc_folder / Path("Resources") + def drivers_path(self): + return self.oc_folder / Path("Drivers") + @property - def map_kext_folder(self): return self.kexts_path / Path("USB-Map.kext") + def kexts_path(self): + return self.oc_folder / Path("Kexts") + @property - def map_contents_folder(self): return self.map_kext_folder / Path("Contents") + def resources_path(self): + return self.oc_folder / Path("Resources") + @property - def pp_kext_folder(self): return self.kexts_path / Path("CPUFriendDataProvider.kext") + def map_kext_folder(self): + return self.kexts_path / Path("USB-Map.kext") + @property - def pp_contents_folder(self): return self.pp_kext_folder / Path("Contents") + def map_contents_folder(self): + return self.map_kext_folder / Path("Contents") + @property - def agdp_kext_folder(self): return self.kexts_path / Path("AGDP-Override.kext") + def pp_kext_folder(self): + return self.kexts_path / Path("CPUFriendDataProvider.kext") + @property - def agdp_contents_folder(self): return self.agdp_kext_folder / Path("Contents") + def pp_contents_folder(self): + return self.pp_kext_folder / Path("Contents") + @property - def agpm_kext_folder(self): return self.kexts_path / Path("AGPM-Override.kext") + def agdp_kext_folder(self): + return self.kexts_path / Path("AGDP-Override.kext") + @property - def agpm_contents_folder(self): return self.agpm_kext_folder / Path("Contents") + def agdp_contents_folder(self): + return self.agdp_kext_folder / Path("Contents") + @property - def amc_kext_folder(self): return self.kexts_path / Path("AMC-Override.kext") + def agpm_kext_folder(self): + return self.kexts_path / Path("AGPM-Override.kext") + @property - def amc_contents_folder(self): return self.amc_kext_folder / Path("Contents") + def agpm_contents_folder(self): + return self.agpm_kext_folder / Path("Contents") + + @property + def amc_kext_folder(self): + return self.kexts_path / Path("AMC-Override.kext") + + @property + def amc_contents_folder(self): + return self.amc_kext_folder / Path("Contents") # Tools @property - def macserial_path(self): return self.payload_path / Path("Tools/macserial") + def macserial_path(self): + return self.payload_path / Path("Tools/macserial") + @property - def gfxutil_path(self): return self.payload_path / Path("Tools/gfxutil") + def gfxutil_path(self): + return self.payload_path / Path("Tools/gfxutil") + @property - def vault_path(self): return self.payload_path / Path("Tools/CreateVault/sign.command") + def vault_path(self): + return self.payload_path / Path("Tools/CreateVault/sign.command") # Icons @property - def app_icon_path(self): return self.current_path / Path("OC-Patcher.icns") + def app_icon_path(self): + return self.current_path / Path("OC-Patcher.icns") + @property - def icon_path_external(self): return self.payload_path / Path("Icon/External/.VolumeIcon.icns") + def icon_path_external(self): + return self.payload_path / Path("Icon/External/.VolumeIcon.icns") + @property - def icon_path_internal(self): return self.payload_path / Path("Icon/Internal/.VolumeIcon.icns") + def icon_path_internal(self): + return self.payload_path / Path("Icon/Internal/.VolumeIcon.icns") + @property - def icon_path_sd(self): return self.payload_path / Path("Icon/SD-Card/.VolumeIcon.icns") + def icon_path_sd(self): + return self.payload_path / Path("Icon/SD-Card/.VolumeIcon.icns") + @property - def icon_path_ssd(self): return self.payload_path / Path("Icon/SSD/.VolumeIcon.icns") + def icon_path_ssd(self): + return self.payload_path / Path("Icon/SSD/.VolumeIcon.icns") + @property - def gui_path(self): return self.payload_path / Path("Icon/Resources.zip") + def gui_path(self): + return self.payload_path / Path("Icon/Resources.zip") # Apple Payloads Paths @property - def payload_apple_root_path_unzip(self): return self.payload_path / Path(f"Apple-Binaries-OCLP-{self.payload_version}") + def payload_apple_root_path_unzip(self): + return self.payload_path / Path(f"Apple-Binaries-OCLP-{self.payload_version}") + @property - def payload_apple_root_path_zip(self): return self.payload_path / Path("Apple.zip") + def payload_apple_root_path_zip(self): + return self.payload_path / Path("Apple.zip") + @property - def payload_apple_root_path(self): return self.payload_path / Path("Apple") + def payload_apple_root_path(self): + return self.payload_path / Path("Apple") + @property - def payload_apple_kexts_path(self): return self.payload_apple_root_path / Path("Extensions") + def payload_apple_kexts_path(self): + return self.payload_apple_root_path / Path("Extensions") + @property - def payload_apple_frameworks_path(self): return self.payload_apple_root_path / Path("Frameworks") + def payload_apple_frameworks_path(self): + return self.payload_apple_root_path / Path("Frameworks") + @property - def payload_apple_frameworks_path_accel(self): return self.payload_apple_frameworks_path / Path("Graphics-Acceleration") + def payload_apple_frameworks_path_accel(self): + return self.payload_apple_frameworks_path / Path("Graphics-Acceleration") + @property - def payload_apple_frameworks_path_accel_ts2(self): return self.payload_apple_frameworks_path / Path("Graphics-Acceleration-TS2") + def payload_apple_frameworks_path_accel_ts2(self): + return self.payload_apple_frameworks_path / Path("Graphics-Acceleration-TS2") + @property - def payload_apple_lauchd_path(self): return self.payload_apple_root_path / Path("LaunchDaemons") + def payload_apple_lauchd_path(self): + return self.payload_apple_root_path / Path("LaunchDaemons") + @property - def payload_apple_lauchd_path_accel(self): return self.payload_apple_lauchd_path / Path("Graphics-Acceleration") + def payload_apple_lauchd_path_accel(self): + return self.payload_apple_lauchd_path / Path("Graphics-Acceleration") + @property - def payload_apple_private_frameworks_path(self): return self.payload_apple_root_path / Path("PrivateFrameworks") + def payload_apple_private_frameworks_path(self): + return self.payload_apple_root_path / Path("PrivateFrameworks") + @property - def payload_apple_private_frameworks_path_accel(self): return self.payload_apple_private_frameworks_path / Path("Graphics-Acceleration") + def payload_apple_private_frameworks_path_accel(self): + return self.payload_apple_private_frameworks_path / Path("Graphics-Acceleration") + @property - def payload_apple_private_frameworks_path_accel_ts2(self): return self.payload_apple_private_frameworks_path / Path("Graphics-Acceleration-TS2") + def payload_apple_private_frameworks_path_accel_ts2(self): + return self.payload_apple_private_frameworks_path / Path("Graphics-Acceleration-TS2") + @property - def payload_apple_private_frameworks_path_brightness(self): return self.payload_apple_private_frameworks_path / Path("Brightness-Control") + def payload_apple_private_frameworks_path_brightness(self): + return self.payload_apple_private_frameworks_path / Path("Brightness-Control") # Apple Extensions @property - def audio_path(self): return self.payload_apple_kexts_path / Path("Audio") + def audio_path(self): + return self.payload_apple_kexts_path / Path("Audio") # GPU Kexts and Bundles @property - def legacy_graphics(self): return self.payload_apple_kexts_path / Path("Graphics-Acceleration") - @property - def legacy_graphics_ts2(self): return self.payload_apple_kexts_path / Path("Graphics-Acceleration-TS2") - @property - def legacy_nvidia_path(self): return self.legacy_graphics / Path("Nvidia-Tesla-Fermi") - @property - def legacy_nvidia_kepler_path(self): return self.legacy_graphics / Path("Nvidia-Kepler") - @property - def legacy_amd_path(self): return self.legacy_graphics / Path("AMD-ATI") - @property - def legacy_amd_path_ts2(self): return self.legacy_graphics / Path("ATI-TS2") - @property - def legacy_intel_gen1_path(self): return self.legacy_graphics / Path("Intel-Gen5-Ironlake") - @property - def legacy_intel_gen2_path(self): return self.legacy_graphics / Path("Intel-Gen6-SandyBridge") - @property - def legacy_intel_gen3_path(self): return self.legacy_graphics / Path("Intel-Gen7-IvyBridge") - @property - def legacy_general_path(self): return self.legacy_graphics / Path("General-Patches") + def legacy_graphics(self): + return self.payload_apple_kexts_path / Path("Graphics-Acceleration") @property - def legacy_brightness(self): return self.payload_apple_kexts_path / Path("Brightness-Control") + def legacy_graphics_ts2(self): + return self.payload_apple_kexts_path / Path("Graphics-Acceleration-TS2") + + @property + def legacy_nvidia_path(self): + return self.legacy_graphics / Path("Nvidia-Tesla-Fermi") + + @property + def legacy_nvidia_kepler_path(self): + return self.legacy_graphics / Path("Nvidia-Kepler") + + @property + def legacy_amd_path(self): + return self.legacy_graphics / Path("AMD-ATI") + + @property + def legacy_amd_path_ts2(self): + return self.legacy_graphics / Path("ATI-TS2") + + @property + def legacy_intel_gen1_path(self): + return self.legacy_graphics / Path("Intel-Gen5-Ironlake") + + @property + def legacy_intel_gen2_path(self): + return self.legacy_graphics / Path("Intel-Gen6-SandyBridge") + + @property + def legacy_intel_gen3_path(self): + return self.legacy_graphics / Path("Intel-Gen7-IvyBridge") + + @property + def legacy_general_path(self): + return self.legacy_graphics / Path("General-Patches") + + @property + def legacy_brightness(self): + return self.payload_apple_kexts_path / Path("Brightness-Control") # Apple Frameworks @property - def coredisplay_path(self): return self.payload_apple_frameworks_path_accel / Path("CoreDisplay.framework") + def coredisplay_path(self): + return self.payload_apple_frameworks_path_accel / Path("CoreDisplay.framework") + @property - def iosurface_f_path(self): return self.payload_apple_frameworks_path_accel / Path("IOSurface.framework") + def iosurface_f_path(self): + return self.payload_apple_frameworks_path_accel / Path("IOSurface.framework") + @property - def opengl_path(self): return self.payload_apple_frameworks_path_accel / Path("OpenGL.framework") + def opengl_path(self): + return self.payload_apple_frameworks_path_accel / Path("OpenGL.framework") # Apple LaunchDaemons @property - def hiddhack_path(self): return self.payload_apple_lauchd_path_accel / Path("IOHID-Fixup.plist") + def hiddhack_path(self): + return self.payload_apple_lauchd_path_accel / Path("IOHID-Fixup.plist") + @property - def legacy_hiddhack_path(self): return self.payload_apple_lauchd_path_accel / Path("HiddHack.plist") + def legacy_hiddhack_path(self): + return self.payload_apple_lauchd_path_accel / Path("HiddHack.plist") # Apple PrivateFrameworks @property - def gpusupport_path(self): return self.payload_apple_private_frameworks_path_accel / Path("GPUSupport.framework") + def gpusupport_path(self): + return self.payload_apple_private_frameworks_path_accel / Path("GPUSupport.framework") + @property - def skylight_path(self): return self.payload_apple_private_frameworks_path_accel / Path("SkyLight.framework") + def skylight_path(self): + return self.payload_apple_private_frameworks_path_accel / Path("SkyLight.framework") csr_values = { - "CSR_ALLOW_UNTRUSTED_KEXTS": False, # 0x1 - Allows Unsigned Kexts - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_UNRESTRICTED_FS": False, # 0x2 - File System Access - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_TASK_FOR_PID": False, # 0x4 - Unrestricted Debugging - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_KERNEL_DEBUGGER": False, # 0x8 - Allow Kernel Debugger - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_APPLE_INTERNAL": False, # 0x10 - Set AppleInternal Features - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_UNRESTRICTED_DTRACE": False, # 0x20 - Unrestricted DTrace usage - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_UNRESTRICTED_NVRAM": False, # 0x40 - Unrestricted NVRAM write - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_DEVICE_CONFIGURATION": False, # 0x80 - Allow Device Configuration(?) - Introduced in El Capitan # noqa: E241 - "CSR_ALLOW_ANY_RECOVERY_OS": False, # 0x100 - Disable BaseSystem Verification - Introduced in Sierra # noqa: E241 - "CSR_ALLOW_UNAPPROVED_KEXTS": False, # 0x200 - Allow Unapproved Kexts - Introduced in High Sierra # noqa: E241 + "CSR_ALLOW_UNTRUSTED_KEXTS": False, # 0x1 - Allows Unsigned Kexts - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_UNRESTRICTED_FS": False, # 0x2 - File System Access - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_TASK_FOR_PID": False, # 0x4 - Unrestricted Debugging - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_KERNEL_DEBUGGER": False, # 0x8 - Allow Kernel Debugger - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_APPLE_INTERNAL": False, # 0x10 - Set AppleInternal Features - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_UNRESTRICTED_DTRACE": False, # 0x20 - Unrestricted DTrace usage - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_UNRESTRICTED_NVRAM": False, # 0x40 - Unrestricted NVRAM write - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_DEVICE_CONFIGURATION": False, # 0x80 - Allow Device Configuration(?) - Introduced in El Capitan # noqa: E241 + "CSR_ALLOW_ANY_RECOVERY_OS": False, # 0x100 - Disable BaseSystem Verification - Introduced in Sierra # noqa: E241 + "CSR_ALLOW_UNAPPROVED_KEXTS": False, # 0x200 - Allow Unapproved Kexts - Introduced in High Sierra # noqa: E241 "CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE": False, # 0x400 - Override Executable Policy - Introduced in Mojave # noqa: E241 - "CSR_ALLOW_UNAUTHENTICATED_ROOT": False, # 0x800 - Allow Root Volume Mounting - Introduced in Big Sur # noqa: E241 + "CSR_ALLOW_UNAUTHENTICATED_ROOT": False, # 0x800 - Allow Root Volume Mounting - Introduced in Big Sur # noqa: E241 } root_patch_sip_mojave = [ @@ -442,7 +634,7 @@ class Constants: "MacBookAir7,1": "Mac-9F18E312C5C2BF0B", "MacBookAir7,2": "Mac-937CB26E2E02BB01", "MacBookAir8,1": "Mac-827FAC58A8FDFA22", - "MacBookAir8,1": "Mac-226CB3C6A851A671", + "MacBookAir8,2": "Mac-226CB3C6A851A671", "MacBookAir9,1": "Mac-0CFF9C7C2B63DF8D", "MacBookPro1,1": "Mac-F425BEC8", "MacBookPro1,2": "Mac-F42DBEC8", @@ -505,14 +697,13 @@ class Constants: "iMac8,1": "Mac-F227BEC8", "iMac9,1": "Mac-F2218FA9", "iMac10,1": "Mac-F221DCC8", - "iMac10,1": "Mac-F2268CC8", + # "iMac10,1": "Mac-F2268CC8", "iMac11,1": "Mac-F2268DAE", "iMac11,2": "Mac-F2238AC8", "iMac11,3": "Mac-F2238BAE", "iMac12,1": "Mac-942B5BF58194151B", "iMac12,2": "Mac-942B59F58194171B", "iMac13,1": "Mac-00BE6ED71E35EB86", - "iMac13,1": "Mac-00BE6ED71E35EB86", "iMac13,2": "Mac-FC02E91DDD3FA6A4", "iMac13,3": "Mac-7DF2A3B5E5D671ED", "iMac14,1": "Mac-031B6874CF7F642A", diff --git a/Resources/DeviceProbe.py b/Resources/DeviceProbe.py deleted file mode 100644 index 25cefb781..000000000 --- a/Resources/DeviceProbe.py +++ /dev/null @@ -1,116 +0,0 @@ -# Probe devices, return device entries -# Copyright (C) 2021 Mykola Grymalyuk -from __future__ import print_function - -import binascii -import plistlib -import subprocess - -from Resources import Constants, Utilities - -class pci_probe: - def __init__(self): - self.constants = Constants.Constants() - - # Converts given device IDs to DeviceProperty pathing, requires ACPI pathing as DeviceProperties shouldn't be used otherwise - def deviceproperty_probe(self, vendor_id, device_id, acpi_path): - gfxutil_output: str = subprocess.run([self.constants.gfxutil_path] + f"-v".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - try: - if acpi_path == "": - acpi_path = "No ACPI Path Given" - raise IndexError - device_path = [line.strip().split("= ", 1)[1] for line in gfxutil_output.split("\n") if f'{vendor_id}:{device_id}'.lower() in line.strip() and acpi_path in line.strip()][0] - return device_path - except IndexError: - print(f"- No DevicePath found for {vendor_id}:{device_id} ({acpi_path})") - return "" - - # Returns the device path of parent controller - def device_property_parent(self, device_path): - device_path_parent = "/".join(device_path.split("/")[:-1]) - return device_path_parent - - def acpi_strip(self, acpi_path_full): - # Strip IOACPIPlane:/_SB, remove 000's, convert ffff into 0 and finally make everything upper case - # IOReg | gfxutil - # IOACPIPlane:/_SB/PC00@0/DMI0@0 -> /PC00@0/DMI0@0 - # IOACPIPlane:/_SB/PC03@0/BR3A@0/SL09@ffff -> /PC03@0/BR3A@0/SL09@0 - # IOACPIPlane:/_SB/PC03@0/M2U0@150000 -> /PC03@0/M2U0@15 - # IOACPIPlane:/_SB/PC01@0/CHA6@100000 -> /PC01@0/CHA6@10 - # IOACPIPlane:/_SB/PC00@0/RP09@1d0000/PXSX@0 -> /PC00@0/RP09@1D/PXSX@0 - # IOACPIPlane:/_SB/PCI0@0/P0P2@10000 -> /PCI0@0/P0P2@1 - acpi_path = acpi_path_full.replace("IOACPIPlane:/_SB", "") - acpi_path = acpi_path.replace("0000", "") - for entry in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]: - acpi_path = acpi_path.replace(f"000{entry}", f",{entry}") - acpi_path = acpi_path.replace("ffff", "0") - acpi_path = acpi_path.upper() - return acpi_path - - # Note gpu_probe should only be used on IGPU and GFX0 entries - def gpu_probe(self, gpu_type): - try: - devices = plistlib.loads(subprocess.run(f"ioreg -r -n {gpu_type} -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - vendor_id = Utilities.hexswap(binascii.hexlify(devices[0]["vendor-id"]).decode()[:4]) - device_id = Utilities.hexswap(binascii.hexlify(devices[0]["device-id"]).decode()[:4]) - try: - acpi_path = devices[0]["acpi-path"] - acpi_path = self.acpi_strip(acpi_path) - return vendor_id, device_id, acpi_path - except KeyError: - print(f"- No ACPI entry found for {gpu_type}") - return vendor_id, device_id, "" - except ValueError: - print(f"- No IOService entry found for {gpu_type} (V)") - return "", "", "" - except IndexError: - print(f"- No IOService entry found for {gpu_type} (I)") - return "", "", "" - - def wifi_probe(self): - devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - try: - devices = [i for i in devices if i["class-code"] == binascii.unhexlify(self.constants.classcode_wifi)] - vendor_id = Utilities.hexswap(binascii.hexlify(devices[0]["vendor-id"]).decode()[:4]) - device_id = Utilities.hexswap(binascii.hexlify(devices[0]["device-id"]).decode()[:4]) - ioname = devices[0]["IOName"] - try: - acpi_path = devices[0]["acpi-path"] - acpi_path = self.acpi_strip(acpi_path) - return vendor_id, device_id, ioname, acpi_path - except KeyError: - print(f"- No ACPI entry found for {vendor_id}:{device_id}") - return vendor_id, device_id, ioname, "" - except ValueError: - print(f"- No IOService entry found for Wireless Card (V)") - return "", "", "", "" - except IndexError: - print(f"- No IOService entry found for Wireless Card (I)") - return "", "", "", "" - - def cpu_feature(self, instruction): - cpu_features = subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" ") - if instruction in cpu_features: - print(f"- Found {instruction} support") - return True - else: - print(f"- Failed to find {instruction} support") - return False - -class smbios_probe: - def model_detect(self, custom): - opencore_model: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-product".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - if not opencore_model.startswith("nvram: Error getting variable") and custom is False: - current_model = [line.strip().split(":oem-product ", 1)[1] for line in opencore_model.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0] - else: - current_model = plistlib.loads(subprocess.run("system_profiler -detailLevel mini -xml SPHardwareDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.strip())[0]["_items"][0]["machine_model"] - return current_model - - def board_detect(self, custom): - opencore_model: str = subprocess.run("nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:oem-board".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - if not opencore_model.startswith("nvram: Error getting variable") and custom is False: - current_model = [line.strip().split(":oem-board ", 1)[1] for line in opencore_model.split("\n") if line.strip().startswith("4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:")][0] - else: - current_model = plistlib.loads(subprocess.run(f"ioreg -p IODeviceTree -r -n / -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - current_model = current_model[0]["board-id"] - return current_model \ No newline at end of file diff --git a/Resources/ModelArray.py b/Resources/ModelArray.py index 52de2e308..33a0e02ac 100644 --- a/Resources/ModelArray.py +++ b/Resources/ModelArray.py @@ -100,32 +100,14 @@ MissingSSE42 = [ "iMac10,1", "MacPro3,1", "Xserve2,1", - "Dortania1,1" + "Dortania1,1", ] -SSEEmulator = [ - "MacPro3,1", - "Xserve2,1", - "Dortania1,1" -] +SSEEmulator = ["MacPro3,1", "Xserve2,1", "Dortania1,1"] -DualSocket = [ - "MacPro3,1", - "MacPro4,1", - "MacPro5,1", - "Xserve2,1", - "Xserve3,1", - "Dortania1,1" -] +DualSocket = ["MacPro3,1", "MacPro4,1", "MacPro5,1", "Xserve2,1", "Xserve3,1", "Dortania1,1"] -pciSSDT = [ - "MacBookPro6,1", - "MacBookPro6,2", - "iMac11,1", - "iMac11,2", - "iMac11,3", - "Dortania1,1" -] +pciSSDT = ["MacBookPro6,1", "MacBookPro6,2", "iMac11,1", "iMac11,2", "iMac11,3", "Dortania1,1"] # Ethernet patches @@ -142,15 +124,9 @@ EthernetNvidia = [ "Macmini3,1", "iMac9,1", "iMac10,1", - "Dortania1,1" -] -EthernetMarvell = [ - "MacBook4,1", - "MacBookPro4,1", - "iMac7,1", - "iMac8,1", - "Dortania1,1" + "Dortania1,1", ] +EthernetMarvell = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "Dortania1,1"] EthernetBroadcom = [ "MacBookAir4,1", "MacBookAir4,2", @@ -169,31 +145,14 @@ EthernetBroadcom = [ "iMac11,3", "iMac12,1", "iMac12,2", - "Dortania1,1" + "Dortania1,1", ] # Wifi patches -WifiAtheros = [ - "iMac10,1", - "iMac11,1", - "iMac11,2", - "iMac11,3", - "iMac12,1", - "iMac12,2", - "MacPro3,1", - "MacPro4,1", - "Dortania1,1" -] +WifiAtheros = ["iMac10,1", "iMac11,1", "iMac11,2", "iMac11,3", "iMac12,1", "iMac12,2", "MacPro3,1", "MacPro4,1", "Dortania1,1"] -WifiBCM94328 = [ - "MacBook4,1", - "MacBookAir2,1", - "MacBookPro4,1", - "iMac7,1", - "iMac8,1", - "Dortania1,1" -] +WifiBCM94328 = ["MacBook4,1", "MacBookAir2,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "Dortania1,1"] WifiBCM94322 = [ "MacBook5,1", @@ -209,12 +168,12 @@ WifiBCM94322 = [ "Macmini3,1", "iMac9,1", "MacPro5,1", - "Dortania1,1" + "Dortania1,1", ] WifiBCM94331 = [ - "MacBook6,1", # PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0) - "MacBook7,1", # PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0) + "MacBook6,1", # PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0) + "MacBook7,1", # PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0) "MacBookAir4,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) "MacBookAir4,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) "MacBookAir5,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) @@ -228,16 +187,16 @@ WifiBCM94331 = [ "MacBookPro9,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) "MacBookPro10,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) "MacBookPro10,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) - "Macmini4,1", # PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0) - "Macmini5,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) - "Macmini5,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) - "Macmini5,3", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) - "Macmini6,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) - "Macmini6,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) - "iMac13,1", # PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0) - "iMac13,2", # PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0) - "iMac13,3", # PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0) - "Dortania1,1" + "Macmini4,1", # PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0) + "Macmini5,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) + "Macmini5,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) + "Macmini5,3", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) + "Macmini6,1", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) + "Macmini6,2", # PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0) + "iMac13,1", # PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0) + "iMac13,2", # PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0) + "iMac13,3", # PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0) + "Dortania1,1", ] # Audio @@ -270,8 +229,8 @@ LegacyAudio = [ "Macmini5,1", "Macmini5,2", "Macmini5,3", - #"iMac7,1", - #"iMac8,1", + # "iMac7,1", + # "iMac8,1", "iMac9,1", "iMac10,1", "iMac11,1", @@ -280,7 +239,7 @@ LegacyAudio = [ "iMac12,1", "iMac12,2", "MacPro3,1", - "Dortania1,1" + "Dortania1,1", ] nvidiaHDEF = [ @@ -300,7 +259,7 @@ nvidiaHDEF = [ "Macmini3,1", "Macmini4,1", "iMac9,1", - "iMac10,1" + "iMac10,1", ] # GPU @@ -355,7 +314,7 @@ LegacyGPU = [ "iMac11,3", # AMD 5000 "iMac12,1", # AMD 6000 "iMac12,2", # AMD 6000 - "Dortania1,1" # RTX 3080 + "Dortania1,1", # RTX 3080 ] LegacyGPUNvidia = [ @@ -447,15 +406,10 @@ LegacyHID = [ "iMac9,1", "iMac10,1", "MacPro3,1", - "Dortania1,1" + "Dortania1,1", ] -NVMePatch = [ - "MacPro3,1", - "MacPro4,1", - "Xserve3,1", - "Dortania1,1" -] +NVMePatch = ["MacPro3,1", "MacPro4,1", "Xserve3,1", "Dortania1,1"] XhciSupport = [ "MacBookAir5,1", @@ -487,7 +441,7 @@ XhciSupport = [ "iMac16,1", "iMac16,2", "MacPro6,1", - "Dortania1,1" + "Dortania1,1", ] SidecarPatch = [ @@ -522,7 +476,7 @@ SidecarPatch = [ "iMac16,2", "MacPro5,1", "MacPro6,1", - "Dortania1,1" + "Dortania1,1", ] DualGPUPatch = [ @@ -540,7 +494,7 @@ DualGPUPatch = [ "iMac13,2", "iMac14,2", "iMac14,3", - "Dortania1,1" + "Dortania1,1", ] DualGPUPatchRetina = [ @@ -555,26 +509,9 @@ IntelNvidiaDRM = [ "iMac14,3", ] -HiDPIpicker = [ - "MacBook8,1", - "MacBookPro10,1", - "MacBookPro10,2", - "MacBookPro11,1", - "MacBookPro11,2", - "MacBookPro11,3", - "iMac15,1", - "Dortania1,1" -] +HiDPIpicker = ["MacBook8,1", "MacBookPro10,1", "MacBookPro10,2", "MacBookPro11,1", "MacBookPro11,2", "MacBookPro11,3", "iMac15,1", "Dortania1,1"] -IDEPatch = [ - "MacBook4,1", - "MacBookPro4,1", - "iMac7,1", - "iMac8,1", - "MacPro3,1", - "Xserve2,1", - "Dortania1,1" -] +IDEPatch = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "MacPro3,1", "Xserve2,1", "Dortania1,1"] # 11" Air MacBookAir61 = [ @@ -616,9 +553,7 @@ MacBookPro111 = [ # MacBook Pro 15" (iGPU) -MacBookPro112 = [ - "MacBookPro11,2" -] +MacBookPro112 = ["MacBookPro11,2"] # MacBook Pro 15" and 17" (dGPU) @@ -639,15 +574,7 @@ MacBookPro113 = [ # Mac Mini -Macmini71 = [ - "Macmini3,1", - "Macmini4,1", - "Macmini5,1", - "Macmini5,2", - "Macmini5,3", - "Macmini6,1", - "Macmini6,2" -] +Macmini71 = ["Macmini3,1", "Macmini4,1", "Macmini5,1", "Macmini5,2", "Macmini5,3", "Macmini6,1", "Macmini6,2"] # iMacPro = dGPU only iMacs iMacPro11 = [ "iMac7,1", @@ -669,21 +596,10 @@ iMac151 = [ "iMac15,1", ] # iMac = Intel iGPU -iMac144 = [ - "iMac13,1", - "iMac14,1", - "iMac14,4" -] +iMac144 = ["iMac13,1", "iMac14,1", "iMac14,4"] # Mac Pro and Xserve -MacPro71 = [ - "MacPro3,1", - "MacPro4,1", - "MacPro5,1", - "Xserve2,1", - "Xserve3,1", - "Dortania1,1" -] +MacPro71 = ["MacPro3,1", "MacPro4,1", "MacPro5,1", "Xserve2,1", "Xserve3,1", "Dortania1,1"] XXerve = [ "Xserve3,1", @@ -778,16 +694,7 @@ ControllerTypes = [ "-InternalHub", ] -upgradableMXMGPUs = [ - "iMac10,1" - "iMac11,1", - "iMac11,2", - "iMac11,3", - "iMac12,1", - "iMac12,2", - "Xserve3,1", - "Dortania1,1" -] +upgradableMXMGPUs = ["iMac10,1", "iMac11,1", "iMac11,2", "iMac11,3", "iMac12,1", "iMac12,2", "Xserve3,1", "Dortania1,1"] NightShift = [ "MacBook4,1", @@ -831,7 +738,7 @@ NightShift = [ "MacPro5,1", "Xserve2,1", "Xserve3,1", - "Dortania1,1" + "Dortania1,1", ] UGAtoGOP = [ @@ -887,7 +794,7 @@ SATAPatch = [ "MacPro5,1", "Xserve2,1", "Xserve3,1", - "Dortania1,1" + "Dortania1,1", ] NoAPFSsupport = [ @@ -909,7 +816,7 @@ NoAPFSsupport = [ "MacPro4,1", "Xserve2,1", "Xserve3,1", - "Dortania1,1" + "Dortania1,1", ] NoRootPatch11 = [ @@ -959,7 +866,7 @@ NoExFat = [ "MacPro5,1", "Xserve2,1", "Xserve3,1", - "Dortania1,1" + "Dortania1,1", ] SandyIGPU = [ @@ -997,14 +904,7 @@ windows_audio = [ "iMac13,3", ] -NoAGPMSupport = [ - "MacBook4,1", - "MacBookPro4,1", - "iMac7,1", - "iMac8,1", - "MacPro3,1", - "Xserve2,1" -] +NoAGPMSupport = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "MacPro3,1", "Xserve2,1"] AGDPSupport = [ "MacBookPro9,1", @@ -1017,37 +917,32 @@ AGDPSupport = [ "iMac14,4", "iMac15,1", # TODO: Uncomment when dropped from macOS - #"iMac17,1", - #"iMac18,2", - #"iMac18,3", - #"iMac19,1", - #"iMac19,2", - #"iMac20,1", - #"iMac20,2", - #"iMacPro1,1", - #"MacPro6,1", + # "iMac17,1", + # "iMac18,2", + # "iMac18,3", + # "iMac19,1", + # "iMac19,2", + # "iMac20,1", + # "iMac20,2", + # "iMacPro1,1", + # "MacPro6,1", ] AMCSupport = [ "MacBookPro8,2", "MacBookPro8,3", - #"MacBookPro9,1", - #"MacBookPro10,1" + # "MacBookPro9,1", + # "MacBookPro10,1" ] NoFireWireSupport = [ - "MacBook5,1", - "MacBook6,1", - "MacBook7,1", - "MacBookAir1,1", - "MacBookAir2,1", - "MacBookAir3,1", - "MacBookAir3,2", + "MacBook5,1", + "MacBook6,1", + "MacBook7,1", + "MacBookAir1,1", + "MacBookAir2,1", + "MacBookAir3,1", + "MacBookAir3,2", ] -RecoveryIgnore = [ - "Update", - "VM", - "Recovery", - "Preboot" -] +RecoveryIgnore = ["Update", "VM", "Recovery", "Preboot"] diff --git a/Resources/PCIIDArray.py b/Resources/PCIIDArray.py index c6849e13b..57867c931 100644 --- a/Resources/PCIIDArray.py +++ b/Resources/PCIIDArray.py @@ -1,788 +1,794 @@ # Array of Device IDs for different devices + + class nvidia_ids: # Courteous of envytools as well as Macrumors: # https://envytools.readthedocs.io/en/latest/hw/pciid.html # https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/ tesla_ids = [ # G80 - "0190", # G80 [GeForce 8800 GTS / 8800 GTX] - "0191", # G80 [GeForce 8800 GTX] - "0193", # G80 [GeForce 8800 GTS] - "0194", # G80 [GeForce 8800 Ultra] - "019E", # G80GL [Quadro FX 4600] - "019D", # G80GL [Quadro FX 5600] + 0x0190, # G80 [GeForce 8800 GTS / 8800 GTX] + 0x0191, # G80 [GeForce 8800 GTX] + 0x0193, # G80 [GeForce 8800 GTS] + 0x0194, # G80 [GeForce 8800 Ultra] + 0x019E, # G80GL [Quadro FX 4600] + 0x019D, # G80GL [Quadro FX 5600] # G84 - "0400", # G84 [8600 GTS] - "0401", # G84 [8600 GT] - "0402", # G84 [8600 GT] - "0403", # G84 [8600 GS] - "0404", # G84 [8400 GS] - "0405", # G84 [9500M GS] - "0406", # G84 [8300 GS] - "0407", # G84 [8600M GT] - "0408", # G84 [9650M GS] - "0409", # G84 [8700M GT] - "040A", # G84 [FX 370] - "040B", # G84 [NVS 320M] - "040C", # G84 [FX 570M] - "040D", # G84 [FX 1600M] - "040E", # G84 [FX 570] - "040F", # G84 [FX 1700] + 0x0400, # G84 [8600 GTS] + 0x0401, # G84 [8600 GT] + 0x0402, # G84 [8600 GT] + 0x0403, # G84 [8600 GS] + 0x0404, # G84 [8400 GS] + 0x0405, # G84 [9500M GS] + 0x0406, # G84 [8300 GS] + 0x0407, # G84 [8600M GT] + 0x0408, # G84 [9650M GS] + 0x0409, # G84 [8700M GT] + 0x040A, # G84 [FX 370] + 0x040B, # G84 [NVS 320M] + 0x040C, # G84 [FX 570M] + 0x040D, # G84 [FX 1600M] + 0x040E, # G84 [FX 570] + 0x040F, # G84 [FX 1700] # G86 - "0420", # G86 [8400 SE] - "0421", # G86 [8500 GT] - "0422", # G86 [8400 GS] - "0423", # G86 [8300 GS] - "0424", # G86 [8400 GS] - "0425", # G86 [8600M GS] - "0426", # G86 [8400M GT] - "0427", # G86 [8400M GS] - "0428", # G86 [8400M G] - "0429", # G86 [NVS 140M] - "042A", # G86 [NVS 130M] - "042B", # G86 [NVS 135M] - "042C", # G86 [9400 GT] - "042D", # G86 [FX 360M] - "042E", # G86 [9300M G] - "042F", # G86 [NVS 290] + 0x0420, # G86 [8400 SE] + 0x0421, # G86 [8500 GT] + 0x0422, # G86 [8400 GS] + 0x0423, # G86 [8300 GS] + 0x0424, # G86 [8400 GS] + 0x0425, # G86 [8600M GS] + 0x0426, # G86 [8400M GT] + 0x0427, # G86 [8400M GS] + 0x0428, # G86 [8400M G] + 0x0429, # G86 [NVS 140M] + 0x042A, # G86 [NVS 130M] + 0x042B, # G86 [NVS 135M] + 0x042C, # G86 [9400 GT] + 0x042D, # G86 [FX 360M] + 0x042E, # G86 [9300M G] + 0x042F, # G86 [NVS 290] # G92 - "0410", # G92 [GT 330] - "0600", # G92 [8800 GTS 512] - "0601", # G92 [9800 GT] - "0602", # G92 [8800 GT] - "0603", # G92 [GT 230] - "0604", # G92 [9800 GX2] - "0605", # G92 [9800 GT] - "0606", # G92 [8800 GS] - "0607", # G92 [GTS 240] - "0608", # G92 [9800M GTX] - "0609", # G92 [8800M GTS] - "060A", # G92 [GTX 280M] - "060B", # G92 [9800M GT] - "060C", # G92 [8800M GTX] - "060F", # G92 [GTX 285M] - "0610", # G92 [9600 GSO] - "0611", # G92 [8800 GT] - "0612", # G92 [9800 GTX/9800 GTX+] - "0613", # G92 [9800 GTX+] - "0614", # G92 [9800 GT] - "0615", # G92 [GTS 250] - "0617", # G92 [9800M GTX] - "0618", # G92 [GTX 260M] - "0619", # G92 [FX 4700 X2] - "061A", # G92 [FX 3700] - "061B", # G92 [VX 200] - "061C", # G92 [FX 3600M] - "061D", # G92 [FX 2800M] - "061E", # G92 [FX 3700M] - "061F", # G92 [FX 3800M] + 0x0410, # G92 [GT 330] + 0x0600, # G92 [8800 GTS 512] + 0x0601, # G92 [9800 GT] + 0x0602, # G92 [8800 GT] + 0x0603, # G92 [GT 230] + 0x0604, # G92 [9800 GX2] + 0x0605, # G92 [9800 GT] + 0x0606, # G92 [8800 GS] + 0x0607, # G92 [GTS 240] + 0x0608, # G92 [9800M GTX] + 0x0609, # G92 [8800M GTS] + 0x060A, # G92 [GTX 280M] + 0x060B, # G92 [9800M GT] + 0x060C, # G92 [8800M GTX] + 0x060F, # G92 [GTX 285M] + 0x0610, # G92 [9600 GSO] + 0x0611, # G92 [8800 GT] + 0x0612, # G92 [9800 GTX/9800 GTX+] + 0x0613, # G92 [9800 GTX+] + 0x0614, # G92 [9800 GT] + 0x0615, # G92 [GTS 250] + 0x0617, # G92 [9800M GTX] + 0x0618, # G92 [GTX 260M] + 0x0619, # G92 [FX 4700 X2] + 0x061A, # G92 [FX 3700] + 0x061B, # G92 [VX 200] + 0x061C, # G92 [FX 3600M] + 0x061D, # G92 [FX 2800M] + 0x061E, # G92 [FX 3700M] + 0x061F, # G92 [FX 3800M] # G94 - "0621", # G94 [GT 230] - "0622", # G94 [9600 GT] - "0623", # G94 [9600 GS] - "0624", # G94 [9600 GT Green Edition] - "0625", # G94 [9600 GSO 512] - "0626", # G94 [GT 130] - "0627", # G94 [GT 140] - "0628", # G94 [9800M GTS] - "062A", # G94 [9700M GTS] - "062B", # G94 [9800M GS] - "062C", # G94 [9800M GTS ] - "062D", # G94 [9600 GT] - "062E", # G94 [9600 GT] - "062F", # G94 [9800 S] - "0631", # G94 [GTS 160M] - "0635", # G94 [9600 GSO] - "0637", # G94 [9600 GT] - "0638", # G94 [FX 1800] - "063A", # G94 [FX 2700M] + 0x0621, # G94 [GT 230] + 0x0622, # G94 [9600 GT] + 0x0623, # G94 [9600 GS] + 0x0624, # G94 [9600 GT Green Edition] + 0x0625, # G94 [9600 GSO 512] + 0x0626, # G94 [GT 130] + 0x0627, # G94 [GT 140] + 0x0628, # G94 [9800M GTS] + 0x062A, # G94 [9700M GTS] + 0x062B, # G94 [9800M GS] + 0x062C, # G94 [9800M GTS ] + 0x062D, # G94 [9600 GT] + 0x062E, # G94 [9600 GT] + 0x062F, # G94 [9800 S] + 0x0631, # G94 [GTS 160M] + 0x0635, # G94 [9600 GSO] + 0x0637, # G94 [9600 GT] + 0x0638, # G94 [FX 1800] + 0x063A, # G94 [FX 2700M] # G96 - "0640", # G96 [9500 GT] - "0641", # G96 [9400 GT] - "0643", # G96 [9500 GT] - "0644", # G96 [9500 GS] - "0645", # G96 [9500 GS] - "0646", # G96 [GT 120] - "0647", # G96 [9600M GT] - "0648", # G96 [9600M GS] - "0649", # G96 [9600M GT] - "064A", # G96 [9700M GT] - "064B", # G96 [9500M G] - "064C", # G96 [9650M GT] - "0651", # G96 [G 110M] - "0652", # G96 [GT 130M] - "0653", # G96 [GT 120M] - "0654", # G96 [GT 220M] - "0655", # G96 [GT 120] - "0656", # G96 [GT 120 ] - "0658", # G96 [FX 380] - "0659", # G96 [FX 580] - "065A", # G96 [FX 1700M] - "065B", # G96 [9400 GT] - "065C", # G96 [FX 770M] - "065F", # G96 [G210] + 0x0640, # G96 [9500 GT] + 0x0641, # G96 [9400 GT] + 0x0643, # G96 [9500 GT] + 0x0644, # G96 [9500 GS] + 0x0645, # G96 [9500 GS] + 0x0646, # G96 [GT 120] + 0x0647, # G96 [9600M GT] + 0x0648, # G96 [9600M GS] + 0x0649, # G96 [9600M GT] + 0x064A, # G96 [9700M GT] + 0x064B, # G96 [9500M G] + 0x064C, # G96 [9650M GT] + 0x0651, # G96 [G 110M] + 0x0652, # G96 [GT 130M] + 0x0653, # G96 [GT 120M] + 0x0654, # G96 [GT 220M] + 0x0655, # G96 [GT 120] + 0x0656, # G96 [GT 120 ] + 0x0658, # G96 [FX 380] + 0x0659, # G96 [FX 580] + 0x065A, # G96 [FX 1700M] + 0x065B, # G96 [9400 GT] + 0x065C, # G96 [FX 770M] + 0x065F, # G96 [G210] # G98 - "06E0", # G98 [9300 GE] - "06E1", # G98 [9300 GS] - "06E2", # G98 [8400] - "06E3", # G98 [8400 SE] - "06E4", # G98 [8400 GS] - "06E5", # G98M [9300M GS] - "06E6", # G98 [G100] - "06E7", # G98 [9300 SE] - "06E8", # G98 [9200M GS] - "06E9", # G98 [9300M GS] - "06EA", # G98 [NVS 150M] - "06EB", # G98 [NVS 160M] - "06EC", # G98 [G 105M] - "06ED", # G98 [9600 GT / 9800 GT] - "06EF", # G98 [G 103M] - "06F1", # G98 [G105M] - "06F8", # G98 [NVS 420] - "06F9", # G98 [FX 370 LP] - "06FA", # G98 [NVS 450] - "06FB", # G98 [FX 370M] - "06FD", # G98 [NVS 295] - "06FF", # G98 [HICx16] + 0x06E0, # G98 [9300 GE] + 0x06E1, # G98 [9300 GS] + 0x06E2, # G98 [8400] + 0x06E3, # G98 [8400 SE] + 0x06E4, # G98 [8400 GS] + 0x06E5, # G98M [9300M GS] + 0x06E6, # G98 [G100] + 0x06E7, # G98 [9300 SE] + 0x06E8, # G98 [9200M GS] + 0x06E9, # G98 [9300M GS] + 0x06EA, # G98 [NVS 150M] + 0x06EB, # G98 [NVS 160M] + 0x06EC, # G98 [G 105M] + 0x06ED, # G98 [9600 GT / 9800 GT] + 0x06EF, # G98 [G 103M] + 0x06F1, # G98 [G105M] + 0x06F8, # G98 [NVS 420] + 0x06F9, # G98 [FX 370 LP] + 0x06FA, # G98 [NVS 450] + 0x06FB, # G98 [FX 370M] + 0x06FD, # G98 [NVS 295] + 0x06FF, # G98 [HICx16] # GT200 - "05E0", # GT200 [GTX 295] - "05E1", # GT200 [GTX 280] - "05E2", # GT200 [GTX 260] - "05E3", # GT200 [GTX 285] - "05E6", # GT200 [GTX 275] - "05E7", # GT200 [C1060] - "05E9", # GT200 [CX] - "05EA", # GT200 [GTX 260] - "05EB", # GT200 [GTX 295] - "05ED", # GT200 [FX 5800] - "05EE", # GT200 [FX 4800] - "05EF", # GT200 [FX 3800] - "05FD", # GT200GL [Quadro FX 5800] - "05FE", # GT200GL [Quadro FX 4800] - "05FF", # GT200GL [Quadro FX 3800] + 0x05E0, # GT200 [GTX 295] + 0x05E1, # GT200 [GTX 280] + 0x05E2, # GT200 [GTX 260] + 0x05E3, # GT200 [GTX 285] + 0x05E6, # GT200 [GTX 275] + 0x05E7, # GT200 [C1060] + 0x05E9, # GT200 [CX] + 0x05EA, # GT200 [GTX 260] + 0x05EB, # GT200 [GTX 295] + 0x05ED, # GT200 [FX 5800] + 0x05EE, # GT200 [FX 4800] + 0x05EF, # GT200 [FX 3800] + 0x05FD, # GT200GL [Quadro FX 5800] + 0x05FE, # GT200GL [Quadro FX 4800] + 0x05FF, # GT200GL [Quadro FX 3800] # MCP77 GPU - "0840", # MCP77 GPU [8200M] - "0844", # MCP77 GPU [9100M G] - "0845", # MCP77 GPU [8200M G] - "0846", # MCP77 GPU [9200] - "0847", # MCP77 GPU [9100] - "0848", # MCP77 GPU [8300] - "0849", # MCP77 GPU [8200] - "084A", # MCP77 GPU [730A] - "084B", # MCP77 GPU [9200] - "084C", # MCP77 GPU [980A/780A SLI] - "084D", # MCP77 GPU [750A SLI] - "084F", # MCP77 GPU [8100 / 720A] + 0x0840, # MCP77 GPU [8200M] + 0x0844, # MCP77 GPU [9100M G] + 0x0845, # MCP77 GPU [8200M G] + 0x0846, # MCP77 GPU [9200] + 0x0847, # MCP77 GPU [9100] + 0x0848, # MCP77 GPU [8300] + 0x0849, # MCP77 GPU [8200] + 0x084A, # MCP77 GPU [730A] + 0x084B, # MCP77 GPU [9200] + 0x084C, # MCP77 GPU [980A/780A SLI] + 0x084D, # MCP77 GPU [750A SLI] + 0x084F, # MCP77 GPU [8100 / 720A] # MCP79 GPU - "0860", # MCP79 GPU [9400] - "0861", # MCP79 GPU [9400] - "0862", # MCP79 GPU [9400M G] - "0863", # MCP79 GPU [9400M] - "0864", # MCP79 GPU [9300] - "0865", # MCP79 GPU [ION] - "0866", # MCP79 GPU [9400M G] - "0867", # MCP79 GPU [9400] - "0868", # MCP79 GPU [760i SLI] - "0869", # MCP79 GPU [9400] - "086A", # MCP79 GPU [9400] - "086C", # MCP79 GPU [9300 / 730i] - "086D", # MCP79 GPU [9200] - "086E", # MCP79 GPU [9100M G] - "086F", # MCP79 GPU [8200M G] - "0870", # MCP79 GPU [9400M] - "0871", # MCP79 GPU [9200] - "0872", # MCP79 GPU [G102M] - "0873", # MCP79 GPU [G102M] - "0874", # MCP79 GPU [ION] - "0876", # MCP79 GPU [ION] - "087A", # MCP79 GPU [9400] - "087D", # MCP79 GPU [ION] - "087E", # MCP79 GPU [ION LE] - "087F", # MCP79 GPU [ION LE] + 0x0860, # MCP79 GPU [9400] + 0x0861, # MCP79 GPU [9400] + 0x0862, # MCP79 GPU [9400M G] + 0x0863, # MCP79 GPU [9400M] + 0x0864, # MCP79 GPU [9300] + 0x0865, # MCP79 GPU [ION] + 0x0866, # MCP79 GPU [9400M G] + 0x0867, # MCP79 GPU [9400] + 0x0868, # MCP79 GPU [760i SLI] + 0x0869, # MCP79 GPU [9400] + 0x086A, # MCP79 GPU [9400] + 0x086C, # MCP79 GPU [9300 / 730i] + 0x086D, # MCP79 GPU [9200] + 0x086E, # MCP79 GPU [9100M G] + 0x086F, # MCP79 GPU [8200M G] + 0x0870, # MCP79 GPU [9400M] + 0x0871, # MCP79 GPU [9200] + 0x0872, # MCP79 GPU [G102M] + 0x0873, # MCP79 GPU [G102M] + 0x0874, # MCP79 GPU [ION] + 0x0876, # MCP79 GPU [ION] + 0x087A, # MCP79 GPU [9400] + 0x087D, # MCP79 GPU [ION] + 0x087E, # MCP79 GPU [ION LE] + 0x087F, # MCP79 GPU [ION LE] # GT215 - "0CA0", # GT215 [GT 330] - "0CA2", # GT215 [GT 320] - "0CA3", # GT215 [GT 240] - "0CA4", # GT215 [GT 340] - "0CA5", # GT215 [GT 220] - "0CA7", # GT215 [GT 330] - "0CA9", # GT215 [GTS 250M] - "0CAC", # GT215 [GT 220] - "0CAF", # GT215 [GT 335M] - "0CB0", # GT215 [GTS 350M] - "0CB1", # GT215 [GTS 360M] - "0CBC", # GT215 [FX 1800M] + 0x0CA0, # GT215 [GT 330] + 0x0CA2, # GT215 [GT 320] + 0x0CA3, # GT215 [GT 240] + 0x0CA4, # GT215 [GT 340] + 0x0CA5, # GT215 [GT 220] + 0x0CA7, # GT215 [GT 330] + 0x0CA9, # GT215 [GTS 250M] + 0x0CAC, # GT215 [GT 220] + 0x0CAF, # GT215 [GT 335M] + 0x0CB0, # GT215 [GTS 350M] + 0x0CB1, # GT215 [GTS 360M] + 0x0CBC, # GT215 [FX 1800M] # GT216 - "0A20", # GT216 [GT 220] - "0A22", # GT216 [315] - "0A23", # GT216 [210] - "0A26", # GT216 [405] - "0A27", # GT216 [405] - "0A28", # GT216 [GT 230M] - "0A29", # GT216 [GT 330M] - "0A2A", # GT216 [GT 230M] - "0A2B", # GT216 [GT 330M] - "0A2C", # GT216 [NVS 5100M] - "0A2D", # GT216 [GT 320M] - "0A32", # GT216 [GT 415] - "0A34", # GT216 [GT 240M] - "0A35", # GT216 [GT 325M] - "0A38", # GT216 [400] - "0A3C", # GT216 [FX 880M] + 0x0A20, # GT216 [GT 220] + 0x0A22, # GT216 [315] + 0x0A23, # GT216 [210] + 0x0A26, # GT216 [405] + 0x0A27, # GT216 [405] + 0x0A28, # GT216 [GT 230M] + 0x0A29, # GT216 [GT 330M] + 0x0A2A, # GT216 [GT 230M] + 0x0A2B, # GT216 [GT 330M] + 0x0A2C, # GT216 [NVS 5100M] + 0x0A2D, # GT216 [GT 320M] + 0x0A32, # GT216 [GT 415] + 0x0A34, # GT216 [GT 240M] + 0x0A35, # GT216 [GT 325M] + 0x0A38, # GT216 [400] + 0x0A3C, # GT216 [FX 880M] # GT218 - "0A60", # GT218 [G210] - "0A62", # GT218 [205] - "0A63", # GT218 [310] - "0A64", # GT218 [ION] - "0A65", # GT218 [210] - "0A66", # GT218 [310] - "0A67", # GT218 [315] - "0A68", # GT218 [G105M] - "0A69", # GT218 [G105M] - "0A6A", # GT218 [NVS 2100M] - "0A6C", # GT218 [NVS 3100M] - "0A6E", # GT218 [305M] - "0A6F", # GT218 [ION] - "0A70", # GT218 [310M] - "0A71", # GT218 [305M] - "0A72", # GT218 [310M] - "0A73", # GT218 [305M] - "0A74", # GT218 [G210M] - "0A75", # GT218 [310M] - "0A76", # GT218 [ION] - "0A78", # GT218 [FX 380 LP] - "0A7A", # GT218 [315M] - "0A7C", # GT218 [FX 380M] - "10C0", # GT218 [9300 GS] - "10C3", # GT218 [8400GS] - "10C5", # GT218 [405] - "10D8", # GT218 [NVS 300] + 0x0A60, # GT218 [G210] + 0x0A62, # GT218 [205] + 0x0A63, # GT218 [310] + 0x0A64, # GT218 [ION] + 0x0A65, # GT218 [210] + 0x0A66, # GT218 [310] + 0x0A67, # GT218 [315] + 0x0A68, # GT218 [G105M] + 0x0A69, # GT218 [G105M] + 0x0A6A, # GT218 [NVS 2100M] + 0x0A6C, # GT218 [NVS 3100M] + 0x0A6E, # GT218 [305M] + 0x0A6F, # GT218 [ION] + 0x0A70, # GT218 [310M] + 0x0A71, # GT218 [305M] + 0x0A72, # GT218 [310M] + 0x0A73, # GT218 [305M] + 0x0A74, # GT218 [G210M] + 0x0A75, # GT218 [310M] + 0x0A76, # GT218 [ION] + 0x0A78, # GT218 [FX 380 LP] + 0x0A7A, # GT218 [315M] + 0x0A7C, # GT218 [FX 380M] + 0x10C0, # GT218 [9300 GS] + 0x10C3, # GT218 [8400GS] + 0x10C5, # GT218 [405] + 0x10D8, # GT218 [NVS 300] # MCP89 GPU - "08A0", # MCP89 GPU [320M] - "08A2", # MCP89 GPU [320M] - "08A3", # MCP89 GPU [320M] - "08A4", # MCP89 GPU [320M] + 0x08A0, # MCP89 GPU [320M] + 0x08A2, # MCP89 GPU [320M] + 0x08A3, # MCP89 GPU [320M] + 0x08A4, # MCP89 GPU [320M] ] fermi_ids = [ # GF100 - "06C0", # GF100 [GTX 480] - "06C4", # GF100 [GTX 465] - "06CA", # GF100 [GTX 480M] - "06CB", # GF100 [GTX 480] - "06CD", # GF100 [GTX 470] - "06D1", # GF100 [C2050 / C2070] - "06D2", # GF100 [M2070] - "06D8", # GF100 [6000] - "06D9", # GF100 [5000] - "06DA", # GF100 [5000M] - "06DC", # GF100 [6000] - "06DD", # GF100 [4000] - "06DE", # GF100 [T20] - "06DF", # GF100 [M2070-Q] + 0x06C0, # GF100 [GTX 480] + 0x06C4, # GF100 [GTX 465] + 0x06CA, # GF100 [GTX 480M] + 0x06CB, # GF100 [GTX 480] + 0x06CD, # GF100 [GTX 470] + 0x06D1, # GF100 [C2050 / C2070] + 0x06D2, # GF100 [M2070] + 0x06D8, # GF100 [6000] + 0x06D9, # GF100 [5000] + 0x06DA, # GF100 [5000M] + 0x06DC, # GF100 [6000] + 0x06DD, # GF100 [4000] + 0x06DE, # GF100 [T20] + 0x06DF, # GF100 [M2070-Q] # GF104 - "0E22", # GF104 [GTX 460] - "0E23", # GF104 [GTX 460 SE] - "0E24", # GF104 [GTX 460 OEM] - "0E30", # GF104 [GTX 470M] - "0E31", # GF104 [GTX 485M] - "0E3A", # GF104 [3000M] - "0E3B", # GF104 [4000M] + 0x0E22, # GF104 [GTX 460] + 0x0E23, # GF104 [GTX 460 SE] + 0x0E24, # GF104 [GTX 460 OEM] + 0x0E30, # GF104 [GTX 470M] + 0x0E31, # GF104 [GTX 485M] + 0x0E3A, # GF104 [3000M] + 0x0E3B, # GF104 [4000M] # GF114 - "1200", # GF114 [GTX 560 Ti] - "1201", # GF114 [GTX 560] - "1202", # GF114 [GTX 560 Ti OEM] - "1203", # GF114 [GTX 460 SE v2] - "1205", # GF114 [GTX 460 v2] - "1206", # GF114 [GTX 555] - "1207", # GF114 [GT 645 OEM] - "1208", # GF114 [GTX 560 SE] - "1210", # GF114 [GTX 570M] - "1211", # GF114 [GTX 580M] - "1212", # GF114 [GTX 675M] - "1213", # GF114 [GTX 670M] + 0x1200, # GF114 [GTX 560 Ti] + 0x1201, # GF114 [GTX 560] + 0x1202, # GF114 [GTX 560 Ti OEM] + 0x1203, # GF114 [GTX 460 SE v2] + 0x1205, # GF114 [GTX 460 v2] + 0x1206, # GF114 [GTX 555] + 0x1207, # GF114 [GT 645 OEM] + 0x1208, # GF114 [GTX 560 SE] + 0x1210, # GF114 [GTX 570M] + 0x1211, # GF114 [GTX 580M] + 0x1212, # GF114 [GTX 675M] + 0x1213, # GF114 [GTX 670M] # GF106 - "0DC0", # GF106 [GT 440] - "0DC4", # GF106 [GTS 450] - "0DC5", # GF106 [GTS 450] - "0DC6", # GF106 [GTS 450] - "0DCD", # GF106 [GT 555M] - "0DCE", # GF106 [GT 555M] - "0DD1", # GF106 [GTX 460M] - "0DD2", # GF106 [GT 445M] - "0DD3", # GF106 [GT 435M] - "0DD6", # GF106 [GT 550M] - "0DD8", # GF106 [2000] - "0DDA", # GF106 [2000M] + 0x0DC0, # GF106 [GT 440] + 0x0DC4, # GF106 [GTS 450] + 0x0DC5, # GF106 [GTS 450] + 0x0DC6, # GF106 [GTS 450] + 0x0DCD, # GF106 [GT 555M] + 0x0DCE, # GF106 [GT 555M] + 0x0DD1, # GF106 [GTX 460M] + 0x0DD2, # GF106 [GT 445M] + 0x0DD3, # GF106 [GT 435M] + 0x0DD6, # GF106 [GT 550M] + 0x0DD8, # GF106 [2000] + 0x0DDA, # GF106 [2000M] # GF116 - "1241", # GF116 [GT 545 OEM] - "1243", # GF116 [GT 545] - "1244", # GF116 [GTX 550 Ti] - "1245", # GF116 [GTS 450 Rev. 2] - "1246", # GF116 [GT 550M] - "1247", # GF116 [GT 635M] - "1248", # GF116 [GT 555M] - "1249", # GF116 [GTS 450 Rev. 3] - "124B", # GF116 [GT 640 OEM] - "124D", # GF116 [GT 555M] - "1251", # GF116 [GTX 560M] + 0x1241, # GF116 [GT 545 OEM] + 0x1243, # GF116 [GT 545] + 0x1244, # GF116 [GTX 550 Ti] + 0x1245, # GF116 [GTS 450 Rev. 2] + 0x1246, # GF116 [GT 550M] + 0x1247, # GF116 [GT 635M] + 0x1248, # GF116 [GT 555M] + 0x1249, # GF116 [GTS 450 Rev. 3] + 0x124B, # GF116 [GT 640 OEM] + 0x124D, # GF116 [GT 555M] + 0x1251, # GF116 [GTX 560M] # GF108 - "0DE0", # GF108 [GT 440] - "0DE1", # GF108 [GT 430] - "0DE2", # GF108 [GT 420] - "0DE3", # GF108 [GT 635M] - "0DE4", # GF108 [GT 520] - "0DE5", # GF108 [GT 530] - "0DE8", # GF108 [GT 620M] - "0DE9", # GF108 [GT 630M] - "0DEA", # GF108 [610M] - "0DEB", # GF108 [GT 555M] - "0DEC", # GF108 [GT 525M] - "0DED", # GF108 [GT 520M] - "0DEE", # GF108 [GT 415M] - "0DEF", # GF108 [NVS 5400M] - "0DF0", # GF108 [GT 425M] - "0DF1", # GF108 [GT 420M] - "0DF2", # GF108 [GT 435M] - "0DF3", # GF108 [GT 420M] - "0DF4", # GF108 [GT 540M] - "0DF5", # GF108 [GT 525M] - "0DF6", # GF108 [GT 550M] - "0DF7", # GF108 [GT 520M] - "0DF8", # GF108 [600] - "0DF9", # GF108 [500M] - "0DFA", # GF108 [1000M] - "0DFC", # GF108 [NVS 5200M] - "0F00", # GF108 [GT 630] - "0F01", # GF108 [GT 620] - "0F02", # GF108 [GT 730] + 0x0DE0, # GF108 [GT 440] + 0x0DE1, # GF108 [GT 430] + 0x0DE2, # GF108 [GT 420] + 0x0DE3, # GF108 [GT 635M] + 0x0DE4, # GF108 [GT 520] + 0x0DE5, # GF108 [GT 530] + 0x0DE8, # GF108 [GT 620M] + 0x0DE9, # GF108 [GT 630M] + 0x0DEA, # GF108 [610M] + 0x0DEB, # GF108 [GT 555M] + 0x0DEC, # GF108 [GT 525M] + 0x0DED, # GF108 [GT 520M] + 0x0DEE, # GF108 [GT 415M] + 0x0DEF, # GF108 [NVS 5400M] + 0x0DF0, # GF108 [GT 425M] + 0x0DF1, # GF108 [GT 420M] + 0x0DF2, # GF108 [GT 435M] + 0x0DF3, # GF108 [GT 420M] + 0x0DF4, # GF108 [GT 540M] + 0x0DF5, # GF108 [GT 525M] + 0x0DF6, # GF108 [GT 550M] + 0x0DF7, # GF108 [GT 520M] + 0x0DF8, # GF108 [600] + 0x0DF9, # GF108 [500M] + 0x0DFA, # GF108 [1000M] + 0x0DFC, # GF108 [NVS 5200M] + 0x0F00, # GF108 [GT 630] + 0x0F01, # GF108 [GT 620] + 0x0F02, # GF108 [GT 730] # GF110 - "1080", # GF110 [GTX 580] - "1081", # GF110 [GTX 570] - "1082", # GF110 [GTX 560 Ti] - "1084", # GF110 [GTX 560] - "1086", # GF110 [GTX 570] - "1087", # GF110 [GTX 560 Ti] - "1088", # GF110 [GTX 590] - "1089", # GF110 [GTX 580] - "108B", # GF110 [GTX 580] - "1091", # GF110 [M2090] - "1096", # GF110GL [Tesla C2050 / C2075] - "109A", # GF110 [5010M] - "109B", # GF110 [7000] + 0x1080, # GF110 [GTX 580] + 0x1081, # GF110 [GTX 570] + 0x1082, # GF110 [GTX 560 Ti] + 0x1084, # GF110 [GTX 560] + 0x1086, # GF110 [GTX 570] + 0x1087, # GF110 [GTX 560 Ti] + 0x1088, # GF110 [GTX 590] + 0x1089, # GF110 [GTX 580] + 0x108B, # GF110 [GTX 580] + 0x1091, # GF110 [M2090] + 0x1096, # GF110GL [Tesla C2050 / C2075] + 0x109A, # GF110 [5010M] + 0x109B, # GF110 [7000] # GF119 - "1040", # GF119 [GT 520] - "1042", # GF119 [510] - "1048", # GF119 [605] - "1049", # GF119 [GT 620] - "104A", # GF119 [GT 610] - "104B", # GF119 [GT 625 OEM] - "104C", # GF119 [GT 705] - "1050", # GF119 [GT 520M] - "1051", # GF119 [GT 520MX] - "1052", # GF119 [GT 520M] - "1054", # GF119 [410M] - "1055", # GF119 [410M] - "1056", # GF119 [NVS 4200M] - "1057", # GF119 [NVS 4200M] - "1058", # GF119 [610M] - "1059", # GF119 [610M] - "105A", # GF119 [610M] - "105B", # GF119M [705M] - "107C", # GF119 [NVS 315] - "107D", # GF119 [NVS 310] + 0x1040, # GF119 [GT 520] + 0x1042, # GF119 [510] + 0x1048, # GF119 [605] + 0x1049, # GF119 [GT 620] + 0x104A, # GF119 [GT 610] + 0x104B, # GF119 [GT 625 OEM] + 0x104C, # GF119 [GT 705] + 0x1050, # GF119 [GT 520M] + 0x1051, # GF119 [GT 520MX] + 0x1052, # GF119 [GT 520M] + 0x1054, # GF119 [410M] + 0x1055, # GF119 [410M] + 0x1056, # GF119 [NVS 4200M] + 0x1057, # GF119 [NVS 4200M] + 0x1058, # GF119 [610M] + 0x1059, # GF119 [610M] + 0x105A, # GF119 [610M] + 0x105B, # GF119M [705M] + 0x107C, # GF119 [NVS 315] + 0x107D, # GF119 [NVS 310] # GF117 - "1140", # GF117 [GT 620M] + 0x1140, # GF117 [GT 620M] ] kepler_ids = [ # GK104 - "1180", # GK104 [GTX 680] - "1183", # GK104 [GTX 660 Ti] - "1184", # GK104 [GTX 770] - "1185", # GK104 [GTX 660] - "1186", # GK104 [GTX 660 Ti] - "1187", # GK104 [GTX 760] - "1188", # GK104 [GTX 690] - "1189", # GK104 [GTX 670] - "118E", # GK104 [GTX 760 OEM] - "118F", # GK104GL [Tesla K10] - "1198", # GTX 880M - "1199", # GK104 [GTX 870M] - "119A", # GTX 860M - "119D", # GK104M [GTX 775M Mac Edition] - "119E", # GTX 780M - "119F", # GK104 [GTX 780M] - "11A0", # GK104 [GTX 680M] - "11A1", # GK104 [GTX 670MX] - "11A2", # GK104 [GTX 675MX] - "11A3", # GK104 [GTX 680MX] - "11A7", # GK104 [GTX 675MX] - "11A9", # GTX 870M - "11B4", # GK104GL [Quadro K4200] - "11B6", # Quadro K3100M - "11B7", # Quadro K4100M - "11B8", # Quadro K5100M - "11BA", # GK104 [K5000] - "11BC", # GK104 [K5000M] - "11BD", # GK104 [K4000M] - "11BE", # GK104 [K3000M] - "11BF", # GK104 [GRID K2] + 0x1180, # GK104 [GTX 680] + 0x1183, # GK104 [GTX 660 Ti] + 0x1184, # GK104 [GTX 770] + 0x1185, # GK104 [GTX 660] + 0x1186, # GK104 [GTX 660 Ti] + 0x1187, # GK104 [GTX 760] + 0x1188, # GK104 [GTX 690] + 0x1189, # GK104 [GTX 670] + 0x118E, # GK104 [GTX 760 OEM] + 0x118F, # GK104GL [Tesla K10] + 0x1198, # GTX 880M + 0x1199, # GK104 [GTX 870M] + 0x119A, # GTX 860M + 0x119D, # GK104M [GTX 775M Mac Edition] + 0x119E, # GTX 780M + 0x119F, # GK104 [GTX 780M] + 0x11A0, # GK104 [GTX 680M] + 0x11A1, # GK104 [GTX 670MX] + 0x11A2, # GK104 [GTX 675MX] + 0x11A3, # GK104 [GTX 680MX] + 0x11A7, # GK104 [GTX 675MX] + 0x11A9, # GTX 870M + 0x11B4, # GK104GL [Quadro K4200] + 0x11B6, # Quadro K3100M + 0x11B7, # Quadro K4100M + 0x11B8, # Quadro K5100M + 0x11BA, # GK104 [K5000] + 0x11BC, # GK104 [K5000M] + 0x11BD, # GK104 [K4000M] + 0x11BE, # GK104 [K3000M] + 0x11BF, # GK104 [GRID K2] # GK106 - "11C0", # GK106 [GTX 660] - "11C2", # GK106 [GTX 650 Ti BOOST] - "11C6", # GK106 [GTX 650 Ti] - "11E0", # GK106 [GTX 770M] - "11E1", # GTX 765M - "11E2", # GTX 765M - "11FA", # GK106 [K4000] - "11FC", # Quadro K2100M + 0x11C0, # GK106 [GTX 660] + 0x11C2, # GK106 [GTX 650 Ti BOOST] + 0x11C6, # GK106 [GTX 650 Ti] + 0x11E0, # GK106 [GTX 770M] + 0x11E1, # GTX 765M + 0x11E2, # GTX 765M + 0x11FA, # GK106 [K4000] + 0x11FC, # Quadro K2100M # GK107 - "0FC0", # GK107 [GT 640] - "0FC1", # GK107 [GT 640] - "0FC2", # GK107 [GT 630] - "0FC6", # GK107 [GTX 650] - "0FC8", # GK107 [GT 740] - "0FCD", # GK107M [GT 755M] - "0FD1", # GK107 [GT 650M] - "0FD2", # GK107 [GT 640M] - "0FD3", # GK107 [GT 640M LE] - "0FD4", # GK107 [GTX 660M] - "0FD5", # GK107 [GT 650M] - "0FD8", # GK107 [GT 640M] - "0FD9", # GK107 [GT 645M] - "0FDF", # GK107M [ GT 740M] - "0FE0", # GK107 [GTX 660M] - "0FE1", # GK107M [GT 730M] - "0FE3", # GK107M [GT 745M] - "0FE4", # GK107M [GT 750M] - "0FE9", # GK107 [GT 750M Mac Edition] - "0FEA", # GK107M [GT 755M Mac Edition] - "0FEE", # GK107M [810M] - "0FF2", # GK107GL [GRID K1] - "0FF3", # GK107GL [Quadro K420] - "0FF6", # Quadro K1100M - "0FF9", # GK107 [K2000D] - "0FFA", # GK107 [K600] - "0FFB", # GK107 [K2000M] - "0FFC", # GK107 [K1000M] - "0FFD", # GK107 [NVS 510] - "0FFE", # GK107 [K2000] - "0FFF", # GK107 [410] + 0x0FC0, # GK107 [GT 640] + 0x0FC1, # GK107 [GT 640] + 0x0FC2, # GK107 [GT 630] + 0x0FC6, # GK107 [GTX 650] + 0x0FC8, # GK107 [GT 740] + 0x0FCD, # GK107M [GT 755M] + 0x0FD1, # GK107 [GT 650M] + 0x0FD2, # GK107 [GT 640M] + 0x0FD3, # GK107 [GT 640M LE] + 0x0FD4, # GK107 [GTX 660M] + 0x0FD5, # GK107 [GT 650M] + 0x0FD8, # GK107 [GT 640M] + 0x0FD9, # GK107 [GT 645M] + 0x0FDF, # GK107M [ GT 740M] + 0x0FE0, # GK107 [GTX 660M] + 0x0FE1, # GK107M [GT 730M] + 0x0FE3, # GK107M [GT 745M] + 0x0FE4, # GK107M [GT 750M] + 0x0FE9, # GK107 [GT 750M Mac Edition] + 0x0FEA, # GK107M [GT 755M Mac Edition] + 0x0FEE, # GK107M [810M] + 0x0FF2, # GK107GL [GRID K1] + 0x0FF3, # GK107GL [Quadro K420] + 0x0FF6, # Quadro K1100M + 0x0FF9, # GK107 [K2000D] + 0x0FFA, # GK107 [K600] + 0x0FFB, # GK107 [K2000M] + 0x0FFC, # GK107 [K1000M] + 0x0FFD, # GK107 [NVS 510] + 0x0FFE, # GK107 [K2000] + 0x0FFF, # GK107 [410] # GK110 - "1001", # GK110B [GTX TITAN Z] - "1003", # GK110 [GTX Titan LE] - "1004", # GK110 [GTX 780] - "1005", # GK110 [GTX Titan] - "1007", # GK110 [GTX 780 Rev. 2] - "100A", # GK110B [GTX 780 Ti] - "100C", # GK110B [GTX TITAN Black] - "101F", # GK110 [TEslA K20] - "1020", # GK110 [TEslA K2] - "1021", # GK110 [TEslA K2m] - "1022", # GK110 [TEslA K20C] - "1023", # GK110BGL [Tesla K40m] - "1024", # GK180GL [Tesla K40c] - "1026", # GK110 [TEslA K20s] - "1028", # GK110 [TEslA K20m] - "102D", # GK210GL [Tesla K80] - "103C", # GK110GL [Quadro K5200] + 0x1001, # GK110B [GTX TITAN Z] + 0x1003, # GK110 [GTX Titan LE] + 0x1004, # GK110 [GTX 780] + 0x1005, # GK110 [GTX Titan] + 0x1007, # GK110 [GTX 780 Rev. 2] + 0x100A, # GK110B [GTX 780 Ti] + 0x100C, # GK110B [GTX TITAN Black] + 0x101F, # GK110 [TEslA K20] + 0x1020, # GK110 [TEslA K2] + 0x1021, # GK110 [TEslA K2m] + 0x1022, # GK110 [TEslA K20C] + 0x1023, # GK110BGL [Tesla K40m] + 0x1024, # GK180GL [Tesla K40c] + 0x1026, # GK110 [TEslA K20s] + 0x1028, # GK110 [TEslA K20m] + 0x102D, # GK210GL [Tesla K80] + 0x103C, # GK110GL [Quadro K5200] # GK208 - "1280", # GK208 [GT 635] - "1281", # GK208 [GT 710] - "1282", # GK208 [GT 640 REv. 2] - "1284", # GK208 [GT 630 REv. 2] - "1286", # GK208 [GT 720] - "1287", # GK208B [GT 730] - "1288", # GK208B [GT 720] - "1289", # GK208 [GT 710] - "128B", # GK208B [GT 710] - "1290", # GK208 [GT 730M] - "1291", # GK208 [GT 735M] - "1292", # GK208 [GT 740M] - "1293", # GK208 [GT 730M] - "1294", # GK208 [GT 740M] - "1295", # GK208 [710M] - "1296", # GK208M [825M] - "1298", # GK208M [GT 720M] - "1299", # GK208BM [920M] - "129A", # GK208BM [910M] - "12B9", # GK208 [K610M] - "12BA", # GK208 [K510M] + 0x1280, # GK208 [GT 635] + 0x1281, # GK208 [GT 710] + 0x1282, # GK208 [GT 640 REv. 2] + 0x1284, # GK208 [GT 630 REv. 2] + 0x1286, # GK208 [GT 720] + 0x1287, # GK208B [GT 730] + 0x1288, # GK208B [GT 720] + 0x1289, # GK208 [GT 710] + 0x128B, # GK208B [GT 710] + 0x1290, # GK208 [GT 730M] + 0x1291, # GK208 [GT 735M] + 0x1292, # GK208 [GT 740M] + 0x1293, # GK208 [GT 730M] + 0x1294, # GK208 [GT 740M] + 0x1295, # GK208 [710M] + 0x1296, # GK208M [825M] + 0x1298, # GK208M [GT 720M] + 0x1299, # GK208BM [920M] + 0x129A, # GK208BM [910M] + 0x12B9, # GK208 [K610M] + 0x12BA, # GK208 [K510M] ] + class amd_ids: legacy_gcn_ids = [ # AMDRadeonX4000 # AMDBonaireGraphicsAccelerator - "6640", - "6641", - "6646", - "6647", - "6650", - "6651", - "665C", - "665D", + 0x6640, + 0x6641, + 0x6646, + 0x6647, + 0x6650, + 0x6651, + 0x665C, + 0x665D, # AMDFijiGraphicsAccelerator - "7300", - "730F", + 0x7300, + 0x730F, # AMDHawaiiGraphicsAccelerator - "67B0", + 0x67B0, # AMDPitcairnGraphicsAccelerator - "6800", - "6801", - "6806", - "6808", - "6810", - "6818", - "6819", + 0x6800, + 0x6801, + 0x6806, + 0x6808, + 0x6810, + 0x6818, + 0x6819, # AMDTahitiGraphicsAccelerator - "6790", - "6798", - "679A", - "679E", - "6780", + 0x6790, + 0x6798, + 0x679A, + 0x679E, + 0x6780, # AMDTongaGraphicsAccelerator - "6920", - "6921", - "6930", - "6938", - "6939", + 0x6920, + 0x6921, + 0x6930, + 0x6938, + 0x6939, # AMDVerdeGraphicsAccelerator - "6820", - "6821", - "6823", - "6825", - "6827", - "682B", - "682D", - "682F", - "6835", - "6839", - "683B", - "683D", - "683F", + 0x6820, + 0x6821, + 0x6823, + 0x6825, + 0x6827, + 0x682B, + 0x682D, + 0x682F, + 0x6835, + 0x6839, + 0x683B, + 0x683D, + 0x683F, ] polaris_ids = [ # AMDRadeonX4000 # AMDBaffinGraphicsAccelerator - "67E0", - "67E3", - "67E8", - "67EB", - "67EF", - "67FF", - "67E1", - "67E7", - "67E9", + 0x67E0, + 0x67E3, + 0x67E8, + 0x67EB, + 0x67EF, + 0x67FF, + 0x67E1, + 0x67E7, + 0x67E9, # AMDEllesmereGraphicsAccelerator - "67C0", - "67C1", - "67C2", - "67C4", - "67C7", - "67DF", - "67D0", - "67C8", - "67C9", - "67CA", - "67CC", - "67CF", + 0x67C0, + 0x67C1, + 0x67C2, + 0x67C4, + 0x67C7, + 0x67DF, + 0x67D0, + 0x67C8, + 0x67C9, + 0x67CA, + 0x67CC, + 0x67CF, ] vega_ids = [ # AMDRadeonX5000 # AMDVega10GraphicsAccelerator - "6860", - "6861", - "6862", - "6863", - "6864", - "6867", - "6868", - "6869", - "686A", - "686B", - "686C", - "686D", - "686E", - "686F", - "687F", + 0x6860, + 0x6861, + 0x6862, + 0x6863, + 0x6864, + 0x6867, + 0x6868, + 0x6869, + 0x686A, + 0x686B, + 0x686C, + 0x686D, + 0x686E, + 0x686F, + 0x687F, # AMDVega12GraphicsAccelerator - "69A0", - "69A1", - "69A2", - "69A3", - "69AF", + 0x69A0, + 0x69A1, + 0x69A2, + 0x69A3, + 0x69AF, # AMDVega20GraphicsAccelerator - "66A0", - "66A1", - "66A2", - "66A3", - "66A7", - "66AF", + 0x66A0, + 0x66A1, + 0x66A2, + 0x66A3, + 0x66A7, + 0x66AF, ] navi_ids = [ # AMDRadeonX6000 # AMDNavi10GraphicsAccelerator - "7310", - "7312", - "7318", - "7319", - "731A", - "731B", - "731F", + 0x7310, + 0x7312, + 0x7318, + 0x7319, + 0x731A, + 0x731B, + 0x731F, # AMDNavi12GraphicsAccelerator - "7360", + 0x7360, # AMDNavi14GraphicsAccelerator - "7340", - "7341", - "7343", - "7347", - "734F", + 0x7340, + 0x7341, + 0x7343, + 0x7347, + 0x734F, # AMDNavi21GraphicsAccelerator - "73A2", - "73AB", - "73BF", + 0x73A2, + 0x73AB, + 0x73BF, ] terascale_1_ids = [ - "9400", - "9401", - "9402", - "9403", - "9581", - "9583", - "9588", - "94C8", - "94C9", - "9500", - "9501", - "9505", - "9507", - "9504", - "9506", - "9598", - "9488", - "9599", - "9591", - "9593", - "9440", - "9442", - "944A", - "945A", - "9490", - "949E", - "9480", - "9540", - "9541", - "954E", - "954F", - "9552", - "9553", - "94A0", + 0x9400, + 0x9401, + 0x9402, + 0x9403, + 0x9581, + 0x9583, + 0x9588, + 0x94C8, + 0x94C9, + 0x9500, + 0x9501, + 0x9505, + 0x9507, + 0x9504, + 0x9506, + 0x9598, + 0x9488, + 0x9599, + 0x9591, + 0x9593, + 0x9440, + 0x9442, + 0x944A, + 0x945A, + 0x9490, + 0x949E, + 0x9480, + 0x9540, + 0x9541, + 0x954E, + 0x954F, + 0x9552, + 0x9553, + 0x94A0, ] terascale_2_ids = [ - "6738", - "6739", - "6720", - "6722", - "6768", - "6770", - "6779", - "6760", - "6761", - "68E0", - "6898", - "6899", - "68B8", - "68B0", - "68B1", - "68A0", - "68A1", - "6840", - "6841", - "68D8", - "68C0", - "68C1", - "68D9", - "6750", - "6758", - "6759", - "6740", - "6741", - "6745", + 0x6738, + 0x6739, + 0x6720, + 0x6722, + 0x6768, + 0x6770, + 0x6779, + 0x6760, + 0x6761, + 0x68E0, + 0x6898, + 0x6899, + 0x68B8, + 0x68B0, + 0x68B1, + 0x68A0, + 0x68A1, + 0x6840, + 0x6841, + 0x68D8, + 0x68C0, + 0x68C1, + 0x68D9, + 0x6750, + 0x6758, + 0x6759, + 0x6740, + 0x6741, + 0x6745, ] + class intel_ids: iron_ids = [ # AppleIntelHDGraphics IDs - "0044", - "0046", + 0x0044, + 0x0046, ] sandy_ids = [ # AppleIntelHD3000Graphics IDs # AppleIntelSNBGraphicsFB IDs - "0106", - "0601", - "0116", - "0102", - "0126", + 0x0106, + 0x0601, + 0x0116, + 0x0102, + 0x0126, ] ivy_ids = [ # AppleIntelHD4000Graphics IDs # AppleIntelFramebufferCapri IDs - "0152", - "0156", - "0162", - "0166", + 0x0152, + 0x0156, + 0x0162, + 0x0166, ] + class broadcom_ids: - BCM4360Wifi = [ + AirPortBrcmNIC = [ # AirPortBrcmNIC IDs - "43BA", # BCM43602 - "43A3", # BCM4350 - "43A0", # BCM4360 + 0x43BA, # BCM43602 + 0x43A3, # BCM4350 + 0x43A0, # BCM4360 ] - BCM94331Wifi = [ + AirPortBrcm4360 = [ # AirPortBrcm4360 IDs (removed duplicates for 4360 class cards) - "4331", # BCM94331 - "4353", # BCM943224 + 0x4331, # BCM94331 + 0x4353, # BCM943224 ] - BCM94322Wifi = [ + AirPortBrcm4331 = [ # AirPortBrcm4331 IDs (removed duplicates for 4331 class cards) - "432B", # BCM94322 + 0x432B, # BCM94322 ] - BCM94328Wifi = [ + AppleAirPortBrcm43224 = [ # AppleAirPortBrcm43224 IDs - "4311", # BCM4311 - never used by Apple - "4312", # BCM4311 - never used by Apple - "4313", # BCM4311 - never used by Apple - "4318", # BCM4318 - never used by Apple - "4319", # BCM4318 - never used by Apple - "431A", # Unknown - never used by Apple - "4320", # BCM4306 - never used by Apple - "4324", # BCM4309 - never used by Apple - "4325", # BCM4306 - never used by Apple - "4328", # BCM4328 - "432C", # BCM4322 - never used by Apple - "432D", # BCM4322 - never used by Apple + 0x4311, # BCM4311 - never used by Apple + 0x4312, # BCM4311 - never used by Apple + 0x4313, # BCM4311 - never used by Apple + 0x4318, # BCM4318 - never used by Apple + 0x4319, # BCM4318 - never used by Apple + 0x431A, # Unknown - never used by Apple + 0x4320, # BCM4306 - never used by Apple + 0x4324, # BCM4309 - never used by Apple + 0x4325, # BCM4306 - never used by Apple + 0x4328, # BCM4328 + 0x432C, # BCM4322 - never used by Apple + 0x432D, # BCM4322 - never used by Apple ] + class atheros_ids: AtherosWifi = [ # AirPortAtheros40 IDs - "0030", # AR93xx - "002A", # AR928X - "001C", # AR242x / AR542x - "0023", # AR5416 - never used by Apple - "0024", # AR5418 + 0x0030, # AR93xx + 0x002A, # AR928X + 0x001C, # AR242x / AR542x + 0x0023, # AR5416 - never used by Apple + 0x0024, # AR5418 ] diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index 56f5f39f6..1a5ff3de8 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -6,14 +6,12 @@ # - Work-around battery throttling on laptops with no battery (IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources/) import os -import plistlib import shutil import subprocess import zipfile from pathlib import Path -from typing import Any -from Resources import Constants, DeviceProbe, ModelArray, SysPatchArray, PCIIDArray, Utilities +from Resources import Constants, device_probe, ModelArray, SysPatchArray, Utilities class PatchSysVolume: @@ -48,14 +46,14 @@ class PatchSysVolume: self.mount_lauchd = f"{self.mount_location}/System/Library/LaunchDaemons" self.mount_private_frameworks = f"{self.mount_location}/System/Library/PrivateFrameworks" - def elevated(self, *args, **kwargs) -> subprocess.CompletedProcess([Any], returncode=0): + def elevated(self, *args, **kwargs) -> subprocess.CompletedProcess: if os.getuid() == 0: return subprocess.run(*args, **kwargs) else: return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs) def find_mount_root_vol(self, patch): - self.root_mount_path = Utilities.get_disk_path() + self.root_mount_path = Utilities.get_disk_path() if self.root_mount_path.startswith("disk"): print(f"- Found Root Volume at: {self.root_mount_path}") if Path(self.mount_extensions).exists(): @@ -124,7 +122,6 @@ class PatchSysVolume: print("\nPlease reboot the machine for patches to take effect") input("Press [ENTER] to continue") - def unmount_drive(self): print("- Unmounting Root Volume (Don't worry if this fails)") self.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() @@ -342,43 +339,39 @@ class PatchSysVolume: print("- Download failed, please verify the below link works:") print(f"{self.constants.url_apple_binaries}{self.constants.payload_version}") - def detect_gpus(self): - igpu_vendor, igpu_device, igpu_acpi = DeviceProbe.pci_probe().gpu_probe("IGPU") - dgpu_vendor, dgpu_device, dgpu_acpi = DeviceProbe.pci_probe().gpu_probe("GFX0") - if dgpu_vendor: - print(f"- Found GFX0: {dgpu_vendor}:{dgpu_device}") - if dgpu_vendor == self.constants.pci_nvidia: - if dgpu_device in PCIIDArray.nvidia_ids().tesla_ids or dgpu_device in PCIIDArray.nvidia_ids().fermi_ids: - if self.constants.detected_os > self.constants.catalina: - self.nvidia_legacy = True - self.amfi_must_disable = True - elif dgpu_vendor == self.constants.pci_amd_ati: - if dgpu_device in PCIIDArray.amd_ids().terascale_1_ids: - if self.constants.detected_os > self.constants.catalina: - self.amd_ts1 = True - self.amfi_must_disable = True - # TODO: Enable TS2 support - elif dgpu_device in PCIIDArray.amd_ids().terascale_2_ids: - # Requires manual permission from user to avoid medical issues - if self.constants.detected_os > self.constants.catalina and self.constants.terscale_2_patch is True: - self.amd_ts2 = True - self.amfi_must_disable = True - if igpu_vendor: - print(f"- Found IGPU: {igpu_vendor}:{igpu_device}") - if igpu_vendor == self.constants.pci_intel: - if igpu_device in PCIIDArray.intel_ids().iron_ids: - if self.constants.detected_os > self.constants.catalina: - self.iron_gpu = True - self.amfi_must_disable = True - elif igpu_device in PCIIDArray.intel_ids().sandy_ids: - if self.constants.detected_os > self.constants.catalina: - self.sandy_gpu = True - self.amfi_must_disable = True - elif igpu_device in PCIIDArray.intel_ids().ivy_ids: - if self.constants.detected_os > self.constants.big_sur: - self.ivy_gpu = True - elif igpu_vendor == self.constants.pci_nvidia: + dgpu = self.constants.computer.dgpu + igpu = self.constants.computer.igpu + if dgpu: + print(f"- Found GFX0: {Utilities.friendly_hex(dgpu.vendor_id)}:{Utilities.friendly_hex(dgpu.device_id)}") + if dgpu.arch in [device_probe.NVIDIA.Archs.Tesla, device_probe.NVIDIA.Archs.Fermi]: + if self.constants.detected_os > self.constants.catalina: + self.nvidia_legacy = True + self.amfi_must_disable = True + elif dgpu.arch == device_probe.AMD.Archs.TeraScale_1: + if self.constants.detected_os > self.constants.catalina: + self.amd_ts1 = True + self.amfi_must_disable = True + # TODO: Enable TS2 support + elif dgpu.arch == device_probe.AMD.Archs.TeraScale_2: + # Requires manual permission from user to avoid medical issues + if self.constants.detected_os > self.constants.catalina and self.constants.terascale_2_patch is True: + self.amd_ts2 = True + self.amfi_must_disable = True + if igpu and igpu.class_code != 0xFFFFFF: + print(f"- Found IGPU: {Utilities.friendly_hex(igpu.vendor_id)}:{Utilities.friendly_hex(igpu.device_id)}") + if igpu.arch == device_probe.Intel.Archs.Iron_Lake: + if self.constants.detected_os > self.constants.catalina: + self.iron_gpu = True + self.amfi_must_disable = True + elif igpu.arch == device_probe.Intel.Archs.Sandy_Bridge: + if self.constants.detected_os > self.constants.catalina: + self.sandy_gpu = True + self.amfi_must_disable = True + elif igpu.arch == device_probe.Intel.Archs.Ivy_Bridge: + if self.constants.detected_os > self.constants.big_sur: + self.ivy_gpu = True + elif isinstance(igpu, device_probe.NVIDIA): if self.constants.detected_os > self.constants.catalina: self.nvidia_legacy = True self.amfi_must_disable = True @@ -412,58 +405,46 @@ class PatchSysVolume: if self.legacy_audio is True: print("- Add legacy Audio Control") - if self.nvidia_legacy is False and \ - self.amd_ts1 is False and \ - self.amd_ts2 is False and \ - self.iron_gpu is False and \ - self.sandy_gpu is False and \ - self.ivy_gpu is False and \ - self.brightness_legacy is False and \ - self.legacy_audio is False: - self.no_patch = True - else: - self.no_patch = False + self.no_patch = not any( + [ + self.nvidia_legacy, + self.amd_ts1, + self.amd_ts2, + self.iron_gpu, + self.sandy_gpu, + self.ivy_gpu, + self.brightness_legacy, + self.legacy_audio, + ] + ) def verify_patch_allowed(self): self.sip_enabled, self.sbm_enabled, self.amfi_enabled, self.fv_enabled = Utilities.patching_status() if self.sip_enabled is True: - print("\nCannot patch!!! Please disable SIP!!!") - print("Disable SIP in Patcher Settings and Rebuild OpenCore") - print("Ensure the following bits are set for csr-active-config:\n") - if self.constants.detected_os > self.constants.catalina: - sip = self.constants.root_patch_sip_big_sur - else: - sip = self.constants.root_patch_sip_mojave - print("\n".join(sip)) - print("For Hackintoshes, please set csr-active-config to 030A0000 (0xA03)") + print("\nCannot patch! Please disable System Integrity Protection (SIP).") + print("Disable SIP in Patcher Settings and Rebuild OpenCore\n") + print("Ensure the following bits are set for csr-active-config:") + print("\n".join(self.constants.root_patch_sip_big_sur if self.constants.detected_os > self.constants.catalina else self.constants.root_patch_sip_mojave)) + print("For Hackintoshes, please set csr-active-config to '030A0000' (0xA03)") print("For non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS") + if self.sbm_enabled is True: - print("\nCannot patch!!! Please disable SecureBootModel!!!") + print("\nCannot patch! Please disable Apple Secure Boot.") print("Disable SecureBootModel in Patcher Settings and Rebuild OpenCore") print("For Hackintoshes, set SecureBootModel to Disabled") + if self.fv_enabled is True: - print("\nCannot patch!!! Please disable FileVault!!!") + print("\nCannot patch! Please disable FileVault.") print("Go to System Preferences -> Security and disable FileVault") if self.amfi_enabled is True and self.amfi_must_disable is True: - print("\nCannot patch!!! Please disable AMFI!!!") + print("\nCannot patch! Please disable AMFI.") print("For Hackintoshes, please add amfi_get_out_of_my_way=1 to boot-args") - if self.amfi_must_disable is True: - if self.sip_enabled is True or \ - self.sbm_enabled is True or \ - self.amfi_enabled is True or \ - self.fv_enabled is True: - return False - else: - return True + if any([self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.amfi_enabled if self.amfi_must_disable else False]): + return False else: - if self.sip_enabled is True or \ - self.sbm_enabled is True or \ - self.fv_enabled is True: - return False - else: - return True + return True # Entry Function def start_patch(self): @@ -494,4 +475,3 @@ class PatchSysVolume: if self.verify_patch_allowed() is True: self.find_mount_root_vol(False) input("\nPress [ENTER] to return to the main menu") - diff --git a/Resources/SysPatchArray.py b/Resources/SysPatchArray.py index 557e35607..3eea61ead 100644 --- a/Resources/SysPatchArray.py +++ b/Resources/SysPatchArray.py @@ -129,8 +129,8 @@ AddAMDBrightness = [ "AMDLegacySupport.kext", "AMDRadeonVADriver.bundle", "AMDRadeonVADriver2.bundle", - #"AMDRadeonX3000.kext", - #"AMDRadeonX3000GLDriver.bundle", + # "AMDRadeonX3000.kext", + # "AMDRadeonX3000GLDriver.bundle", "AMDShared.bundle", "ATIRadeonX2000.kext", "ATIRadeonX2000GA.plugin", @@ -169,14 +169,9 @@ AddIntelGen3Accel = [ "AppleIntelGraphicsShared.bundle", ] -AddGeneralAccel = [ - "IOAcceleratorFamily2.kext", - "IOSurface.kext" -] +AddGeneralAccel = ["IOAcceleratorFamily2.kext", "IOSurface.kext"] -DeleteBrightness = [ - "AppleGraphicsControl.kext/Contents/PlugIns/AGDCBacklightControl.kext" -] +DeleteBrightness = ["AppleGraphicsControl.kext/Contents/PlugIns/AGDCBacklightControl.kext"] AddBrightness = [ "AppleBacklight.kext", diff --git a/Resources/Utilities.py b/Resources/Utilities.py index 3102a1c72..032ca2f2c 100644 --- a/Resources/Utilities.py +++ b/Resources/Utilities.py @@ -3,11 +3,13 @@ from __future__ import print_function import os import math +from pathlib import Path import plistlib import subprocess from Resources import Constants + def hexswap(input_hex: str): hex_pairs = [input_hex[i : i + 2] for i in range(0, len(input_hex), 2)] hex_rev = hex_pairs[::-1] @@ -25,12 +27,17 @@ def header(lines): print("#" * total_length) +RECOVERY_STATUS = None + + def check_recovery(): - root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - if root_partition_info["VolumeName"] == "macOS Base System" and root_partition_info["FilesystemType"] == "apfs" and root_partition_info["BusProtocol"] == "Disk Image": - return True - else: - return False + global RECOVERY_STATUS # pylint: disable=global-statement # We need to cache the result + + if RECOVERY_STATUS is None: + RECOVERY_STATUS = Path("/System/Library/BaseSystem").exists() + + return RECOVERY_STATUS + def get_disk_path(): root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) @@ -38,39 +45,40 @@ def get_disk_path(): root_mount_path = root_mount_path[:-2] if root_mount_path.count("s") > 1 else root_mount_path return root_mount_path + def csr_decode(csr_active_config): if csr_active_config is None: csr_active_config = b"\x00\x00\x00\x00" sip_int = int.from_bytes(csr_active_config, byteorder="little") i = 0 - for current_sip_bit in Constants.Constants().csr_values: + for current_sip_bit in Constants.Constants.csr_values: if sip_int & (1 << i): - Constants.Constants().csr_values[current_sip_bit] = True + Constants.Constants.csr_values[current_sip_bit] = True i = i + 1 # Can be adjusted to whatever OS needs patching - sip_needs_change = all( - Constants.Constants().csr_values[i] - for i in Constants.Constants().root_patch_sip_big_sur - ) + sip_needs_change = all(Constants.Constants.csr_values[i] for i in Constants.Constants.root_patch_sip_big_sur) if sip_needs_change is True: return False else: return True +def friendly_hex(integer: int): + return "{:02X}".format(integer) + def patching_status(): # Detection for Root Patching sip_enabled = True # System Integrity Protection sbm_enabled = True # Secure Boot Status (SecureBootModel) - amfi_enabled = True # Apple Mobile File Integrity - fv_enabled = True # FileVault + amfi_enabled = True # Apple Mobile File Integrity + fv_enabled = True # FileVault amfi_1 = "amfi_get_out_of_my_way=0x1" amfi_2 = "amfi_get_out_of_my_way=1" - if get_nvram("boot-args", decode=False) and (amfi_1 in get_nvram("boot-args", decode=False) or amfi_2 in get_nvram("boot-args", decode=False)): + if get_nvram("boot-args", decode=False) and amfi_1 in get_nvram("boot-args", decode=False) or amfi_2 in get_nvram("boot-args", decode=False): amfi_enabled = False - if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in Constants.Constants().sbm_values: + if get_nvram("HardwareModel", "94B73556-2197-4702-82A8-3E1337DAFBFB", decode=False) not in Constants.Constants.sbm_values: sbm_enabled = False if get_nvram("csr-active-config", decode=False) and csr_decode(get_nvram("csr-active-config", decode=False)) is False: @@ -82,14 +90,18 @@ def patching_status(): return sip_enabled, sbm_enabled, amfi_enabled, fv_enabled + def cls(): - if check_recovery() == False: - os.system('cls' if os.name == 'nt' else 'clear') + if not check_recovery(): + os.system("cls" if os.name == "nt" else "clear") else: print("\u001Bc") + def get_nvram(variable: str, uuid: str = None, *, decode: bool = False): - if uuid != None: + # TODO: Properly fix for El Capitan, which does not print the XML representation even though we say to + + if uuid is not None: uuid += ":" else: uuid = "" @@ -102,6 +114,7 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False): value = value.strip(b"\0").decode() return value + # def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False): # return_option = ["Q", "Quit", None] if top_level else ["B", "Back", None] # if add_quit: menu_options.append(return_option) diff --git a/Resources/device_probe.py b/Resources/device_probe.py new file mode 100644 index 000000000..ef6d8628e --- /dev/null +++ b/Resources/device_probe.py @@ -0,0 +1,379 @@ +import binascii +import enum +import itertools +import subprocess +from dataclasses import dataclass, field +from typing import Any, ClassVar, Optional, Type + +from Resources import PCIIDArray, Utilities, ioreg + + +@dataclass +class CPU: + name: str + flags: list[str] + + +@dataclass +class PCIDevice: + VENDOR_ID: ClassVar[int] # Default vendor id, for subclasses. + + vendor_id: int # The vendor ID of this PCI device + device_id: int # The device ID of this PCI device + class_code: int # The class code of this PCI device + + # ioregistryentry: Optional[ioreg.IORegistryEntry] = None + name: Optional[str] = None # Name of IORegistryEntry + model: Optional[str] = None # model property + pci_path: Optional[str] = None + + # def __getstate__(self): + # state = self.__dict__.copy() + # state.pop("ioregistryentry") + # return state + + @classmethod + def from_ioregistry(cls, entry: ioreg.IORegistryEntry, anti_spoof=False): + if anti_spoof and "IOName" in entry.properties: + vendor_id, device_id = (int(i, 16) for i in entry.properties["IOName"][3:].split(",")) + else: + vendor_id, device_id = [int.from_bytes(entry.properties[i][:4], byteorder="little") for i in ["vendor-id", "device-id"]] + + device = cls(vendor_id, device_id, int.from_bytes(entry.properties["class-code"][:6], byteorder="little"), name=entry.name) + if "model" in entry.properties: + device.model = entry.properties["model"].strip(b"\0").decode() + device.populate_pci_path(entry) + return device + + # @staticmethod + # def vendor_detect_old(device): + # for i in [NVIDIA, AMD]: + # if i.detect(device): + # return i + # return None + + def vendor_detect(self, *, inherits: ClassVar[Any] = None, classes: list = None): + for i in classes or itertools.chain.from_iterable([subclass.__subclasses__() for subclass in PCIDevice.__subclasses__()]): + if issubclass(i, inherits or object) and i.detect(self): + return i + return None + + @classmethod + def detect(cls, device): + return device.vendor_id == cls.VENDOR_ID and ((device.class_code == cls.CLASS_CODE) if getattr(cls, "CLASS_CODE", None) else True) # type: ignore # pylint: disable=no-member + + # def acpi_path(self): + # # Eventually + # raise NotImplementedError + + def populate_pci_path(self, entry: ioreg.IORegistryEntry): + # Based off gfxutil logic, seems to work. + paths = [] + while entry: + if entry.entry_class == "IOPCIDevice": + location = [hex(int(i, 16)) for i in entry.location.split(",") + ["0"]] + paths.append(f"Pci({location[0]},{location[1]})") + elif entry.entry_class == "IOACPIPlatformDevice": + paths.append(f"PciRoot({hex(int(entry.properties.get('_UID', 0)))})") + break + elif entry.entry_class in ["IOPCI2PCIBridge", "IOPCIBridge", "AppleACPIPCI"]: + pass + else: + # There's something in between that's not PCI! Abort + paths = [] + break + entry = entry.parent + self.pci_path = "/".join(reversed(paths)) + + +@dataclass +class GPU(PCIDevice): + arch: enum.Enum = field(init=False) # The architecture, see subclasses. + + def __post_init__(self): + self.detect_arch() + + def detect_arch(self): + raise NotImplementedError + + +@dataclass +class WirelessCard(PCIDevice): + CLASS_CODE: ClassVar[int] = 0x028000 # 00800200 hexswapped + chipset: enum.Enum = field(init=False) + + def __post_init__(self): + self.detect_chipset() + + def detect_chipset(self): + raise NotImplementedError + + +@dataclass +class NVMeController(PCIDevice): + CLASS_CODE: ClassVar[int] = 0x010802 + + aspm: Optional[int] = None + parent_aspm: Optional[int] = None + + +@dataclass +class SATAController(PCIDevice): + CLASS_CODE: ClassVar[int] = 0x010601 + + +@dataclass +class NVIDIA(GPU): + VENDOR_ID: ClassVar[int] = 0x10DE + + class Archs(enum.Enum): + # pylint: disable=invalid-name + Fermi = "Fermi" + Tesla = "Tesla" + Kepler = "Kepler" + Unknown = "Unknown" + + arch: Archs = field(init=False) + + def detect_arch(self): + # G80/G80GL + if self.device_id in PCIIDArray.nvidia_ids.tesla_ids: + self.arch = NVIDIA.Archs.Tesla + elif self.device_id in PCIIDArray.nvidia_ids.fermi_ids: + self.arch = NVIDIA.Archs.Fermi + elif self.device_id in PCIIDArray.nvidia_ids.kepler_ids: + self.arch = NVIDIA.Archs.Kepler + else: + self.arch = NVIDIA.Archs.Unknown + + +@dataclass +class AMD(GPU): + VENDOR_ID: ClassVar[int] = 0x1002 + + class Archs(enum.Enum): + # pylint: disable=invalid-name + Legacy_GCN = "Legacy GCN" + TeraScale_1 = "TeraScale 1" + TeraScale_2 = "TeraScale 2" + Polaris = "Polaris" + Vega = "Vega" + Navi = "Navi" + Unknown = "Unknown" + + arch: Archs = field(init=False) + + def detect_arch(self): + if self.device_id in PCIIDArray.amd_ids.legacy_gcn_ids: + self.arch = AMD.Archs.Legacy_GCN + elif self.device_id in PCIIDArray.amd_ids.terascale_1_ids: + self.arch = AMD.Archs.TeraScale_1 + elif self.device_id in PCIIDArray.amd_ids.terascale_2_ids: + self.arch = AMD.Archs.TeraScale_2 + elif self.device_id in PCIIDArray.amd_ids.polaris_ids: + self.arch = AMD.Archs.Polaris + elif self.device_id in PCIIDArray.amd_ids.vega_ids: + self.arch = AMD.Archs.Vega + elif self.device_id in PCIIDArray.amd_ids.navi_ids: + self.arch = AMD.Archs.Navi + else: + self.arch = AMD.Archs.Unknown + + +@dataclass +class Intel(GPU): + VENDOR_ID: ClassVar[int] = 0x8086 + + class Archs(enum.Enum): + # pylint: disable=invalid-name + Iron_Lake = "Iron Lake" + Sandy_Bridge = "Sandy Bridge" + Ivy_Bridge = "Ivy Bridge" + Unknown = "Unknown" + + arch: Archs = field(init=False) + + def detect_arch(self): + if self.device_id in PCIIDArray.intel_ids.iron_ids: + self.arch = Intel.Archs.Iron_Lake + elif self.device_id in PCIIDArray.intel_ids.sandy_ids: + self.arch = Intel.Archs.Sandy_Bridge + elif self.device_id in PCIIDArray.intel_ids.ivy_ids: + self.arch = Intel.Archs.Ivy_Bridge + else: + self.arch = Intel.Archs.Unknown + + +@dataclass +class Broadcom(WirelessCard): + VENDOR_ID: ClassVar[int] = 0x14E4 + + class Chipsets(enum.Enum): + # pylint: disable=invalid-name + AirportBrcmNIC = "AirportBrcmNIC supported" + AirPortBrcm4360 = "AirPortBrcm4360 supported" + AirPortBrcm4331 = "AirPortBrcm4331 supported" + AirPortBrcm43224 = "AppleAirPortBrcm43224 supported" + Unknown = "Unknown" + + chipset: Chipsets = field(init=False) + + def detect_chipset(self): + if self.device_id in PCIIDArray.broadcom_ids.AirPortBrcmNIC: + self.chipset = Broadcom.Chipsets.AirportBrcmNIC + elif self.device_id in PCIIDArray.broadcom_ids.AirPortBrcm4360: + self.chipset = Broadcom.Chipsets.AirPortBrcm4360 + elif self.device_id in PCIIDArray.broadcom_ids.AirPortBrcm4331: + self.chipset = Broadcom.Chipsets.AirPortBrcm4331 + elif self.device_id in PCIIDArray.broadcom_ids.AppleAirPortBrcm43224: + self.chipset = Broadcom.Chipsets.AirPortBrcm43224 + else: + self.chipset = Broadcom.Chipsets.Unknown + + +@dataclass +class Atheros(WirelessCard): + VENDOR_ID: ClassVar[int] = 0x168C + + class Chipsets(enum.Enum): + # pylint: disable=invalid-name + # Well there's only one model but + AirPortAtheros40 = "AirPortAtheros40 supported" + Unknown = "Unknown" + + chipset: Chipsets = field(init=False) + + def detect_chipset(self): + if self.device_id in PCIIDArray.atheros_ids.AtherosWifi: + self.chipset = Atheros.Chipsets.AirPortAtheros40 + else: + self.chipset = Atheros.Chipsets.Unknown + + +@dataclass +class Computer: + real_model: Optional[str] = None + real_board_id: Optional[str] = None + reported_model: Optional[str] = None + reported_board_id: Optional[str] = None + gpus: list[GPU] = field(default_factory=list) + igpu: Optional[GPU] = None # Shortcut for IGPU + dgpu: Optional[GPU] = None # Shortcut for GFX0 + storage: list[PCIDevice] = field(default_factory=list) + wifi: Optional[WirelessCard] = None + cpu: Optional[CPU] = None + oclp_version: Optional[str] = None + ioregistry: Optional[ioreg.IOReg] = None + + @staticmethod + def probe(): + computer = Computer() + computer.ioregistry = ioreg.IOReg() + computer.gpu_probe() + computer.dgpu_probe() + computer.igpu_probe() + computer.wifi_probe() + computer.storage_probe() + computer.smbios_probe() + computer.cpu_probe() + return computer + + def gpu_probe(self): + # Chain together two iterators: one for class code 00000300, the other for class code 00800300 + devices = itertools.chain(self.ioregistry.find(property=("class-code", binascii.a2b_hex("00000300"))), self.ioregistry.find(property=("class-code", binascii.a2b_hex("00800300")))) + + for device in devices: + vendor: Type[GPU] = PCIDevice.from_ioregistry(device).vendor_detect(inherits=GPU) # type: ignore + if vendor: + self.gpus.append(vendor.from_ioregistry(device)) # type: ignore + + def dgpu_probe(self): + device = next(self.ioregistry.find(name="GFX0"), None) + if not device: + # No devices + return + + vendor: Type[GPU] = PCIDevice.from_ioregistry(device).vendor_detect(inherits=GPU) # type: ignore + if vendor: + self.dgpu = vendor.from_ioregistry(device) # type: ignore + + def igpu_probe(self): + device = next(self.ioregistry.find(name="IGPU"), None) + if not device: + # No devices + return + + vendor: Type[GPU] = PCIDevice.from_ioregistry(device).vendor_detect(inherits=GPU) # type: ignore + if vendor: + self.igpu = vendor.from_ioregistry(device) # type: ignore + + def wifi_probe(self): + # result = subprocess.run("ioreg -r -c IOPCIDevice -a -d2".split(), stdout=subprocess.PIPE).stdout.strip() + devices = self.ioregistry.find(property=("class-code", binascii.a2b_hex(Utilities.hexswap(hex(WirelessCard.CLASS_CODE)[2:].zfill(8))))) + # if not result: + # # No devices + # print("A") + # return + + # devices = plistlib.loads(result) + # devices = [i for i in devices if i["class-code"] == binascii.a2b_hex("00800200")] + + # if not devices: + # # No devices + # print("B") + # return + + for device in devices: + vendor: Type[WirelessCard] = PCIDevice.from_ioregistry(device, anti_spoof=True).vendor_detect(inherits=WirelessCard) # type: ignore + if vendor: + self.wifi = vendor.from_ioregistry(device, anti_spoof=True) # type: ignore + break + + def storage_probe(self): + sata_controllers = self.ioregistry.find(entry_class="IOPCIDevice", property=("class-code", binascii.a2b_hex(Utilities.hexswap(hex(SATAController.CLASS_CODE)[2:].zfill(8))))) + nvme_controllers = itertools.chain.from_iterable( + [ + # self.ioregistry.find(entry_class="IOPCIDevice", property=("class-code", binascii.a2b_hex(Utilities.hexswap(hex(NVMeController.CLASS_CODE)[2:].zfill(8))))), + self.ioregistry.find(entry_class="IOPCIDevice", children={"entry_class": "IONVMeController"}), + ] + ) + for device in sata_controllers: + self.storage.append(SATAController.from_ioregistry(device)) + for device in nvme_controllers: + aspm = device.properties.get("pci-aspm-default", 0) + if isinstance(aspm, bytes): + aspm = int.from_bytes(aspm, byteorder="little") + + if device.parent.parent.entry_class == "IOPCIDevice": + parent_aspm = device.parent.parent.properties.get("pci-aspm-default", 0) + if isinstance(parent_aspm, bytes): + parent_aspm = int.from_bytes(parent_aspm, byteorder="little") + else: + parent_aspm = None + + controller = NVMeController.from_ioregistry(device) + controller.aspm = aspm + controller.parent_aspm = parent_aspm + + if controller.vendor_id != 0x106B: + self.storage.append(controller) + + def smbios_probe(self): + # Reported model + entry = next(self.ioregistry.find(name="Root")).children[0] + self.reported_model = entry.properties["model"].strip(b"\0").decode() + self.reported_board_id = entry.properties.get("board-id", entry.properties.get("target-type", b"")).strip(b"\0").decode() + + # Real model + # TODO: We previously had logic for OC users using iMacPro1,1 with incorrect ExposeSensitiveData. Add logic? + self.real_model = Utilities.get_nvram("oem-product", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_model + self.real_board_id = Utilities.get_nvram("oem-board", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) or self.reported_board_id + + # OCLP version + self.oclp_version = Utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) + + def cpu_probe(self): + self.cpu = CPU( + subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(), + subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" "), + ) diff --git a/Resources/ioreg.py b/Resources/ioreg.py new file mode 100644 index 000000000..d821b829d --- /dev/null +++ b/Resources/ioreg.py @@ -0,0 +1,83 @@ +from __future__ import annotations + +from dataclasses import dataclass +import plistlib +import subprocess +from typing import Generator + + +@dataclass +class IORegistryEntry: + name: str + entry_class: str + properties: dict + location: str + children: list[IORegistryEntry] + parent: IORegistryEntry + + +class IOReg: + def __init__(self): + self.ioreg = plistlib.loads(subprocess.run("ioreg -a -l".split(), stdout=subprocess.PIPE).stdout.strip()) + self.tree = self.recurse(self.ioreg, None) + + def recurse(self, entry, parent): + converted = IORegistryEntry( + entry["IORegistryEntryName"], + entry["IOObjectClass"], + { + i: v + for i, v in entry.items() + if i + not in [ + "IOServiceBusyState", + "IOServiceBusyTime", + "IOServiceState", + "IORegistryEntryLocation", + "IORegistryEntryName", + "IORegistryEntryID", + "IOObjectClass", + "IORegistryEntryChildren", + "IOObjectRetainCount", + ] + }, + entry.get("IORegistryEntryLocation"), + [], + parent, + ) + + for i in entry.get("IORegistryEntryChildren", []): + converted.children.append(self.recurse(i, converted)) + + return converted + + def parse_conditions(self, entry: IORegistryEntry, **kwargs): + conditions = [] + if "parent" in kwargs: + conditions.append(self.parse_conditions(entry.parent, **kwargs["parent"])) + if "children" in kwargs: + conditions.append(any(self.parse_conditions(i, **kwargs["children"]) for i in entry.children)) + if "name" in kwargs: + conditions.append(kwargs["name"] == entry.name) + if "entry_class" in kwargs: + conditions.append(kwargs["entry_class"] == entry.entry_class) + if "key" in kwargs: + conditions.append(kwargs["key"] in entry.properties) + if "property" in kwargs: + conditions.append(kwargs["property"][0] in entry.properties and entry.properties[kwargs["property"][0]] == kwargs["property"][1]) + + return all(conditions) + + def find(self, root: IORegistryEntry = None, **kwargs) -> Generator[IORegistryEntry, None, None]: + if not root: + root = self.tree + + if not kwargs: + return + + if self.parse_conditions(root, **kwargs): + yield root + + for i in root.children: + for j in self.find(i, **kwargs): + yield j