[docs] add section "crt0 early boot trap handler"

This commit is contained in:
stnolting 2023-10-30 21:34:41 +01:00
parent e3bb725f8e
commit be6ba95e4b

View file

@ -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