device_probe: Add leaf feature detection

This commit is contained in:
Mykola Grymalyuk
2022-09-27 08:43:38 -06:00
parent 1d821b993b
commit 8cc87980d1
2 changed files with 45 additions and 15 deletions
+9
View File
@@ -18,6 +18,7 @@ from data import pci_data
class CPU:
name: str
flags: list[str]
leafs: list[str]
@dataclass
@@ -715,8 +716,16 @@ class Computer:
self.cpu = CPU(
subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(),
subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" "),
self.cpu_get_leafs(),
)
def cpu_get_leafs(self):
leafs = []
result = subprocess.run("sysctl machdep.cpu.leaf7_features".split(), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
if result.returncode == 0:
leafs.append(result.stdout.decode().partition(": ")[2].strip().split(" "))
return leafs
def bluetooth_probe(self):
usb_data: str = subprocess.run("system_profiler SPUSBDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if "BRCM20702 Hub" in usb_data: