Add customizable ACPI patch options and update additional patches

This commit is contained in:
Hoang Hong Quan
2024-09-29 07:44:25 +07:00
parent 9796362b4c
commit 03811eff62
6 changed files with 1435 additions and 1383 deletions

View File

@@ -1,4 +1,5 @@
from Scripts.datasets import os_data
from Scripts import acpi_guru
from Scripts import aida64
from Scripts import compatibility_checker
from Scripts import efi_builder
@@ -14,6 +15,7 @@ class OCPE:
def __init__(self):
self.u = utils.Utils("OpCore Simplify")
self.o = gathering_files.gatheringFiles()
self.ac = acpi_guru.ACPIGuru()
self.a = aida64.AIDA64()
self.c = compatibility_checker.CompatibilityChecker()
self.b = efi_builder.builder()
@@ -178,15 +180,22 @@ class OCPE:
print("")
print("1. Select Hardware Report")
print("2. Select macOS Version")
print("3. Customize SMBIOS Model")
print("4. Build OpenCore EFI")
print("3. Customize ACPI Patch")
print("4. Customize SMBIOS Model")
print("5. Build OpenCore EFI")
print("")
print("Q. Quit")
print("")
option = self.u.request_input("Select an option: ")
if option.lower() == "q":
self.u.exit_program()
if option == "1":
try:
option = int(option)
except:
continue
if option == 1:
hardware_report_path, hardware_report = self.select_hardware_report()
self.show_hardware_report(hardware_report)
supported_macos_version, unsupported_devices = self.compatibility_check(hardware_report)
@@ -194,20 +203,26 @@ class OCPE:
if int(macos_version[:2]) == os_data.macos_versions[-1].darwin_version and os_data.macos_versions[-1].release_status == "beta":
macos_version = str(int(macos_version[:2]) - 1) + macos_version[2:]
smbios_model = self.s.select_smbios_model(hardware_report, macos_version)
try:
hardware_report
self.ac.select_acpi_tables()
self.ac.select_acpi_patches(hardware_report, unsupported_devices, smbios_model)
elif option < 6:
try:
hardware_report
except:
self.u.request_input("\nPlease select a hardware report to proceed")
continue
if option == "2":
macos_version = self.select_macos_version(supported_macos_version)
smbios_model = self.s.select_smbios_model(hardware_report, macos_version)
elif option == "3":
self.ac.customize_patch_selection(hardware_report, unsupported_devices, smbios_model)
elif option == "4":
smbios_model = self.s.customize_smbios_model(hardware_report, smbios_model, macos_version)
if option == "4":
elif option == "5":
self.gathering_files()
self.b.build_efi(hardware_report, unsupported_devices, smbios_model, macos_version)
self.b.build_efi(hardware_report, unsupported_devices, smbios_model, macos_version, self.ac)
self.show_result(hardware_report)
except:
self.u.request_input("\nPlease select a hardware report to proceed")
if __name__ == '__main__':
o = OCPE()

File diff suppressed because it is too large Load Diff

View File

