This patch refactors big chunks of the memory subsystem code.
Most of all, it does away with the the design being based around the raw pointer
type "*const Page". While raw pointers to an actual page seemed like a
compelling idea, in practice it turned out difficult. Rust feels a bit
inconsistent with respect to raw pointers. While it is safe to create them out
of nowhere (only dereferencing is unsafe), it gets weird when multi-threading
comes into picture.
For example, wrapping them into synchronization primitives caused issues because
they don't implement Send. For this reason, we switch to the PageAddress type
which is based on usize, which makes things a lot easier.
Other changes/benefits include:
- Gets rid of unsafe code in the removed PageSlice type.
- Decouple the translation table code and MMIO VA allocation.
- For the translation table tool, make better use of what the ELF format already
provides with respect to memory segmentation and translation. For example, the
tool now queries the ELF file for VA->PA translations and other segment
attributes. This has also the added benefit of reduced BSP code and more
generic code in the tool.
- Packs rbelftools in the Docker image now (used by translation table tool).
- In tutorials 14/15/16, rearrange the PA and VA layout.
It is too risky to rely on the compiler to not insert any operations using the
stack.
Having a stack-setting call in Rust using the cortex-a crate as the first action
in a Rust-only _start() function does not work if you're subsequently using the
stack, because the compiler often inserts the operations to make room on the
stack to prepare a function call BEFORE the call to set the stack, which crashes
the boot process.
Hence, keep on using a small piece of assembly boot code throughout.
- Don't wildcard-import from arch modules. Make it explicit.
- Put translation table code into its own module.
- Put boot code in boot.rs instead of cpu.rs
- Other minor changes, most memory subsystem.
The GCC versions of `objdump` and `nm` seem to have better out-of-the-box
support (for AArch64). Demangling works better, and instructions in objdump are
presented as 4 bytes instead of 4 * 1 bytes, which helps a lot.
Hence, switch to the GCC versions for now until LLVM has caught up.
Detect if we run on Linux. If so, dockerize Makefile targets that need access to
USB devices. If we run on anything else, attempt to execute natively.
This will enable non-Linux Unixes like macOS to run the chainboot target, given
they install the needed Ruby dependencies.
`rustup target add aarch64-unknown-none-softfloat` is now a thing.
It is no longer required to build rust-std on-demand with `xbuild`.
This reduces compile-times significantly.