source: rtems/bsps/m68k/mvme147s/mpci/lock.c @ 1efa1c8

5
Last change on this file since 1efa1c8 was 1efa1c8, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 11:38:33

bsps: Move MPCI support to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  Shared Memory Lock Routines
2 *
3 *  This shared memory locked queue support routine need to be
4 *  able to lock the specified locked queue.  Interrupts are
5 *  disabled while the queue is locked to prevent preemption
6 *  and deadlock when two tasks poll for the same lock.
7 *  previous level.
8 *
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#include <rtems.h>
18#include <bsp.h>
19#include <shm_driver.h>
20
21/*
22 *  Shm_Initialize_lock
23 *
24 *  Initialize the lock for the specified locked queue.
25 */
26
27void Shm_Initialize_lock(
28  Shm_Locked_queue_Control *lq_cb
29)
30{
31  lq_cb->lock = LQ_UNLOCKED;
32}
33
34/*  void _Shm_Lock( &lq_cb )
35 *
36 *  This shared memory locked queue support routine locks the
37 *  specified locked queue.  It disables interrupts to prevent
38 *  a deadlock condition.
39 */
40
41void Shm_Lock(
42  Shm_Locked_queue_Control *lq_cb
43)
44{
45  uint32_t         isr_level;
46  uint32_t         *lockptr = (uint32_t*)&lq_cb->lock;
47
48  rtems_interrupt_disable( isr_level );
49    Shm_isrstat = isr_level;
50    __asm__ volatile( "lockit:"    : : );
51    __asm__ volatile( "tas %0@"    : "=a" (lockptr) : "0" (lockptr) );
52    __asm__ volatile( "bne lockit" : : );
53/* should delay */
54}
55
56/*
57 *  Shm_Unlock
58 *
59 *  Unlock the lock for the specified locked queue.
60 */
61
62void Shm_Unlock(
63  Shm_Locked_queue_Control *lq_cb
64)
65{
66  uint32_t         isr_level;
67
68  lq_cb->lock = SHM_UNLOCK_VALUE;
69  isr_level = Shm_isrstat;
70  rtems_interrupt_enable( isr_level );
71}
Note: See TracBrowser for help on using the repository browser.