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-1997. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * Copyright assigned to U.S. Government, 1994. |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.OARcorp.com/rtems/license.html. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #include <bsp.h> |
---|
21 | #include <shm.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_cb - Shm_Locked_queues; |
---|
34 | } |
---|
35 | |
---|
36 | /* 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; |
---|
48 | |
---|
49 | rtems_interrupt_disable( isr_level ); |
---|
50 | |
---|
51 | Shm_isrstat = isr_level; |
---|
52 | |
---|
53 | _CPU_SHM_Lock( lq_cb->lock ); |
---|
54 | } |
---|
55 | |
---|
56 | /* |
---|
57 | * Shm_Unlock |
---|
58 | * |
---|
59 | * Unlock the lock for the specified locked queue. |
---|
60 | */ |
---|
61 | |
---|
62 | void Shm_Unlock( |
---|
63 | Shm_Locked_queue_Control *lq_cb |
---|
64 | ) |
---|
65 | { |
---|
66 | rtems_unsigned32 isr_level; |
---|
67 | |
---|
68 | _CPU_SHM_Unlock( lq_cb->lock ); |
---|
69 | |
---|
70 | isr_level = Shm_isrstat; |
---|
71 | rtems_interrupt_enable( isr_level ); |
---|
72 | } |
---|