diff --git a/arch/arm/include/armv6-m/irq.h b/arch/arm/include/armv6-m/irq.h index 10d9238839..13921fa503 100644 --- a/arch/arm/include/armv6-m/irq.h +++ b/arch/arm/include/armv6-m/irq.h @@ -323,6 +323,20 @@ static always_inline_function void setcontrol(uint32_t control) : "memory"); } +static always_inline_function uint32_t getpsp(void) +{ + uint32_t psp; + + __asm__ __volatile__ + ( + "\tmrs %0, psp\n" + : "=r" (psp) + : + : "memory"); + + return psp; +} + /**************************************************************************** * Name: up_cpu_index * diff --git a/arch/arm/include/armv7-m/irq.h b/arch/arm/include/armv7-m/irq.h index c09b79fb31..207dbfc3c1 100644 --- a/arch/arm/include/armv7-m/irq.h +++ b/arch/arm/include/armv7-m/irq.h @@ -473,6 +473,20 @@ static always_inline_function void setcontrol(uint32_t control) : "memory"); } +static always_inline_function uint32_t getpsp(void) +{ + uint32_t psp; + + __asm__ __volatile__ + ( + "\tmrs %0, psp\n" + : "=r" (psp) + : + : "memory"); + + return psp; +} + /**************************************************************************** * Name: up_cpu_index * diff --git a/arch/arm/include/armv8-m/irq.h b/arch/arm/include/armv8-m/irq.h index 09940739d6..66a51f274c 100644 --- a/arch/arm/include/armv8-m/irq.h +++ b/arch/arm/include/armv8-m/irq.h @@ -448,6 +448,20 @@ static always_inline_function void setcontrol(uint32_t control) : "memory"); } +static always_inline_function uint32_t getpsp(void) +{ + uint32_t psp; + + __asm__ __volatile__ + ( + "\tmrs %0, psp\n" + : "=r" (psp) + : + : "memory"); + + return psp; +} + /**************************************************************************** * Name: up_cpu_index *