OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [i960/] [cvme961/] [shmsupp/] [lock.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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.OARcorp.com/rtems/license.html.
15
 *
16
 *  $Id: lock.c,v 1.2 2001-09-27 11:59:56 chris Exp $
17
 */
18
 
19
#include <rtems.h>
20
#include <bsp.h>
21
#include <shm_driver.h>
22
 
23
/*
24
 *  Shm_Initialize_lock
25
 *
26
 *  Initialize the lock for the specified locked queue.
27
 */
28
 
29
void 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
 
43
void Shm_Lock(
44
  Shm_Locked_queue_Control *lq_cb
45
)
46
{
47
  rtems_unsigned32 isr_level, oldlock;
48
 
49
  rtems_interrupt_disable( isr_level );
50
    Shm_isrstat = isr_level;
51
    while ( 1 ) {
52
      atomic_modify( SHM_LOCK_VALUE, &lq_cb->lock, oldlock );
53
      if ( !(oldlock & SHM_LOCK_VALUE) )
54
        return;
55
      delay( 28 );        /* delay 28 microseconds */
56
    }
57
}
58
 
59
/*
60
 *  Shm_Unlock
61
 *
62
 *  Unlock the lock for the specified locked queue.
63
 */
64
 
65
void Shm_Unlock(
66
  Shm_Locked_queue_Control *lq_cb
67
)
68
{
69
  rtems_unsigned32 isr_level;
70
 
71
  lq_cb->lock = SHM_UNLOCK_VALUE;
72
  isr_level = Shm_isrstat;
73
  rtems_interrupt_enable( isr_level );
74
}
75
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.