diff --git a/OpCore-Simplify.py b/OpCore-Simplify.py index e5ed744..4a67722 100644 --- a/OpCore-Simplify.py +++ b/OpCore-Simplify.py @@ -172,7 +172,7 @@ class OCPE: if patch.checked: if patch.name == "BATP": patch.checked = getattr(self.ac, patch.function_name)() - self.k.kexts[self.k.get_kext_index("ECEnabler")].checked = patch.checked + self.k.kexts[self.k.kext_data.kext_index_by_name("ECEnabler")].checked = patch.checked continue acpi_load = getattr(self.ac, patch.function_name)() @@ -251,22 +251,20 @@ class OCPE: print("OpenCore EFI build complete.") time.sleep(2) - def results(self, hardware_report, smbios_model, kexts): + def results(self, hardware_report, smbios_model): self.u.head("Results") print("") print("Your OpenCore EFI for {} has been built at:".format(hardware_report.get("Motherboard").get("Name"))) print("\t{}".format(self.result_dir)) - for kext in kexts: - if kext.name == "USBInjectAll": - if kext.checked: - print("\033[0;31mNote: USBInjectAll is not recommended. Please use USBMap.kext instead.\033[0m") - print("") - print("To use USBMap.kext:") - print("") - print("* Remove USBInjectAll.kext from the {} folder.".format("EFI\\OC\\Kexts" if os.name == "nt" else "EFI/OC/Kexts")) - else: - print("") - print("Before using EFI, please complete the following steps:") + if self.k.kexts[self.k.kext_data.kext_index_by_name("USBInjectAll")].checked: + print("\033[0;31mNote: USBInjectAll is not recommended. Please use USBMap.kext instead.\033[0m") + print("") + print("To use USBMap.kext:") + print("") + print("* Remove USBInjectAll.kext from the {} folder.".format("EFI\\OC\\Kexts" if os.name == "nt" else "EFI/OC/Kexts")) + else: + print("") + print("Before using EFI, please complete the following steps:") print("") print("* Use USBToolBox:") print(" - Mapping USB with the option 'Use Native Class' enabled.") @@ -363,7 +361,7 @@ class OCPE: continue self.build_opencore_efi(customized_hardware, disabled_devices, smbios_model, macos_version, needs_oclp) - self.results(customized_hardware, smbios_model, self.k.kexts) + self.results(customized_hardware, smbios_model) if __name__ == '__main__': update_flag = updater.Updater().run_update() diff --git a/Scripts/config_prodigy.py b/Scripts/config_prodigy.py index e9ea911..5c1bbdd 100644 --- a/Scripts/config_prodigy.py +++ b/Scripts/config_prodigy.py @@ -1,7 +1,7 @@ from Scripts.datasets import chipset_data from Scripts.datasets import cpu_data from Scripts.datasets import mac_model_data -from Scripts.datasets import os_data +from Scripts.datasets import kext_data from Scripts.datasets import pci_data from Scripts.datasets import codec_layouts from Scripts import gathering_files @@ -404,18 +404,16 @@ class ConfigProdigy: def block_kext_bundle(self, kexts): kernel_block = [] - for kext in kexts: - if kext.checked: - if kext.name == "IOSkywalkFamily": - kernel_block.append({ - "Arch": "x86_64", - "Comment": "Allow IOSkywalk Downgrade", - "Enabled": True, - "Identifier": "com.apple.iokit.IOSkywalkFamily", - "MaxKernel": "", - "MinKernel": "23.0.0", - "Strategy": "Exclude" - }) + if kexts[kext_data.kext_index_by_name("IOSkywalkFamily")].checked: + kernel_block.append({ + "Arch": "x86_64", + "Comment": "Allow IOSkywalk Downgrade", + "Enabled": True, + "Identifier": "com.apple.iokit.IOSkywalkFamily", + "MaxKernel": "", + "MinKernel": "23.0.0", + "Strategy": "Exclude" + }) return kernel_block @@ -455,30 +453,28 @@ class ConfigProdigy: if any(network_props.get("Device ID") in pci_data.AquantiaAqtionIDs for network_props in networks.values()): kernel_patch.extend(self.g.get_kernel_patches("Aquantia macOS Patches", self.g.aquantia_macos_patches_url)) - for kext in kexts: - if kext.checked: - if kext.name == "CpuTopologyRebuild": - kernel_patch.extend(self.g.get_kernel_patches("Hyper Threading Patches", self.g.hyper_threading_patches_url)) - elif kext.name == "ForgedInvariant": - if not "AMD" in cpu_manufacturer: - kernel_patch.extend(self.g.get_kernel_patches("AMD Vanilla Patches", self.g.amd_vanilla_patches_url)[-6:-4]) - elif kext.name == "CatalinaBCM5701Ethernet": - kernel_patch.append({ - "Arch": "Any", - "Base": "", - "Comment": "Broadcom BCM577XX Patch", - "Count": 1, - "Enabled": True, - "Find": self.utils.hex_to_bytes("E8CA9EFFFF66898300050000"), - "Identifier": "com.apple.iokit.CatalinaBCM5701Ethernet", - "Limit": 0, - "Mask": self.utils.hex_to_bytes(""), - "MaxKernel": "", - "MinKernel": "20.0.0", - "Replace": self.utils.hex_to_bytes("B8B416000066898300050000"), - "ReplaceMask": self.utils.hex_to_bytes(""), - "Skip": 0 - }) + if kexts[kext_data.kext_index_by_name("CpuTopologyRebuild")].checked: + kernel_patch.extend(self.g.get_kernel_patches("Hyper Threading Patches", self.g.hyper_threading_patches_url)) + elif kexts[kext_data.kext_index_by_name("ForgedInvariant")].checked: + if not "AMD" in cpu_manufacturer: + kernel_patch.extend(self.g.get_kernel_patches("AMD Vanilla Patches", self.g.amd_vanilla_patches_url)[-6:-4]) + elif kexts[kext_data.kext_index_by_name("CatalinaBCM5701Ethernet")].checked: + kernel_patch.append({ + "Arch": "Any", + "Base": "", + "Comment": "Broadcom BCM577XX Patch", + "Count": 1, + "Enabled": True, + "Find": self.utils.hex_to_bytes("E8CA9EFFFF66898300050000"), + "Identifier": "com.apple.iokit.CatalinaBCM5701Ethernet", + "Limit": 0, + "Mask": self.utils.hex_to_bytes(""), + "MaxKernel": "", + "MinKernel": "20.0.0", + "Replace": self.utils.hex_to_bytes("B8B416000066898300050000"), + "ReplaceMask": self.utils.hex_to_bytes(""), + "Skip": 0 + }) for patch in kernel_patch: if "AppleEthernetAquantiaAqtion" in patch["Identifier"]: @@ -691,42 +687,42 @@ class ConfigProdigy: config["UEFI"]["Quirks"]["UnblockFsConnect"] = "HP " in hardware_report.get("Motherboard").get("Name") config["UEFI"]["ReservedMemory"] = [] - for kext in kexts: - if kext.checked: - if kext.name == "BlueToolFixup": - config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["bluetoothExternalDongleFailed"] = self.utils.hex_to_bytes("00") - config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["bluetoothInternalControllerInfo"] = self.utils.hex_to_bytes("0000000000000000000000000000") - elif kext.name == "USBInjectAll": - config["Kernel"]["Quirks"]["XhciPortLimit"] = True - elif kext.name == "RestrictEvents": - revpatch = [] - revblock = [] - if self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("23.0.0") or \ - len(config["Booter"]["Patch"]) and self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("20.4.0"): - revpatch.append("sbvmm") - if not (" Core" in hardware_report.get("CPU").get("Processor Name") and \ - self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), start=5)): - config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revcpu"] = 1 - config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revcpuname"] = hardware_report.get("CPU").get("Processor Name") - if self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("23.0.0"): - revpatch.append("cpuname") - config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537 if int(hardware_report.get("CPU").get("Core Count")) < 8 else 3841 - if "Intel" in hardware_report.get("CPU").get("Manufacturer") and \ - "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type"): - intergrated_gpu = list(hardware_report.get("GPU").items())[-1][-1] - if intergrated_gpu.get("OCLP Compatibility"): - config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Settings"] = "-allow_amfi" - if self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("20.4.0"): - if intergrated_gpu.get("Codename") in ("Broadwell", "Haswell", "Ivy Bridge", "Sandy Bridge"): - revblock.append("media") - if intergrated_gpu.get("Codename") in ("Kaby Lake", "Skylake", "Broadwell", "Haswell"): - revpatch.append("asset") - elif intergrated_gpu.get("Codename") in ("Ivy Bridge", "Sandy Bridge"): - revpatch.append("f16c") - if revpatch: - config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revpatch"] = ",".join(revpatch) - if revblock: - config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revblock"] = ",".join(revblock) + if kexts[kext_data.kext_index_by_name("BlueToolFixup")].checked: + config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["bluetoothExternalDongleFailed"] = self.utils.hex_to_bytes("00") + config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["bluetoothInternalControllerInfo"] = self.utils.hex_to_bytes("0000000000000000000000000000") + + if kexts[kext_data.kext_index_by_name("USBInjectAll")].checked: + config["Kernel"]["Quirks"]["XhciPortLimit"] = True + + if kexts[kext_data.kext_index_by_name("RestrictEvents")].checked: + revpatch = [] + revblock = [] + if self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("23.0.0") or \ + len(config["Booter"]["Patch"]) and self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("20.4.0"): + revpatch.append("sbvmm") + if not (" Core" in hardware_report.get("CPU").get("Processor Name") and \ + self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), start=5)): + config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revcpu"] = 1 + config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revcpuname"] = hardware_report.get("CPU").get("Processor Name") + if self.utils.parse_darwin_version(macos_version) > self.utils.parse_darwin_version("23.0.0"): + revpatch.append("cpuname") + config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537 if int(hardware_report.get("CPU").get("Core Count")) < 8 else 3841 + if "Intel" in hardware_report.get("CPU").get("Manufacturer") and \ + "Integrated GPU" in list(hardware_report.get("GPU").items())[-1][-1].get("Device Type"): + intergrated_gpu = list(hardware_report.get("GPU").items())[-1][-1] + if intergrated_gpu.get("OCLP Compatibility"): + config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["OCLP-Settings"] = "-allow_amfi" + if self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("20.4.0"): + if intergrated_gpu.get("Codename") in ("Broadwell", "Haswell", "Ivy Bridge", "Sandy Bridge"): + revblock.append("media") + if intergrated_gpu.get("Codename") in ("Kaby Lake", "Skylake", "Broadwell", "Haswell"): + revpatch.append("asset") + elif intergrated_gpu.get("Codename") in ("Ivy Bridge", "Sandy Bridge"): + revpatch.append("f16c") + if revpatch: + config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revpatch"] = ",".join(revpatch) + if revblock: + config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"]["revblock"] = ",".join(revblock) config["NVRAM"]["Delete"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"] = list(config["NVRAM"]["Add"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"].keys()) config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] = list(config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].keys()) diff --git a/Scripts/datasets/kext_data.py b/Scripts/datasets/kext_data.py index cc6de32..8df7462 100644 --- a/Scripts/datasets/kext_data.py +++ b/Scripts/datasets/kext_data.py @@ -887,3 +887,5 @@ kexts = [ } ) ] + +kext_index_by_name = {kext.name: index for index, kext in enumerate(kexts)} \ No newline at end of file diff --git a/Scripts/kext_maestro.py b/Scripts/kext_maestro.py index 4d3de33..7b2435f 100644 --- a/Scripts/kext_maestro.py +++ b/Scripts/kext_maestro.py @@ -1,4 +1,3 @@ - from Scripts.datasets import cpu_data from Scripts.datasets import kext_data from Scripts.datasets import os_data @@ -77,12 +76,6 @@ class KextMaestro: return "Xeon" in processor_name return False - - def get_kext_index(self, name): - for index, kext in enumerate(self.kexts): - if kext.name == name: - return index - return None def check_kext(self, index, target_darwin_version, allow_unsupported_kexts=False): kext = self.kexts[index] @@ -93,7 +86,7 @@ class KextMaestro: kext.checked = True for requires_kext_name in kext.requires_kexts: - requires_kext_index = self.get_kext_index(requires_kext_name) + requires_kext_index = kext_data.kext_index_by_name(requires_kext_name) if requires_kext_index: self.check_kext(requires_kext_index, target_darwin_version, allow_unsupported_kexts) @@ -277,7 +270,7 @@ class KextMaestro: selected_kexts.extend(("AppleIntelCPUPowerManagement", "AppleIntelCPUPowerManagementClient")) for name in selected_kexts: - self.check_kext(self.get_kext_index(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version)) + self.check_kext(kext_data.kext_index_by_name(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version)) def install_kexts_to_efi(self, macos_version, kexts_directory): for kext in self.kexts: @@ -302,7 +295,7 @@ class KextMaestro: break else: main_kext = kext_path.split("/")[0] - main_kext_index = self.get_kext_index(main_kext) + main_kext_index = kext_data.kext_index_by_name(main_kext) if not main_kext_index or self.kexts[main_kext_index].checked: if os.path.splitext(os.path.basename(kext_path))[0] in kext.name: source_kext_path = os.path.join(self.ock_files_dir, kext_path) @@ -372,15 +365,15 @@ class KextMaestro: kernel_add = [] unload_kext = [] - if self.kexts[self.get_kext_index("IO80211ElCap")].checked: + if self.kexts[kext_data.kext_index_by_name("IO80211ElCap")].checked: unload_kext.extend(( "AirPortBrcm4331", "AppleAirPortBrcm43224" )) - elif self.kexts[self.get_kext_index("VoodooSMBus")].checked: + elif self.kexts[kext_data.kext_index_by_name("VoodooSMBus")].checked: unload_kext.append("VoodooPS2Mouse") - elif self.kexts[self.get_kext_index("VoodooRMI")].checked: - if not self.kexts[self.get_kext_index("VoodooI2C")].checked: + elif self.kexts[kext_data.kext_index_by_name("VoodooRMI")].checked: + if not self.kexts[kext_data.kext_index_by_name("VoodooI2C")].checked: unload_kext.append("RMII2C") else: unload_kext.extend(( @@ -414,7 +407,7 @@ class KextMaestro: bundle["MaxKernel"] = os_data.get_latest_darwin_version() bundle["MinKernel"] = os_data.get_lowest_darwin_version() - kext_index = self.get_kext_index(os.path.splitext(os.path.basename(bundle.get("BundlePath")))[0]) + kext_index = kext_data.kext_index_by_name(os.path.splitext(os.path.basename(bundle.get("BundlePath")))[0]) if kext_index: bundle["MaxKernel"] = self.kexts[kext_index].max_darwin_version diff --git a/Scripts/smbios.py b/Scripts/smbios.py index 7830053..0f6403e 100644 --- a/Scripts/smbios.py +++ b/Scripts/smbios.py @@ -73,7 +73,7 @@ class SMBIOS: selected_kexts.append("NoTouchID") for name in selected_kexts: - kext_maestro.check_kext(kext_maestro.get_kext_index(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version)) + kext_maestro.check_kext(kext_maestro.kext_data.kext_index_by_name(name), macos_version, "Beta" in os_data.get_macos_name_by_darwin(macos_version)) def select_smbios_model(self, hardware_report, macos_version): platform = "NUC" if "NUC" in hardware_report.get("Motherboard").get("Name") else hardware_report.get("Motherboard").get("Platform")