1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreAPIMutex |
---|
5 | * |
---|
6 | * @brief API Mutex Handler API. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2008. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
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.rtems.com/license/LICENSE. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef _RTEMS_SCORE_APIMUTEX_H |
---|
21 | #define _RTEMS_SCORE_APIMUTEX_H |
---|
22 | |
---|
23 | #ifdef __cplusplus |
---|
24 | extern "C" { |
---|
25 | #endif |
---|
26 | |
---|
27 | /** |
---|
28 | * @defgroup ScoreAPIMutex API Mutex Handler |
---|
29 | * |
---|
30 | * @ingroup Score |
---|
31 | * |
---|
32 | * @brief Provides routines to ensure mutual exclusion on API level. |
---|
33 | * |
---|
34 | * @{ |
---|
35 | */ |
---|
36 | |
---|
37 | #include <rtems/score/coremutex.h> |
---|
38 | #include <rtems/score/isr.h> |
---|
39 | #include <rtems/score/object.h> |
---|
40 | |
---|
41 | /** |
---|
42 | * @brief Control block used to manage each API mutex. |
---|
43 | */ |
---|
44 | typedef struct { |
---|
45 | /** |
---|
46 | * @brief Allows each API Mutex to be a full-fledged RTEMS object. |
---|
47 | */ |
---|
48 | Objects_Control Object; |
---|
49 | |
---|
50 | /** |
---|
51 | * Contains the SuperCore mutex information. |
---|
52 | */ |
---|
53 | CORE_mutex_Control Mutex; |
---|
54 | } API_Mutex_Control; |
---|
55 | |
---|
56 | /** |
---|
57 | * @brief Information control block used to manage this class of objects. |
---|
58 | */ |
---|
59 | SCORE_EXTERN Objects_Information _API_Mutex_Information; |
---|
60 | |
---|
61 | /** |
---|
62 | * @brief Performs the initialization necessary for this handler. |
---|
63 | * |
---|
64 | * The value @a maximum_mutexes is the maximum number of API mutexes that may |
---|
65 | * exist at any time. |
---|
66 | */ |
---|
67 | void _API_Mutex_Initialization( uint32_t maximum_mutexes ); |
---|
68 | |
---|
69 | /** |
---|
70 | * @brief Allocates an API mutex from the inactive set and returns it in |
---|
71 | * @a mutex. |
---|
72 | */ |
---|
73 | void _API_Mutex_Allocate( API_Mutex_Control **mutex ); |
---|
74 | |
---|
75 | /** |
---|
76 | * @brief Acquires the specified API mutex @a mutex. |
---|
77 | */ |
---|
78 | void _API_Mutex_Lock( API_Mutex_Control *mutex ); |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief Releases the specified API mutex @a mutex. |
---|
82 | */ |
---|
83 | void _API_Mutex_Unlock( API_Mutex_Control *mutex ); |
---|
84 | |
---|
85 | /** @} */ |
---|
86 | |
---|
87 | /** |
---|
88 | * @defgroup ScoreAllocatorMutex RTEMS Allocator Mutex |
---|
89 | * |
---|
90 | * @ingroup ScoreAPIMutex |
---|
91 | * |
---|
92 | * @brief Protection for all memory allocations and deallocations in RTEMS. |
---|
93 | * |
---|
94 | * When the APIs all use this for allocation and deallocation protection, then |
---|
95 | * this possibly should be renamed and moved to a higher level in the |
---|
96 | * hierarchy. |
---|
97 | * |
---|
98 | * @{ |
---|
99 | */ |
---|
100 | |
---|
101 | SCORE_EXTERN API_Mutex_Control *_RTEMS_Allocator_Mutex; |
---|
102 | |
---|
103 | #define _RTEMS_Lock_allocator() \ |
---|
104 | _API_Mutex_Lock( _RTEMS_Allocator_Mutex ) |
---|
105 | |
---|
106 | #define _RTEMS_Unlock_allocator() \ |
---|
107 | _API_Mutex_Unlock( _RTEMS_Allocator_Mutex ) |
---|
108 | |
---|
109 | /** @} */ |
---|
110 | |
---|
111 | #ifdef __cplusplus |
---|
112 | } |
---|
113 | #endif |
---|
114 | |
---|
115 | #endif |
---|
116 | /* end of include file */ |
---|