Improve quirk configuration

This commit is contained in:
Hoang Hong Quan
2024-11-10 09:54:08 +07:00
parent 706f33a909
commit e2ff7d1eef
+15 -22
View File
@@ -61,11 +61,6 @@ class ConfigProdigy:
return booter_patch return booter_patch
def check_mats_support(self, cpu_manufacturer, motherboard_chipset):
return "AMD" in cpu_manufacturer or \
not self.utils.contains_any(chipset_data.IntelChipsets, motherboard_chipset, start=101) is None or \
not self.utils.contains_any(chipset_data.IntelChipsets, motherboard_chipset, start=79, end=89) is None
def is_low_end_intel_cpu(self, processor_name): def is_low_end_intel_cpu(self, processor_name):
return any(cpu_branding in processor_name for cpu_branding in ("Celeron", "Pentium")) return any(cpu_branding in processor_name for cpu_branding in ("Celeron", "Pentium"))
@@ -326,10 +321,10 @@ class ConfigProdigy:
return kernel_block return kernel_block
def is_low_end_haswell_plus(self, processor_name, cpu_codename): def is_low_end_haswell_plus(self, processor_name, cpu_codename):
return self.is_low_end_intel_cpu(processor_name) and not self.utils.contains_any(cpu_data.IntelCPUGenerations, cpu_codename, end=38) is None return self.is_low_end_intel_cpu(processor_name) and cpu_codename in cpu_data.IntelCPUGenerations[:38]
def is_intel_hedt_cpu(self, cpu_codename): def is_intel_hedt_cpu(self, cpu_codename):
return not self.utils.contains_any(cpu_data.IntelCPUGenerations, cpu_codename, start=21) is None and cpu_codename.endswith(("-X", "-P", "-W", "-E", "-EP", "-EX")) return cpu_codename in cpu_data.IntelCPUGenerations[21:] and cpu_codename.endswith(("-X", "-P", "-W", "-E", "-EP", "-EX"))
def spoof_cpuid(self, processor_name, cpu_codename, macos_version): def spoof_cpuid(self, processor_name, cpu_codename, macos_version):
if self.is_low_end_haswell_plus(processor_name, cpu_codename): if self.is_low_end_haswell_plus(processor_name, cpu_codename):
@@ -503,18 +498,17 @@ class ConfigProdigy:
config["Booter"]["MmioWhitelist"] = self.mmio_whitelist(hardware_report.get("Motherboard").get("Chipset")) config["Booter"]["MmioWhitelist"] = self.mmio_whitelist(hardware_report.get("Motherboard").get("Chipset"))
config["Booter"]["Patch"] = self.add_booter_patch(smbios_model, macos_version) config["Booter"]["Patch"] = self.add_booter_patch(smbios_model, macos_version)
config["Booter"]["Quirks"]["DevirtualiseMmio"] = self.check_mats_support(hardware_report.get("CPU").get("Manufacturer"), hardware_report.get("Motherboard").get("Chipset")) config["Booter"]["Quirks"]["DevirtualiseMmio"] = len(config["Booter"]["MmioWhitelist"]) != 0 or \
if "AMD" in hardware_report.get("CPU").get("Manufacturer") and not "TRX40" in hardware_report.get("Motherboard").get("Chipset"): hardware_report.get("Motherboard").get("Chipset") in chipset_data.IntelChipsets[101:] + chipset_data.IntelChipsets[79:89] or \
config["Booter"]["Quirks"]["DevirtualiseMmio"] = False hardware_report.get("Motherboard").get("Chipset") in chipset_data.IntelChipsets[93:101] and ("Desktop" in hardware_report.get("Motherboard").get("Platform") or not "-8" in hardware_report.get("CPU").get("Processor Name")) or \
config["Booter"]["Quirks"]["DevirtualiseMmio"] = len(config["Booter"]["MmioWhitelist"]) != 0 or config["Booter"]["Quirks"]["DevirtualiseMmio"] hardware_report.get("Motherboard").get("Chipset") == chipset_data.AMDChipsets[16]
config["Booter"]["Quirks"]["EnableWriteUnprotector"] = False if "AMD" in hardware_report.get("CPU").get("Manufacturer") else not config["Booter"]["Quirks"]["DevirtualiseMmio"] config["Booter"]["Quirks"]["EnableWriteUnprotector"] = not ("AMD" in hardware_report.get("CPU").get("Manufacturer") or hardware_report.get("Motherboard").get("Chipset") in chipset_data.IntelChipsets[79:89] + chipset_data.IntelChipsets[101:])
config["Booter"]["Quirks"]["ProtectUefiServices"] = "Z390" in hardware_report.get("Motherboard").get("Chipset") or \ config["Booter"]["Quirks"]["ProtectUefiServices"] = hardware_report.get("Motherboard").get("Chipset") in chipset_data.IntelChipsets[101:] or \
not self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), end=14) is None hardware_report.get("Motherboard").get("Chipset") in chipset_data.IntelChipsets[93:101] and (not "-8" in hardware_report.get("CPU").get("Processor Name") or hardware_report.get("Motherboard").get("Chipset") == chipset_data.IntelChipsets[98])
config["Booter"]["Quirks"]["RebuildAppleMemoryMap"] = not config["Booter"]["Quirks"]["EnableWriteUnprotector"] config["Booter"]["Quirks"]["RebuildAppleMemoryMap"] = not config["Booter"]["Quirks"]["EnableWriteUnprotector"]
config["Booter"]["Quirks"]["ResizeAppleGpuBars"] = 0 if any(gpu_props.get("Resizable BAR", "Disabled") == "Enabled" for gpu_name, gpu_props in hardware_report.get("GPU", {}).items()) else -1 config["Booter"]["Quirks"]["ResizeAppleGpuBars"] = 0 if any(gpu_props.get("Resizable BAR", "Disabled") == "Enabled" for gpu_name, gpu_props in hardware_report.get("GPU", {}).items()) else -1
config["Booter"]["Quirks"]["SetupVirtualMap"] = not (hardware_report.get("Motherboard").get("Chipset") == "TRX40" or \ config["Booter"]["Quirks"]["SetupVirtualMap"] = not hardware_report.get("Motherboard").get("Chipset") in chipset_data.AMDChipsets[11:17] + chipset_data.IntelChipsets[79:89]
"ASUS" in hardware_report.get("Motherboard").get("Name") and self.is_intel_hedt_cpu(hardware_report.get("CPU").get("Codename")) and config["Booter"]["Quirks"]["DevirtualiseMmio"]) config["Booter"]["Quirks"]["SyncRuntimePermissions"] = "AMD" in hardware_report.get("CPU").get("Manufacturer") or hardware_report.get("Motherboard").get("Chipset") in chipset_data.IntelChipsets[79:89] + chipset_data.IntelChipsets[93:]
config["Booter"]["Quirks"]["SyncRuntimePermissions"] = config["Booter"]["Quirks"]["RebuildAppleMemoryMap"]
config["DeviceProperties"]["Add"] = self.deviceproperties(hardware_report, macos_version, kexts) config["DeviceProperties"]["Add"] = self.deviceproperties(hardware_report, macos_version, kexts)
@@ -538,16 +532,15 @@ class ConfigProdigy:
list(hardware_report.get("GPU").items())[0][-1].get("Manufacturer"), list(hardware_report.get("GPU").items())[0][-1].get("Manufacturer"),
kexts kexts
) )
config["Kernel"]["Quirks"]["AppleCpuPmCfgLock"] = not self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), start=38) is None config["Kernel"]["Quirks"]["AppleCpuPmCfgLock"] = bool(self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), start=38))
config["Kernel"]["Quirks"]["AppleXcpmCfgLock"] = False if "AMD" in hardware_report.get("CPU").get("Manufacturer") else not config["Kernel"]["Quirks"]["AppleCpuPmCfgLock"] config["Kernel"]["Quirks"]["AppleXcpmCfgLock"] = False if "AMD" in hardware_report.get("CPU").get("Manufacturer") else not config["Kernel"]["Quirks"]["AppleCpuPmCfgLock"]
config["Kernel"]["Quirks"]["AppleXcpmExtraMsrs"] = "-E" in hardware_report.get("CPU").get("Codename") and not self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), start=26) is None config["Kernel"]["Quirks"]["AppleXcpmExtraMsrs"] = "-E" in hardware_report.get("CPU").get("Codename") and hardware_report.get("CPU").get("Codename") in cpu_data.IntelCPUGenerations[26:]
config["Kernel"]["Quirks"]["CustomSMBIOSGuid"] = True config["Kernel"]["Quirks"]["CustomSMBIOSGuid"] = True
config["Kernel"]["Quirks"]["DisableIoMapper"] = not "AMD" in hardware_report.get("CPU").get("Manufacturer") config["Kernel"]["Quirks"]["DisableIoMapper"] = not "AMD" in hardware_report.get("CPU").get("Manufacturer")
config["Kernel"]["Quirks"]["DisableRtcChecksum"] = "ASUS" in hardware_report.get("Motherboard").get("Name") or "HP " in hardware_report.get("Motherboard").get("Name") config["Kernel"]["Quirks"]["DisableRtcChecksum"] = "ASUS" in hardware_report.get("Motherboard").get("Name") or "HP " in hardware_report.get("Motherboard").get("Name")
config["Kernel"]["Quirks"]["LapicKernelPanic"] = "HP " in hardware_report.get("Motherboard").get("Name") config["Kernel"]["Quirks"]["LapicKernelPanic"] = "HP " in hardware_report.get("Motherboard").get("Name")
config["Kernel"]["Quirks"]["PanicNoKextDump"] = config["Kernel"]["Quirks"]["PowerTimeoutKernelPanic"] = True config["Kernel"]["Quirks"]["PanicNoKextDump"] = config["Kernel"]["Quirks"]["PowerTimeoutKernelPanic"] = True
config["Kernel"]["Quirks"]["ProvideCurrentCpuInfo"] = "AMD" in hardware_report.get("CPU").get("Manufacturer") or \ config["Kernel"]["Quirks"]["ProvideCurrentCpuInfo"] = "AMD" in hardware_report.get("CPU").get("Manufacturer") or hardware_report.get("CPU").get("Codename") in cpu_data.IntelCPUGenerations[:2]
not self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), end=2) is None
config["Misc"]["BlessOverride"] = [] config["Misc"]["BlessOverride"] = []
config["Misc"]["Boot"]["HideAuxiliary"] = False config["Misc"]["Boot"]["HideAuxiliary"] = False
@@ -576,7 +569,7 @@ class ConfigProdigy:
config["UEFI"]["APFS"]["MinDate"] = config["UEFI"]["APFS"]["MinVersion"] = -1 config["UEFI"]["APFS"]["MinDate"] = config["UEFI"]["APFS"]["MinVersion"] = -1
config["UEFI"]["Drivers"] = self.load_drivers() config["UEFI"]["Drivers"] = self.load_drivers()
config["UEFI"]["Quirks"]["IgnoreInvalidFlexRatio"] = not self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_report.get("CPU").get("Codename"), start=26) is None config["UEFI"]["Quirks"]["IgnoreInvalidFlexRatio"] = hardware_report.get("CPU").get("Codename") in cpu_data.IntelCPUGenerations[26:]
config["UEFI"]["Quirks"]["ReleaseUsbOwnership"] = True config["UEFI"]["Quirks"]["ReleaseUsbOwnership"] = True
config["UEFI"]["Quirks"]["UnblockFsConnect"] = "HP " in hardware_report.get("Motherboard").get("Name") config["UEFI"]["Quirks"]["UnblockFsConnect"] = "HP " in hardware_report.get("Motherboard").get("Name")
config["UEFI"]["ReservedMemory"] = [] config["UEFI"]["ReservedMemory"] = []