mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-13 20:28:21 +10:00
Move FirmwareFeature generation
This commit is contained in:
@@ -32,23 +32,6 @@ class BuildOpenCore:
|
||||
self.computer = self.constants.computer
|
||||
self.gfx0_path = None
|
||||
|
||||
def patch_firmware_feature(self):
|
||||
# Adjust FirmwareFeature to support everything macOS requires
|
||||
# APFS Bit (19/20): 10.13+ (OSInstall)
|
||||
# Large BaseSystem Bit (35): 12.0 B7+ (patchd)
|
||||
# https://github.com/acidanthera/OpenCorePkg/tree/2f76673546ac3e32d2e2d528095fddcd66ad6a23/Include/Apple/IndustryStandard/AppleFeatures.h
|
||||
if not self.constants.custom_model:
|
||||
firmwarefeature = Utilities.get_rom("firmware-features")
|
||||
if not firmwarefeature:
|
||||
print("- Failed to find FirmwareFeatures, falling back on defaults")
|
||||
firmwarefeature = int(smbios_data.smbios_dictionary[self.model]["FirmwareFeatures"], 16)
|
||||
else:
|
||||
firmwarefeature = int(smbios_data.smbios_dictionary[self.model]["FirmwareFeatures"], 16)
|
||||
firmwarefeature = Utilities.enable_apfs(firmwarefeature)
|
||||
firmwarefeature = Utilities.enable_apfs_extended(firmwarefeature)
|
||||
firmwarefeature = Utilities.enable_large_basesystem(firmwarefeature)
|
||||
return firmwarefeature
|
||||
|
||||
def disk_type(self):
|
||||
drive_host_info = plistlib.loads(subprocess.run(f"diskutil info -plist {self.constants.disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||
sd_type = drive_host_info["MediaName"]
|
||||
@@ -725,7 +708,8 @@ class BuildOpenCore:
|
||||
# Setup menu
|
||||
def minimal_serial_patch(self):
|
||||
# Generate Firmware Features
|
||||
fw_feature = self.patch_firmware_feature()
|
||||
fw_feature = generate_smbios.generate_fw_features(self.model, self.constants.custom_model)
|
||||
# fw_feature = self.patch_firmware_feature()
|
||||
fw_feature = hex(fw_feature).lstrip("0x").rstrip("L").strip()
|
||||
print(f"- Setting Firmware Feature: {fw_feature}")
|
||||
fw_feature = Utilities.string_to_hex(fw_feature)
|
||||
|
||||
@@ -75,7 +75,7 @@ class Constants:
|
||||
self.payload_path = self.current_path / Path("payloads")
|
||||
|
||||
# Patcher Settings
|
||||
self.allow_oc_everywhere = True # Set whether Patcher can be run on unsupported Macs
|
||||
self.allow_oc_everywhere = False # Set whether Patcher can be run on unsupported Macs
|
||||
self.gui_mode = False # Determine whether running in a GUI or TUI
|
||||
self.disk = "" # Set installation ESP
|
||||
self.patch_disk = "" # Set Root Volume to patch
|
||||
|
||||
@@ -92,30 +92,6 @@ def check_seal():
|
||||
return False
|
||||
|
||||
|
||||
def latebloom_detection(model):
|
||||
if model in ["MacPro4,1", "MacPro5,1", "iMac7,1", "iMac8,1"]:
|
||||
# These machines are more likely to experience boot hangs, increase delays to accomodate
|
||||
lb_delay = "250"
|
||||
else:
|
||||
lb_delay = "100"
|
||||
lb_range = "1"
|
||||
lb_debug = "1"
|
||||
boot_args = get_nvram("boot-args", decode=False)
|
||||
# boot_args = "latebloom=200 lb_range=40 lb_debug=0 keepsyms=1 debug=0x100 -lilubetaall"
|
||||
if boot_args:
|
||||
# TODO: This crashes if latebloom=xxx is the very first entry in boot-args
|
||||
if "latebloom=" in boot_args:
|
||||
lb_delay = re.search(r"(?:[, ])latebloom=(\d+)", boot_args)
|
||||
lb_delay = lb_delay[1]
|
||||
if "lb_range=" in boot_args:
|
||||
lb_range = re.search(r"(?:[, ])lb_range=(\d+)", boot_args)
|
||||
lb_range = lb_range[1]
|
||||
if "lb_debug=" in boot_args:
|
||||
lb_debug = re.search(r"(?:[, ])lb_debug=(\d+)", boot_args)
|
||||
lb_debug = lb_debug[1]
|
||||
return int(lb_delay), int(lb_range), int(lb_debug)
|
||||
|
||||
|
||||
def csr_decode(csr_active_config, os_sip):
|
||||
if csr_active_config is None:
|
||||
csr_active_config = b"\x00\x00\x00\x00"
|
||||
@@ -323,17 +299,7 @@ def download_file(link, location):
|
||||
return checksum
|
||||
|
||||
|
||||
def enable_apfs(fw_feature):
|
||||
fw_feature |= 2 ** 19 # Enable FW_FEATURE_SUPPORTS_APFS
|
||||
return fw_feature
|
||||
|
||||
def enable_apfs_extended(fw_feature):
|
||||
fw_feature |= 2 ** 20 # Enable FW_FEATURE_SUPPORTS_APFS_EXTRA
|
||||
return fw_feature
|
||||
|
||||
def enable_large_basesystem(fw_feature):
|
||||
fw_feature |= 2 ** 35 # Enable FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
|
||||
return fw_feature
|
||||
|
||||
|
||||
# def menu(title, prompt, menu_options, add_quit=True, auto_number=False, in_between=[], top_level=False):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from Data import smbios_data, os_data
|
||||
from Resources import Utilities
|
||||
|
||||
def set_smbios_model_spoof(model):
|
||||
try:
|
||||
@@ -50,4 +51,25 @@ def set_smbios_model_spoof(model):
|
||||
return "iMac17,1"
|
||||
else:
|
||||
# Unknown Model
|
||||
raise Exception
|
||||
raise Exception
|
||||
|
||||
def update_firmware_features(firmwarefeature):
|
||||
# Adjust FirmwareFeature to support everything macOS requires
|
||||
# APFS Bit (19/20): 10.13+ (OSInstall)
|
||||
# Large BaseSystem Bit (35): 12.0 B7+ (patchd)
|
||||
# https://github.com/acidanthera/OpenCorePkg/tree/2f76673546ac3e32d2e2d528095fddcd66ad6a23/Include/Apple/IndustryStandard/AppleFeatures.h
|
||||
firmwarefeature |= 2 ** 19 # FW_FEATURE_SUPPORTS_APFS
|
||||
firmwarefeature |= 2 ** 20 # FW_FEATURE_SUPPORTS_APFS_EXTRA
|
||||
firmwarefeature |= 2 ** 35 # FW_FEATURE_SUPPORTS_LARGE_BASESYSTEM
|
||||
return firmwarefeature
|
||||
|
||||
def generate_fw_features(model, custom):
|
||||
if not custom:
|
||||
firmwarefeature = Utilities.get_rom("firmware-features")
|
||||
if not firmwarefeature:
|
||||
print("- Failed to find FirmwareFeatures, falling back on defaults")
|
||||
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
|
||||
else:
|
||||
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
|
||||
firmwarefeature = update_firmware_features(firmwarefeature)
|
||||
return firmwarefeature
|
||||
Reference in New Issue
Block a user