@@ -257,9 +257,10 @@ class ConfigProdigy:
del config["#WARNING - 2"]
del config["#WARNING - 3"]
del config["#WARNING - 4"]
config["ACPI"]["Add"] = efi_option.get("ACPI").get("Add")
config["ACPI"]["Delete"] = efi_option.get("ACPI").get("Delete")
config["ACPI"]["Patch"] = efi_option.get("ACPI").get("Patch")
config["ACPI"]["Add"] = []
config["ACPI"]["Delete"] = []
config["ACPI"]["Patch"] = []
config["Booter"]["MmioWhitelist"] = self.mmio_whitelist(hardware.get("Motherboard Chipset"))
config["Booter"]["Patch"] = self.add_booter_patch(efi_option.get("SMBIOS"), efi_option.get("macOS Version"))
@@ -280,7 +281,7 @@ class ConfigProdigy:
config["DeviceProperties"]["Add"] = self.deviceproperties(hardware.get("CPU Codename"), hardware.get("Intel MEI"), efi_option.get("iGPU Properties"))
config["Kernel"]["Add"] = efi_option.get("Kernel_Add")
config["Kernel"]["Add"] = []
config["Kernel"]["Block"] = self.block_kext_bundle(hardware.get("Network"), efi_option.get("macOS Version"))
spoof_cpuid = self.spoof_cpuid(
hardware.get("Processor Name"),

View File

@@ -16,6 +16,11 @@ patches = [
description = "Avoid kernel panic by pointing the first CPU entry to an active CPU on HEDT systems",
function_name = "fix_apic_processor_id"
),
PatchInfo(
name = "BATP",
description = "Enables displaying the battery percentage on laptops",
function_name = "battery_status_patch"
),
PatchInfo(
name = "BUS0",
description = "Add a System Management Bus device to fix AppleSMBus issues",

View File

@@ -1,5 +1,4 @@
from Scripts.datasets import cpu_data
from Scripts import acpi_guru
from Scripts import config_prodigy
from Scripts import kext_maestro
from Scripts import utils
@@ -9,7 +8,6 @@ import re
class builder:
def __init__(self):
self.acpi = acpi_guru.ACPIGuru()
self.config = config_prodigy.ConfigProdigy()
self.kext = kext_maestro.KextMaestro()
self.utils = utils.Utils()
@@ -296,10 +294,13 @@ class builder:
print("")
self.utils.request_input()
def build_efi(self, hardware, unsupported_devices, smbios_model, macos_version):
def build_efi(self, hardware, unsupported_devices, smbios_model, macos_version, acpi_guru):
efi_directory = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "Results")
self.utils.create_folder(efi_directory, remove_content=True)
forbidden_chars = r'[<>:"/\\|?*]'
self.utils.write_file(os.path.join(efi_directory, re.sub(forbidden_chars, '_', hardware.get("Motherboard").get("Motherboard Name")) + ".json"), hardware)
if not os.path.exists(self.kext.ock_files_dir):
raise Exception("Directory '{}' does not exist.".format(self.kext.ock_files_dir))
@@ -327,13 +328,12 @@ class builder:
hardware_shorc["Codec ID"] = next((device_props.get("Codec ID") for device_name, device_props in hardware.get("Audio").items()), None)
hardware_shorc["SD Controller"] = hardware.get("SD Controller")
hardware_shorc["Input"] = hardware.get("Input")
input_devices = ", ".join(list(hardware_shorc.get("Input", {}).keys()))
hardware_shorc["Touchpad Communication"] = "None" if not "Laptop" in hardware_shorc.get("Platform") else "I2C" if "I2C" in input_devices else "PS2" if "PS2" in input_devices else "None"
hardware_shorc["Storage Controllers"] = hardware.get("Storage Controllers")
hardware_shorc["Intel MEI"] = hardware.get("Intel MEI")
hardware_shorc["Unsupported Devices"] = unsupported_devices
forbidden_chars = r'[<>:"/\\|?*]'
hardware_shorc["Motherboard Name"] = re.sub(forbidden_chars, '_', hardware_shorc["Motherboard Name"])
efi_option = {}
efi_option["macOS Version"] = macos_version
efi_option["Custom CPU Name"] = not (" Core" in hardware_shorc.get("Processor Name") and self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_shorc.get("CPU Codename"), end=12))
@@ -347,26 +347,38 @@ class builder:
hardware_shorc["Integrated GPU Name"],
efi_option.get("macOS Version"))
efi_option["SMBIOS"] = smbios_model
input_devices = ", ".join(list(hardware_shorc.get("Input", {}).keys()))
hardware_shorc["Touchpad Communication"] = "None" if not "Laptop" in hardware_shorc.get("Platform") else "I2C" if "I2C" in input_devices else "PS2" if "PS2" in input_devices else "None"
efi_option["ACPI"] = self.acpi.initialize_patches(
hardware_shorc["Motherboard Name"],
hardware_shorc["Motherboard Chipset"],
hardware_shorc["Platform"],
hardware_shorc["CPU Manufacturer"],
hardware_shorc["CPU Codename"],
hardware_shorc["Integrated GPU"],
hardware_shorc["Discrete GPU"],
hardware_shorc["Network"],
hardware_shorc["Touchpad Communication"],
efi_option.get("SMBIOS"),
hardware_shorc.get("Intel MEI"),
hardware_shorc["Unsupported Devices"],
efi_option.get("macOS Version"),
os.path.join(efi_directory, "EFI", "OC", "ACPI")
)
config_file = os.path.join(efi_directory, "EFI", "OC", "config.plist")
config_data = self.utils.read_file(config_file)
if not config_data:
raise Exception("Error: The file {} does not exist.".format(config_file))
self.config.genarate(hardware_shorc, efi_option, config_data)
acpi_guru.hardware_report = hardware
acpi_guru.unsupported_devices = unsupported_devices
acpi_guru.acpi_directory = os.path.join(efi_directory, "EFI", "OC", "ACPI")
acpi_guru.smbios_model = smbios_model
acpi_guru.get_low_pin_count_bus_device()
for patch in acpi_guru.patches:
if patch.checked:
if patch.name == "BATP":
patch.checked = getattr(acpi_guru, patch.function_name)()
continue
acpi_load = getattr(acpi_guru, patch.function_name)()
if not isinstance(acpi_load, dict):
continue
config_data["ACPI"]["Add"].extend(acpi_load.get("Add", []))
config_data["ACPI"]["Delete"].extend(acpi_load.get("Delete", []))
config_data["ACPI"]["Patch"].extend(acpi_load.get("Patch", []))
config_data["ACPI"]["Patch"] = acpi_guru.apply_acpi_patches(config_data["ACPI"]["Patch"])
kexts = self.kext.gathering_kexts(
hardware_shorc["Motherboard Name"],
hardware_shorc["Platform"],
@@ -387,13 +399,13 @@ class builder:
efi_option.get("SMBIOS"),
efi_option.get("Custom CPU Name"),
efi_option.get("Synchronize the TSC"),
efi_option.get("ACPI"),
acpi_guru.patches,
efi_option.get("macOS Version")
)
kexts_directory = os.path.join(efi_directory, "EFI", "OC", "Kexts")
self.kext.install_kexts_to_efi(kexts, efi_option.get("macOS Version"), kexts_directory)
efi_option["Kernel_Add"] = self.kext.load_kexts(
config_data["Kernel"]["Add"] = self.kext.load_kexts(
kexts,
hardware_shorc["Motherboard Name"],
hardware_shorc["Platform"],
@@ -401,16 +413,7 @@ class builder:
hardware_shorc["Discrete GPU"].get("GPU Codename", ""),
efi_option["macOS Version"]
)
config_file = os.path.join(efi_directory, "EFI", "OC", "config.plist")
config_data = self.utils.read_file(config_file)
if not config_data:
raise Exception("Error: The file {} does not exist.".format(config_file))
self.config.genarate(hardware_shorc, efi_option, config_data)
self.utils.write_file(config_file, config_data)
self.clean_up(config_data, efi_directory)
hardware_file = os.path.join(efi_directory, hardware_shorc.get("Motherboard Name") + ".json")
self.utils.write_file(hardware_file, hardware)
self.clean_up(config_data, efi_directory)

View File

@@ -580,7 +580,7 @@ class KextMaestro:
return pci_ids
def gathering_kexts(self, motherboard_name, platform, cpu_configuration, cpu_manufacturer, cpu_codename, cpu_cores, simd_features, discrete_gpu_codename, integrated_gpu, network, bluetooth, codec_id, input, sd_controller, storage_controllers, usb_controllers, smbios, custom_cpu_name, tsc_sync, acpi, macos_version):
def gathering_kexts(self, motherboard_name, platform, cpu_configuration, cpu_manufacturer, cpu_codename, cpu_cores, simd_features, discrete_gpu_codename, integrated_gpu, network, bluetooth, codec_id, input, sd_controller, storage_controllers, usb_controllers, smbios, custom_cpu_name, tsc_sync, acpi_patches, macos_version):
kexts = [
"Lilu",
"VirtualSMC",
@@ -610,7 +610,7 @@ class KextMaestro:
else:
kexts.append("NootRX" if "Navi 2" in discrete_gpu_codename else "WhateverGreen")
if "SSDT-RMNE" in ", ".join(acpi_table.get("Path") for acpi_table in acpi.get("Add")):
if any(patch.checked for patch in acpi_patches if patch.name == "RMNE"):
kexts.append("NullEthernet")
wifi_pci = None
@@ -685,7 +685,7 @@ class KextMaestro:
elif 79 < idx:
kexts.append("VoodooRMI")
if "Laptop" in platform and "SURFACE" not in motherboard_name and acpi.get("Battery Status Patch Needed"):
if any(patch.checked for patch in acpi_patches if patch.name == "BATP"):
kexts.append("ECEnabler")
if sd_controller and sd_controller.get("Device ID") in pci_data.RealtekCardReaderIDs: