rust-raspberrypi-OS-tutorials/01_wait_forever
2019-11-01 23:21:57 +01:00
..
.vscode Adapt tooling settings 2019-10-27 23:12:19 +01:00
src Actions: Add RPi4 build 2019-10-29 22:34:20 +01:00
Cargo.lock Add code for tutorial 01 2019-10-27 23:09:35 +01:00
Cargo.toml Actions: Add RPi4 build 2019-10-29 22:34:20 +01:00
kernel Built with new compiler version 2019-11-01 23:21:57 +01:00
kernel8.img Add code for tutorial 01 2019-10-27 23:09:35 +01:00
Makefile Actions: Add RPi4 build 2019-10-29 22:34:20 +01:00
README.md Update README.md 2019-10-27 23:12:36 +01:00

Tutorial 01 - Wait Forever

tl;dr

Project skeleton is set up; Code just halts all CPU cores executing the kernel code.

  • Toolchain: cargo xbuild tools (xrustc, xclippy) and the aarch64-unknown-none-softfloat target are used for building AArch64 bare-metal code.
  • Makefile targets:
    • doc: Generate documentation.
    • qemu: Run the kernel in QEMU
    • clippy
    • clean
    • readelf: Inspect the ELF output.
    • objdump: Inspect the assembly.
    • nm: Inspect the symbols.
  • Code is organized into kernel, arch and BSP (Board Support Package) parts.
    • Conditional compilation includes respective arch and BSP according to user-supplied arguments.
  • Custom link.ld linker script.
    • Load address at 0x80_000
    • Only .text section.
  • main.rs: Important inner attributes:
    • #![no_std], #![no_main]
  • Assembly _start() function that executes wfe (Wait For Event), halting all cores that are executing _start().
  • We (have to) define a #[panic_handler] function.
    • Just waits infinitely for a cpu event.

Give it a try

In the project folder, invoke QEMU and observe the CPU core spinning on wfe:

make qemu
[...]
IN: 
0x00080000:  d503205f  wfe      
0x00080004:  17ffffff  b        #0x80000