Skip to content

Commit

Permalink
raise_exception2: cause=2, tval=0x10401073
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 19, 2024
1 parent e62d49f commit 37c2d11
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,39 @@

See https://github.com/lupyuen/nuttx-tinyemu

# TODO

```text
TinyEMU Emulator for Ox64 BL808 RISC-V SBC
virtio_console_init
csr_write: csr=0x341 val=0x0000000050200000
raise_exception2: cause=2, tval=0x10401073
pc =0000000050200074 ra =0000000000000000 sp =0000000050407c00 gp =0000000000000000
tp =0000000000000000 t0 =0000000050200000 t1 =0000000000000000 t2 =0000000000000000
s0 =0000000000000000 s1 =0000000000000000 a0 =0000000000000000 a1 =0000000000001040
a2 =0000000000000000 a3 =0000000000000000 a4 =0000000000000000 a5 =0000000000000000
a6 =0000000000000000 a7 =0000000000000000 s2 =0000000000000000 s3 =0000000000000000
s4 =fffffffffffffff3 s5 =0000000000000000 s6 =0000000000000000 s7 =0000000000000000
s8 =0000000000000000 s9 =0000000000000000 s10=0000000000000000 s11=0000000000000000
t3 =0000000000000000 t4 =0000000000000000 t5 =0000000000000000 t6 =0000000000000000
priv=U mstatus=0000000a00000080 cycles=13
mideleg=0000000000000000 mie=0000000000000000 mip=0000000000000080
raise_exception2: cause=2, tval=0x0
pc =0000000000000000 ra =0000000000000000 sp =0000000050407c00 gp =
```

Source:

```text
/Users/Luppy/ox64/nuttx/arch/risc-v/src/chip/bl808_head.S:124
2:
/* Disable all interrupts (i.e. timer, external) in sie */
csrw sie, zero
50200074: 10401073 csrw sie,zero
```

Why is `csrw sie,zero` invalid? Are we in Supervisor Mode?

# TinyEMU

[![Build](https://github.com/lupyuen/TinyEMU/workflows/Build/badge.svg)][GitHub Actions]
Expand Down
3 changes: 2 additions & 1 deletion riscv_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
#ifdef DUMP_EXCEPTIONS
flag = 1;
flag = (cause & CAUSE_INTERRUPT) == 0;
if (cause == CAUSE_SUPERVISOR_ECALL || cause == CAUSE_ILLEGAL_INSTRUCTION)
//// Previously: if (cause == CAUSE_SUPERVISOR_ECALL || cause == CAUSE_ILLEGAL_INSTRUCTION)
if (cause == CAUSE_SUPERVISOR_ECALL) ////
flag = 0;
#endif
if (flag) {
Expand Down

0 comments on commit 37c2d11

Please sign in to comment.