diff options
Diffstat (limited to 'arch/riscv/include/asm/riscv_nmon.h')
-rw-r--r-- | arch/riscv/include/asm/riscv_nmon.h | 99 |
1 files changed, 57 insertions, 42 deletions
diff --git a/arch/riscv/include/asm/riscv_nmon.h b/arch/riscv/include/asm/riscv_nmon.h index caf213cdd8..3e349025fe 100644 --- a/arch/riscv/include/asm/riscv_nmon.h +++ b/arch/riscv/include/asm/riscv_nmon.h @@ -16,13 +16,26 @@ #ifndef __ASM_RISCV_NMON_H #define __ASM_RISCV_NMON_H +#include <linux/kconfig.h> + #define CODE_ESC 0x1b -.macro nmon_outs msg +#ifndef __ASSEMBLY__ - la a1, \msg +extern void __barebox_nmon_entry(void); - jal _nmon_outs +static inline void barebox_nmon_entry(void) +{ + if (IS_ENABLED(CONFIG_NMON)) + __barebox_nmon_entry(); +} + +#else + +.macro nmon_outs msg + + lla a1, \msg + jal a2, _nmon_outs .endm @@ -71,72 +84,72 @@ nmon_main: debug_ll_getc li a0, 'q' - bne s0, a0, 3f + bne s1, a0, 3f - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 j nmon_exit 3: li a0, 'd' - beq s0, a0, nmon_cmd_d + beq s1, a0, nmon_cmd_d li a0, 'w' - beq s0, a0, nmon_cmd_w + beq s1, a0, nmon_cmd_w li a0, 'g' - beq s0, a0, nmon_cmd_g + beq s1, a0, nmon_cmd_g j nmon_main_help nmon_cmd_d: - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 li a0, ' ' - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 - jal _nmon_gethexw + jal a2, _nmon_gethexw nmon_outs msg_nl - lw a0, (s0) + lw a0, (s1) debug_ll_outhexw j nmon_main nmon_cmd_w: - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 li a0, ' ' - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 - jal _nmon_gethexw - move s2, s0 + jal a2, _nmon_gethexw + move s3, s1 li a0, ' ' - jal _nmon_outc_a0 - jal _nmon_gethexw + jal a2, _nmon_outc_a0 + jal a2, _nmon_gethexw - sw s0, 0(s2) + sw s1, 0(s3) j nmon_main nmon_cmd_g: - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 li a0, ' ' - jal _nmon_outc_a0 + jal a2, _nmon_outc_a0 - jal _nmon_gethexw - move s2, s0 + jal a2, _nmon_gethexw + move s3, s1 nmon_outs msg_nl - jalr s2 + jalr s3 j nmon_main _nmon_outc_a0: debug_ll_outc_a0 - jr ra + jr a2 _nmon_outs: @@ -156,37 +169,37 @@ _nmon_gethexw: _get_hex_digit: debug_ll_getc - li s1, CODE_ESC - beq s0, s1, nmon_main + li s2, CODE_ESC + beq s1, s2, nmon_main - li s1, '0' - bge s0, s1, 0f + li s2, '0' + bge s1, s2, 0f j _get_hex_digit 0: - li s1, '9' - ble s0, s1, 9f + li s2, '9' + ble s1, s2, 9f - li s1, 'f' - ble s0, s1, 1f + li s2, 'f' + ble s1, s2, 1f j _get_hex_digit 1: - li s1, 'a' - bge s0, s1, 8f + li s2, 'a' + bge s1, s2, 8f j _get_hex_digit -8: /* s0 \in {'a', 'b' ... 'f'} */ - sub a3, s0, s1 +8: /* s1 \in {'a', 'b' ... 'f'} */ + sub a3, s1, s2 addi a3, a3, 0xa j 0f -9: /* s0 \in {'0', '1' ... '9'} */ +9: /* s1 \in {'0', '1' ... '9'} */ li a3, '0' - sub a3, s0, a3 + sub a3, s1, a3 -0: move a0, s0 +0: move a0, s1 debug_ll_outc_a0 sll t2, t2, 4 @@ -199,10 +212,10 @@ _get_hex_digit: j _get_hex_digit 0: - move s0, t2 + move s1, t2 _nmon_jr_ra_exit: - jr ra + jr a2 msg_prompt: .asciz "\r\nnmon> " @@ -231,4 +244,6 @@ nmon_exit: .endm +#endif /* __ASSEMBLY__ */ + #endif /* __ASM_RISCV_NMON_H */ |