Skip to content

Commit

Permalink
Cleanup and clarify "arm11" usage despite ARMv6 removal (#40)
Browse files Browse the repository at this point in the history
* python: unify architecture dictionaries

- avoid redundancy and merge this into one dict.
- remove internal helper normalise_architecture()

Signed-off-by: Axel Heider <[email protected]>

* doc: clarify "arm11" usage despite ARMv6 removal

Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
axel-h authored May 29, 2022
1 parent 400076e commit 752151b
Showing 1 changed file with 23 additions and 34 deletions.
57 changes: 23 additions & 34 deletions python-capdl-tool/capdl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,46 +239,35 @@ def ipc_buffer_size(self):
return 512


def normalised_map():
return {
'aarch32': 'aarch32',
'aarch64': 'aarch64',
'arm': 'aarch32',
'arm11': 'aarch32',
'arm_hyp': 'arm_hyp',
'ia32': 'ia32',
'x86': 'ia32',
'x86_64': 'x86_64',
'riscv64': 'riscv64',
'riscv32': 'riscv32'
}
# Support for ARMv6 has been removed from seL4 in early 2022. However, support
# for "arm11" is kept here, because this name is used in the CapDL specification
# for AARCH32 configurations. Updating this is a low priority task, because it
# is a lot of work with not much gain (except cleaning up legacy), Also, keeping
# the name there isn't causing any issues.
CAPDL_SUPPORTED_ARCHITECTURES = {
# <name>: [arch_obj_ctor, <alias_list>]
'aarch32': [lambda: ARM32Arch(), ['arm', 'arm11']],
'arm_hyp': [lambda: ARM32Arch(hyp=True), []],
'aarch64': [lambda: AARCH64Arch(), []],
'ia32': [lambda: IA32Arch(), ['x86']],
'x86_64': [lambda: X64Arch(), []],
'riscv32': [lambda: RISCV32Arch(), []],
'riscv64': [lambda: RISCV64Arch(), []],
}


def valid_architectures():
return set(normalised_map().values())


def normalise_architecture(arch):
try:
return normalised_map()[arch.lower()]
except KeyError:
raise Exception('invalid architecture: %s' % arch)
return set(CAPDL_SUPPORTED_ARCHITECTURES.keys())


def lookup_architecture(arch):
arch_map = {
'aarch32': ARM32Arch(),
'aarch64': AARCH64Arch(),
'arm_hyp': ARM32Arch(hyp=True),
'ia32': IA32Arch(),
'x86_64': X64Arch(),
'riscv64': RISCV64Arch(),
'riscv32': RISCV32Arch()
}
try:
return arch_map[normalise_architecture(arch)]
except KeyError:
raise Exception('invalid architecture: %s' % arch)
arch_normalised = arch.lower()
for name, ctx in CAPDL_SUPPORTED_ARCHITECTURES.items():
arch_alias_list = ctx[1]
if (arch_normalised == name) or (arch_normalised in arch_alias_list):
arch_obj_ctor = ctx[0]
return arch_obj_ctor()
raise Exception('invalid architecture: %s' % arch)


def round_down(n, alignment=FRAME_SIZE):
Expand Down

0 comments on commit 752151b

Please sign in to comment.