Skip to content

Commit

Permalink
[docs] add section "crt0 early boot trap handler"
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed Oct 30, 2023
1 parent e3bb725 commit be6ba95
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/datasheet/software.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down

0 comments on commit be6ba95

Please sign in to comment.