mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user