Add 3rd Party SATA SSD detection

Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/741
This commit is contained in:
Mykola Grymalyuk
2021-11-17 22:01:26 -07:00
parent 48380afdd5
commit c37aa306fd
2 changed files with 37 additions and 3 deletions

View File

@@ -704,9 +704,17 @@ class BuildOpenCore:
pass
# ThirdPartDrives Check
if self.model in model_array.SATAPatch and self.constants.allow_oc_everywhere is False:
print("- Adding SATA Hibernation Patch")
self.config["Kernel"]["Quirks"]["ThirdPartyDrives"] = True
for drive in ["SATA 2.5", "SATA 3.5", "mSATA"]:
if drive in smbios_data.smbios_dictionary[self.model]["Stock Storage"]:
if not self.constants.custom_model:
if self.computer.third_party_sata_ssd is True:
print("- Adding SATA Hibernation Patch")
self.config["Kernel"]["Quirks"]["ThirdPartyDrives"] = True
break
else:
print("- Adding SATA Hibernation Patch")
self.config["Kernel"]["Quirks"]["ThirdPartyDrives"] = True
break
# DEBUG Settings
if self.constants.verbose_debug is True:

View File

@@ -7,6 +7,7 @@ import binascii
import enum
import itertools
import subprocess
import plistlib
from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional, Type, Union
@@ -339,6 +340,7 @@ class Computer:
oclp_version: Optional[str] = None
opencore_version: Optional[str] = None
bluetooth_chipset: Optional[str] = None
third_party_sata_ssd: Optional[bool] = False
@staticmethod
def probe():
@@ -351,6 +353,7 @@ class Computer:
computer.smbios_probe()
computer.cpu_probe()
computer.bluetooth_probe()
computer.sata_disk_probe()
return computer
def gpu_probe(self):
@@ -475,3 +478,26 @@ class Computer:
self.bluetooth_chipset = "BRCM20702 Hub"
elif "Bluetooth":
self.bluetooth_chipset = "Generic"
def sata_disk_probe(self):
# Get all SATA Controllers/Disks from 'system_profiler SPSerialATADataType'
# Determine whether SATA SSD is present and Apple-made
sp_sata_data = plistlib.loads(subprocess.run(f"system_profiler SPSerialATADataType -xml".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
for root in sp_sata_data:
for ahci_controller in root["_items"]:
# Each AHCI controller will have its own entry
# Skip entries that are AHCI PCIe controllers
# Apple's AHCI PCIe controller will report 'PCI' interconnect
if ahci_controller["spsata_physical_interconnect"] == "SATA":
# Note: 'spsata_physical_interconnect' was not introduced till 10.9
for port in ahci_controller["_items"]:
try:
if port["spsata_medium_type"] == "Solid State" and "apple" not in port["device_model"].lower():
self.third_party_sata_ssd = True
# Bail out of loop as we only need to know if there are any third-party SSDs present
break
except KeyError:
# SATA Optical Disk Drives don't report 'spsata_medium_type'
continue
print(f"SATA 3rd Party: {self.third_party_sata_ssd}")