Skip to content

Commit

Permalink
sys_patch: Add basic USB 1.1 support
Browse files Browse the repository at this point in the history
Ref: #1021
  • Loading branch information
khronokernel committed Jan 7, 2023
1 parent a5d5614 commit 4cc9e41
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 32 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
- Allows for easy root patching, dropping reliance on Safe Mode to boot
- Primarily applicable for Mac Pros with AMD Polaris and Vega GPUs
- Implement mini validation during GUI build
- Add early UHCI/OHCI support (USB1.1)
- Implemented via Root Volume patching, ie. no installer support at this time
- Applicable for Penryn Macs and Cheese Grater Mac Pros (MacPro3,1 - MacPro5,1)
- See associated issue for current limitations: [Legacy UHCI/OHCI support in Ventura](https://github.com/dortania/OpenCore-Legacy-Patcher/issues/1021)
- Increment Binaries:
- OpenCorePkg 0.8.8 - release
- PatcherSupportPkg 0.7.3 - release
- PatcherSupportPkg 0.7.4 - release
- KDKlessWorkaround 1.0.0 - rolling (4924276)
- FeatureUnlock 1.1.2 - release
- CPUFriend 1.2.6 - release
Expand Down
22 changes: 22 additions & 0 deletions data/sys_patch_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,28 @@ def SystemPatchDictionary(os_major, os_minor, non_metal_os_support):
"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 Reference": {
"/System/Library/Extensions/IOUSBHostFamily.kext/Contents/MacOS": {
"IOUSBHostFamily": "12.6.2",
},
"/System/Library/Extensions/IOUSBHostFamily.kext/Contents/PlugIns": {
"AppleUSBEHCI.kext": "12.6.2",
"AppleUSBHub.kext": "12.6.2",
},
},
}
},
}

Expand Down
20 changes: 10 additions & 10 deletions resources/build/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,16 @@ def usb_handling(self):
# - IOUSBHostFamily.kext (only kext itself, not plugins)
# - AppleUSBHub.kext
# - AppleUSBEHCI.kext
# if (
# smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value or \
# self.model in ["MacPro4,1", "MacPro5,1"]
# ):
# print("- Adding UHCI/OHCI USB support")
# shutil.copy(self.constants.apple_usb_11_injector_path, self.constants.kexts_path)
# support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBOHCI.kext")["Enabled"] = True
# support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBOHCIPCI.kext")["Enabled"] = True
# support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBUHCI.kext")["Enabled"] = True
# support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBUHCIPCI.kext")["Enabled"] = True
if (
smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value or \
self.model in ["MacPro4,1", "MacPro5,1"]
):
print("- Adding UHCI/OHCI USB support")
shutil.copy(self.constants.apple_usb_11_injector_path, self.constants.kexts_path)
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBOHCI.kext")["Enabled"] = True
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBOHCIPCI.kext")["Enabled"] = True
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBUHCI.kext")["Enabled"] = True
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("USB1.1-Injector.kext/Contents/PlugIns/AppleUSBUHCIPCI.kext")["Enabled"] = True

def debug_handling(self):
# DEBUG Settings (OpenCorePkg and Kernel Space)
Expand Down
2 changes: 1 addition & 1 deletion resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Constants:
def __init__(self):
# Patcher Versioning
self.patcher_version = "0.5.4" # OpenCore-Legacy-Patcher
self.patcher_support_pkg_version = "0.7.3" # PatcherSupportPkg
self.patcher_support_pkg_version = "0.7.4" # PatcherSupportPkg
self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/"
self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/"
self.discord_link = "https://discord.gg/rqdPgH8xSN"
Expand Down
12 changes: 1 addition & 11 deletions resources/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,4 @@ def gpu_probe(self):
self.constants.disable_cs_lv = True
if os_data.os_data.ventura in self.constants.legacy_accel_support:
# Only disable AMFI if we officially support Ventura
self.constants.disable_amfi = True

