diff --git a/src/bare-metal/aps/better-uart/using.md b/src/bare-metal/aps/better-uart/using.md index c574f7e0..5089224c 100644 --- a/src/bare-metal/aps/better-uart/using.md +++ b/src/bare-metal/aps/better-uart/using.md @@ -9,6 +9,8 @@ bytes.
+* As in the [inline assembly](../inline-assembly.md) example, this `main` function is called from our + entry point code in `entry.S`. See the speaker notes there for details. * Run the example in QEMU with `make qemu` under `src/bare-metal/aps/examples`.
diff --git a/src/bare-metal/aps/inline-assembly.md b/src/bare-metal/aps/inline-assembly.md index 7224d892..845d12b6 100644 --- a/src/bare-metal/aps/inline-assembly.md +++ b/src/bare-metal/aps/inline-assembly.md @@ -17,6 +17,13 @@ to make an HVC to tell the firmware to powe * The `0 => _` syntax means initialise the register to 0 before running the inline assembly code, and ignore its contents afterwards. We need to use `inout` rather than `in` because the call could potentially clobber the contents of the registers. +* This `main` function needs to be `#[no_mangle]` and `extern "C"` because it is called from our + entry point in `entry.S`. +* `_x0`–`_x3` are the values of registers `x0`–`x3`, which are conventionally used by the bootloader + to pass things like a pointer to the device tree. According to the standard aarch64 calling + convention (which is what `extern "C"` specifies to use), registers `x0`–`x7` are used for the + first 8 arguments passed to a function, so `entry.S` doesn't need to do anything special except + make sure it doesn't change these registers. * Run the example in QEMU with `make qemu_psci` under `src/bare-metal/aps/examples`.