Provide configuration required for using OpenCore Legacy Patcher

Closed #27
This commit is contained in:
Hoang Hong Quan
2024-10-20 06:25:04 +07:00
parent a7e19c0a1b
commit d8511d1710
5 changed files with 110 additions and 39 deletions
+34 -6
View File
@@ -59,8 +59,8 @@ class CompatibilityChecker:
self.utils.request_input("\n\nThe CPU is not compatible with macOS!")
self.utils.exit_program()
self.max_supported_macos_version = max_version
self.min_supported_macos_version = min_version
self.max_native_macos_version = max_version
self.min_native_macos_version = min_version
def discrete_gpu_settings(self, gpu_name, compatibility):
while True:
@@ -88,6 +88,8 @@ class CompatibilityChecker:
max_version = os_data.get_latest_darwin_version()
min_version = os_data.get_lowest_darwin_version()
ocl_patched_max_version = max_version
ocl_patched_min_version = "20.0.0"
if "Intel" in gpu_manufacturer:
if device_id.startswith("01") and not device_id[-2] in ("5", "6") and not device_id in ("0102", "0106", "010A"):
@@ -113,6 +115,7 @@ class CompatibilityChecker:
if "Navi 2" in gpu_codename:
if not "AVX2" in self.hardware_report.get("CPU").get("SIMD Features"):
max_version = "21.99.99"
ocl_patched_max_version = max_version
else:
if gpu_codename in ("Navi 23", "Navi 22"):
min_version = "21.2.0"
@@ -121,10 +124,19 @@ class CompatibilityChecker:
else:
max_version = min_version = None
elif "Navi 1" in gpu_codename:
if not "AVX2" in self.hardware_report.get("CPU").get("SIMD Features"):
max_version = "21.99.99"
ocl_patched_min_version = "22.0.0"
min_version = "19.0.0"
elif "Vega 20" in gpu_codename:
if not "AVX2" in self.hardware_report.get("CPU").get("SIMD Features"):
max_version = "21.99.99"
ocl_patched_min_version = "22.0.0"
min_version = "18.6.0"
elif gpu_codename in ("Vega 10", "Polaris 22", "Polaris 20", "Baffin", "Ellesmere") or device_id == "699F":
if not "AVX2" in self.hardware_report.get("CPU").get("SIMD Features"):
max_version = "21.99.99"
ocl_patched_min_version = "22.0.0"
min_version = "17.0.0"
elif self.utils.contains_any(gpu_data.AMDCodenames, gpu_codename):
max_version = "21.99.99"
@@ -147,6 +159,9 @@ class CompatibilityChecker:
gpu_props["Compatibility"] = (None, None)
else:
gpu_props["Compatibility"] = (max_version, min_version)
if max_version != ocl_patched_max_version:
gpu_props["OCLP Compatibility"] = (ocl_patched_max_version, ocl_patched_min_version if self.utils.parse_darwin_version(ocl_patched_min_version) > self.utils.parse_darwin_version("{}.{}.{}".format(int(max_version[:2]) + 1, 0, 0)) else "{}.{}.{}".format(int(max_version[:2]) + 1, 0, 0))
self.ocl_patched_macos_version = (ocl_patched_max_version, self.ocl_patched_macos_version[-1] if self.ocl_patched_macos_version and self.utils.parse_darwin_version(self.ocl_patched_macos_version[-1]) < self.utils.parse_darwin_version(gpu_props.get("OCLP Compatibility")[-1]) else gpu_props.get("OCLP Compatibility")[-1])
print("{}- {}: {}{}".format(
" "*3,
@@ -205,6 +220,8 @@ class CompatibilityChecker:
max_version = os_data.get_latest_darwin_version()
min_version = os_data.get_lowest_darwin_version()
ocl_patched_max_version = max_version
ocl_patched_min_version = "23.0.0"
if bus_type.startswith("PCI"):
if device_id in ("8086-125B", "8086-125C", "8086-125D", "8086-3102"):
@@ -217,6 +234,10 @@ class CompatibilityChecker:
else:
if pci_data.NetworkIDs.index(device_id) < 108:
if device_id == primary_wifi_device:
if device_id in ("14E4-43A0", "14E4-43A3", "14E4-43BA"):
max_version = "22.99.99"
device_props["OCLP Compatibility"] = (ocl_patched_max_version, ocl_patched_min_version)
self.ocl_patched_macos_version = (ocl_patched_max_version, self.ocl_patched_macos_version[-1] if self.ocl_patched_macos_version and self.utils.parse_darwin_version(self.ocl_patched_macos_version[-1]) < self.utils.parse_darwin_version(device_props.get("OCLP Compatibility")[-1]) else device_props.get("OCLP Compatibility")[-1])
device_props["Compatibility"] = (max_version, min_version)
primary_wifi_device = None
else:
@@ -252,6 +273,7 @@ class CompatibilityChecker:
def get_unsupported_devices(self, macos_verison):
new_hardware_report = {}
unsupported_device = {}
needs_oclp = False
for device_type, devices in self.hardware_report.items():
if device_type in ("Motherboard", "CPU", "USB Controllers", "Input", "Bluetooth", "System Devices"):
@@ -261,6 +283,11 @@ class CompatibilityChecker:
new_hardware_report[device_type] = {}
for device_name, device_props in devices.items():
if device_props.get("OCLP Compatibility") and self.utils.parse_darwin_version(device_props.get("OCLP Compatibility")[0]) >= self.utils.parse_darwin_version(macos_verison) >= self.utils.parse_darwin_version(device_props.get("OCLP Compatibility")[-1]):
new_hardware_report[device_type][device_name] = device_props
needs_oclp = True
continue
device_compatibility = device_props.get("Compatibility")
if device_compatibility:
@@ -274,10 +301,11 @@ class CompatibilityChecker:
if not new_hardware_report[device_type]:
del new_hardware_report[device_type]
return new_hardware_report, unsupported_device
return new_hardware_report, unsupported_device, needs_oclp
def check_compatibility(self, hardware_report):
self.hardware_report = hardware_report
self.ocl_patched_macos_version = None
self.utils.head("Compatibility Checker")
print()
@@ -324,11 +352,11 @@ class CompatibilityChecker:
self.utils.request_input("\n\nNo compatible GPU card for macOS was found!")
self.utils.exit_program()
self.max_supported_macos_version = max_supported_gpu_version if self.utils.parse_darwin_version(max_supported_gpu_version) < self.utils.parse_darwin_version(self.max_supported_macos_version) else self.max_supported_macos_version
self.min_supported_macos_version = min_supported_gpu_version if self.utils.parse_darwin_version(min_supported_gpu_version) > self.utils.parse_darwin_version(self.min_supported_macos_version) else self.min_supported_macos_version
self.max_native_macos_version = max_supported_gpu_version if self.utils.parse_darwin_version(max_supported_gpu_version) < self.utils.parse_darwin_version(self.max_native_macos_version) else self.max_native_macos_version
self.min_native_macos_version = min_supported_gpu_version if self.utils.parse_darwin_version(min_supported_gpu_version) > self.utils.parse_darwin_version(self.min_native_macos_version) else self.min_native_macos_version
if discrete_gpu_mode == "Unknown":
print("")
self.utils.request_input()
return (self.min_supported_macos_version, self.max_supported_macos_version), *self.get_unsupported_devices(self.max_supported_macos_version)
return (self.min_native_macos_version, self.max_native_macos_version), *self.get_unsupported_devices(self.max_native_macos_version), self.ocl_patched_macos_version
+41 -11
View File
@@ -368,7 +368,7 @@ class ConfigProdigy:
return kernel_patch
def boot_args(self, hardware_report, macos_version, kexts, resize_bar):
def boot_args(self, hardware_report, macos_version, needs_oclp, kexts, resize_bar):
boot_args = [
"-v",
"debug=0x100",
@@ -391,8 +391,12 @@ class ConfigProdigy:
self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("20.0.0"):
boot_args.append("-cdfon")
if "Intel" in hardware_report.get("CPU").get("Manufacturer"):
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]
if needs_oclp and intergrated_gpu[-1].get("OCLP Compatibility"):
boot_args.append("ipc_control_port_options=0")
if intergrated_gpu[-1].get("Device ID")[5:].startswith(("3E", "87", "9B")) and \
self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("19.4.0"):
boot_args.append("igfxonln=1")
@@ -420,6 +424,12 @@ class ConfigProdigy:
if discrete_gpu.get("Device ID") in ("1002-67B0", "1002-67B1", "1002-67B8", "1002-6810", "1002-6811"):
boot_args.append("-raddvi")
if needs_oclp:
if discrete_gpu.get("Manufacturer") == "AMD":
boot_args.append("-radvesa")
elif discrete_gpu.get("Manufacturer") == "NVIDIA":
boot_args.extend(("nvda_drv_vrl=1", "ngfxcompat=1", "ngfxgl=1"))
elif kext.name == "AppleALC":
if hardware_report.get("Sound"):
codec_id = list(hardware_report.get("Sound").items())[0][-1].get("Device ID")
@@ -431,10 +441,6 @@ class ConfigProdigy:
boot_args.append("-vi2c-force-polling")
elif kext.name == "CpuTopologyRebuild":
boot_args.append("-ctrsmt")
elif kext.name == "RestrictEvents":
if self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("23.0.0"):
boot_args.append("revpatch=sbvmm{}".format(",cpuname" 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=4)) else ""))
return " ".join(boot_args)
@@ -460,7 +466,7 @@ class ConfigProdigy:
return uefi_drivers
def genarate(self, hardware_report, smbios_model, macos_version, kexts, config):
def genarate(self, hardware_report, smbios_model, macos_version, needs_oclp, kexts, config):
del config["#WARNING - 1"]
del config["#WARNING - 2"]
del config["#WARNING - 3"]
@@ -529,12 +535,12 @@ class ConfigProdigy:
config["Misc"]["Entries"] = []
config["Misc"]["Security"]["AllowSetDefault"] = True
config["Misc"]["Security"]["ScanPolicy"] = 0
config["Misc"]["Security"]["SecureBootModel"] = "Default" if self.utils.parse_darwin_version("20.0.0") <= self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("23.0.0") else "Disabled"
config["Misc"]["Security"]["SecureBootModel"] = "Default" if not needs_oclp and self.utils.parse_darwin_version("20.0.0") <= self.utils.parse_darwin_version(macos_version) < self.utils.parse_darwin_version("23.0.0") else "Disabled"
config["Misc"]["Security"]["Vault"] = "Optional"
config["Misc"]["Tools"] = []
del config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["#INFO (prev-lang:kbd)"]
config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] = self.boot_args(hardware_report, macos_version, kexts, config["Booter"]["Quirks"]["ResizeAppleGpuBars"] == 0)
config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] = self.boot_args(hardware_report, macos_version, needs_oclp, kexts, config["Booter"]["Quirks"]["ResizeAppleGpuBars"] == 0)
config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["csr-active-config"] = self.utils.hex_to_bytes(self.csr_active_config(macos_version))
config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["prev-lang:kbd"] = "en:252"
config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].append("csr-active-config")
@@ -555,13 +561,37 @@ class ConfigProdigy:
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")
config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"].extend(["bluetoothExternalDongleFailed", "bluetoothInternalControllerInfo"])
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=4)):
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")
config["NVRAM"]["Delete"]["4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102"].extend(["revcpu", "revcpuname"])
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 needs_oclp and 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())
return config
+5 -2
View File
@@ -96,7 +96,7 @@ class KextMaestro:
if other_kext.conflict_group_id == kext.conflict_group_id and other_kext.name != kext.name:
other_kext.checked = False
def select_required_kexts(self, hardware_report, smbios_model, macos_version, acpi_patches):
def select_required_kexts(self, hardware_report, smbios_model, macos_version, needs_oclp, acpi_patches):
for kext in self.kexts:
kext.checked = kext.required
@@ -143,6 +143,9 @@ class KextMaestro:
self.is_intel_hedt_cpu(hardware_report.get("CPU").get("Codename")):
selected_kexts.append("ForgedInvariant")
if needs_oclp:
selected_kexts.extend(("AMFIPass", "RestrictEvents"))
ethernet_pci = None
for network_name, network_props in hardware_report.get("Network", {}).items():
device_id = network_props.get("Device ID")
@@ -150,7 +153,7 @@ class KextMaestro:
if self.utils.contains_any(pci_data.NetworkIDs, device_id, end=21):
if device_id in ["14E4-43A0", "14E4-43A3", "14E4-43BA"]:
if self.utils.parse_darwin_version(macos_version) >= self.utils.parse_darwin_version("23.0.0"):
selected_kexts.extend(("AirportBrcmFixup", "IOSkywalkFamily", "AMFIPass"))
selected_kexts.extend(("AirportBrcmFixup", "IOSkywalkFamily"))
elif device_id in pci_data.NetworkIDs:
selected_kexts.append("AirportBrcmFixup")
elif self.utils.contains_any(pci_data.NetworkIDs, device_id, start=21, end=108):