From 302cfb3bef03a2593fc530d0937598495c9fbc42 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Tue, 4 May 2021 22:24:14 -0600 Subject: [PATCH] Add built-in to party PCI drives --- CHANGELOG.md | 1 + Resources/Build.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc86bc05..81f236a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 0.1.3 - Fix internal PCIe devices reporting as external + - Opt for `built-in` when device path is detectable - Innie 0ccd95e (1.3.0 release - 01-16-2021) - Fix MacBookPro5,4 audio support - Increment binaries diff --git a/Resources/Build.py b/Resources/Build.py index ddcf98489..02452f572 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -130,13 +130,38 @@ class BuildOpenCore: ("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in ModelArray.IDEPatch), # Misc ("SidecarFixup.kext", self.constants.sidecarfixup_version, self.constants.sidecarfixup_path, lambda: self.model in ModelArray.SidecarPatch), - ("Innie.kext", self.constants.innie_version, self.constants.innie_path, lambda: self.model in self.model in ModelArray.MacPro71), ]: self.enable_kext(name, version, path, check) if self.constants.allow_oc_everywhere is False: self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleSMC")["Enabled"] = True + + if not self.constants.custom_model 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 wifi_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 = 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') + 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") + 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") + except IndexError: + print("- No PCIe Drives 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"] @@ -164,7 +189,7 @@ class BuildOpenCore: nvme_path_parent = "/".join(nvme_path.split("/")[:-1]) 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} + 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: