From 057b8739d386ed0a7c6aacef9b9a587ccc97fdae Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Wed, 5 May 2021 12:28:24 -0600 Subject: [PATCH] Refactor Device Probing --- OCLP-CLI.command | 10 +--- OpenCore-Patcher.command | 10 +--- Resources/Build.py | 106 ++++++++++----------------------------- Resources/Constants.py | 4 -- Resources/DeviceProbe.py | 77 ++++++++++++++++++++++++++++ Resources/SysPatch.py | 70 +++++++++----------------- 6 files changed, 132 insertions(+), 145 deletions(-) create mode 100644 Resources/DeviceProbe.py diff --git a/OCLP-CLI.command b/OCLP-CLI.command index 133e5cde2..721187a4e 100755 --- a/OCLP-CLI.command +++ b/OCLP-CLI.command @@ -12,7 +12,7 @@ import platform import argparse from pathlib import Path -from Resources import Build, ModelArray, Constants, SysPatch, Utilities, CliMenu +from Resources import Build, ModelArray, Constants, SysPatch, Utilities, CliMenu, DeviceProbe class OpenCoreLegacyPatcher(): @@ -30,13 +30,7 @@ class OpenCoreLegacyPatcher(): if self.current_model in ModelArray.NoAPFSsupport: self.constants.serial_settings = "Moderate" if self.current_model in ModelArray.LegacyGPU: - try: - dgpu_devices = plistlib.loads(subprocess.run("ioreg -r -n GFX0 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - dgpu_vendor = self.hexswap(binascii.hexlify(dgpu_devices[0]["vendor-id"]).decode()[:4]) - dgpu_device = self.hexswap(binascii.hexlify(dgpu_devices[0]["device-id"]).decode()[:4]) - except ValueError: - dgpu_vendor = "" - dgpu_device = "" + dgpu_vendor,dgpu_device = DeviceProbe.pci_probe().gpu_probe("GFX0") if (dgpu_vendor == self.constants.pci_amd_ati and dgpu_device in ModelArray.AMDMXMGPUs) or (dgpu_vendor == self.constants.pci_nvidia and dgpu_device in ModelArray.NVIDIAMXMGPUs): self.constants.sip_status = True diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 09e24f3da..3d8e123fc 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -10,7 +10,7 @@ import sys import time import platform -from Resources import Build, ModelArray, Constants, SysPatch, Utilities, CliMenu +from Resources import Build, ModelArray, Constants, SysPatch, Utilities, CliMenu, DeviceProbe class OpenCoreLegacyPatcher(): @@ -27,13 +27,7 @@ class OpenCoreLegacyPatcher(): if self.current_model in ModelArray.NoAPFSsupport: self.constants.serial_settings = "Moderate" if self.current_model in ModelArray.LegacyGPU: - try: - dgpu_devices = plistlib.loads(subprocess.run("ioreg -r -n GFX0 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - dgpu_vendor = self.hexswap(binascii.hexlify(dgpu_devices[0]["vendor-id"]).decode()[:4]) - dgpu_device = self.hexswap(binascii.hexlify(dgpu_devices[0]["device-id"]).decode()[:4]) - except ValueError: - dgpu_vendor = "" - dgpu_device = "" + dgpu_vendor,dgpu_device = DeviceProbe.pci_probe().gpu_probe("GFX0") if (dgpu_vendor == self.constants.pci_amd_ati and dgpu_device in ModelArray.AMDMXMGPUs) or (dgpu_vendor == self.constants.pci_nvidia and dgpu_device in ModelArray.NVIDIAMXMGPUs): self.constants.sip_status = True diff --git a/Resources/Build.py b/Resources/Build.py index add1a5530..f9666862a 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -15,7 +15,7 @@ import ast from pathlib import Path from datetime import date -from Resources import Constants, ModelArray, Utilities +from Resources import Constants, ModelArray, Utilities, DeviceProbe def human_fmt(num): @@ -44,33 +44,6 @@ class BuildOpenCore: hex_str = "".join(["".join(x) for x in hex_rev]) return hex_str.upper() - def check_pciid(self, print_status): - try: - self.constants.igpu_devices = plistlib.loads(subprocess.run("ioreg -r -n IGPU -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - self.constants.igpu_vendor = self.hexswap(binascii.hexlify(self.constants.igpu_devices[0]["vendor-id"]).decode()[:4]) - self.constants.igpu_device = self.hexswap(binascii.hexlify(self.constants.igpu_devices[0]["device-id"]).decode()[:4]) - if print_status is True: - print(f"- Detected iGPU: {self.constants.igpu_vendor}:{self.constants.igpu_device}") - self.config["#Revision"]["Hardware-iGPU"] = f"{self.constants.igpu_vendor}:{self.constants.igpu_device}" - except ValueError: - if print_status is True: - print("- No iGPU detected") - self.constants.igpu_devices = "" - self.config["#Revision"]["Hardware-iGPU"] = "No iGPU detected" - - try: - self.constants.dgpu_devices = plistlib.loads(subprocess.run("ioreg -r -n GFX0 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - self.constants.dgpu_vendor = self.hexswap(binascii.hexlify(self.constants.dgpu_devices[0]["vendor-id"]).decode()[:4]) - self.constants.dgpu_device = self.hexswap(binascii.hexlify(self.constants.dgpu_devices[0]["device-id"]).decode()[:4]) - if print_status is True: - print(f"- Detected dGPU: {self.constants.dgpu_vendor}:{self.constants.dgpu_device}") - self.config["#Revision"]["Hardware-GFX0"] = f"{self.constants.dgpu_vendor}:{self.constants.dgpu_device}" - except ValueError: - if print_status is True: - print("- No dGPU detected") - self.constants.dgpu_devices = "" - self.config["#Revision"]["Hardware-GFX0"] = "No dGPU detected" - def build_efi(self): Utilities.cls() print(f"Building Configuration for model: {self.model}") @@ -148,24 +121,23 @@ class BuildOpenCore: for i in storage_devices: storage_vendor = self.hexswap(binascii.hexlify(i["vendor-id"]).decode()[:4]) storage_device = self.hexswap(binascii.hexlify(i["device-id"]).decode()[:4]) - print(f'- Fixing PCIe Drive ({x}) reporting') + 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 drive {x}, falling back to Innie") + 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 Drives found to fix") + print("- No PCIe Storage Controllers found to fix") except IndexError: - print("- No PCIe Drives found to fix") + 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"] - nvme_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 nvme_devices: @@ -174,24 +146,18 @@ class BuildOpenCore: nvme_aspm = i["pci-aspm-default"] # Disable Bit 0 (L0s), enable Bit 1 (L1) if not isinstance(nvme_aspm, int): - #print("- Converting variable") binascii.unhexlify(nvme_aspm) nvme_aspm = self.hexswap(nvme_aspm) nvme_aspm = int(nvme_aspm, 16) - nvme_aspm = (nvme_aspm & (~3)) | 2 - print(f'- Found 3rd Party NVMe SSD ({x}): {nvme_vendor}:{nvme_device}') self.config["#Revision"][f"Hardware-NVMe-{x}"] = f'{nvme_vendor}:{nvme_device}' - try: - nvme_path = [line.strip().split("= ", 1)[1] for line in nvme_path_gfx.split("\n") if f'{nvme_vendor}:{nvme_device}'.lower() in line.strip()][0] - nvme_path_parent = "/".join(nvme_path.split("/")[:-1]) + nvme_path = DeviceProbe.pci_probe().deviceproperty_probe(nvme_vendor, nvme_device) + nvme_path_parent = DeviceProbe.pci_probe().device_property_parent(nvme_path) print(f"- Found NVMe ({x}) at {nvme_path}") - #print(f"- Found NVMe({x}) Parent at {nvme_path_parent}") 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: print(f"- Failed to find Device path for NVMe {x}") if "-nvmefaspm" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: @@ -210,13 +176,11 @@ class BuildOpenCore: 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: str = subprocess.run([self.constants.gfxutil_path] + f"-v".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() - try: - arpt_path = [line.strip().split("= ", 1)[1] for line in arpt_path.split("\n") if f"{wifi_vendor}:{wifi_device}".lower() in line.strip()][0] + arpt_path = DeviceProbe.pci_probe().deviceproperty_probe(wifi_vendor, wifi_device) + if arpt_path: print(f"- Found ARPT device at {arpt_path}") default_path = False - except IndexError: - print("- Failed to find Device path") + else: default_path = True if default_path is True: if self.model in ModelArray.nvidiaHDEF: @@ -238,35 +202,17 @@ 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: - try: - wifi_devices = plistlib.loads(subprocess.run("ioreg -r -n ARPT -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - except ValueError: - # Work-around Mac Pros where Wifi card may not be named ARPT (ie. installed in dedicated PCIe card slot) - wifi_devices = plistlib.loads(subprocess.run("ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - vendor_atheros = binascii.unhexlify("E4140000") - vendor_broadcom = binascii.unhexlify("8C160000") - wifi_devices = [i for i in wifi_devices if i["vendor-id"] == vendor_atheros or i["vendor-id"] == vendor_broadcom and i["class-code"] == binascii.unhexlify("00800200")] - try: - wifi_vendor = self.hexswap(binascii.hexlify(wifi_devices[0]["vendor-id"]).decode()[:4]) - wifi_device = self.hexswap(binascii.hexlify(wifi_devices[0]["device-id"]).decode()[:4]) - wifi_ioname = wifi_devices[0]["IOName"] - if not self.constants.custom_model: - if wifi_ioname in ["pci14e4,4353", "pci14e4,4331"]: - print(f"- Detected Wifi Card: {wifi_ioname}") - self.config["#Revision"]["Hardware-Wifi"] = f"{wifi_ioname}" - else: - print(f"- Detected Wifi Card: {wifi_vendor}:{wifi_device}") - self.config["#Revision"]["Hardware-Wifi"] = f"{wifi_vendor}:{wifi_device}" - except IndexError: - wifi_devices = "" - + if self.constants.detected_os > self.constants.lion and not self.constants.custom_model: + wifi_vendor,wifi_device,wifi_ioname = 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}" else: - wifi_devices = "" - print("- Can't run Wifi hardware detection on Snow Leopard and older") + 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_devices: + elif not self.constants.custom_model and wifi_vendor: if wifi_vendor == self.constants.pci_broadcom: # This works around OCLP spoofing the Wifi card and therefore unable to actually detect the correct device if wifi_device in ModelArray.BCM4360Wifi and wifi_ioname not in ["pci14e4,4353", "pci14e4,4331"]: @@ -447,13 +393,15 @@ class BuildOpenCore: else: print("- Failed to find vendor") elif not self.constants.custom_model: - self.check_pciid(True) - if self.constants.dgpu_vendor == self.constants.pci_amd_ati and self.constants.dgpu_device in ModelArray.AMDMXMGPUs: - backlight_path_detection(self) - amd_patch(self, self.gfx0_path) - elif self.constants.dgpu_vendor == self.constants.pci_nvidia and self.constants.dgpu_device in ModelArray.NVIDIAMXMGPUs: - backlight_path_detection(self) - nvidia_patch(self, self.gfx0_path) + dgpu_vendor,dgpu_device = 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 ModelArray.AMDMXMGPUs: + backlight_path_detection(self) + amd_patch(self, self.gfx0_path) + elif dgpu_vendor == self.constants.pci_nvidia and dgpu_device in ModelArray.NVIDIAMXMGPUs: + 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()) diff --git a/Resources/Constants.py b/Resources/Constants.py index 63e31140c..23093661e 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -48,10 +48,6 @@ class Constants: self.custom_mxm_gpu: str = None self.current_gpuv: str = None self.current_gpud: str = None - self.igpu_vendor = "" - self.igpu_device = "" - self.dgpu_vendor = "" - self.dgpu_device = "" # Patcher Settings self.opencore_debug = False diff --git a/Resources/DeviceProbe.py b/Resources/DeviceProbe.py new file mode 100644 index 000000000..6c0786f78 --- /dev/null +++ b/Resources/DeviceProbe.py @@ -0,0 +1,77 @@ +# Probe devices, return device entries +# Copyright (C) 2021 Mykola Grymalyuk +from __future__ import print_function + +import binascii +import plistlib +import shutil +import subprocess +import uuid +import os +import sys +import platform +from pathlib import Path + +from Resources import Constants, ModelArray, Utilities + +class pci_probe: + def __init__(self): + self.constants = Constants.Constants() + + def hexswap(self, input_hex: str): + hex_pairs = [input_hex[i:i + 2] for i in range(0, len(input_hex), 2)] + hex_rev = hex_pairs[::-1] + hex_str = "".join(["".join(x) for x in hex_rev]) + return hex_str.upper() + + # 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): + gfxutil_output: str = subprocess.run([self.constants.gfxutil_path] + f"-v".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() + try: + #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 f'{acpi_path}' in line.strip()][0] + device_path = [line.strip().split("= ", 1)[1] for line in gfxutil_output.split("\n") if f'{vendor_id}:{device_id}'.lower() in line.strip()][0] + return device_path + except IndexError: + #print(f"- No DevicePath found for {vendor_id}:{device_id} at {acpi_path}") + print(f"- No DevicePath found for {vendor_id}:{device_id}") + 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 + + # GPU probing, note best way to handle is: + # vendor,device,acpi_path = gpu_vendor_probe("GFX0") + # + # Note gpu_probe should only be used on IGPU and GFX0 entries + def gpu_probe(self, gpu_type): + print(f"- Probing IOService for device: {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 = self.hexswap(binascii.hexlify(devices[0]["vendor-id"]).decode()[:4]) + device_id = self.hexswap(binascii.hexlify(devices[0]["device-id"]).decode()[:4]) + try: + acpi_path = devices[0]["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}") + return "", "", "" + + def wifi_probe(self): + try: + devices = plistlib.loads(subprocess.run("ioreg -r -n ARPT -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) + except ValueError: + 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 = self.hexswap(binascii.hexlify(devices[0]["vendor-id"]).decode()[:4]) + device_id = self.hexswap(binascii.hexlify(devices[0]["device-id"]).decode()[:4]) + ioname = devices[0]["IOName"] + return vendor_id, device_id, ioname + except ValueError: + print(f"- No IOService entry found for Wireless Card") + return "", "", "" \ No newline at end of file diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index 1ac3a80cd..b3382f120 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -18,7 +18,7 @@ import os from pathlib import Path from datetime import date -from Resources import Constants, ModelArray, Utilities +from Resources import Constants, ModelArray, Utilities, DeviceProbe class PatchSysVolume: @@ -121,52 +121,29 @@ class PatchSysVolume: subprocess.run(f"sudo chmod -R 755 {self.mount_private_frameworks}/DisplayServices.framework".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() subprocess.run(f"sudo chown -R root:wheel {self.mount_private_frameworks}/DisplayServices.framework".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() - def check_pciid(self): - try: - self.igpu_devices = plistlib.loads(subprocess.run("ioreg -r -n IGPU -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - self.igpu_devices = [i for i in self.igpu_devices if i["class-code"] == binascii.unhexlify("00000300")] - self.igpu_vendor = self.hexswap(binascii.hexlify(self.igpu_devices[0]["vendor-id"]).decode()[:4]) - self.igpu_device = self.hexswap(binascii.hexlify(self.igpu_devices[0]["device-id"]).decode()[:4]) - print(f"- Detected iGPU: {self.igpu_vendor}:{self.igpu_device}") - except ValueError: - print("- No iGPU detected") - self.igpu_devices = "" - - try: - self.dgpu_devices = plistlib.loads(subprocess.run("ioreg -r -n GFX0 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) - self.dgpu_devices = [i for i in self.dgpu_devices if i["class-code"] == binascii.unhexlify("00000300")] - self.dgpu_vendor = self.hexswap(binascii.hexlify(self.dgpu_devices[0]["vendor-id"]).decode()[:4]) - self.dgpu_device = self.hexswap(binascii.hexlify(self.dgpu_devices[0]["device-id"]).decode()[:4]) - try: - self.nvidia_arch = self.dgpu_devices[0]["NVArch"] - except KeyError: - self.nvidia_arch = "" - print(f"- Detected dGPU: {self.dgpu_vendor}:{self.dgpu_device}") - except ValueError: - print("- No dGPU detected") - self.dgpu_devices = "" - def gpu_accel_patches_11(self): - if self.dgpu_devices: - if self.dgpu_vendor == self.constants.pci_nvidia: - if self.nvidia_arch == self.constants.arch_kepler and self.constants.assume_legacy is True and self.constants.detected_os > self.constants.big_sur: - print("- Merging legacy Nvidia Kepler Kexts and Bundles") - self.add_new_binaries(ModelArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path) - else: - print("- Merging legacy Nvidia Tesla and Fermi Kexts and Bundles") - self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) - self.add_new_binaries(ModelArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path) - elif self.dgpu_vendor == self.constants.pci_amd_ati: + igpu_vendor,igpu_device = DeviceProbe.pci_probe().gpu_probe("IGPU") + dgpu_vendor,dgpu_device = DeviceProbe.pci_probe().gpu_probe("GFX0") + if dgpu_vendor: + if dgpu_vendor == self.constants.pci_nvidia: + #if self.nvidia_arch == self.constants.arch_kepler and self.constants.assume_legacy is True and self.constants.detected_os > self.constants.big_sur: + # print("- Merging legacy Nvidia Kepler Kexts and Bundles") + # self.add_new_binaries(ModelArray.AddNvidiaKeplerAccel11, self.constants.legacy_nvidia_kepler_path) + #else: + print("- Merging legacy Nvidia Tesla and Fermi Kexts and Bundles") + self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) + self.add_new_binaries(ModelArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path) + elif dgpu_vendor == self.constants.pci_amd_ati: print("- Merging legacy AMD Kexts and Bundles") self.delete_old_binaries(ModelArray.DeleteAMDAccel11) self.add_new_binaries(ModelArray.AddAMDAccel11, self.constants.legacy_amd_path) - if self.igpu_devices: - if self.igpu_vendor == self.constants.pci_intel: - if self.igpu_device in ModelArray.IronLakepciid: + if igpu_vendor: + if igpu_vendor == self.constants.pci_intel: + if igpu_device in ModelArray.IronLakepciid: print("- Merging legacy Intel 1st Gen Kexts and Bundles") self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) self.add_new_binaries(ModelArray.AddIntelGen1Accel, self.constants.legacy_intel_gen1_path) - elif self.igpu_device in ModelArray.SandyBridgepiciid: + elif igpu_device in ModelArray.SandyBridgepiciid: print("- Merging legacy Intel 2nd Gen Kexts and Bundles") self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) self.add_new_binaries(ModelArray.AddIntelGen2Accel, self.constants.legacy_intel_gen2_path) @@ -176,11 +153,11 @@ class PatchSysVolume: # subprocess.run(f"sudo cp -R {self.constants.legacy_amd_path}/AMD-Link/AppleIntelSNBGraphicsFB.kext {self.mount_extensions}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() # Code for when Ivy Bridge binares are presumably removed from macOS 12, code currently - #elif self.igpu_device in ModelArray.IvyBridgepciid: + #elif igpu_device in ModelArray.IvyBridgepciid: # print("- Merging legacy Intel 3rd Gen Kexts and Bundles") # self.add_new_binaries(ModelArray.AddIntelGen3Accel, self.constants.legacy_intel_gen3_path) - elif self.igpu_vendor == self.constants.pci_nvidia: - if not self.dgpu_devices: + elif igpu_vendor == self.constants.pci_nvidia: + if not dgpu_devices: # Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs print("- Merging legacy Nvidia Kexts and Bundles") self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) @@ -222,10 +199,10 @@ class PatchSysVolume: subprocess.run(f"sudo find {self.constants.payload_apple_root_path} -name '.DS_Store' -delete".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() if self.model in ModelArray.LegacyGPU or self.constants.assume_legacy is True: - self.check_pciid() - if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_amd_ati and self.dgpu_device in ModelArray.AMDMXMGPUs: + dgpu_vendor,dgpu_device = DeviceProbe.pci_probe().gpu_probe("GFX0") + if dgpu_vendor and dgpu_vendor == self.constants.pci_amd_ati and dgpu_device in ModelArray.AMDMXMGPUs: print("- Detected Metal-based AMD GPU, skipping legacy patches") - elif self.dgpu_devices and self.dgpu_vendor == self.constants.pci_nvidia and self.dgpu_device in ModelArray.NVIDIAMXMGPUs: + elif dgpu_vendor and dgpu_vendor == self.constants.pci_nvidia and dgpu_device in ModelArray.NVIDIAMXMGPUs: print("- Detected Metal-based Nvidia GPU, skipping legacy patches") else: print("- Detected legacy GPU, attempting legacy acceleration patches") @@ -334,6 +311,7 @@ class PatchSysVolume: def start_patch(self): # Check SIP + # self.check_files() if self.constants.custom_model is not None: print("Root Patching must be done on target machine!") elif self.model in ModelArray.NoRootPatch11 and self.constants.assume_legacy is False: