* [Qemu-devel] [PATCH] m68k: implement move to/from usp register instruction
@ 2012-09-13 6:33 gerg
2012-09-13 17:34 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: gerg @ 2012-09-13 6:33 UTC (permalink / raw)
To: qemu-devel, paul; +Cc: Greg Ungerer
From: Greg Ungerer <gerg@uclinux.org>
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.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
target-m68k/helper.c | 10 ++++++++++
target-m68k/helpers.h | 2 ++
target-m68k/translate.c | 10 ++++++----
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index eac0053..722dbd9 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -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;
diff --git a/target-m68k/helpers.h b/target-m68k/helpers.h
index cb8a0c7..bca780b 100644
--- a/target-m68k/helpers.h
+++ b/target-m68k/helpers.h
@@ -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)
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 9fc1e31..5609240 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -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)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] m68k: implement move to/from usp register instruction
2012-09-13 6:33 [Qemu-devel] [PATCH] m68k: implement move to/from usp register instruction gerg
@ 2012-09-13 17:34 ` Richard Henderson
2012-09-13 23:36 ` Greg Ungerer
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2012-09-13 17:34 UTC (permalink / raw)
To: gerg; +Cc: Greg Ungerer, qemu-devel, paul
On 09/12/2012 11:33 PM, gerg@snapgear.com wrote:
> +uint32_t HELPER(move_from_usp)(CPUM68KState * env)
> +{
> + return env->sp[M68K_USP];
> +}
You don't need helpers for these.
> 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);
tcg_gen_ld_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));
> 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);
tcg_gen_st_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] m68k: implement move to/from usp register instruction
2012-09-13 17:34 ` Richard Henderson
@ 2012-09-13 23:36 ` Greg Ungerer
0 siblings, 0 replies; 3+ messages in thread
From: Greg Ungerer @ 2012-09-13 23:36 UTC (permalink / raw)
To: Richard Henderson; +Cc: Greg Ungerer, qemu-devel, paul
Hi Richard,
On 14/09/12 03:34, Richard Henderson wrote:
> On 09/12/2012 11:33 PM, gerg@snapgear.com wrote:
>> +uint32_t HELPER(move_from_usp)(CPUM68KState * env)
>> +{
>> + return env->sp[M68K_USP];
>> +}
>
> You don't need helpers for these.
>
>> 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);
>
> tcg_gen_ld_i32(AREG(insn, 0), offsetof(CPUM68KState, sp[M68K_USP]));
>
>> 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);
>
> 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: gerg@snapgear.com
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-13 23:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-13 6:33 [Qemu-devel] [PATCH] m68k: implement move to/from usp register instruction gerg
2012-09-13 17:34 ` Richard Henderson
2012-09-13 23:36 ` Greg Ungerer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).