def get_kernel_devices(tree: FdtParser, hw_yaml: HardwareYaml) -> (List, Dict): ''' Given a device tree and a set of rules, returns a tuple (groups, offsets). Groups is a list of 'KernelRegionGroups', each of which represents a single contiguous region of memory that is associated with a device. Offsets is a dict of offset -> label, where label is the name given to the kernel for that address (e.g. SERIAL_PPTR) and offset is the offset from KDEV_BASE at which it's mapped. ''' kernel_devices = tree.get_kernel_devices() kernel_offset = 0 groups = [] for dev in kernel_devices: dev_rule = hw_yaml.get_rule(dev) new_regions = dev_rule.get_regions(dev) for reg in new_regions: if reg in groups: other = groups[groups.index(reg)] other.take_labels(reg) else: groups.append(reg) offsets = {} for group in groups: kernel_offset = group.set_kernel_offset(kernel_offset) offsets.update(group.get_labelled_addresses()) return (groups, offsets)
def get_kernel_devices(tree: fdt.FdtParser, rules: rule.HardwareYaml): kernel_devices = tree.get_kernel_devices() groups = [] for dev in kernel_devices: rule = rules.get_rule(dev) groups += rule.get_regions(dev) return groups
def get_kernel_devices(tree: FdtParser, hw_yaml: HardwareYaml): kernel_devices = tree.get_kernel_devices() groups = [] for dev in kernel_devices: rule = hw_yaml.get_rule(dev) groups += rule.get_regions(dev) return groups
def get_interrupts(tree: FdtParser, hw_yaml: HardwareYaml) -> List: ''' Get dict of interrupts, {label: KernelInterrupt} from the DT and hardware rules. ''' kernel_devices = tree.get_kernel_devices() irqs = [] for dev in kernel_devices: dev_rule = hw_yaml.get_rule(dev) if len(dev_rule.interrupts.items()) > 0: irqs += dev_rule.get_interrupts(tree, dev) ret = {} for irq in irqs: if irq.label in ret: if irq.prio > ret[irq.label].prio: ret[irq.label] = irq else: ret[irq.label] = irq ret = list(ret.values()) ret.sort(key=lambda a: a.label) return ret
def get_interrupts(tree: fdt.FdtParser, rules: rule.HardwareYaml): ''' Get dict of interrupts, {label: KernelInterrupt} from the DT and hardware rules. ''' kernel_devices = tree.get_kernel_devices() irqs = [] for dev in kernel_devices: dev_rule = rules.get_rule(dev) print(f"interrupts for device {dev.path}") irqs += dev_rule.get_interrupts(tree, dev) ret = {} for irq in irqs: if irq.label in ret: if irq.prio > ret[irq.label].prio: ret[irq.label] = irq else: ret[irq.label] = irq ret = list(ret.values()) ret.sort(key=lambda a: a.label) return ret