MCPcopy Index your code
hub / github.com/lzhoang2801/OpCore-Simplify / load_kernel_patch

Method load_kernel_patch

Scripts/config_prodigy.py:447–503  ·  view source on GitHub ↗
(self, motherboard_chipset, cpu_manufacturer, cpu_codename, cpu_cores, gpu_manufacturer, networks, macos_version, kexts, provide_current_cpu_info)

Source from the content-addressed store, hash-verified

445 return None
446
447 def load_kernel_patch(self, motherboard_chipset, cpu_manufacturer, cpu_codename, cpu_cores, gpu_manufacturer, networks, macos_version, kexts, provide_current_cpu_info):
448 kernel_patch = []
449
450 if "AMD" in cpu_manufacturer:
451 kernel_patch.extend(self.g.get_kernel_patches("AMD Vanilla Patches", self.g.amd_vanilla_patches_url))
452
453 if any(network_props.get("Device ID") in pci_data.AquantiaAqtionIDs for network_props in networks.values()):
454 kernel_patch.extend(self.g.get_kernel_patches("Aquantia macOS Patches", self.g.aquantia_macos_patches_url))
455
456 if provide_current_cpu_info and kexts[kext_data.kext_index_by_name.get("CpuTopologyRebuild")].checked:
457 kernel_patch.extend(self.g.get_kernel_patches("Hyper Threading Patches", self.g.hyper_threading_patches_url))
458 elif kexts[kext_data.kext_index_by_name.get("ForgedInvariant")].checked:
459 if not "AMD" in cpu_manufacturer:
460 kernel_patch.extend(self.g.get_kernel_patches("AMD Vanilla Patches", self.g.amd_vanilla_patches_url)[-6:-4])
461 elif kexts[kext_data.kext_index_by_name.get("CatalinaBCM5701Ethernet")].checked:
462 kernel_patch.append({
463 "Arch": "Any",
464 "Base": "",
465 "Comment": "Broadcom BCM577XX Patch",
466 "Count": 1,
467 "Enabled": True,
468 "Find": self.utils.hex_to_bytes("E8CA9EFFFF66898300050000"),
469 "Identifier": "com.apple.iokit.CatalinaBCM5701Ethernet",
470 "Limit": 0,
471 "Mask": self.utils.hex_to_bytes(""),
472 "MaxKernel": "",
473 "MinKernel": "20.0.0",
474 "Replace": self.utils.hex_to_bytes("B8B416000066898300050000"),
475 "ReplaceMask": self.utils.hex_to_bytes(""),
476 "Skip": 0
477 })
478
479 latest_darwin_version = (os_data.get_latest_darwin_version(), os_data.get_latest_darwin_version(include_beta=False))
480
481 for patch in kernel_patch:
482 if "AppleEthernetAquantiaAqtion" in patch["Identifier"]:
483 patch["Enabled"] = patch["Base"] != ""
484 elif "cpuid_cores_per_package" in patch["Comment"]:
485 patch["Replace"] = patch["Replace"].hex()
486 patch["Replace"] = self.utils.hex_to_bytes(patch["Replace"][:2] + self.utils.int_to_hex(int(cpu_cores)) + patch["Replace"][4:])
487 elif "IOPCIIsHotplugPort" in patch["Comment"]:
488 if motherboard_chipset in chipset_data.AMDChipsets[17:] or cpu_codename in ("Raphael", "Storm Peak", "Phoenix", "Granite Ridge"):
489 patch["Enabled"] = True
490 elif "_mtrr_update_action" in patch["Comment"]:
491 if "TRX" in motherboard_chipset.upper():
492 patch["Enabled"] = False
493 elif "AMD" in gpu_manufacturer:
494 if "algrey" in patch["Comment"].lower():
495 patch["Enabled"] = False
496 elif "shaneee" in patch["Comment"].lower():
497 patch["Enabled"] = True
498
499 if "Beta" in os_data.get_macos_name_by_darwin(macos_version):
500 if patch["MaxKernel"] in latest_darwin_version:
501 patch["MaxKernel"] = latest_darwin_version[0]
502
503 return kernel_patch
504

Callers 1

genarateMethod · 0.95

Calls 3

get_kernel_patchesMethod · 0.80
hex_to_bytesMethod · 0.80
int_to_hexMethod · 0.80

Tested by

no test coverage detected