qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] SH: Implement MOVCO.L and MOVLI.L
Date: Thu, 11 Dec 2008 21:27:28 +0300	[thread overview]
Message-ID: <200812112127.29115.vladimir@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]


This patch implements a couple more instructions
specific to SH4A. The patch includes a copy of their
description from the manual. The only point worth
noting is the LDST -- my copy of the manual does not
explain it, but I was told by Paul Mundt that this is
internal state of the processor not otherwise exposed.
So, adding a new field in processor state seems reasonable.

- Volodya

[-- Attachment #2: 0003-SH-Implement-MOVCO.L-and-MOVLI.L.patch --]
[-- Type: text/x-diff, Size: 3775 bytes --]

From db021cfa5ca5a170d9691910ab7450cc84dcaf97 Mon Sep 17 00:00:00 2001
From: Vladimir Prus <vladimir@codesourcery.com>
Date: Sun, 12 Oct 2008 19:36:22 +0400
Subject: [PATCH] SH: Implement MOVCO.L and MOVLI.L
To: qemu-devel@nongnu.org
X-KMail-Transport: CodeSourcery
X-KMail-Identity: 901867920

	* target-sh4/cpu.h (struct CPUSH4State): New field ldst.
	* target-sh4/helper.c (do_interrupt): Initialize ldst.
	* target-sh4/translate.c (cpu_ldst): New.
	(sh4_translate_init): Initialize cpu_ldst.
	(_decode_opc): Support MOVCO.L and MOVLI.L.
---
 target-sh4/cpu.h       |    2 ++
 target-sh4/helper.c    |    1 +
 target-sh4/translate.c |   35 ++++++++++++++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h
index a0108b4..ae434d1 100644
--- a/target-sh4/cpu.h
+++ b/target-sh4/cpu.h
@@ -135,6 +135,8 @@ typedef struct CPUSH4State {
     uint32_t prr;		/* Processor Revision Register */
     uint32_t cvr;		/* Cache Version Register */
 
+    uint32_t ldst;
+
      CPU_COMMON tlb_t utlb[UTLB_SIZE];	/* unified translation table */
     tlb_t itlb[ITLB_SIZE];	/* instruction translation table */
     void *intc_handle;
diff --git a/target-sh4/helper.c b/target-sh4/helper.c
index 882bc9c..61b668b 100644
--- a/target-sh4/helper.c
+++ b/target-sh4/helper.c
@@ -160,6 +160,7 @@ void do_interrupt(CPUState * env)
     env->spc = env->pc;
     env->sgr = env->gregs[15];
     env->sr |= SR_BL | SR_MD | SR_RB;
+    env->ldst = 0;
 
     if (env->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
         /* Branch instruction should be executed again before delay slot. */
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index d38e95f..ba9db14 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -72,7 +72,7 @@ static TCGv_ptr cpu_env;
 static TCGv cpu_gregs[24];
 static TCGv cpu_pc, cpu_sr, cpu_ssr, cpu_spc, cpu_gbr;
 static TCGv cpu_vbr, cpu_sgr, cpu_dbr, cpu_mach, cpu_macl;
-static TCGv cpu_pr, cpu_fpscr, cpu_fpul;
+static TCGv cpu_pr, cpu_fpscr, cpu_fpul, cpu_ldst;
 static TCGv cpu_fregs[32];
 
 /* internal register indexes */
@@ -144,6 +144,8 @@ static void sh4_translate_init(void)
     cpu_delayed_pc = tcg_global_mem_new_i32(TCG_AREG0,
 					    offsetof(CPUState, delayed_pc),
 					    "_delayed_pc_");
+    cpu_ldst = tcg_global_mem_new_i32(TCG_AREG0,
+				      offsetof(CPUState, ldst), "_ldst_");
 
     for (i = 0; i < 32; i++)
         cpu_fregs[i] = tcg_global_mem_new_i32(TCG_AREG0,
@@ -1543,6 +1545,37 @@ static void _decode_opc(DisasContext * ctx)
     case 0x0029:		/* movt Rn */
 	tcg_gen_andi_i32(REG(B11_8), cpu_sr, SR_T);
 	return;
+    case 0x0073:
+        /* MOVCO.L 
+	       LDST -> T
+               If (T == 1) R0 -> (Rn)
+               0 -> LDST
+	   For now, do unconditional move. FIXME.    
+        */	   
+        if (ctx->features & SH_FEATURE_SH4A) {
+	    int label = gen_new_label();
+	    gen_clr_t();
+	    tcg_gen_or_i32(cpu_sr, cpu_sr, cpu_ldst);
+	    tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ldst, 0, label);
+	    tcg_gen_qemu_st32(REG(0), REG(B11_8), ctx->memidx);
+	    gen_set_label(label);
+	    tcg_gen_movi_i32(cpu_ldst, 0);
+	    return;
+	} else
+	    break;
+    case 0x0063:
+        /* MOVLI.L @Rm,R0 
+               1 -> LDST
+               (Rm) -> R0
+               When interrupt/exception
+               occurred 0 -> LDST
+        */     
+	if (ctx->features & SH_FEATURE_SH4A) {
+	    tcg_gen_movi_i32(cpu_ldst, 1);
+	    tcg_gen_qemu_ld32s(REG(0), REG(B11_8), ctx->memidx);
+	    return;
+	} else
+	    break;
     case 0x0093:		/* ocbi @Rn */
 	{
 	    TCGv dummy = tcg_temp_new();
-- 
1.5.3.5


             reply	other threads:[~2008-12-11 18:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11 18:27 Vladimir Prus [this message]
2008-12-11 18:36 ` [Qemu-devel] SH: Implement MOVCO.L and MOVLI.L Paul Brook
2008-12-11 18:48   ` Vladimir Prus
2009-02-07 14:24     ` Aurelien Jarno
2009-02-11 21:05       ` Vladimir Prus
2009-02-13 20:11         ` Aurelien Jarno
2009-02-19 20:12           ` Vladimir Prus
2009-03-02 17:13             ` Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200812112127.29115.vladimir@codesourcery.com \
    --to=vladimir@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).