def find_urn_from_device_type(self, device_name, sub_type = None, abi_class = 0): """ Returns a list of SDB components that reference all the criteria the user specified Args: device_type (String): Type of device to find, 'gpio' or 'uart' can be searched for device_sub_type (None, Integer): a number to identify one version of the device and another abi_class (None, Integer): A number identifying the class Returns (List of Strings): a list of sdb components URNs Raises: None """ abi_major = 0 self.s.Verbose("ABI Class == %d" % abi_class) try: abi_major = device_manager.get_device_id_from_name(device_name) except SDBError as ex: return [] #print "abi major: %d" % abi_major return self.find_urn_from_abi(abi_class, abi_major = abi_major, abi_minor = sub_type)
def find_urn_from_device_type(self, device_name, sub_type=None, abi_class=0): """ Returns a list of SDB components that reference all the criteria the user specified Args: device_type (String): Type of device to find, 'gpio' or 'uart' can be searched for device_sub_type (None, Integer): a number to identify one version of the device and another abi_class (None, Integer): A number identifying the class Returns (List of Strings): a list of sdb components URNs Raises: None """ abi_major = 0 self.s.Verbose("ABI Class == %d" % abi_class) try: abi_major = device_manager.get_device_id_from_name(device_name) except SDBError as ex: return [] #print "abi major: %d" % abi_major return self.find_urn_from_abi(abi_class, abi_major=abi_major, abi_minor=sub_type)
def find_urn_from_abi(self, abi_class = 0, abi_major = None, abi_minor = None): """ Returns a list of SDB components that reference all the criteria the user specified Args: abi_class (None, Integer): Application Binary Interface Class, currently most components use '0' as the class is not defined abi_major (None, Integer): Application Binary Interface Major Number the current list of abi_major numbers can be found using the nysa command line tool ('nysa devices') abi_minor (None, Integer): Applicatoin Binary Interface Minor Number this is an identification within the major number, used to distinguish one version of a device from another Returns (List of Strings): a list of sdb components URNs Raises: None """ l = [] urns = self.get_all_components_as_urns() if isinstance(abi_major, str): abi_major = device_manager.get_device_id_from_name(abi_major) for urn in urns: if self.is_bus(urn): continue abi_class_test = self.get_device_abi_class(urn) abi_major_test = self.get_device_abi_major(urn) abi_minor_test = self.get_device_abi_minor(urn) if abi_class is not None: if abi_class_test != abi_class: continue if abi_major is not None: if abi_major_test != abi_major: continue if abi_minor is not None: if abi_minor_test != abi_minor: continue #l.append(self.get_component_from_urn(urn).get_component()) l.append(urn) return l
def find_urn_from_abi(self, abi_class=0, abi_major=None, abi_minor=None): """ Returns a list of SDB components that reference all the criteria the user specified Args: abi_class (None, Integer): Application Binary Interface Class, currently most components use '0' as the class is not defined abi_major (None, Integer): Application Binary Interface Major Number the current list of abi_major numbers can be found using the nysa command line tool ('nysa devices') abi_minor (None, Integer): Applicatoin Binary Interface Minor Number this is an identification within the major number, used to distinguish one version of a device from another Returns (List of Strings): a list of sdb components URNs Raises: None """ l = [] urns = self.get_all_components_as_urns() if isinstance(abi_major, str): abi_major = device_manager.get_device_id_from_name(abi_major) for urn in urns: if self.is_bus(urn): continue abi_class_test = self.get_device_abi_class(urn) abi_major_test = self.get_device_abi_major(urn) abi_minor_test = self.get_device_abi_minor(urn) if abi_class is not None: if abi_class_test != abi_class: continue if abi_major is not None: if abi_major_test != abi_major: continue if abi_minor is not None: if abi_minor_test != abi_minor: continue #l.append(self.get_component_from_urn(urn).get_component()) l.append(urn) return l
def is_memory_device(self, urn): memory_major = device_manager.get_device_id_from_name("memory") return self.get_device_abi_major(urn) == memory_major
def find_device_from_driver(self, driver): """ Returns a list of SDB components that reference all the criteria the user specified Args: device (Driver Object): Type of device to find, a subclass of the driver object Returns (List of Strings): a list of sdb components URNs Raises: None """ l = [] if self.som is None: self.read_sdb() urns = self.get_all_components_as_urns() driver_abi_class = driver.get_abi_class() driver_abi_major = driver.get_abi_major() driver_abi_minor = driver.get_abi_minor() driver_vendor_id = driver.get_vendor_id() driver_device_id = driver.get_device_id() driver_version = driver.get_version() driver_date = driver.get_date() if isinstance(driver_abi_major, str): driver_abi_major= device_manager.get_device_id_from_name(driver_abi_major) for urn in urns: if self.is_bus(urn): continue device_abi_class = self.get_device_abi_class(urn) device_abi_major = self.get_device_abi_major(urn) device_abi_minor = self.get_device_abi_minor(urn) device_vendor_id = self.get_device_vendor_id(urn) device_device_id = self.get_device_product_id(urn) device_version = self.get_device_version(urn) device_date = self.get_device_date(urn) if driver_abi_class is not None: if driver_abi_class != device_abi_class: continue if driver_abi_major is not None: if driver_abi_major != device_abi_major: continue if driver_abi_minor is not None: if driver_abi_minor != device_abi_minor: continue if driver_vendor_id is not None: if driver_vendor_id != device_vendor_id: continue if driver_device_id is not None: if driver_device_id != device_device_id: continue if driver_version is not None: if driver_version != device_version: continue if driver_date is not None: if driver_date != device_date: continue l.append(urn) return l
def find_device_from_driver(self, driver): """ Returns a list of SDB components that reference all the criteria the user specified Args: device (Driver Object): Type of device to find, a subclass of the driver object Returns (List of Strings): a list of sdb components URNs Raises: None """ l = [] if self.som is None: self.read_sdb() urns = self.get_all_components_as_urns() driver_abi_class = driver.get_abi_class() driver_abi_major = driver.get_abi_major() driver_abi_minor = driver.get_abi_minor() driver_vendor_id = driver.get_vendor_id() driver_device_id = driver.get_device_id() driver_version = driver.get_version() driver_date = driver.get_date() if isinstance(driver_abi_major, str): driver_abi_major = device_manager.get_device_id_from_name( driver_abi_major) for urn in urns: if self.is_bus(urn): continue device_abi_class = self.get_device_abi_class(urn) device_abi_major = self.get_device_abi_major(urn) device_abi_minor = self.get_device_abi_minor(urn) device_vendor_id = self.get_device_vendor_id(urn) device_device_id = self.get_device_product_id(urn) device_version = self.get_device_version(urn) device_date = self.get_device_date(urn) if driver_abi_class is not None: if driver_abi_class != device_abi_class: continue if driver_abi_major is not None: if driver_abi_major != device_abi_major: continue if driver_abi_minor is not None: if driver_abi_minor != device_abi_minor: continue if driver_vendor_id is not None: if driver_vendor_id != device_vendor_id: continue if driver_device_id is not None: if driver_device_id != device_device_id: continue if driver_version is not None: if driver_version != device_version: continue if driver_date is not None: if driver_date != device_date: continue l.append(urn) return l