Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Add `pre_init_trap` to detect early errors during the boot process.

### Changed

- Moved all the assembly code to `asm.rs`
Expand Down
19 changes: 15 additions & 4 deletions riscv-rt/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ _abs_start:
.option norelax
.cfi_startproc
.cfi_undefined ra",
// Disable interrupts
#[cfg(feature = "s-mode")]
"csrw sie, 0
csrw sip, 0",
#[cfg(not(feature = "s-mode"))]
"csrw mie, 0
csrw mip, 0",
// Set pre-init trap vector
"la t0, pre_init_trap",
#[cfg(feature = "s-mode")]
"csrw stvec, t0",
#[cfg(not(feature = "s-mode"))]
"csrw mtvec, t0",
);

// ZERO OUT GENERAL-PURPOSE REGISTERS
Expand Down Expand Up @@ -280,10 +287,14 @@ trap_handler!(
(a0, 8), (a1, 9), (a2, 10), (a3, 11), (a4, 12), (a5, 13), (a6, 14), (a7, 15)]
);

// Make sure there is an abort when linking
#[rustfmt::skip]
global_asm!(
".section .text.abort
.globl abort
abort:
j abort"
.global abort
abort: // make sure there is an abort symbol when linking
j abort

.align 2
pre_init_trap: // if you end up here, there is a bug in the boot code
j pre_init_trap"
);