|
33 | 33 | #include "exec/translator.h" |
34 | 34 | #include "qemu/qemu-print.h" |
35 | 35 | #include "exec/gen-icount.h" |
| 36 | +#include "semihosting/semihost.h" |
36 | 37 |
|
37 | 38 | /* is_jmp field values */ |
38 | 39 | #define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ |
@@ -644,6 +645,20 @@ static void trap(DisasContext *dc, uint32_t code, uint32_t flags) |
644 | 645 | t_gen_helper_raise_exception(dc, EXCP_TRAP); |
645 | 646 | } |
646 | 647 |
|
| 648 | +static void gen_break(DisasContext *dc, uint32_t code, uint32_t flags) |
| 649 | +{ |
| 650 | +#ifndef CONFIG_USER_ONLY |
| 651 | + /* The semihosting instruction is "break 1". */ |
| 652 | + R_TYPE(instr, code); |
| 653 | + if (semihosting_enabled() && instr.imm5 == 1) { |
| 654 | + t_gen_helper_raise_exception(dc, EXCP_SEMIHOST); |
| 655 | + return; |
| 656 | + } |
| 657 | +#endif |
| 658 | + |
| 659 | + t_gen_helper_raise_exception(dc, EXCP_BREAK); |
| 660 | +} |
| 661 | + |
647 | 662 | static const Nios2Instruction r_type_instructions[] = { |
648 | 663 | INSTRUCTION_ILLEGAL(), |
649 | 664 | INSTRUCTION(eret), /* eret */ |
@@ -697,7 +712,7 @@ static const Nios2Instruction r_type_instructions[] = { |
697 | 712 | INSTRUCTION(add), /* add */ |
698 | 713 | INSTRUCTION_ILLEGAL(), |
699 | 714 | INSTRUCTION_ILLEGAL(), |
700 | | - INSTRUCTION_FLG(gen_excp, EXCP_BREAK), /* break */ |
| 715 | + INSTRUCTION(gen_break), /* break */ |
701 | 716 | INSTRUCTION_ILLEGAL(), |
702 | 717 | INSTRUCTION(nop), /* nop */ |
703 | 718 | INSTRUCTION_ILLEGAL(), |
|
0 commit comments