Webcentive RISC-V Reference

mtvec

Machine trap-handler base address

Address
0x305
Group
Machine-level CSRs
Privilege
MRW (privileged spec CSR listing, Machine Trap Setup)
Access
read/write; lowest privilege M (machine)
Address range
Standard read/write
Name in riscv-unified-db
Machine Trap Vector Control

Privileged spec: Machine trap-handler base address

Description

Controls where traps jump.

From riscv-unified-db, reformatted.

Fields

FieldBitsTypeDescription
BASERV32 31-2 / RV64 63-2

Bits [MXLEN-1:2] of the exception vector physical address for any trap taken in M-mode.

The implementation physical memory map may resitrict which values are legal in this field.

The address must be aligned to MTVEC_BASE_ALIGNMENT_DIRECT bytes when mtvec.MODE is Direct, and to MTVEC_BASE_ALIGNMENT_VECTORED bytes when mtvec.MODE is Vectored. A write that does not meet the alignment for the new mode is illegal, and follows MTVEC_ILLEGAL_WRITE_BEHAVIOR.

MODE1-0

Vectoring mode for asynchronous interrupts.

0 - Direct, 1 - Vectored

When Direct, all synchronous exceptions and asynchronous interrupts jump to (mtvec.BASE << 2).

When Vectored, asynchronous interrupts jump to (mtvec.BASE << 2 + mcause.CODE*4) while synchronous exceptions continue to jump to (mtvec.BASE << 2).

Fields from riscv-unified-db; field types computed by IDL functions there are not shown.

Specification and related pages