diff --git a/arch/arm/src/armv6-m/arm_ramvec_attach.c b/arch/arm/src/armv6-m/arm_ramvec_attach.c index 221f47dcbb..7f72a547f1 100644 --- a/arch/arm/src/armv6-m/arm_ramvec_attach.c +++ b/arch/arm/src/armv6-m/arm_ramvec_attach.c @@ -31,11 +31,18 @@ #include #include +#include #include "ram_vectors.h" #ifdef CONFIG_ARCH_RAMVECTORS +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_ramvec_lock = SP_UNLOCKED; + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector) * common exception handler. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_ramvec_lock); if (vector == NULL) { /* Disable the interrupt if we can before detaching it. We might @@ -87,7 +94,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector) /* Save the new vector in the vector table */ g_ram_vectors[irq] = vector; - leave_critical_section(flags); + spin_unlock_irqrestore(&g_ramvec_lock, flags); ret = OK; } diff --git a/arch/arm/src/armv7-m/arm_ramvec_attach.c b/arch/arm/src/armv7-m/arm_ramvec_attach.c index 16899e0629..ad331046bc 100644 --- a/arch/arm/src/armv7-m/arm_ramvec_attach.c +++ b/arch/arm/src/armv7-m/arm_ramvec_attach.c @@ -31,11 +31,18 @@ #include #include +#include #include "ram_vectors.h" #ifdef CONFIG_ARCH_RAMVECTORS +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_ramvec_lock = SP_UNLOCKED; + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector) * common exception handler. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_ramvec_lock); if (vector == NULL) { /* Disable the interrupt if we can before detaching it. We might @@ -87,7 +94,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector) /* Save the new vector in the vector table */ g_ram_vectors[irq] = vector; - leave_critical_section(flags); + spin_unlock_irqrestore(&g_ramvec_lock, flags); ret = OK; } diff --git a/arch/arm/src/armv8-m/arm_ramvec_attach.c b/arch/arm/src/armv8-m/arm_ramvec_attach.c index d882431db2..a08ea3af21 100644 --- a/arch/arm/src/armv8-m/arm_ramvec_attach.c +++ b/arch/arm/src/armv8-m/arm_ramvec_attach.c @@ -31,11 +31,18 @@ #include #include +#include #include "ram_vectors.h" #ifdef CONFIG_ARCH_RAMVECTORS +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_ramvec_lock = SP_UNLOCKED; + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector) * common exception handler. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_ramvec_lock); if (vector == NULL) { /* Disable the interrupt if we can before detaching it. We might @@ -87,7 +94,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector) /* Save the new vector in the vector table */ g_ram_vectors[irq] = vector; - leave_critical_section(flags); + spin_unlock_irqrestore(&g_ramvec_lock, flags); ret = OK; }