Merge branch 'main' into sonoma-development

This commit is contained in:
Mykola Grymalyuk
2023-07-16 21:43:06 -06:00
committed by GitHub
70 changed files with 423 additions and 436 deletions
+41 -17
View File
@@ -36,7 +36,7 @@ class BuildMiscellaneous:
self._feature_unlock_handling()
self._restrict_events_handling()
self._firewire_handling()
self._trackpad_handling()
self._topcase_handling()
self._thunderbolt_handling()
self._webcam_handling()
self._usb_handling()
@@ -106,6 +106,12 @@ class BuildMiscellaneous:
logging.info("- Disabling memory error reporting")
re_block_args.append("pcie")
# Resolve mediaanalysisd crashing on 3802 GPUs
# Applicable for systems that are the primary iCloud Photos library host, with large amounts of unprocessed faces
if self.constants.disable_mediaanalysisd is True:
logging.info("- Disabling mediaanalysisd")
re_block_args.append("media")
return re_block_args
@@ -171,25 +177,43 @@ class BuildMiscellaneous:
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("IOFireWireFamily.kext/Contents/PlugIns/AppleFWOHCI.kext")["Enabled"] = True
def _trackpad_handling(self) -> None:
def _topcase_handling(self) -> None:
"""
Trackpad Handler
USB Top Case Handler
"""
# Pre-Force Touch trackpad & keyboard support for macOS Ventura
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.CPUGen.skylake.value:
if self.model.startswith("MacBook"):
# These units got force touch & the new keyboard mapping early, so ignore them
if self.model not in ["MacBookPro11,4", "MacBookPro11,5", "MacBookPro12,1", "MacBook8,1"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTopCase.kext", self.constants.topcase_version, self.constants.top_case_path)
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCButtons.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBMultitouch.kext", self.constants.multitouch_version, self.constants.multitouch_path)
# Legacy Trackpad & Keyboard support
if self.model in ["MacBook4,1", "MacBook5,2"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path)
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path) # Inject legacy personalities into AppleUSBTCKeyboard and AppleUSBTCKeyEventDriver
#On-device probing
if not self.constants.custom_model and self.computer.internal_keyboard_type and self.computer.trackpad_type:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTopCase.kext", self.constants.topcase_version, self.constants.top_case_path)
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCButtons.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True
if self.computer.internal_keyboard_type == "Legacy":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path)
if self.computer.trackpad_type == "Legacy":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path)
elif self.computer.trackpad_type == "Modern":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBMultitouch.kext", self.constants.multitouch_version, self.constants.multitouch_path)
#Predefined fallback
else:
# Multi Touch Top Case support for macOS Ventura+
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.CPUGen.skylake.value:
if self.model.startswith("MacBook"):
# These units got the Force Touch top case, so ignore them
if self.model not in ["MacBookPro11,4", "MacBookPro11,5", "MacBookPro12,1", "MacBook8,1"]:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTopCase.kext", self.constants.topcase_version, self.constants.top_case_path)
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCButtons.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBMultitouch.kext", self.constants.multitouch_version, self.constants.multitouch_path)
# Two-finger Top Case support for macOS High Sierra+
if self.model == "MacBook5,2":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path) # Also requires AppleUSBTopCase.kext
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path) # Inject legacy personalities into AppleUSBTCKeyboard and AppleUSBTCKeyEventDriver
def _thunderbolt_handling(self) -> None:
+8
View File
@@ -63,6 +63,14 @@ class BuildWiredNetworking:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path)
elif isinstance(controller, device_probe.Marvell) or isinstance(controller, device_probe.SysKonnect):
support.BuildSupport(self.model, self.constants, self.config).enable_kext("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path)
# Pre-Ivy Bridge Aquantia Ethernet Patch
if isinstance(controller, device_probe.Aquantia) and controller.chipset == device_probe.Aquantia.Chipsets.AppleEthernetAquantiaAqtion:
if not self.model in smbios_data.smbios_dictionary:
continue
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] < cpu_data.CPUGen.ivy_bridge.value:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleEthernetAbuantiaAqtion.kext", self.constants.aquantia_version, self.constants.aquantia_path)
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleEthernetAbuantiaAqtionFirmware.kext", self.constants.aquantiafirmware_version, self.constants.aquantiafirmware_path)
def _prebuilt_assumption(self) -> None:
+13
View File
@@ -76,6 +76,10 @@ class Constants:
self.bigsursdxc_version: str = "1.0.0" # BigSurSDXC
self.monterey_ahci_version: str = "1.0.0" # CatalinaAHCI
## Apple - Jazzzny Modified
self.aquantia_version: str = "1.0.0" # AppleEthernetAbuantiaAqtion
self.aquantiafirmware_version: str = "1.0.0" # AppleEthernetAbuantiaAqtionFirmware
## Dortania
## https://github.com/dortania
self.backlight_injector_version: str = "1.1.0" # BacklightInjector
@@ -217,6 +221,7 @@ class Constants:
self.force_vmm: bool = False # Force VMM patch
self.disable_connectdrivers: bool = False # Disable ConnectDrivers (hibernation)
self.set_vmm_cpuid: bool = False # Set VMM bit inside CPUID
self.disable_mediaanalysisd: bool = False # Set mediaanalysisd to spawn
self.set_alc_usage: bool = True # Set AppleALC usage
self.allow_3rd_party_drives: bool = True # Allow ThridPartyDrives quirk
self.allow_nvme_fixing: bool = True # Allow NVMe Kernel Space Patches
@@ -346,6 +351,14 @@ class Constants:
@property
def bcm570_path(self):
return self.payload_kexts_path / Path(f"Ethernet/CatalinaBCM5701Ethernet-v{self.bcm570_version}.zip")
@property
def aquantia_path(self):
return self.payload_kexts_path / Path(f"Ethernet/AppleEthernetAbuantiaAqtion-v{self.aquantia_version}.zip")
@property
def aquantiafirmware_path(self):
return self.payload_kexts_path / Path(f"Ethernet/AppleEthernetAbuantiaAqtionFirmware-v{self.aquantiafirmware_version}.zip")
@property
def i210_path(self):
+138 -7
View File
@@ -12,7 +12,7 @@ from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional, Type, Union
from resources import utilities, ioreg
from data import pci_data
from data import pci_data, usb_data
@dataclass
@@ -22,6 +22,94 @@ class CPU:
leafs: list[str]
@dataclass
class USBDevice:
vendor_id: int
device_id: int
device_class: int
device_speed: int
product_name: str
vendor_name: Optional[str] = None
@classmethod
def from_ioregistry(cls, entry: ioreg.io_registry_entry_t):
properties: dict = ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperties(entry, None, ioreg.kCFAllocatorDefault, ioreg.kNilOptions)[1])
vendor_id = None
device_id = None
device_class = None
device_speed = None
vendor_name = None
product_name = "N/A"
if "idVendor" in properties:
vendor_id = properties["idVendor"]
if "idProduct" in properties:
device_id = properties["idProduct"]
if "bDeviceClass" in properties:
device_class = properties["bDeviceClass"]
if "kUSBProductString" in properties:
product_name = properties["kUSBProductString"].strip()
if "kUSBVendorString" in properties:
vendor_name = properties["kUSBVendorString"].strip()
if "USBSpeed" in properties:
device_speed = properties["USBSpeed"]
return cls(vendor_id, device_id, device_class, device_speed, product_name, vendor_name)
def detect(self):
self.detect_class()
self.detect_speed()
def detect_class(self) -> None:
for device_class in self.ClassCode:
if self.device_class == device_class.value:
self.device_class = device_class
def detect_speed(self) -> None:
for speed in self.Speed:
if self.device_speed == speed.value:
self.device_speed = speed
class Speed(enum.Enum):
LOW_SPEED = 0x01
FULL_SPEED = 0x02
HIGH_SPEED = 0x03
SUPER_SPEED = 0x04
SUPER_SPEED_PLUS = 0x05
class ClassCode(enum.Enum):
# https://www.usb.org/defined-class-codes
GENERIC = 0x00
AUDIO = 0x01
CDC_CONTROL = 0x02
HID = 0x03
PHYSICAL = 0x05
IMAGE = 0x06
PRINTER = 0x07
MASS_STORAGE = 0x08
HUB = 0x09
CDC_DATA = 0x0A
SMART_CARD = 0x0B
CONTENT_SEC = 0x0D
VIDEO = 0x0E
PERSONAL_HEALTH = 0x0F
AUDIO_VIDEO = 0x10
BILLBOARD = 0x11
USB_TYPE_C_BRIDGE = 0x12
DISPLAY_BDP = 0x13
I3C = 0x3C
DIAGNOSTIC = 0xDC
WIRELESS = 0xE0
MISCELLANEOUS = 0xEF
APPLICATION = 0xFE
VENDOR_SPEC = 0xFF
@dataclass
class PCIDevice:
VENDOR_ID: ClassVar[int] # Default vendor id, for subclasses.
@@ -502,10 +590,13 @@ class Computer:
ethernet: Optional[EthernetController] = field(default_factory=list)
wifi: Optional[WirelessCard] = None
cpu: Optional[CPU] = None
usb_devices: list[USBDevice] = field(default_factory=list)
oclp_version: Optional[str] = None
opencore_version: Optional[str] = None
opencore_path: Optional[str] = None
bluetooth_chipset: Optional[str] = None
internal_keyboard_type: Optional[str] = None
trackpad_type: Optional[str] = None
ambient_light_sensor: Optional[bool] = False
third_party_sata_ssd: Optional[bool] = False
secure_boot_model: Optional[str] = None
@@ -528,14 +619,31 @@ class Computer:
computer.sdxc_controller_probe()
computer.ethernet_probe()
computer.smbios_probe()
computer.usb_device_probe()
computer.cpu_probe()
computer.bluetooth_probe()
computer.topcase_probe()
computer.ambient_light_sensor_probe()
computer.sata_disk_probe()
computer.oclp_sys_patch_probe()
computer.check_rosetta()
return computer
def usb_device_probe(self):
devices = ioreg.ioiterator_to_list(
ioreg.IOServiceGetMatchingServices(
ioreg.kIOMasterPortDefault, {"IOProviderClass": "IOUSBDevice"}, None
)[1]
)
for device in devices:
properties = USBDevice.from_ioregistry(device)
if properties:
properties.detect()
self.usb_devices.append(properties)
ioreg.IOObjectRelease(device)
def gpu_probe(self):
# Chain together two iterators: one for class code 00000300, the other for class code 00800300
devices = ioreg.ioiterator_to_list(
@@ -758,18 +866,41 @@ class Computer:
return leafs
def bluetooth_probe(self):
usb_data: str = subprocess.run("system_profiler SPUSBDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if "BRCM20702 Hub" in usb_data:
if not self.usb_devices:
return
# Ensure we get the "best" bluetooth chipset (if multiple are present)
if any("BRCM20702" in usb_device.product_name for usb_device in self.usb_devices):
self.bluetooth_chipset = "BRCM20702 Hub"
elif "BCM20702A0" in usb_data or "BCM2045A0" in usb_data:
elif any("BCM20702A0" in usb_device.product_name or "BCM2045A0" in usb_device.product_name for usb_device in self.usb_devices):
self.bluetooth_chipset = "3rd Party Bluetooth 4.0 Hub"
elif "BRCM2070 Hub" in usb_data:
elif any("BRCM2070 Hub" in usb_device.product_name for usb_device in self.usb_devices):
self.bluetooth_chipset = "BRCM2070 Hub"
elif "BRCM2046 Hub" in usb_data:
elif any("BRCM2046 Hub" in usb_device.product_name for usb_device in self.usb_devices):
self.bluetooth_chipset = "BRCM2046 Hub"
elif "Bluetooth" in usb_data:
elif any("Bluetooth" in usb_device.product_name for usb_device in self.usb_devices):
self.bluetooth_chipset = "Generic"
def topcase_probe(self):
if not self.usb_devices:
return
for usb_device in self.usb_devices:
if self.internal_keyboard_type and self.trackpad_type:
break
if usb_device.vendor_id != 0x5ac:
continue
if usb_device.device_id in usb_data.AppleIDs.Legacy_AppleUSBTCKeyboard:
self.internal_keyboard_type = "Legacy"
elif usb_device.device_id in usb_data.AppleIDs.Modern_AppleUSBTCKeyboard:
self.internal_keyboard_type = "Modern"
if usb_device.device_id in usb_data.AppleIDs.AppleUSBTrackpad:
self.trackpad_type = "Legacy"
elif usb_device.device_id in usb_data.AppleIDs.AppleUSBMultiTouch:
self.trackpad_type = "Modern"
def sata_disk_probe(self):
# Get all SATA Controllers/Disks from 'system_profiler SPSerialATADataType'
# Determine whether SATA SSD is present and Apple-made
+1 -1
View File
@@ -437,7 +437,7 @@ def clean_device_path(device_path: str):
if len(device_path_array) >= 2:
device_path_stripped = device_path_array[-2]
device_path_root_array = device_path_stripped.split(",")
if len(device_path_root_array) >= 2:
if len(device_path_root_array) > 2:
return device_path_root_array[2]
return None
+12 -1
View File
@@ -386,6 +386,17 @@ class SettingsFrame(wx.Frame):
"for unsupported models.",
],
},
"Disable mediaanalysisd service": {
"type": "checkbox",
"value": self.constants.disable_mediaanalysisd,
"variable": "disable_mediaanalysisd",
"description": [
"For systems that are the primary iCloud",
"Photo Library host with a 3802-based GPU,",
"this may aid in prolonged idle stability.",
],
"condition": gui_support.CheckProperties(self.constants).host_has_3802_gpu()
},
"wrap_around 1": {
"type": "wrap_around",
},
@@ -1003,7 +1014,7 @@ Hardware Information:
if self.constants.computer.real_model in smbios_data.smbios_dictionary:
if self.constants.detected_os > smbios_data.smbios_dictionary[self.constants.computer.real_model]["Max OS Supported"]:
chassis_type = "aluminum"
if self.constants.computer.real_model in ["MacBook4,1", "MacBook5,2", "MacBook6,1", "MacBook7,1"]:
if self.constants.computer.real_model in ["MacBook5,2", "MacBook6,1", "MacBook7,1"]:
chassis_type = "plastic"
dlg = wx.MessageDialog(self.frame_modal, f"This model, {self.constants.computer.real_model}, does not natively support macOS {os_data.os_conversion.kernel_to_os(self.constants.detected_os)}, {os_data.os_conversion.convert_kernel_to_marketing_name(self.constants.detected_os)}. The last native OS was macOS {os_data.os_conversion.kernel_to_os(smbios_data.smbios_dictionary[self.constants.computer.real_model]['Max OS Supported'])}, {os_data.os_conversion.convert_kernel_to_marketing_name(smbios_data.smbios_dictionary[self.constants.computer.real_model]['Max OS Supported'])}\n\nToggling this option will break booting on this OS. Are you absolutely certain this is desired?\n\nYou may end up with a nice {chassis_type} brick 🧱", "Are you certain?", wx.YES_NO | wx.ICON_WARNING | wx.NO_DEFAULT)
if dlg.ShowModal() == wx.ID_NO:
+21 -1
View File
@@ -13,7 +13,7 @@ import packaging.version
from pathlib import Path
from resources.wx_gui import gui_about
from resources import constants
from resources import constants, device_probe
from data import model_array, os_data, smbios_data
@@ -179,6 +179,26 @@ class CheckProperties:
return packaging.version.parse(oclp_plist["PatcherSupportPkg"])
def host_has_3802_gpu(self) -> bool:
"""
Check if either host, or override model, has a 3802 GPU
"""
gpu_dict = [] if self.constants.custom_model else self.constants.computer.gpus
model = self.constants.custom_model if self.constants.custom_model else self.constants.computer.real_model
if gpu_dict == []:
gpu_dict = smbios_data.smbios_dictionary[model]["Stock GPUs"] if model in smbios_data.smbios_dictionary else []
for gpu in gpu_dict:
if not self.constants.custom_model:
gpu = gpu.arch
if gpu in [
device_probe.Intel.Archs.Ivy_Bridge,
device_probe.Intel.Archs.Haswell,
device_probe.NVIDIA.Archs.Kepler,
]:
return True
return False
class PayloadMount: