Move SMBIOS generation to dedicated file

This commit is contained in:
Mykola Grymalyuk
2021-10-01 09:45:34 -06:00
parent 8b41cc6ff5
commit 0e07273c8e
6 changed files with 233 additions and 292 deletions

View File

@@ -3,7 +3,7 @@ class cpu_data:
yonah = 1
conroe = 2
penryn = 3
nahalem = 4 # (Westmere included)
nehalem = 4 # (Westmere included)
sandy_bridge = 5 # 2000
ivy_bridge = 6 # 3000
haswell = 7 # 4000

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@ import ast
from pathlib import Path
from datetime import date
from Resources import Constants, ModelArray, Utilities, device_probe
from Resources import Constants, ModelArray, Utilities, device_probe, generate_smbios
from Data import smbios_data, bluetooth_data, cpu_data
@@ -30,39 +30,8 @@ class BuildOpenCore:
self.config = None
self.constants: Constants.Constants = versions
self.computer = self.constants.computer
self.gfx0_path = None
def smbios_set(self, model):
if model in ModelArray.MacBookAir_11:
return "MacBookAir7,1"
elif model in ModelArray.MacBookAir_13:
return "MacBookAir7,2"
elif model in ModelArray.MacBook_12:
return "MacBook9,1"
elif model in ModelArray.MacBookPro_13:
return "MacBookPro12,1"
elif model in ModelArray.MacBookPro_15_iGPU:
return "MacBookPro11,4"
elif model in ModelArray.MacBookPro_15_dGPU:
return "MacBookPro11,5"
elif model in ModelArray.Macmini:
return "Macmini7,1"
elif model in ModelArray.iMac_iGPUless:
return "iMacPro1,1"
elif model in ModelArray.iMac_dGPU:
# Check for upgraded GPUs on iMacs
if self.constants.drm_support is True:
return "iMacPro1,1"
else:
return "iMac17,1"
elif model in ModelArray.iMac_iGPU:
return "iMac16,1"
elif model in ModelArray.MacPro:
return "MacPro7,1"
else:
return model
def patch_firmware_feature(self):
# Adjust FirmwareFeature to support everything macOS requires
# APFS Bit (19/20): 10.13+ (OSInstall)
@@ -179,12 +148,12 @@ class BuildOpenCore:
if self.constants.allow_oc_everywhere is False:
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleSMC")["Enabled"] = True
if (smbios_data.smbios_dictionary[self.smbios_set(self.model) or self.constants.override_smbios]["SecureBootModel"]) != None:
# Monterey T2 SMBIOS don't get OS updates without a T2 SBM
# Forces VMM patch instead
if self.get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
self.enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
if self.constants.allow_oc_everywhere is False:
if (smbios_data.smbios_dictionary[generate_smbios.set_smbios_model_spoof(self.model) or self.constants.override_smbios]["SecureBootModel"]) != None:
# Monterey T2 SMBIOS don't get OS updates without a T2 SBM
# Forces VMM patch instead
if self.get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False:
self.enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path)
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge:
# Ref: https://github.com/reenigneorcim/SurPlus
@@ -345,14 +314,15 @@ class BuildOpenCore:
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.iokit.IOHIDFamily")["Enabled"] = True
# SSDT patches
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] == cpu_data.cpu_data.nahalem and not (self.model.startswith("MacPro") or self.model.startswith("Xserve")):
if smbios_data.smbios_dictionary[self.model]["CPU Generation"] == cpu_data.cpu_data.nehalem and not (self.model.startswith("MacPro") or self.model.startswith("Xserve")):
# Applicable for consumer Nehalem
print("- Adding SSDT-CPBG.aml")
self.get_item_by_kv(self.config["ACPI"]["Add"], "Path", "SSDT-CPBG.aml")["Enabled"] = True
shutil.copy(self.constants.pci_ssdt_path, self.constants.acpi_path)
if cpu_data.cpu_data.sandy_bridge <= smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.ivy_bridge:
# Based on: https://egpu.io/forums/pc-setup/fix-dsdt-override-to-correct-error-12/
# Apply to Sandy and Ivy Bridge Macs
# Applicable for Sandy and Ivy Bridge Macs
print("- Enabling Windows 10 UEFI Audio support")
self.get_item_by_kv(self.config["ACPI"]["Add"], "Path", "SSDT-PCI.aml")["Enabled"] = True
self.get_item_by_kv(self.config["ACPI"]["Patch"], "Comment", "BUF0 to BUF1")["Enabled"] = True
@@ -453,6 +423,7 @@ class BuildOpenCore:
}
# Enable FireWire Boot Support
# Applicable for both native FireWire and Thunderbolt to FireWire adapters
if self.constants.firewire_boot is True and self.model not in ModelArray.NoFireWireSupport:
print("- Enabling FireWire Boot Support")
self.enable_kext("IOFireWireFamily.kext", self.constants.fw_kext, self.constants.fw_family_path)
@@ -529,7 +500,8 @@ class BuildOpenCore:
"class-code": binascii.unhexlify("FFFFFFFF"),
}
elif self.model == "iMac10,1":
self.enable_kext("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path)
if self.get_kext_by_bundle_path("AAAMouSSE.kext")["Enabled"] is False:
self.enable_kext("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path)
# Check GPU Vendor
if self.constants.metal_build is True:
@@ -736,7 +708,7 @@ class BuildOpenCore:
spoofed_model = self.model
if self.constants.override_smbios == "Default":
print("- Setting macOS Monterey Supported SMBIOS")
spoofed_model = self.smbios_set(self.model)
spoofed_model = generate_smbios.set_smbios_model_spoof(self.model)
else:
spoofed_model = self.constants.override_smbios
print(f"- Using Model ID: {spoofed_model}")
@@ -983,7 +955,8 @@ class BuildOpenCore:
def build_opencore(self):
self.build_efi()
self.set_smbios()
if self.constants.allow_oc_everywhere is False:
self.set_smbios()
self.cleanup()
self.sign_files()
print("")

View File

@@ -75,7 +75,7 @@ class Constants:
self.payload_path = self.current_path / Path("payloads")
# Patcher Settings
self.allow_oc_everywhere = False # Set whether Patcher can be run on unsupported Macs
self.allow_oc_everywhere = True # Set whether Patcher can be run on unsupported Macs
self.gui_mode = False # Determine whether running in a GUI or TUI
self.disk = "" # Set installation ESP
self.patch_disk = "" # Set Root Volume to patch

View File

@@ -340,91 +340,6 @@ IntelNvidiaDRM = [
IDEPatch = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "MacPro3,1", "Xserve2,1", "Dortania1,1"]
# 11" Air
MacBookAir_11 = [
"MacBookAir3,1",
"MacBookAir4,1",
"MacBookAir5,1",
"MacBookAir6,1",
]
# Classic MacBook and 13" Air
MacBookAir_13 = [
"MacBook4,1",
"MacBook5,1",
"MacBook5,2",
"MacBook6,1",
"MacBook7,1",
"MacBookAir2,1",
"MacBookAir3,2",
"MacBookAir4,2",
"MacBookAir5,2",
"MacBookAir6,2",
]
# Retina MacBook
MacBook_12 = [
"MacBook8,1",
]
# MacBook Pro 13"
MacBookPro_13 = [
"MacBookPro5,5",
"MacBookPro7,1",
"MacBookPro8,1",
"MacBookPro9,2",
"MacBookPro10,2",
"MacBookPro11,1",
]
# MacBook Pro 15" (iGPU)
MacBookPro_15_iGPU = ["MacBookPro11,2"]
# MacBook Pro 15" and 17" (dGPU)
MacBookPro_15_dGPU = [
"MacBookPro4,1",
"MacBookPro5,1",
"MacBookPro5,2",
"MacBookPro5,3",
"MacBookPro5,4",
"MacBookPro6,1",
"MacBookPro6,2",
"MacBookPro8,2",
"MacBookPro8,3",
"MacBookPro9,1",
"MacBookPro10,1",
"MacBookPro11,3",
]
# Mac Mini
Macmini = ["Macmini3,1", "Macmini4,1", "Macmini5,1", "Macmini5,2", "Macmini5,3", "Macmini6,1", "Macmini6,2"]
# iMacPro = dGPU only iMacs
iMac_iGPUless = [
"iMac7,1",
"iMac8,1",
"iMac9,1",
"iMac10,1",
"iMac11,1",
"iMac11,2",
"iMac11,3",
"iMac12,1",
"iMac12,2",
]
# iMac = AMD and Nvidia GPU with iGPU
iMac_dGPU = [
"iMac13,2",
"iMac14,2",
"iMac14,3",
"iMac15,1",
]
# iMac = Intel iGPU
iMac_iGPU = ["iMac13,1", "iMac13,3", "iMac14,1", "iMac14,4"]
# Mac Pro and Xserve
MacPro = ["MacPro3,1", "MacPro4,1", "MacPro5,1", "Xserve2,1", "Xserve3,1", "Dortania1,1"]

View File

@@ -0,0 +1,53 @@
from Data import smbios_data, os_data
def set_smbios_model_spoof(model):
try:
smbios_data.smbios_dictionary[model]["Screen Size"]
# Found mobile SMBIOS
if model.startswith("MacBookAir"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookAir7,2"
elif smbios_data.smbios_dictionary[model]["Screen Size"] == 11:
return "MacBookAir7,1"
else:
# Unknown Model
raise Exception
elif model.startswith("MacBookPro"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookPro12,1"
elif smbios_data.smbios_dictionary[model]["Screen Size"] >= 15:
# 15" and 17"
try:
smbios_data.smbios_dictionary[model]["Switchable GPUs"]
return "MacBookPro11,5"
except KeyError:
return "MacBookPro11,4"
else:
# Unknown Model
raise Exception
elif model.startswith("MacBook"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookAir7,2"
elif smbios_data.smbios_dictionary[model]["Screen Size"] == 12:
return "MacBook9,1"
else:
# Unknown Model
raise Exception
else:
# Unknown Model
raise Exception
except KeyError:
# Found desktop model
if model.startswith("MacPro") or model.startswith("Xserve"):
return "MacPro7,1"
elif model.startswith("Macmini"):
return "Macmini7,1"
elif model.startswith("iMac"):
if smbios_data.smbios_dictionary[model]["Max OS Supported"] <= os_data.os_data.high_sierra:
# Models dropped in Mojave either do not have an iGPU, or should have them disabled
return "iMacPro1,1"
else:
return "iMac17,1"
else:
# Unknown Model
raise Exception