m68k: implement move to/from usp register instruction
PATCH 1/1 m68k: implement move to/from usp register instruction
From: Greg Ungerer <[email protected]>
Fill out the code support for the move to/from usp instructions. They are being decoded, but there is no code to support there actions. So add it.
Current versions of Linux running on the ColdFire 5208 use these instructions.
--- target-m68k/helper.c | 10 ++++++++++ target-m68k/helpers.h | 2 ++ target-m68k/translate.c | 10 ++++++---- 3 files changed, 18 insertions(+), 4 deletions(-)
target-m68k/helper.c +10 -0
@@ -229,6 +229,16 @@ void HELPER(movec)(CPUM68KState *env, uint32_t reg, uint32_t val) } } +uint32_t HELPER (move_from_usp )(CPUM68KState * env) +{ +return env->sp[M68K_USP ]; +} + +void HELPER (move_to_usp )(CPUM68KState * env,uint32_t val) +{ + env->sp[M68K_USP ] = val; +} +void HELPER (set_macsr )(CPUM68KState *env,uint32_t val) {uint32_t acc;
target-m68k/helpers.h +2 -0
@@ -13,6 +13,8 @@ DEF_HELPER_3(sar_cc, i32, env, i32, i32) DEF_HELPER_2(xflag_lt, i32, i32, i32) DEF_HELPER_2(set_sr, void, env, i32) DEF_HELPER_3(movec, void, env, i32, i32) +DEF_HELPER_1(move_from_usp, i32, env) +DEF_HELPER_2(move_to_usp, void, env, i32) DEF_HELPER_2(f64_to_i32, f32, env, f64)DEF_HELPER_2 (f64_to_f32, f32, env, f64)
target-m68k/translate.c +6 -4
@@ -1976,22 +1976,24 @@ DISAS_INSN(move_to_sr)DISAS_INSN (move_from_usp) { +TCGv reg;if (IS_USER (s)) {gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); + reg =AREG (insn,0 ); +gen_helper_move_from_usp (reg, cpu_env); }DISAS_INSN (move_to_usp) { +TCGv reg;if (IS_USER (s)) {gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); + reg =AREG (insn,0 ); +gen_helper_move_to_usp (cpu_env, reg); }DISAS_INSN (halt)
Signature · 1 line
1.7.0.4
target-m68k/helper.c void HELPER(movec)(CPUM68KState *env, uint32_t reg, uint32_t val) · line 235
Quoted 4 lines · On 09/12/2012 11:33 PM, [email protected] wrote:
target-m68k/helper.c +4
-0+uint32_t HELPER (move_from_usp )(CPUM68KState * env) +{ +return env->sp[M68K_USP ]; +}
You don't need helpers for these.
target-m68k/translate.c DISAS_INSN(move_to_sr) · line 1985
Quoted 11 lines
DISAS_INSN(move_from_usp)
{target-m68k/translate.c +3
-2+TCGv reg;if (IS_USER (s)) {gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); + reg =AREG (insn,0 ); +gen_helper_move_from_usp (reg, cpu_env);
tcg_gen_ld_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));
target-m68k/translate.c DISAS_INSN(move_to_sr) · line 1996
Quoted 11 lines
DISAS_INSN(move_to_usp)
{target-m68k/translate.c +3
-2+TCGv reg;if (IS_USER (s)) {gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); + reg =AREG (insn,0 ); +gen_helper_move_to_usp (cpu_env, reg);
tcg_gen_st_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));
r~
Hi Richard,
Quoted 34 lines · Richard Henderson
target-m68k/helper.c void HELPER(movec)(CPUM68KState *env, uint32_t reg, uint32_t val) · line 235
Quoted 4 lines · On 09/12/2012 11:33 PM, [email protected] wrote:
target-m68k/helper.c +4
-0+uint32_t HELPER (move_from_usp )(CPUM68KState * env) +{ +return env->sp[M68K_USP ]; +}You don't need helpers for these.
target-m68k/translate.c DISAS_INSN(move_to_sr) · line 1985
Quoted 11 lines
DISAS_INSN(move_from_usp) {target-m68k/translate.c +3
-2+TCGv reg;if (IS_USER (s)) {gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); + reg =AREG (insn,0 ); +gen_helper_move_from_usp (reg, cpu_env);tcg_gen_ld_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));target-m68k/translate.c DISAS_INSN(move_to_sr) · line 1996
Quoted 11 lines
DISAS_INSN(move_to_usp) {target-m68k/translate.c +3
-2+TCGv reg;if (IS_USER (s)) {gen_exception (s, s->pc -2 ,EXCP_PRIVILEGE );return ; } -/* TODO: Implement USP. */ -gen_exception (s, s->pc -2 ,EXCP_ILLEGAL ); + reg =AREG (insn,0 ); +gen_helper_move_to_usp (cpu_env, reg);
Quoted 1 line
tcg_gen_st_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));
That looks cleaner, thanks. I'll send a revised patch.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com