From be6ba95e4b4ed103d8abe7fc93a6cf234a755904 Mon Sep 17 00:00:00 2001 From: stnolting <22944758+stnolting@users.noreply.github.com> Date: Mon, 30 Oct 2023 21:34:41 +0100 Subject: [PATCH] [docs] add section "crt0 early boot trap handler" --- docs/datasheet/software.adoc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/datasheet/software.adoc b/docs/datasheet/software.adoc index 14c88894a..938bb0396 100644 --- a/docs/datasheet/software.adoc +++ b/docs/datasheet/software.adoc @@ -499,7 +499,7 @@ The `crt0.S` start-up performs the following operations: [start=1] . Clear <<_mstatus>>. . Clear <<_mie>> disabling all interrupt sources. -. Install an early-boot dummy trap handler to <<_mtvec>>. +. Install an <<_early_trap_handler>> to <<_mtvec>>. . Initialize the global pointer `gp` and the stack pointer `sp` according to the <<_ram_layout>> provided by the linker script. . Initialize all integer register `x1 - x31` (only `x1 - x15` if the `E` CPU extension is enabled). . Setup `.data` section to configure initialized variables. @@ -519,6 +519,22 @@ The bootloader uses the same start-up code as any "usual" application. However, `crt0` for the bootloader (like calling constructors and destructors). See the `crt0` source code for more information. +:sectnums: +===== Early Trap Handler + +The start-up code provides a very basic trap handler for the early boot stage. This handler does nothing but trying to move +on to the next linear instruction whenever an interrupt or synchronous exception is encountered. + +This simple trap handler does not interact with the stack at all as it just uses a single register that is backup-ed +using the <<_mscratch>> CSR. Furthermore, the information if the trap-causing instruction is compressed or uncompressed +is **not** determined by loading the instruction from memory. Instead, the transformed instruction word is read from the +<<_mtinst>> CSRs. These two features allow the trap handler to execute with minimal latency and high robustness. + +[NOTE] +The early-trap handler should be replaced by a more capable / informative one as soon as the application software is started +(for example by using the <<_neorv32_runtime_environment>>). + + :sectnums: ===== After-Main Handler