Skip to contentSkip to conversation

riscv: Add option to print registers on exception

PATCH New Sean Anderson 3 participants 3 messages Dec 25, 2019 – Jan 3, 2020 1 message not in the archive RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 riscv: Add option to print registers on exception

When debugging, it can be helpful to see more information about an unhandled exception. This patch adds an option to view the registers at the time of the trap, similar to the linux output on a kernel panic.

---
Changes for v2:
- Renamed "PC" to "EPC"

 arch/riscv/Kconfig          |  3 +++
 arch/riscv/cpu/mtrap.S      |  3 ++-
 arch/riscv/lib/interrupts.c | 50 +++++++++++++++++++++++++++++--------
 3 files changed, 44 insertions(+), 12 deletions(-)
arch/riscv/Kconfig +3 -0
index 85e15ebffa..3338b788f8 100644
@@ -222,6 +222,9 @@ config XIP
 	  from a NOR flash memory without copying the code to ram.
 	  Say yes here if U-Boot boots from flash directly.
 
+config SHOW_REGS
+	bool "Show registers on unhandled exception"
+
 config STACK_SIZE_SHIFT
 	int
 	default 14
arch/riscv/cpu/mtrap.S +2 -1
index 407ecfa9c0..e40c7bd3f4 100644
@@ -64,7 +64,8 @@ trap_entry:
 	SREG x31, 31 * REGBYTES(sp)
 	csrr a0, MODE_PREFIX(cause)
 	csrr a1, MODE_PREFIX(epc)
-	mv a2, sp
+	csrr a2, MODE_PREFIX(tval)
+	mv a3, sp
 	jal handle_trap
 	csrw MODE_PREFIX(epc), a0
 
arch/riscv/lib/interrupts.c +39 -11

84 lines not on this page · raw message

Signature · 1 line
2.24.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH v2 1/1 riscv: Add option to print registers on exception

Quoted 9 lines

From: Sean Anderson [mailto:seanga2 at gmail.com]
Sent: Wednesday, December 25, 2019 1:28 PM
To: U-Boot Mailing List
Cc: Rick Jian-Zhi Chen(陳建志)
Subject: [PATCH v2] riscv: Add option to print registers on exception

When debugging, it can be helpful to see more information about an unhandled exception. This patch adds an option to view the registers at the time of the trap, similar to the linux output on a kernel panic.

Quoted 9 lines

---
Changes for v2:
- Renamed "PC" to "EPC"

 arch/riscv/Kconfig          |  3 +++
 arch/riscv/cpu/mtrap.S      |  3 ++-
 arch/riscv/lib/interrupts.c | 50 +++++++++++++++++++++++++++++--------
 3 files changed, 44 insertions(+), 12 deletions(-)
#3 lore raw

PATCH v2 1/1 riscv: Add option to print registers on exception

In reply to Sean Anderson
Quoted 6 lines · Sean Anderson

When debugging, it can be helpful to see more information about an unhandled exception. This patch adds an option to view the registers at the time of the trap, similar to the linux output on a kernel panic.

Quoted 9 lines

---
Changes for v2:
- Renamed "PC" to "EPC"

 arch/riscv/Kconfig          |  3 +++
 arch/riscv/cpu/mtrap.S      |  3 ++-
 arch/riscv/lib/interrupts.c | 50 +++++++++++++++++++++++++++++--------
 3 files changed, 44 insertions(+), 12 deletions(-)