1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Semaphore Translate Core Mutex and Semaphore Return Code |
---|
5 | * @ingroup ClassicSem |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
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.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/rtems/status.h> |
---|
23 | #include <rtems/rtems/support.h> |
---|
24 | #include <rtems/rtems/attr.h> |
---|
25 | #include <rtems/score/isr.h> |
---|
26 | #include <rtems/score/object.h> |
---|
27 | #include <rtems/rtems/options.h> |
---|
28 | #include <rtems/rtems/sem.h> |
---|
29 | #include <rtems/score/coremutex.h> |
---|
30 | #include <rtems/score/coresem.h> |
---|
31 | #include <rtems/score/states.h> |
---|
32 | #include <rtems/score/thread.h> |
---|
33 | #include <rtems/score/threadq.h> |
---|
34 | #if defined(RTEMS_MULTIPROCESSING) |
---|
35 | #include <rtems/score/mpci.h> |
---|
36 | #endif |
---|
37 | #include <rtems/score/sysstate.h> |
---|
38 | |
---|
39 | #include <rtems/score/interr.h> |
---|
40 | |
---|
41 | const rtems_status_code _Semaphore_Translate_core_mutex_return_code_[] = { |
---|
42 | RTEMS_SUCCESSFUL, /* CORE_MUTEX_STATUS_SUCCESSFUL */ |
---|
43 | RTEMS_UNSATISFIED, /* CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT */ |
---|
44 | #if defined(RTEMS_POSIX_API) |
---|
45 | RTEMS_UNSATISFIED, /* CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED */ |
---|
46 | #endif |
---|
47 | RTEMS_NOT_OWNER_OF_RESOURCE, /* CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE */ |
---|
48 | RTEMS_OBJECT_WAS_DELETED, /* CORE_MUTEX_WAS_DELETED */ |
---|
49 | RTEMS_TIMEOUT, /* CORE_MUTEX_TIMEOUT */ |
---|
50 | #if defined(__RTEMS_STRICT_ORDER_MUTEX__) |
---|
51 | 123, |
---|
52 | #endif |
---|
53 | RTEMS_INVALID_PRIORITY /* CORE_MUTEX_STATUS_CEILING_VIOLATED */ |
---|
54 | }; |
---|
55 | |
---|
56 | rtems_status_code _Semaphore_Translate_core_mutex_return_code ( |
---|
57 | uint32_t status |
---|
58 | ) |
---|
59 | { |
---|
60 | /* |
---|
61 | * If this thread is blocking waiting for a result on a remote operation. |
---|
62 | */ |
---|
63 | #if defined(RTEMS_MULTIPROCESSING) |
---|
64 | if ( _Thread_Is_proxy_blocking(status) ) |
---|
65 | return RTEMS_PROXY_BLOCKING; |
---|
66 | #endif |
---|
67 | |
---|
68 | /* |
---|
69 | * Internal consistency check for bad status from SuperCore |
---|
70 | */ |
---|
71 | #if defined(RTEMS_DEBUG) |
---|
72 | if ( status > CORE_MUTEX_STATUS_LAST ) |
---|
73 | return RTEMS_INTERNAL_ERROR; |
---|
74 | #endif |
---|
75 | return _Semaphore_Translate_core_mutex_return_code_[status]; |
---|
76 | } |
---|
77 | |
---|
78 | const rtems_status_code _Semaphore_Translate_core_semaphore_return_code_[] = { |
---|
79 | RTEMS_SUCCESSFUL, /* CORE_SEMAPHORE_STATUS_SUCCESSFUL */ |
---|
80 | RTEMS_UNSATISFIED, /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */ |
---|
81 | RTEMS_OBJECT_WAS_DELETED, /* CORE_SEMAPHORE_WAS_DELETED */ |
---|
82 | RTEMS_TIMEOUT, /* CORE_SEMAPHORE_TIMEOUT */ |
---|
83 | RTEMS_INTERNAL_ERROR, /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */ |
---|
84 | }; |
---|
85 | |
---|
86 | rtems_status_code _Semaphore_Translate_core_semaphore_return_code ( |
---|
87 | uint32_t status |
---|
88 | ) |
---|
89 | { |
---|
90 | #if defined(RTEMS_MULTIPROCESSING) |
---|
91 | if ( _Thread_Is_proxy_blocking(status) ) |
---|
92 | return RTEMS_PROXY_BLOCKING; |
---|
93 | #endif |
---|
94 | /* |
---|
95 | * Internal consistency check for bad status from SuperCore |
---|
96 | */ |
---|
97 | #if defined(RTEMS_DEBUG) |
---|
98 | if ( status > CORE_SEMAPHORE_STATUS_LAST ) |
---|
99 | return RTEMS_INTERNAL_ERROR; |
---|
100 | #endif |
---|
101 | return _Semaphore_Translate_core_semaphore_return_code_[status]; |
---|
102 | } |
---|