arch/risc-v: Rework riscv_get_newintctx

Some fields of mstatus were marked as Reserved Writes Preserve Values, Reads Ignore Values (WPRI),
so we must keep its origin value with addition flags.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi
2022-03-17 12:49:25 +08:00
committed by Xiang Xiao
parent c3bae60c57
commit 807304f283
10 changed files with 45 additions and 22 deletions
+5 -3
View File
@@ -171,16 +171,18 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode.
* Also set machine previous interrupt enable
*/
uintptr_t mstatus = READ_CSR(mstatus);
#ifdef CONFIG_ARCH_FPU
return (MSTATUS_FS_INIT | MSTATUS_MPPM | MSTATUS_MPIE);
return (mstatus | MSTATUS_FS_INIT | MSTATUS_MPPM | MSTATUS_MPIE);
#else
return (MSTATUS_MPPM | MSTATUS_MPIE);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
#endif
}
+5 -3
View File
@@ -202,7 +202,7 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode. Reegardless of
* how NuttX is configured and of what kind of thread is being started.
@@ -212,10 +212,12 @@ uint32_t riscv_get_newintctx(void)
* user code. Also set machine previous interrupt enable.
*/
uintptr_t mstatus = READ_CSR(mstatus);
#ifdef CONFIG_ARCH_FPU
return (MSTATUS_FS_INIT | MSTATUS_MPPM | MSTATUS_MPIE);
return (mstatus | MSTATUS_FS_INIT | MSTATUS_MPPM | MSTATUS_MPIE);
#else
return (MSTATUS_MPPM | MSTATUS_MPIE);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
#endif
}
+1 -1
View File
@@ -197,7 +197,7 @@ void riscv_copyfullstate(uintptr_t *dest, uintptr_t *src);
void riscv_sigdeliver(void);
int riscv_swint(int irq, void *context, void *arg);
uint32_t riscv_get_newintctx(void);
uintptr_t riscv_get_newintctx(void);
#ifdef CONFIG_ARCH_FPU
void riscv_savefpu(uintptr_t *regs);
+5 -2
View File
@@ -35,6 +35,7 @@
#include <arch/irq.h>
#include <arch/csr.h>
#include <stdint.h>
#include "riscv_internal.h"
#include "hardware/esp32c3_interrupt.h"
@@ -141,13 +142,15 @@ void up_irqinitialize(void)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode.
* Also set machine previous interrupt enable
*/
return (MSTATUS_MPPM | MSTATUS_MPIE);
uintptr_t mstatus = READ_CSR(mstatus);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
}
/****************************************************************************
+4 -2
View File
@@ -173,13 +173,15 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode.
* Also set machine previous interrupt enable
*/
return (MSTATUS_MPPM | MSTATUS_MPIE);
uintptr_t mstatus = READ_CSR(mstatus);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
}
/****************************************************************************
+4 -2
View File
@@ -218,7 +218,7 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode. Reegardless of
* how NuttX is configured and of what kind of thread is being started.
@@ -228,7 +228,9 @@ uint32_t riscv_get_newintctx(void)
* user code. Also set machine previous interrupt enable.
*/
return (MSTATUS_MPPM | MSTATUS_MPIE);
uintptr_t mstatus = READ_CSR(mstatus);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
}
/****************************************************************************
+4 -2
View File
@@ -179,13 +179,15 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode.
* Also set machine previous interrupt enable
*/
return (MSTATUS_MPPM | MSTATUS_MPIE);
uintptr_t mstatus = READ_CSR(mstatus);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
}
/****************************************************************************
+5 -3
View File
@@ -270,7 +270,7 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode. Reegardless of
* how NuttX is configured and of what kind of thread is being started.
@@ -280,10 +280,12 @@ uint32_t riscv_get_newintctx(void)
* user code. Also set machine previous interrupt enable.
*/
uintptr_t mstatus = READ_CSR(mstatus);
#ifdef CONFIG_ARCH_FPU
return (MSTATUS_FS_INIT | MSTATUS_MPPM | MSTATUS_MPIE);
return (mstatus | MSTATUS_FS_INIT | MSTATUS_MPPM | MSTATUS_MPIE);
#else
return (MSTATUS_MPPM | MSTATUS_MPIE);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
#endif
}
+8 -2
View File
@@ -214,12 +214,18 @@ irqstate_t up_irq_enable(void)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode.
* Also set machine previous interrupt enable
* Note: In qemu, FPU is always exist even if don't use F|D ISA extension
*/
return (MSTATUS_MPPM | MSTATUS_MPIE | MSTATUS_FS_INIT);
uintptr_t mstatus = READ_CSR(mstatus);
#ifdef CONFIG_ARCH_FPU
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE | MSTATUS_FS_INIT);
#else
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
#endif
}
+4 -2
View File
@@ -221,13 +221,15 @@ void up_enable_irq(int irq)
*
****************************************************************************/
uint32_t riscv_get_newintctx(void)
uintptr_t riscv_get_newintctx(void)
{
/* Set machine previous privilege mode to machine mode.
* Also set machine previous interrupt enable
*/
return (MSTATUS_MPPM | MSTATUS_MPIE);
uintptr_t mstatus = READ_CSR(mstatus);
return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE);
}
/****************************************************************************