Changeset 7b8a920 in rtems


Ignore:
Timestamp:
Jan 26, 2017, 9:52:31 AM (3 years ago)
Author:
Martin Aberg <maberg@…>
Branches:
5, master
Children:
c297060
Parents:
bc40b4d
git-author:
Martin Aberg <maberg@…> (01/26/17 09:52:31)
git-committer:
Daniel Hellstrom <daniel@…> (05/14/17 10:31:57)
Message:

leon, grcan: use RTEMS 4.12 SMP interrupt lock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/shared/can/grcan.c

    rbc40b4d r7b8a920  
    2323#include <ambapp.h>
    2424
     25#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x040b63)
     26
     27/* Spin locks mapped via rtems_interrupt_lock_* API: */
     28#define SPIN_DECLARE(lock) RTEMS_INTERRUPT_LOCK_MEMBER(lock)
     29#define SPIN_INIT(lock, name) rtems_interrupt_lock_initialize(lock, name)
     30#define SPIN_LOCK(lock, level) rtems_interrupt_lock_acquire_isr(lock, &level)
     31#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_lock_acquire(lock, &level)
     32#define SPIN_UNLOCK(lock, level) rtems_interrupt_lock_release_isr(lock, &level)
     33#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_lock_release(lock, &level)
     34#define SPIN_IRQFLAGS(k) rtems_interrupt_lock_context k
     35#define SPIN_ISR_IRQFLAGS(k) SPIN_IRQFLAGS(k)
     36
     37#else
     38
     39/* maintain compatibility with older versions of RTEMS: */
     40#define SPIN_DECLARE(name)
     41#define SPIN_INIT(lock, name)
     42#define SPIN_LOCK(lock, level)
     43#define SPIN_LOCK_IRQ(lock, level) rtems_interrupt_disable(level)
     44#define SPIN_UNLOCK(lock, level)
     45#define SPIN_UNLOCK_IRQ(lock, level) rtems_interrupt_enable(level)
     46#define SPIN_IRQFLAGS(k) rtems_interrupt_level k
     47#define SPIN_ISR_IRQFLAGS(k)
     48
     49#endif
     50
    2551/* Maximum number of GRCAN devices supported by driver */
    2652#define GRCAN_COUNT_MAX 8
     
    4268#ifndef RX_BUF_SIZE
    4369 #define RX_BUF_SIZE ((3*BLOCK_SIZE)*16)
    44 #endif
    45 
    46 #ifndef IRQ_GLOBAL_PREPARE
    47  #define IRQ_GLOBAL_PREPARE(level) rtems_interrupt_level level
    48 #endif
    49 
    50 #ifndef IRQ_GLOBAL_DISABLE
    51  #define IRQ_GLOBAL_DISABLE(level) rtems_interrupt_disable(level)
    52 #endif
    53 
    54 #ifndef IRQ_GLOBAL_ENABLE
    55  #define IRQ_GLOBAL_ENABLE(level) rtems_interrupt_enable(level)
    5670#endif
    5771
     
    138152
    139153        rtems_id rx_sem, tx_sem, txempty_sem, dev_sem;
     154        SPIN_DECLARE(devlock);
    140155};
    141156
     
    385400        unsigned int tmp RTEMS_UNUSED;
    386401
    387         IRQ_GLOBAL_PREPARE(oldLevel);
     402        SPIN_IRQFLAGS(oldLevel);
    388403
    389404        FUNCDBG();
     
    429444
    430445        /* Enable routing of the IRQs */
    431         IRQ_GLOBAL_DISABLE(oldLevel);
     446        SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
    432447        IRQ_UNMASK(pDev->irq + GRCAN_IRQ_TXSYNC);
    433448        IRQ_UNMASK(pDev->irq + GRCAN_IRQ_RXSYNC);
    434449        IRQ_UNMASK(pDev->irq + GRCAN_IRQ_IRQ);
    435         IRQ_GLOBAL_ENABLE(oldLevel);
     450        SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
    436451
    437452        /* Reset some software data */
     
    869884        unsigned int irq_trunk, dataavail;
    870885        int wait;
    871         IRQ_GLOBAL_PREPARE(oldLevel);
     886        SPIN_IRQFLAGS(oldLevel);
    872887
    873888        FUNCDBG();
     
    877892         * when one or more messages are received
    878893         */
    879         IRQ_GLOBAL_DISABLE(oldLevel);
     894        SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
    880895
    881896        size = READ_REG(&pDev->regs->rx0size);
     
    910925                wait = 0;
    911926        }
    912         IRQ_GLOBAL_ENABLE(oldLevel);
     927        SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
    913928
    914929        /* Wait for IRQ to fire only if has been triggered */
     
    939954        unsigned int irq, rp, wp, size, space_left;
    940955        unsigned int irq_trunk;
    941         IRQ_GLOBAL_PREPARE(oldLevel);
     956        SPIN_IRQFLAGS(oldLevel);
    942957
    943958        DBGC(DBG_TX, "\n");
    944959        /*FUNCDBG(); */
    945960
    946         IRQ_GLOBAL_DISABLE(oldLevel);
     961        SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
    947962
    948963        pDev->regs->tx0ctrl = GRCAN_TXCTRL_ENABLE;
     
    9861001                wait = 0;
    9871002        }
    988         IRQ_GLOBAL_ENABLE(oldLevel);
     1003        SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
    9891004
    9901005        /* Wait for IRQ to fire only if it has been triggered */
     
    10061021        int wait;
    10071022        unsigned int rp, wp;
    1008         IRQ_GLOBAL_PREPARE(oldLevel);
     1023        SPIN_IRQFLAGS(oldLevel);
    10091024        FUNCDBG();
    10101025
     
    10191034        ) {
    10201035                /* Wait for TX empty IRQ */
    1021                 IRQ_GLOBAL_DISABLE(oldLevel);
     1036                SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
    10221037                /* Clear pending TXEmpty IRQ */
    10231038                pDev->regs->picr = GRCAN_TXEMPTY_IRQ;
     
    10321047                        wait = 0;
    10331048                }
    1034                 IRQ_GLOBAL_ENABLE(oldLevel);
     1049                SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
    10351050                if (!wait)
    10361051                        break;
     
    11891204        }
    11901205
     1206        SPIN_INIT(&pDev->devlock, pDev->devName);
     1207
    11911208        /* Mark device taken */
    11921209        pDev->open = 1;
     
    16101627{
    16111628        struct grcan_priv *pDev = d;
    1612         IRQ_GLOBAL_PREPARE(oldLevel);
    1613 
    1614         FUNCDBG();
    1615 
    1616         IRQ_GLOBAL_DISABLE(oldLevel);
     1629        SPIN_IRQFLAGS(oldLevel);
     1630
     1631        FUNCDBG();
     1632
     1633        SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
    16171634        memset(&pDev->stats,0,sizeof(struct grcan_stats));
    1618         IRQ_GLOBAL_ENABLE(oldLevel);
     1635        SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
    16191636
    16201637        return 0;
Note: See TracChangeset for help on using the changeset viewer.