qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
To: qemu-devel@nongnu.org
Cc: rth@twiddle.net
Subject: [Qemu-devel] [PATCH 3/5] target-tricore: add context managment trap generation
Date: Thu, 11 Feb 2016 17:01:58 +0100	[thread overview]
Message-ID: <1455206520-6465-4-git-send-email-kbastian@mail.uni-paderborn.de> (raw)
In-Reply-To: <1455206520-6465-1-git-send-email-kbastian@mail.uni-paderborn.de>

Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 target-tricore/op_helper.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/target-tricore/op_helper.c b/target-tricore/op_helper.c
index fbe2be0..d7aafd1 100644
--- a/target-tricore/op_helper.c
+++ b/target-tricore/op_helper.c
@@ -2404,11 +2404,13 @@ void helper_call(CPUTriCoreState *env, uint32_t next_pc)
     /* if (FCX == 0) trap(FCU); */
     if (env->FCX == 0) {
         /* FCU trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCU);
     }
     /* if (PSW.CDE) then if (cdc_increment()) then trap(CDO); */
     if (psw & MASK_PSW_CDE) {
         if (cdc_increment(&psw)) {
             /* CDO trap */
+            generate_trap(env, TRAPC_CTX_MNG, TIN3_CDO);
         }
     }
     /* PSW.CDE = 1;*/
@@ -2444,6 +2446,7 @@ void helper_call(CPUTriCoreState *env, uint32_t next_pc)
     /* if (tmp_FCX == LCX) trap(FCD);*/
     if (tmp_FCX == env->LCX) {
         /* FCD trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCD);
     }
     psw_write(env, psw);
 }
@@ -2456,18 +2459,25 @@ void helper_ret(CPUTriCoreState *env)
 
     psw = psw_read(env);
      /* if (PSW.CDE) then if (cdc_decrement()) then trap(CDU);*/
-    if (env->PSW & MASK_PSW_CDE) {
-        if (cdc_decrement(&(env->PSW))) {
+    if (psw & MASK_PSW_CDE) {
+        if (cdc_decrement(&psw)) {
             /* CDU trap */
+            psw_write(env, psw);
+            generate_trap(env, TRAPC_CTX_MNG, TIN3_CDU);
         }
     }
     /*   if (PCXI[19: 0] == 0) then trap(CSU); */
     if ((env->PCXI & 0xfffff) == 0) {
         /* CSU trap */
+        psw_write(env, psw);
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_CSU);
     }
     /* if (PCXI.UL == 0) then trap(CTYP); */
     if ((env->PCXI & MASK_PCXI_UL) == 0) {
         /* CTYP trap */
+        cdc_increment(&psw); /* restore to the start of helper */
+        psw_write(env, psw);
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_CTYP);
     }
     /* PC = {A11 [31: 1], 1’b0}; */
     env->PC = env->gpr_a[11] & 0xfffffffe;
@@ -2502,6 +2512,7 @@ void helper_bisr(CPUTriCoreState *env, uint32_t const9)
 
     if (env->FCX == 0) {
         /* FCU trap */
+       generate_trap(env, TRAPC_CTX_MNG, TIN3_FCU);
     }
 
     tmp_FCX = env->FCX;
@@ -2533,6 +2544,7 @@ void helper_bisr(CPUTriCoreState *env, uint32_t const9)
 
     if (tmp_FCX == env->LCX) {
         /* FCD trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCD);
     }
 }
 
@@ -2544,14 +2556,17 @@ void helper_rfe(CPUTriCoreState *env)
     /* if (PCXI[19: 0] == 0) then trap(CSU); */
     if ((env->PCXI & 0xfffff) == 0) {
         /* raise csu trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_CSU);
     }
     /* if (PCXI.UL == 0) then trap(CTYP); */
     if ((env->PCXI & MASK_PCXI_UL) == 0) {
         /* raise CTYP trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_CTYP);
     }
     /* if (!cdc_zero() AND PSW.CDE) then trap(NEST); */
     if (!cdc_zero(&(env->PSW)) && (env->PSW & MASK_PSW_CDE)) {
-        /* raise MNG trap */
+        /* raise NEST trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_NEST);
     }
     env->PC = env->gpr_a[11] & ~0x1;
     /* ICR.IE = PCXI.PIE; */
@@ -2627,6 +2642,7 @@ void helper_svlcx(CPUTriCoreState *env)
 
     if (env->FCX == 0) {
         /* FCU trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCU);
     }
     /* tmp_FCX = FCX; */
     tmp_FCX = env->FCX;
@@ -2657,6 +2673,7 @@ void helper_svlcx(CPUTriCoreState *env)
     /* if (tmp_FCX == LCX) trap(FCD);*/
     if (tmp_FCX == env->LCX) {
         /* FCD trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCD);
     }
 }
 
@@ -2668,6 +2685,7 @@ void helper_svucx(CPUTriCoreState *env)
 
     if (env->FCX == 0) {
         /* FCU trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCU);
     }
     /* tmp_FCX = FCX; */
     tmp_FCX = env->FCX;
@@ -2698,6 +2716,7 @@ void helper_svucx(CPUTriCoreState *env)
     /* if (tmp_FCX == LCX) trap(FCD);*/
     if (tmp_FCX == env->LCX) {
         /* FCD trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_FCD);
     }
 }
 
@@ -2708,10 +2727,12 @@ void helper_rslcx(CPUTriCoreState *env)
     /*   if (PCXI[19: 0] == 0) then trap(CSU); */
     if ((env->PCXI & 0xfffff) == 0) {
         /* CSU trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_CSU);
     }
     /* if (PCXI.UL == 1) then trap(CTYP); */
     if ((env->PCXI & MASK_PCXI_UL) != 0) {
         /* CTYP trap */
+        generate_trap(env, TRAPC_CTX_MNG, TIN3_CTYP);
     }
     /* EA = {PCXI.PCXS, 6'b0, PCXI.PCXO, 6'b0}; */
     ea = ((env->PCXI & MASK_PCXI_PCXS) << 12) +
-- 
2.7.1

  parent reply	other threads:[~2016-02-11 16:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11 16:01 [Qemu-devel] [PATCH 0/5] TriCore exception patches Bastian Koppelmann
2016-02-11 16:01 ` [Qemu-devel] [PATCH 1/5] target-tricore: Add trap handling Bastian Koppelmann
2016-02-12  2:39   ` Richard Henderson
2016-02-12 11:12     ` Bastian Koppelmann
2016-02-12 18:55       ` Richard Henderson
2016-02-12 20:08         ` Bastian Koppelmann
2016-02-12  2:44   ` Richard Henderson
2016-02-11 16:01 ` [Qemu-devel] [PATCH 2/5] target-tricore: Save the pc before CSA operations for exceptions Bastian Koppelmann
2016-02-11 16:01 ` Bastian Koppelmann [this message]
2016-02-11 16:01 ` [Qemu-devel] [PATCH 4/5] target-tricore: add illegal opcode trap generation Bastian Koppelmann
2016-02-11 16:02 ` [Qemu-devel] [PATCH 5/5] target-tricore: add opd " Bastian Koppelmann

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=1455206520-6465-4-git-send-email-kbastian@mail.uni-paderborn.de \
    --to=kbastian@mail.uni-paderborn.de \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).