History log of /seL4-refos-master/seL4_tools/cmake-tool/helpers/platform_sift.py
Revision Date Author Comments
# 9f904ed2 06-Mar-2020 Gerwin Klein <gerwin.klein@data61.csiro.au>

convert license headers to SPDX

Includes license review of 3rd-party files, adding missing upstream
headers, and moving the UNSW OZPLB license into its own file rather
than replicating it in the header.


# c1d01151 05-Aug-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

elfloader: simplify and generalise interface

Migrate the `shoehorn` tool from a fragile command-line interface to a
more robust one. The existing one did not support platforms that didn't
include the DTB in the ELF-loader image, and did not support checksum
files for the kernel and rootserver ELF files (an advanced configuration
option). Now `shoehorn` takes only two operands: the platform YAML file
(as before) and the ELF-loader image ("archive.o"), not a list of the
image's contents. `shoehorn` now understands the structure of the
ELF-loader image: an ELF object file header prepended to a System V
ASCII CPIO archive without checksum.

Update ELF-loader CMakeLists.txt file to no longer require any knowledge
of the contents of the ELF-loader image for the purpose of calling
`shoehorn`; cmake simply passes it (and the platform YAML file) to the
tool.

Refactor and enhance `elf_sift` tool to support extracting ELF loadable
segment size information from a BinaryIO object; required since
`shoehorn` now reads CPIO archive entries into memory.

* cmake-tool/helpers/elf_sift.py:
+ Add notice of unstable API.
+ Rename `get_memory_size()` to `get_memory_usage_from_file()`.
+ ...and update its call site.
+ Add new function `get_memory_usage()`.
+ Make `get_memory_usage_from_file()` a context-managing wrapper
around `get_memory_usage()`.
+ Import `BinaryIO` symbol from `typing` module to support PEP 484
type hints.

* cmake-tool/helpers/platform_sift.py:
+ Use `safe_load()` method of PyYAML 5.1 and later since there doesn't
seem to be any reason to expect executable Python code to be present
in the hardware description files.
+ Rename `platform_file` and `yaml_file` variables to `*_filename` to
better document the fact that they are pathname/filespec strings.

* cmake-tool/helpers/shoehorn.py:
+ Add notice of unstable API.
+ Rewrite and improve usage message (and main docstring).
+ Flesh out diagnostic interface. Add `write()`, `debug()`, `die()`,
`notice()`, and `warn()` functions. Migrate call sites of
`sys.stderr.write()` to appropriate diagnostic functions.
+ Add new function `get_bytes()`. Returns an io.BytesIO object with
the contents of the given (CPIO) archive entry.
+ Add new function `get_cpio()`. Returns an io.BytesIO object with
the CPIO file contained in `payload_file` (the ELF-loader image).
+ Drop stale comments.
+ Update argument interface to support only `platform_yaml` and
`payload_file` operands.
+ Only perform DTB-based memory computations if a DTB is present.
+ Load ELF objects in CPIO archive into memory, and measure them with
`get_memory_usage()` from `elf_sift` instead of `get_memory_size()`.
+ Recognize checksum entries in CPIO archive (their names end in
".bin"), but issue a diagnostic instead of handling them. Right now
the rest of the build does not provide a mechanism for naming
rootserver checksum files such that they won't collide if multiple
rootservers are present.
+ Simplify variable naming and locality for better readability.
+ Simplify redundant Boolean expression.
+ Stop making an iterator out of an already-iterable list.
+ Update comments.
+ Improve the fatal diagnostic when the image cannot be fitted into
memory, directing the user where to look for the source of the
problem (i.e., they need to reconcile the size of the ELF-loader
image with the memory described as available in the platform YAML
file).
+ Rename `payload_file` variable to `payload_filename` to better
document the fact that it is a pathname/filespec string.

* elfloader-tool/CMakeLists.txt: Simplify; stop munging the list of CPIO
archive members, and just invoke `shoehorn` with two arguments: the
platform YAML file and the ELF-loader image ("archive.o").


# a90da0c2 27-Jun-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

platform_sift.py: let user specify C symbol names

Add command-line options to support user-specified names for the
generated C symbols (array length, array, and structure tag).


# caa4b9d0 13-Jun-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

platform_sift.py: add parser for platform_gen.yaml

cmake-tool/helpers/platform_sift.py: Report informatiom about memory
regions declared in input YAML file to standard output. Validate the
input and support optional emission of C syntax, with an example of
usage in the help message.

elfloader-tool/CMakeLists.txt: Invoke the above script and construct the
header file platform_info.h to house it. Add dependency on this file to
ensure it gets created. Anna Lyons contributed the placement of the
header file in the correct directory, some bits required to support
that, and made my CMake more idiomatic (less painful to read). Thanks,
Anna!