def run(tree: fdt.FdtParser, hardware: rule.HardwareYaml, config: config.Config, args: argparse.Namespace): if not args.header_out: raise ValueError( 'You need to specify a header-out to use c header output') physical_memory, reserved, physBase = memory.get_physical_memory( tree, config) kernel_regions, kernel_macros = get_kernel_devices(tree, hardware) kernel_irqs = get_interrupts(tree, hardware) template = Environment(loader=BaseLoader, trim_blocks=True, lstrip_blocks=True).from_string(HEADER_TEMPLATE) template_args = dict( builtins.__dict__, **{ 'args': args, 'kernel_irqs': kernel_irqs, 'kernel_macros': kernel_macros, 'kernel_regions': kernel_regions, 'physBase': physBase, 'physical_memory': physical_memory, }) data = template.render(template_args) args.header_out.write(data) args.header_out.close()
def run(tree: fdt.FdtParser, hardware: rule.HardwareYaml, config: config.Config, args: argparse.Namespace): if not args.yaml_out: raise ValueError( 'you need to provide a yaml-out to use the yaml output method') phys_mem, reserved, _ = memory.get_physical_memory(tree, config) kernel_devs = get_kernel_devices(tree, hardware) dev_mem = memory.get_addrspace_exclude( list(reserved) + phys_mem + kernel_devs, config) yaml.add_representer( int, lambda dumper, data: yaml.ScalarNode('tag:yaml.org,2002:int', hex(data))) yaml_obj = { 'devices': [{ 'start': r.base, 'end': r.base + r.size } for r in dev_mem if r.size > 0], 'memory': [{ 'start': r.base, 'end': r.base + r.size } for r in phys_mem if r.size > 0] } yaml.dump(yaml_obj, args.yaml_out) args.yaml_out.close()