[PATCH v2 9/9] target/loongarch: CSR_ECFG enable msg interrupt

Song Gao posted 9 patches 4 months, 4 weeks ago
There is a newer version of this series
[PATCH v2 9/9] target/loongarch: CSR_ECFG enable msg interrupt
Posted by Song Gao 4 months, 4 weeks ago
when loongarch cpu set irq is INT_AVEC, we need set CSR_ECFG MSGINT bit.

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 target/loongarch/cpu-csr.h | 5 +++--
 target/loongarch/cpu.c     | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/loongarch/cpu-csr.h b/target/loongarch/cpu-csr.h
index 83f6cb081a..b1e251a72b 100644
--- a/target/loongarch/cpu-csr.h
+++ b/target/loongarch/cpu-csr.h
@@ -34,11 +34,12 @@ FIELD(CSR_MISC, ALCL, 12, 4)
 FIELD(CSR_MISC, DWPL, 16, 3)
 
 #define LOONGARCH_CSR_ECFG           0x4 /* Exception config */
-FIELD(CSR_ECFG, LIE, 0, 13)
+FIELD(CSR_ECFG, LIE, 0, 15)          /*bit 15 is msg interrupt enabled */
+FIELD(CSR_ECFG, MSGINT, 14, 1)
 FIELD(CSR_ECFG, VS, 16, 3)
 
 #define LOONGARCH_CSR_ESTAT          0x5 /* Exception status */
-FIELD(CSR_ESTAT, IS, 0, 13)
+FIELD(CSR_ESTAT, IS, 0, 15)          /*bit 15 is msg interrupt enabled */
 FIELD(CSR_ESTAT, MSGINT, 14, 1)
 FIELD(CSR_ESTAT, ECODE, 16, 6)
 FIELD(CSR_ESTAT, ESUBCODE, 22, 9)
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 28b23743f9..c5924bb94f 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -132,6 +132,7 @@ void loongarch_cpu_set_irq(void *opaque, int irq, int level)
         for (int i = 256; i >= 0; i--) {
             if (test_bit(i, &(env->CSR_MSGIS[i / 64]))) {
                 env->CSR_ESTAT = FIELD_DP64(env->CSR_ESTAT, CSR_ESTAT, MSGINT, 1);
+                env->CSR_ECFG = FIELD_DP64(env->CSR_ECFG, CSR_ECFG, MSGINT, 1);
             }
         }
     }
-- 
2.34.1