riscv: Add inline IRQ process functions
Remove functions from RISC-V chips.
This commit is contained in:
parent
35a7902367
commit
60fb1adaca
@ -72,36 +72,4 @@
|
||||
|
||||
#define NR_IRQS (C906_IRQ_UART0 + 1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN irqstate_t up_irq_save(void);
|
||||
EXTERN void up_irq_restore(irqstate_t);
|
||||
EXTERN irqstate_t up_irq_enable(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_RISCV_INCLUDE_C906_IRQ_H */
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <arch/csr.h>
|
||||
# include <arch/irq.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -227,89 +228,4 @@
|
||||
|
||||
#define NR_IRQS (RISCV_NIRQ_INTERRUPTS + ESP32C3_NIRQ_PERIPH + ESP32C3_NIRQ_GPIO)
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore the value of the mstatus register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"csrw mstatus, %0" : /* no output */ : "r" (flags)
|
||||
);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Disable interrupts and return the previous value of the mstatus register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline irqstate_t up_irq_save(void)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"csrrc %0, mstatus, %1" : "=r" (flags) : "r"(MSTATUS_MIE)
|
||||
);
|
||||
|
||||
/* Return the previous mstatus value so that it can be restored with
|
||||
* up_irq_restore().
|
||||
*/
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and enable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline irqstate_t up_irq_enable(void)
|
||||
{
|
||||
uint32_t flags;
|
||||
|
||||
/* Read mstatus & set machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"csrrs %0, mstatus, %1": "=r" (flags) : "r"(MSTATUS_MIE)
|
||||
);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_disable
|
||||
*
|
||||
* Description:
|
||||
* Disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void up_irq_disable(void)
|
||||
{
|
||||
up_irq_save();
|
||||
}
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_RISCV_INCLUDE_ESP32C3_IRQ_H */
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/csr.h>
|
||||
#include <arch/chip/irq.h>
|
||||
|
||||
/* Include RISC-V architecture-specific IRQ definitions */
|
||||
@ -64,12 +65,70 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Disable interrupts and return the previous value of the mstatus register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline irqstate_t up_irq_save(void)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"csrrc %0, mstatus, %1\n"
|
||||
: "=r" (flags)
|
||||
: "r"(MSTATUS_MIE)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
/* Return the previous mstatus value so that it can be restored with
|
||||
* up_irq_restore().
|
||||
*/
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore the value of the mstatus register
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"csrw mstatus, %0\n"
|
||||
: /* no output */
|
||||
: "r" (flags)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN irqstate_t up_irq_save(void);
|
||||
EXTERN void up_irq_restore(irqstate_t);
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and enable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN irqstate_t up_irq_enable(void);
|
||||
|
||||
#undef EXTERN
|
||||
|
@ -305,36 +305,4 @@
|
||||
|
||||
#define NR_IRQS (MPFS_IRQ_BUS_ERROR_UNIT_HART_4 + 1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN irqstate_t up_irq_save(void);
|
||||
EXTERN void up_irq_restore(irqstate_t);
|
||||
EXTERN irqstate_t up_irq_enable(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_RISCV_INCLUDE_MPFS_IRQ_H */
|
||||
|
@ -203,41 +203,6 @@ void riscv_ack_irq(int irq)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint32_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile("csrrc %0, mstatus, %1" : "=r"(oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0"
|
||||
: /* no output */
|
||||
: "r"(flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
@ -234,39 +234,6 @@ void riscv_ack_irq(int irq)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint64_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile ("csrrc %0, mstatus, %1": "=r" (oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0" : /* no output */ : "r" (flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
@ -416,3 +416,28 @@ IRAM_ATTR uint32_t *esp32c3_dispatch_irq(uint32_t mcause, uint32_t *regs)
|
||||
|
||||
return regs;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and enable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_enable(void)
|
||||
{
|
||||
uint32_t flags;
|
||||
|
||||
/* Read mstatus & set machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"csrrs %0, mstatus, %1\n"
|
||||
: "=r" (flags)
|
||||
: "r"(MSTATUS_MIE)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
@ -198,39 +198,6 @@ void riscv_ack_irq(int irq)
|
||||
board_autoled_on(LED_CPU);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint32_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile ("csrrc %0, mstatus, %1": "=r" (oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0" : /* no output */ : "r" (flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
@ -254,39 +254,6 @@ void riscv_ack_irq(int irq)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint64_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile ("csrrc %0, mstatus, %1": "=r" (oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0" : /* no output */ : "r" (flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
@ -203,39 +203,6 @@ void riscv_ack_irq(int irq)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint32_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile ("csrrc %0, mstatus, %1": "=r" (oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0" : /* no output */ : "r" (flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
@ -261,39 +261,6 @@ void riscv_ack_irq(int irq)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint64_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile ("csrrc %0, mstatus, %1": "=r" (oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0" : /* no output */ : "r" (flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
@ -244,41 +244,6 @@ void riscv_ack_irq(int irq)
|
||||
board_autoled_on(LED_CPU);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_save
|
||||
*
|
||||
* Description:
|
||||
* Return the current interrupt state and disable interrupts
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
LOCATE_ITCM
|
||||
irqstate_t up_irq_save(void)
|
||||
{
|
||||
uint32_t oldstat;
|
||||
|
||||
/* Read mstatus & clear machine interrupt enable (MIE) in mstatus */
|
||||
|
||||
asm volatile ("csrrc %0, mstatus, %1": "=r" (oldstat) : "r"(MSTATUS_MIE));
|
||||
return oldstat;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore previous IRQ mask state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
LOCATE_ITCM
|
||||
void up_irq_restore(irqstate_t flags)
|
||||
{
|
||||
/* Write flags to mstatus */
|
||||
|
||||
asm volatile("csrw mstatus, %0" : /* no output */ : "r" (flags));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_irq_enable
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user