async def _get_serial(self): ports = [] for devices in devinfo.DevInfo().resource_managers['I/O ports'].values(): for dev in devices: if not dev.name.startswith('uart'): continue ports.append({ 'name': dev.name, 'description': dev.desc, 'drivername': dev.drivername, 'location': dev.location, 'start': hex(dev.start), 'size': dev.size }) return ports
def generate_device_hints(context, current, config): output = re.sub(r'.*uart.*flags="0x10"\n', '', current.strip('\n')) dinfo = devinfo.DevInfo() uart = None for name, ports in dinfo.resource_managers['I/O ports'].items(): if not name.startswith('uart'): continue for port in ports: if config['serial_port'] == hex(port.start): uart = port break if uart is None: context.logger.warn('uart number not found for %s', config['serial_port']) return current unit = re.sub(r'[a-z]', '', uart.name) irq = dinfo.resource_managers['Interrupt request lines'].get(uart.name) if irq is None: context.logger.warn('irq not found for %s', config['serial_port']) return current irq = irq[0].start output = re.sub(r'hint\.uart\.%s.*\n' % unit, '', output) output += ''' hint.uart.{0}.at="isa" hint.uart.{0}.port="{1}" hint.uart.{0}.flags="0x10" hint.uart.{0}.irq="{2}" hint.uart.{0}.baud="{3}" '''.format(unit, config['serial_port'], irq, config['serial_speed']) return output