@@ -34,6 +34,12 @@ def __init__(self, model, versions):
3434 self .config = None
3535 self .constants : Constants .Constants = versions
3636
37+ def hexswap (self , input_hex : str ):
38+ hex_pairs = [input_hex [i :i + 2 ] for i in range (0 , len (input_hex ), 2 )]
39+ hex_rev = hex_pairs [::- 1 ]
40+ hex_str = "" .join (["" .join (x ) for x in hex_rev ])
41+ return hex_str .upper ()
42+
3743 def build_efi (self ):
3844 utilities .cls ()
3945 if not Path (self .constants .build_path ).exists ():
@@ -87,30 +93,36 @@ def build_efi(self):
8793
8894 # WiFi patches
8995
90- if self .model in ModelArray .WifiAtheros :
91- self .enable_kext ("IO80211HighSierra.kext" , self .constants .io80211high_sierra_version , self .constants .io80211high_sierra_path )
92- self .get_kext_by_bundle_path ("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext" )["Enabled" ] = True
93-
94- if self .model in ModelArray .WifiBCM94331 :
95- self .enable_kext ("AirportBrcmFixup.kext" , self .constants .airportbcrmfixup_version , self .constants .airportbcrmfixup_path )
96- self .get_kext_by_bundle_path ("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext" )["Enabled" ] = True
97-
98- if self .model in ModelArray .EthernetNvidia :
99- # Nvidia chipsets all have the same path to ARPT
100- property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
101- if self .model in ("MacBookAir2,1" , "MacBookAir3,1" , "MacBookAir3,2" ):
102- property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
103- elif self .model in ("iMac7,1" , "iMac8,1" ):
104- property_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
105- elif self .model in ("iMac13,1" , "iMac13,2" ):
106- property_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
107- elif self .model == "MacPro5,1" :
108- property_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
109- else :
110- # Assumes we have a laptop with Intel chipset
111- property_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
112- print ("- Applying fake ID for WiFi" )
113- self .config ["DeviceProperties" ]["Add" ][property_path ] = {"device-id" : binascii .unhexlify ("ba430000" ), "compatible" : "pci14e4,43ba" }
96+ wifi_devices = plistlib .loads (subprocess .run (f"ioreg -c IOPCIDevice -r -d2 -a" .split (), stdout = subprocess .PIPE ).stdout .decode ().strip ().encode ())
97+ wifi_devices = [i for i in wifi_devices if i ["vendor-id" ] == binascii .unhexlify ("E4140000" ) and i ["class-code" ] == binascii .unhexlify ("00800200" )]
98+ wifi_devices = wifi_devices [0 ]
99+ if (self .constants .custom_model ) == "None" & (self .hexswap (binascii .hexlify (wifi_devices ["vendor-id" ]).decode ()[:4 ]) in ModelArray .nativeWifi ):
100+ print ("- Skipping wifi patches" )
101+ else :
102+ if self .model in ModelArray .WifiAtheros :
103+ self .enable_kext ("IO80211HighSierra.kext" , self .constants .io80211high_sierra_version , self .constants .io80211high_sierra_path )
104+ self .get_kext_by_bundle_path ("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext" )["Enabled" ] = True
105+
106+ if self .model in ModelArray .WifiBCM94331 :
107+ self .enable_kext ("AirportBrcmFixup.kext" , self .constants .airportbcrmfixup_version , self .constants .airportbcrmfixup_path )
108+ self .get_kext_by_bundle_path ("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext" )["Enabled" ] = True
109+
110+ if self .model in ModelArray .EthernetNvidia :
111+ # Nvidia chipsets all have the same path to ARPT
112+ property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
113+ if self .model in ("MacBookAir2,1" , "MacBookAir3,1" , "MacBookAir3,2" ):
114+ property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
115+ elif self .model in ("iMac7,1" , "iMac8,1" ):
116+ property_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
117+ elif self .model in ("iMac13,1" , "iMac13,2" ):
118+ property_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
119+ elif self .model == "MacPro5,1" :
120+ property_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
121+ else :
122+ # Assumes we have a laptop with Intel chipset
123+ property_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
124+ print ("- Applying fake ID for WiFi" )
125+ self .config ["DeviceProperties" ]["Add" ][property_path ] = {"device-id" : binascii .unhexlify ("ba430000" ), "compatible" : "pci14e4,43ba" }
114126
115127 # HID patches
116128 if self .model in ModelArray .LegacyHID :
@@ -139,12 +151,10 @@ def build_efi(self):
139151 self .config ["NVRAM" ]["Add" ]["4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14" ]["UIScale" ] = binascii .unhexlify ("02" )
140152
141153 # Check GPU Vendor
142- if self .constants .custom_model != "None" :
143- #current_gpu: str = subprocess.run("system_profiler SPDisplaysDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
144- #current_gpuv = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Vendor"))][0]
145- #current_gpud = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Device ID"))][0]
146- current_gpuv = "NVIDIA (0x10de)"
147- current_gpud = "0x11a9"
154+ if self .constants .custom_model == "None" :
155+ current_gpu : str = subprocess .run ("system_profiler SPDisplaysDataType" .split (), stdout = subprocess .PIPE , stderr = subprocess .STDOUT ).stdout .decode ()
156+ current_gpuv = [line .strip ().split (": " , 1 )[1 ] for line in current_gpu .split ("\n " ) if line .strip ().startswith (("Vendor" ))][0 ]
157+ current_gpud = [line .strip ().split (": " , 1 )[1 ] for line in current_gpu .split ("\n " ) if line .strip ().startswith (("Device ID" ))][0 ]
148158 print (f"- Detected GPU: { current_gpuv } { current_gpud } " )
149159 if (current_gpuv == "AMD (0x1002)" ) & (current_gpud in ModelArray .AMDMXMGPUs ):
150160 self .constants .custom_mxm_gpu = True
0 commit comments