Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TeraScaleFixup #1139

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- Removes Gatekeeper "verifying" prompt on first launch after PKG installation
- Note `gktool` is only available on macOS Sonoma and newer
- Resolve unpatching crash edge case when host doesn't require patches.
- Add [TeraScaleFixup](https://github.com/Jazzzny/TeraScaleFixup) (Jazzzny)
- Provides support for non-natively supported AMD TeraScale 1 GPUs

## 1.5.0
- Restructure project directories
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ To run the project from source, see here: [Build and run from source](./SOURCE.m
* Non-Metal Photo Booth Patch for Monterey+
* GUI and Backend Development
* Vaulting implementation
* [TeraScaleFixup](https://github.com/Jazzzny/TeraScaleFixup)
* Amazing users who've graciously donate hardware:
* [JohnD](https://forums.macrumors.com/members/johnd.53633/) - 2013 Mac Pro
* [SpiGAndromeda](https://github.com/SpiGAndromeda) - AMD Vega 64
Expand Down
9 changes: 7 additions & 2 deletions opencore_legacy_patcher/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def __init__(self) -> None:
self.kdkless_version: str = "1.0.0"

## Jazzzny
self.legacy_keyboard: str = "1.0.0" # LegacyKeyboardInjector - Jazzzny
self.legacy_keyboard_version: str = "1.0.0" # LegacyKeyboardInjector
self.terascalefixup_version: str = "1.0.0" # TeraScaleFixup

# Get resource path
self.current_path: Path = Path(__file__).parent.parent.resolve()
Expand Down Expand Up @@ -593,7 +594,11 @@ def apple_isight_path(self):

@property
def legacy_keyboard_path(self):
return self.payload_kexts_path / Path(f"Misc/LegacyKeyboardInjector-v{self.legacy_keyboard}.zip")
return self.payload_kexts_path / Path(f"Jazzzny/LegacyKeyboardInjector-v{self.legacy_keyboard_version}.zip")

@property
def terascalefixup_path(self):
return self.payload_kexts_path / Path(f"Jazzzny/TeraScaleFixup-v{self.terascalefixup_version}-{self.kext_variant}.zip")

@property
def apple_raid_path(self):
Expand Down
24 changes: 24 additions & 0 deletions opencore_legacy_patcher/datasets/example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,30 @@ class MacPro:
opencore_version="REL-071-2021-07-02"
)

MacPro41_51__TeraScaleFixup_AMD = device_probe.Computer(
# 4,1 flashed to 5,1, HD 4890, BCM94360CD, WD SN750 NVMe
real_model="MacPro5,1",
real_board_id="Mac-F221BEC8",
reported_model="MacPro5,1",
reported_board_id="Mac-F221BEC8",
gpus=[device_probe.AMD(vendor_id=4098, device_id=37984, class_code=196608, name="GFX0", model="ATI Radeon HD 4890", pci_path="PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)")],
igpu=None,
dgpu=device_probe.AMD(vendor_id=4098, device_id=37984, class_code=196608, name="GFX0", model="ATI Radeon HD 4890", pci_path="PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)"),
storage=[
device_probe.SATAController(vendor_id=32902, device_id=14882, class_code=67073, name="SATA", model=None, pci_path="PciRoot(0x0)/Pci(0x1f,0x2)"),
device_probe.NVMeController(vendor_id=5559, device_id=20482, class_code=67586, name="PXS3", model=None, pci_path="PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)/Pci(0x2,0x0)/Pci(0x0,0x0)", aspm=2)
],

wifi=device_probe.Broadcom(vendor_id=5348, device_id=17312, class_code=163840, name="PXS4", model=None, pci_path="PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)/Pci(0x4,0x0)/Pci(0x0,0x0)"),
cpu=device_probe.CPU(
name="Intel(R) Xeon(R) CPU X5670 @ 2.93GHz",
flags=["FPU", "VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "SEP", "MTRR", "PGE", "MCA", "CMOV", "PAT", "PSE36", "CLFSH", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", "HTT", "TM", "PBE", "SSE3", "PCLMULQDQ", "DTES64", "MON", "DSCPL", "VMX", "SMX", "EST", "TM2", "SSSE3", "CX16", "TPR", "PDCM", "SSE4.1", "SSE4.2", "POPCNT", "AES", "PCID"],
leafs=[],
),
oclp_version="0.2.5",
opencore_version="REL-071-2021-07-02"
)

MacPro41_51_Flashed_NVIDIA_WEB_DRIVERS = device_probe.Computer(
real_model='MacPro5,1',
real_board_id='Mac-F221BEC8',
Expand Down
23 changes: 19 additions & 4 deletions opencore_legacy_patcher/datasets/pci_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,21 +964,36 @@ class amd_ids:
0x9591, # HD 3650 (mobile)
0x9593, # HD 3670 (mobile)
0x9440, # HD 4870
0x9442, # HD 4850
# 0x9442, # HD 4850 - This ID is present in AMDLegacySupport but not anywhere else
0x944A, # HD 4850 (mobile)
0x945A, # HD 4870 (mobile)
0x9490, # HD 4670
0x949E, # FirePro V5700
0x9480, # HD 4650/5165 (mobile)
0x9540, # HD 4550
# 0x9540, # HD 4550 - This ID is present in AMDLegacySupport but not anywhere else
0x9541, # Unknown
0x954E, # Unknown
0x954F, # HD 4350/4550
# 0x954F, # HD 4350/4550 - This ID is present in AMDLegacySupport but not anywhere else
0x9552, # HD 4330/4350/4550 (mobile)
0x9553, # HD 4530/4570/545v (mobile)
# 0x9553, # HD 4530/4570/545v (mobile) - This ID is present in AMDLegacySupport but not anywhere else
0x94A0, # HD 4830
]

# Not natively supported by ATIRadeonX2000, uses https://github.com/Jazzzny/TeraScaleFixup
terascale1_terascalefixup_ids = [
0x9498, # HD 4650
0x9540, # HD 4550
0x954F, # HD 4350/4550
0x9553, # HD 4530/4570/545v (mobile)
0x9442, # HD 4850
0x9441, # HD 4870 X2
0x9443, # HD 4850 X2
0x944C, # HD 4830
0x9460, # HD 4890
0x9462, # HD 4860
0x94B3, # HD 4770
]

terascale_2_ids = [
0x6738, # HD 6870
0x6739, # HD 6850
Expand Down
2 changes: 1 addition & 1 deletion opencore_legacy_patcher/datasets/sys_patch_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def _generate_sys_patch_dict(self):
"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",
"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",
Expand Down
2 changes: 2 additions & 0 deletions opencore_legacy_patcher/detections/device_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ def detect_arch(self):
self.arch = AMD.Archs.Legacy_GCN_9000
elif self.device_id in pci_data.amd_ids.terascale_1_ids:
self.arch = AMD.Archs.TeraScale_1
elif self.device_id in pci_data.amd_ids.terascale1_terascalefixup_ids:
self.arch = AMD.Archs.TeraScale_1
elif self.device_id in pci_data.amd_ids.terascale_2_ids:
self.arch = AMD.Archs.TeraScale_2
elif self.device_id in pci_data.amd_ids.polaris_ids:
Expand Down
11 changes: 9 additions & 2 deletions opencore_legacy_patcher/efi_builder/graphics_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
model_array,
os_data,
cpu_data,
video_bios_data
video_bios_data,
pci_data
)


Expand Down Expand Up @@ -111,7 +112,7 @@ def _graphics_handling(self) -> None:
if not support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is True:
support.BuildSupport(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path)

# Web Driver specific
# Web Driver and TeraScaleFixup
if not self.constants.custom_model:
for i, device in enumerate(self.computer.gpus):
if isinstance(device, device_probe.NVIDIA):
Expand All @@ -137,6 +138,12 @@ def _graphics_handling(self) -> None:
if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]:
self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"]

if isinstance(device, device_probe.AMD):
if device.device_id in pci_data.amd_ids.terascale1_terascalefixup_ids:
logging.info(f"- Enabling TeraScaleFixup for GPU ({i + 1}): {utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}")
support.BuildSupport(self.model, self.constants, self.config).enable_kext("TeraScaleFixup.kext", self.constants.terascalefixup_version, self.constants.terascalefixup_path)


def _backlight_path_detection(self) -> None:
"""
iMac MXM dGPU Backlight DevicePath Detection
Expand Down
4 changes: 2 additions & 2 deletions opencore_legacy_patcher/efi_builder/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _topcase_handling(self) -> None:
support.BuildSupport(self.model, self.constants, self.config).get_kext_by_bundle_path("AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyEventDriver.kext")["Enabled"] = True

if self.computer.internal_keyboard_type == "Legacy":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path)
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard_version, self.constants.legacy_keyboard_path)
if self.computer.trackpad_type == "Legacy":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path)
elif self.computer.trackpad_type == "Modern":
Expand All @@ -232,7 +232,7 @@ def _topcase_handling(self) -> None:
# Two-finger Top Case support for macOS High Sierra+
if self.model == "MacBook5,2":
support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleUSBTrackpad.kext", self.constants.apple_trackpad, self.constants.apple_trackpad_path) # Also requires AppleUSBTopCase.kext
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard, self.constants.legacy_keyboard_path) # Inject legacy personalities into AppleUSBTCKeyboard and AppleUSBTCKeyEventDriver
support.BuildSupport(self.model, self.constants, self.config).enable_kext("LegacyKeyboardInjector.kext", self.constants.legacy_keyboard_version, self.constants.legacy_keyboard_path) # Inject legacy personalities into AppleUSBTCKeyboard and AppleUSBTCKeyEventDriver


def _thunderbolt_handling(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions opencore_legacy_patcher/support/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, global_constants: constants.Constants, verify_unused_files: b
example_data.MacPro.MacPro41_Modern_AMD,
example_data.MacPro.MacPro41_51__Flashed_Modern_AMD,
example_data.MacPro.MacPro41_51_Flashed_NVIDIA_WEB_DRIVERS,
example_data.MacPro.MacPro41_51__TeraScaleFixup_AMD,
]

self.valid_dumps_native = [
Expand Down
35 changes: 29 additions & 6 deletions opencore_legacy_patcher/sys_patch/sys_patch_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
model_array,
os_data,
sip_data,
smbios_data
smbios_data,
pci_data
)


Expand Down Expand Up @@ -87,11 +88,12 @@ def __init__(self, model: str, global_constants: constants.Constants,
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
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
self.needs_terascalefixup = False

# Validation Checks
self.sip_enabled = False
Expand Down Expand Up @@ -167,6 +169,8 @@ def _detect_gpus(self):
if os_data.os_data.ventura in self.constants.legacy_accel_support:
self.amfi_shim_bins = True
self.requires_root_kc = True
if gpu.device_id in pci_data.amd_ids.terascale1_terascalefixup_ids:
self.needs_terascalefixup = True
elif gpu.arch == device_probe.AMD.Archs.TeraScale_2:
if self.os_major > non_metal_os:
self.amd_ts2 = True
Expand Down Expand Up @@ -475,6 +479,16 @@ def _check_os_compat(self) -> bool:
return False
return True

def _check_terascalefixup(self):
"""
Query whether TeraScaleFixup.kext is loaded

Returns:
bool: True if loaded, False otherwise
"""

return utilities.check_kext_loaded("com.jazzzny.terascalefixup")


def _check_kdk(self):
"""
Expand Down Expand Up @@ -669,6 +683,7 @@ def detect_patch_set(self):
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: TeraScaleFixup.kext missing": self.missing_terascalefixup if self.needs_terascalefixup is True else False,
"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,
Expand Down Expand Up @@ -734,6 +749,9 @@ def verify_patch_allowed(self, print_errors: bool = False):
self.missing_nv_compat = not self._check_nv_compat()
self.missing_whatever_green = not self._check_whatevergreen()

if self.needs_terascalefixup is True:
self.missing_terascalefixup = not self._check_terascalefixup()

if print_errors is True:
if self.sip_enabled is True:
logging.info("\nCannot patch! Please disable System Integrity Protection (SIP).")
Expand Down Expand Up @@ -777,6 +795,11 @@ def verify_patch_allowed(self, print_errors: bool = False):
logging.info("\nCannot patch! WhateverGreen.kext missing")
logging.info("Please ensure WhateverGreen.kext is installed")

#if self.needs_terascalefixup is True:
# if self.missing_terascalefixup is True:
# logging.info("\nCannot patch! TeraScaleFixup.kext missing")
# logging.info("Please ensure TeraScaleFixup.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")
Expand Down
18 changes: 18 additions & 0 deletions payloads/Config/config.plist
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,24 @@
<key>PlistPath</key>
<string>Contents/Info.plist</string>
</dict>
<dict>
<key>Arch</key>
<string>x86_64</string>
<key>Comment</key>
<string>Non-native TeraScale GPU Patching</string>
<key>Enabled</key>
<false/>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string>10.0.0</string>
<key>BundlePath</key>
<string>TeraScaleFixup.kext</string>
<key>ExecutablePath</key>
<string>Contents/MacOS/TeraScaleFixup</string>
<key>PlistPath</key>
<string>Contents/Info.plist</string>
</dict>
<dict>
<key>Arch</key>
<string>x86_64</string>
Expand Down
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions payloads/Kexts/Update-Kexts.command
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ KEXT_DICTIONARY = {
},
},

"Jazzzny": {
"TeraScaleFixup": {
"Repository": "https://github.com/Jazzzny/TeraScaleFixup",
"Constants Variable": "self.terascalefixup_version",
},
},

"Misc": {
"Innie": {
"Repository": "https://github.com/cdf/Innie",
Expand Down