[f839bf5a] | 1 | /** |
---|
| 2 | * @file |
---|
[a2e3f33] | 3 | * |
---|
| 4 | * @brief Initialization and Allocation for API Mutex Handler |
---|
[f839bf5a] | 5 | * |
---|
| 6 | * @ingroup ScoreAPIMutex |
---|
| 7 | */ |
---|
| 8 | |
---|
[8fd28d83] | 9 | /* |
---|
| 10 | * COPYRIGHT (c) 1989-2007. |
---|
| 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 |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[8fd28d83] | 16 | */ |
---|
| 17 | |
---|
| 18 | #if HAVE_CONFIG_H |
---|
| 19 | #include "config.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
| 22 | #include <rtems/score/apimutex.h> |
---|
[a2e3f33] | 23 | #include <rtems/score/coremuteximpl.h> |
---|
| 24 | #include <rtems/score/objectimpl.h> |
---|
| 25 | |
---|
| 26 | static Objects_Information _API_Mutex_Information; |
---|
[8fd28d83] | 27 | |
---|
| 28 | void _API_Mutex_Initialization( |
---|
| 29 | uint32_t maximum_mutexes |
---|
| 30 | ) |
---|
| 31 | { |
---|
| 32 | _Objects_Initialize_information( |
---|
| 33 | &_API_Mutex_Information, /* object information table */ |
---|
| 34 | OBJECTS_INTERNAL_API, /* object API */ |
---|
| 35 | OBJECTS_INTERNAL_MUTEXES, /* object class */ |
---|
| 36 | maximum_mutexes, /* maximum objects of this class */ |
---|
| 37 | sizeof( API_Mutex_Control ), /* size of this object's control block */ |
---|
[aae7f1a1] | 38 | false, /* true if the name is a string */ |
---|
[8fd28d83] | 39 | 0 /* maximum length of an object name */ |
---|
| 40 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 41 | , |
---|
[aae7f1a1] | 42 | true, /* true if this is a global object class */ |
---|
[8fd28d83] | 43 | NULL /* Proxy extraction support callout */ |
---|
| 44 | #endif |
---|
| 45 | ); |
---|
| 46 | } |
---|
[a2e3f33] | 47 | |
---|
| 48 | void _API_Mutex_Allocate( |
---|
| 49 | API_Mutex_Control **the_mutex |
---|
| 50 | ) |
---|
| 51 | { |
---|
| 52 | API_Mutex_Control *mutex; |
---|
| 53 | |
---|
| 54 | CORE_mutex_Attributes attr = { |
---|
| 55 | CORE_MUTEX_NESTING_ACQUIRES, |
---|
| 56 | false, |
---|
| 57 | CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT, |
---|
| 58 | 0 |
---|
| 59 | }; |
---|
| 60 | |
---|
[23fec9f0] | 61 | mutex = (API_Mutex_Control *) |
---|
| 62 | _Objects_Allocate_unprotected( &_API_Mutex_Information ); |
---|
[a2e3f33] | 63 | |
---|
[03e89287] | 64 | _CORE_mutex_Initialize( &mutex->Mutex, NULL, &attr, false ); |
---|
[a2e3f33] | 65 | |
---|
| 66 | _Objects_Open_u32( &_API_Mutex_Information, &mutex->Object, 1 ); |
---|
| 67 | |
---|
| 68 | *the_mutex = mutex; |
---|
| 69 | } |
---|