mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-21 06:30:52 +10:00
wireless.py: Refactor
This commit is contained in:
@@ -10,6 +10,7 @@ class build_wired:
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.computer = self.constants.computer
|
self.computer = self.constants.computer
|
||||||
|
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
# Check if Ethernet was detected, otherwise fall back to assumptions (mainly for 2011 MacBook Airs and TB Ethernet)
|
# Check if Ethernet was detected, otherwise fall back to assumptions (mainly for 2011 MacBook Airs and TB Ethernet)
|
||||||
if not self.constants.custom_model and self.constants.computer.ethernet:
|
if not self.constants.custom_model and self.constants.computer.ethernet:
|
||||||
@@ -17,6 +18,7 @@ class build_wired:
|
|||||||
else:
|
else:
|
||||||
self.prebuilt_assumption()
|
self.prebuilt_assumption()
|
||||||
|
|
||||||
|
|
||||||
def on_model(self):
|
def on_model(self):
|
||||||
# On-model hardware detection
|
# On-model hardware detection
|
||||||
for controller in self.constants.computer.ethernet:
|
for controller in self.constants.computer.ethernet:
|
||||||
@@ -44,6 +46,7 @@ class build_wired:
|
|||||||
elif isinstance(controller, device_probe.Marvell) or isinstance(controller, device_probe.SysKonnect):
|
elif isinstance(controller, device_probe.Marvell) or isinstance(controller, device_probe.SysKonnect):
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path)
|
support.build_support(self.model, self.constants, self.config).enable_kext("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path)
|
||||||
|
|
||||||
|
|
||||||
def prebuilt_assumption(self):
|
def prebuilt_assumption(self):
|
||||||
# Stock hardware assumptions
|
# Stock hardware assumptions
|
||||||
if not self.model in smbios_data.smbios_dictionary:
|
if not self.model in smbios_data.smbios_dictionary:
|
||||||
|
|||||||
@@ -12,82 +12,103 @@ class build_wireless:
|
|||||||
|
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
|
|
||||||
# WiFi patches
|
# WiFi patches
|
||||||
if not self.constants.custom_model:
|
if not self.constants.custom_model and self.constants.computer.wifi:
|
||||||
if self.computer.wifi:
|
self.on_model()
|
||||||
print(f"- Found Wireless Device {utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}")
|
|
||||||
self.config["#Revision"]["Hardware-Wifi"] = f"{utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}"
|
|
||||||
else:
|
else:
|
||||||
print("- Unable to run Wireless hardware detection")
|
self.prebuilt_assumption()
|
||||||
|
self.wowl_handling()
|
||||||
|
|
||||||
if not self.constants.custom_model:
|
|
||||||
if self.computer.wifi:
|
def on_model(self):
|
||||||
if isinstance(self.computer.wifi, device_probe.Broadcom):
|
print(f"- Found Wireless Device {utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}")
|
||||||
# This works around OCLP spoofing the Wifi card and therefore unable to actually detect the correct device
|
self.config["#Revision"]["Hardware-Wifi"] = f"{utilities.friendly_hex(self.computer.wifi.vendor_id)}:{utilities.friendly_hex(self.computer.wifi.device_id)}"
|
||||||
if self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirportBrcmNIC and self.constants.validate is False and self.computer.wifi.country_code:
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
|
if isinstance(self.computer.wifi, device_probe.Broadcom):
|
||||||
print(f"- Setting Wireless Card's Country Code: {self.computer.wifi.country_code}")
|
# This works around OCLP spoofing the Wifi card and therefore unable to actually detect the correct device
|
||||||
if self.computer.wifi.pci_path:
|
if self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirportBrcmNIC and self.constants.validate is False and self.computer.wifi.country_code:
|
||||||
arpt_path = self.computer.wifi.pci_path
|
|
||||||
print(f"- Found ARPT device at {arpt_path}")
|
|
||||||
self.config["DeviceProperties"]["Add"][arpt_path] = {"brcmfx-country": self.computer.wifi.country_code}
|
|
||||||
else:
|
|
||||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" brcmfx-country={self.computer.wifi.country_code}"
|
|
||||||
if self.constants.enable_wake_on_wlan is True:
|
|
||||||
print("- Enabling Wake on WLAN support")
|
|
||||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" -brcmfxwowl"
|
|
||||||
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4360:
|
|
||||||
self.wifi_fake_id()
|
|
||||||
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4331:
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
|
|
||||||
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm43224:
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
|
|
||||||
elif isinstance(self.computer.wifi, device_probe.Atheros) and self.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40:
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
|
|
||||||
else:
|
|
||||||
if smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm4360:
|
|
||||||
print("- Enabling BCM943224 and BCM94331 Networking Support")
|
|
||||||
self.wifi_fake_id()
|
|
||||||
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm4331:
|
|
||||||
print("- Enabling BCM94328 Networking Support")
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
|
|
||||||
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm43224:
|
|
||||||
print("- Enabling BCM94328 Networking Support")
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
|
|
||||||
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Atheros.Chipsets.AirPortAtheros40:
|
|
||||||
print("- Enabling Atheros Networking Support")
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
|
|
||||||
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirportBrcmNIC:
|
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
|
support.build_support(self.model, self.constants, self.config).enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
|
||||||
|
print(f"- Setting Wireless Card's Country Code: {self.computer.wifi.country_code}")
|
||||||
|
if self.computer.wifi.pci_path:
|
||||||
|
arpt_path = self.computer.wifi.pci_path
|
||||||
|
print(f"- Found ARPT device at {arpt_path}")
|
||||||
|
self.config["DeviceProperties"]["Add"][arpt_path] = {"brcmfx-country": self.computer.wifi.country_code}
|
||||||
|
else:
|
||||||
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" brcmfx-country={self.computer.wifi.country_code}"
|
||||||
if self.constants.enable_wake_on_wlan is True:
|
if self.constants.enable_wake_on_wlan is True:
|
||||||
print("- Enabling Wake on WLAN support")
|
print("- Enabling Wake on WLAN support")
|
||||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" -brcmfxwowl"
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" -brcmfxwowl"
|
||||||
|
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4360:
|
||||||
|
self.wifi_fake_id()
|
||||||
|
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4331:
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
|
||||||
|
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm43224:
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
|
||||||
|
elif isinstance(self.computer.wifi, device_probe.Atheros) and self.computer.wifi.chipset == device_probe.Atheros.Chipsets.AirPortAtheros40:
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
|
||||||
|
|
||||||
|
|
||||||
|
def prebuilt_assumption(self):
|
||||||
|
if not self.model in smbios_data.smbios_dictionary:
|
||||||
|
return
|
||||||
|
if not "Wireless Model" in smbios_data.smbios_dictionary[self.model]:
|
||||||
|
return
|
||||||
|
if smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm4360:
|
||||||
|
print("- Enabling BCM943224 and BCM94331 Networking Support")
|
||||||
|
self.wifi_fake_id()
|
||||||
|
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm4331:
|
||||||
|
print("- Enabling BCM94328 Networking Support")
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
|
||||||
|
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirPortBrcm43224:
|
||||||
|
print("- Enabling BCM94328 Networking Support")
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
|
||||||
|
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Atheros.Chipsets.AirPortAtheros40:
|
||||||
|
print("- Enabling Atheros Networking Support")
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
|
||||||
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
|
||||||
|
elif smbios_data.smbios_dictionary[self.model]["Wireless Model"] == device_probe.Broadcom.Chipsets.AirportBrcmNIC:
|
||||||
|
support.build_support(self.model, self.constants, self.config).enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
|
||||||
|
|
||||||
|
|
||||||
|
def wowl_handling(self):
|
||||||
|
# To avoid reduced networking performance from wake, AirPortBrcmFixup is used to disable wake on WLAN by default.
|
||||||
|
# However some users may want to enable wake on WLAN, so enable if requested.
|
||||||
|
if self.constants.enable_wake_on_wlan is False:
|
||||||
|
return
|
||||||
|
if support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("AirportBrcmFixup.kext")["Enabled"] is False:
|
||||||
|
return
|
||||||
|
|
||||||
|
print("- Enabling Wake on WLAN support")
|
||||||
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" -brcmfxwowl"
|
||||||
|
|
||||||
|
|
||||||
def wifi_fake_id(self):
|
def wifi_fake_id(self):
|
||||||
|
# BCM94331 and BCM943224 are both partially supported within Big Sur's native AirPortBrcmNIC stack
|
||||||
|
# Simply adding the Device IDs and usage of AirPortBrcmFixup will restore full functionality
|
||||||
support.build_support(self.model, self.constants, self.config).enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
|
support.build_support(self.model, self.constants, self.config).enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
|
||||||
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True
|
support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True
|
||||||
if not self.constants.custom_model and self.computer.wifi and self.computer.wifi.pci_path:
|
if not self.constants.custom_model and self.computer.wifi and self.computer.wifi.pci_path:
|
||||||
arpt_path = self.computer.wifi.pci_path
|
arpt_path = self.computer.wifi.pci_path
|
||||||
print(f"- Found ARPT device at {arpt_path}")
|
print(f"- Found ARPT device at {arpt_path}")
|
||||||
else:
|
else:
|
||||||
try:
|
if not self.model in smbios_data.smbios_dictionary:
|
||||||
smbios_data.smbios_dictionary[self.model]["nForce Chipset"]
|
print("No known PCI pathing for this model")
|
||||||
|
return
|
||||||
|
if "nForce Chipset" in smbios_data.smbios_dictionary[self.model]:
|
||||||
# Nvidia chipsets all have the same path to ARPT
|
# Nvidia chipsets all have the same path to ARPT
|
||||||
arpt_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
|
arpt_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
|
||||||
except KeyError:
|
else:
|
||||||
if self.model in ("iMac7,1", "iMac8,1", "MacPro3,1", "MacBookPro4,1"):
|
if self.model in ("iMac7,1", "iMac8,1", "MacPro3,1", "MacBookPro4,1"):
|
||||||
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
|
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
|
||||||
elif self.model in ("iMac13,1", "iMac13,2"):
|
elif self.model in ("iMac13,1", "iMac13,2"):
|
||||||
@@ -98,11 +119,8 @@ class build_wireless:
|
|||||||
# Assumes we have a laptop with Intel chipset
|
# Assumes we have a laptop with Intel chipset
|
||||||
# iMac11,x-12,x also apply
|
# iMac11,x-12,x also apply
|
||||||
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
|
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
|
||||||
print(f"- Using known DevicePath {arpt_path}")
|
print(f"- Using known ARPT Path: {arpt_path}")
|
||||||
|
|
||||||
if not self.constants.custom_model and self.computer.wifi and self.constants.validate is False and self.computer.wifi.country_code:
|
if not self.constants.custom_model and self.computer.wifi and self.constants.validate is False and self.computer.wifi.country_code:
|
||||||
print(f"- Applying fake ID for WiFi, setting Country Code: {self.computer.wifi.country_code}")
|
print(f"- Applying fake ID for WiFi, setting Country Code: {self.computer.wifi.country_code}")
|
||||||
self.config["DeviceProperties"]["Add"][arpt_path] = {"brcmfx-country": self.computer.wifi.country_code}
|
self.config["DeviceProperties"]["Add"][arpt_path] = {"brcmfx-country": self.computer.wifi.country_code}
|
||||||
if self.constants.enable_wake_on_wlan is True:
|
|
||||||
print("- Enabling Wake on WLAN support")
|
|
||||||
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" -brcmfxwowl"
|
|
||||||
Reference in New Issue
Block a user