Skip to contentSkip to conversation

target-mips: Use EXCP_SC rather than a magic number

PATCH Applied 陳韋任 (Wei-Ren Chen) 3 participants 6 messages Dec 10, 2012 – Jan 1, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-mips: Use EXCP_SC rather than a magic number

From the discussion on the ML [1], the exception limit defined by
magic number 0x100 is actually EXCP_SC defined in cpu.h. Replace the magic number with EXCP_SC. Remove "#if 1 .. #endif" as well.

[1] http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg03080.html

---
 target-mips/op_helper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
target-mips/op_helper.c +3 -3
index f45d494..98a445c 100644
@@ -39,10 +39,10 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
                                                         uintptr_t pc)
 {
     TranslationBlock *tb;
-#if 1
-    if (exception < 0x100)
+    if (exception < EXCP_SC) {
         qemu_log("%s: %d %d\n", __func__, exception, error_code);
-#endif
+    }
+
     env->exception_index = exception;
     env->error_code = error_code;
 
Signature · 1 line
1.7.3.4
#1 lore raw

ping? :-)

Quoted 31 lines · 陳韋任 (Wei-Ren Chen)

From the discussion on the ML [1], the exception limit defined by
magic number 0x100 is actually EXCP_SC defined in cpu.h. Replace the magic number with EXCP_SC. Remove "#if 1 .. #endif" as well.

[1] http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg03080.html

---
 target-mips/op_helper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
target-mips/op_helper.c +3 -3
index f45d494..98a445c 100644
@@ -39,10 +39,10 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
                                                         uintptr_t pc)
 {
     TranslationBlock *tb;
-#if 1
-    if (exception < 0x100)
+    if (exception < EXCP_SC) {
         qemu_log("%s: %d %d\n", __func__, exception, error_code);
-#endif
+    }
+
     env->exception_index = exception;
     env->error_code = error_code;
 
Signature · 1 line
1.7.3.4
Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
#2 lore raw
Quoted 14 lines · 在 2012-12-20四的 09:23 +0800,陳韋任 (Wei-Ren Chen)写道:

ping? :-)

Quoted 11 lines · 陳韋任 (Wei-Ren Chen)

From the discussion on the ML [1], the exception limit defined by
magic number 0x100 is actually EXCP_SC defined in cpu.h. Replace the magic number with EXCP_SC. Remove "#if 1 .. #endif" as well.

[1] http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg03080.html

---
 target-mips/op_helper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Quoted 15 lines
Quoted 5 lines
target-mips/op_helper.c +0 -0
index f45d494..98a445c 100644

target-mips/op_helper.c static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, · line 45

Quoted 10 lines
target-mips/op_helper.c +3 -3
@@ -39,10 +39,10 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
                                                         uintptr_t pc)
 {
     TranslationBlock *tb;
-#if 1
-    if (exception < 0x100)
+    if (exception < EXCP_SC) {
         qemu_log("%s: %d %d\n", __func__, exception, error_code);
-#endif
+    }
+

seems original '#if 1, #endif' statement is for temporary debug only,
so maybe can be concealed out entirely. for log purpose, every exception code will log when 'do_interrupt' for MIPS if log is enabled.

Quoted 6 lines
Quoted 5 lines
target-mips/op_helper.c +0 -0
     env->exception_index = exception;
     env->error_code = error_code;
 
Signature · 1 line
1.7.3.4
Signature · 2 lines
regards!
li guang
#3 lore raw

Hi Li,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
 target-mips/op_helper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
target-mips/op_helper.c +2 -3
index f45d494..98a445c 100644
@@ -39,10 +39,10 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
                                                         uintptr_t pc)
 {
     TranslationBlock *tb;
-#if 1
-    if (exception < 0x100)
+    if (exception < EXCP_SC) {
         qemu_log("%s: %d %d\n", __func__, exception, error_code);
-#endif
+    }
Quoted 8 lines
Quoted 1 line

target-mips/op_helper.c static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, · line 45

Quoted 1 line
target-mips/op_helper.c +1 -0
+

seems original '#if 1, #endif' statement is for temporary debug only,
so maybe can be concealed out entirely. for log purpose, every exception code will log when 'do_interrupt' for MIPS if log is enabled.

Thanks for your feedback. You mean the code snippet below?

--- target-mips/helper.c
void do_interrupt (CPUMIPSState *env)

{
    ...

    if (qemu_log_enabled() && env->exception_index != EXCP_EXT_INTERRUPT) {
        if (env->exception_index < 0 || env->exception_index > EXCP_LAST)
            name = "unknown";
        else
            name = excp_names[env->exception_index];

        qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
                 __func__, env->active_tc.PC, env->CP0_EPC, name);
    }

    ...
}