if self.host_is_target:
self.constants.host_is_non_metal = True
# If a Mac is non-Metal based, Beta Blur is highly recommended
if self.constants.detected_os >= os_data.os_data.big_sur:
for arg in ["Moraea_BlurBeta"]:
# If user explicitly set the blur, don't override
arg_result = subprocess.run(["defaults", "read", "-g", arg], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if arg_result not in ["true", "1", "false", "0"]:
subprocess.run(["defaults", "write", "-g", arg, "-bool", "TRUE"])
self.constants.disable_amfi = True
16 changes: 8 additions & 8 deletions resources/gui/gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3590,11 +3590,11 @@ def non_metal_config_menu(self, event=None):
else:
is_blur_enabled = False

is_rim_enabled = subprocess.run(["defaults", "read", "-g", "Moraea_RimBeta"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if is_rim_enabled in ["1", "true"]:
is_rim_enabled = True
is_rim_disabled = subprocess.run(["defaults", "read", "-g", "Moraea_RimBetaDisabled"], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if is_rim_disabled in ["1", "true"]:
is_rim_disabled = True
else:
is_rim_enabled = False
is_rim_disabled = False

# Checkbox: Dark Menu Bar
self.dark_menu_bar_checkbox = wx.CheckBox(self.frame_modal, label="Dark Menu Bar")
Expand All @@ -3610,8 +3610,8 @@ def non_metal_config_menu(self, event=None):
self.enable_beta_blur_checkbox.SetPosition(wx.Point(self.dark_menu_bar_checkbox.GetPosition().x, self.dark_menu_bar_checkbox.GetPosition().y + self.dark_menu_bar_checkbox.GetSize().height + 7))

# Checkbox: Enable Beta Rim
self.enable_beta_rim_checkbox = wx.CheckBox(self.frame_modal, label="Enable Beta Rim")
self.enable_beta_rim_checkbox.SetValue(is_rim_enabled)
self.enable_beta_rim_checkbox = wx.CheckBox(self.frame_modal, label="Disable Beta Rim")
self.enable_beta_rim_checkbox.SetValue(is_rim_disabled)
self.enable_beta_rim_checkbox.Bind(wx.EVT_CHECKBOX, self.enable_beta_rim_click)
self.enable_beta_rim_checkbox.SetPosition(wx.Point(self.enable_beta_blur_checkbox.GetPosition().x, self.enable_beta_blur_checkbox.GetPosition().y + self.enable_beta_blur_checkbox.GetSize().height + 7))

Expand Down Expand Up @@ -3640,7 +3640,7 @@ def enable_dark_menubar_click(self, event=None):

def enable_beta_rim_click(self, event=None):
if event.IsChecked():
subprocess.run(["defaults", "write", "-g", "Moraea_RimBeta", "-bool", "true"])
subprocess.run(["defaults", "write", "-g", "Moraea_RimBetaDisabled", "-bool", "true"])
else:
subprocess.run(["defaults", "write", "-g", "Moraea_RimBeta", "-bool", "false"])
subprocess.run(["defaults", "write", "-g", "Moraea_RimBetaDisabled", "-bool", "false"])
print("Beta Rim Enabled:", event.IsChecked())
38 changes: 37 additions & 1 deletion resources/sys_patch/sys_patch_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from resources import constants, device_probe, utilities, amfi_detect
from resources.sys_patch import sys_patch_helpers
from data import model_array, os_data, sip_data, sys_patch_dict
from data import model_array, os_data, sip_data, sys_patch_dict, smbios_data, cpu_data

import py_sip_xnu
from pathlib import Path
Expand Down Expand Up @@ -39,6 +39,7 @@ def __init__(self, model, versions):
self.legacy_wifi = False
self.legacy_gmux = False
self.legacy_keyboard_backlight = False
self.legacy_uhci_ohci = False

# Patch Requirements
self.amfi_must_disable = False
Expand Down Expand Up @@ -364,9 +365,41 @@ def check_sip(self):
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):
if self.constants.detected_os < 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 and MacPro5,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.cpu_data.penryn.value or \
self.model in ["MacPro4,1", "MacPro5,1"]
):
return True

return False

def detect_patch_set(self):
self.has_network = utilities.verify_network_connection()

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.constants.detected_os > os_data.os_data.catalina:
self.brightness_legacy = True
Expand Down Expand Up @@ -423,6 +456,7 @@ def detect_patch_set(self):
"Networking: Legacy Wireless": self.legacy_wifi,
"Miscellaneous: Legacy GMUX": self.legacy_gmux,
"Miscellaneous: Legacy Keyboard Backlight": self.legacy_keyboard_backlight,
"Miscellaneous: Legacy USB 1.1": self.legacy_uhci_ohci,
"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.constants.detected_os >= os_data.os_data.ventura.value else False,
Expand Down Expand Up @@ -641,6 +675,8 @@ def generate_patchset(self, hardware_details):
required_patches.update({"Legacy GMUX": all_hardware_patchset["Miscellaneous"]["Legacy GMUX"]})
if hardware_details["Miscellaneous: Legacy Keyboard Backlight"] is True:
required_patches.update({"Legacy Keyboard Backlight": all_hardware_patchset["Miscellaneous"]["Legacy Keyboard Backlight"]})
if hardware_details["Miscellaneous: Legacy USB 1.1"] is True:
required_patches.update({"Legacy USB 1.1": all_hardware_patchset["Miscellaneous"]["Legacy USB 1.1"]})

if required_patches:
host_os_float = float(f"{self.constants.detected_os}.{self.constants.detected_os_minor}")
Expand Down

0 comments on commit 4cc9e41

Please sign in to comment.