source: rtems/c/src/lib/libbsp/m68k/mvme136/shmsupp/lock.c @ df49c60

4.104.114.84.95
Last change on this file since df49c60 was 48bfd992, checked in by Joel Sherrill <joel.sherrill@…>, on 11/30/99 at 19:58:02

Renamed shm.h to shm_driver.h to avoid conflicts with POSIX shm.h.

Renamed file shmsupp/intr.c in some BSPs to shmsupp/cause_intr.c to
avoid conflict with rtems/src/intr.c (Classic API Interrupt Manager).

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[ac7d5ef0]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 *
[08311cc3]9 *  COPYRIGHT (c) 1989-1999.
[ac7d5ef0]10 *  On-Line Applications Research Corporation (OAR).
11 *
[98e4ebf5]12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
[03f2154e]14 *  http://www.OARcorp.com/rtems/license.html.
[ac7d5ef0]15 *
16 *  $Id$
17 */
18
19#include <rtems.h>
20#include <bsp.h>
[48bfd992]21#include <shm_driver.h>
[ac7d5ef0]22
23/*
24 *  Shm_Initialize_lock
25 *
26 *  Initialize the lock for the specified locked queue.
27 */
28
29void Shm_Initialize_lock(
30  Shm_Locked_queue_Control *lq_cb
31)
32{
33  lq_cb->lock = LQ_UNLOCKED;
34}
35
36/*  void _Shm_Lock( &lq_cb )
37 *
38 *  This shared memory locked queue support routine locks the
39 *  specified locked queue.  It disables interrupts to prevent
40 *  a deadlock condition.
41 */
42
43void Shm_Lock(
44  Shm_Locked_queue_Control *lq_cb
45)
46{
47  rtems_unsigned32 isr_level;
48  rtems_unsigned32 *lockptr = (rtems_unsigned32 *)&lq_cb->lock;
49
50  rtems_interrupt_disable( isr_level );
51    Shm_isrstat = isr_level;
52    asm volatile( "lockit:"    : : );
53    asm volatile( "tas %0@"    : "=a" (lockptr) : "0" (lockptr) );
54    asm volatile( "bne lockit" : : );
55/* should delay */
56}
57
58/*
59 *  Shm_Unlock
60 *
61 *  Unlock the lock for the specified locked queue.
62 */
63
64void Shm_Unlock(
65  Shm_Locked_queue_Control *lq_cb
66)
67{
68  rtems_unsigned32 isr_level;
69
70  lq_cb->lock = SHM_UNLOCK_VALUE;
71  isr_level = Shm_isrstat;
72  rtems_interrupt_enable( isr_level );
73}
74
Note: See TracBrowser for help on using the repository browser.