Maybe we can do this way?

---

target-mips/cpu.h +2 -2
index 31602ac..507a213 100644
@@ -616,9 +616,9 @@ enum {
     EXCP_DSPDIS,
 
     EXCP_LAST = EXCP_DSPDIS,
+    /* Dummy exception for conditional stores. */
+    EXCP_SC = EXCP_LAST,
 };
-/* Dummy exception for conditional stores.  */
-#define EXCP_SC 0x100
 
 /*
  * This is an interrnally generated WAKE request line.

---

Aurelien, Johnson, thoughts? :)

Regards,
chenwj

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
#5 lore raw
In reply to 陳韋任 (Wei-Ren Chen)
Quoted 19 lines · 陳韋任 (Wei-Ren Chen)

From the discussion on the ML [1], the exception limit defined by
magic number 0x100 is actually EXCP_SC defined in cpu.h. Replace the magic number with EXCP_SC. Remove "#if 1 .. #endif" as well.

[1] http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg03080.html

---
 target-mips/op_helper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
target-mips/op_helper.c +0 -0
index f45d494..98a445c 100644
@@ -39,10 +39,10 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
                                                         uintptr_t pc)
 {
     TranslationBlock *tb;

target-mips/op_helper.c static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, · line 48

Quoted 10 lines
target-mips/op_helper.c +3 -3
-#if 1
-    if (exception < 0x100)
+    if (exception < EXCP_SC) {
         qemu_log("%s: %d %d\n", __func__, exception, error_code);
-#endif
+    }
+
     env->exception_index = exception;
     env->error_code = error_code;
 

Thanks, applied.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#4 lore raw
In reply to 陳韋任 (Wei-Ren Chen)
Quoted 34 lines · 陳韋任 (Wei-Ren Chen)

Hi Li,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
---
 target-mips/op_helper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
target-mips/op_helper.c +2 -3
index f45d494..98a445c 100644
@@ -39,10 +39,10 @@ static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
                                                         uintptr_t pc)
 {
     TranslationBlock *tb;
-#if 1
-    if (exception < 0x100)
+    if (exception < EXCP_SC) {
         qemu_log("%s: %d %d\n", __func__, exception, error_code);
-#endif
+    }
Quoted 8 lines
Quoted 1 line

target-mips/op_helper.c static inline void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env, · line 45

Quoted 1 line
target-mips/op_helper.c +1 -0
+

seems original '#if 1, #endif' statement is for temporary debug only,
so maybe can be concealed out entirely. for log purpose, every exception code will log when 'do_interrupt' for MIPS if log is enabled.

Thanks for your feedback. You mean the code snippet below?

--- target-mips/helper.c
void do_interrupt (CPUMIPSState *env)

Quoted 16 lines
{
    ...

    if (qemu_log_enabled() && env->exception_index != EXCP_EXT_INTERRUPT) {
        if (env->exception_index < 0 || env->exception_index > EXCP_LAST)
            name = "unknown";
        else
            name = excp_names[env->exception_index];

        qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
                 __func__, env->active_tc.PC, env->CP0_EPC, name);
    }

    ...
}

I don't think this is necessary to add a qemu_log_enabled(), this is already something included in qemu_log().

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net