You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/01/08 13:39:44 UTC
[incubator-nuttx] branch master updated: arch: fe310: Fix mstatus
handling
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d76ba14 arch: fe310: Fix mstatus handling
d76ba14 is described below
commit d76ba14d5830fd2edd47ae15cdf02cf9ce55896b
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Wed Jan 8 10:38:27 2020 -0300
arch: fe310: Fix mstatus handling
In previous commit, mstatus.mie was set when creating a new task
but this change was incorrect and had a side effect such that
a machine interrupt would be enabled just before returning from
interrupt handling routine to switch context.
Also, mstatus.mpp is set to machine mode in up_get_newintctx()
instead of fe310_dispatch_irq().
---
arch/risc-v/include/fe310/irq.h | 1 +
arch/risc-v/src/fe310/fe310_irq.c | 6 +++++-
arch/risc-v/src/fe310/fe310_irq_dispatch.c | 4 ----
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/risc-v/include/fe310/irq.h b/arch/risc-v/include/fe310/irq.h
index 78c60b3..d24caeb 100644
--- a/arch/risc-v/include/fe310/irq.h
+++ b/arch/risc-v/include/fe310/irq.h
@@ -47,6 +47,7 @@
#define MSTATUS_MIE (0x1 << 3) /* Machine Interrupt Enable */
#define MSTATUS_MPIE (0x1 << 7) /* Machine Previous Interrupt Enable */
+#define MSTATUS_MPPM (0x3 << 11) /* Machine Previous Privilege (m-mode) */
/* In mie (machine interrupt enable) register */
diff --git a/arch/risc-v/src/fe310/fe310_irq.c b/arch/risc-v/src/fe310/fe310_irq.c
index 7fabc9a..3a51929 100644
--- a/arch/risc-v/src/fe310/fe310_irq.c
+++ b/arch/risc-v/src/fe310/fe310_irq.c
@@ -193,7 +193,11 @@ void up_enable_irq(int irq)
uint32_t up_get_newintctx(void)
{
- return (MSTATUS_MPIE | MSTATUS_MIE);
+ /* Set machine previous privilege mode to machine mode.
+ * Also set machine previous interrupt enable
+ */
+
+ return (MSTATUS_MPPM | MSTATUS_MPIE);
}
/****************************************************************************
diff --git a/arch/risc-v/src/fe310/fe310_irq_dispatch.c b/arch/risc-v/src/fe310/fe310_irq_dispatch.c
index 9dfa330..e83ff96 100644
--- a/arch/risc-v/src/fe310/fe310_irq_dispatch.c
+++ b/arch/risc-v/src/fe310/fe310_irq_dispatch.c
@@ -131,10 +131,6 @@ void *fe310_dispatch_irq(uint32_t vector, uint32_t *regs)
regs = (uint32_t *)g_current_regs;
g_current_regs = NULL;
- /* Set machine previous privilege mode to machine mode */
-
- *(regs + REG_INT_CTX_NDX) |= 0x3 << 11;
-
return regs;
}