Commit f24f381b2de01c37a811ac06c7d60644fd74a5b5

Authored by aurel32
1 parent 9f4576f0

SH4: sleep instruction bug fix

fix a bug on 'sleep' instruction, which have caused halt of idle task.
As i386 'hlt' instruction does, it should save PC before sleep.

(Shin-ichiro KAWASAKI)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5220 c046a42c-6fe2-441c-8c8c-71466251a162
target-sh4/helper.h
@@ -6,7 +6,7 @@ DEF_HELPER(void, helper_ldtlb, (void)) @@ -6,7 +6,7 @@ DEF_HELPER(void, helper_ldtlb, (void))
6 DEF_HELPER(void, helper_raise_illegal_instruction, (void)) 6 DEF_HELPER(void, helper_raise_illegal_instruction, (void))
7 DEF_HELPER(void, helper_raise_slot_illegal_instruction, (void)) 7 DEF_HELPER(void, helper_raise_slot_illegal_instruction, (void))
8 DEF_HELPER(void, helper_debug, (void)) 8 DEF_HELPER(void, helper_debug, (void))
9 -DEF_HELPER(void, helper_sleep, (void)) 9 +DEF_HELPER(void, helper_sleep, (uint32_t))
10 DEF_HELPER(void, helper_trapa, (uint32_t)) 10 DEF_HELPER(void, helper_trapa, (uint32_t))
11 11
12 DEF_HELPER(uint32_t, helper_addv, (uint32_t, uint32_t)) 12 DEF_HELPER(uint32_t, helper_addv, (uint32_t, uint32_t))
target-sh4/op_helper.c
@@ -94,10 +94,11 @@ void helper_debug(void) @@ -94,10 +94,11 @@ void helper_debug(void)
94 cpu_loop_exit(); 94 cpu_loop_exit();
95 } 95 }
96 96
97 -void helper_sleep(void) 97 +void helper_sleep(uint32_t next_pc)
98 { 98 {
99 env->halted = 1; 99 env->halted = 1;
100 env->exception_index = EXCP_HLT; 100 env->exception_index = EXCP_HLT;
  101 + env->pc = next_pc;
101 cpu_loop_exit(); 102 cpu_loop_exit();
102 } 103 }
103 104
target-sh4/translate.c
@@ -505,7 +505,7 @@ void _decode_opc(DisasContext * ctx) @@ -505,7 +505,7 @@ void _decode_opc(DisasContext * ctx)
505 return; 505 return;
506 case 0x001b: /* sleep */ 506 case 0x001b: /* sleep */
507 if (ctx->memidx) { 507 if (ctx->memidx) {
508 - tcg_gen_helper_0_0(helper_sleep); 508 + tcg_gen_helper_0_1(helper_sleep, tcg_const_i32(ctx->pc + 2));
509 } else { 509 } else {
510 tcg_gen_helper_0_0(helper_raise_illegal_instruction); 510 tcg_gen_helper_0_0(helper_raise_illegal_instruction);
511 ctx->bstate = BS_EXCP; 511 ctx->bstate = BS_EXCP;