Changeset 6fdded2c in rtems


Ignore:
Timestamp:
May 10, 2017, 10:39:23 AM (3 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
master
Children:
818f10bc
Parents:
3feae3b
git-author:
Daniel Hellstrom <daniel@…> (05/10/17 10:39:23)
git-committer:
Daniel Hellstrom <daniel@…> (05/14/17 10:32:00)
Message:

leon, gr1553bm: SMP support by using spin-locks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/shared/1553/gr1553bm.c

    r3feae3b r6fdded2c  
    2424#define GR1553BM_READ_REG(adr) (*(volatile uint32_t *)(adr))
    2525
    26 #ifndef IRQ_GLOBAL_PREPARE
    27  #define IRQ_GLOBAL_PREPARE(level) rtems_interrupt_level level
     26/* Use interrupt lock privmitives compatible with SMP defined in
     27 * RTEMS 4.11.99 and higher.
     28 */
     29#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
     30
     31/* map via rtems_interrupt_lock_* API: */
     32#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
     33#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
     34#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
     35#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
     36#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
     37#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
     38#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
     39#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
     40#define SPIN_FREE(lock) rtems_interrupt_lock_destroy(lock)
     41
     42#else
     43
     44/* maintain single-core compatibility with older versions of RTEMS: */
     45#define SPIN_DECLARE(name)
     46#define SPIN_INIT(lock, name)
     47#define SPIN_LOCK(lock, level)
     48#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
     49#define SPIN_UNLOCK(lock, level)
     50#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
     51#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
     52#define SPIN_ISR_IRQFLAGS(k)
     53#define SPIN_FREE(lock)
     54
     55#ifdef RTEMS_SMP
     56#error SMP mode not compatible with these interrupt lock primitives
    2857#endif
    2958
    30 #ifndef IRQ_GLOBAL_DISABLE
    31  #define IRQ_GLOBAL_DISABLE(level) rtems_interrupt_disable(level)
    32 #endif
    33 
    34 #ifndef IRQ_GLOBAL_ENABLE
    35  #define IRQ_GLOBAL_ENABLE(level) rtems_interrupt_enable(level)
    3659#endif
    3760
     
    3962        struct drvmgr_dev **pdev;
    4063        struct gr1553b_regs *regs;
     64        SPIN_DECLARE(devlock);
    4165
    4266        void *buffer;
     
    81105static void gr1553bm_hw_start(struct gr1553bm_priv *priv)
    82106{
    83         IRQ_GLOBAL_PREPARE(oldLevel);
     107        SPIN_IRQFLAGS(irqflags);
    84108
    85109        /* Enable IRQ source and mark running state */
    86         IRQ_GLOBAL_DISABLE(oldLevel);
     110        SPIN_LOCK_IRQ(&priv->devlock, irqflags);
    87111
    88112        priv->started = 1;
     
    104128                | GR1553B_BM_CTRL_BMEN;
    105129
    106         IRQ_GLOBAL_ENABLE(oldLevel);
     130        SPIN_UNLOCK_IRQ(&priv->devlock, irqflags);
    107131}
    108132
    109133static void gr1553bm_hw_stop(struct gr1553bm_priv *priv)
    110134{
    111         IRQ_GLOBAL_PREPARE(oldLevel);
    112 
    113         IRQ_GLOBAL_DISABLE(oldLevel);
     135        SPIN_IRQFLAGS(irqflags);
     136
     137        SPIN_LOCK_IRQ(&priv->devlock, irqflags);
    114138
    115139        /* Stop Logging */
     
    124148        priv->started = 0;
    125149
    126         IRQ_GLOBAL_ENABLE(oldLevel);
     150        SPIN_UNLOCK_IRQ(&priv->devlock, irqflags);
    127151}
    128152
     
    153177        pnpinfo = &ambadev->info;
    154178        priv->regs = (struct gr1553b_regs *)pnpinfo->apb_slv->start;
     179        SPIN_INIT(&priv->devlock, "gr1553bm");
    155180
    156181        /* Start with default configuration */
Note: See TracChangeset for help on using the changeset viewer.