From 172d467c26303408887c2fbd7aecb5887789bff3 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Sun, 1 Jan 2023 22:33:52 +0800 Subject: [PATCH] arch:add faultmask register operation to armv7-m & armv8-m Signed-off-by: anjiahao --- arch/arm/include/armv7-m/irq.h | 27 +++++++++++++++++++++++++++ arch/arm/include/armv8-m/irq.h | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arch/arm/include/armv7-m/irq.h b/arch/arm/include/armv7-m/irq.h index 772ba5e6e2..10bc465615 100644 --- a/arch/arm/include/armv7-m/irq.h +++ b/arch/arm/include/armv7-m/irq.h @@ -474,6 +474,33 @@ static inline uint32_t getipsr(void) return ipsr; } +/* Get/set FAULTMASK */ + +static inline uint32_t getfaultmask(void) always_inline_function; +static inline uint32_t getfaultmask(void) +{ + uint32_t faultmask; + __asm__ __volatile__ + ( + "\tmrs %0, faultmask\n" + : "=r" (faultmask) + : + : "memory"); + + return faultmask; +} + +static inline void setfaultmask(uint32_t faultmask) always_inline_function; +static inline void setfaultmask(uint32_t faultmask) +{ + __asm__ __volatile__ + ( + "\tmsr faultmask, %0\n" + : + : "r" (faultmask) + : "memory"); +} + /* Get/set CONTROL */ static inline uint32_t getcontrol(void) always_inline_function; diff --git a/arch/arm/include/armv8-m/irq.h b/arch/arm/include/armv8-m/irq.h index 86d135b02b..066a575427 100644 --- a/arch/arm/include/armv8-m/irq.h +++ b/arch/arm/include/armv8-m/irq.h @@ -451,6 +451,33 @@ static inline uint32_t getipsr(void) return ipsr; } +/* Get/set FAULTMASK */ + +static inline uint32_t getfaultmask(void) always_inline_function; +static inline uint32_t getfaultmask(void) +{ + uint32_t faultmask; + __asm__ __volatile__ + ( + "\tmrs %0, faultmask\n" + : "=r" (faultmask) + : + : "memory"); + + return faultmask; +} + +static inline void setfaultmask(uint32_t faultmask) always_inline_function; +static inline void setfaultmask(uint32_t faultmask) +{ + __asm__ __volatile__ + ( + "\tmsr faultmask, %0\n" + : + : "r" (faultmask) + : "memory"); +} + /* Get/set CONTROL */ static inline uint32_t getcontrol(void) always_inline_function;