forked from Imagelibrary/seL4
committed by
Gerwin Klein
parent
88be9c1f7c
commit
e75d22bedd
@@ -5,8 +5,7 @@
|
||||
#
|
||||
|
||||
import functools
|
||||
|
||||
import hardware.utils as utils
|
||||
import hardware
|
||||
|
||||
|
||||
@functools.total_ordering
|
||||
@@ -87,7 +86,7 @@ class Region:
|
||||
|
||||
def align_base(self, align_bits):
|
||||
''' align this region up to a given number of bits '''
|
||||
new_base = utils.align_up(self.base, align_bits)
|
||||
new_base = hardware.utils.align_up(self.base, align_bits)
|
||||
diff = new_base - self.base
|
||||
if self.size < diff:
|
||||
raise ValueError(
|
||||
@@ -101,8 +100,8 @@ class Region:
|
||||
''' align this region's size to a given number of bits.
|
||||
will move the base address down and the region's size
|
||||
up '''
|
||||
new_base = utils.align_down(self.base, align_bits)
|
||||
new_size = utils.align_up(self.size, align_bits)
|
||||
new_base = hardware.utils.align_down(self.base, align_bits)
|
||||
new_size = hardware.utils.align_up(self.size, align_bits)
|
||||
return Region(new_base, new_size, self.owner)
|
||||
|
||||
def make_chunks(self, chunksz):
|
||||
|
||||
@@ -9,8 +9,11 @@ import argparse
|
||||
import builtins
|
||||
import jinja2
|
||||
from typing import Dict, List
|
||||
from hardware import config, fdt
|
||||
from hardware.utils import memory, rule
|
||||
import hardware
|
||||
from hardware.config import Config
|
||||
from hardware.fdt import FdtParser
|
||||
from hardware.utils.rule import HardwareYaml
|
||||
|
||||
|
||||
HEADER_TEMPLATE = '''/*
|
||||
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
|
||||
@@ -119,7 +122,7 @@ static const p_region_t BOOT_RODATA avail_p_regs[] = {
|
||||
'''
|
||||
|
||||
|
||||
def get_kernel_devices(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml) -> (List, Dict):
|
||||
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).
|
||||
|
||||
@@ -150,7 +153,7 @@ def get_kernel_devices(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml) -> (List
|
||||
return (groups, offsets)
|
||||
|
||||
|
||||
def get_interrupts(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml) -> List:
|
||||
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()
|
||||
|
||||
@@ -196,11 +199,11 @@ def create_c_header_file(args, kernel_irqs: List, kernel_macros: Dict,
|
||||
outputStream.write(data)
|
||||
|
||||
|
||||
def run(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml, config: config.Config, args: argparse.Namespace):
|
||||
def run(tree: FdtParser, hw_yaml: HardwareYaml, 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)
|
||||
physical_memory, reserved, physBase = hardware.utils.memory.get_physical_memory(tree, config)
|
||||
kernel_regions, kernel_macros = get_kernel_devices(tree, hw_yaml)
|
||||
|
||||
create_c_header_file(
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
''' generate a text file with matched compatible strings from the device tree '''
|
||||
import argparse
|
||||
|
||||
from hardware import config, fdt
|
||||
from hardware.utils import rule
|
||||
from hardware.config import Config
|
||||
from hardware.fdt import FdtParser
|
||||
from hardware.utils.rule import HardwareYaml
|
||||
|
||||
|
||||
def run(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml, config: config.Config,
|
||||
def run(tree: FdtParser, hw_yaml: HardwareYaml, config: Config,
|
||||
args: argparse.Namespace):
|
||||
if not args.compat_strings_out:
|
||||
raise ValueError('You need to specify a compat-strings-out to use compat strings output')
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
import argparse
|
||||
import yaml
|
||||
from typing import List
|
||||
from hardware import config, fdt
|
||||
from hardware.utils import memory, rule
|
||||
from hardware.memory import Region
|
||||
import hardware
|
||||
from hardware.config import Config
|
||||
from hardware.fdt import FdtParser
|
||||
from hardware.utils.rule import HardwareYaml
|
||||
|
||||
|
||||
def make_yaml_list_of_regions(regions) -> List:
|
||||
@@ -39,7 +40,7 @@ def create_yaml_file(dev_mem, phys_mem, outputStream):
|
||||
yaml.dump(yaml_obj, outputStream)
|
||||
|
||||
|
||||
def get_kernel_devices(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml):
|
||||
def get_kernel_devices(tree: FdtParser, hw_yaml: HardwareYaml):
|
||||
kernel_devices = tree.get_kernel_devices()
|
||||
|
||||
groups = []
|
||||
@@ -50,14 +51,15 @@ def get_kernel_devices(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml):
|
||||
return groups
|
||||
|
||||
|
||||
def run(tree: fdt.FdtParser, hw_yaml: rule.HardwareYaml, config: config.Config,
|
||||
def run(tree: FdtParser, hw_yaml: HardwareYaml, 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)
|
||||
phys_mem, reserved, _ = hardware.utils.memory.get_physical_memory(tree, config)
|
||||
kernel_devs = get_kernel_devices(tree, hw_yaml)
|
||||
dev_mem = memory.get_addrspace_exclude(list(reserved) + phys_mem + kernel_devs, config)
|
||||
dev_mem = hardware.utils.memory.get_addrspace_exclude(
|
||||
list(reserved) + phys_mem + kernel_devs, config)
|
||||
|
||||
create_yaml_file(dev_mem, phys_mem, args.yaml_out)
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
from typing import List, Set
|
||||
|
||||
import hardware.utils as utils
|
||||
|
||||
import hardware
|
||||
from hardware.config import Config
|
||||
from hardware.device import WrappedNode
|
||||
from hardware.fdt import FdtParser
|
||||
@@ -99,7 +98,8 @@ def get_addrspace_exclude(regions: List[Region], config: Config):
|
||||
ret = set()
|
||||
# We can't create untypeds that exceed the addrspace_max, so we round down to the smallest
|
||||
# untyped size alignment so that the kernel will be able to turn the entire range into untypeds.
|
||||
as_max = utils.align_down(config.addrspace_max, config.get_smallest_kernel_object_alignment())
|
||||
as_max = hardware.utils.align_down(config.addrspace_max,
|
||||
config.get_smallest_kernel_object_alignment())
|
||||
ret.add(Region(0, as_max))
|
||||
|
||||
for reg in regions:
|
||||
|
||||
@@ -10,10 +10,13 @@ import argparse
|
||||
import logging
|
||||
import yaml
|
||||
|
||||
from hardware import config, fdt
|
||||
import hardware
|
||||
from hardware.config import Config
|
||||
from hardware.fdt import FdtParser
|
||||
from hardware.outputs import c_header, compat_strings, yaml as yaml_out, elfloader
|
||||
from hardware.utils.rule import HardwareYaml
|
||||
|
||||
|
||||
OUTPUTS = {
|
||||
'c_header': c_header,
|
||||
'compat_strings': compat_strings,
|
||||
@@ -46,8 +49,8 @@ def add_task_args(outputs: dict, parser: argparse.ArgumentParser):
|
||||
def main(args: argparse.Namespace):
|
||||
''' Parse the DT and hardware config YAML and run each
|
||||
selected output method. '''
|
||||
cfg = config.get_arch_config(args.arch, args.addrspace_max)
|
||||
parsed_dt = fdt.FdtParser(args.dtb)
|
||||
cfg = hardware.config.get_arch_config(args.arch, args.addrspace_max)
|
||||
parsed_dt = FdtParser(args.dtb)
|
||||
rules = yaml.load(args.hardware_config, Loader=yaml.FullLoader)
|
||||
schema = yaml.load(args.hardware_schema, Loader=yaml.FullLoader)
|
||||
validate_rules(rules, schema)
|
||||
|
||||
Reference in New Issue
Block a user