Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/hardware.py
diff options
context:
space:
mode:
authorcodefiles <11915375+codefiles@users.noreply.github.com>2023-09-24 05:18:52 -0400
committerGitHub <noreply@github.com>2023-09-24 19:18:52 +1000
commit9e3e4a5df5b6ff106bcbf30273cdb0de9af7e02e (patch)
tree6f04e351797b9e94d5a24e196b8669e97dca292e /archinstall/lib/hardware.py
parent360a1b4f337e45b2dc26c9af067e53fbd364231f (diff)
Refactor microcode (#2099)
Diffstat (limited to 'archinstall/lib/hardware.py')
-rw-r--r--archinstall/lib/hardware.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 85f903e1..56d3bc7b 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -10,6 +10,32 @@ from .networking import list_interfaces, enrich_iface_types
from .output import debug
+class CpuVendor(Enum):
+ AuthenticAMD = 'amd'
+ GenuineIntel = 'intel'
+ _Unknown = 'unknown'
+
+ @classmethod
+ def get_vendor(cls, name: str) -> 'CpuVendor':
+ if vendor := getattr(cls, name, None):
+ return vendor
+ else:
+ debug(f"Unknown CPU vendor '{name}' detected.")
+ return cls._Unknown
+
+ def _has_microcode(self) -> bool:
+ match self:
+ case CpuVendor.AuthenticAMD | CpuVendor.GenuineIntel:
+ return True
+ case _:
+ return False
+
+ def get_ucode(self) -> Optional[Path]:
+ if self._has_microcode():
+ return Path(self.value + '-ucode.img')
+ return None
+
+
class GfxPackage(Enum):
IntelMediaDriver = 'intel-media-driver'
LibvaIntelDriver = 'libva-intel-driver'
@@ -180,8 +206,10 @@ class SysInfo:
return any('intel' in x.lower() for x in SysInfo._graphics_devices())
@staticmethod
- def cpu_vendor() -> Optional[str]:
- return _sys_info.cpu_info.get('vendor_id', None)
+ def cpu_vendor() -> Optional[CpuVendor]:
+ if vendor := _sys_info.cpu_info.get('vendor_id'):
+ return CpuVendor.get_vendor(vendor)
+ return None
@staticmethod
def cpu_model() -> Optional[str]: