From 0aa7e39eef6c9ab1c2808ae49cd934f4c38788a9 Mon Sep 17 00:00:00 2001 From: guoshichao Date: Thu, 22 Feb 2024 11:14:06 +0800 Subject: [PATCH] nuttx/arch/irq: add up_irq_disable method implementation Signed-off-by: guoshichao --- arch/arm/include/armv7-r/irq.h | 18 ++++++++++++++++++ arch/arm/include/armv8-r/irq.h | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/arm/include/armv7-r/irq.h b/arch/arm/include/armv7-r/irq.h index a31c90ebbb..cbfaab7315 100644 --- a/arch/arm/include/armv7-r/irq.h +++ b/arch/arm/include/armv7-r/irq.h @@ -389,6 +389,24 @@ static inline irqstate_t up_irq_enable(void) return cpsr; } +/* Disable IRQs and return the previous IRQ state */ + +static inline irqstate_t up_irq_disable(void) +{ + unsigned int cpsr; + + __asm__ __volatile__ + ( + "\tmrs %0, cpsr\n" + "\tcpsid i\n" + : "=r" (cpsr) + : + : "memory" + ); + + return cpsr; +} + /* Restore saved IRQ & FIQ state */ static inline void up_irq_restore(irqstate_t flags) diff --git a/arch/arm/include/armv8-r/irq.h b/arch/arm/include/armv8-r/irq.h index b0e1a9ff8d..2f4216fb04 100644 --- a/arch/arm/include/armv8-r/irq.h +++ b/arch/arm/include/armv8-r/irq.h @@ -389,6 +389,24 @@ static inline irqstate_t up_irq_enable(void) return cpsr; } +/* Disable IRQs and return the previous IRQ state */ + +static inline irqstate_t up_irq_disable(void) +{ + unsigned int cpsr; + + __asm__ __volatile__ + ( + "\tmrs %0, cpsr\n" + "\tcpsid i\n" + : "=r" (cpsr) + : + : "memory" + ); + + return cpsr; +} + /* Restore saved IRQ & FIQ state */ static inline void up_irq_restore(irqstate_t flags)