diff --git a/CHANGELOG.md b/CHANGELOG.md index 67a3ddc43..929376a4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # OpenCore Legacy Patcher changelog -## 1.6.0 +## 2.0.0 - Set `AssociatedBundleIdentifiers` property in launch services as an array - Move to auto-generated pre/postinstall scripts for PKGs - Streamlines PKG creation process, ensuring Install and AutoPKG scripts are always in sync @@ -17,8 +17,39 @@ - Only affects building EFI from another machine - Resolve AMD Navi MXM GPU detection for modded iMac9,x-12,x - Thanks @Ausdauersportler for the patch! +- Implement early macOS Sequoia support: + - Supporting Macs with Metal-based graphics: + - MacBook8,1 - 10,1 + - MacBookAir5,x - 7,x + - MacBookPro9,x - 14,x + - Macmini6,x - 7,1 + - iMac13,x - 18,x + - iMac10,1 - 12,x included if Metal GPU installed. + - MacPro3,1 - 6,1 + - MacPro3,1 - 5,1 require Metal GPU installed. + - MacPro3,1 can only boot with 4 cores max currently + - Xserve2,1 - 3,1 + - Requires Metal GPU installed. + - Xserve2,1 can only boot with 4 cores max currently + - Excludes the newly dropped MacBookAir8,x series. + - No estimate can be given when support will be added. +- Implement new MetallibSupportPkg system to support macOS Sequoia on Metal 3802-based GPUs. + - See repository for more details: [MetallibSupportPkg](https://github.com/dortania/MetallibSupportPkg). +- Implement new Patchset Detection architecture. +- Implement new kernel cache building architecture. +- Resolve "Label" error in com.dortania.opencore-legacy-patcher.os-caching.plist. +- Add macOS Sequoia icons to boot picker and GUI. - Increment Binaries: - PatcherSupportPkg 1.6.3 - release + - OpenCorePkg 1.0.1 - release + - Lilu 1.6.8 - release + - WhateverGreen 1.6.7 - release + - RestrictEvents 1.1.4 - release + - FeatureUnlock 1.1.6 - release + - DebugEnhancer 1.0.9 - release + - CPUFriend 1.2.8 - release + - AutoPkgInstaller 1.0.4 - release + - CryptexFixup 1.0.3 - release ## 1.5.0 - Restructure project directories diff --git a/DortaniaInternalResources.dmg b/DortaniaInternalResources.dmg new file mode 100644 index 000000000..b75d1e7d4 Binary files /dev/null and b/DortaniaInternalResources.dmg differ diff --git a/README.md b/README.md index 9c3f3aa40..d8a98dac4 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ To run the project from source, see here: [Build and run from source](./SOURCE.m * USB Top Case probing * Developer root patching * Vaulting implementation + * macOS 15 3802 Helios Research * UEFI bootx64.efi research * universal2 build research * Various documentation contributions diff --git a/ci_tooling/installer_backups/macOS_Installer_Backup.command b/ci_tooling/installer_backups/macOS_Installer_Backup.command index 2f472a95e..525634d23 100755 --- a/ci_tooling/installer_backups/macOS_Installer_Backup.command +++ b/ci_tooling/installer_backups/macOS_Installer_Backup.command @@ -42,7 +42,8 @@ class InstallerBackup: os_data.os_data.big_sur, os_data.os_data.monterey, os_data.os_data.ventura, - os_data.os_data.sonoma + os_data.os_data.sonoma, + os_data.os_data.sequoia, ], first_run: bool = False ) -> None: @@ -57,6 +58,7 @@ class InstallerBackup: os_data.os_data.monterey: Path(self._directory, "12 Monterey"), os_data.os_data.ventura: Path(self._directory, "13 Ventura"), os_data.os_data.sonoma: Path(self._directory, "14 Sonoma"), + os_data.os_data.sequoia: Path(self._directory, "15 Sequoia"), } for os_version in self._supported_oses: diff --git a/opencore_legacy_patcher/constants.py b/opencore_legacy_patcher/constants.py index 62f3a3dfa..ba67f0790 100644 --- a/opencore_legacy_patcher/constants.py +++ b/opencore_legacy_patcher/constants.py @@ -13,8 +13,8 @@ from .detections import device_probe class Constants: def __init__(self) -> None: # Patcher Versioning - self.patcher_version: str = "1.6.0" # OpenCore-Legacy-Patcher - self.patcher_support_pkg_version: str = "1.6.3" # PatcherSupportPkg + self.patcher_version: str = "2.0.0" # OpenCore-Legacy-Patcher + self.patcher_support_pkg_version: str = "1.7.8" # PatcherSupportPkg self.copyright_date: str = "Copyright © 2020-2024 Dortania" self.patcher_name: str = "OpenCore Legacy Patcher" @@ -28,25 +28,25 @@ class Constants: # OpenCore Versioning # https://github.com/acidanthera/OpenCorePkg - self.opencore_version: str = "1.0.0" + self.opencore_version: str = "1.0.1" # Kext Versioning ## Acidanthera ## https://github.com/acidanthera - self.lilu_version: str = "1.6.7" # Lilu - self.whatevergreen_version: str = "1.6.6" # WhateverGreen - self.whatevergreen_navi_version: str = "1.6.6-Navi" # WhateverGreen (Navi Patch) + self.lilu_version: str = "1.6.8" # Lilu + self.whatevergreen_version: str = "1.6.7" # WhateverGreen + self.whatevergreen_navi_version: str = "1.6.7-Navi" # WhateverGreen (Navi Patch) self.airportbcrmfixup_version: str = "2.1.8" # AirPortBrcmFixup self.nvmefix_version: str = "1.1.1" # NVMeFix self.applealc_version: str = "1.6.3" # AppleALC - self.restrictevents_version: str = "1.1.3" # RestrictEvents - self.featureunlock_version: str = "1.1.5" # FeatureUnlock - self.debugenhancer_version: str = "1.0.8" # DebugEnhancer - self.cpufriend_version: str = "1.2.7" # CPUFriend + self.restrictevents_version: str = "1.1.4" # RestrictEvents + self.featureunlock_version: str = "1.1.6" # FeatureUnlock + self.debugenhancer_version: str = "1.0.9" # DebugEnhancer + self.cpufriend_version: str = "1.2.8" # CPUFriend self.bluetool_version: str = "2.6.8" # BlueToolFixup (BrcmPatchRAM) self.cslvfixup_version: str = "2.6.1" # CSLVFixup - self.autopkg_version: str = "1.0.3" # AutoPkgInstaller - self.cryptexfixup_version: str = "1.0.2" # CryptexFixup + self.autopkg_version: str = "1.0.4" # AutoPkgInstaller + self.cryptexfixup_version: str = "1.0.3" # CryptexFixup ## Apple ## https://www.apple.com @@ -61,6 +61,7 @@ class Constants: self.apfs_zlib_v2_version: str = "12.6" # NoAVXFSCompressionTypeZlib (patched with AVXpel) self.multitouch_version: str = "1.0.0" # AppleUSBMultitouch self.topcase_version: str = "1.0.0" # AppleUSBTopCase + self.topcase_inj_version: str = "1.0.0" # AppleTopCaseInjector self.intel_82574l_version: str = "1.0.0" # Intel82574L self.intel_8254x_version: str = "1.0.0" # AppleIntel8254XEthernet self.apple_usb_11_injector: str = "1.0.0" # AppleUSBUHCI/OHCI @@ -73,6 +74,7 @@ class Constants: self.t1_corecrypto_version: str = "1.0.1" # corecrypto (13.6 - T1 support) self.apple_spi_version: str = "1.0.0" # AppleHSSPISupport (14.4 Beta 1) self.apple_spi_hid_version: str = "1.0.0" # AppleHSSPIHIDDriver (14.4 Beta 1) + self.kernel_relay_version: str = "1.0.0" # KernelRelayHost (15.0 Beta 3) ## Apple - Dortania Modified self.bcm570_version: str = "1.0.2" # CatalinaBCM5701Ethernet @@ -80,7 +82,7 @@ class Constants: self.corecaptureelcap_version: str = "1.0.2" # corecaptureElCap self.io80211elcap_version: str = "2.0.1" # IO80211ElCap self.io80211legacy_version: str = "1.0.0" # IO80211FamilyLegacy (Ventura) - self.ioskywalk_version: str = "1.1.0" # IOSkywalkFamily (Ventura) + self.ioskywalk_version: str = "1.2.0" # IOSkywalkFamily (Ventura) self.bigsursdxc_version: str = "1.0.0" # BigSurSDXC self.monterey_ahci_version: str = "1.0.0" # CatalinaAHCI @@ -96,8 +98,8 @@ class Constants: self.btspoof_version: str = "1.0.0" # Bluetooth-Spoof self.aspp_override_version: str = "1.0.1" # ACPI_SMC_PlatformPlugin Override self.ecm_override_version: str = "1.0.0" # AppleUSBECM Override - self.rsrhelper_version: str = "1.0.0" # RSRHelper - self.amfipass_version: str = "1.4.0" # AMFIPass + self.rsrhelper_version: str = "1.0.2" # RSRHelper + self.amfipass_version: str = "1.4.1" # AMFIPass self.amfipass_compatibility_version: str = "1.2.1" # Minimum AMFIPass version required ## Syncretic @@ -177,7 +179,7 @@ class Constants: ## SMBIOS Settings self.serial_settings: str = "None" # Set SMBIOS level used self.override_smbios: str = "Default" # Set SMBIOS model used - self.allow_native_spoofs: bool = False # Allow native models to recieve spoofs + self.allow_native_spoofs: bool = False # Allow native models to receive spoofs ### Serial Number Overrides self.custom_serial_number: str = "" # Set SMBIOS serial number @@ -450,6 +452,10 @@ class Constants: def top_case_path(self): return self.payload_kexts_path / Path(f"Misc/AppleUSBTopCase-v{self.topcase_version}.zip") + @property + def top_case_inj_path(self): + return self.payload_kexts_path / Path(f"Misc/AppleTopCaseInjector-v{self.topcase_inj_version}.zip") + @property def t1_key_store_path(self): return self.payload_kexts_path / Path(f"Misc/AppleKeyStore-v{self.t1_key_store_version}.zip") @@ -474,6 +480,10 @@ class Constants: def apple_spi_hid_path(self): return self.payload_kexts_path / Path(f"Misc/AppleHSSPIHIDDriver-v{self.apple_spi_hid_version}.zip") + @property + def kernel_relay_path(self): + return self.payload_kexts_path / Path(f"Misc/KernelRelayHost-v{self.kernel_relay_version}.zip") + @property def mousse_path(self): return self.payload_kexts_path / Path(f"SSE/AAAMouSSE-v{self.mousse_version}.zip") @@ -777,6 +787,10 @@ class Constants: def icon_path_macos_sonoma(self): return self.icns_resource_path / Path("Sonoma.icns") + @property + def icon_path_macos_sequoia(self): + return self.icns_resource_path / Path("Sequoia.icns") + @property def gui_path(self): return self.payload_path / Path("Icon/Resources.zip") @@ -798,6 +812,10 @@ class Constants: def kdk_download_path(self): return self.payload_path / Path("KDK.dmg") + @property + def metallib_download_path(self): + return self.payload_path / Path("MetallibSupportPkg.pkg") + @property def icons_path(self): return [ @@ -805,7 +823,8 @@ class Constants: str(self.icon_path_macos_big_sur), str(self.icon_path_macos_monterey), str(self.icon_path_macos_ventura), - str(self.icon_path_macos_sonoma) + str(self.icon_path_macos_sonoma), + str(self.icon_path_macos_sequoia), ] sbm_values = [ diff --git a/opencore_legacy_patcher/datasets/model_array.py b/opencore_legacy_patcher/datasets/model_array.py index ff76d01d8..1985e2042 100644 --- a/opencore_legacy_patcher/datasets/model_array.py +++ b/opencore_legacy_patcher/datasets/model_array.py @@ -24,6 +24,8 @@ SupportedSMBIOS = [ "MacBookAir6,2", "MacBookAir7,1", "MacBookAir7,2", + # "MacBookAir8,1", + # "MacBookAir8,2", # MacBook Pro "MacBookPro4,1", "MacBookPro5,1", diff --git a/opencore_legacy_patcher/datasets/smbios_data.py b/opencore_legacy_patcher/datasets/smbios_data.py index 011b2100e..322a30e37 100644 --- a/opencore_legacy_patcher/datasets/smbios_data.py +++ b/opencore_legacy_patcher/datasets/smbios_data.py @@ -507,7 +507,7 @@ smbios_dictionary = { "FirmwareFeatures": "0x8FD8FF42E", "SecureBootModel": "j140k", "CPU Generation": cpu_data.CPUGen.coffee_lake.value, - "Max OS Supported": os_data.os_data.max_os, + "Max OS Supported": os_data.os_data.sonoma, "Wireless Model": device_probe.Broadcom.Chipsets.AppleBCMWLANBusInterfacePCIe, "Bluetooth Model": bluetooth_data.bluetooth_data.UART, "Screen Size": 13, @@ -524,7 +524,7 @@ smbios_dictionary = { "FirmwareFeatures": "0x8FD8FF42E", "SecureBootModel": "j140k", # TODO: Verify "CPU Generation": cpu_data.CPUGen.coffee_lake.value, - "Max OS Supported": os_data.os_data.max_os, + "Max OS Supported": os_data.os_data.sonoma, "Wireless Model": device_probe.Broadcom.Chipsets.AppleBCMWLANBusInterfacePCIe, "Bluetooth Model": bluetooth_data.bluetooth_data.UART, "Screen Size": 13, @@ -543,7 +543,7 @@ smbios_dictionary = { "FirmwareFeatures": "0x8FD8FF42E", "SecureBootModel": "x589amlu", "CPU Generation": cpu_data.CPUGen.coffee_lake.value, - "Max OS Supported": os_data.os_data.max_os, + "Max OS Supported": os_data.os_data.sonoma, "Wireless Model": device_probe.Broadcom.Chipsets.AppleBCMWLANBusInterfacePCIe, "Bluetooth Model": bluetooth_data.bluetooth_data.UART, "Screen Size": 13, @@ -561,7 +561,7 @@ smbios_dictionary = { "FirmwareFeatures": "0x8FD8FF42E", "SecureBootModel": "j140a", "CPU Generation": cpu_data.CPUGen.coffee_lake.value, - "Max OS Supported": os_data.os_data.max_os, + "Max OS Supported": os_data.os_data.sonoma, "Wireless Model": device_probe.Broadcom.Chipsets.AppleBCMWLANBusInterfacePCIe, "Bluetooth Model": bluetooth_data.bluetooth_data.UART, "Screen Size": 13, diff --git a/opencore_legacy_patcher/datasets/sys_patch_dict.py b/opencore_legacy_patcher/datasets/sys_patch_dict.py deleted file mode 100644 index 6ff22ea5b..000000000 --- a/opencore_legacy_patcher/datasets/sys_patch_dict.py +++ /dev/null @@ -1,1440 +0,0 @@ -""" -sys_patch_dict.py: Dictionary defining patch sets used during Root Volume patching (sys_patch.py) -""" - -import packaging.version - -from . import os_data - - -class SystemPatchDictionary(): - """ - Library for generating patch sets for sys_patch.py and supporting modules - - Usage: - >>> patchsets = SystemPatchDictionary(22, 0, [20, 21, 22], "13.0").patchset_dict - - - Patchset Schema: - Supports following types of higher level keys: - - OS Support: Supported OSes by patches - - Minimum OS Support: Minimum supported OS version - - OS Major: Major XNU Kernel version - - OS Minor: Minor XNU Kernel version - - Maximum OS Support: Maximum supported OS version - - OS Major: Major XNU Kernel version - - OS Minor: Minor XNU Kernel version - - Install: Files to install to root volume - - Location: - - File (dict: { "File": "Source" }) - - Install Non-Root: Files to install to data partition - - Location: - - File (dict: { "File": "Source" }) - - Remove: Files to remove - - Location: - - File (array: [ "File" ]) - - Remove Non-Root: Files to remove from data partition - - Location: - - File (array: [ "File" ]) - - Processes: Additional processes to run - - Process (dict: { "Process": "Requires Root" }) - - Display Name: User-friendly name (string, "" if user-friendly name is not required) - - - Schema file storage is based off the origin, ie. '10.13.6/System/Library/Extensions/IOSurface.kext': - - "Install": { - "/System/Library/Extensions": { - "IOSurface.kext": "10.13.6", - }, - }, - - Note: Stubbed binaries are OS specific, thus use the 'self.os_major' variable to denounce which folder variant to use - """ - - def __init__(self, os_major: int, os_minor: int, non_metal_os_support: list, marketing_version: str) -> None: - """ - Parameters: - os_major (int): Major XNU Kernel version - os_minor (int): Minor XNU Kernel version - non_metal_os_support (list): List of supported non-metal OSes (XNU Major Versions) - marketing_version (str): Marketing version of the OS - - 'non_metal_os_support' is assumed to be sorted from oldest to newest - """ - - self.os_major: int = os_major - self.os_minor: int = os_minor - self.os_float: float = float(f"{self.os_major}.{self.os_minor}") - self.non_metal_os_support: list = non_metal_os_support - self.patchset_dict: dict = {} - self.marketing_version: str = marketing_version - - self.affected_by_cve_2024_23227: bool = self.__is_affect_by_cve_2024_23227() - - # XNU Kernel versions - self.macOS_12_0_B7: float = 21.1 - self.macOS_12_4: float = 21.5 - self.macOS_12_5: float = 21.6 - self.macOS_13_3: float = 22.4 - self.macOS_14_1: float = 23.1 - self.macOS_14_2: float = 23.2 - self.macOS_14_4: float = 23.4 - - self._generate_sys_patch_dict() - - - def __resolve_ivy_bridge_framebuffers(self) -> str: - """ - Resolve patchset directory for Ivy Bridge framebuffers: - - AppleIntelFramebufferCapri.kext - - AppleIntelHD4000Graphics.kext - """ - if self.os_major < os_data.os_data.sonoma: - return "11.7.10" - if self.os_float < self.macOS_14_4: - return "11.7.10-23" - return "11.7.10-23.4" - - - def __resolve_kepler_geforce_framebuffers(self) -> str: - """ - Resolve patchset directory for GeForce.kext - """ - if self.os_major < os_data.os_data.sonoma: - return "12.0 Beta 6" - if self.os_float < self.macOS_14_4: - return "12.0 Beta 6-23" - return "12.0 Beta 6-23.4" - - - def __resolve_monterey_framebuffers(self) -> str: - """ - Resolve patchset directory for framebuffers last supported in Monterey: - - AppleIntelBDWGraphics.kext - - AppleIntelBDWGraphicsFramebuffer.kext - - AppleIntelFramebufferAzul.kext - - AppleIntelHD5000Graphics.kext - - AppleIntelSKLGraphics.kext - - AppleIntelSKLGraphicsFramebuffer.kext - - AMDRadeonX4000.kext - - AMDRadeonX5000.kext - """ - if self.os_major < os_data.os_data.sonoma: - return "12.5" - if self.os_float < self.macOS_14_4: - return "12.5-23" - return "12.5-23.4" - - - def __is_affect_by_cve_2024_23227(self) -> bool: - """ - CVE-2024-23227 broke our airportd patches for 12.7.4, 13.6.5 and 14.4 - - Note that since the XNU version's security patch level is not increment - """ - - if self.os_major > os_data.os_data.sonoma: - return True - - parsed_version = packaging.version.parse(self.marketing_version) - if self.marketing_version.startswith("12"): - return parsed_version >= packaging.version.parse("12.7.4") - if self.marketing_version.startswith("13"): - return parsed_version >= packaging.version.parse("13.6.5") - if self.marketing_version.startswith("14"): - return parsed_version >= packaging.version.parse("14.4") - - return False - - - def _generate_sys_patch_dict(self): - """ - Generates the sys_patch_dict dictionary - """ - - self.patchset_dict = { - "Graphics": { - "Non-Metal Common": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": self.non_metal_os_support[0], - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": self.non_metal_os_support[-1], - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "IOSurface.kext": "10.15.7", - }, - "/System/Library/Frameworks": { - "OpenGL.framework": "10.14.3", - "CoreDisplay.framework": f"10.14.4-{self.os_major}", - "IOSurface.framework": f"10.15.7-{self.os_major}", - "QuartzCore.framework": f"10.15.7-{self.os_major}", - }, - "/System/Library/PrivateFrameworks": { - "GPUSupport.framework": "10.14.3", - "SkyLight.framework": f"10.14.6-{self.os_major}", - **({"FaceCore.framework": f"13.5"} if self.os_major >= os_data.os_data.sonoma else {}), - }, - "/System/Applications": { - **({ "Photo Booth.app": "11.7.9"} if self.os_major >= os_data.os_data.monterey else {}), - }, - }, - "Remove": { - "/System/Library/Extensions": [ - "AMDRadeonX4000.kext", - "AMDRadeonX4000HWServices.kext", - "AMDRadeonX5000.kext", - "AMDRadeonX5000HWServices.kext", - "AMDRadeonX6000.kext", - "AMDRadeonX6000Framebuffer.kext", - "AMDRadeonX6000HWServices.kext", - "AppleIntelBDWGraphics.kext", - "AppleIntelBDWGraphicsFramebuffer.kext", - "AppleIntelCFLGraphicsFramebuffer.kext", - "AppleIntelHD4000Graphics.kext", - "AppleIntelHD5000Graphics.kext", - "AppleIntelICLGraphics.kext", - "AppleIntelICLLPGraphicsFramebuffer.kext", - "AppleIntelKBLGraphics.kext", - "AppleIntelKBLGraphicsFramebuffer.kext", - "AppleIntelSKLGraphics.kext", - "AppleIntelSKLGraphicsFramebuffer.kext", - "AppleIntelFramebufferAzul.kext", - "AppleIntelFramebufferCapri.kext", - "AppleParavirtGPU.kext", - "GeForce.kext", - "IOAcceleratorFamily2.kext", - "IOGPUFamily.kext", - "AppleAfterburner.kext", - ], - }, - "Install Non-Root": { - "/Library/Application Support/SkyLightPlugins": { - **({ "DropboxHack.dylib": "SkyLightPlugins" } if self.os_major >= os_data.os_data.monterey else {}), - **({ "DropboxHack.txt": "SkyLightPlugins" } if self.os_major >= os_data.os_data.monterey else {}), - }, - }, - "Processes": { - # 'When Space Allows' option introduced in 12.4 (XNU 21.5) - **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist ShowDate -int 1": True } if self.os_float >= self.macOS_12_4 else {}), - "/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist InternalDebugUseGPUProcessForCanvasRenderingEnabled -bool false": True, - "/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist WebKitExperimentalUseGPUProcessForCanvasRenderingEnabled -bool false": True, - **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist WebKitPreferences.acceleratedDrawingEnabled -bool false": True} if self.os_major >= os_data.os_data.sonoma else {}), - **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist NSEnableAppKitMenus -bool false": True} if self.os_major >= os_data.os_data.sonoma else {}), - **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist NSZoomButtonShowMenu -bool false": True} if self.os_major >= os_data.os_data.sonoma else {}), - }, - }, - "Non-Metal IOAccelerator Common": { - # TeraScale 2 and Nvidia Web Drivers broke in Mojave due to mismatched structs in - # the IOAccelerator stack - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": self.non_metal_os_support[0], - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": self.non_metal_os_support[-1], - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "IOAcceleratorFamily2.kext": "10.13.6", - "IOSurface.kext": "10.14.6", - }, - "/System/Library/Frameworks": { - "IOSurface.framework": f"10.14.6-{self.os_major}", - "OpenCL.framework": "10.13.6", - }, - "/System/Library/PrivateFrameworks": { - "GPUSupport.framework": "10.13.6", - "IOAccelerator.framework": f"10.13.6-{self.os_major}", - }, - }, - "Remove": { - "/System/Library/Extensions": [ - "AppleCameraInterface.kext" - ], - }, - }, - - "Non-Metal CoreDisplay Common": { - # Nvidia Web Drivers require an older build of CoreDisplay - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": self.non_metal_os_support[0], - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": self.non_metal_os_support[-1], - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "CoreDisplay.framework": f"10.13.6-{self.os_major}", - }, - }, - }, - - "Non-Metal Enforcement": { - # Forces Metal kexts from High Sierra to run in the fallback non-Metal mode - # Verified functional with HD4000 and Iris Plus 655 - # Only used for internal development purposes, not suitable for end users - - # Note: Metal kexts in High Sierra rely on IOAccelerator, thus 'Non-Metal IOAccelerator Common' - # is needed for proper linking - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": self.non_metal_os_support[0], - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": self.non_metal_os_support[-1], - "OS Minor": 99 - }, - }, - "Processes": { - "/usr/bin/defaults write /Library/Preferences/com.apple.CoreDisplay useMetal -boolean no": True, - "/usr/bin/defaults write /Library/Preferences/com.apple.CoreDisplay useIOP -boolean no": True, - }, - }, - - "Revert Non-Metal ColorSync Workaround": { - # Old patch for ColorSync in Ventura on HD3000s - # Proper solution has been integrated into QuartzCore - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 99 - }, - }, - "Remove": { - "/System/Library/Frameworks/ColorSync.framework/Versions/A": [ - "ColorSync", - "ColorSyncOld.dylib", - ], - }, - }, - - # AMD GCN and Nvidia Kepler require Metal Downgrade in Ventura - # The patches are required due to struct issues in the Metal stack - # - AMD GCN will break on BronzeMtlDevice - # - See Nvidia Kepler patchset for more info - "Metal Common": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "Metal.framework": "12.5", - "MetalPerformanceShaders.framework": "12.5", - }, - }, - }, - - # Temporary work-around for Kepler GPUs on Ventura - # We removed the reliance on Metal.framework downgrade, however the new Kepler - # patchset breaks with the old Metal. Thus we need to ensure stock variant is used - # Remove this when OCLP is merged onto mainline - "Revert Metal Downgrade": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 99 - }, - }, - "Remove": { - "/System/Library/Frameworks/Metal.framework/Versions/A/": [ - "Metal", - "MetalOld.dylib", - ], - "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSCore.framework/Versions/A": [ - "MPSCore", - ], - }, - }, - - # Monterey has a WebKit sandboxing issue where many UI elements fail to render - # This patch simple replaces the sandbox profile with one supporting our GPUs - # Note: Neither Big Sur nor Ventura have this issue - "WebKit Monterey Common": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.monterey, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.monterey, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "WebKit.framework": "11.6" - }, - }, - "Install Non-Root": { - "/Library/Apple/System/Library/StagedFrameworks/Safari": { - "WebKit.framework": "11.6" - }, - }, - }, - - # Intel Ivy Bridge, Haswell and Nvidia Kepler are Metal 3802-based GPUs - # Due to this, we need to re-add 3802 compiler support to the Metal stack - "Metal 3802 Common": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "Metal.framework": f"12.5-3802-{self.os_major}", - }, - "/System/Library/PrivateFrameworks": { - "MTLCompiler.framework": "12.5-3802", - "GPUCompiler.framework": "12.5-3802", - }, - "/System/Library/Sandbox/Profiles": { - "com.apple.mtlcompilerservice.sb": "12.5-3802", - } - }, - }, - - # Support for 3802 GPUs were broken with 13.3+ - # Downgrades 31001 stack to 13.2.1, however nukes AMFI support - "Metal 3802 Common Extended": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 4 # 13.3 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "Metal.framework": f"13.2.1-{self.os_major}", - **({ "CoreImage.framework": "14.0 Beta 3" } if self.os_major >= os_data.os_data.sonoma else {}), - }, - "/System/Library/PrivateFrameworks": { - **({ "MTLCompiler.framework": "13.2.1" } if self.os_major == os_data.os_data.ventura else {}), - **({ "GPUCompiler.framework": "13.2.1" } if self.os_major == os_data.os_data.ventura else {}), - "RenderBox.framework": "13.2.1-3802" if self.os_major == os_data.os_data.ventura else "14.0-3802", - - # More issues for 3802, now with 14.2 Beta 2+... - # If there is a god, they clearly despise us and legacy Macs. - **({ "MTLCompiler.framework": "14.2 Beta 1" } if self.os_float >= self.macOS_14_2 else {}), - **({ "GPUCompiler.framework": "14.2 Beta 1" } if self.os_float >= self.macOS_14_2 else {}), - }, - }, - }, - - # Primarily for AMD GCN GPUs - "Revert GVA Downgrade": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Remove": { - "/System/Library/PrivateFrameworks/AppleGVA.framework/Versions/A/": [ - "AppleGVA", - ], - "/System/Library/PrivateFrameworks/AppleGVACore.framework/Versions/A/": [ - "AppleGVACore", - ], - }, - }, - - # For GPUs last natively supported in Catalina/Big Sur - # Restores DRM support - "Catalina GVA": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.monterey, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/PrivateFrameworks": { - "AppleGVA.framework": "11.7.10", - "AppleGVACore.framework": "11.7.10", - }, - }, - }, - - # For GPUs last natively supported in Monterey - # Restores DRM support - "Monterey GVA": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/PrivateFrameworks": { - "AppleGVA.framework": "12.5", - "AppleGVACore.framework": "12.5", - }, - }, - }, - - "High Sierra GVA": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": self.non_metal_os_support[0], - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/PrivateFrameworks": { - "AppleGVA.framework": "10.13.6", - "AppleGVACore.framework": "10.15.7", - }, - }, - }, - - "Big Sur OpenCL": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.monterey, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "OpenCL.framework": "11.6", - }, - }, - }, - - "Monterey OpenCL": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "OpenCL.framework": "12.5", - }, - }, - }, - - # In Ventura, Apple added AVX2.0 code to AMD's OpenCL/GL compilers - "AMD OpenCL": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "OpenCL.framework": "12.5 non-AVX2.0", - "OpenGL.framework": "12.5 non-AVX2.0", - }, - }, - }, - - "Nvidia Tesla": { - "Display Name": "Graphics: Nvidia Tesla", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "GeForceGA.bundle": "10.13.6", - "GeForceTesla.kext": "10.13.6", - "GeForceTeslaGLDriver.bundle": "10.13.6", - "GeForceTeslaVADriver.bundle": "10.13.6", - "NVDANV50HalTesla.kext": "10.13.6", - "NVDAResmanTesla.kext": "10.13.6", - # Apple dropped NVDAStartup in 12.0 Beta 7 (XNU 21.1) - **({ "NVDAStartup.kext": "12.0 Beta 6" } if self.os_float >= self.macOS_12_0_B7 else {}) - }, - }, - }, - "Nvidia Kepler": { - "Display Name": "Graphics: Nvidia Kepler", - "OS Support": { - "Minimum OS Support": { - # 12.0 beta 7 (XNU 21.1) - "OS Major": os_data.os_data.monterey, - "OS Minor": 1 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "GeForce.kext": self.__resolve_kepler_geforce_framebuffers(), - "NVDAGF100Hal.kext": "12.0 Beta 6", - "NVDAGK100Hal.kext": "12.0 Beta 6", - "NVDAResman.kext": "12.0 Beta 6", - "NVDAStartup.kext": "12.0 Beta 6", - "GeForceAIRPlugin.bundle": "11.0 Beta 3", - "GeForceGLDriver.bundle": "11.0 Beta 3", - "GeForceMTLDriver.bundle": "11.0 Beta 3" if self.os_major <= os_data.os_data.monterey else f"11.0 Beta 3-22", - "GeForceVADriver.bundle": "12.0 Beta 6", - }, - "/System/Library/Frameworks": { - # XNU 21.6 (macOS 12.5) - **({ "Metal.framework": "12.5 Beta 2"} if (self.os_float >= self.macOS_12_5 and self.os_major < os_data.os_data.ventura) else {}), - }, - "/System/Library/PrivateFrameworks": { - "GPUCompiler.framework": "11.6", - }, - }, - }, - "Nvidia Web Drivers": { - "Display Name": "Graphics: Nvidia Web Drivers", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "GeForceAIRPluginWeb.bundle": "WebDriver-387.10.10.10.40.140", - "GeForceGLDriverWeb.bundle": "WebDriver-387.10.10.10.40.140", - "GeForceMTLDriverWeb.bundle": "WebDriver-387.10.10.10.40.140", - "GeForceVADriverWeb.bundle": "WebDriver-387.10.10.10.40.140", - - # Tesla-only files - "GeForceTeslaGAWeb.bundle": "WebDriver-387.10.10.10.40.140", - "GeForceTeslaGLDriverWeb.bundle": "WebDriver-387.10.10.10.40.140", - "GeForceTeslaVADriverWeb.bundle": "WebDriver-387.10.10.10.40.140", - }, - "/System/Library/PrivateFrameworks": { - # Restore OpenCL by adding missing compiler files - **({ "GPUCompiler.framework": "11.6"} if self.os_major >= os_data.os_data.monterey else {}), - }, - }, - "Install Non-Root": { - "/Library/Extensions": { - "GeForceWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAGF100HalWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAGK100HalWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAGM100HalWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAGP100HalWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAResmanWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAStartupWeb.kext": "WebDriver-387.10.10.10.40.140", - - # Tesla-only files - "GeForceTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDANV50HalTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", - "NVDAResmanTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", - }, - - # Disabled due to issues with Pref pane stripping 'nvda_drv' NVRAM - # variables - # "/Library/PreferencePanes": { - # "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", - # }, - # "/Library/LaunchAgents": { - # "com.nvidia.nvagent.plist": "WebDriver-387.10.10.10.40.140", - # }, - # "/Library/LaunchDaemons": { - # "com.nvidia.nvroothelper.plist": "WebDriver-387.10.10.10.40.140", - # }, - }, - "Remove": { - "/System/Library/Extensions": [ - # Due to how late the Auxiliary cache loads, NVDAStartup will match first and then the Web Driver kexts. - # This has no effect for Maxwell and Pascal, however for development purposes, Tesla and Kepler are partially supported. - "NVDAStartup.kext", - ], - }, - }, - "AMD TeraScale Common": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMDFramebuffer.kext": "10.13.6", - "AMDLegacyFramebuffer.kext": "10.13.6", - "AMDLegacySupport.kext": "10.13.6", - "AMDShared.bundle": "10.13.6", - "AMDSupport.kext": "10.13.6", - }, - }, - "Remove": { - "/System/Library/Extensions": [ - "AMD7000Controller.kext", - "AMD8000Controller.kext", - "AMD9000Controller.kext", - "AMD9500Controller.kext", - "AMD10000Controller.kext", - ], - }, - }, - - "AMD TeraScale 1": { - "Display Name": "Graphics: AMD TeraScale 1", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMD2400Controller.kext": "10.13.6", - "AMD2600Controller.kext": "10.13.6", - "AMD3800Controller.kext": "10.13.6", - "AMD4600Controller.kext": "10.13.6", - "AMD4800Controller.kext": "10.13.6", - "ATIRadeonX2000.kext": "10.13.6" if self.os_major < os_data.os_data.ventura else "10.13.6 TS1", - "ATIRadeonX2000GA.plugin": "10.13.6", - "ATIRadeonX2000GLDriver.bundle": "10.13.6", - "ATIRadeonX2000VADriver.bundle": "10.13.6", - }, - }, - "Remove": { - "/System/Library/Extensions": [ - # Following removals are a work around for 0.4.3 and older root patches - # Previously TS1 and TS2 patch sets were shared, now they're split off - # Due to this, updating to 0.4.4 or newer can break kmutil linking - "AMD5000Controller.kext", - "AMD6000Controller.kext", - "AMDRadeonVADriver.bundle", - "AMDRadeonVADriver2.bundle", - "AMDRadeonX3000.kext", - "AMDRadeonX3000GLDriver.bundle", - ], - }, - }, - "AMD TeraScale 2": { - "Display Name": "Graphics: AMD TeraScale 2", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMD5000Controller.kext": "10.13.6", - "AMD6000Controller.kext": "10.13.6", - "AMDRadeonVADriver.bundle": "10.13.6", - "AMDRadeonVADriver2.bundle": "10.13.6", - "AMDRadeonX3000.kext": "10.13.6", - "AMDRadeonX3000GLDriver.bundle": "10.13.6", - }, - }, - }, - "AMD Legacy GCN": { - "Display Name": "Graphics: AMD Legacy GCN", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMD7000Controller.kext": "12.5", - "AMD8000Controller.kext": "12.5", - "AMD9000Controller.kext": "12.5", - "AMD9500Controller.kext": "12.5", - "AMD10000Controller.kext": "12.5", - "AMDRadeonX4000.kext": self.__resolve_monterey_framebuffers(), - "AMDRadeonX4000HWServices.kext": "12.5", - "AMDFramebuffer.kext": "12.5" if self.os_float < self.macOS_13_3 else "12.5-GCN", - "AMDSupport.kext": "12.5", - - "AMDRadeonVADriver.bundle": "12.5", - "AMDRadeonVADriver2.bundle": "12.5", - "AMDRadeonX4000GLDriver.bundle": "12.5", - "AMDMTLBronzeDriver.bundle": "12.5", - "AMDShared.bundle": "12.5", - }, - }, - }, - - # For MacBookPro14,3 (and other AMD dGPUs that no longer function in Sonoma) - # iMac18,2/3 still function with the generic framebuffer, however if issues arise - # we'll downgrade them as well. - "AMD Legacy GCN v2": { - "Display Name": "Graphics: AMD Legacy GCN (2017)", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.sonoma, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMD9500Controller.kext": "13.5.2", - "AMD10000Controller.kext": "13.5.2", - "AMDRadeonX4000.kext": "13.5.2", - "AMDRadeonX4000HWServices.kext": "13.5.2", - "AMDFramebuffer.kext": "13.5.2", - "AMDSupport.kext": "13.5.2", - - "AMDRadeonVADriver.bundle": "13.5.2", - "AMDRadeonVADriver2.bundle": "13.5.2", - "AMDRadeonX4000GLDriver.bundle": "13.5.2", - "AMDMTLBronzeDriver.bundle": "13.5.2", - "AMDShared.bundle": "13.5.2", - }, - }, - }, - - # Used only for AMD Polaris with host lacking AVX2.0 - # Note missing framebuffers are not restored (ex. 'ATY,Berbice') - "AMD Legacy Polaris": { - "Display Name": "Graphics: AMD Legacy Polaris", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMDRadeonX4000.kext": self.__resolve_monterey_framebuffers(), - "AMDRadeonX4000HWServices.kext": "12.5", - - "AMDRadeonVADriver2.bundle": "12.5", - "AMDRadeonX4000GLDriver.bundle": "12.5", - "AMDMTLBronzeDriver.bundle": "12.5", - "AMDShared.bundle": "12.5", - }, - }, - }, - "AMD Legacy Vega": { - "Display Name": "Graphics: AMD Legacy Vega", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMDRadeonX5000.kext": self.__resolve_monterey_framebuffers(), - - "AMDRadeonVADriver2.bundle": "12.5", - "AMDRadeonX5000GLDriver.bundle": "12.5", - "AMDRadeonX5000MTLDriver.bundle": "12.5", - "AMDRadeonX5000Shared.bundle": "12.5", - - "AMDShared.bundle": "12.5", - }, - }, - }, - # Support mixed legacy and modern AMD GPUs - # Specifically systems using AMD GCN 1-3 and Vega (ex. MacPro6,1 with eGPU) - # Assume 'AMD Legacy GCN' patchset is installed alongside this - "AMD Legacy Vega Extended": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AMDRadeonX5000HWServices.kext": "12.5", - }, - }, - }, - "Intel Ironlake": { - "Display Name": "Graphics: Intel Ironlake", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleIntelHDGraphics.kext": "10.13.6", - "AppleIntelHDGraphicsFB.kext": "10.13.6", - "AppleIntelHDGraphicsGA.plugin": "10.13.6", - "AppleIntelHDGraphicsGLDriver.bundle": "10.13.6", - "AppleIntelHDGraphicsVADriver.bundle": "10.13.6", - }, - }, - }, - "Intel Sandy Bridge": { - "Display Name": "Graphics: Intel Sandy Bridge", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleIntelHD3000Graphics.kext": "10.13.6", - "AppleIntelHD3000GraphicsGA.plugin": "10.13.6", - "AppleIntelHD3000GraphicsGLDriver.bundle": "10.13.6", - "AppleIntelHD3000GraphicsVADriver.bundle": "10.13.6", - "AppleIntelSNBGraphicsFB.kext": "10.13.6", - "AppleIntelSNBVA.bundle": "10.13.6", - }, - }, - }, - "Intel Ivy Bridge": { - "Display Name": "Graphics: Intel Ivy Bridge", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.monterey, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleIntelHD4000GraphicsGLDriver.bundle": "11.7.10", - "AppleIntelHD4000GraphicsMTLDriver.bundle": "11.7.10" if self.os_major < os_data.os_data.ventura else "11.7.10-22", - "AppleIntelHD4000GraphicsVADriver.bundle": "11.7.10", - "AppleIntelFramebufferCapri.kext": self.__resolve_ivy_bridge_framebuffers(), - "AppleIntelHD4000Graphics.kext": self.__resolve_ivy_bridge_framebuffers(), - "AppleIntelIVBVA.bundle": "11.7.10", - "AppleIntelGraphicsShared.bundle": "11.7.10", # libIGIL-Metal.dylib pulled from 11.0 Beta 6 - }, - }, - }, - "Intel Haswell": { - "Display Name": "Graphics: Intel Haswell", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleIntelFramebufferAzul.kext": self.__resolve_monterey_framebuffers(), - "AppleIntelHD5000Graphics.kext": self.__resolve_monterey_framebuffers(), - "AppleIntelHD5000GraphicsGLDriver.bundle": "12.5", - "AppleIntelHD5000GraphicsMTLDriver.bundle": "12.5", - "AppleIntelHD5000GraphicsVADriver.bundle": "12.5", - "AppleIntelHSWVA.bundle": "12.5", - "AppleIntelGraphicsShared.bundle": "12.5", - }, - }, - }, - "Intel Broadwell": { - "Display Name": "Graphics: Intel Broadwell", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleIntelBDWGraphics.kext": self.__resolve_monterey_framebuffers(), - "AppleIntelBDWGraphicsFramebuffer.kext": self.__resolve_monterey_framebuffers(), - "AppleIntelBDWGraphicsGLDriver.bundle": "12.5", - "AppleIntelBDWGraphicsMTLDriver.bundle": "12.5-22", - "AppleIntelBDWGraphicsVADriver.bundle": "12.5", - "AppleIntelBDWGraphicsVAME.bundle": "12.5", - "AppleIntelGraphicsShared.bundle": "12.5", - }, - }, - }, - "Intel Skylake": { - "Display Name": "Graphics: Intel Skylake", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleIntelSKLGraphics.kext": self.__resolve_monterey_framebuffers(), - "AppleIntelSKLGraphicsFramebuffer.kext": self.__resolve_monterey_framebuffers(), - "AppleIntelSKLGraphicsGLDriver.bundle": "12.5", - "AppleIntelSKLGraphicsMTLDriver.bundle": "12.5", - "AppleIntelSKLGraphicsVADriver.bundle": "12.5", - "AppleIntelSKLGraphicsVAME.bundle": "12.5", - "AppleIntelGraphicsShared.bundle": "12.5", - }, - }, - }, - }, - "Audio": { - "Legacy Realtek": { - "Display Name": "Audio: Legacy Realtek", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.sierra, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - # For iMac7,1 and iMac8,1 units with legacy Realtek HD Audio - "Install": { - "/System/Library/Extensions": { - "AppleHDA.kext": "10.11.6", - "IOAudioFamily.kext": "10.11.6", - }, - }, - "Remove": { - "/System/Library/Extensions": [ - "AppleVirtIO.kext", - "AppleVirtualGraphics.kext", - "AppleVirtualPlatform.kext", - "ApplePVPanic.kext", - "AppleVirtIOStorage.kext", - ], - }, - }, - # For Mac Pros with non-UGA/GOP GPUs - "Legacy Non-GOP": { - "Display Name": "Audio: Legacy non-GOP", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.mojave, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleHDA.kext": "10.13.6", - }, - }, - }, - }, - "Networking": { - "Legacy Wireless": { - "Display Name": "Networking: Legacy Wireless", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.monterey, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/usr/libexec": { - "airportd": "11.7.10" if self.affected_by_cve_2024_23227 is False else "11.7.10-Sandbox", - }, - "/System/Library/CoreServices": { - "WiFiAgent.app": "11.7.10", - }, - }, - "Install Non-Root": { - "/Library/Application Support/SkyLightPlugins": { - **({ "CoreWLAN.dylib": "SkyLightPlugins" } if self.os_major == os_data.os_data.monterey else {}), - **({ "CoreWLAN.txt": "SkyLightPlugins" } if self.os_major == os_data.os_data.monterey else {}), - }, - }, - }, - "Legacy Wireless Extended": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/usr/libexec": { - "wps": "12.7.2", - "wifip2pd": "12.7.2", - }, - "/System/Library/Frameworks": { - "CoreWLAN.framework": "12.7.2", - }, - "/System/Library/PrivateFrameworks": { - "CoreWiFi.framework": "12.7.2", - "IO80211.framework": "12.7.2", - "WiFiPeerToPeer.framework": "12.7.2", - }, - }, - }, - # May lord have mercy on our souls - # Applicable for BCM943324, BCM94331, BCM94360, BCM943602 - "Modern Wireless": { - "Display Name": "Networking: Modern Wireless", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.sonoma, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/usr/libexec": { - "airportd": "13.6.5", - "wifip2pd": "13.6.5", - }, - "/System/Library/Frameworks": { - "CoreWLAN.framework": f"13.6.5-{self.os_major}", - }, - "/System/Library/PrivateFrameworks": { - "CoreWiFi.framework": f"13.6.5-{self.os_major}", - "IO80211.framework": f"13.6.5-{self.os_major}", - "WiFiPeerToPeer.framework": f"13.6.5-{self.os_major}", - }, - }, - }, - }, - "Brightness": { - "Legacy Backlight Control": { - "Display Name": "Brightness: Legacy Backlight Control", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.high_sierra, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "AppleBacklight.kext": "10.12.6", - "AppleBacklightExpert.kext": "10.12.6", - }, - "/System/Library/PrivateFrameworks": { - "DisplayServices.framework": "10.12.6", - }, - }, - "Remove": { - "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": [ - "AGDCBacklightControl.kext", - ], - }, - }, - }, - "Miscellaneous": { - "Legacy GMUX": { - "Display Name": "Miscellaneous: Legacy GMUX", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.high_sierra, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": { - "AppleMuxControl.kext": "10.12.6", - }, - }, - "Remove": { - "/System/Library/Extensions": [ - "AppleBacklight.kext", - ], - "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": [ - "AGDCBacklightControl.kext", - "AppleMuxControl.kext", - ], - }, - }, - "Legacy Keyboard Backlight": { - "Display Name": "Miscellaneous: Legacy Keyboard Backlight", - "OS Support": { - "Minimum OS Support": { - "OS Major": self.non_metal_os_support[0], - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": self.non_metal_os_support[-1], - "OS Minor": 99 - }, - }, - "Processes": { - "/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist Moraea_BacklightHack -bool true": True, - }, - }, - "Legacy USB 1.1": { - "Display Name": "Miscellaneous: Legacy USB 1.1", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.ventura, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions": { - "IOUSBHostFamily.kext": "12.6.2" if self.os_float < self.macOS_14_4 else "12.6.2-23.4", - }, - }, - }, - # Injection of UHCI/OHCI causes a panic on 14.1+ - "Legacy USB 1.1 Extended": { - "Display Name": "", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.sonoma, - "OS Minor": 1 # macOS 14.1 (XNU 23.1) - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Extensions/IOUSBHostFamily.kext/Contents/PlugIns": { - "AppleUSBOHCI.kext": "12.6.2-USB", - "AppleUSBOHCIPCI.kext": "12.6.2-USB", - "AppleUSBUHCI.kext": "12.6.2-USB", - "AppleUSBUHCIPCI.kext": "12.6.2-USB", - }, - }, - }, - # With macOS 14.1, daemon won't load if not on root volume - "PCIe FaceTime Camera": { - "Display Name": "Miscellaneous: PCIe FaceTime Camera", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.sonoma, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources": { - "AppleCamera.plugin": "14.0 Beta 1" - }, - "/System/Library/LaunchDaemons": { - "com.apple.cmio.AppleCameraAssistant.plist": "14.0 Beta 1" - }, - }, - "Remove Non-Root": { - "/Library/CoreMediaIO/Plug-Ins/DAL": [ - "AppleCamera.plugin" - ], - "/Library/LaunchDaemons": [ - "com.apple.cmio.AppleCameraAssistant.plist" - ], - } - }, - "T1 Security Chip": { - "Display Name": "Miscellaneous: T1 Security Chip", - "OS Support": { - "Minimum OS Support": { - "OS Major": os_data.os_data.sonoma, - "OS Minor": 0 - }, - "Maximum OS Support": { - "OS Major": os_data.os_data.max_os, - "OS Minor": 99 - }, - }, - "Install": { - "/System/Library/Frameworks": { - "LocalAuthentication.framework": f"13.6-{self.os_major}" # Required for Password Authentication (SharedUtils.framework) - }, - "/System/Library/PrivateFrameworks": { - "EmbeddedOSInstall.framework": "13.6" # Required for biometrickitd - }, - # Required for Apple Pay - "/usr/lib": { - "libNFC_Comet.dylib": "13.6", - "libNFC_HAL.dylib": "13.6", - - "libnfshared.dylib": "13.6", - "libnfshared.dylibOld.dylib": "13.6", - "libnfstorage.dylib": "13.6", - "libnfrestore.dylib": "13.6", - - "libPN548_API.dylib": "13.6" - }, - "/usr/libexec": { - "biometrickitd": "13.6", # Required for Touch ID - "nfcd": "13.6", # Required for Apple Pay - "nfrestore_service": "13.6", # Required for Apple Pay - }, - "/usr/standalone/firmware/nfrestore/firmware/fw": { - "PN549_FW_02_01_5A_rev88207.bin": "13.6", - "SN100V_FW_A3_01_01_81_rev127208.bin": "13.6", - "SN200V_FW_B1_02_01_86_rev127266.bin": "13.6", - "SN300V_FW_B0_02_01_22_rev129172.bin": "13.6", - } - }, - }, - }, - } diff --git a/opencore_legacy_patcher/efi_builder/build.py b/opencore_legacy_patcher/efi_builder/build.py index 568b3bcea..d43626faf 100644 --- a/opencore_legacy_patcher/efi_builder/build.py +++ b/opencore_legacy_patcher/efi_builder/build.py @@ -67,6 +67,9 @@ class BuildOpenCore: support.BuildSupport(self.model, self.constants, self.config).enable_kext("Lilu.kext", self.constants.lilu_version, self.constants.lilu_path) self.config["Kernel"]["Quirks"]["DisableLinkeditJettison"] = True + # macOS Sequoia support for Lilu plugins + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -lilubetaall" + # Call support functions for function in [ firmware.BuildFirmware, diff --git a/opencore_legacy_patcher/efi_builder/graphics_audio.py b/opencore_legacy_patcher/efi_builder/graphics_audio.py index 35cf86b53..93954291a 100644 --- a/opencore_legacy_patcher/efi_builder/graphics_audio.py +++ b/opencore_legacy_patcher/efi_builder/graphics_audio.py @@ -354,7 +354,8 @@ class BuildGraphicsAudio: # Due to regression in AppleALC 1.6.4+, temporarily use 1.6.3 and set override if support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleALC.kext")["Enabled"] is True: - self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -lilubetaall" + if "-lilubetaall" not in self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"]: + self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -lilubetaall" def _firmware_handling(self) -> None: diff --git a/opencore_legacy_patcher/efi_builder/misc.py b/opencore_legacy_patcher/efi_builder/misc.py index 2334fff49..a930f6745 100644 --- a/opencore_legacy_patcher/efi_builder/misc.py +++ b/opencore_legacy_patcher/efi_builder/misc.py @@ -18,7 +18,8 @@ from ..detections import device_probe from ..datasets import ( model_array, smbios_data, - cpu_data + cpu_data, + os_data ) @@ -64,6 +65,12 @@ xw if self.constants.fu_status is False: return + if not self.model in smbios_data.smbios_dictionary: + return + + if smbios_data.smbios_dictionary[self.model]["Max OS Supported"] >= os_data.os_data.sonoma: + return + support.BuildSupport(self.model, self.constants, self.config).enable_kext("FeatureUnlock.kext", self.constants.featureunlock_version, self.constants.featureunlock_path) if self.constants.fu_arguments is not None: logging.info(f"- Adding additional FeatureUnlock args: {self.constants.fu_arguments}") @@ -199,6 +206,7 @@ xw logging.info("- Enabling SPI-based top case support") support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleHSSPISupport.kext", self.constants.apple_spi_version, self.constants.apple_spi_path) support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleHSSPIHIDDriver.kext", self.constants.apple_spi_hid_version, self.constants.apple_spi_hid_path) + support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleTopCaseInjector.kext", self.constants.topcase_inj_version, self.constants.top_case_inj_path) #On-device probing @@ -298,7 +306,7 @@ xw # And MacPro4,1, MacPro5,1 and Xserve3,1 are the only post-Penryn Macs that lack an internal USB hub # - Ref: https://techcommunity.microsoft.com/t5/microsoft-usb-blog/reasons-to-avoid-companion-controllers/ba-p/270710 # - # To be paired for sys_patch_dict.py's 'Legacy USB 1.1' patchset + # To be paired for usb11.py's 'Legacy USB 1.1' patchset # # Note: With macOS 14.1, injection of these kexts causes a panic. # To avoid this, a MaxKernel is configured with XNU 23.0.0 (macOS 14.0). @@ -380,4 +388,5 @@ xw support.BuildSupport(self.model, self.constants, self.config).enable_kext("corecrypto_T1.kext", self.constants.t1_corecrypto_version, self.constants.t1_corecrypto_path) support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleSSE.kext", self.constants.t1_sse_version, self.constants.t1_sse_path) support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleKeyStore.kext", self.constants.t1_key_store_version, self.constants.t1_key_store_path) - support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleCredentialManager.kext", self.constants.t1_credential_version, self.constants.t1_credential_path) \ No newline at end of file + support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleCredentialManager.kext", self.constants.t1_credential_version, self.constants.t1_credential_path) + support.BuildSupport(self.model, self.constants, self.config).enable_kext("KernelRelayHost.kext", self.constants.kernel_relay_version, self.constants.kernel_relay_path) \ No newline at end of file diff --git a/opencore_legacy_patcher/efi_builder/networking/wired.py b/opencore_legacy_patcher/efi_builder/networking/wired.py index b0360db0b..14f408708 100644 --- a/opencore_legacy_patcher/efi_builder/networking/wired.py +++ b/opencore_legacy_patcher/efi_builder/networking/wired.py @@ -10,7 +10,8 @@ from ...detections import device_probe from ...datasets import ( smbios_data, - cpu_data + cpu_data, + os_data ) @@ -55,6 +56,11 @@ class BuildWiredNetworking: # the kernel driver to prevent a kernel panic # - DriverKit: com.apple.DriverKit.AppleUserECM.dext # - Kext: AppleUSBECM.kext + if not self.model in smbios_data.smbios_dictionary: + return + if smbios_data.smbios_dictionary[self.model]["Max OS Supported"] >= os_data.os_data.sonoma: + return + support.BuildSupport(self.model, self.constants, self.config).enable_kext("ECM-Override.kext", self.constants.ecm_override_version, self.constants.ecm_override_path) @@ -66,6 +72,8 @@ class BuildWiredNetworking: # See ECM logic for why it's always enabled if not self.model in smbios_data.smbios_dictionary: return + if smbios_data.smbios_dictionary[self.model]["Max OS Supported"] >= os_data.os_data.sonoma: + return support.BuildSupport(self.model, self.constants, self.config).enable_kext("CatalinaIntelI210Ethernet.kext", self.constants.i210_version, self.constants.i210_path) # Ivy Bridge and newer natively support DriverKit, so set MinKernel to 23.0.0 if smbios_data.smbios_dictionary[self.model]["CPU Generation"] >= cpu_data.CPUGen.ivy_bridge.value: diff --git a/opencore_legacy_patcher/efi_builder/security.py b/opencore_legacy_patcher/efi_builder/security.py index 6eb1819d5..765bf6bdb 100644 --- a/opencore_legacy_patcher/efi_builder/security.py +++ b/opencore_legacy_patcher/efi_builder/security.py @@ -12,6 +12,11 @@ from .. import constants from ..support import utilities from ..detections import device_probe +from ..datasets import ( + smbios_data, + os_data +) + class BuildSecurity: """ @@ -83,5 +88,6 @@ class BuildSecurity: logging.info("- Disabling SecureBootModel") self.config["Misc"]["Security"]["SecureBootModel"] = "Disabled" - logging.info("- Enabling AMFIPass") - support.BuildSupport(self.model, self.constants, self.config).enable_kext("AMFIPass.kext", self.constants.amfipass_version, self.constants.amfipass_path) + if smbios_data.smbios_dictionary[self.model]["Max OS Supported"] < os_data.os_data.sonoma: + logging.info("- Enabling AMFIPass") + support.BuildSupport(self.model, self.constants, self.config).enable_kext("AMFIPass.kext", self.constants.amfipass_version, self.constants.amfipass_path) diff --git a/opencore_legacy_patcher/sucatalog/products.py b/opencore_legacy_patcher/sucatalog/products.py index 809162c51..193505a5e 100644 --- a/opencore_legacy_patcher/sucatalog/products.py +++ b/opencore_legacy_patcher/sucatalog/products.py @@ -29,7 +29,7 @@ class CatalogProducts: catalog: dict, install_assistants_only: bool = True, only_vmm_install_assistants: bool = True, - max_install_assistant_version: CatalogVersion = CatalogVersion.SONOMA + max_install_assistant_version: CatalogVersion = CatalogVersion.SEQUOIA ) -> None: self.catalog: dict = catalog self.ia_only: bool = install_assistants_only diff --git a/opencore_legacy_patcher/sucatalog/url.py b/opencore_legacy_patcher/sucatalog/url.py index 7c3be128f..1ceeabd2a 100644 --- a/opencore_legacy_patcher/sucatalog/url.py +++ b/opencore_legacy_patcher/sucatalog/url.py @@ -29,7 +29,7 @@ class CatalogURL: extension (CatalogExtension): Extension for the catalog URL """ def __init__(self, - version: CatalogVersion = CatalogVersion.SONOMA, + version: CatalogVersion = CatalogVersion.SEQUOIA, seed: SeedType = SeedType.PublicRelease, extension: CatalogExtension = CatalogExtension.PLIST ) -> None: diff --git a/opencore_legacy_patcher/support/defaults.py b/opencore_legacy_patcher/support/defaults.py index 19d34b960..a9eb8e3d2 100644 --- a/opencore_legacy_patcher/support/defaults.py +++ b/opencore_legacy_patcher/support/defaults.py @@ -115,7 +115,6 @@ class GenerateDefaults: # As we don't spoof on native models, we can safely ignore this spoof_model = self.model - if spoof_model in smbios_data.smbios_dictionary: if smbios_data.smbios_dictionary[spoof_model]["SecureBootModel"] is not None: if self.constants.sip_status is False: @@ -206,10 +205,13 @@ class GenerateDefaults: # 12.0: Legacy Wireless chipsets require root patching # 14.0: Modern Wireless chipsets require root patching - self.constants.sip_status = False - self.constants.secure_status = False - self.constants.disable_cs_lv = True - self.constants.disable_amfi = True + if self.model in smbios_data.smbios_dictionary: + if smbios_data.smbios_dictionary[self.model]["Max OS Supported"] < os_data.os_data.sonoma: + self.constants.sip_status = True + self.constants.sip_status = False + self.constants.secure_status = False + self.constants.disable_cs_lv = True + self.constants.disable_amfi = True if is_legacy_wifi is True: # 13.0: Enabling AirPlay to Mac patches breaks Control Center on legacy chipsets diff --git a/opencore_legacy_patcher/support/metallib_handler.py b/opencore_legacy_patcher/support/metallib_handler.py new file mode 100644 index 000000000..6530e1431 --- /dev/null +++ b/opencore_legacy_patcher/support/metallib_handler.py @@ -0,0 +1,274 @@ +""" +metallib_handler.py: Library for handling Metal libraries +""" + +import logging +import requests +import subprocess +import packaging.version + +from typing import cast +from pathlib import Path + +from . import network_handler, subprocess_wrapper +from .. import constants + +from ..datasets import os_data + + +METALLIB_INSTALL_PATH: str = "/Library/Application Support/Dortania/MetallibSupportPkg" +METALLIB_API_LINK: str = "https://dortania.github.io/MetallibSupportPkg/manifest.json" + +METALLIB_ASSET_LIST: list = None + + +class MetalLibraryObject: + + def __init__(self, global_constants: constants.Constants, + host_build: str, host_version: str, + ignore_installed: bool = False, passive: bool = False + ) -> None: + + self.constants: constants.Constants = global_constants + + self.host_build: str = host_build # ex. 20A5384c + self.host_version: str = host_version # ex. 11.0.1 + + self.passive: bool = passive # Don't perform actions requiring elevated privileges + + self.ignore_installed: bool = ignore_installed # If True, will ignore any installed MetallibSupportPkg PKGs and download the latest + self.metallib_already_installed: bool = False + + self.metallib_installed_path: str = "" + + self.metallib_url: str = "" + self.metallib_url_build: str = "" + self.metallib_url_version: str = "" + + self.metallib_url_is_exactly_match: bool = False + + self.metallib_closest_match_url: str = "" + self.metallib_closest_match_url_build: str = "" + self.metallib_closest_match_url_version: str = "" + + self.success: bool = False + + self.error_msg: str = "" + + self._get_latest_metallib() + + + def _get_remote_metallibs(self) -> dict: + """ + Get the MetallibSupportPkg list from the API + """ + + global METALLIB_ASSET_LIST + + logging.info("Pulling metallib list from MetallibSupportPkg API") + if METALLIB_ASSET_LIST: + return METALLIB_ASSET_LIST + + try: + results = network_handler.NetworkUtilities().get( + METALLIB_API_LINK, + headers={ + "User-Agent": f"OCLP/{self.constants.patcher_version}" + }, + timeout=5 + ) + except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError): + logging.info("Could not contact MetallibSupportPkg API") + return None + + if results.status_code != 200: + logging.info("Could not fetch Metallib list") + return None + + METALLIB_ASSET_LIST = results.json() + + return METALLIB_ASSET_LIST + + + def _get_latest_metallib(self) -> None: + """ + Get the latest MetallibSupportPkg PKG + """ + + parsed_version = cast(packaging.version.Version, packaging.version.parse(self.host_version)) + + if os_data.os_conversion.os_to_kernel(str(parsed_version.major)) < os_data.os_data.sequoia: + self.error_msg = "MetallibSupportPkg is not required for macOS Sonoma or older" + logging.warning(f"{self.error_msg}") + return + + self.metallib_installed_path = self._local_metallib_installed() + if self.metallib_installed_path: + logging.info(f"metallib already installed ({Path(self.metallib_installed_path).name}), skipping") + self.metallib_already_installed = True + self.success = True + return + + remote_metallib_version = self._get_remote_metallibs() + + if remote_metallib_version is None: + logging.warning("Failed to fetch metallib list, falling back to local metallib matching") + + # First check if a metallib matching the current macOS version is installed + # ex. 13.0.1 vs 13.0 + loose_version = f"{parsed_version.major}.{parsed_version.minor}" + logging.info(f"Checking for metallibs loosely matching {loose_version}") + self.metallib_installed_path = self._local_metallib_installed(match=loose_version, check_version=True) + if self.metallib_installed_path: + logging.info(f"Found matching metallib: {Path(self.metallib_installed_path).name}") + self.metallib_already_installed = True + self.success = True + return + + older_version = f"{parsed_version.major}.{parsed_version.minor - 1 if parsed_version.minor > 0 else 0}" + logging.info(f"Checking for metallibs matching {older_version}") + self.metallib_installed_path = self._local_metallib_installed(match=older_version, check_version=True) + if self.metallib_installed_path: + logging.info(f"Found matching metallib: {Path(self.metallib_installed_path).name}") + self.metallib_already_installed = True + self.success = True + return + + logging.warning(f"Couldn't find metallib matching {self.host_version} or {older_version}, please install one manually") + + self.error_msg = f"Could not contact MetallibSupportPkg API, and no metallib matching {self.host_version} ({self.host_build}) or {older_version} was installed.\nPlease ensure you have a network connection or manually install a metallib." + + return + + + # First check exact match + for metallib in remote_metallib_version: + if (metallib["build"] != self.host_build): + continue + self.metallib_url = metallib["url"] + self.metallib_url_build = metallib["build"] + self.metallib_url_version = metallib["version"] + self.metallib_url_is_exactly_match = True + break + + # If no exact match, check for closest match + if self.metallib_url == "": + for metallib in remote_metallib_version: + metallib_version = cast(packaging.version.Version, packaging.version.parse(metallib["version"])) + if metallib_version > parsed_version: + continue + if metallib_version.major != parsed_version.major: + continue + if metallib_version.minor not in range(parsed_version.minor - 1, parsed_version.minor + 1): + continue + + # The metallib list is already sorted by version then date, so the first match is the closest + self.metallib_closest_match_url = metallib["url"] + self.metallib_closest_match_url_build = metallib["build"] + self.metallib_closest_match_url_version = metallib["version"] + self.metallib_url_is_exactly_match = False + break + + if self.metallib_url == "": + if self.metallib_closest_match_url == "": + logging.warning(f"No metallibs found for {self.host_build} ({self.host_version})") + self.error_msg = f"No metallibs found for {self.host_build} ({self.host_version})" + return + logging.info(f"No direct match found for {self.host_build}, falling back to closest match") + logging.info(f"Closest Match: {self.metallib_closest_match_url_build} ({self.metallib_closest_match_url_version})") + + self.metallib_url = self.metallib_closest_match_url + self.metallib_url_build = self.metallib_closest_match_url_build + self.metallib_url_version = self.metallib_closest_match_url_version + else: + logging.info(f"Direct match found for {self.host_build} ({self.host_version})") + + + # Check if this metallib is already installed + self.metallib_installed_path = self._local_metallib_installed(match=self.metallib_url_build) + if self.metallib_installed_path: + logging.info(f"metallib already installed ({Path(self.metallib_installed_path).name}), skipping") + self.metallib_already_installed = True + self.success = True + return + + logging.info("Following metallib is recommended:") + logging.info(f"- metallib Build: {self.metallib_url_build}") + logging.info(f"- metallib Version: {self.metallib_url_version}") + logging.info(f"- metallib URL: {self.metallib_url}") + + self.success = True + + + def _local_metallib_installed(self, match: str = None, check_version: bool = False) -> str: + """ + Check if a metallib is already installed + """ + + if self.ignore_installed: + return None + + if not Path(METALLIB_INSTALL_PATH).exists(): + return None + + for metallib_folder in Path(METALLIB_INSTALL_PATH).iterdir(): + if not metallib_folder.is_dir(): + continue + if check_version: + if match not in metallib_folder.name: + continue + else: + if not metallib_folder.name.endswith(f"-{match}"): + continue + + return metallib_folder + + return None + + + def retrieve_download(self, override_path: str = "") -> network_handler.DownloadObject: + """ + Retrieve MetallibSupportPkg PKG download object + """ + + self.success = False + self.error_msg = "" + + if self.metallib_already_installed: + logging.info("No download required, metallib already installed") + self.success = True + return None + + if self.metallib_url == "": + self.error_msg = "Could not retrieve metallib catalog, no metallib to download" + logging.error(self.error_msg) + return None + + logging.info(f"Returning DownloadObject for metallib: {Path(self.metallib_url).name}") + self.success = True + + metallib_download_path = self.constants.metallib_download_path if override_path == "" else Path(override_path) + return network_handler.DownloadObject(self.metallib_url, metallib_download_path) + + + def install_metallib(self, metallib: str = None) -> None: + """ + Install MetallibSupportPkg PKG + """ + + if not self.success: + logging.error("Cannot install metallib, no metallib was successfully retrieved") + return False + + if self.metallib_already_installed: + logging.info("No installation required, metallib already installed") + return True + + result = subprocess_wrapper.run_as_root([ + "/usr/sbin/installer", "-pkg", metallib if metallib else self.constants.metallib_download_path, "-target", "/" + ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.returncode != 0: + subprocess_wrapper.log(result) + return False + + return True \ No newline at end of file diff --git a/opencore_legacy_patcher/support/validation.py b/opencore_legacy_patcher/support/validation.py index ead7b0807..7557e52b1 100644 --- a/opencore_legacy_patcher/support/validation.py +++ b/opencore_legacy_patcher/support/validation.py @@ -2,6 +2,7 @@ validation.py: Validation class for the patcher """ +import atexit import logging import subprocess @@ -18,9 +19,13 @@ from ..support import subprocess_wrapper from ..datasets import ( example_data, model_array, - sys_patch_dict, os_data ) +from ..sys_patch.patchsets import ( + HardwarePatchsetDetection, + PatchType, + DynamicPatchset +) class PatcherValidation: @@ -119,48 +124,55 @@ class PatcherValidation: minor_kernel (int): Minor kernel version """ - patchset = sys_patch_dict.SystemPatchDictionary(major_kernel, minor_kernel, self.constants.legacy_accel_support, self.constants.detected_os_version).patchset_dict - host_os_float = float(f"{major_kernel}.{minor_kernel}") + patch_type_merge_exempt = ["MechanismPlugins"] + patch_type_overwrite_exempt = [] - for patch_subject in patchset: - for patch_core in patchset[patch_subject]: - patch_os_min_float = float(f'{patchset[patch_subject][patch_core]["OS Support"]["Minimum OS Support"]["OS Major"]}.{patchset[patch_subject][patch_core]["OS Support"]["Minimum OS Support"]["OS Minor"]}') - patch_os_max_float = float(f'{patchset[patch_subject][patch_core]["OS Support"]["Maximum OS Support"]["OS Major"]}.{patchset[patch_subject][patch_core]["OS Support"]["Maximum OS Support"]["OS Minor"]}') - if (host_os_float < patch_os_min_float or host_os_float > patch_os_max_float): - continue - for install_type in ["Install", "Install Non-Root"]: - if install_type in patchset[patch_subject][patch_core]: - for install_directory in patchset[patch_subject][patch_core][install_type]: - for install_file in patchset[patch_subject][patch_core][install_type][install_directory]: - source_file = str(self.constants.payload_local_binaries_root_path) + "/" + patchset[patch_subject][patch_core][install_type][install_directory][install_file] + install_directory + "/" + install_file - if not Path(source_file).exists(): - logging.info(f"File not found: {source_file}") - raise Exception(f"Failed to find {source_file}") - if self.verify_unused_files is True: + patchset = HardwarePatchsetDetection(self.constants, xnu_major=major_kernel, xnu_minor=minor_kernel, validation=True).patches + + for patch_core in patchset: + # Check if any unknown PathType is present + for install_type in patchset[patch_core]: + if install_type not in PatchType: + raise Exception(f"Unknown PatchType: {install_type}") + + for install_type in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.OVERWRITE_DATA_VOLUME, PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]: + if install_type in patchset[patch_core]: + for install_directory in patchset[patch_core][install_type]: + for install_file in patchset[patch_core][install_type][install_directory]: + try: + if patchset[patch_core][install_type][install_directory][install_file] in DynamicPatchset: + continue + except TypeError: + pass + + # Technically there is nothing wrong with using a .framework with OVERWRITE, but it's a good indicator of a mistake + if install_type in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.OVERWRITE_DATA_VOLUME]: + if install_file.endswith(".framework") and install_file not in patch_type_overwrite_exempt: + raise Exception(f"{install_file} used with {install_type}, are you certain this is correct?") + elif install_type in [PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]: + if not install_file.endswith(".framework") and install_file not in patch_type_merge_exempt: + raise Exception(f"{install_file} used with {install_type}, are you certain this is correct?") + + source_file = str(self.constants.payload_local_binaries_root_path) + "/" + patchset[patch_core][install_type][install_directory][install_file] + install_directory + "/" + install_file + if not Path(source_file).exists(): + logging.info(f"File not found: {source_file}") + raise Exception(f"Failed to find {source_file}") + if self.verify_unused_files is True: + if source_file not in self.active_patchset_files: self.active_patchset_files.append(source_file) logging.info(f"Validating against Darwin {major_kernel}.{minor_kernel}") - if not sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, f"OpenCore-Legacy-Patcher-{major_kernel}.{minor_kernel}.plist", None): + if not sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, f"OpenCore-Legacy-Patcher-{major_kernel}.{minor_kernel}.plist", None, None): raise Exception("Failed to generate patchset plist") # Remove the plist file after validation Path(self.constants.payload_path / f"OpenCore-Legacy-Patcher-{major_kernel}.{minor_kernel}.plist").unlink() - def _validate_sys_patch(self) -> None: + def _unmount_dmg(self) -> None: """ - Validates sys_patch modules + Unmounts the Universal-Binaries.dmg """ - - if not Path(self.constants.payload_local_binaries_root_path_dmg).exists(): - dl_obj = network_handler.DownloadObject(f"https://github.com/dortania/PatcherSupportPkg/releases/download/{self.constants.patcher_support_pkg_version}/Universal-Binaries.dmg", self.constants.payload_local_binaries_root_path_dmg) - dl_obj.download(spawn_thread=False) - if dl_obj.download_complete is False: - logging.info("Failed to download Universal-Binaries.dmg") - raise Exception("Failed to download Universal-Binaries.dmg") - - logging.info("Validating Root Patch File integrity") - if Path(self.constants.payload_path / Path("Universal-Binaries_overlay")).exists(): subprocess.run( [ @@ -183,6 +195,23 @@ class PatcherValidation: raise Exception("Failed to unmount Universal-Binaries.dmg") + + def _validate_sys_patch(self) -> None: + """ + Validates sys_patch modules + """ + + if not Path(self.constants.payload_local_binaries_root_path_dmg).exists(): + dl_obj = network_handler.DownloadObject(f"https://github.com/dortania/PatcherSupportPkg/releases/download/{self.constants.patcher_support_pkg_version}/Universal-Binaries.dmg", self.constants.payload_local_binaries_root_path_dmg) + dl_obj.download(spawn_thread=False) + if dl_obj.download_complete is False: + logging.info("Failed to download Universal-Binaries.dmg") + raise Exception("Failed to download Universal-Binaries.dmg") + + logging.info("Validating Root Patch File integrity") + + self._unmount_dmg() + output = subprocess.run( [ "/usr/bin/hdiutil", "attach", "-noverify", f"{self.constants.payload_local_binaries_root_path_dmg}", @@ -202,8 +231,9 @@ class PatcherValidation: logging.info("Mounted Universal-Binaries.dmg") + atexit.register(self._unmount_dmg) - for supported_os in [os_data.os_data.big_sur, os_data.os_data.monterey, os_data.os_data.ventura, os_data.os_data.sonoma]: + for supported_os in [os_data.os_data.big_sur, os_data.os_data.monterey, os_data.os_data.ventura, os_data.os_data.sonoma, os_data.os_data.sequoia]: for i in range(0, 10): self._validate_root_patch_files(supported_os, i) diff --git a/opencore_legacy_patcher/sys_patch/auto_patcher/start.py b/opencore_legacy_patcher/sys_patch/auto_patcher/start.py index 1ce297992..0addc45d5 100644 --- a/opencore_legacy_patcher/sys_patch/auto_patcher/start.py +++ b/opencore_legacy_patcher/sys_patch/auto_patcher/start.py @@ -12,7 +12,6 @@ import markdown2 import subprocess import webbrowser -from ..detections import DetectRootPatch from ... import constants @@ -28,6 +27,10 @@ from ...support import ( global_settings, network_handler, ) +from ..patchsets import ( + HardwarePatchsetDetection, + HardwarePatchsetValidation +) class StartAutomaticPatching: @@ -142,12 +145,12 @@ Please check the Github page for more information about this release.""" if utilities.check_seal() is True: logging.info("- Detected Snapshot seal intact, detecting patches") - patches = DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set() + patches = HardwarePatchsetDetection(self.constants).device_properties if not any(not patch.startswith("Settings") and not patch.startswith("Validation") and patches[patch] is True for patch in patches): patches = {} if patches: logging.info("- Detected applicable patches, determining whether possible to patch") - if patches["Validation: Patching Possible"] is False: + if patches[HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE] is True: logging.info("- Cannot run patching") return @@ -186,10 +189,12 @@ Please check the Github page for more information about this release.""" if self._determine_if_versions_match(): self._determine_if_boot_matches() + def _onWebviewNav(self, event): url = event.GetURL() webbrowser.open(url) + def _determine_if_versions_match(self): """ Determine if the booted version of OCLP matches the installed version diff --git a/opencore_legacy_patcher/sys_patch/detections/__init__.py b/opencore_legacy_patcher/sys_patch/detections/__init__.py deleted file mode 100644 index 367983760..000000000 --- a/opencore_legacy_patcher/sys_patch/detections/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -""" -detections: Detect and generate patch sets for the host -""" -from .detect import DetectRootPatch -from .generate import GenerateRootPatchSets \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/detections/detect.py b/opencore_legacy_patcher/sys_patch/detections/detect.py deleted file mode 100644 index 1a2db6300..000000000 --- a/opencore_legacy_patcher/sys_patch/detections/detect.py +++ /dev/null @@ -1,822 +0,0 @@ -""" -detect.py: Hardware Detection Logic for Root Patching -""" - -import logging -import plistlib -import py_sip_xnu -import packaging.version - -from pathlib import Path - -from ... import constants - -from ...detections import ( - amfi_detect, - device_probe -) -from ...support import ( - kdk_handler, - network_handler, - utilities -) -from ...datasets import ( - cpu_data, - model_array, - os_data, - sip_data, - smbios_data -) - - -class DetectRootPatch: - """ - Library for querying root volume patches applicable for booted system - """ - - def __init__(self, model: str, global_constants: constants.Constants, - os_major: int = None, os_minor: int = None, - os_build: str = None, os_version: str = None - ) -> None: - - self.model: str = model - - self.constants: constants.Constants = global_constants - if os_major is None: - os_major = self.constants.detected_os - if os_minor is None: - os_minor = self.constants.detected_os_minor - if os_build is None: - os_build = self.constants.detected_os_build - if os_version is None: - os_version = self.constants.detected_os_version - - self.os_major: int = os_major - self.os_minor: int = os_minor - self.os_build: str = os_build - self.os_version: str = os_version - - self.computer = self.constants.computer - - # GPU Patch Detection - self.nvidia_tesla = False - self.kepler_gpu = False - self.nvidia_web = False - self.amd_ts1 = False - self.amd_ts2 = False - self.iron_gpu = False - self.sandy_gpu = False - self.ivy_gpu = False - self.haswell_gpu = False - self.broadwell_gpu = False - self.skylake_gpu = False - self.legacy_gcn = False - self.legacy_gcn_v2 = False - self.legacy_polaris = False - self.legacy_vega = False - - # Misc Patch Detection - self.brightness_legacy = False - self.legacy_audio = False - self.legacy_wifi = False - self.modern_wifi = False - self.legacy_gmux = False - self.legacy_keyboard_backlight = False - self.legacy_uhci_ohci = False - self.legacy_pcie_webcam = False - self.legacy_t1_chip = False - - # Patch Requirements - self.amfi_must_disable = False - self.amfi_shim_bins = False - self.supports_metal = False - self.needs_nv_web_checks = False - self.requires_root_kc = False - - # Validation Checks - self.sip_enabled = False - self.sbm_enabled = False - self.amfi_enabled = False - self.fv_enabled = False - self.dosdude_patched = False - self.missing_kdk = False - self.has_network = False - self.unsupported_os = False - - self.missing_whatever_green = False - self.missing_nv_web_nvram = False - self.missing_nv_web_opengl = False - self.missing_nv_compat = False - - - def _detect_gpus(self): - """ - Query GPUs and set flags for applicable patches - """ - - gpus = self.constants.computer.gpus - non_metal_os = os_data.os_data.catalina - for i, gpu in enumerate(gpus): - if gpu.class_code and gpu.class_code != 0xFFFFFFFF: - logging.info(f"Found GPU ({i}): {utilities.friendly_hex(gpu.vendor_id)}:{utilities.friendly_hex(gpu.device_id)}") - if gpu.arch in [device_probe.NVIDIA.Archs.Tesla] and self.constants.force_nv_web is False: - if self.os_major > non_metal_os: - self.nvidia_tesla = True - self.amfi_must_disable = True - if os_data.os_data.ventura in self.constants.legacy_accel_support: - self.amfi_shim_bins = True - self.legacy_keyboard_backlight = self._check_legacy_keyboard_backlight() - self.requires_root_kc = True - elif gpu.arch == device_probe.NVIDIA.Archs.Kepler and self.constants.force_nv_web is False: - if self.os_major > os_data.os_data.big_sur: - # Kepler drivers were dropped with Beta 7 - # 12.0 Beta 5: 21.0.0 - 21A5304g - # 12.0 Beta 6: 21.1.0 - 21A5506j - # 12.0 Beta 7: 21.1.0 - 21A5522h - if ( - self.os_major >= os_data.os_data.ventura or - ( - "21A5506j" not in self.os_build and - self.os_major == os_data.os_data.monterey and - self.os_minor > 0 - ) - ): - self.kepler_gpu = True - self.supports_metal = True - if self.os_major >= os_data.os_data.ventura: - self.amfi_must_disable = True - if (self.os_major == os_data.os_data.ventura and self.os_minor >= 4) or self.os_major > os_data.os_data.ventura: - self.amfi_shim_bins = True - elif gpu.arch in [ - device_probe.NVIDIA.Archs.Fermi, - device_probe.NVIDIA.Archs.Kepler, - device_probe.NVIDIA.Archs.Maxwell, - device_probe.NVIDIA.Archs.Pascal, - ]: - if self.os_major > os_data.os_data.mojave: - self.nvidia_web = True - self.amfi_must_disable = True - if os_data.os_data.ventura in self.constants.legacy_accel_support: - self.amfi_shim_bins = True - self.needs_nv_web_checks = True - self.requires_root_kc = True - elif gpu.arch == device_probe.AMD.Archs.TeraScale_1: - if self.os_major > non_metal_os: - self.amd_ts1 = True - self.amfi_must_disable = True - if os_data.os_data.ventura in self.constants.legacy_accel_support: - self.amfi_shim_bins = True - self.requires_root_kc = True - elif gpu.arch == device_probe.AMD.Archs.TeraScale_2: - if self.os_major > non_metal_os: - self.amd_ts2 = True - self.amfi_must_disable = True - if os_data.os_data.ventura in self.constants.legacy_accel_support: - self.amfi_shim_bins = True - self.requires_root_kc = True - elif gpu.arch in [ - device_probe.AMD.Archs.Legacy_GCN_7000, - device_probe.AMD.Archs.Legacy_GCN_8000, - device_probe.AMD.Archs.Legacy_GCN_9000, - device_probe.AMD.Archs.Polaris, - ]: - if self.os_major > os_data.os_data.monterey: - if self.constants.computer.rosetta_active is True: - continue - - if gpu.arch == device_probe.AMD.Archs.Polaris: - # Check if host supports AVX2.0 - # If not, enable legacy GCN patch - # MacBookPro13,3 does include an unsupported framebuffer, thus we'll patch to ensure - # full compatibility (namely power states, etc) - # Reference: https://github.com/dortania/bugtracker/issues/292 - # TODO: Probe framebuffer families further - # Sonoma note: MacBookPro14,3 has the same issue... - # iMac18,2/3 is partially affected, however currently it seems the generic framebuffer - # is sufficient. Only MacBookPro14,3 needs this for dGPU handling - if self.model not in ["MacBookPro13,3", "MacBookPro14,3"]: - if "AVX2" in self.constants.computer.cpu.leafs: - continue - self.legacy_polaris = True - else: - if self.model == "MacBookPro13,3": - self.legacy_gcn = True - elif self.model == "MacBookPro14,3": - if self.os_major < os_data.os_data.sonoma: - continue - self.legacy_gcn_v2 = True - else: - self.legacy_gcn = True - self.supports_metal = True - self.requires_root_kc = True - self.amfi_must_disable = True - elif gpu.arch == device_probe.AMD.Archs.Vega: - if self.os_major > os_data.os_data.monterey: - if "AVX2" in self.constants.computer.cpu.leafs: - continue - - self.legacy_vega = True - self.supports_metal = True - self.requires_root_kc = True - self.amfi_must_disable = True - elif gpu.arch == device_probe.Intel.Archs.Iron_Lake: - if self.os_major > non_metal_os: - self.iron_gpu = True - self.amfi_must_disable = True - if os_data.os_data.ventura in self.constants.legacy_accel_support: - self.amfi_shim_bins = True - self.legacy_keyboard_backlight = self._check_legacy_keyboard_backlight() - self.requires_root_kc = True - elif gpu.arch == device_probe.Intel.Archs.Sandy_Bridge: - if self.os_major > non_metal_os: - self.sandy_gpu = True - self.amfi_must_disable = True - if os_data.os_data.ventura in self.constants.legacy_accel_support: - self.amfi_shim_bins = True - self.legacy_keyboard_backlight = self._check_legacy_keyboard_backlight() - self.requires_root_kc = True - elif gpu.arch == device_probe.Intel.Archs.Ivy_Bridge: - if self.os_major > os_data.os_data.big_sur: - self.ivy_gpu = True - if self.os_major >= os_data.os_data.ventura: - self.amfi_must_disable = True - if (self.os_major == os_data.os_data.ventura and self.os_minor >= 4) or self.os_major > os_data.os_data.ventura: - self.amfi_shim_bins = True - self.supports_metal = True - elif gpu.arch == device_probe.Intel.Archs.Haswell: - if self.os_major > os_data.os_data.monterey: - self.haswell_gpu = True - self.amfi_must_disable = True - if (self.os_major == os_data.os_data.ventura and self.os_minor >= 4) or self.os_major > os_data.os_data.ventura: - self.amfi_shim_bins = True - self.supports_metal = True - elif gpu.arch == device_probe.Intel.Archs.Broadwell: - if self.os_major > os_data.os_data.monterey: - self.broadwell_gpu = True - self.amfi_must_disable = True - self.supports_metal = True - elif gpu.arch == device_probe.Intel.Archs.Skylake: - if self.os_major > os_data.os_data.monterey: - self.skylake_gpu = True - self.amfi_must_disable = True - self.supports_metal = True - - if self.supports_metal is True: - # Avoid patching Metal and non-Metal GPUs if both present, prioritize Metal GPU - # Main concerns are for iMac12,x with Sandy iGPU and Kepler dGPU - self.nvidia_tesla = False - self.nvidia_web = False - self.amd_ts1 = False - self.amd_ts2 = False - self.iron_gpu = False - self.sandy_gpu = False - self.legacy_keyboard_backlight = False - - if self.legacy_gcn is True or self.legacy_gcn_v2 is True: - # We can only support one or the other due to the nature of relying - # on portions of the native AMD stack for Polaris and Vega - # Thus we'll prioritize legacy GCN due to being the internal card - # ex. MacPro6,1 and MacBookPro11,5 with eGPUs - self.legacy_polaris = False - self.legacy_vega = False - - if self.os_major <= os_data.os_data.monterey: - # Always assume Root KC requirement on Monterey and older - self.requires_root_kc = True - else: - if self.requires_root_kc is True: - self.missing_kdk = not self._check_kdk() - - - - def _check_networking_support(self): - """ - Query for network requirement, ex. KDK downloading - - On macOS Ventura, networking support is required to download KDKs. - However for machines such as BCM94322, BCM94328 and Atheros chipsets, - users may only have wifi as their only supported network interface. - Thus we'll allow for KDK-less installs for these machines on first run. - On subsequent runs, we'll require networking to be enabled. - """ - - # Increase OS check if modern wifi is detected - if self.os_major < (os_data.os_data.ventura if self.legacy_wifi is True else os_data.os_data.sonoma): - return - if self.legacy_wifi is False and self.modern_wifi is False: - return - if self.requires_root_kc is False: - return - if self.missing_kdk is False: - return - if self.has_network is True: - return - - # Verify whether OCLP already installed network patches to the root volume - # If so, require networking to be enabled (user just needs to connect to wifi) - oclp_patch_path = "/System/Library/CoreServices/OpenCore-Legacy-Patcher.plist" - if Path(oclp_patch_path).exists(): - oclp_plist = plistlib.load(open(oclp_patch_path, "rb")) - if "Legacy Wireless" in oclp_plist or "Modern Wireless" in oclp_plist: - return - - # Due to the reliance of KDKs for most older patches, we'll allow KDK-less - # installs for Legacy Wifi patches and remove others - self.missing_kdk = False - self.requires_root_kc = False - - # Reset patches needing KDK - self.nvidia_tesla = False - self.nvidia_web = False - self.amd_ts1 = False - self.amd_ts2 = False - self.iron_gpu = False - self.sandy_gpu = False - self.legacy_gcn = False - self.legacy_gcn_v2 = False - self.legacy_polaris = False - self.legacy_vega = False - self.brightness_legacy = False - self.legacy_audio = False - self.legacy_gmux = False - self.legacy_keyboard_backlight = False - - # Currently all graphics patches require a KDK - if self.os_major >= os_data.os_data.sonoma: - self.kepler_gpu = False - self.ivy_gpu = False - self.haswell_gpu = False - self.broadwell_gpu = False - self.skylake_gpu = False - - - def _check_dgpu_status(self): - """ - Query whether system has an active dGPU - """ - - dgpu = self.constants.computer.dgpu - if dgpu: - if dgpu.class_code and dgpu.class_code == 0xFFFFFFFF: - # If dGPU is disabled via class-codes, assume demuxed - return False - return True - return False - - - def _detect_demux(self): - """ - Query whether system has been demuxed (ex. MacBookPro8,2, disabled dGPU) - """ - - # If GFX0 is missing, assume machine was demuxed - # -wegnoegpu would also trigger this, so ensure arg is not present - if not "-wegnoegpu" in (utilities.get_nvram("boot-args", decode=True) or ""): - igpu = self.constants.computer.igpu - dgpu = self._check_dgpu_status() - if igpu and not dgpu: - return True - return False - - - def _check_legacy_keyboard_backlight(self): - """ - Query whether system has a legacy keyboard backlight - - Returns: - bool: True if legacy keyboard backlight, False otherwise - """ - - # iMac12,x+ have an 'ACPI0008' device, but it's not a keyboard backlight - # Best to assume laptops will have a keyboard backlight - if self.model.startswith("MacBook"): - return self.constants.computer.ambient_light_sensor - return False - - - def _check_nv_web_nvram(self): - """ - Query for Nvidia Web Driver property: nvda_drv_vrl or nvda_drv - - Returns: - bool: True if property is present, False otherwise - """ - - nv_on = utilities.get_nvram("boot-args", decode=True) - if nv_on: - if "nvda_drv_vrl=" in nv_on: - return True - nv_on = utilities.get_nvram("nvda_drv") - if nv_on: - return True - return False - - - def _check_nv_web_opengl(self): - """ - Query for Nvidia Web Driver property: ngfxgl - - Verify Web Drivers will run in OpenGL mode - - Returns: - bool: True if property is present, False otherwise - """ - - nv_on = utilities.get_nvram("boot-args", decode=True) - if nv_on: - if "ngfxgl=" in nv_on: - return True - for gpu in self.constants.computer.gpus: - if isinstance(gpu, device_probe.NVIDIA): - if gpu.disable_metal is True: - return True - return False - - - def _check_nv_compat(self): - """ - Query for Nvidia Web Driver property: ngfxcompat - - Verify Web Drivers will skip NVDAStartupWeb compatibility check - - Returns: - bool: True if property is present, False otherwise - """ - - nv_on = utilities.get_nvram("boot-args", decode=True) - if nv_on: - if "ngfxcompat=" in nv_on: - return True - for gpu in self.constants.computer.gpus: - if isinstance(gpu, device_probe.NVIDIA): - if gpu.force_compatible is True: - return True - return False - - - def _check_whatevergreen(self): - """ - Query whether WhateverGreen.kext is loaded - - Returns: - bool: True if loaded, False otherwise - """ - - return utilities.check_kext_loaded("as.vit9696.WhateverGreen") - - - def _check_os_compat(self) -> bool: - """ - Base check to ensure patcher is compatible with host OS - """ - min_os = os_data.os_data.big_sur - max_os = os_data.os_data.sonoma - if self.os_major < min_os or self.os_major > max_os: - return False - return True - - - def _check_kdk(self): - """ - Query whether Kernel Debug Kit is installed - - Returns: - bool: True if installed, False otherwise - """ - - return kdk_handler.KernelDebugKitObject(self.constants, self.os_build, self.os_version, passive=True).kdk_already_installed - - - def _check_sip(self): - """ - Query System Integrity checks required for patching - - Returns: - tuple: (list, str, str) of SIP values, SIP hex, SIP error message - """ - - if self.os_major > os_data.os_data.catalina: - if self.nvidia_web is True: - sip = sip_data.system_integrity_protection.root_patch_sip_big_sur_3rd_part_kexts - sip_hex = "0xA03" - sip_value = ( - f"For Hackintoshes, please set csr-active-config to '030A0000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" - ) - elif self.os_major >= os_data.os_data.ventura: - sip = sip_data.system_integrity_protection.root_patch_sip_ventura - sip_hex = "0x803" - sip_value = ( - f"For Hackintoshes, please set csr-active-config to '03080000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" - ) - else: - sip = sip_data.system_integrity_protection.root_patch_sip_big_sur - sip_hex = "0x802" - sip_value = ( - f"For Hackintoshes, please set csr-active-config to '02080000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' and \n'csrutil authenticated-root disable' in RecoveryOS" - ) - else: - sip = sip_data.system_integrity_protection.root_patch_sip_mojave - sip_hex = "0x603" - sip_value = f"For Hackintoshes, please set csr-active-config to '03060000' ({sip_hex})\nFor non-OpenCore Macs, please run 'csrutil disable' in RecoveryOS" - return (sip, sip_value, sip_hex) - - - def _check_uhci_ohci(self): - """ - Query whether host has UHCI/OHCI controllers, and requires USB 1.1 patches - - Returns: - bool: True if UHCI/OHCI patches required, False otherwise - """ - - if self.os_major < os_data.os_data.ventura: - return False - - # If we're on a hackintosh, check for UHCI/OHCI controllers - if self.constants.host_is_hackintosh is True: - for controller in self.constants.computer.usb_controllers: - if ( - isinstance(controller, device_probe.UHCIController) or - isinstance(controller, device_probe.OHCIController) - ): - return True - return False - - if self.model not in smbios_data.smbios_dictionary: - return False - - # If we're on a Mac, check for Penryn or older - # This is due to Apple implementing an internal USB hub on post-Penryn (excluding MacPro4,1, MacPro5,1 and Xserve3,1) - # Ref: https://techcommunity.microsoft.com/t5/microsoft-usb-blog/reasons-to-avoid-companion-controllers/ba-p/270710 - if ( - smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.CPUGen.penryn.value or \ - self.model in ["MacPro4,1", "MacPro5,1", "Xserve3,1"] - ): - return True - - return False - - - # Entry point for patch set detection - def detect_patch_set(self): - """ - Query patch sets required for host - - Returns: - dict: Dictionary of patch sets - """ - - self.has_network = network_handler.NetworkUtilities().verify_network_connection() - - if self.os_major >= os_data.os_data.sonoma: - self.legacy_pcie_webcam = self.constants.computer.pcie_webcam - self.legacy_t1_chip = self.constants.computer.t1_chip - - if self.legacy_t1_chip is True: - self.amfi_must_disable = True - - if self._check_uhci_ohci() is True: - self.legacy_uhci_ohci = True - self.requires_root_kc = True - - if self.model in model_array.LegacyBrightness: - if self.os_major > os_data.os_data.catalina: - self.brightness_legacy = True - - if self.model in ["iMac7,1", "iMac8,1"] or (self.model in model_array.LegacyAudio and utilities.check_kext_loaded("as.vit9696.AppleALC") is False): - # Special hack for systems with botched GOPs - # TL;DR: No Boot Screen breaks Lilu, therefore breaking audio - if self.os_major > os_data.os_data.catalina: - self.legacy_audio = True - - if ( - isinstance(self.constants.computer.wifi, device_probe.Broadcom) - and self.constants.computer.wifi.chipset in [device_probe.Broadcom.Chipsets.AirPortBrcm4331, device_probe.Broadcom.Chipsets.AirPortBrcm43224] - ) or (isinstance(self.constants.computer.wifi, device_probe.Atheros) and self.constants.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40): - if self.os_major > os_data.os_data.big_sur: - self.legacy_wifi = True - if self.os_major >= os_data.os_data.ventura: - # Due to extracted frameworks for IO80211.framework and co, check library validation - self.amfi_must_disable = True - if self.os_major > os_data.os_data.ventura: - self.amfi_shim_bins = True - - if ( - isinstance(self.constants.computer.wifi, device_probe.Broadcom) - and self.constants.computer.wifi.chipset in [ - device_probe.Broadcom.Chipsets.AirPortBrcm4360, - device_probe.Broadcom.Chipsets.AirportBrcmNIC, - # We don't officially support this chipset, however we'll throw a bone to hackintosh users - device_probe.Broadcom.Chipsets.AirPortBrcmNICThirdParty, - ]): - if self.os_major > os_data.os_data.ventura: - self.modern_wifi = True - self.amfi_shim_bins = True - - # if self.model in ["MacBookPro5,1", "MacBookPro5,2", "MacBookPro5,3", "MacBookPro8,2", "MacBookPro8,3"]: - if self.model in ["MacBookPro8,2", "MacBookPro8,3"]: - # Sierra uses a legacy GMUX control method needed for dGPU switching on MacBookPro5,x - # Same method is also used for demuxed machines - # Note that MacBookPro5,x machines are extremely unstable with this patch set, so disabled until investigated further - # Ref: https://github.com/dortania/OpenCore-Legacy-Patcher/files/7360909/KP-b10-030.txt - if self.os_major > os_data.os_data.high_sierra: - if self.model in ["MacBookPro8,2", "MacBookPro8,3"]: - # Ref: https://doslabelectronics.com/Demux.html - if self._detect_demux() is True: - self.legacy_gmux = True - else: - self.legacy_gmux = True - - self._detect_gpus() - # This must be performed last, as it may override previous decisions - # Namely, whether we allow patches requiring KDKs - self._check_networking_support() - - self.root_patch_dict = { - "Graphics: Nvidia Tesla": self.nvidia_tesla, - "Graphics: Nvidia Kepler": self.kepler_gpu, - "Graphics: Nvidia Web Drivers": self.nvidia_web, - "Graphics: AMD TeraScale 1": self.amd_ts1, - "Graphics: AMD TeraScale 2": self.amd_ts2, - "Graphics: AMD Legacy GCN": self.legacy_gcn, - "Graphics: AMD Legacy GCN (2017)": self.legacy_gcn_v2, - "Graphics: AMD Legacy Polaris": self.legacy_polaris, - "Graphics: AMD Legacy Vega": self.legacy_vega, - "Graphics: Intel Ironlake": self.iron_gpu, - "Graphics: Intel Sandy Bridge": self.sandy_gpu, - "Graphics: Intel Ivy Bridge": self.ivy_gpu, - "Graphics: Intel Haswell": self.haswell_gpu, - "Graphics: Intel Broadwell": self.broadwell_gpu, - "Graphics: Intel Skylake": self.skylake_gpu, - "Brightness: Legacy Backlight Control": self.brightness_legacy, - "Audio: Legacy Realtek": self.legacy_audio, - "Networking: Legacy Wireless": self.legacy_wifi, - "Networking: Modern Wireless": self.modern_wifi, - "Miscellaneous: Legacy GMUX": self.legacy_gmux, - "Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight, - "Miscellaneous: Legacy USB 1.1": self.legacy_uhci_ohci, - "Miscellaneous: PCIe FaceTime Camera": self.legacy_pcie_webcam, - "Miscellaneous: T1 Security Chip": self.legacy_t1_chip, - "Settings: Requires AMFI exemption": self.amfi_must_disable, - "Settings: Supports Auxiliary Cache": not self.requires_root_kc, - "Settings: Kernel Debug Kit missing": self.missing_kdk if self.os_major >= os_data.os_data.ventura.value else False, - "Validation: Patching Possible": self.verify_patch_allowed(), - "Validation: Unpatching Possible": self._verify_unpatch_allowed(), - f"Validation: Unsupported Host OS": self.unsupported_os, - f"Validation: SIP is enabled (Required: {self._check_sip()[2]} or higher)": self.sip_enabled, - f"Validation: Currently Booted SIP: ({hex(py_sip_xnu.SipXnu().get_sip_status().value)})": self.sip_enabled, - "Validation: SecureBootModel is enabled": self.sbm_enabled, - f"Validation: {'AMFI' if self.constants.host_is_hackintosh is True or self._get_amfi_level_needed() > 2 else 'Library Validation'} is enabled": self.amfi_enabled if self.amfi_must_disable is True else False, - "Validation: FileVault is enabled": self.fv_enabled, - "Validation: System is dosdude1 patched": self.dosdude_patched, - "Validation: WhateverGreen.kext missing": self.missing_whatever_green if self.nvidia_web is True else False, - "Validation: Force OpenGL property missing": self.missing_nv_web_opengl if self.nvidia_web is True else False, - "Validation: Force compat property missing": self.missing_nv_compat if self.nvidia_web is True else False, - "Validation: nvda_drv(_vrl) variable missing": self.missing_nv_web_nvram if self.nvidia_web is True else False, - "Validation: Network Connection Required": (not self.has_network) if (self.requires_root_kc and self.missing_kdk and self.os_major >= os_data.os_data.ventura.value) else False, - } - - return self.root_patch_dict - - - def _get_amfi_level_needed(self): - """ - Query the AMFI level needed for the patcher to work - - Returns: - int: AMFI level needed - """ - - if self.amfi_must_disable is False: - return amfi_detect.AmfiConfigDetectLevel.NO_CHECK - - if self.os_major < os_data.os_data.big_sur: - return amfi_detect.AmfiConfigDetectLevel.NO_CHECK - - amfipass_version = utilities.check_kext_loaded("com.dhinakg.AMFIPass") - if amfipass_version: - if packaging.version.parse(amfipass_version) >= packaging.version.parse(self.constants.amfipass_compatibility_version): - # If AMFIPass is loaded, our binaries will work - return amfi_detect.AmfiConfigDetectLevel.NO_CHECK - - if self.os_major >= os_data.os_data.ventura: - if self.amfi_shim_bins is True: - # Currently we require AMFI outright disabled - # in Ventura to work with shim'd binaries - return amfi_detect.AmfiConfigDetectLevel.ALLOW_ALL - - return amfi_detect.AmfiConfigDetectLevel.LIBRARY_VALIDATION - - - def verify_patch_allowed(self, print_errors: bool = False): - """ - Validate that the patcher can be run - - Parameters: - print_errors (bool): Print errors to console - - Returns: - bool: True if patching is allowed, False otherwise - """ - - sip_dict = self._check_sip() - sip = sip_dict[0] - sip_value = sip_dict[1] - - self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched = utilities.patching_status(sip, self.os_major) - self.amfi_enabled = not amfi_detect.AmfiConfigurationDetection().check_config(self._get_amfi_level_needed()) - - self.unsupported_os = not self._check_os_compat() - - if self.nvidia_web is True: - self.missing_nv_web_nvram = not self._check_nv_web_nvram() - self.missing_nv_web_opengl = not self._check_nv_web_opengl() - self.missing_nv_compat = not self._check_nv_compat() - self.missing_whatever_green = not self._check_whatevergreen() - - if print_errors is True: - if self.sip_enabled is True: - logging.info("\nCannot patch! Please disable System Integrity Protection (SIP).") - logging.info("Disable SIP in Patcher Settings and Rebuild OpenCore\n") - logging.info("Ensure the following bits are set for csr-active-config:") - logging.info("\n".join(sip)) - logging.info(sip_value) - - if self.sbm_enabled is True: - logging.info("\nCannot patch! Please disable Apple Secure Boot.") - logging.info("Disable SecureBootModel in Patcher Settings and Rebuild OpenCore") - logging.info("For Hackintoshes, set SecureBootModel to Disabled") - - if self.fv_enabled is True: - logging.info("\nCannot patch! Please disable FileVault.") - logging.info("For OCLP Macs, please rebuild your config with 0.2.5 or newer") - logging.info("For others, Go to System Preferences -> Security and disable FileVault") - - if self.amfi_enabled is True and self.amfi_must_disable is True: - logging.info("\nCannot patch! Please disable AMFI.") - logging.info("For Hackintoshes, please add amfi_get_out_of_my_way=1 to boot-args") - - if self.dosdude_patched is True: - logging.info("\nCannot patch! Detected machine has already been patched by another patcher") - logging.info("Please ensure your install is either clean or patched with OpenCore Legacy Patcher") - - if self.nvidia_web is True: - if self.missing_nv_web_opengl is True: - logging.info("\nCannot patch! Force OpenGL property missing") - logging.info("Please ensure ngfxgl=1 is set in boot-args") - - if self.missing_nv_compat is True: - logging.info("\nCannot patch! Force Nvidia compatibility property missing") - logging.info("Please ensure ngfxcompat=1 is set in boot-args") - - if self.missing_nv_web_nvram is True: - logging.info("\nCannot patch! nvda_drv(_vrl) variable missing") - logging.info("Please ensure nvda_drv_vrl=1 is set in boot-args") - - if self.missing_whatever_green is True: - logging.info("\nCannot patch! WhateverGreen.kext missing") - logging.info("Please ensure WhateverGreen.kext is installed") - - if (not self.has_network) if (self.requires_root_kc and self.missing_kdk and self.os_major >= os_data.os_data.ventura.value) else False: - logging.info("\nCannot patch! Network Connection Required") - logging.info("Please ensure you have an active internet connection") - - if self.unsupported_os is True: - logging.info("\nCannot patch! Unsupported Host OS") - logging.info("Please ensure you are running a patcher-supported OS") - - if any( - [ - # General patch checks - self.sip_enabled, self.sbm_enabled, self.fv_enabled, self.dosdude_patched, self.unsupported_os, - - # non-Metal specific - self.amfi_enabled if self.amfi_must_disable is True else False, - - # Web Driver specific - self.missing_nv_web_nvram if self.nvidia_web is True else False, - self.missing_nv_web_opengl if self.nvidia_web is True else False, - self.missing_nv_compat if self.nvidia_web is True else False, - self.missing_whatever_green if self.nvidia_web is True else False, - - # KDK specific - (not self.has_network) if (self.requires_root_kc and self.missing_kdk and self.os_major >= os_data.os_data.ventura.value) else False - ] - ): - return False - - return True - - - def _verify_unpatch_allowed(self): - """ - Validate that the unpatcher can be run - - Preconditions: - Must be called after verify_patch_allowed() - - Returns: - bool: True if unpatching is allowed, False otherwise - """ - - return not self.sip_enabled \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/detections/generate.py b/opencore_legacy_patcher/sys_patch/detections/generate.py deleted file mode 100644 index f272318a2..000000000 --- a/opencore_legacy_patcher/sys_patch/detections/generate.py +++ /dev/null @@ -1,212 +0,0 @@ -""" -generate.py: Class for generating patch sets for the current host -""" - -import logging - -from ... import constants - -from ...datasets import sys_patch_dict -from ...support import utilities -from ...detections import device_probe - - -class GenerateRootPatchSets: - """ - Library for generating patch sets for the current host - - Parameters: - model (str): Model identifier - global_constants (constants.Constants): Global constants object - hardware_details (dict): Dictionary of hardware details generated by detect_patch_set() - - Usage: - >>> from resources.sys_patch import sys_patch_generate - >>> patchset = sys_patch_generate.GenerateRootPatches("iMac7,1", self.constants, self.hardware_details).patchset - - """ - - def __init__(self, model: str, global_constants: constants.Constants, hardware_details: dict) -> None: - self.model: str = model - self.constants: constants.Constants = global_constants - self.hardware_details: dict = hardware_details - - self.patchset: dict = self._generate_patchset() - - - def _generate_patchset(self) -> dict: - """ - Generate Patchset dictionary for the current system - - Returns: - dict: Dictionary of patches to be applied from sys_patch_dict.py - """ - - all_hardware_patchset: dict = sys_patch_dict.SystemPatchDictionary(self.constants.detected_os, self.constants.detected_os_minor, self.constants.legacy_accel_support, self.constants.detected_os_version).patchset_dict - required_patches: dict = {} - - utilities.cls() - - logging.info("The following patches will be applied:") - - if self.hardware_details["Graphics: Intel Ironlake"] is True: - required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"Intel Ironlake": all_hardware_patchset["Graphics"]["Intel Ironlake"]}) - - if self.hardware_details["Graphics: Intel Sandy Bridge"] is True: - required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) - required_patches.update({"High Sierra GVA": all_hardware_patchset["Graphics"]["High Sierra GVA"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"Intel Sandy Bridge": all_hardware_patchset["Graphics"]["Intel Sandy Bridge"]}) - # Patchset breaks Display Profiles, don't install if primary GPU is AMD. Give users option to disable patch in settings to restore Display Profiles - if self.constants.computer.real_model not in ["Macmini5,2", "iMac12,1", "iMac12,2"]: - required_patches.update({"Revert Non-Metal ColorSync Workaround": all_hardware_patchset["Graphics"]["Revert Non-Metal ColorSync Workaround"]}) - - if self.hardware_details["Graphics: Intel Ivy Bridge"] is True: - required_patches.update({"Metal 3802 Common": all_hardware_patchset["Graphics"]["Metal 3802 Common"]}) - required_patches.update({"Metal 3802 Common Extended": all_hardware_patchset["Graphics"]["Metal 3802 Common Extended"]}) - required_patches.update({"Catalina GVA": all_hardware_patchset["Graphics"]["Catalina GVA"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - required_patches.update({"Big Sur OpenCL": all_hardware_patchset["Graphics"]["Big Sur OpenCL"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"Intel Ivy Bridge": all_hardware_patchset["Graphics"]["Intel Ivy Bridge"]}) - - if self.hardware_details["Graphics: Intel Haswell"] is True: - required_patches.update({"Metal 3802 Common": all_hardware_patchset["Graphics"]["Metal 3802 Common"]}) - required_patches.update({"Metal 3802 Common Extended": all_hardware_patchset["Graphics"]["Metal 3802 Common Extended"]}) - required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - required_patches.update({"Intel Haswell": all_hardware_patchset["Graphics"]["Intel Haswell"]}) - - if self.hardware_details["Graphics: Intel Broadwell"] is True: - required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - required_patches.update({"Intel Broadwell": all_hardware_patchset["Graphics"]["Intel Broadwell"]}) - - if self.hardware_details["Graphics: Intel Skylake"] is True: - required_patches.update({"Revert GVA Downgrade": all_hardware_patchset["Graphics"]["Revert GVA Downgrade"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - required_patches.update({"Intel Skylake": all_hardware_patchset["Graphics"]["Intel Skylake"]}) - - if self.hardware_details["Graphics: Nvidia Tesla"] is True: - required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"Nvidia Tesla": all_hardware_patchset["Graphics"]["Nvidia Tesla"]}) - - if self.hardware_details["Graphics: Nvidia Web Drivers"] is True: - required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) - required_patches.update({"Non-Metal IOAccelerator Common": all_hardware_patchset["Graphics"]["Non-Metal IOAccelerator Common"]}) - required_patches.update({"Non-Metal CoreDisplay Common": all_hardware_patchset["Graphics"]["Non-Metal CoreDisplay Common"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"Nvidia Web Drivers": all_hardware_patchset["Graphics"]["Nvidia Web Drivers"]}) - required_patches.update({"Non-Metal Enforcement": all_hardware_patchset["Graphics"]["Non-Metal Enforcement"]}) - - if self.hardware_details["Graphics: Nvidia Kepler"] is True: - required_patches.update({"Metal 3802 Common": all_hardware_patchset["Graphics"]["Metal 3802 Common"]}) - required_patches.update({"Metal 3802 Common Extended": all_hardware_patchset["Graphics"]["Metal 3802 Common Extended"]}) - required_patches.update({"Catalina GVA": all_hardware_patchset["Graphics"]["Catalina GVA"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - required_patches.update({"Big Sur OpenCL": all_hardware_patchset["Graphics"]["Big Sur OpenCL"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"Nvidia Kepler": all_hardware_patchset["Graphics"]["Nvidia Kepler"]}) - for gpu in self.constants.computer.gpus: - # Handle mixed GPU situations (ie. MacBookPro11,3: Haswell iGPU + Kepler dGPU) - if gpu.arch == device_probe.Intel.Archs.Haswell: - if "Catalina GVA" in required_patches: - del(required_patches["Catalina GVA"]) - break - - if self.hardware_details["Graphics: AMD TeraScale 1"] is True: - required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"AMD TeraScale Common": all_hardware_patchset["Graphics"]["AMD TeraScale Common"]}) - required_patches.update({"AMD TeraScale 1": all_hardware_patchset["Graphics"]["AMD TeraScale 1"]}) - - if self.hardware_details["Graphics: AMD TeraScale 2"] is True: - required_patches.update({"Non-Metal Common": all_hardware_patchset["Graphics"]["Non-Metal Common"]}) - required_patches.update({"Non-Metal IOAccelerator Common": all_hardware_patchset["Graphics"]["Non-Metal IOAccelerator Common"]}) - required_patches.update({"WebKit Monterey Common": all_hardware_patchset["Graphics"]["WebKit Monterey Common"]}) - required_patches.update({"AMD TeraScale Common": all_hardware_patchset["Graphics"]["AMD TeraScale Common"]}) - required_patches.update({"AMD TeraScale 2": all_hardware_patchset["Graphics"]["AMD TeraScale 2"]}) - if self.constants.allow_ts2_accel is False or self.constants.detected_os not in self.constants.legacy_accel_support: - # TeraScale 2 MacBooks with faulty GPUs are highly prone to crashing with AMDRadeonX3000 attached - # Additionally, AMDRadeonX3000 requires IOAccelerator downgrade which is not installed without 'Non-Metal IOAccelerator Common' - del(required_patches["AMD TeraScale 2"]["Install"]["/System/Library/Extensions"]["AMDRadeonX3000.kext"]) - - if self.hardware_details["Graphics: AMD Legacy GCN"] is True or self.hardware_details["Graphics: AMD Legacy Polaris"] is True: - if self.hardware_details["Graphics: Intel Skylake"] is False: - # GVA downgrade not required if Skylake is present - required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - if self.hardware_details["Graphics: AMD Legacy GCN"] is True: - required_patches.update({"AMD Legacy GCN": all_hardware_patchset["Graphics"]["AMD Legacy GCN"]}) - else: - required_patches.update({"AMD Legacy Polaris": all_hardware_patchset["Graphics"]["AMD Legacy Polaris"]}) - required_patches.update({"Revert GVA Downgrade": all_hardware_patchset["Graphics"]["Revert GVA Downgrade"]}) - if "AVX2" not in self.constants.computer.cpu.leafs: - required_patches.update({"AMD OpenCL": all_hardware_patchset["Graphics"]["AMD OpenCL"]}) - if self.hardware_details["Graphics: AMD Legacy GCN (2017)"] is True: - required_patches.update({"AMD Legacy GCN v2": all_hardware_patchset["Graphics"]["AMD Legacy GCN v2"]}) - - if self.hardware_details["Graphics: AMD Legacy Vega"] is True: - required_patches.update({"Monterey GVA": all_hardware_patchset["Graphics"]["Monterey GVA"]}) - required_patches.update({"Monterey OpenCL": all_hardware_patchset["Graphics"]["Monterey OpenCL"]}) - required_patches.update({"AMD Legacy Vega": all_hardware_patchset["Graphics"]["AMD Legacy Vega"]}) - required_patches.update({"AMD OpenCL": all_hardware_patchset["Graphics"]["AMD OpenCL"]}) - if self.hardware_details["Graphics: AMD Legacy GCN"] is True: - required_patches.update({"AMD Legacy Vega Extended": all_hardware_patchset["Graphics"]["AMD Legacy Vega Extended"]}) - else: - required_patches.update({"Revert GVA Downgrade": all_hardware_patchset["Graphics"]["Revert GVA Downgrade"]}) - - if self.hardware_details["Brightness: Legacy Backlight Control"] is True: - required_patches.update({"Legacy Backlight Control": all_hardware_patchset["Brightness"]["Legacy Backlight Control"]}) - - if self.hardware_details["Audio: Legacy Realtek"] is True: - if self.model in ["iMac7,1", "iMac8,1"]: - required_patches.update({"Legacy Realtek": all_hardware_patchset["Audio"]["Legacy Realtek"]}) - else: - required_patches.update({"Legacy Non-GOP": all_hardware_patchset["Audio"]["Legacy Non-GOP"]}) - - if self.hardware_details["Networking: Legacy Wireless"] is True: - required_patches.update({"Legacy Wireless": all_hardware_patchset["Networking"]["Legacy Wireless"]}) - required_patches.update({"Legacy Wireless Extended": all_hardware_patchset["Networking"]["Legacy Wireless Extended"]}) - - if self.hardware_details["Networking: Modern Wireless"] is True: - required_patches.update({"Legacy Wireless": all_hardware_patchset["Networking"]["Modern Wireless"]}) - - if self.hardware_details["Miscellaneous: Legacy GMUX"] is True: - required_patches.update({"Legacy GMUX": all_hardware_patchset["Miscellaneous"]["Legacy GMUX"]}) - - if self.hardware_details["Miscellaneous: Legacy Keyboard Backlight"] is True: - required_patches.update({"Legacy Keyboard Backlight": all_hardware_patchset["Miscellaneous"]["Legacy Keyboard Backlight"]}) - - if self.hardware_details["Miscellaneous: Legacy USB 1.1"] is True: - required_patches.update({"Legacy USB 1.1": all_hardware_patchset["Miscellaneous"]["Legacy USB 1.1"]}) - required_patches.update({"Legacy USB 1.1 Extended": all_hardware_patchset["Miscellaneous"]["Legacy USB 1.1 Extended"]}) - - if self.hardware_details["Miscellaneous: PCIe FaceTime Camera"] is True: - required_patches.update({"PCIe FaceTime Camera": all_hardware_patchset["Miscellaneous"]["PCIe FaceTime Camera"]}) - - if self.hardware_details["Miscellaneous: T1 Security Chip"] is True: - required_patches.update({"T1 Security Chip": all_hardware_patchset["Miscellaneous"]["T1 Security Chip"]}) - - if required_patches: - host_os_float = float(f"{self.constants.detected_os}.{self.constants.detected_os_minor}") - - # Prioritize Monterey GVA patches - if "Catalina GVA" in required_patches and "Monterey GVA" in required_patches: - del(required_patches["Catalina GVA"]) - - for patch_name in list(required_patches): - patch_os_min_float = float(f'{required_patches[patch_name]["OS Support"]["Minimum OS Support"]["OS Major"]}.{required_patches[patch_name]["OS Support"]["Minimum OS Support"]["OS Minor"]}') - patch_os_max_float = float(f'{required_patches[patch_name]["OS Support"]["Maximum OS Support"]["OS Major"]}.{required_patches[patch_name]["OS Support"]["Maximum OS Support"]["OS Minor"]}') - if (host_os_float < patch_os_min_float or host_os_float > patch_os_max_float): - del(required_patches[patch_name]) - else: - if required_patches[patch_name]["Display Name"]: - logging.info(f"- {required_patches[patch_name]['Display Name']}") - else: - logging.info("- No patch sets found for booted model") - - return required_patches \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/kernelcache/kernel_collection/support.py b/opencore_legacy_patcher/sys_patch/kernelcache/kernel_collection/support.py index 866700f9f..44b699401 100644 --- a/opencore_legacy_patcher/sys_patch/kernelcache/kernel_collection/support.py +++ b/opencore_legacy_patcher/sys_patch/kernelcache/kernel_collection/support.py @@ -8,6 +8,8 @@ import plistlib from pathlib import Path from datetime import datetime +from ...patchsets import PatchType + from ....datasets import os_data from ....support import subprocess_wrapper @@ -126,7 +128,7 @@ class KernelCacheSupport: for key in oclp_plist_data: if isinstance(oclp_plist_data[key], (bool, int)): continue - for install_type in ["Install", "Install Non-Root"]: + for install_type in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.OVERWRITE_DATA_VOLUME, PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]: if install_type not in oclp_plist_data[key]: continue for location in oclp_plist_data[key][install_type]: diff --git a/opencore_legacy_patcher/sys_patch/patchsets/__init__.py b/opencore_legacy_patcher/sys_patch/patchsets/__init__.py new file mode 100644 index 000000000..4d1f4839e --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/__init__.py @@ -0,0 +1,6 @@ +""" +patchsets module +""" + +from .base import PatchType, DynamicPatchset +from .detect import HardwarePatchsetDetection, HardwarePatchsetSettings, HardwarePatchsetValidation \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/base.py b/opencore_legacy_patcher/sys_patch/patchsets/base.py new file mode 100644 index 000000000..fb70ca3ef --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/base.py @@ -0,0 +1,35 @@ +""" +base.py: Base class for all patch sets +""" + +from enum import StrEnum + + +class PatchType(StrEnum): + """ + Type of patch + """ + OVERWRITE_SYSTEM_VOLUME = "Overwrite System Volume" + OVERWRITE_DATA_VOLUME = "Overwrite Data Volume" + MERGE_SYSTEM_VOLUME = "Merge System Volume" + MERGE_DATA_VOLUME = "Merge Data Volume" + REMOVE_SYSTEM_VOLUME = "Remove System Volume" + REMOVE_DATA_VOLUME = "Remove Data Volume" + EXECUTE = "Execute" + + +class DynamicPatchset(StrEnum): + MetallibSupportPkg = "MetallibSupportPkg" + + +class BasePatchset: + + def __init__(self) -> None: + # XNU Kernel versions + self.macOS_12_0_B7: float = 21.1 + self.macOS_12_4: float = 21.5 + self.macOS_12_5: float = 21.6 + self.macOS_13_3: float = 22.4 + self.macOS_14_1: float = 23.1 + self.macOS_14_2: float = 23.2 + self.macOS_14_4: float = 23.4 \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/detect.py b/opencore_legacy_patcher/sys_patch/patchsets/detect.py new file mode 100644 index 000000000..23f361dbf --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/detect.py @@ -0,0 +1,549 @@ +""" +detect.py: Detects patches for a given system +""" + +import logging +import plistlib +import subprocess +import py_sip_xnu +import packaging.version + +from enum import StrEnum +from pathlib import Path +from functools import cache + +from .hardware.base import BaseHardware, HardwareVariantGraphicsSubclass + +from .hardware.graphics import ( + intel_iron_lake, + intel_sandy_bridge, + intel_ivy_bridge, + intel_haswell, + intel_broadwell, + intel_skylake, + + nvidia_tesla, + nvidia_kepler, + nvidia_webdriver, + + amd_terascale_1, + amd_terascale_2, + amd_legacy_gcn, + amd_polaris, + amd_vega, +) +from .hardware.networking import ( + legacy_wireless, + modern_wireless, +) +from .hardware.misc import ( + display_backlight, + gmux, + keyboard_backlight, + legacy_audio, + pcie_webcam, + t1_security, + usb11, +) + +from ... import constants + +from ...datasets import sip_data +from ...datasets.os_data import os_data +from ...support import ( + network_handler, + utilities, + kdk_handler, + metallib_handler +) +from ...detections import ( + amfi_detect, + device_probe +) + + +class HardwarePatchsetSettings(StrEnum): + """ + Enum for patch settings + """ + KERNEL_DEBUG_KIT_REQUIRED = "Settings: Kernel Debug Kit required" + KERNEL_DEBUG_KIT_MISSING = "Settings: Kernel Debug Kit missing" + METALLIB_SUPPORT_PKG_REQUIRED = "Settings: MetallibSupportPkg.pkg required" + METALLIB_SUPPORT_PKG_MISSING = "Settings: MetallibSupportPkg.pkg missing" + + +class HardwarePatchsetValidation(StrEnum): + """ + Enum for validation settings + """ + UNSUPPORTED_HOST_OS = "Validation: Unsupported Host OS" + MISSING_NETWORK_CONNECTION = "Validation: Missing Network Connection" + FILEVAULT_ENABLED = "Validation: FileVault is enabled" + SIP_ENABLED = "Validation: System Integrity Protection is enabled" + SECURE_BOOT_MODEL_ENABLED = "Validation: SecureBootModel is enabled" + AMFI_ENABLED = "Validation: AMFI is enabled" + WHATEVERGREEN_MISSING = "Validation: WhateverGreen.kext missing" + FORCE_OPENGL_MISSING = "Validation: Force OpenGL property missing" + FORCE_COMPAT_MISSING = "Validation: Force compat property missing" + NVDA_DRV_MISSING = "Validation: nvda_drv(_vrl) variable missing" + PATCHING_NOT_POSSIBLE = "Validation: Patching not possible" + UNPATCHING_NOT_POSSIBLE = "Validation: Unpatching not possible" + + +class HardwarePatchsetDetection: + + def __init__(self, constants: constants.Constants, + xnu_major: int = None, xnu_minor: int = None, + os_build: str = None, os_version: str = None, + validation: bool = False # Whether to run validation checks + ) -> None: + self._constants = constants + + self._xnu_major = xnu_major or self._constants.detected_os + self._xnu_minor = xnu_minor or self._constants.detected_os_minor + self._os_build = os_build or self._constants.detected_os_build + self._os_version = os_version or self._constants.detected_os_version + self._validation = validation + + self._hardware_variants = [ + intel_iron_lake.IntelIronLake, + intel_sandy_bridge.IntelSandyBridge, + intel_ivy_bridge.IntelIvyBridge, + intel_haswell.IntelHaswell, + intel_broadwell.IntelBroadwell, + intel_skylake.IntelSkylake, + + nvidia_tesla.NvidiaTesla, + nvidia_kepler.NvidiaKepler, + nvidia_webdriver.NvidiaWebDriver, + + amd_terascale_1.AMDTeraScale1, + amd_terascale_2.AMDTeraScale2, + amd_legacy_gcn.AMDLegacyGCN, + amd_polaris.AMDPolaris, + amd_vega.AMDVega, + + legacy_wireless.LegacyWireless, + modern_wireless.ModernWireless, + + display_backlight.DisplayBacklight, + gmux.GraphicsMultiplexer, + keyboard_backlight.KeyboardBacklight, + legacy_audio.LegacyAudio, + pcie_webcam.PCIeFaceTimeCamera, + t1_security.T1SecurityChip, + usb11.USB11Controller, + ] + + self.device_properties = None + self.patches = None + + self.can_patch = False + self.can_unpatch = False + + self._detect() + + + def _validation_check_unsupported_host_os(self) -> bool: + """ + Determine if host OS is unsupported + """ + _min_os = os_data.big_sur.value + _max_os = os_data.sequoia.value + if self._dortania_internal_check() is True: + return False + if self._xnu_major < _min_os or self._xnu_major > _max_os: + return True + return False + + + @cache + def _validation_check_missing_network_connection(self) -> bool: + """ + Determine if network connection is present + """ + return network_handler.NetworkUtilities().verify_network_connection() is False + + + @cache + def _validation_check_filevault_is_enabled(self) -> bool: + """ + Determine if FileVault is enabled + """ + # macOS 11.0 introduced a FileVault check for root patching + if self._xnu_major < os_data.big_sur.value: + return False + + # OpenCore Legacy Patcher exposes whether it patched APFS.kext to allow for FileVault + nvram = utilities.get_nvram("OCLP-Settings", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) + if nvram: + if "-allow_fv" in nvram: + return False + + return "FileVault is Off" not in subprocess.run(["/usr/bin/fdesetup", "status"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() + + + def _validation_check_system_integrity_protection_enabled(self, configs: list[str]) -> bool: + """ + Determine if System Integrity Protection is enabled + """ + return utilities.csr_decode(configs) + + + def _validation_check_secure_boot_model_enabled(self) -> bool: + """ + Determine if SecureBootModel is enabled + """ + return utilities.check_secure_boot_level() + + + def _validation_check_amfi_enabled(self, level: amfi_detect.AmfiConfigDetectLevel) -> bool: + """ + Determine if AMFI is enabled + """ + return not amfi_detect.AmfiConfigurationDetection().check_config(self._override_amfi_level(level)) + + + def _validation_check_whatevergreen_missing(self) -> bool: + """ + Determine if WhateverGreen.kext is missing + """ + return utilities.check_kext_loaded("as.vit9696.WhateverGreen") is False + + + @cache + def _validation_check_force_opengl_missing(self) -> bool: + """ + Determine if Force OpenGL property is missing + """ + nv_on = utilities.get_nvram("boot-args", decode=True) + if nv_on: + if "ngfxgl=" in nv_on: + return True + for gpu in self._constants.computer.gpus: + if isinstance(gpu, device_probe.NVIDIA): + if gpu.disable_metal is True: + return True + return False + + + def _validation_check_force_compat_missing(self) -> bool: + """ + Determine if Force compat property is missing + """ + nv_on = utilities.get_nvram("boot-args", decode=True) + if nv_on: + if "ngfxcompat=" in nv_on: + return True + for gpu in self._constants.computer.gpus: + if isinstance(gpu, device_probe.NVIDIA): + if gpu.force_compatible is True: + return True + return False + + + def _validation_check_nvda_drv_missing(self) -> bool: + """ + Determine if nvda_drv(_vrl) variable is missing + """ + nv_on = utilities.get_nvram("boot-args", decode=True) + if nv_on: + if "nvda_drv_vrl=" in nv_on: + return True + nv_on = utilities.get_nvram("nvda_drv") + if nv_on: + return True + return False + + + @cache + def _override_amfi_level(self, level: amfi_detect.AmfiConfigDetectLevel) -> amfi_detect.AmfiConfigDetectLevel: + """ + Override level required based on whether AMFIPass is loaded + """ + amfipass_version = utilities.check_kext_loaded("com.dhinakg.AMFIPass") + if amfipass_version: + if packaging.version.parse(amfipass_version) >= packaging.version.parse(self._constants.amfipass_compatibility_version): + # If AMFIPass is loaded, our binaries will work + return amfi_detect.AmfiConfigDetectLevel.NO_CHECK + return level + + + def _dortania_internal_check(self) -> None: + """ + Determine whether to unlock Dortania Developer mode + """ + return Path("~/.dortania_developer").expanduser().exists() + + + def _already_has_networking_patches(self) -> bool: + """ + Check if network patches are already applied + """ + oclp_patch_path = "/System/Library/CoreServices/OpenCore-Legacy-Patcher.plist" + if not Path(oclp_patch_path).exists(): + return False + try: + oclp_plist = plistlib.load(open(oclp_patch_path, "rb")) + except Exception as e: + return False + if "Legacy Wireless" in oclp_plist or "Modern Wireless" in oclp_plist: + return True + return False + + + def _is_cached_kernel_debug_kit_present(self) -> bool: + """ + Check if Kernel Debug Kit is present + """ + return kdk_handler.KernelDebugKitObject(self._constants, self._os_build, self._os_version, passive=True).kdk_already_installed + + + def _is_cached_metallib_support_pkg_present(self) -> bool: + """ + Check if MetallibSupportPkg is present + """ + return metallib_handler.MetalLibraryObject(self._constants, self._os_build, self._os_version).metallib_already_installed + + + def _can_patch(self, requirements: dict, ignore_keys: list[str] = []) -> bool: + """ + Check if patching is possible + """ + for key, value in requirements.items(): + if key in ignore_keys: + continue + if not key.startswith("Validation:"): + continue + if value is True: + return False + return True + + + def _convert_required_sip_config_to_int(self, configs: list[str]) -> int: + """ + Convert required SIP configurations to integer + """ + value = 0 + for config in configs: + if config in sip_data.system_integrity_protection.csr_values_extended: + value += sip_data.system_integrity_protection.csr_values_extended[config]["value"] + + return value + + + def _strip_incompatible_hardware(self, present_hardware: list[BaseHardware]) -> list[BaseHardware]: + """ + Strip out incompatible hardware. Priority is given to Metal GPUs (specifically 31001 when applicable) + + Notes: + - Non-Metal GPUs are stripped out if any Metal GPUs are present + - Metal 3802 GPUs are stripped out if Metal 31001 GPUs are present on macOS Sequoia or newer + - Exception is made for "Graphics: AMD Legacy GCN" on Sequoia or newer + - Special handling is done in amd_legacy_gcn.py + """ + non_metal_gpu_present = False + metal_gpu_present = False + metal_3802_gpu_present = False + metal_31001_gpu_present = False + metal_31001_name = None + + for hardware in present_hardware: + hardware: BaseHardware + sub_variant = hardware.hardware_variant_graphics_subclass() + if sub_variant == HardwareVariantGraphicsSubclass.METAL_31001_GRAPHICS: + metal_31001_gpu_present = True + metal_31001_name = hardware.name() + elif sub_variant == HardwareVariantGraphicsSubclass.METAL_3802_GRAPHICS: + metal_3802_gpu_present = True + elif sub_variant == HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS: + non_metal_gpu_present = True + + metal_gpu_present = metal_31001_gpu_present or metal_3802_gpu_present + + if metal_gpu_present and non_metal_gpu_present: + logging.error("Cannot mix Metal and Non-Metal GPUs") + logging.error("Stripping out Non-Metal GPUs") + for hardware in list(present_hardware): + if hardware.hardware_variant_graphics_subclass() == HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS: + print(f" Stripping out {hardware.name()}") + present_hardware.remove(hardware) + + if metal_3802_gpu_present and metal_31001_gpu_present and self._xnu_major >= os_data.sequoia.value: + if metal_31001_name != "Graphics: AMD Legacy GCN": + logging.error("Cannot mix Metal 3802 and Metal 31001 GPUs on macOS Sequoia or newer") + logging.error("Stripping out Metal 3802 GPUs") + for hardware in list(present_hardware): + if hardware.hardware_variant_graphics_subclass() == HardwareVariantGraphicsSubclass.METAL_3802_GRAPHICS: + logging.error(f" Stripping out {hardware.name()}") + present_hardware.remove(hardware) + + return present_hardware + + + def _handle_missing_network_connection(self, requirements: dict, device_properties: dict) -> tuple[dict, dict]: + """ + Sync network connection requirements + """ + if self._can_patch(requirements, ignore_keys=[HardwarePatchsetValidation.MISSING_NETWORK_CONNECTION]) is False: + return requirements, device_properties + logging.info("Network connection missing, checking whether network patches are applicable") + if self._already_has_networking_patches() is True: + logging.info("Network patches are already applied, requiring network connection") + return requirements, device_properties + + if not any([key.startswith("Networking:") for key in device_properties.keys()]): + logging.info("Network patches are not applicable, requiring network connection") + return requirements, device_properties + + logging.info("Network patches are applicable, removing other patches") + for key in list(device_properties.keys()): + if key.startswith("Networking:"): + continue + device_properties.pop(key, None) + + requirements[HardwarePatchsetValidation.MISSING_NETWORK_CONNECTION] = False + requirements[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED] = False + requirements[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_MISSING] = False + requirements[HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_REQUIRED] = False + requirements[HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_MISSING] = False + + return requirements, device_properties + + + def _handle_sip_breakdown(self, requirements: dict, required_sip_configs: list[str]) -> dict: + """ + Handle SIP breakdown + """ + current_sip_status = hex(py_sip_xnu.SipXnu().get_sip_status().value) + expected_sip_status = hex(self._convert_required_sip_config_to_int(required_sip_configs)) + sip_string = f"Validation: Booted SIP: {current_sip_status} vs expected: {expected_sip_status}" + index = list(requirements.keys()).index(HardwarePatchsetValidation.SIP_ENABLED) + return dict(list(requirements.items())[:index+1] + [(sip_string, True)] + list(requirements.items())[index+1:]) + + + def _detect(self) -> None: + """ + Detect patches for a given system + """ + present_hardware = [] + device_properties = {} + patches = {} + + requires_metallib_support_pkg = False + missing_metallib_support_pkg = False + requires_kernel_debug_kit = False + missing_kernel_debug_kit = False + requires_network_connection = False + has_nvidia_web_drivers = False + highest_amfi_level = amfi_detect.AmfiConfigDetectLevel.NO_CHECK + required_sip_configs = [] + + # First pass to find all present hardware + for hardware in self._hardware_variants: + item: BaseHardware = hardware( + xnu_major = self._xnu_major, + xnu_minor = self._xnu_minor, + os_build = self._os_build, + global_constants = self._constants + ) + # During validation, don't skip missing items + # This is to ensure we can validate all files + if self._validation is False: + if item.present() is False: # Skip if not present + continue + if item.native_os() is True: # Skip if native OS + continue + present_hardware.append(item) + + if self._validation is False: + present_hardware = self._strip_incompatible_hardware(present_hardware) + + # Second pass to determine requirements + for item in present_hardware: + item: BaseHardware + device_properties[item.name()] = True + + if item.name() == "Graphics: Nvidia Web Drivers": + has_nvidia_web_drivers = True + + for config in item.required_system_integrity_protection_configurations(): + if config not in required_sip_configs: + required_sip_configs.append(config) + + if item.requires_metallib_support_pkg() is True: + requires_metallib_support_pkg = True + if item.requires_kernel_debug_kit() is True: + requires_kernel_debug_kit = True + if item.required_amfi_level() > highest_amfi_level: + highest_amfi_level = item.required_amfi_level() + + if self._validation is False: + if requires_metallib_support_pkg is True: + missing_metallib_support_pkg = not self._is_cached_metallib_support_pkg_present() + if requires_kernel_debug_kit is True: + missing_kernel_debug_kit = not self._is_cached_kernel_debug_kit_present() + + requires_network_connection = missing_metallib_support_pkg or missing_kernel_debug_kit + + requirements = { + HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED: requires_kernel_debug_kit, + HardwarePatchsetSettings.KERNEL_DEBUG_KIT_MISSING: missing_kernel_debug_kit, + HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_REQUIRED: requires_metallib_support_pkg, + HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_MISSING: missing_metallib_support_pkg, + + HardwarePatchsetValidation.UNSUPPORTED_HOST_OS: self._validation_check_unsupported_host_os(), + HardwarePatchsetValidation.MISSING_NETWORK_CONNECTION: self._validation_check_missing_network_connection() if requires_network_connection else False, + HardwarePatchsetValidation.FILEVAULT_ENABLED: self._validation_check_filevault_is_enabled(), + HardwarePatchsetValidation.SIP_ENABLED: self._validation_check_system_integrity_protection_enabled(required_sip_configs), + HardwarePatchsetValidation.SECURE_BOOT_MODEL_ENABLED: self._validation_check_secure_boot_model_enabled(), + HardwarePatchsetValidation.AMFI_ENABLED: self._validation_check_amfi_enabled(highest_amfi_level), + HardwarePatchsetValidation.WHATEVERGREEN_MISSING: self._validation_check_whatevergreen_missing() if has_nvidia_web_drivers is True else False, + HardwarePatchsetValidation.FORCE_OPENGL_MISSING: self._validation_check_force_opengl_missing() if has_nvidia_web_drivers is True else False, + HardwarePatchsetValidation.FORCE_COMPAT_MISSING: self._validation_check_force_compat_missing() if has_nvidia_web_drivers is True else False, + HardwarePatchsetValidation.NVDA_DRV_MISSING: self._validation_check_nvda_drv_missing() if has_nvidia_web_drivers is True else False, + } + + _cant_patch = False + _cant_unpatch = requirements[HardwarePatchsetValidation.SIP_ENABLED] + + if self._validation is False: + if requirements[HardwarePatchsetValidation.SIP_ENABLED] is True: + requirements = self._handle_sip_breakdown(requirements, required_sip_configs) + if requirements[HardwarePatchsetValidation.MISSING_NETWORK_CONNECTION] is True: + requirements, device_properties = self._handle_missing_network_connection(requirements, device_properties) + + # Third pass to sync stripped hardware (ie. '_handle_missing_network_connection()') + for item in present_hardware: + item: BaseHardware + if item.name() not in device_properties: + continue + patches.update(item.patches()) + + _cant_patch = not self._can_patch(requirements) + + requirements[HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE] = _cant_patch + requirements[HardwarePatchsetValidation.UNPATCHING_NOT_POSSIBLE] = _cant_unpatch + + self.can_patch = not _cant_patch + self.can_unpatch = not _cant_unpatch + + device_properties.update(requirements) + + self.device_properties = device_properties + self.patches = patches + + + def detailed_errors(self) -> None: + """ + Print out detailed errors + """ + logging.error("- Breakdown:") + for key, value in self.device_properties.items(): + if not key.startswith("Validation:"): + continue + if key in [HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE, HardwarePatchsetValidation.UNPATCHING_NOT_POSSIBLE]: + continue + if value is False: + continue + logging.error(f" - {key.replace('Validation: ', '')}") diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/base.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/base.py new file mode 100644 index 000000000..bbb9ec58e --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/base.py @@ -0,0 +1,176 @@ +""" +base.py: Base class for hardware patch set detection +""" + +from enum import StrEnum +from pathlib import Path + +from ..base import BasePatchset + +from ....constants import Constants + +from ....datasets.os_data import os_data +from ....datasets.sip_data import system_integrity_protection +from ....detections.amfi_detect import AmfiConfigDetectLevel +from ....detections import device_probe + + +class HardwareVariant(StrEnum): + """ + Hardware variant for patch set + """ + GRAPHICS: str = "Graphics" + NETWORKING: str = "Networking" + AUDIO: str = "Audio" + MISCELLANEOUS: str = "Miscellaneous" + + +class HardwareVariantGraphicsSubclass(StrEnum): + """ + Graphics hardware variant subclass + """ + NON_METAL_GRAPHICS: str = "Non-Metal Graphics" + METAL_3802_GRAPHICS: str = "Metal 3802 Graphics" + METAL_31001_GRAPHICS: str = "Metal 31001 Graphics" + HEADLESS_GRAPHICS: str = "Headless Graphics" + NOT_APPLICABLE: str = "N/A" + + +class BaseHardware(BasePatchset): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__() + self._xnu_major = xnu_major + self._xnu_minor = xnu_minor + self._os_build = os_build + self._constants = global_constants + self._computer = global_constants.computer + + self._xnu_float = float(f"{self._xnu_major}.{self._xnu_minor}") + + + def name(self) -> str: + """ + Name of the patch set + """ + raise NotImplementedError + + + def present(self) -> bool: + """ + Whether the hardware is present in the system + """ + raise NotImplementedError + + + def native_os(self) -> bool: + """ + Is on native OS + """ + raise NotImplementedError + + + def hardware_variant(self) -> HardwareVariant: + """ + What hardware variant is this patch set for + """ + raise NotImplementedError + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + What subclass of graphics + """ + return HardwareVariantGraphicsSubclass.NOT_APPLICABLE + + + def required_amfi_level(self) -> AmfiConfigDetectLevel: + """ + What level of AMFI configuration is required for this patch set + Currently defaulted to AMFI needing to be disabled + """ + return AmfiConfigDetectLevel.ALLOW_ALL + + + def requires_primary_kernel_cache(self) -> bool: + """ + Whether patch set requires access to the primary kernel cache + ex. Boot/System Kernel Collection on Big Sur and newer + """ + return False + + + def requires_kernel_debug_kit(self) -> bool: + """ + Whether patch set requires access to the Kernel Debug Kit + """ + return False + + + def requires_metallib_support_pkg(self) -> bool: + """ + Whether patch set requires access to the MetallibSupportPkg PKG + """ + return False + + + def required_system_integrity_protection_configurations(self) -> list[str]: + """ + List of required SIP configurations for the patch set + """ + if self._xnu_major >= os_data.ventura.value: + return system_integrity_protection.root_patch_sip_ventura + if self._xnu_major >= os_data.big_sur.value: + return system_integrity_protection.root_patch_sip_big_sur + return system_integrity_protection.root_patch_sip_mojave + + + def patches(self) -> dict: + """ + Dictionary of patches + """ + raise NotImplementedError + + + def _is_gpu_architecture_present(self, gpu_architectures: list[device_probe.GPU]) -> bool: + """ + Check if a GPU architecture is present + """ + for gpu in self._computer.gpus: + if not gpu.class_code: + continue + if not gpu.arch: + continue + if gpu.class_code == 0xFFFFFFFF: + continue + + if gpu.arch in gpu_architectures: + return True + + return False + + + def _resolve_monterey_framebuffers(self) -> str: + """ + Resolve patchset directory for framebuffers last supported in Monterey: + - AppleIntelBDWGraphics.kext + - AppleIntelBDWGraphicsFramebuffer.kext + - AppleIntelFramebufferAzul.kext + - AppleIntelHD5000Graphics.kext + - AppleIntelSKLGraphics.kext + - AppleIntelSKLGraphicsFramebuffer.kext + - AMDRadeonX4000.kext + - AMDRadeonX5000.kext + """ + if self._xnu_major < os_data.sonoma.value: + return "12.5" + if self._xnu_float < self.macOS_14_4: + return "12.5-23" + return "12.5-23.4" + + + def _dortania_internal_check(self) -> None: + """ + Determine whether to unlock Dortania Developer mode + """ + return Path("~/.dortania_developer").expanduser().exists() diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_legacy_gcn.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_legacy_gcn.py new file mode 100644 index 000000000..794b2229a --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_legacy_gcn.py @@ -0,0 +1,135 @@ +""" +amd_legacy_gcn.py: AMD Legacy GCN detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.monterey_gva import MontereyGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL +from ...shared_patches.amd_opencl import AMDOpenCL + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class AMDLegacyGCN(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: AMD Legacy GCN" + + + def present(self) -> bool: + """ + Targeting AMD Legacy GCN GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.AMD.Archs.Legacy_GCN_7000, + device_probe.AMD.Archs.Legacy_GCN_8000, + device_probe.AMD.Archs.Legacy_GCN_9000 + ] + ) and self._computer.rosetta_active is False # Rosetta 2 mimics an AMD R9 270X + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_31001_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + # If 3802 GPU present, use stock Monterey bronze bundle even on Sequoia + bronze_bundle_source = "12.5" + if self._is_gpu_architecture_present( + [ + device_probe.Intel.Archs.Ivy_Bridge, + device_probe.Intel.Archs.Haswell, + device_probe.NVIDIA.Archs.Kepler, + ] + ) is False: + if self._xnu_major >= os_data.sequoia: + bronze_bundle_source = "12.5-24" + + return { + "AMD Legacy GCN": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMD7000Controller.kext": "12.5", + "AMD8000Controller.kext": "12.5", + "AMD9000Controller.kext": "12.5", + "AMD9500Controller.kext": "12.5", + "AMD10000Controller.kext": "12.5", + "AMDRadeonX4000.kext": self._resolve_monterey_framebuffers(), + "AMDRadeonX4000HWServices.kext": "12.5", + "AMDFramebuffer.kext": "12.5" if self._xnu_float < self.macOS_13_3 else "12.5-GCN", + "AMDSupport.kext": "12.5", + + "AMDRadeonVADriver.bundle": "12.5", + "AMDRadeonVADriver2.bundle": "12.5", + "AMDRadeonX4000GLDriver.bundle": "12.5", + "AMDMTLBronzeDriver.bundle": bronze_bundle_source, + "AMDShared.bundle": "12.5", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for AMD Legacy GCN GPUs + """ + if self.native_os() is True: + return {} + + _base = {} + + if self._is_gpu_architecture_present(gpu_architectures=[device_probe.Intel.Archs.Skylake]) is False: + # Monterey GVA is not required for Intel Skylake iGPUs + _base.update({ + **MontereyGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + }) + + _base.update({ + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **AMDOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **self._model_specific_patches(), + }) + + return _base \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_polaris.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_polaris.py new file mode 100644 index 000000000..f37f2bc56 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_polaris.py @@ -0,0 +1,146 @@ +""" +amd_polaris.py: AMD Polaris detection +""" + +from .amd_legacy_gcn import AMDLegacyGCN + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.monterey_gva import MontereyGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL +from ...shared_patches.amd_opencl import AMDOpenCL + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class AMDPolaris(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: AMD Polaris" + + + def present(self) -> bool: + """ + Targeting AMD Polaris GPUs with CPUs lacking AVX2.0 or missing Framebuffer patches (ie. MacBookPro13,3 and MacBookPro14,3) + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.AMD.Archs.Polaris + ] + ) and ("AVX2" not in self._computer.cpu.leafs or self._computer.real_model in ["MacBookPro13,3", "MacBookPro14,3"]) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_31001_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + + # For MacBookPro13,3 missing framebuffers (ex. 'ATY,Berbice') + if self._computer.real_model in ["MacBookPro13,3"]: + # Since dropped at the same time, we can use the same patches + return AMDLegacyGCN(self._xnu_major, self._xnu_minor, self._os_build, self._constants)._model_specific_patches() + + # For MacBookPro14,3 (and other AMD dGPUs that no longer function in Sonoma) + # iMac18,2/3 still function with the generic framebuffer, however if issues arise + # we'll downgrade them as well. + if self._computer.real_model in ["MacBookPro14,3"]: + if self._xnu_major < os_data.sonoma.value: + return {} + return { + "AMD Polaris": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMD9500Controller.kext": "13.5.2", + "AMD10000Controller.kext": "13.5.2", + "AMDFramebuffer.kext": "13.5.2", + "AMDSupport.kext": "13.5.2", + }, + }, + }, + } + + # Assuming non-AVX2.0 CPUs + # Note missing framebuffers are not restored (ex. 'ATY,Berbice') + return { + "AMD Polaris": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMDRadeonX4000.kext": self._resolve_monterey_framebuffers(), + "AMDRadeonX4000HWServices.kext": "12.5", + "AMDRadeonVADriver2.bundle": "12.5", + "AMDRadeonX4000GLDriver.bundle": "12.5", + "AMDMTLBronzeDriver.bundle": "12.5" if self._xnu_major < os_data.sequoia else "12.5-24", + "AMDShared.bundle": "12.5", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for AMD Polaris GPUs + """ + if self.native_os() is True: + return {} + + # Minimal amount of patches required for 2017 Polaris + if self._computer.real_model in ["MacBookPro14,3"]: + return self._model_specific_patches() + + _base = { + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **self._model_specific_patches(), + } + if "AVX2" not in self._computer.cpu.leafs: + _base.update({ + **AMDOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + }) + + if self._is_gpu_architecture_present(gpu_architectures=[device_probe.Intel.Archs.Skylake]) is False: + # Monterey GVA is not required for Intel Skylake iGPUs + _base.update({ + **MontereyGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + }) + + return _base \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_terascale_1.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_terascale_1.py new file mode 100644 index 000000000..65953260c --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_terascale_1.py @@ -0,0 +1,112 @@ +""" +amd_terascale_1.py: AMD TeraScale 1 detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.non_metal import NonMetal +from ...shared_patches.monterey_webkit import MontereyWebKit +from ...shared_patches.amd_terascale import AMDTeraScale + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class AMDTeraScale1(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: AMD TeraScale 1" + + + def present(self) -> bool: + """ + Targeting AMD TeraScale GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.AMD.Archs.TeraScale_1 + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major < os_data.mojave.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "AMD TeraScale 1": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMD2400Controller.kext": "10.13.6", + "AMD2600Controller.kext": "10.13.6", + "AMD3800Controller.kext": "10.13.6", + "AMD4600Controller.kext": "10.13.6", + "AMD4800Controller.kext": "10.13.6", + "ATIRadeonX2000.kext": "10.13.6" if self._xnu_major < os_data.ventura else "10.13.6 TS1", + "ATIRadeonX2000GA.plugin": "10.13.6", + "ATIRadeonX2000GLDriver.bundle": "10.13.6", + "ATIRadeonX2000VADriver.bundle": "10.13.6", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for AMD TeraScale 1 GPUs + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support and self._dortania_internal_check() is False: + return { + **AMDTeraScale(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches() + } + + return { + **NonMetal(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **AMDTeraScale(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_terascale_2.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_terascale_2.py new file mode 100644 index 000000000..3ea7a8870 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_terascale_2.py @@ -0,0 +1,117 @@ +""" +amd_terascale_2.py: AMD TeraScale 2 detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.non_metal import NonMetal +from ...shared_patches.non_metal_ioaccel import NonMetalIOAccelerator +from ...shared_patches.monterey_webkit import MontereyWebKit +from ...shared_patches.amd_terascale import AMDTeraScale + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class AMDTeraScale2(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: AMD TeraScale 2" + + + def present(self) -> bool: + """ + Targeting AMD TeraScale GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.AMD.Archs.TeraScale_2 + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major < os_data.mojave.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + _base = { + "AMD TeraScale 2": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMD5000Controller.kext": "10.13.6", + "AMD6000Controller.kext": "10.13.6", + "AMDRadeonVADriver.bundle": "10.13.6", + "AMDRadeonVADriver2.bundle": "10.13.6", + "AMDRadeonX3000.kext": "10.13.6", + "AMDRadeonX3000GLDriver.bundle": "10.13.6", + }, + }, + }, + } + + # TeraScale 2 MacBooks with faulty GPUs are highly prone to crashing with AMDRadeonX3000 attached + if self._constants.allow_ts2_accel is False and self._constants.host_is_hackintosh is False: + _base["AMD TeraScale 2"][PatchType.OVERWRITE_SYSTEM_VOLUME]["/System/Library/Extensions"].pop("AMDRadeonX3000.kext") + + return _base + + + def patches(self) -> dict: + """ + Patches for AMD TeraScale 2 GPUs + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support and self._dortania_internal_check() is False: + return { + **AMDTeraScale(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches() + } + + return { + **NonMetal(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **NonMetalIOAccelerator(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **AMDTeraScale(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_vega.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_vega.py new file mode 100644 index 000000000..ef8070b8b --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/amd_vega.py @@ -0,0 +1,130 @@ +""" +amd_vega.py: AMD Vega detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.monterey_gva import MontereyGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL +from ...shared_patches.amd_opencl import AMDOpenCL + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class AMDVega(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: AMD Vega" + + + def present(self) -> bool: + """ + Targeting AMD Vega GPUs with CPUs lacking AVX2.0 + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.AMD.Archs.Vega + ] + ) and "AVX2" not in self._computer.cpu.leafs + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_31001_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "AMD Vega": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMDRadeonX5000.kext": self._resolve_monterey_framebuffers(), + + "AMDRadeonVADriver2.bundle": "12.5", + "AMDRadeonX5000GLDriver.bundle": "12.5", + "AMDRadeonX5000MTLDriver.bundle": "12.5" if self._xnu_major < os_data.sequoia else "12.5-24", + "AMDRadeonX5000Shared.bundle": "12.5", + + "AMDShared.bundle": "12.5", + }, + }, + }, + } + + + def _model_specific_patches_extended(self) -> dict: + """ + Support mixed legacy and modern AMD GPUs + Specifically systems using AMD GCN 1-3 and Vega (ex. MacPro6,1 with eGPU) + Assume 'AMD Legacy GCN' patchset is installed alongside this + """ + if self._is_gpu_architecture_present([ + device_probe.AMD.Archs.Legacy_GCN_7000, + device_probe.AMD.Archs.Legacy_GCN_8000, + device_probe.AMD.Archs.Legacy_GCN_9000 + ]) is False: + return {} + + return { + "AMD Vega Extended": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMDRadeonX5000HWServices.kext": "12.5", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for AMD Vega GPUs + """ + if self.native_os() is True: + return {} + + return { + **MontereyGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **AMDOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **self._model_specific_patches(), + **self._model_specific_patches_extended(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_broadwell.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_broadwell.py new file mode 100644 index 000000000..b94ca3bfe --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_broadwell.py @@ -0,0 +1,94 @@ +""" +intel_broadwell.py: Intel Broadwell detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.monterey_gva import MontereyGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class IntelBroadwell(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Intel Broadwell" + + + def present(self) -> bool: + """ + Targeting Intel Broadwell GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Broadwell + ] + ) + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_31001_GRAPHICS + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Intel Broadwell": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelBDWGraphics.kext": self._resolve_monterey_framebuffers(), + "AppleIntelBDWGraphicsFramebuffer.kext": self._resolve_monterey_framebuffers(), + "AppleIntelBDWGraphicsGLDriver.bundle": "12.5", + "AppleIntelBDWGraphicsMTLDriver.bundle": "12.5-22" if self._xnu_major < os_data.sequoia else "12.5-24", + "AppleIntelBDWGraphicsVADriver.bundle": "12.5", + "AppleIntelBDWGraphicsVAME.bundle": "12.5", + "AppleIntelGraphicsShared.bundle": "12.5", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Intel Broadwell iGPUs + """ + if self.native_os() is True: + return {} + + return { + **MontereyGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **self._model_specific_patches(), + } diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_haswell.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_haswell.py new file mode 100644 index 000000000..5ef1ae0f5 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_haswell.py @@ -0,0 +1,120 @@ +""" +intel_haswell.py: Intel Haswell detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.metal_3802 import LegacyMetal3802 +from ...shared_patches.monterey_gva import MontereyGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class IntelHaswell(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Intel Haswell" + + + def present(self) -> bool: + """ + Targeting Intel Haswell GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Haswell + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_3802_GRAPHICS + + + def requires_metallib_support_pkg(self) -> bool: + """ + New compiler format introduced in macOS 15, Sequoia + """ + return self._xnu_major >= os_data.sequoia.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Intel Haswell": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelFramebufferAzul.kext": self._resolve_monterey_framebuffers(), + "AppleIntelHD5000Graphics.kext": self._resolve_monterey_framebuffers(), + "AppleIntelHD5000GraphicsGLDriver.bundle": "12.5", + "AppleIntelHD5000GraphicsMTLDriver.bundle": "12.5", + "AppleIntelHD5000GraphicsVADriver.bundle": "12.5", + "AppleIntelHSWVA.bundle": "12.5", + "AppleIntelGraphicsShared.bundle": "12.5", + }, + }, + }, + } + + + def _framebuffer_only_patches(self) -> dict: + """ + Framebuffer only patches + """ + return { + "Intel Haswell": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelFramebufferAzul.kext": self._resolve_monterey_framebuffers(), + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Intel Haswell iGPUs + """ + if self.native_os() is True: + return {} + + return { + **LegacyMetal3802(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **self._model_specific_patches(), + + } diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_iron_lake.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_iron_lake.py new file mode 100644 index 000000000..5d513b13c --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_iron_lake.py @@ -0,0 +1,103 @@ +""" +intel_iron_lake.py: Intel Iron Lake detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.non_metal import NonMetal +from ...shared_patches.monterey_webkit import MontereyWebKit + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class IntelIronLake(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Intel Iron Lake" + + + def present(self) -> bool: + """ + Targeting Intel Iron Lake GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Iron_Lake + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major < os_data.mojave.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Intel Iron Lake": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelHDGraphics.kext": "10.13.6", + "AppleIntelHDGraphicsFB.kext": "10.13.6", + "AppleIntelHDGraphicsGA.plugin": "10.13.6", + "AppleIntelHDGraphicsGLDriver.bundle": "10.13.6", + "AppleIntelHDGraphicsVADriver.bundle": "10.13.6", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Intel Iron Lake iGPUs + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support and self._dortania_internal_check() is False: + return {**self._model_specific_patches()} + + return { + **NonMetal(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_ivy_bridge.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_ivy_bridge.py new file mode 100644 index 000000000..3f4c70312 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_ivy_bridge.py @@ -0,0 +1,121 @@ +""" +intel_ivy_bridge.py: Intel Ivy Bridge detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.metal_3802 import LegacyMetal3802 +from ...shared_patches.big_sur_gva import BigSurGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL +from ...shared_patches.big_sur_opencl import BigSurOpenCL +from ...shared_patches.monterey_webkit import MontereyWebKit + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class IntelIvyBridge(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Intel Ivy Bridge" + + + def present(self) -> bool: + """ + Targeting Intel Ivy Bridge GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Ivy_Bridge + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 12, Monterey + """ + return self._xnu_major < os_data.monterey.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_3802_GRAPHICS + + + def requires_metallib_support_pkg(self) -> bool: + """ + New compiler format introduced in macOS 15, Sequoia + """ + return self._xnu_major >= os_data.sequoia.value + + + def _resolve_ivy_bridge_framebuffers(self) -> str: + """ + Resolve patchset directory for Ivy Bridge framebuffers: + - AppleIntelFramebufferCapri.kext + - AppleIntelHD4000Graphics.kext + """ + if self._xnu_major < os_data.sonoma: + return "11.7.10" + if self._xnu_float < self.macOS_14_4: + return "11.7.10-23" + return "11.7.10-23.4" + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Intel Ivy Bridge": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelHD4000GraphicsGLDriver.bundle": "11.7.10", + "AppleIntelHD4000GraphicsMTLDriver.bundle": "11.7.10" if self._xnu_major < os_data.ventura else "11.7.10-22", + "AppleIntelHD4000GraphicsVADriver.bundle": "11.7.10", + "AppleIntelFramebufferCapri.kext": self._resolve_ivy_bridge_framebuffers(), + "AppleIntelHD4000Graphics.kext": self._resolve_ivy_bridge_framebuffers(), + "AppleIntelIVBVA.bundle": "11.7.10", + "AppleIntelGraphicsShared.bundle": "11.7.10", # libIGIL-Metal.dylib pulled from 11.0 Beta 6 + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Intel Ivy Bridge iGPUs + """ + if self.native_os() is True: + return {} + + return { + **LegacyMetal3802(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **BigSurGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **BigSurOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_sandy_bridge.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_sandy_bridge.py new file mode 100644 index 000000000..4fb35a196 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_sandy_bridge.py @@ -0,0 +1,108 @@ +""" +intel_sandy_bridge.py: Intel Sandy Bridge detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.non_metal import NonMetal +from ...shared_patches.monterey_webkit import MontereyWebKit +from ...shared_patches.high_sierra_gva import HighSierraGVA + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class IntelSandyBridge(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Intel Sandy Bridge" + + + def present(self) -> bool: + """ + Targeting Intel Sandy Bridge GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Sandy_Bridge + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major < os_data.mojave.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Requires replacing a number of kexts in the BootKC + """ + if self._xnu_major >= os_data.ventura.value: + return True + return False + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Intel Sandy Bridge": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelHD3000Graphics.kext": "10.13.6", + "AppleIntelHD3000GraphicsGA.plugin": "10.13.6", + "AppleIntelHD3000GraphicsGLDriver.bundle": "10.13.6", + "AppleIntelHD3000GraphicsVADriver.bundle": "10.13.6", + "AppleIntelSNBGraphicsFB.kext": "10.13.6", + "AppleIntelSNBVA.bundle": "10.13.6", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Intel Sandy Bridge GPUs + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support and self._dortania_internal_check() is False: + return {**self._model_specific_patches()} + + return { + **NonMetal(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **HighSierraGVA(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_skylake.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_skylake.py new file mode 100644 index 000000000..8b69b3e91 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/intel_skylake.py @@ -0,0 +1,93 @@ +""" +intel_skylake.py: Intel Skylake detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.monterey_opencl import MontereyOpenCL + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class IntelSkylake(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Intel Skylake" + + + def present(self) -> bool: + """ + Targeting Intel Skylake GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Skylake + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_31001_GRAPHICS + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Intel Skylake": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleIntelSKLGraphics.kext": self._resolve_monterey_framebuffers(), + "AppleIntelSKLGraphicsFramebuffer.kext": self._resolve_monterey_framebuffers(), + "AppleIntelSKLGraphicsGLDriver.bundle": "12.5", + "AppleIntelSKLGraphicsMTLDriver.bundle": "12.5" if self._xnu_major < os_data.sequoia else "12.5-24", + "AppleIntelSKLGraphicsVADriver.bundle": "12.5", + "AppleIntelSKLGraphicsVAME.bundle": "12.5", + "AppleIntelGraphicsShared.bundle": "12.5", + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Intel Skylake iGPUs + """ + if self.native_os() is True: + return {} + + return { + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **self._model_specific_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_kepler.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_kepler.py new file mode 100644 index 000000000..2873f5326 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_kepler.py @@ -0,0 +1,139 @@ +""" +nvidia_kepler.py: Nvidia Kepler detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.metal_3802 import LegacyMetal3802 +from ...shared_patches.big_sur_gva import BigSurGVA +from ...shared_patches.monterey_opencl import MontereyOpenCL +from ...shared_patches.big_sur_opencl import BigSurOpenCL +from ...shared_patches.monterey_webkit import MontereyWebKit + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class NvidiaKepler(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Nvidia Kepler" + + + def present(self) -> bool: + """ + Targeting Nvidia Kepler GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.NVIDIA.Archs.Kepler + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 12.0 Beta 7, Monterey + """ + if self._xnu_major < os_data.monterey: + return True + + if self._xnu_major == os_data.monterey: + if self._xnu_minor > 0: + return True + if self._os_build != "21A5522h": # 12.0 Beta 7 + return True + + return False + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.METAL_3802_GRAPHICS + + + def requires_metallib_support_pkg(self) -> bool: + """ + New compiler format introduced in macOS 15, Sequoia + """ + return self._xnu_major >= os_data.sequoia.value + + + def _resolve_kepler_geforce_framebuffers(self) -> str: + """ + Resolve patchset directory for GeForce.kext + """ + if self._xnu_major < os_data.sonoma: + return "12.0 Beta 6" + if self._xnu_float < self.macOS_14_4: + return "12.0 Beta 6-23" + return "12.0 Beta 6-23.4" + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Nvidia Kepler": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "GeForce.kext": self._resolve_kepler_geforce_framebuffers(), + "NVDAGF100Hal.kext": "12.0 Beta 6", + "NVDAGK100Hal.kext": "12.0 Beta 6", + "NVDAResman.kext": "12.0 Beta 6", + "NVDAStartup.kext": "12.0 Beta 6", + "GeForceAIRPlugin.bundle": "11.0 Beta 3", + "GeForceGLDriver.bundle": "11.0 Beta 3", + "GeForceMTLDriver.bundle": "11.0 Beta 3" if self._xnu_major <= os_data.monterey else f"11.0 Beta 3-22", + "GeForceVADriver.bundle": "12.0 Beta 6", + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + # XNU 21.6 (macOS 12.5) + **({ "Metal.framework": "12.5 Beta 2"} if (self._xnu_float >= self.macOS_12_5 and self._xnu_major < os_data.ventura) else {}), + }, + "/System/Library/PrivateFrameworks": { + "GPUCompiler.framework": "11.6", + }, + } + }, + } + + + def patches(self) -> dict: + """ + Patches for Nvidia Kepler GPUs + """ + if self.native_os() is True: + return {} + + return { + **LegacyMetal3802(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **BigSurGVA(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **BigSurOpenCL(self._xnu_major, self._xnu_minor, self._constants.detected_os_version).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_tesla.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_tesla.py new file mode 100644 index 000000000..e071f9ee3 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_tesla.py @@ -0,0 +1,106 @@ +""" +nvidia_tesla.py: Nvidia Tesla detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.non_metal import NonMetal +from ...shared_patches.monterey_webkit import MontereyWebKit + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class NvidiaTesla(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Nvidia Tesla" + + + def present(self) -> bool: + """ + Targeting Nvidia Tesla GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.NVIDIA.Archs.Tesla + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Nvidia Tesla": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "GeForceGA.bundle": "10.13.6", + "GeForceTesla.kext": "10.13.6", + "GeForceTeslaGLDriver.bundle": "10.13.6", + "GeForceTeslaVADriver.bundle": "10.13.6", + "NVDANV50HalTesla.kext": "10.13.6", + "NVDAResmanTesla.kext": "10.13.6", + # Apple dropped NVDAStartup in 12.0 Beta 7 (XNU 21.1) + **({ "NVDAStartup.kext": "12.0 Beta 6" } if self._xnu_float >= self.macOS_12_0_B7 else {}) + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Nvidia Tesla GPUs + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support and self._dortania_internal_check() is False: + return {**self._model_specific_patches()} + + return { + **NonMetal(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_webdriver.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_webdriver.py new file mode 100644 index 000000000..f272f54c1 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/graphics/nvidia_webdriver.py @@ -0,0 +1,164 @@ +""" +nvidia_webdriver.py: Nvidia Web Driver detection +""" + +from ..base import BaseHardware, HardwareVariant, HardwareVariantGraphicsSubclass + +from ...base import PatchType + +from ...shared_patches.non_metal import NonMetal +from ...shared_patches.monterey_webkit import MontereyWebKit +from ...shared_patches.non_metal_ioaccel import NonMetalIOAccelerator +from ...shared_patches.non_metal_coredisplay import NonMetalCoreDisplay +from ...shared_patches.non_metal_enforcement import NonMetalEnforcement + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data +from .....datasets.sip_data import system_integrity_protection + + +class NvidiaWebDriver(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Nvidia Web Drivers" + + + def present(self) -> bool: + """ + Targeting Nvidia Fermi, Maxwell, Pascal GPUs + """ + return self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.NVIDIA.Archs.Fermi, + device_probe.NVIDIA.Archs.Maxwell, + device_probe.NVIDIA.Archs.Pascal, + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major < os_data.mojave.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.GRAPHICS + + + def hardware_variant_graphics_subclass(self) -> HardwareVariantGraphicsSubclass: + """ + Type of hardware variant subclass + """ + return HardwareVariantGraphicsSubclass.NON_METAL_GRAPHICS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def required_system_integrity_protection_configurations(self) -> list[str]: + """ + List of required SIP configurations for the patch set + """ + return system_integrity_protection.root_patch_sip_big_sur_3rd_part_kexts + + + def _model_specific_patches(self) -> dict: + """ + Model specific patches + """ + return { + "Nvidia Web Drivers": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "GeForceAIRPluginWeb.bundle": "WebDriver-387.10.10.10.40.140", + "GeForceGLDriverWeb.bundle": "WebDriver-387.10.10.10.40.140", + "GeForceMTLDriverWeb.bundle": "WebDriver-387.10.10.10.40.140", + "GeForceVADriverWeb.bundle": "WebDriver-387.10.10.10.40.140", + + # Tesla-only files + "GeForceTeslaGAWeb.bundle": "WebDriver-387.10.10.10.40.140", + "GeForceTeslaGLDriverWeb.bundle": "WebDriver-387.10.10.10.40.140", + "GeForceTeslaVADriverWeb.bundle": "WebDriver-387.10.10.10.40.140", + }, + }, + PatchType.OVERWRITE_DATA_VOLUME: { + "/Library/Extensions": { + "GeForceWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAGF100HalWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAGK100HalWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAGM100HalWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAGP100HalWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAResmanWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAStartupWeb.kext": "WebDriver-387.10.10.10.40.140", + + # Tesla-only files + "GeForceTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDANV50HalTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", + "NVDAResmanTeslaWeb.kext": "WebDriver-387.10.10.10.40.140", + }, + + # Disabled due to issues with Pref pane stripping 'nvda_drv' NVRAM + # variables + # "/Library/PreferencePanes": { + # "NVIDIA Driver Manager.prefPane": "WebDriver-387.10.10.10.40.140", + # }, + # "/Library/LaunchAgents": { + # "com.nvidia.nvagent.plist": "WebDriver-387.10.10.10.40.140", + # }, + # "/Library/LaunchDaemons": { + # "com.nvidia.nvroothelper.plist": "WebDriver-387.10.10.10.40.140", + # }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks": { + # Restore OpenCL by adding missing compiler files + **({ "GPUCompiler.framework": "11.6"} if self._xnu_major >= os_data.monterey else {}), + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions": [ + # Due to how late the Auxiliary cache loads, NVDAStartup will match first and then the Web Driver kexts. + # This has no effect for Maxwell and Pascal, however for development purposes, Tesla and Kepler are partially supported. + "NVDAStartup.kext", + ], + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for Nvidia Web Drivers + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support and self._dortania_internal_check() is False: + return {**self._model_specific_patches()} + + return { + **NonMetal(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **NonMetalIOAccelerator(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **NonMetalCoreDisplay(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **MontereyWebKit(self._xnu_major, self._xnu_minor, self._os_build).patches(), + **self._model_specific_patches(), + **NonMetalEnforcement(self._xnu_major, self._xnu_minor, self._os_build).patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/display_backlight.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/display_backlight.py new file mode 100644 index 000000000..25176804e --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/display_backlight.py @@ -0,0 +1,86 @@ +""" +display_backlight.py: Legacy Backlight Control detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants + +from .....datasets.os_data import os_data + + +class DisplayBacklight(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Legacy Backlight Control" + + + def present(self) -> bool: + """ + Targeting Legacy Backlight Controllers + """ + return self._computer.real_model in [ + "MacBook5,2", + "iMac7,1", + "iMac8,1", + "iMac9,1", + ] + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.13, High Sierra + """ + return self._xnu_major < os_data.high_sierra.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def patches(self) -> dict: + """ + Patches for Legacy Backlight Control + """ + if self.native_os() is True: + return {} + + return { + "Legacy Backlight Control": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleBacklight.kext": "10.12.6", + "AppleBacklightExpert.kext": "10.12.6", + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks": { + "DisplayServices.framework": "10.12.6", + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": [ + "AGDCBacklightControl.kext", + ], + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/gmux.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/gmux.py new file mode 100644 index 000000000..12c1958e0 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/gmux.py @@ -0,0 +1,116 @@ +""" +gmux.py: Legacy GMUX detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants +from .....support import utilities + +from .....datasets.os_data import os_data + + +class GraphicsMultiplexer(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Legacy GMUX" + + + def _check_dgpu_status(self) -> bool: + """ + Query whether system has an active dGPU + """ + dgpu = self._computer.dgpu + if dgpu: + if dgpu.class_code and dgpu.class_code == 0xFFFFFFFF: + # If dGPU is disabled via class-codes, assume demuxed + return False + return True + return False + + + def _detect_demux(self) -> bool: + """ + Query whether system has been demuxed (ex. MacBookPro8,2, disabled dGPU) + """ + # If GFX0 is missing, assume machine was demuxed + # -wegnoegpu would also trigger this, so ensure arg is not present + if not "-wegnoegpu" in (utilities.get_nvram("boot-args", decode=True) or ""): + igpu = self._constants.computer.igpu + dgpu = self._check_dgpu_status() + if igpu and not dgpu: + return True + return False + + + def present(self) -> bool: + """ + Targeting Legacy GMUX Controllers + Ref: https://doslabelectronics.com/Demux.html + + Sierra uses a legacy GMUX control method needed for dGPU switching on MacBookPro5,x + Same method is also used for demuxed machines + Note that MacBookPro5,x machines are extremely unstable with this patch set, so disabled until investigated further + Ref: https://github.com/dortania/OpenCore-Legacy-Patcher/files/7360909/KP-b10-030.txt + """ + return self._computer.real_model in ["MacBookPro8,2", "MacBookPro8,3"] and self._detect_demux() + + + def native_os(self) -> bool: + """ + Dropped support with macOS 10.13, High Sierra + """ + return self._xnu_major < os_data.sierra.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def patches(self) -> dict: + """ + Patches for Legacy Backlight Control + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support: + return {} + + return { + "Legacy GMUX": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": { + "AppleMuxControl.kext": "10.12.6", + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions": [ + "AppleBacklight.kext", + ], + "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": [ + "AGDCBacklightControl.kext", + "AppleMuxControl.kext", + ], + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/keyboard_backlight.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/keyboard_backlight.py new file mode 100644 index 000000000..94e01e7fe --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/keyboard_backlight.py @@ -0,0 +1,93 @@ +""" +keyboard_backlight.py: Legacy Keyboard Backlight detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class KeyboardBacklight(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Legacy Keyboard Backlight" + + + def present(self) -> bool: + """ + Targeting Legacy Keyboard Backlight (ie. non-Metal Macs) + """ + return self._computer.real_model.startswith("MacBook") and self._is_gpu_architecture_present( + gpu_architectures=[ + device_probe.Intel.Archs.Iron_Lake, + device_probe.Intel.Archs.Sandy_Bridge, + device_probe.AMD.Archs.TeraScale_1, + device_probe.AMD.Archs.TeraScale_2, + device_probe.NVIDIA.Archs.Tesla, + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 11, Big Sur + """ + return self._xnu_major < os_data.big_sur.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def requires_kernel_debug_kit(self) -> bool: + """ + Apple no longer provides standalone kexts in the base OS + """ + return self._xnu_major >= os_data.ventura.value + + + def patches(self) -> dict: + """ + Patches for Legacy Backlight Control + """ + if self.native_os() is True: + return {} + + if self._xnu_major not in self._constants.legacy_accel_support: + return {} + + return { + "Legacy Backlight Control": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleBacklight.kext": "10.12.6", + "AppleBacklightExpert.kext": "10.12.6", + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks": { + "DisplayServices.framework": "10.12.6", + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns": [ + "AGDCBacklightControl.kext", + ], + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/legacy_audio.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/legacy_audio.py new file mode 100644 index 000000000..c2ae5b458 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/legacy_audio.py @@ -0,0 +1,136 @@ +""" +legacy_audio.py: Legacy Audio detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants +from .....support import utilities + +from .....datasets.os_data import os_data + + +class LegacyAudio(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Legacy Audio" + + + def present(self) -> bool: + """ + Targeting Realtek Audio and machines without AppleALC + """ + return self._computer.real_model in ["iMac7,1", "iMac8,1"] or ( + self._computer.real_model in ["MacBook5,1", + "MacBook5,2", + "MacBook6,1", + "MacBook7,1", + "MacBookAir2,1", + "MacBookAir3,1", + "MacBookAir3,2", + "MacBookAir4,1", + "MacBookAir4,2", + "MacBookPro4,1", + "MacBookPro5,1", + "MacBookPro5,2", + "MacBookPro5,3", + "MacBookPro5,4", + "MacBookPro5,5", + "MacBookPro6,1", + "MacBookPro6,2", + "MacBookPro7,1", + "MacBookPro8,1", + "MacBookPro8,2", + "MacBookPro8,3", + "Macmini3,1", + "Macmini4,1", + "Macmini5,1", + "Macmini5,2", + "Macmini5,3", + "iMac9,1", + "iMac10,1", + "iMac11,1", + "iMac11,2", + "iMac11,3", + "iMac12,1", + "iMac12,2", + "MacPro3,1" + ] and utilities.check_kext_loaded("as.vit9696.AppleALC") is False) + + + def native_os(self) -> bool: + """ + - iMac7,1 and iMac8,1 last supported in macOS 10.11, El Capitan + - All other models pre-2012 models last supported in macOS 10.13, High Sierra + """ + if self._computer.real_model in ["iMac7,1", "iMac8,1"]: + return self._xnu_major < os_data.sierra.value + return self._xnu_major < os_data.mojave.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def _missing_gop_patches(self) -> dict: + """ + Patches for graphics cards with missing GOP (ie. breaking AppleALC functionality) + """ + return { + "Legacy Non-GOP": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleHDA.kext": "10.13.6", + }, + }, + }, + } + + + def _realtek_audio_patches(self) -> dict: + """ + Patches for Realtek Audio + """ + return { + "Legacy Realtek": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AppleHDA.kext": "10.11.6", + "IOAudioFamily.kext": "10.11.6", + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions": [ + "AppleVirtIO.kext", + "AppleVirtualGraphics.kext", + "AppleVirtualPlatform.kext", + "ApplePVPanic.kext", + "AppleVirtIOStorage.kext", + ], + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for legacy audio + """ + if self.native_os() is True: + return {} + + if self._computer.real_model in ["iMac7,1", "iMac8,1"]: + return self._realtek_audio_patches() + return self._missing_gop_patches() \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/pcie_webcam.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/pcie_webcam.py new file mode 100644 index 000000000..76fb8c03d --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/pcie_webcam.py @@ -0,0 +1,66 @@ +""" +pci_webcam.py: PCIe FaceTime Camera detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants + +from .....datasets.os_data import os_data + + +class PCIeFaceTimeCamera(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: PCIe FaceTime Camera" + + + def present(self) -> bool: + """ + Targeting PCIe FaceTime Cameras + """ + return self._computer.pcie_webcam + + + def native_os(self) -> bool: + """ + Dropped support with macOS 14 Developer Beta 1 (23A5257q) + """ + return self._xnu_major < os_data.sonoma.value or self._os_build == "23A5257q" + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def patches(self) -> dict: + """ + Patches for PCIe FaceTime Camera + """ + if self.native_os() is True: + return {} + + return { + "PCIe FaceTime Camera": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources": { + "AppleCamera.plugin": "14.0 Beta 1" + }, + "/System/Library/LaunchDaemons": { + "com.apple.cmio.AppleCameraAssistant.plist": "14.0 Beta 1" + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/t1_security.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/t1_security.py new file mode 100644 index 000000000..1ee79ac0f --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/t1_security.py @@ -0,0 +1,93 @@ +""" +t1_security.py: T1 Security Chip detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants + +from .....datasets.os_data import os_data + + +class T1SecurityChip(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: T1 Security Chip" + + + def present(self) -> bool: + """ + Targeting T1 Security Chip + """ + return self._computer.t1_chip + + + def native_os(self) -> bool: + """ + Dropped support with macOS 14, Sonoma + """ + return self._xnu_major < os_data.sonoma.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def patches(self) -> dict: + """ + Patches for T1 Security Chip + """ + if self.native_os() is True: + return {} + + return { + "T1 Security Chip": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + # Required for Apple Pay + "/usr/lib": { + "libNFC_Comet.dylib": "13.6", + "libNFC_HAL.dylib": "13.6", + + "libnfshared.dylib": "13.6", + "libnfshared.dylibOld.dylib": "13.6", + "libnfstorage.dylib": "13.6", + "libnfrestore.dylib": "13.6", + + "libPN548_API.dylib": "13.6" + }, + "/usr/libexec": { + "biometrickitd": "13.6", # Required for Touch ID + "nfcd": "13.6", # Required for Apple Pay + "nfrestore_service": "13.6", # Required for Apple Pay + }, + "/usr/standalone/firmware/nfrestore/firmware/fw": { + "PN549_FW_02_01_5A_rev88207.bin": "13.6", + "SN100V_FW_A3_01_01_81_rev127208.bin": "13.6", + "SN200V_FW_B1_02_01_86_rev127266.bin": "13.6", + "SN300V_FW_B0_02_01_22_rev129172.bin": "13.6", + } + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks/LocalAuthentication.framework/Support": { + "SharedUtils.framework": f"13.6-{self._xnu_major}", # Required for Password Authentication (SharedUtils.framework) + **({ "MechanismPlugins": "15.0 Beta 4" } if self._xnu_major >= os_data.sequoia else {}), # Required to add a TouchID fingerprint + }, + "/System/Library/PrivateFrameworks": { + "EmbeddedOSInstall.framework": "13.6", # Required for biometrickitd + **({ "NearField.framework": "14.5" } if self._xnu_major >= os_data.sequoia else {}), + }, + } + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/usb11.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/usb11.py new file mode 100644 index 000000000..bceeb6125 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/misc/usb11.py @@ -0,0 +1,125 @@ + + +""" +usb11.py: Legacy USB 1.1 Controller detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data +from .....datasets import smbios_data, cpu_data + + +class USB11Controller(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Legacy USB 1.1" + + + def present(self) -> bool: + """ + Targeting UHCI/OHCI controllers + """ + # If we're on a hackintosh, check for UHCI/OHCI controllers + if self._constants.host_is_hackintosh is True: + for controller in self._computer.usb_controllers: + if ( + isinstance(controller, device_probe.UHCIController) or + isinstance(controller, device_probe.OHCIController) + ): + return True + return False + + if self._computer.real_model not in smbios_data.smbios_dictionary: + return False + + # If we're on a Mac, check for Penryn or older + # This is due to Apple implementing an internal USB hub on post-Penryn (excluding MacPro4,1, MacPro5,1 and Xserve3,1) + # Ref: https://techcommunity.microsoft.com/t5/microsoft-usb-blog/reasons-to-avoid-companion-controllers/ba-p/270710 + if ( + smbios_data.smbios_dictionary[self._computer.real_model]["CPU Generation"] <= cpu_data.CPUGen.penryn.value or \ + self._computer.real_model in ["MacPro4,1", "MacPro5,1", "Xserve3,1"] + ): + return True + + return False + + + def native_os(self) -> bool: + """ + Dropped support with macOS 13, Ventura + """ + return self._xnu_major < os_data.ventura.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.MISCELLANEOUS + + + def _base_patches(self) -> dict: + """ + Base patches for USB 1.1 Controller + """ + return { + "Legacy USB 1.1": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "IOUSBHostFamily.kext": "12.6.2" if self._xnu_float < self.macOS_14_4 else "12.6.2-23.4", + }, + }, + }, + } + + + def _extended_patches(self) -> dict: + """ + Extended patches for USB 1.1 Controller + """ + if self._xnu_float < self.macOS_14_1: + return {} + + return { + # Injection of UHCI/OHCI causes a panic on 14.1+ + "Legacy USB 1.1 Extended": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions/IOUSBHostFamily.kext/Contents/PlugIns": { + "AppleUSBOHCI.kext": "12.6.2-USB", + "AppleUSBOHCIPCI.kext": "12.6.2-USB", + "AppleUSBUHCI.kext": "12.6.2-USB", + "AppleUSBUHCIPCI.kext": "12.6.2-USB", + }, + "/System/Library/Extensions": { + **({ "AppleUSBAudio.kext": "14.5" } if self._xnu_major >= os_data.sequoia else {}), + **({ "AppleUSBCDC.kext": "14.5" } if self._xnu_major >= os_data.sequoia else {}), + }, + }, + }, + } + + + def patches(self) -> dict: + """ + Patches for USB 1.1 Controller + """ + if self.native_os() is True: + return {} + + return { + **self._base_patches(), + **self._extended_patches(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/networking/legacy_wireless.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/networking/legacy_wireless.py new file mode 100644 index 000000000..c856f2f52 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/networking/legacy_wireless.py @@ -0,0 +1,149 @@ +""" +legacy_wireless.py: Legacy Wireless detection +""" + +import packaging.version + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class LegacyWireless(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Legacy Wireless" + + + def present(self) -> bool: + """ + Targeting Legacy Wireless + """ + if ( + isinstance(self._computer.wifi, device_probe.Broadcom) + and self._computer.wifi.chipset in [device_probe.Broadcom.Chipsets.AirPortBrcm4331, device_probe.Broadcom.Chipsets.AirPortBrcm43224] + ): + return True + + if ( + isinstance(self._computer.wifi, device_probe.Atheros) + and self._computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40 + ): + return True + + return False + + + def native_os(self) -> bool: + """ + Dropped support with macOS 12, Monterey + """ + return self._xnu_major < os_data.monterey.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.NETWORKING + + + def _affected_by_cve_2024_23227(self) -> bool: + """ + CVE-2024-23227 broke our airportd patches for 12.7.4, 13.6.5 and 14.4 + + Note that since the XNU version's security patch level is not increment + """ + + if self._xnu_major > os_data.sonoma: + return True + + marketing_version = self._constants.detected_os_version + parsed_version = packaging.version.parse(marketing_version) + + if marketing_version.startswith("12"): + return parsed_version >= packaging.version.parse("12.7.4") + if marketing_version.startswith("13"): + return parsed_version >= packaging.version.parse("13.6.5") + if marketing_version.startswith("14"): + return parsed_version >= packaging.version.parse("14.4") + + return False + + + def _base_patch(self) -> dict: + """ + Base patches for Legacy Wireless + """ + return { + "Legacy Wireless": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/usr/libexec": { + "airportd": "11.7.10" if self._affected_by_cve_2024_23227 is False else "11.7.10-Sandbox", + }, + "/System/Library/CoreServices": { + "WiFiAgent.app": "11.7.10", + }, + }, + PatchType.OVERWRITE_DATA_VOLUME: { + "/Library/Application Support/SkyLightPlugins": { + **({ "CoreWLAN.dylib": "SkyLightPlugins" } if self._xnu_major == os_data.monterey else {}), + **({ "CoreWLAN.txt": "SkyLightPlugins" } if self._xnu_major == os_data.monterey else {}), + }, + }, + }, + } + + + def _extended_patch(self) -> dict: + """ + Extended patches for Legacy Wireless + """ + if self._xnu_major < os_data.ventura: + return {} + + return { + "Legacy Wireless Extended": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/usr/libexec": { + "wps": "12.7.2", + "wifip2pd": "12.7.2", + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "CoreWLAN.framework": "12.7.2", + }, + "/System/Library/PrivateFrameworks": { + "CoreWiFi.framework": "12.7.2", + "IO80211.framework": "12.7.2", + "WiFiPeerToPeer.framework": "12.7.2", + }, + } + }, + } + + + def patches(self) -> dict: + """ + Patches for Legacy Wireless + """ + if self.native_os() is True: + return {} + + return { + **self._base_patch(), + **self._extended_patch(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/hardware/networking/modern_wireless.py b/opencore_legacy_patcher/sys_patch/patchsets/hardware/networking/modern_wireless.py new file mode 100644 index 000000000..3a41848eb --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/hardware/networking/modern_wireless.py @@ -0,0 +1,85 @@ +""" +modern_wireless.py: Modern Wireless detection +""" + +from ..base import BaseHardware, HardwareVariant + +from ...base import PatchType + +from .....constants import Constants +from .....detections import device_probe + +from .....datasets.os_data import os_data + + +class ModernWireless(BaseHardware): + + def __init__(self, xnu_major, xnu_minor, os_build, global_constants: Constants) -> None: + super().__init__(xnu_major, xnu_minor, os_build, global_constants) + + + def name(self) -> str: + """ + Display name for end users + """ + return f"{self.hardware_variant()}: Modern Wireless" + + + def present(self) -> bool: + """ + Targeting Modern Wireless + """ + return isinstance(self._computer.wifi, device_probe.Broadcom) and ( + self._computer.wifi.chipset in [ + device_probe.Broadcom.Chipsets.AirPortBrcm4360, + device_probe.Broadcom.Chipsets.AirportBrcmNIC, + # We don't officially support this chipset, however we'll throw a bone to hackintosh users + device_probe.Broadcom.Chipsets.AirPortBrcmNICThirdParty, + ] + ) + + + def native_os(self) -> bool: + """ + Dropped support with macOS 14, Sonoma + """ + return self._xnu_major < os_data.sonoma.value + + + def hardware_variant(self) -> HardwareVariant: + """ + Type of hardware variant + """ + return HardwareVariant.NETWORKING + + + def patches(self) -> dict: + """ + Patches for Modern Wireless + """ + if self.native_os() is True: + return {} + + return { + "Modern Wireless": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/usr/libexec": { + "airportd": "13.6.5", + "wifip2pd": "13.6.5", + }, + "/System/Library/CoreServices": { + **({ "WiFiAgent.app": "14.5" } if self._xnu_major >= os_data.sequoia else {}), + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "CoreWLAN.framework": f"13.6.5-{self._xnu_major}", + }, + "/System/Library/PrivateFrameworks": { + "CoreWiFi.framework": f"13.6.5-{self._xnu_major}", + "IO80211.framework": f"13.6.5-{self._xnu_major}", + "WiFiPeerToPeer.framework": f"13.6.5-{self._xnu_major}", + }, + } + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/amd_opencl.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/amd_opencl.py new file mode 100644 index 000000000..64dbfe82a --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/amd_opencl.py @@ -0,0 +1,41 @@ +""" +amd_opencl.py: AMD OpenCL patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class AMDOpenCL(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major >= os_data.ventura.value + + + def patches(self) -> dict: + """ + In Ventura, Apple added AVX2.0 code to AMD's OpenCL/GL compilers + """ + if self._os_requires_patches() is False: + return {} + + return { + "AMD OpenCL": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "OpenCL.framework": "12.5 non-AVX2.0", + "OpenGL.framework": "12.5 non-AVX2.0", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/amd_terascale.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/amd_terascale.py new file mode 100644 index 000000000..bc2274053 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/amd_terascale.py @@ -0,0 +1,53 @@ +""" +amd_terascale.py: AMD TeraScale patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class AMDTeraScale(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major >= os_data.mojave.value + + + def patches(self) -> dict: + """ + Shared patches between TeraScale 1 and 2 + """ + if self._os_requires_patches() is False: + return {} + + return { + "AMD TeraScale Common": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "AMDFramebuffer.kext": "10.13.6", + "AMDLegacyFramebuffer.kext": "10.13.6", + "AMDLegacySupport.kext": "10.13.6", + "AMDShared.bundle": "10.13.6", + "AMDSupport.kext": "10.13.6", + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions": [ + "AMD7000Controller.kext", + "AMD8000Controller.kext", + "AMD9000Controller.kext", + "AMD9500Controller.kext", + "AMD10000Controller.kext", + ], + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/base.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/base.py new file mode 100644 index 000000000..1ac33f27a --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/base.py @@ -0,0 +1,30 @@ +""" +base.py: Base class for shared patch sets +""" + +from ..base import BasePatchset + + +class BaseSharedPatchSet(BasePatchset): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__() + self._xnu_major = xnu_major + self._xnu_minor = xnu_minor + self._marketing_version = marketing_version + + self._xnu_float = float(f"{self._xnu_major}.{self._xnu_minor}") + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires patches + """ + raise NotImplementedError + + + def patches(self) -> dict: + """ + Dictionary of patches + """ + raise NotImplementedError \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/big_sur_gva.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/big_sur_gva.py new file mode 100644 index 000000000..aa1c750a5 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/big_sur_gva.py @@ -0,0 +1,42 @@ +""" +big_sur_gva.py: Big Sur GVA patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class BigSurGVA(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major >= os_data.monterey.value + + + def patches(self) -> dict: + """ + For GPUs last natively supported in Catalina/Big Sur + Restores DRM support for these GPUs + """ + if self._os_requires_patches() is False: + return {} + + return { + "Big Sur GVA": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks": { + "AppleGVA.framework": "11.7.10", + "AppleGVACore.framework": "11.7.10", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/big_sur_opencl.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/big_sur_opencl.py new file mode 100644 index 000000000..ad33ccb4f --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/big_sur_opencl.py @@ -0,0 +1,40 @@ +""" +big_sur_opencl.py: Big Sur OpenCL patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class BigSurOpenCL(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major >= os_data.monterey.value + + + def patches(self) -> dict: + """ + For graphics cards dropped in Monterey + """ + if self._os_requires_patches() is False: + return {} + + return { + "Big Sur OpenCL": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "OpenCL.framework": "11.6", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/high_sierra_gva.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/high_sierra_gva.py new file mode 100644 index 000000000..b4fd8438e --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/high_sierra_gva.py @@ -0,0 +1,43 @@ +""" +high_sierra_gva.py: High Sierra GVA patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class HighSierraGVA(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Dropped support with macOS 11.0, Big Sur + """ + return self._xnu_major >= os_data.big_sur.value + + + def patches(self) -> dict: + """ + For GPUs last natively supported in High Sierra/Catalina + """ + if self._os_requires_patches() is False: + return {} + + return { + # For GPUs last natively supported in High Sierra/Catalina + # Restores DRM support + "High Sierra GVA": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks": { + "AppleGVA.framework": "10.13.6", + "AppleGVACore.framework": "10.15.7", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/metal_3802.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/metal_3802.py new file mode 100644 index 000000000..b3a43ffa1 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/metal_3802.py @@ -0,0 +1,479 @@ +""" +metal_3802.py: Metal 3802 patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType, DynamicPatchset + +from ....datasets.os_data import os_data + + +class LegacyMetal3802(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major >= os_data.ventura.value + + + def _patches_metal_3802_common(self) -> dict: + """ + Intel Ivy Bridge, Haswell and Nvidia Kepler are Metal 3802-based GPUs + Due to this, we need to re-add 3802 compiler support to the Metal stack + """ + if self._os_requires_patches() is False: + return {} + + return { + "Metal 3802 Common": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Sandbox/Profiles": { + "com.apple.mtlcompilerservice.sb": "12.5-3802", + } + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "Metal.framework": "12.5-3802-22" if self._xnu_major < os_data.sonoma else "12.5-3802-23", + }, + "/System/Library/PrivateFrameworks": { + "MTLCompiler.framework": "12.7.6-3802", + "GPUCompiler.framework": "12.7.6-3802", + }, + } + } + } + + + def _patches_metal_3802_common_extended(self) -> dict: + """ + Support for 3802 GPUs were broken with 13.3+ + Downgrades 31001 stack to 13.2.1, however nukes AMFI support + """ + if self._xnu_float < self.macOS_13_3: + return {} + + return { + "Metal 3802 Common Extended": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "Metal.framework": f"13.2.1-{self._xnu_major}", + **({ "CoreImage.framework": "14.0 Beta 3" if self._xnu_major < os_data.sequoia.value else "14.0 Beta 3-24"} if self._xnu_major >= os_data.sonoma.value else {}), + }, + "/System/Library/PrivateFrameworks": { + **({ "MTLCompiler.framework": "13.2.1" } if self._xnu_major == os_data.ventura.value else {}), + **({ "GPUCompiler.framework": "13.2.1" } if self._xnu_major == os_data.ventura.value else {}), + "RenderBox.framework": "13.2.1-3802" if self._xnu_major == os_data.ventura.value else "14.0-3802", + + # More issues for 3802, now with 14.2 Beta 2+... + # If there is a god, they clearly despise us and legacy Macs. + **({ "MTLCompiler.framework": "14.2 Beta 1" } if self._xnu_float >= self.macOS_14_2 else {}), + **({ "GPUCompiler.framework": "14.2 Beta 1" } if self._xnu_float >= self.macOS_14_2 else {}), + }, + } + } + } + + + def _patches_metal_3802_metallibs(self) -> dict: + """ + With macOS Sequoia, a new .metallib compiler format was introduced (V27) + Thus we need to patch all .metallib files to support 3802 GPUs using MetallibSupportPkg + + Reference: + https://github.com/dortania/MetallibSupportPkg + """ + if self._xnu_major < os_data.sequoia.value: + return {} + + return { + "Metal 3802 .metallibs": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSCore.framework/Versions/A/Resources": { + "default.metallib": "14.6.1", + }, + "/System/Library/Frameworks/MLCompute.framework/Versions/A/Resources": { + "default.metallib": "14.6.1" + }, + "/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/Resources": { + "default.metallib": "14.6.1", + }, + "/System/Library/Frameworks/CoreImage.framework/Versions/A": { + "CoreImage.metallib": "14.6.1", + }, + "/System/Library/Frameworks/CoreImage.framework/Versions/A/Resources": { + "default.metallib": "14.6.1", + "ci_filters.metallib": "14.6.1", + "ci_stdlib_stitchable_h.metallib": "14.6.1", + "ci_stdlib_stitchable.metallib": "14.6.1", + "CIPortraitBlurStitchableV3.metallib": "14.6.1", + "CIPortraitBlurStitchableV2.metallib": "14.6.1", + "ci_stdlib_h.metallib": "14.6.1", + "ci_filters_stitchable.metallib": "14.6.1", + "CIPortraitBlurV2.metallib": "14.6.1", + "CIPortraitBlurV3.metallib": "14.6.1", + "ci_stdlib.metallib": "14.6.1", + }, + "/System/Library/PrivateFrameworks/PhotosUICore.framework/Versions/A/Resources": { + "default.metallib": "14.6.1", + }, + "/System/Library/PrivateFrameworks/Tungsten.framework/Versions/A/Resources": { + "default.metallib": "15.0 Beta 7", + }, + "/System/Library/PrivateFrameworks/RenderBox.framework/Versions/A/Resources": { + "default.metallib": "15.0 Beta 8", + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/VFX.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/VisionKitInternal.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/TSReading.framework/Versions/A/Resources": { + "TSDDefaultMetalLibrary.metallib": DynamicPatchset.MetallibSupportPkg, + "KeynoteMetalLibrary.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/WeatherUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "ForegroundEffectShaders.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/AvatarKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/Tungsten.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/TextInputUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/ActivityRingsUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/ChatKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/WeatherMaps.framework/Versions/A/Resources": { + "WeatherMapsMetalLib.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/HomeAccessoryControlUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/PassKitUIFoundation.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/PrivateFrameworks/MediaCoreUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/Frameworks/ARKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/Frameworks/SpriteKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/Frameworks/PencilKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/Frameworks/SwiftUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/iOSSupport/System/Library/Frameworks/SceneKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Video/Plug-Ins/AppleGVAHEVCEncoder.bundle/Contents/Resources": { + "AppleGVAHEVCFrameStatistics.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Video/Plug-Ins/AV1DecoderSW.bundle/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Video/Plug-Ins/AppleAVEEncoder.bundle/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/CoreServices/MTLReplayer.app/Contents/Frameworks/MTLReplayController.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/CoreImage/CIPassThrough.cifilter/Contents/Resources": { + "CIPassThrough.ci.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/CoreImage/PortraitFilters.cifilter/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "portrait_filters.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/ScreenCaptureKitMetal/ScreenCaptureKitMetal.bundle/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/ExtensionKit/Extensions/Monterey.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/ExtensionKit/Extensions/Drift.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/ExtensionKit/Extensions/WallpaperMacintoshExtension.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/ExtensionKit/Extensions/WallpaperSequoiaExtension.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/SetupAssistantSupportUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/GESS.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VFX.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VisionCore.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/CMImaging.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/CoreRE.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/HDRProcessing.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/AvatarKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/Resources": { + "SkyLightShaders.air64.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/AppleISPEmulator.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/NeutrinoCore.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/ImageHarmonizationKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VideoProcessing.framework/Versions/A/PlugIns/Codecs/VCPRealtimeEncoder.bundle/Contents/Resources": { + "ProcessAccelerate.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VideoProcessing.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "ProcessAccelerate.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Portrait.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VisualGeneration.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "NonMaxLineSuppress.ci.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/AccelerateGPU.framework": { + "GPUBLAS.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/AccelerateGPU.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/ShaderGraph.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Hydra.framework/Plugins/HydraQLThumbnailExtension.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Hydra.framework/Plugins/HydraQLPreviewExtension.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Hydra.framework/Versions/C/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/SiriUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/TextRecognition.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Leonardo.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VectorKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/VectorKit.framework/Versions/A/Resources/metal_libraries": { + "AlloyCommonLibrary.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/GPUToolsCapture.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/PhotoImaging.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/MetalTools.framework/Versions/A/Resources": { + "MTLLegacySVICBSupport.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLGPUDebugICBSupport.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLGPUDebugAccelerationStructureSupport.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLDebugShaders.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLLegacySVAccelerationStructureSupport.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/AppleDepth.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Human.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/CorePhotogrammetry.framework/Versions/A/Resources": { + "ComputerVision_Tess_Kernels.metallib": DynamicPatchset.MetallibSupportPkg, + "Photogrammetry_Matching_Kernels.metallib": DynamicPatchset.MetallibSupportPkg, + "Photogrammetry_Texturing_Kernels.metallib": DynamicPatchset.MetallibSupportPkg, + "Photogrammetry_MVS_Kernels.metallib": DynamicPatchset.MetallibSupportPkg, + "Photogrammetry_Meshing_Kernels.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/HumanUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Quagga.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/Espresso.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/CMPhoto.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/MediaAnalysis.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/AltruisticBodyPoseKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/MusicUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/FRC.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/H13ISPServices.framework/Versions/A/Resources": { + "CalibrateRgbIr.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/SiriUICore.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/PassKitUIFoundation.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/H16ISPServices.framework/Versions/A/Resources": { + "CalibrateRgbIr.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/CoreOCModules.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/PhotosensitivityProcessing.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/PrivateFrameworks/MediaCoreUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/Metal.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLMeshShaderEmulator.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLBVHBuilder.metallib": DynamicPatchset.MetallibSupportPkg, + "MTLECBE.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/QuartzCore.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources/ACD.plugin/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSFunctions.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSRayIntersector.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSNeuralNetwork.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSNDArray.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSImage.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/Frameworks/MPSMatrix.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/MetalFX.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/ParavirtualizedGraphics.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/ImageIO.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/SpriteKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/PencilKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/CoreDisplay.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/SwiftUICore.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/SwiftUI.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/Vision.framework/Versions/A/Resources": { + "ImageFilters.metallib": DynamicPatchset.MetallibSupportPkg, + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/StickerKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/VideoToolbox.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/Frameworks/SceneKit.framework/Versions/A/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Library/VideoProcessors/CCPortrait.bundle/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "CoreImageKernels_only.ci.metallib": DynamicPatchset.MetallibSupportPkg, + "CoreImageKernels.ci.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Applications/Music.app/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Applications/Chess.app/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Applications/Freeform.app/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + "coreimage.metallib": DynamicPatchset.MetallibSupportPkg, + }, + "/System/Applications/Freeform.app/Contents/Extensions/USDRendererExtension.appex/Contents/Resources": { + "default.metallib": DynamicPatchset.MetallibSupportPkg, + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks/RenderBox.framework/Versions/A/Resources": [ + # For some reason Ivy Bridge can't tell the metallib lacks AIR64 support, and errors out + "archive.metallib", + ], + }, + } + } + + + def patches(self) -> dict: + """ + Dictionary of patches + """ + return { + **self._patches_metal_3802_common(), + **self._patches_metal_3802_common_extended(), + **self._patches_metal_3802_metallibs(), + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_gva.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_gva.py new file mode 100644 index 000000000..492003534 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_gva.py @@ -0,0 +1,42 @@ +""" +monterey_gva.py: Monterey GVA patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class MontereyGVA(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major >= os_data.ventura.value + + + def patches(self) -> dict: + """ + For GPUs last natively supported in Monterey + Restores DRM support + """ + if self._os_requires_patches() is False: + return {} + + return { + "Monterey GVA": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/PrivateFrameworks": { + "AppleGVA.framework": "12.5", + "AppleGVACore.framework": "12.5", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_opencl.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_opencl.py new file mode 100644 index 000000000..172c8db11 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_opencl.py @@ -0,0 +1,40 @@ +""" +monterey_opencl.py: Monterey OpenCL patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class MontereyOpenCL(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major >= os_data.ventura.value + + + def patches(self) -> dict: + """ + For graphics cards dropped in Ventura + """ + if self._os_requires_patches() is False: + return {} + + return { + "Monterey OpenCL": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "OpenCL.framework": "12.5", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_webkit.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_webkit.py new file mode 100644 index 000000000..2ad1ef7a8 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/monterey_webkit.py @@ -0,0 +1,47 @@ +""" +monterey_opencl.py: Monterey OpenCL patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class MontereyWebKit(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Check if the current OS requires + """ + return self._xnu_major == os_data.monterey.value + + + def patches(self) -> dict: + """ + Monterey has a WebKit sandboxing issue where many UI elements fail to render + This patch simple replaces the sandbox profile with one supporting our GPUs + Note: Neither Big Sur nor Ventura have this issue + """ + if self._os_requires_patches() is False: + return {} + + return { + "WebKit Monterey Common": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "WebKit.framework": "11.6" + }, + }, + PatchType.MERGE_DATA_VOLUME: { + "/Library/Apple/System/Library/StagedFrameworks/Safari": { + "WebKit.framework": "11.6" + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal.py new file mode 100644 index 000000000..0555b5016 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal.py @@ -0,0 +1,100 @@ +""" +non_metal.py: Non-Metal patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class NonMetal(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major >= os_data.mojave.value + + + def patches(self) -> dict: + """ + General non-Metal GPU patches + """ + if self._os_requires_patches() is False: + return {} + + return { + "Non-Metal Common": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "IOSurface.kext": "10.15.7", + }, + "/System/Applications": { + **({ "Photo Booth.app": "11.7.9"} if self._xnu_major >= os_data.monterey else {}), + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions": [ + "AMDRadeonX4000.kext", + "AMDRadeonX4000HWServices.kext", + "AMDRadeonX5000.kext", + "AMDRadeonX5000HWServices.kext", + "AMDRadeonX6000.kext", + "AMDRadeonX6000Framebuffer.kext", + "AMDRadeonX6000HWServices.kext", + "AppleIntelBDWGraphics.kext", + "AppleIntelBDWGraphicsFramebuffer.kext", + "AppleIntelCFLGraphicsFramebuffer.kext", + "AppleIntelHD4000Graphics.kext", + "AppleIntelHD5000Graphics.kext", + "AppleIntelICLGraphics.kext", + "AppleIntelICLLPGraphicsFramebuffer.kext", + "AppleIntelKBLGraphics.kext", + "AppleIntelKBLGraphicsFramebuffer.kext", + "AppleIntelSKLGraphics.kext", + "AppleIntelSKLGraphicsFramebuffer.kext", + "AppleIntelFramebufferAzul.kext", + "AppleIntelFramebufferCapri.kext", + "AppleParavirtGPU.kext", + "GeForce.kext", + "IOAcceleratorFamily2.kext", + "IOGPUFamily.kext", + "AppleAfterburner.kext", + ], + }, + PatchType.OVERWRITE_DATA_VOLUME: { + "/Library/Application Support/SkyLightPlugins": { + **({ "DropboxHack.dylib": "SkyLightPlugins" } if self._xnu_major >= os_data.monterey else {}), + **({ "DropboxHack.txt": "SkyLightPlugins" } if self._xnu_major >= os_data.monterey else {}), + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "OpenGL.framework": "10.14.3", + "CoreDisplay.framework": f"10.14.4-{self._xnu_major}", + "IOSurface.framework": f"10.15.7-{self._xnu_major}", + "QuartzCore.framework": f"10.15.7-{self._xnu_major}", + }, + "/System/Library/PrivateFrameworks": { + "GPUSupport.framework": "10.14.3", + "SkyLight.framework": f"10.14.6-{self._xnu_major}", + **({"FaceCore.framework": f"13.5"} if self._xnu_major >= os_data.sonoma else {}), + }, + }, + PatchType.EXECUTE: { + # 'When Space Allows' option introduced in 12.4 (XNU 21.5) + **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist ShowDate -int 1": True } if self._xnu_float >= self.macOS_12_4 else {}), + "/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist InternalDebugUseGPUProcessForCanvasRenderingEnabled -bool false": True, + "/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist WebKitExperimentalUseGPUProcessForCanvasRenderingEnabled -bool false": True, + **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist WebKitPreferences.acceleratedDrawingEnabled -bool false": True} if self._xnu_major >= os_data.sonoma else {}), + **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist NSEnableAppKitMenus -bool false": True} if self._xnu_major >= os_data.sonoma else {}), + **({"/usr/bin/defaults write /Library/Preferences/.GlobalPreferences.plist NSZoomButtonShowMenu -bool false": True} if self._xnu_major >= os_data.sonoma else {}), + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_coredisplay.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_coredisplay.py new file mode 100644 index 000000000..9ca498e31 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_coredisplay.py @@ -0,0 +1,40 @@ +""" +non_metal_coredisplay.py: Non-Metal CoreDisplay patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class NonMetalCoreDisplay(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major >= os_data.mojave.value + + + def patches(self) -> dict: + """ + Nvidia Web Drivers require an older build of CoreDisplay + """ + if self._os_requires_patches() is False: + return {} + + return { + "Non-Metal CoreDisplay Common": { + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "CoreDisplay.framework": f"10.13.6-{self._xnu_major}", + }, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_enforcement.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_enforcement.py new file mode 100644 index 000000000..ea77b6ad5 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_enforcement.py @@ -0,0 +1,44 @@ +""" +non_metal_enforcement.py: Non-Metal Enforcement patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class NonMetalEnforcement(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major >= os_data.mojave.value + + + def patches(self) -> dict: + """ + Forces Metal kexts from High Sierra to run in the fallback non-Metal mode + Verified functional with HD4000 and Iris Plus 655 + Only used for internal development purposes, not suitable for end users + + Note: Metal kexts in High Sierra rely on IOAccelerator, thus 'Non-Metal IOAccelerator Common' + is needed for proper linking + """ + if self._os_requires_patches() is False: + return {} + + return { + "Non-Metal Enforcement": { + PatchType.EXECUTE: { + "/usr/bin/defaults write /Library/Preferences/com.apple.CoreDisplay useMetal -boolean no": True, + "/usr/bin/defaults write /Library/Preferences/com.apple.CoreDisplay useIOP -boolean no": True, + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_ioaccel.py b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_ioaccel.py new file mode 100644 index 000000000..8bd4e4f96 --- /dev/null +++ b/opencore_legacy_patcher/sys_patch/patchsets/shared_patches/non_metal_ioaccel.py @@ -0,0 +1,57 @@ +""" +non_metal_ioaccel.py: Non-Metal IOAccelerator patches +""" + +from .base import BaseSharedPatchSet + +from ..base import PatchType + +from ....datasets.os_data import os_data + + +class NonMetalIOAccelerator(BaseSharedPatchSet): + + def __init__(self, xnu_major: int, xnu_minor: int, marketing_version: str) -> None: + super().__init__(xnu_major, xnu_minor, marketing_version) + + + def _os_requires_patches(self) -> bool: + """ + Dropped support with macOS 10.14, Mojave + """ + return self._xnu_major >= os_data.mojave.value + + + def patches(self) -> dict: + """ + TeraScale 2 and Nvidia Web Drivers broke in Mojave due to mismatched structs in + the IOAccelerator stack + """ + if self._os_requires_patches() is False: + return {} + + return { + "Non-Metal IOAccelerator Common": { + PatchType.OVERWRITE_SYSTEM_VOLUME: { + "/System/Library/Extensions": { + "IOAcceleratorFamily2.kext": "10.13.6", + "IOSurface.kext": "10.14.6", + }, + }, + PatchType.MERGE_SYSTEM_VOLUME: { + "/System/Library/Frameworks": { + "IOSurface.framework": f"10.14.6-{self._xnu_major}", + "OpenCL.framework": "10.13.6", + }, + "/System/Library/PrivateFrameworks": { + "GPUSupport.framework": "10.13.6", + "IOAccelerator.framework": f"10.13.6-{self._xnu_major}", + }, + }, + PatchType.REMOVE_SYSTEM_VOLUME: { + "/System/Library/Extensions": [ + "AppleCameraInterface.kext" + ], + }, + }, + } \ No newline at end of file diff --git a/opencore_legacy_patcher/sys_patch/sys_patch.py b/opencore_legacy_patcher/sys_patch/sys_patch.py index 121972728..700b737bd 100644 --- a/opencore_legacy_patcher/sys_patch/sys_patch.py +++ b/opencore_legacy_patcher/sys_patch/sys_patch.py @@ -39,7 +39,8 @@ import logging import plistlib import subprocess -from pathlib import Path +from pathlib import Path +from functools import cache from .mount import ( RootVolumeMount, @@ -54,19 +55,27 @@ from .utilities import ( from .. import constants -from ..datasets import os_data from ..volume import generate_copy_arguments +from ..datasets import ( + os_data +) from ..support import ( utilities, - subprocess_wrapper + subprocess_wrapper, + metallib_handler +) +from .patchsets import ( + HardwarePatchsetDetection, + HardwarePatchsetSettings, + PatchType, + DynamicPatchset ) from . import ( sys_patch_helpers, kernelcache ) from .auto_patcher import InstallAutomaticPatchingServices -from .detections import DetectRootPatch, GenerateRootPatchSets class PatchSysVolume: @@ -80,15 +89,16 @@ class PatchSysVolume: self.patch_set_dictionary = {} self.needs_kmutil_exemptions = False # For '/Library/Extensions' rebuilds self.kdk_path = None + self.metallib_path = None # GUI will detect hardware patches before starting PatchSysVolume() # However the TUI will not, so allow for data to be passed in manually avoiding multiple calls if hardware_details is None: - hardware_details = DetectRootPatch(self.computer.real_model, self.constants).detect_patch_set() + hardware_details = HardwarePatchsetDetection(self.constants).device_properties self.hardware_details = hardware_details self._init_pathing() - self.skip_root_kmutil_requirement = self.hardware_details["Settings: Supports Auxiliary Cache"] + self.skip_root_kmutil_requirement = not self.hardware_details[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED] if self.constants.detected_os >= os_data.os_data.ventura else False self.mount_obj = RootVolumeMount(self.constants.detected_os) @@ -309,13 +319,13 @@ class PatchSysVolume: Write patchset information to Root Volume Parameters: - patchset (dict): Patchset information (generated by GenerateRootPatchSets) + patchset (dict): Patchset information (generated by HardwarePatchsetDetection) """ destination_path = f"{self.mount_location}/System/Library/CoreServices" file_name = "OpenCore-Legacy-Patcher.plist" destination_path_file = f"{destination_path}/{file_name}" - if sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, file_name, self.kdk_path): + if sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, file_name, self.kdk_path, self.metallib_path): logging.info("- Writing patchset information to Root Volume") if Path(destination_path_file).exists(): subprocess_wrapper.run_as_root_and_verify(["/bin/rm", destination_path_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -331,7 +341,7 @@ class PatchSysVolume: if self.patch_set_dictionary != {}: self._execute_patchset(self.patch_set_dictionary) else: - self._execute_patchset(GenerateRootPatchSets(self.computer.real_model, self.constants, self.hardware_details).patchset) + self._execute_patchset(HardwarePatchsetDetection(self.constants).patches) if self.constants.wxpython_variant is True and self.constants.detected_os >= os_data.os_data.big_sur: needs_daemon = False @@ -347,7 +357,7 @@ class PatchSysVolume: Executes provided patchset Parameters: - required_patches (dict): Patchset to execute (generated by sys_patch_generate.GenerateRootPatchSets) + required_patches (dict): Patchset to execute (generated by HardwarePatchsetDetection) """ kc_support_obj = kernelcache.KernelCacheSupport( @@ -357,30 +367,34 @@ class PatchSysVolume: ) source_files_path = str(self.constants.payload_local_binaries_root_path) - self._preflight_checks(required_patches, source_files_path) + required_patches = self._preflight_checks(required_patches, source_files_path) for patch in required_patches: logging.info("- Installing Patchset: " + patch) - for method_remove in ["Remove", "Remove Non-Root"]: + for method_remove in [PatchType.REMOVE_SYSTEM_VOLUME, PatchType.REMOVE_DATA_VOLUME]: if method_remove in required_patches[patch]: for remove_patch_directory in required_patches[patch][method_remove]: logging.info("- Remove Files at: " + remove_patch_directory) for remove_patch_file in required_patches[patch][method_remove][remove_patch_directory]: - if method_remove == "Remove": + if method_remove == PatchType.REMOVE_SYSTEM_VOLUME: destination_folder_path = str(self.mount_location) + remove_patch_directory else: destination_folder_path = str(self.mount_location_data) + remove_patch_directory remove_file(destination_folder_path, remove_patch_file) - for method_install in ["Install", "Install Non-Root"]: + for method_install in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.OVERWRITE_DATA_VOLUME, PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]: if method_install not in required_patches[patch]: continue for install_patch_directory in list(required_patches[patch][method_install]): logging.info(f"- Handling Installs in: {install_patch_directory}") for install_file in list(required_patches[patch][method_install][install_patch_directory]): - source_folder_path = source_files_path + "/" + required_patches[patch][method_install][install_patch_directory][install_file] + install_patch_directory - if method_install == "Install": + source_folder_path = required_patches[patch][method_install][install_patch_directory][install_file] + install_patch_directory + # Check whether to source from root + if not required_patches[patch][method_install][install_patch_directory][install_file].startswith("/"): + source_folder_path = source_files_path + "/" + source_folder_path + + if method_install in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.MERGE_SYSTEM_VOLUME]: destination_folder_path = str(self.mount_location) + install_patch_directory else: if install_patch_directory == "/Library/Extensions": @@ -404,13 +418,13 @@ class PatchSysVolume: destination_folder_path = updated_destination_folder_path - install_new_file(source_folder_path, destination_folder_path, install_file) + install_new_file(source_folder_path, destination_folder_path, install_file, method_install) - if "Processes" in required_patches[patch]: - for process in required_patches[patch]["Processes"]: + if PatchType.EXECUTE in required_patches[patch]: + for process in required_patches[patch][PatchType.EXECUTE]: # Some processes need sudo, however we cannot directly call sudo in some scenarios # Instead, call elevated funtion if string's boolean is True - if required_patches[patch]["Processes"][process] is True: + if required_patches[patch][PatchType.EXECUTE][process] is True: logging.info(f"- Running Process as Root:\n{process}") subprocess_wrapper.run_as_root_and_verify(process.split(" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) else: @@ -425,21 +439,88 @@ class PatchSysVolume: self._write_patchset(required_patches) - def _preflight_checks(self, required_patches: dict, source_files_path: Path) -> None: + def _resolve_metallib_support_pkg(self) -> str: + """ + Resolves MetalLibSupportPkg + """ + metallib_obj = metallib_handler.MetalLibraryObject(self.constants, self.constants.detected_os_build, self.constants.detected_os_version) + if metallib_obj.success is False: + logging.error(f"Failed to find MetalLibSupportPkg: {metallib_obj.error_msg}") + raise Exception(f"Failed to find MetalLibSupportPkg: {metallib_obj.error_msg}") + + metallib_download_obj = metallib_obj.retrieve_download() + if not metallib_download_obj: + # Already downloaded, return path + logging.info(f"Using MetalLibSupportPkg: {metallib_obj.metallib_installed_path}") + self.metallib_path = metallib_obj.metallib_installed_path + return str(metallib_obj.metallib_installed_path) + + metallib_download_obj.download(spawn_thread=False) + if metallib_download_obj.download_complete is False: + error_msg = metallib_download_obj.error_msg + logging.error(f"Could not download MetalLibSupportPkg: {error_msg}") + raise Exception(f"Could not download MetalLibSupportPkg: {error_msg}") + + if metallib_obj.install_metallib() is False: + logging.error("Failed to install MetalLibSupportPkg") + raise Exception("Failed to install MetalLibSupportPkg") + + # After install, check if it's present + return self._resolve_metallib_support_pkg() + + + @cache + def _resolve_dynamic_patchset(self, variant: DynamicPatchset) -> str: + """ + Resolves dynamic patchset to a path + """ + if variant == DynamicPatchset.MetallibSupportPkg: + return self._resolve_metallib_support_pkg() + + raise Exception(f"Unknown Dynamic Patchset: {variant}") + + + def _preflight_checks(self, required_patches: dict, source_files_path: Path) -> dict: """ Runs preflight checks before patching Parameters: - required_patches (dict): Patchset dictionary (from sys_patch_generate.GenerateRootPatchSets) + required_patches (dict): Patchset dictionary (from HardwarePatchsetDetection) source_files_path (Path): Path to the source files (PatcherSupportPkg) + + Returns: + dict: Updated patchset dictionary """ logging.info("- Running Preflight Checks before patching") + for patch in required_patches: + # Check if all files are present + for method_type in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.OVERWRITE_DATA_VOLUME, PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]: + if method_type not in required_patches[patch]: + continue + for install_patch_directory in required_patches[patch][method_type]: + for install_file in required_patches[patch][method_type][install_patch_directory]: + try: + if required_patches[patch][method_type][install_patch_directory][install_file] in DynamicPatchset: + required_patches[patch][method_type][install_patch_directory][install_file] = self._resolve_dynamic_patchset(required_patches[patch][method_type][install_patch_directory][install_file]) + except TypeError: + pass + + source_file = required_patches[patch][method_type][install_patch_directory][install_file] + install_patch_directory + "/" + install_file + + # Check whether to source from root + if not required_patches[patch][method_type][install_patch_directory][install_file].startswith("/"): + source_file = source_files_path + "/" + source_file + if not Path(source_file).exists(): + raise Exception(f"Failed to find {source_file}") + # Make sure old SkyLight plugins aren't being used self._clean_skylight_plugins() + # Make sure non-Metal Enforcement preferences are not present self._delete_nonmetal_enforcement() + # Make sure we clean old kexts in /L*/E* that are not in the patchset kernelcache.KernelCacheSupport( mount_location_data=self.mount_location_data, @@ -451,22 +532,13 @@ class PatchSysVolume: if "Intel Sandy Bridge" in required_patches: sys_patch_helpers.SysPatchHelpers(self.constants).snb_board_id_patch(source_files_path) - for patch in required_patches: - # Check if all files are present - for method_type in ["Install", "Install Non-Root"]: - if method_type not in required_patches[patch]: - continue - for install_patch_directory in required_patches[patch][method_type]: - for install_file in required_patches[patch][method_type][install_patch_directory]: - source_file = source_files_path + "/" + required_patches[patch][method_type][install_patch_directory][install_file] + install_patch_directory + "/" + install_file - if not Path(source_file).exists(): - raise Exception(f"Failed to find {source_file}") - # Ensure KDK is properly installed self._merge_kdk_with_root(save_hid_cs=True if "Legacy USB 1.1" in required_patches else False) logging.info("- Finished Preflight, starting patching") + return required_patches + # Entry Function def start_patch(self): @@ -476,15 +548,17 @@ class PatchSysVolume: logging.info("- Starting Patch Process") logging.info(f"- Determining Required Patch set for Darwin {self.constants.detected_os}") - self.patch_set_dictionary = GenerateRootPatchSets(self.computer.real_model, self.constants, self.hardware_details).patchset + patchset_obj = HardwarePatchsetDetection(self.constants) + self.patch_set_dictionary = patchset_obj.patches if self.patch_set_dictionary == {}: logging.info("- No Root Patches required for your machine!") return logging.info("- Verifying whether Root Patching possible") - if DetectRootPatch(self.computer.real_model, self.constants).verify_patch_allowed(print_errors=not self.constants.wxpython_variant) is False: + if patchset_obj.can_patch is False: logging.error("- Cannot continue with patching!!!") + patchset_obj.detailed_errors() return logging.info("- Patcher is capable of patching") @@ -511,8 +585,10 @@ class PatchSysVolume: """ logging.info("- Starting Unpatch Process") - if DetectRootPatch(self.computer.real_model, self.constants).verify_patch_allowed(print_errors=True) is False: + patchset_obj = HardwarePatchsetDetection(self.constants) + if patchset_obj.can_unpatch is False: logging.error("- Cannot continue with unpatching!!!") + patchset_obj.detailed_errors() return if self._mount_root_vol() is False: diff --git a/opencore_legacy_patcher/sys_patch/sys_patch_helpers.py b/opencore_legacy_patcher/sys_patch/sys_patch_helpers.py index 3774f7065..e4c153e11 100644 --- a/opencore_legacy_patcher/sys_patch/sys_patch_helpers.py +++ b/opencore_legacy_patcher/sys_patch/sys_patch_helpers.py @@ -77,12 +77,12 @@ class SysPatchHelpers: f.write(data) - def generate_patchset_plist(self, patchset: dict, file_name: str, kdk_used: Path): + def generate_patchset_plist(self, patchset: dict, file_name: str, kdk_used: Path, metallib_used: Path): """ Generate patchset file for user reference Parameters: - patchset (dict): Dictionary of patchset, see detect.py and sys_patch_dict.py + patchset (dict): Dictionary of patchset, sys_patch/patchsets file_name (str): Name of the file to write to kdk_used (Path): Path to the KDK used, if any @@ -98,12 +98,17 @@ class SysPatchHelpers: if kdk_used: kdk_string = kdk_used + metallib_used_string = "Not applicable" + if metallib_used: + metallib_used_string = metallib_used + data = { "OpenCore Legacy Patcher": f"v{self.constants.patcher_version}", "PatcherSupportPkg": f"v{self.constants.patcher_support_pkg_version}", "Time Patched": f"{datetime.now().strftime('%B %d, %Y @ %H:%M:%S')}", "Commit URL": f"{self.constants.commit_info[2]}", "Kernel Debug Kit Used": f"{kdk_string}", + "Metal Library Used": f"{metallib_used_string}", "OS Version": f"{self.constants.detected_os}.{self.constants.detected_os_minor} ({self.constants.detected_os_build})", "Custom Signature": bool(Path(self.constants.payload_local_binaries_root_path / ".signed").exists()), } @@ -212,6 +217,10 @@ class SysPatchHelpers: return BASE_VERSION = "32023" GPU_VERSION = f"{BASE_VERSION}.26" + else: + # Fall back for newer versions + BASE_VERSION = "32023" + GPU_VERSION = f"{BASE_VERSION}.26" LIBRARY_DIR = f"{mount_point}/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/{BASE_VERSION}/Libraries/lib/clang" DEST_DIR = f"{LIBRARY_DIR}/{GPU_VERSION}" diff --git a/opencore_legacy_patcher/sys_patch/utilities/dmg_mount.py b/opencore_legacy_patcher/sys_patch/utilities/dmg_mount.py index 108737bcf..8460f0286 100644 --- a/opencore_legacy_patcher/sys_patch/utilities/dmg_mount.py +++ b/opencore_legacy_patcher/sys_patch/utilities/dmg_mount.py @@ -81,6 +81,8 @@ class PatcherSupportPkgMount: if i == 2: self._display_too_many_attempts() return False + continue + break logging.info("- Mounted DortaniaInternal resources") return self._merge_dortania_internal_resources() @@ -114,7 +116,7 @@ class PatcherSupportPkgMount: return Path("~/.dortania_developer_key").expanduser().read_text().strip() password = "" - msg = "Welcome to the DortaniaInternal Program, please provided the decryption key to access internal resources. Press cancel to skip." + msg = "Welcome to the DortaniaInternal Program, please provide the decryption key to access internal resources. Press cancel to skip." if attempt > 0: msg = f"Decryption failed, please try again. {2 - attempt} attempts remaining. " diff --git a/opencore_legacy_patcher/sys_patch/utilities/files.py b/opencore_legacy_patcher/sys_patch/utilities/files.py index 5ef11ff36..c962ad48f 100644 --- a/opencore_legacy_patcher/sys_patch/utilities/files.py +++ b/opencore_legacy_patcher/sys_patch/utilities/files.py @@ -7,17 +7,19 @@ import subprocess from pathlib import Path +from ..patchsets.base import PatchType + from ...volume import generate_copy_arguments from ...support import subprocess_wrapper -def install_new_file(source_folder: Path, destination_folder: Path, file_name: str) -> None: +def install_new_file(source_folder: Path, destination_folder: Path, file_name: str, method: PatchType) -> None: """ Installs a new file to the destination folder File handling logic: - - .frameworks are merged with the destination folder - - Other files are deleted and replaced (ex. .kexts, .apps) + - PatchType.MERGE_* are merged with the destination folder + - Other files are deleted and replaced Parameters: source_folder (Path): Path to the source folder @@ -31,7 +33,7 @@ def install_new_file(source_folder: Path, destination_folder: Path, file_name: s logging.info(f" - Skipping {file_name}, cannot locate {source_folder}") return - if file_name_str.endswith(".framework"): + if method in [PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]: # merge with rsync logging.info(f" - Installing: {file_name}") subprocess_wrapper.run_as_root(["/usr/bin/rsync", "-r", "-i", "-a", f"{source_folder}/{file_name}", f"{destination_folder}/"], stdout=subprocess.PIPE) diff --git a/opencore_legacy_patcher/wx_gui/gui_cache_os_update.py b/opencore_legacy_patcher/wx_gui/gui_cache_os_update.py index 1f3f0e39d..5f6db193c 100644 --- a/opencore_legacy_patcher/wx_gui/gui_cache_os_update.py +++ b/opencore_legacy_patcher/wx_gui/gui_cache_os_update.py @@ -12,9 +12,11 @@ import threading from pathlib import Path from .. import constants -from ..support import kdk_handler, utilities +from ..support import kdk_handler, utilities, metallib_handler from ..wx_gui import gui_support, gui_download +from ..sys_patch.patchsets import HardwarePatchsetDetection, HardwarePatchsetSettings + class OSUpdateFrame(wx.Frame): """ @@ -40,29 +42,68 @@ class OSUpdateFrame(wx.Frame): logging.info(f"Staged update found: {os_data[0]} ({os_data[1]})") self.os_data = os_data + # Check if we need to patch the system volume + results = HardwarePatchsetDetection( + constants=self.constants, + xnu_major=int(self.os_data[1][:2]), + xnu_minor=0, # We can't determine this from the build number + os_build=self.os_data[1], + os_version=self.os_data[0], + ).device_properties + + if results[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED] is True: + logging.info("KDK required") + if results[HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_REQUIRED] is True: + # TODO: Download MetalLibSupportPkg + logging.info("MetallibSupportPkg required") + + if not any([results[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED], results[HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_REQUIRED]]): + logging.info("No additional resources required") + self._exit() + self._generate_ui() self.kdk_obj: kdk_handler.KernelDebugKitObject = None def _kdk_thread_spawn(): self.kdk_obj = kdk_handler.KernelDebugKitObject(self.constants, self.os_data[1], self.os_data[0], passive=True, check_backups_only=True) - kdk_thread = threading.Thread(target=_kdk_thread_spawn) - kdk_thread.start() - while kdk_thread.is_alive(): - wx.Yield() + self.metallib_obj: metallib_handler.MetalLibraryObject = None + def _metallib_thread_spawn(): + self.metallib_obj = metallib_handler.MetalLibraryObject(self.constants, self.os_data[1], self.os_data[0]) - if self.kdk_obj.success is False: + + if results[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED] is True: + kdk_thread = threading.Thread(target=_kdk_thread_spawn) + kdk_thread.start() + while kdk_thread.is_alive(): + wx.Yield() + if results[HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_REQUIRED] is True: + metallib_thread = threading.Thread(target=_metallib_thread_spawn) + metallib_thread.start() + while metallib_thread.is_alive(): + wx.Yield() + + + download_objects = { + # Name: xxx + # download_obj: xxx + } + + if self.kdk_obj: + if self.kdk_obj.success is True: + result = self.kdk_obj.retrieve_download() + if result is not None: + download_objects[f"KDK Build {self.kdk_obj.kdk_url_build}"] = result + if self.metallib_obj: + if self.metallib_obj.success is True: + result = self.metallib_obj.retrieve_download() + if result is not None: + download_objects[f"Metallib Build {self.metallib_obj.metallib_url_build}"] = result + + if len(download_objects) == 0: self._exit() - kdk_download_obj = self.kdk_obj.retrieve_download() - if not kdk_download_obj: - # KDK is already downloaded - # Return false since we didn't display anything - self._exit() - - self.kdk_download_obj = kdk_download_obj - self.frame.Show() self.did_cancel = -1 @@ -76,20 +117,34 @@ class OSUpdateFrame(wx.Frame): if self.did_cancel == -1: time.sleep(1) - gui_download.DownloadFrame( - self, - title=self.title, - global_constants=self.constants, - download_obj=kdk_download_obj, - item_name=f"KDK Build {self.kdk_obj.kdk_url_build}" - ) - if kdk_download_obj.download_complete is False: - self._exit() + for item in download_objects: + name = item + download_obj = download_objects[item] + self.download_obj = download_obj + gui_download.DownloadFrame( + self, + title=self.title, + global_constants=self.constants, + download_obj=download_obj, + item_name=name + ) + if download_obj.download_complete is True: + if item.startswith("KDK"): + self._handle_kdk(self.kdk_obj) + if item.startswith("Metallib"): + self._handle_metallib(self.metallib_obj) + self._exit() + + + def _handle_kdk(self, kdk_obj: kdk_handler.KernelDebugKitObject) -> None: + """ + Handle KDK installation + """ logging.info("KDK download complete, validating with hdiutil") self.kdk_checksum_result = False def _validate_kdk_checksum_thread(): - self.kdk_checksum_result = self.kdk_obj.validate_kdk_checksum() + self.kdk_checksum_result = kdk_obj.validate_kdk_checksum() kdk_checksum_thread = threading.Thread(target=_validate_kdk_checksum_thread) kdk_checksum_thread.start() @@ -99,15 +154,16 @@ class OSUpdateFrame(wx.Frame): if self.kdk_checksum_result is False: logging.error("KDK checksum validation failed") - logging.error(self.kdk_obj.error_msg) + logging.error(kdk_obj.error_msg) self._exit() + logging.info("KDK checksum validation passed") logging.info("Mounting KDK") if not Path(self.constants.kdk_download_path).exists(): logging.error("KDK download path does not exist") - self._exit() + return self.kdk_install_result = False def _install_kdk_thread(): @@ -121,10 +177,31 @@ class OSUpdateFrame(wx.Frame): if self.kdk_install_result is False: logging.info("Failed to install KDK") - self._exit() + return logging.info("KDK installed successfully") - self._exit() + + + + def _handle_metallib(self, metallib_obj: metallib_handler.MetalLibraryObject) -> None: + """ + Handle Metallib installation + """ + self.metallib_install_result = False + def _install_metallib_thread(): + self.metallib_install_result = metallib_obj.install_metallib() + + metallib_install_thread = threading.Thread(target=_install_metallib_thread) + metallib_install_thread.start() + + while metallib_install_thread.is_alive(): + wx.Yield() + + if self.metallib_install_result is False: + logging.info("Failed to install Metallib") + return + + logging.info("Metallib installed successfully") def _generate_ui(self) -> None: @@ -179,7 +256,8 @@ class OSUpdateFrame(wx.Frame): result = dlg.ShowModal() if result == wx.ID_NO: logging.info("User cancelled OS caching") - self.kdk_download_obj.stop() + if hasattr(self, "download_obj"): + self.download_obj.stop() self.did_cancel = 1 else: self.did_cancel = 0 diff --git a/opencore_legacy_patcher/wx_gui/gui_entry.py b/opencore_legacy_patcher/wx_gui/gui_entry.py index 1fc644092..cf5f37156 100644 --- a/opencore_legacy_patcher/wx_gui/gui_entry.py +++ b/opencore_legacy_patcher/wx_gui/gui_entry.py @@ -12,7 +12,7 @@ from Cocoa import NSApp, NSApplication from .. import constants -from ..sys_patch.detections import DetectRootPatch +from ..sys_patch.patchsets import HardwarePatchsetDetection from ..wx_gui import ( gui_cache_os_update, @@ -64,7 +64,7 @@ class EntryPoint: if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv or start_patching is True : entry = gui_sys_patch_start.SysPatchStartFrame - patches = DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set() + patches = HardwarePatchsetDetection(constants=self.constants).device_properties logging.info(f"Entry point set: {entry.__name__}") diff --git a/opencore_legacy_patcher/wx_gui/gui_macos_installer_flash.py b/opencore_legacy_patcher/wx_gui/gui_macos_installer_flash.py index b3fe856fc..e25923c05 100644 --- a/opencore_legacy_patcher/wx_gui/gui_macos_installer_flash.py +++ b/opencore_legacy_patcher/wx_gui/gui_macos_installer_flash.py @@ -27,6 +27,7 @@ from ..support import ( utilities, network_handler, kdk_handler, + metallib_handler, subprocess_wrapper ) @@ -463,6 +464,8 @@ class macOSInstallerFlashFrame(wx.Frame): subprocess.run(["/bin/mkdir", "-p", f"{path}/Library/Packages/"]) subprocess.run(generate_copy_arguments(self.constants.installer_pkg_path, f"{path}/Library/Packages/")) + # Chainload KDK and Metallib + self._chainload_metallib(os_version["ProductBuildVersion"], os_version["ProductVersion"], Path(path + "/Library/Packages/")) self._kdk_chainload(os_version["ProductBuildVersion"], os_version["ProductVersion"], Path(path + "/Library/Packages/")) @@ -543,6 +546,51 @@ class macOSInstallerFlashFrame(wx.Frame): logging.info("Removing KDK Disk Image") kdk_dmg_path.unlink() + + def _chainload_metallib(self, build: str, version: str, download_dir: str): + """ + Download the correct Metallib to be chainloaded in the macOS installer + """ + + metallib_pkg_path = Path(download_dir) / "MetallibSupportPkg.pkg" + + if metallib_pkg_path.exists(): + metallib_pkg_path.unlink() + + logging.info("Initiating Metallib download") + logging.info(f"- Build: {build}") + logging.info(f"- Version: {version}") + logging.info(f"- Working Directory: {download_dir}") + + metallib_obj = metallib_handler.MetalLibraryObject(self.constants, build, version, ignore_installed=True) + if metallib_obj.success is False: + logging.info("Failed to retrieve Metallib") + logging.info(metallib_obj.error_msg) + return + + metallib_download_obj = metallib_obj.retrieve_download(override_path=metallib_pkg_path) + if metallib_download_obj is None: + logging.info("Failed to retrieve Metallib") + logging.info(metallib_obj.error_msg) + + # Check remaining disk space before downloading + space = utilities.get_free_space(download_dir) + size = 100 * 1024 * 1024 + if space < size: + logging.info("Not enough disk space to download and install Metallib") + return + + metallib_download_obj.download(spawn_thread=False) + if metallib_download_obj.download_complete is False: + logging.info("Failed to download Metallib") + logging.info(metallib_download_obj.error_msg) + return + + if not metallib_pkg_path.exists(): + logging.info(f"Metallib missing: {metallib_pkg_path}") + return + + def _validate_installer_pkg(self, disk: str) -> bool: logging.info("Validating installer pkg") error_message = "" diff --git a/opencore_legacy_patcher/wx_gui/gui_sys_patch_display.py b/opencore_legacy_patcher/wx_gui/gui_sys_patch_display.py index 884e35e1f..747e5f60b 100644 --- a/opencore_legacy_patcher/wx_gui/gui_sys_patch_display.py +++ b/opencore_legacy_patcher/wx_gui/gui_sys_patch_display.py @@ -11,7 +11,7 @@ from pathlib import Path from .. import constants -from ..sys_patch.detections import DetectRootPatch +from ..sys_patch.patchsets import HardwarePatchsetDetection, HardwarePatchsetValidation from ..wx_gui import ( gui_main_menu, @@ -86,7 +86,7 @@ class SysPatchDisplayFrame(wx.Frame): patches: dict = {} def _fetch_patches(self) -> None: nonlocal patches - patches = DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set() + patches = HardwarePatchsetDetection(constants=self.constants).device_properties thread = threading.Thread(target=_fetch_patches, args=(self,)) thread.start() @@ -106,7 +106,7 @@ class SysPatchDisplayFrame(wx.Frame): available_label.Centre(wx.HORIZONTAL) - can_unpatch: bool = patches["Validation: Unpatching Possible"] + can_unpatch: bool = not patches[HardwarePatchsetValidation.UNPATCHING_NOT_POSSIBLE] if not any(not patch.startswith("Settings") and not patch.startswith("Validation") and patches[patch] is True for patch in patches): logging.info("No applicable patches available") @@ -152,7 +152,7 @@ class SysPatchDisplayFrame(wx.Frame): patch_label.SetLabel(patch_label.GetLabel().replace("-", "")) patch_label.Centre(wx.HORIZONTAL) - if patches["Validation: Patching Possible"] is False: + if patches[HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE] is True: # Cannot patch due to the following reasons: patch_label = wx.StaticText(frame, label="Cannot patch due to the following reasons:", pos=(-1, patch_label.GetPosition()[1] + 25)) patch_label.SetFont(gui_support.font_factory(13, wx.FONTWEIGHT_BOLD)) @@ -164,7 +164,7 @@ class SysPatchDisplayFrame(wx.Frame): continue if patches[patch] is False: continue - if patch == "Validation: Unpatching Possible": + if patch in [HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE, HardwarePatchsetValidation.UNPATCHING_NOT_POSSIBLE]: continue if len(patch) > len(longest_patch): @@ -180,7 +180,7 @@ class SysPatchDisplayFrame(wx.Frame): continue if patches[patch] is False: continue - if patch == "Validation: Unpatching Possible": + if patch in [HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE, HardwarePatchsetValidation.UNPATCHING_NOT_POSSIBLE]: continue patch_label = wx.StaticText(frame, label=f"- {patch.split('Validation: ')[1]}", pos=(anchor.GetPosition()[0], anchor.GetPosition()[1] + i)) @@ -231,7 +231,7 @@ class SysPatchDisplayFrame(wx.Frame): start_button.Disable() else: self.available_patches = True - if patches["Validation: Patching Possible"] is False: + if patches[HardwarePatchsetValidation.PATCHING_NOT_POSSIBLE] is True: start_button.Disable() elif no_new_patches is False: start_button.SetDefault() @@ -320,18 +320,8 @@ class SysPatchDisplayFrame(wx.Frame): for patch in patches: if (not patch.startswith("Settings") and not patch.startswith("Validation") and patches[patch] is True): # Patches should share the same name as the plist key - # See sys_patch_dict.py for more info - patch_installed = False - for key in oclp_plist_data: - if isinstance(oclp_plist_data[key], (bool, int)): - continue - if "Display Name" not in oclp_plist_data[key]: - continue - if oclp_plist_data[key]["Display Name"] == patch: - patch_installed = True - break - - if patch_installed is False: + # See sys_patch/patchsets/base.py for more info + if patch.split(": ")[1] not in oclp_plist_data: logging.info(f"- Patch {patch} not installed") return True diff --git a/opencore_legacy_patcher/wx_gui/gui_sys_patch_start.py b/opencore_legacy_patcher/wx_gui/gui_sys_patch_start.py index 8f4afa434..75d1695ea 100644 --- a/opencore_legacy_patcher/wx_gui/gui_sys_patch_start.py +++ b/opencore_legacy_patcher/wx_gui/gui_sys_patch_start.py @@ -16,8 +16,11 @@ from pathlib import Path from .. import constants from ..datasets import os_data -from ..support import kdk_handler +from ..support import ( + kdk_handler, + metallib_handler +) from ..sys_patch import ( sys_patch, ) @@ -27,7 +30,7 @@ from ..wx_gui import ( gui_download, ) -from ..sys_patch.detections import DetectRootPatch +from ..sys_patch.patchsets import HardwarePatchsetDetection, HardwarePatchsetSettings @@ -51,7 +54,7 @@ class SysPatchStartFrame(wx.Frame): self.Centre() if self.patches == {}: - self.patches = DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set() + self.patches = HardwarePatchsetDetection(constants=self.constants).device_properties def _kdk_download(self, frame: wx.Frame = None) -> bool: @@ -137,6 +140,95 @@ class SysPatchStartFrame(wx.Frame): return True + def _metallib_download(self, frame: wx.Frame = None) -> bool: + frame = self if not frame else frame + + logging.info("MetallibSupportPkg missing, generating Metallib download frame") + + header = wx.StaticText(frame, label="Downloading Metal Libraries", pos=(-1,5)) + header.SetFont(gui_support.font_factory(19, wx.FONTWEIGHT_BOLD)) + header.Centre(wx.HORIZONTAL) + + subheader = wx.StaticText(frame, label="Fetching MetallibSupportPkg database...", pos=(-1, header.GetPosition()[1] + header.GetSize()[1] + 5)) + subheader.SetFont(gui_support.font_factory(13, wx.FONTWEIGHT_NORMAL)) + subheader.Centre(wx.HORIZONTAL) + + progress_bar = wx.Gauge(frame, range=100, pos=(-1, subheader.GetPosition()[1] + subheader.GetSize()[1] + 5), size=(250, 20)) + progress_bar.Centre(wx.HORIZONTAL) + + progress_bar_animation = gui_support.GaugePulseCallback(self.constants, progress_bar) + progress_bar_animation.start_pulse() + + # Set size of frame + frame.SetSize((-1, progress_bar.GetPosition()[1] + progress_bar.GetSize()[1] + 35)) + frame.Show() + + self.metallib_obj: metallib_handler.MetalLibraryObject = None + def _metallib_thread_spawn(): + self.metallib_obj = metallib_handler.MetalLibraryObject(self.constants, self.constants.detected_os_build, self.constants.detected_os_version) + + metallib_thread = threading.Thread(target=_metallib_thread_spawn) + metallib_thread.start() + + while metallib_thread.is_alive(): + wx.Yield() + + if self.metallib_obj.success is False: + progress_bar_animation.stop_pulse() + progress_bar.SetValue(0) + wx.MessageBox(f"Metallib download failed: {self.metallib_obj.error_msg}", "Error", wx.OK | wx.ICON_ERROR) + return False + + self.metallib_download_obj = self.metallib_obj.retrieve_download() + if not self.metallib_download_obj: + # Metallib is already downloaded + return True + + gui_download.DownloadFrame( + self, + title=self.title, + global_constants=self.constants, + download_obj=self.metallib_download_obj, + item_name=f"Metallib Build {self.metallib_obj.metallib_url_build}" + ) + if self.metallib_download_obj.download_complete is False: + return False + + logging.info("Metallib download complete, installing Metallib PKG") + + header.SetLabel(f"Installing Metallib: {self.metallib_obj.metallib_url_build}") + header.Centre(wx.HORIZONTAL) + + subheader.SetLabel("Installing MetallibSupportPkg PKG...") + subheader.Centre(wx.HORIZONTAL) + + self.result = False + def _install_metallib(): + self.result = self.metallib_obj.install_metallib() + + install_thread = threading.Thread(target=_install_metallib) + install_thread.start() + + while install_thread.is_alive(): + wx.Yield() + + if self.result is False: + progress_bar_animation.stop_pulse() + progress_bar.SetValue(0) + wx.MessageBox(f"Metallib installation failed: {self.metallib_obj.error_msg}", "Error", wx.OK | wx.ICON_ERROR) + return False + + progress_bar_animation.stop_pulse() + progress_bar.SetValue(100) + + logging.info("Metallib installation complete") + + for child in frame.GetChildren(): + child.Destroy() + + return True + + def _generate_modal(self, patches: dict = {}, variant: str = "Root Patching"): """ Create UI for root patching/unpatching @@ -223,10 +315,14 @@ class SysPatchStartFrame(wx.Frame): while gui_support.PayloadMount(self.constants, self).is_unpack_finished() is False: wx.Yield() - if self.patches["Settings: Kernel Debug Kit missing"] is True: + if self.patches[HardwarePatchsetSettings.KERNEL_DEBUG_KIT_REQUIRED] is True: if self._kdk_download(self) is False: sys.exit(1) + if self.patches[HardwarePatchsetSettings.METALLIB_SUPPORT_PKG_REQUIRED] is True: + if self._metallib_download(self) is False: + sys.exit(1) + self._generate_modal(self.patches, "Root Patching") self.return_button.Disable() @@ -363,18 +459,8 @@ class SysPatchStartFrame(wx.Frame): for patch in patches: if (not patch.startswith("Settings") and not patch.startswith("Validation") and patches[patch] is True): # Patches should share the same name as the plist key - # See sys_patch_dict.py for more info - patch_installed = False - for key in oclp_plist_data: - if isinstance(oclp_plist_data[key], (bool, int)): - continue - if "Display Name" not in oclp_plist_data[key]: - continue - if oclp_plist_data[key]["Display Name"] == patch: - patch_installed = True - break - - if patch_installed is False: + # See sys_patch/patchsets/base.py for more info + if patch.split(": ")[1] not in oclp_plist_data: logging.info(f"- Patch {patch} not installed") return True diff --git a/payloads/Config/config.plist b/payloads/Config/config.plist index 005812531..5e9316a21 100644 --- a/payloads/Config/config.plist +++ b/payloads/Config/config.plist @@ -1373,6 +1373,24 @@ PlistPath Contents/Info.plist + + Arch + x86_64 + BundlePath + AppleTopCaseInjector.kext + Comment + AppleTopCaseInjector - SPI + Enabled + + ExecutablePath + + MaxKernel + + MinKernel + 24.0.0 + PlistPath + Contents/Info.plist + Arch x86_64 @@ -1733,6 +1751,24 @@ PlistPath Contents/Info.plist + + Arch + x86_64 + Comment + KernelRelayHost - T1 Communication + Enabled + + MaxKernel + + MinKernel + 24.0.0 + BundlePath + KernelRelayHost.kext + ExecutablePath + Contents/MacOS/KernelRelayHost + PlistPath + Contents/Info.plist + Arch x86_64 diff --git a/payloads/Icon/AppIcons/Sequoia.icns b/payloads/Icon/AppIcons/Sequoia.icns new file mode 100644 index 000000000..5268da5e3 Binary files /dev/null and b/payloads/Icon/AppIcons/Sequoia.icns differ diff --git a/payloads/Icon/Resources.zip b/payloads/Icon/Resources.zip index 65b037585..98143353d 100644 Binary files a/payloads/Icon/Resources.zip and b/payloads/Icon/Resources.zip differ diff --git a/payloads/Kexts/Acidanthera/AMFIPass-v1.3.1-RELEASE.zip b/payloads/Kexts/Acidanthera/AMFIPass-v1.3.1-RELEASE.zip deleted file mode 100644 index 06a04afcf..000000000 Binary files a/payloads/Kexts/Acidanthera/AMFIPass-v1.3.1-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/AMFIPass-v1.4.0-RELEASE.zip b/payloads/Kexts/Acidanthera/AMFIPass-v1.4.0-RELEASE.zip deleted file mode 100644 index eb1ea3872..000000000 Binary files a/payloads/Kexts/Acidanthera/AMFIPass-v1.4.0-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/AMFIPass-v1.4.1-RELEASE.zip b/payloads/Kexts/Acidanthera/AMFIPass-v1.4.1-RELEASE.zip new file mode 100644 index 000000000..b42fe05c3 Binary files /dev/null and b/payloads/Kexts/Acidanthera/AMFIPass-v1.4.1-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.3-DEBUG.zip b/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.3-DEBUG.zip deleted file mode 100644 index 513a7f514..000000000 Binary files a/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.3-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.3-RELEASE.zip b/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.3-RELEASE.zip deleted file mode 100644 index ab225ede8..000000000 Binary files a/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.3-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.4-DEBUG.zip b/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.4-DEBUG.zip new file mode 100644 index 000000000..d74a26e9c Binary files /dev/null and b/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.4-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.4-RELEASE.zip b/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.4-RELEASE.zip new file mode 100644 index 000000000..527ef4c00 Binary files /dev/null and b/payloads/Kexts/Acidanthera/AutoPkgInstaller-v1.0.4-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/CPUFriend-v1.2.7-DEBUG.zip b/payloads/Kexts/Acidanthera/CPUFriend-v1.2.7-DEBUG.zip deleted file mode 100644 index e8e3313ad..000000000 Binary files a/payloads/Kexts/Acidanthera/CPUFriend-v1.2.7-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/CPUFriend-v1.2.7-RELEASE.zip b/payloads/Kexts/Acidanthera/CPUFriend-v1.2.7-RELEASE.zip deleted file mode 100644 index efa08c405..000000000 Binary files a/payloads/Kexts/Acidanthera/CPUFriend-v1.2.7-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/CPUFriend-v1.2.8-DEBUG.zip b/payloads/Kexts/Acidanthera/CPUFriend-v1.2.8-DEBUG.zip new file mode 100644 index 000000000..80530e717 Binary files /dev/null and b/payloads/Kexts/Acidanthera/CPUFriend-v1.2.8-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/CPUFriend-v1.2.8-RELEASE.zip b/payloads/Kexts/Acidanthera/CPUFriend-v1.2.8-RELEASE.zip new file mode 100644 index 000000000..0be0ccb66 Binary files /dev/null and b/payloads/Kexts/Acidanthera/CPUFriend-v1.2.8-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.2-DEBUG.zip b/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.2-DEBUG.zip deleted file mode 100644 index b7a5dd6a7..000000000 Binary files a/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.2-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.2-RELEASE.zip b/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.2-RELEASE.zip deleted file mode 100644 index bcb3a7f9a..000000000 Binary files a/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.2-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.3-DEBUG.zip b/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.3-DEBUG.zip new file mode 100644 index 000000000..5f742496d Binary files /dev/null and b/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.3-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.3-RELEASE.zip b/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.3-RELEASE.zip new file mode 100644 index 000000000..a3c28a2d3 Binary files /dev/null and b/payloads/Kexts/Acidanthera/CryptexFixup-v1.0.3-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.8-DEBUG.zip b/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.8-DEBUG.zip deleted file mode 100644 index e6887e55b..000000000 Binary files a/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.8-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.8-RELEASE.zip b/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.8-RELEASE.zip deleted file mode 100644 index 0a11c8d4e..000000000 Binary files a/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.8-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.9-DEBUG.zip b/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.9-DEBUG.zip new file mode 100644 index 000000000..67e630305 Binary files /dev/null and b/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.9-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.9-RELEASE.zip b/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.9-RELEASE.zip new file mode 100644 index 000000000..91f5efc17 Binary files /dev/null and b/payloads/Kexts/Acidanthera/DebugEnhancer-v1.0.9-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.5-DEBUG.zip b/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.5-DEBUG.zip deleted file mode 100644 index d723275b5..000000000 Binary files a/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.5-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.5-RELEASE.zip b/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.5-RELEASE.zip deleted file mode 100644 index 82b6a8c27..000000000 Binary files a/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.5-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.6-DEBUG.zip b/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.6-DEBUG.zip new file mode 100644 index 000000000..0e56ae905 Binary files /dev/null and b/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.6-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.6-RELEASE.zip b/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.6-RELEASE.zip new file mode 100644 index 000000000..25a9400b8 Binary files /dev/null and b/payloads/Kexts/Acidanthera/FeatureUnlock-v1.1.6-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/Lilu-v1.6.7-DEBUG.zip b/payloads/Kexts/Acidanthera/Lilu-v1.6.7-DEBUG.zip deleted file mode 100644 index a77342251..000000000 Binary files a/payloads/Kexts/Acidanthera/Lilu-v1.6.7-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/Lilu-v1.6.7-RELEASE.zip b/payloads/Kexts/Acidanthera/Lilu-v1.6.7-RELEASE.zip deleted file mode 100644 index 5b8b8cc8b..000000000 Binary files a/payloads/Kexts/Acidanthera/Lilu-v1.6.7-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/Lilu-v1.6.8-DEBUG.zip b/payloads/Kexts/Acidanthera/Lilu-v1.6.8-DEBUG.zip new file mode 100644 index 000000000..968c758b2 Binary files /dev/null and b/payloads/Kexts/Acidanthera/Lilu-v1.6.8-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/Lilu-v1.6.8-RELEASE.zip b/payloads/Kexts/Acidanthera/Lilu-v1.6.8-RELEASE.zip new file mode 100644 index 000000000..30c3ccb7f Binary files /dev/null and b/payloads/Kexts/Acidanthera/Lilu-v1.6.8-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/RSRHelper-v1.0.0-DEBUG.zip b/payloads/Kexts/Acidanthera/RSRHelper-v1.0.0-DEBUG.zip deleted file mode 100644 index b167bad7e..000000000 Binary files a/payloads/Kexts/Acidanthera/RSRHelper-v1.0.0-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/RSRHelper-v1.0.0-RELEASE.zip b/payloads/Kexts/Acidanthera/RSRHelper-v1.0.0-RELEASE.zip deleted file mode 100644 index 928b4f37e..000000000 Binary files a/payloads/Kexts/Acidanthera/RSRHelper-v1.0.0-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/RSRHelper-v1.0.2-DEBUG.zip b/payloads/Kexts/Acidanthera/RSRHelper-v1.0.2-DEBUG.zip new file mode 100644 index 000000000..bd1f62f62 Binary files /dev/null and b/payloads/Kexts/Acidanthera/RSRHelper-v1.0.2-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/RSRHelper-v1.0.2-RELEASE.zip b/payloads/Kexts/Acidanthera/RSRHelper-v1.0.2-RELEASE.zip new file mode 100644 index 000000000..673c845ec Binary files /dev/null and b/payloads/Kexts/Acidanthera/RSRHelper-v1.0.2-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.3-DEBUG.zip b/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.3-DEBUG.zip deleted file mode 100644 index c3ec8ffe9..000000000 Binary files a/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.3-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.3-RELEASE.zip b/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.3-RELEASE.zip deleted file mode 100644 index e771e4d6c..000000000 Binary files a/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.3-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.4-DEBUG.zip b/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.4-DEBUG.zip new file mode 100644 index 000000000..873b9db55 Binary files /dev/null and b/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.4-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.4-RELEASE.zip b/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.4-RELEASE.zip new file mode 100644 index 000000000..f811ed0d5 Binary files /dev/null and b/payloads/Kexts/Acidanthera/RestrictEvents-v1.1.4-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-DEBUG.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-DEBUG.zip deleted file mode 100644 index 9754608fe..000000000 Binary files a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-Navi-DEBUG.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-Navi-DEBUG.zip deleted file mode 100644 index 9e469b48a..000000000 Binary files a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-Navi-DEBUG.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-Navi-RELEASE.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-Navi-RELEASE.zip deleted file mode 100644 index 528d1cdd6..000000000 Binary files a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-Navi-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-RELEASE.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-RELEASE.zip deleted file mode 100644 index 73f65b505..000000000 Binary files a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.6-RELEASE.zip and /dev/null differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-DEBUG.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-DEBUG.zip new file mode 100644 index 000000000..fca460edc Binary files /dev/null and b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-Navi-DEBUG.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-Navi-DEBUG.zip new file mode 100644 index 000000000..23485e20d Binary files /dev/null and b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-Navi-DEBUG.zip differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-Navi-RELEASE.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-Navi-RELEASE.zip new file mode 100644 index 000000000..314dde06b Binary files /dev/null and b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-Navi-RELEASE.zip differ diff --git a/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-RELEASE.zip b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-RELEASE.zip new file mode 100644 index 000000000..ec78ef398 Binary files /dev/null and b/payloads/Kexts/Acidanthera/WhateverGreen-v1.6.7-RELEASE.zip differ diff --git a/payloads/Kexts/Misc/AppleTopCaseInjector-v1.0.0.zip b/payloads/Kexts/Misc/AppleTopCaseInjector-v1.0.0.zip new file mode 100644 index 000000000..34aac6db8 Binary files /dev/null and b/payloads/Kexts/Misc/AppleTopCaseInjector-v1.0.0.zip differ diff --git a/payloads/Kexts/Misc/KernelRelayHost-v1.0.0.zip b/payloads/Kexts/Misc/KernelRelayHost-v1.0.0.zip new file mode 100644 index 000000000..aef76f4de Binary files /dev/null and b/payloads/Kexts/Misc/KernelRelayHost-v1.0.0.zip differ diff --git a/payloads/Kexts/Plists/AppleGraphicsPowerManagement/Info.plist b/payloads/Kexts/Plists/AppleGraphicsPowerManagement/Info.plist index f92fe3f11..c7ac5b70a 100644 --- a/payloads/Kexts/Plists/AppleGraphicsPowerManagement/Info.plist +++ b/payloads/Kexts/Plists/AppleGraphicsPowerManagement/Info.plist @@ -1712,6 +1712,418 @@ 16 + MacBookAir8,1 + + IGPU + + BoostPState + + 24 + 24 + 280 + 24 + 280 + + BoostTime + + 1 + 1 + 1000 + 15 + 100 + + Heuristic + + BusyDownThresholdPercent + 50 + BusyUpThresholdPercent + 70 + CPGControl + + MediaHysteresis + 32 + RenderHysteresis + 32 + Wake_Limit + 80 + + DownStep + 1 + EnableOverride + 1 + EnableRingTableOverride + 1 + EvaluateDownInterval + 40000 + EvaluateUpInterval + 40000 + ID + 2 + IOBusynessSamplingInterval + 1 + NumOfRingTableOverride + 23 + NumOfRingTables + 3 + NumOfThresholdsForRingTables + 2 + PMCounterControl + + PM_C0_Any_Media_Threshold + 26263 + PM_Counter_Eval_Interval + 40 + PM_Counter_Heuristic_Enable + 1 + PM_Counter_Window + 2 + PM_DRAM_Threshold_High + 18 + PM_DRAM_Threshold_Low + 3 + PM_DRAM_Writes_Threshold + 165077 + PM_EU_Idle_Threshold + 55 + PM_EU_Stall_Sampler_Threshold + 40 + PM_EU_Stall_Threshold + 60 + PM_GPU_Busy + 30 + PM_Rasterized_Threshold + 486104 + PM_Slice_Switch_Timer + 1070 + + RCxControl + + RC6_Threshold + 520 + RC6_Wake_Limit + 40 + RC_Eval_Interval + 40000 + RP_Idle_Hysteresis + 128 + + RingOverrideTable0 + + 8 + 8 + 8 + 8 + 8 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + + RingOverrideTable1 + + 9 + 11 + 12 + 14 + 15 + 17 + 18 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + + RingOverrideTable2 + + 9 + 11 + 12 + 14 + 15 + 17 + 18 + 20 + 21 + 23 + 24 + 26 + 27 + 29 + 30 + 32 + 33 + 35 + 36 + 38 + 39 + 41 + 42 + + StartingPstateForRingTableOverride + 11 + ThresholdsForRingOverrideTable0 + + 0 + 10 + + ThresholdsForRingOverrideTable1 + + 5 + 15 + + ThresholdsForRingOverrideTable2 + + 10 + 100 + + UpStep + 1 + sampleInterval + 1000 + + NumPriorityLevels + 3 + SliceControl + 0 + ThermalSupport + 1 + control-id + 16 + + + MacBookAir8,2 + + IGPU + + BoostPState + + 24 + 24 + 280 + 24 + 280 + + BoostTime + + 1 + 1 + 1000 + 15 + 100 + + Heuristic + + BusyDownThresholdPercent + 50 + BusyUpThresholdPercent + 70 + CPGControl + + MediaHysteresis + 32 + RenderHysteresis + 32 + Wake_Limit + 80 + + DownStep + 1 + EnableOverride + 1 + EnableRingTableOverride + 1 + EvaluateDownInterval + 40000 + EvaluateUpInterval + 40000 + ID + 2 + IOBusynessSamplingInterval + 1 + NumOfRingTableOverride + 23 + NumOfRingTables + 3 + NumOfThresholdsForRingTables + 2 + PMCounterControl + + PM_C0_Any_Media_Threshold + 26263 + PM_Counter_Eval_Interval + 40 + PM_Counter_Heuristic_Enable + 1 + PM_Counter_Window + 2 + PM_DRAM_Threshold_High + 18 + PM_DRAM_Threshold_Low + 3 + PM_DRAM_Writes_Threshold + 165077 + PM_EU_Idle_Threshold + 55 + PM_EU_Stall_Sampler_Threshold + 40 + PM_EU_Stall_Threshold + 60 + PM_GPU_Busy + 30 + PM_Rasterized_Threshold + 486104 + PM_Render_Idle_GT3_Switch + 0 + PM_Slice_Switch_Timer + 1070 + + RCxControl + + RC6_Threshold + 520 + RC6_Wake_Limit + 40 + RC_Eval_Interval + 40000 + RP_Idle_Hysteresis + 128 + + RingOverrideTable0 + + 8 + 8 + 8 + 8 + 8 + 9 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + + RingOverrideTable1 + + 9 + 11 + 12 + 14 + 15 + 17 + 18 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + 19 + + RingOverrideTable2 + + 9 + 11 + 12 + 14 + 15 + 17 + 18 + 20 + 21 + 23 + 24 + 26 + 27 + 29 + 30 + 32 + 33 + 35 + 36 + 38 + 39 + 41 + 42 + + StartingPstateForRingTableOverride + 11 + ThresholdsForRingOverrideTable0 + + 0 + 10 + + ThresholdsForRingOverrideTable1 + + 5 + 15 + + ThresholdsForRingOverrideTable2 + + 10 + 100 + + UpStep + 1 + sampleInterval + 1000 + + NumPriorityLevels + 3 + SliceControl + 1 + ThermalSupport + 1 + control-id + 16 + + MacBookPro5,1 GFX0 diff --git a/payloads/Kexts/Update-Kexts.command b/payloads/Kexts/Update-Kexts.command index 48d2d8642..aedac590f 100755 --- a/payloads/Kexts/Update-Kexts.command +++ b/payloads/Kexts/Update-Kexts.command @@ -259,7 +259,7 @@ class GenerateKexts: def _update_constants_file(self, variable_name, old_version, new_version): print(f" Updating {variable_name} to {new_version}...") - constants_file = Path("../../resources/constants.py") + constants_file = Path("../../opencore_legacy_patcher/constants.py") if not constants_file.exists(): raise Exception("Constants file does not exist") constants_file_contents = constants_file.read_text() diff --git a/payloads/Kexts/Wifi/IOSkywalkFamily-v1.1.0.zip b/payloads/Kexts/Wifi/IOSkywalkFamily-v1.1.0.zip deleted file mode 100644 index e225efd87..000000000 Binary files a/payloads/Kexts/Wifi/IOSkywalkFamily-v1.1.0.zip and /dev/null differ diff --git a/payloads/Kexts/Wifi/IOSkywalkFamily-v1.2.0.txt b/payloads/Kexts/Wifi/IOSkywalkFamily-v1.2.0.txt new file mode 100644 index 000000000..7420d8fdf --- /dev/null +++ b/payloads/Kexts/Wifi/IOSkywalkFamily-v1.2.0.txt @@ -0,0 +1,2 @@ +__ZL15nxp_tx_doorbellP19kern_nexus_providerP10kern_nexusP19__kern_channel_ringj +return 0x0 \ No newline at end of file diff --git a/payloads/Kexts/Wifi/IOSkywalkFamily-v1.2.0.zip b/payloads/Kexts/Wifi/IOSkywalkFamily-v1.2.0.zip new file mode 100644 index 000000000..17eab5f1b Binary files /dev/null and b/payloads/Kexts/Wifi/IOSkywalkFamily-v1.2.0.zip differ diff --git a/payloads/Launch Services/com.dortania.opencore-legacy-patcher.os-caching.plist b/payloads/Launch Services/com.dortania.opencore-legacy-patcher.os-caching.plist index 88099b898..27d8c94e3 100644 --- a/payloads/Launch Services/com.dortania.opencore-legacy-patcher.os-caching.plist +++ b/payloads/Launch Services/com.dortania.opencore-legacy-patcher.os-caching.plist @@ -7,7 +7,7 @@ com.dortania.opencore-legacy-patcher Label - com.dortania.opencore-legacy-patcher.rsr-monitor + com.dortania.opencore-legacy-patcher.os-caching ProgramArguments /Library/Application Support/Dortania/OpenCore-Patcher.app/Contents/MacOS/OpenCore-Patcher diff --git a/payloads/OpenCore/OpenCore-DEBUG.zip b/payloads/OpenCore/OpenCore-DEBUG.zip index 15b7c7ad2..5eacd3856 100644 Binary files a/payloads/OpenCore/OpenCore-DEBUG.zip and b/payloads/OpenCore/OpenCore-DEBUG.zip differ diff --git a/payloads/OpenCore/OpenCore-RELEASE.zip b/payloads/OpenCore/OpenCore-RELEASE.zip index 3837dfe67..b0ecd2a23 100644 Binary files a/payloads/OpenCore/OpenCore-RELEASE.zip and b/payloads/OpenCore/OpenCore-RELEASE.zip differ diff --git a/payloads/OpenCore/macserial b/payloads/OpenCore/macserial index b329b0fa7..0106c8612 100755 Binary files a/payloads/OpenCore/macserial and b/payloads/OpenCore/macserial differ diff --git a/payloads/OpenCore/ocvalidate b/payloads/OpenCore/ocvalidate index 9400298d1..4a40ac663 100755 Binary files a/payloads/OpenCore/ocvalidate and b/payloads/OpenCore/ocvalidate differ