mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 01:38:36 +08:00
use small lock to protect g_ram_vectors, involving armv6-m, armv7-m, armv8-m.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
This commit is contained in:
parent
d84ba608a1
commit
b9837bed08
3 changed files with 27 additions and 6 deletions
|
@ -31,11 +31,18 @@
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/spinlock.h>
|
||||||
|
|
||||||
#include "ram_vectors.h"
|
#include "ram_vectors.h"
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_RAMVECTORS
|
#ifdef CONFIG_ARCH_RAMVECTORS
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static spinlock_t g_ramvec_lock = SP_UNLOCKED;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
|
||||||
* common exception handler.
|
* common exception handler.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_ramvec_lock);
|
||||||
if (vector == NULL)
|
if (vector == NULL)
|
||||||
{
|
{
|
||||||
/* Disable the interrupt if we can before detaching it. We might
|
/* 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 */
|
/* Save the new vector in the vector table */
|
||||||
|
|
||||||
g_ram_vectors[irq] = vector;
|
g_ram_vectors[irq] = vector;
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_ramvec_lock, flags);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,18 @@
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/spinlock.h>
|
||||||
|
|
||||||
#include "ram_vectors.h"
|
#include "ram_vectors.h"
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_RAMVECTORS
|
#ifdef CONFIG_ARCH_RAMVECTORS
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static spinlock_t g_ramvec_lock = SP_UNLOCKED;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
|
||||||
* common exception handler.
|
* common exception handler.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_ramvec_lock);
|
||||||
if (vector == NULL)
|
if (vector == NULL)
|
||||||
{
|
{
|
||||||
/* Disable the interrupt if we can before detaching it. We might
|
/* 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 */
|
/* Save the new vector in the vector table */
|
||||||
|
|
||||||
g_ram_vectors[irq] = vector;
|
g_ram_vectors[irq] = vector;
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_ramvec_lock, flags);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,18 @@
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/spinlock.h>
|
||||||
|
|
||||||
#include "ram_vectors.h"
|
#include "ram_vectors.h"
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_RAMVECTORS
|
#ifdef CONFIG_ARCH_RAMVECTORS
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static spinlock_t g_ramvec_lock = SP_UNLOCKED;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
|
||||||
* common exception handler.
|
* common exception handler.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_ramvec_lock);
|
||||||
if (vector == NULL)
|
if (vector == NULL)
|
||||||
{
|
{
|
||||||
/* Disable the interrupt if we can before detaching it. We might
|
/* 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 */
|
/* Save the new vector in the vector table */
|
||||||
|
|
||||||
g_ram_vectors[irq] = vector;
|
g_ram_vectors[irq] = vector;
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_ramvec_lock, flags);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue