def get_device_date(self, urn): """ Return the Date number of the device Args: urn (String): Absolute reference to the component Returns (Integer) Date of the device or interconnect Raises: SDBError: User attempted to get the Date number of a synthesis record SDBError: User attempted to get the Date number of a URL record SDBError: User attempted to get the Date number of an integration record SDBError: User attempted to get the Date number of an interconnect """ component = self.get_component_from_urn(urn).get_component() if component.is_synthesis_record(): raise SDBError("Synthesis Record does not have an %s: %s" % ("Version", component)) if component.is_url_record(): raise SDBError("URL Record does not have an %s: %s" % ("Version", component)) return component.get_abi_version_minor_as_int()
def _verify_functional_device(self, component, error_name): if component.is_synthesis_record(): raise SDBError("Synthesis Record does not have an %s: %s" % (error_name, component)) if component.is_integration_record(): raise SDBError("Integration Record does not have an %s: %s" % (error_name, component)) if component.is_url_record(): raise SDBError("URL Record does not have an %s: %s" % (error_name, component))
def get_component_from_urn(self, urn): ls = urn.split("/") name_list = [] for l in ls: if len(l) > 0: name_list.append(l) root = self.som.get_root() #print "ls: %s" % str(ls) # If user set URN to "/" if len(name_list) == 0: return root if (len(name_list) == 1) and (name_list[0] != root.get_name()): raise SDBError("Could not find Component from URN: %s" % urn) return self._get_component_from_bus_urn(root, name_list[1:])
def get_device_abi_class(self, urn): """ Return the ABI class of the device Args: urn (String): Absolute reference to the component Returns (Integer) ABI Class of the device or interconnect Raises: SDBError: User attempted to get the ABI class of a synthesis record SDBError: User attempted to get the ABI class of a URL record SDBError: User attempted to get the ABI class of an integration record SDBError: User attempted to get the ABI class of an interconnect """ component = self.get_component_from_urn(urn).get_component() self._verify_functional_device(component, "ABI Class") if component.is_interconnect(): raise SDBError("Interconnects do not have an ABI Class: %s" % component) return component.get_abi_class_as_int()
def _parse_bus(n, som, bus, addr, base_addr, status): #The first element at this address is the interconnect sdb_data = Array('B') entity_rom = n.read(addr, SDB_ROM_RECORD_LENGTH / 4) sdb_data.extend(entity_rom) status.Verbose("Bus @ 0x%08X: Name: %s" % (addr, bus.get_name())) #print_sdb_rom(sdbc.convert_rom_to_32bit_buffer(entity_rom)) try: bus_entity = srp.parse_rom_element(entity_rom) except SDBError as e: error = "Error when parsing bus entry at base address: 0x%08X, addr: 0x%08X\n" % ( base_addr, addr) error += str(e) raise SDBError(error) if not bus_entity.is_interconnect(): raise SDBError("Rom data does not point to an interconnect") num_devices = bus_entity.get_number_of_records_as_int() status.Verbose("\tFound %d Devices" % num_devices) som.set_bus_component(bus, bus_entity) #print "Found bus: %s" % bus_entity.get_name() entity_size = [] entity_addr_start = [] for i in range(1, (num_devices + 2)): I = (i * (SDB_ROM_RECORD_LENGTH / 4)) + addr entity_rom = n.read(I, SDB_ROM_RECORD_LENGTH / 4) sdb_data.extend(entity_rom) entity = srp.parse_rom_element(entity_rom) #print_sdb_rom(sdbc.convert_rom_to_32bit_buffer(entity_rom)) end = long(entity.get_end_address_as_int()) start = long(entity.get_start_address_as_int()) entity_addr_start.append(start) entity_size.append(end - start) if entity.is_bridge(): #print "Found bridge" status.Verbose("Found Bridge:") sub_bus = som.insert_bus(root=bus, name=entity.get_name()) sub_bus_addr = entity.get_bridge_address_as_int() * 2 + base_addr sdb_data.extend( _parse_bus(n, som, sub_bus, sub_bus_addr, base_addr, status)) else: if entity.is_empty_record(): continue som.insert_component(root=bus, component=entity) status.Verbose( "Found device %s Type (0x%02X): %s" % (entity.get_name(), entity.get_abi_version_major_as_int(), device_manager.get_device_name_from_id( entity.get_abi_version_major_as_int()))) #print_sdb_rom(sdbc.convert_rom_to_32bit_buffer(entity_rom)) #Calculate Spacing spacing = 0 prev_start = None prev_size = None for i in range(num_devices): size = entity_size[i] start_addr = entity_addr_start[i] if prev_start is None: prev_size = size prev_start = start_addr continue potential_spacing = (start_addr - prev_start) if potential_spacing > prev_size: if potential_spacing > 0 and spacing == 0: spacing = potential_spacing if spacing > potential_spacing: spacing = potential_spacing prev_size = size prev_start = start_addr som.set_child_spacing(bus, spacing) return sdb_data