RISC-V ECALL Trap
U-mode ecall -> trap entry -> handler -> return
U-mode reaches ECALL
U-mode instructionExecution is in U-mode at the ECALL instruction at address 0x4040. ECALL raises a synchronous exception; hardware then records the trapping address in the target EPC (sepc or mepc), records the cause in the target cause CSR (scause or mcause), saves return state, and enters the S-mode or M-mode path according to delegation configuration.
This page does not specify a concrete operating-system syscall ABI.
Boundaries that often get mixed up
EPC first saves the ECALL instruction address, not the next instruction automatically.
Syscall numbers and argument locations are OS/execution-environment ABI policy, not fixed RISC-V ISA semantics.
medeleg[8] changes the trap target; it does not change ECALL cause=8.
The official manual defines the ECALL trap and cause; the syscall ABI is OS/execution-environment policy.