u-boot/arch/riscv/lib
Heinrich Schuchardt f6431e8fb3 riscv: show code leading to exception
To make analyzing exceptions easier output the code that leads to it.
We already do the same on the ARM platform.

Here is an example:

    => exception ebreak
    Unhandled exception: Breakpoint
    EPC: 000000008ff5d50e RA: 000000008ff5d62c TVAL: 0000000000000000
    EPC: 000000008020b50e RA: 000000008020b62c reloc adjusted

    Code: 2785 0693 07a0 dce3 fef6 47a5 d563 00e7 (9002)

To disassemble the code we can use the decodecode script:

    $ echo 'Code: 2785 0693 07a0 dce3 fef6 47a5 d563 00e7 (9002)' | \
      CROSS_COMPILE=riscv64-linux-gnu- scripts/decodecode

    Code: 2785 0693 07a0 dce3 fef6 47a5 d563 00e7 (9002)
    All code
    ========
       0:   2785                    addiw   a5,a5,1
       2:   07a00693                li      a3,122
       6:   fef6dce3                bge     a3,a5,0xfffffffffffffffe
       a:   47a5                    li      a5,9
       c:   00e7d563                bge     a5,a4,0x16
      10:*  9002                    ebreak         <-- trapping instruction
            ...

    Code starting with the faulting instruction
    ===========================================
       0:   9002                    ebreak
            ...

As it is not always clear if the first 16 bits are at the start or in the
middle of a 32bit instruction it may become necessary to strip the first
u16 from the output before calling decodecode to get the correct
disassembled code.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
2021-09-07 10:34:29 +08:00
..
andes_plic.c riscv: andes_plic: Fix riscv_get_ipi() mask 2021-06-17 09:39:46 +08:00
asm-offsets.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
boot.c command: Remove the cmd_tbl_t typedef 2020-05-18 18:36:55 -04:00
bootm.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
cache.c common: Move some cache and MMU functions out of common.h 2019-12-02 18:23:55 -05:00
crt0_riscv_efi.S efi_loader: add Linux magic to RISC-V crt0 2021-08-14 20:54:41 +02:00
elf_riscv32_efi.lds SPDX: Convert single license tags to Linux Kernel style 2018-05-29 14:44:21 +08:00
elf_riscv64_efi.lds SPDX: Convert single license tags to Linux Kernel style 2018-05-29 14:44:21 +08:00
fdt_fixup.c riscv: Fix arch_fixup_fdt always failing without /chosen 2021-05-17 16:46:33 +08:00
image.c riscv: booti: do not force relocation if force_reloc is not set 2021-07-21 16:38:26 +08:00
interrupts.c riscv: show code leading to exception 2021-09-07 10:34:29 +08:00
Makefile riscv: Split SiFive CLINT support between SPL and U-Boot proper 2021-05-17 16:42:24 +08:00
memcpy.S riscv: Fix memmove and optimise memcpy when misalign 2021-05-17 16:47:33 +08:00
memmove.S riscv: Fix memmove and optimise memcpy when misalign 2021-05-17 16:47:33 +08:00
memset.S riscv: assembler versions of memcpy, memmove, memset 2021-04-08 15:37:29 +08:00
reloc_riscv_efi.c riscv: Remove unused _relocate arguments 2018-07-19 16:31:37 -04:00
reset.c Revert "riscv: Allow use of reset drivers" 2020-07-24 14:55:31 +08:00
sbi.c cmd: provide command sbi 2020-08-25 09:34:47 +08:00
sbi_ipi.c riscv: Clean up IPI initialization code 2020-07-01 15:01:22 +08:00
setjmp.S riscv: simplify longjmp 2021-04-08 15:37:29 +08:00
sifive_clint.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
smp.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
spl.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00