From ecf4e5f627e26956e899dfbcfbb3aed8dcf60466 Mon Sep 17 00:00:00 2001 From: Nathaniel Mitchell Date: Wed, 4 Feb 2026 11:22:06 -0800 Subject: [PATCH] Add functionality to filter devices by enabled status Signed-off-by: Nathaniel Mitchell --- chipsec/cfg/parsers/ip/pci_device.py | 4 ++++ chipsec/library/device.py | 24 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/chipsec/cfg/parsers/ip/pci_device.py b/chipsec/cfg/parsers/ip/pci_device.py index 8502150c..914fbf4f 100644 --- a/chipsec/cfg/parsers/ip/pci_device.py +++ b/chipsec/cfg/parsers/ip/pci_device.py @@ -294,6 +294,10 @@ class PCIConfig(GenericConfig): return inst return None + def is_enabled(self) -> bool: + """Check if any PCI instance is enabled.""" + return bool(self.get_enabled_instances()) + def validate_pci_config(self) -> bool: """ Validate PCI-specific configuration. diff --git a/chipsec/library/device.py b/chipsec/library/device.py index b36955e3..78be5ed0 100644 --- a/chipsec/library/device.py +++ b/chipsec/library/device.py @@ -27,6 +27,7 @@ in the CHIPSEC framework, including PCI devices and I/O spaces. from typing import Any, List, Optional, Tuple from chipsec.cfg.parsers.ip.pci_device import PCIConfig +from chipsec.library.register import ObjList class Device: @@ -66,18 +67,31 @@ class Device: def get_list_by_name(self, device_name: str) -> List[Any]: """ - Get list of device objects by name. + Get list of enabled device objects by name. + + Args: + device_name: Name of the device to retrieve objects for + + Returns: + List of enabled device objects matching the name + """ + objList = self._get_defined_list(device_name) + return objList.filter_enabled() + + def _get_defined_list(self, device_name: str) -> List[Any]: + """ + Get list of all defined device objects by name. Args: device_name: Name of the device to retrieve objects for Returns: - List of device objects matching the name + List of all defined device objects matching the name """ devices = self.cs.Cfg.get_objlist(device_name) - objlist = [] + objlist = ObjList() [objlist.extend(ip.obj) for ip in devices] - return objlist + return objlist def is_defined(self, device_name: str) -> bool: """ @@ -89,7 +103,7 @@ class Device: Returns: True if device is defined, False otherwise """ - return len(self.get_list_by_name(device_name)) > 0 + return len(self._get_defined_list(device_name)) > 0 def get_bus(self, device_name: str) -> List[int]: """