Mistake on this page?
Report an issue in GitHub or email us
rtx_lib.h
1 /*
2  * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * -----------------------------------------------------------------------------
19  *
20  * Project: CMSIS-RTOS RTX
21  * Title: RTX Library definitions
22  *
23  * -----------------------------------------------------------------------------
24  */
25 
26 #ifndef RTX_LIB_H_
27 #define RTX_LIB_H_
28 
29 #include <string.h>
30 #include "rtx_core_c.h" // Cortex core definitions
31 #if ((defined(__ARM_ARCH_8M_BASE__) && (__ARM_ARCH_8M_BASE__ != 0)) || \
32  (defined(__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ != 0)))
33 #include "tz_context.h" // TrustZone Context API
34 #endif
35 #include "os_tick.h" // CMSIS OS Tick API
36 #include "cmsis_os2.h" // CMSIS RTOS API
37 #include "RTX_Config.h" // RTX Configuration
38 #include "rtx_os.h" // RTX OS definitions
39 #include "rtx_evr.h" // RTX Event Recorder definitions
40 
41 
42 // ==== Library defines ====
43 
44 #define os_thread_t osRtxThread_t
45 #define os_timer_t osRtxTimer_t
46 #define os_timer_finfo_t osRtxTimerFinfo_t
47 #define os_event_flags_t osRtxEventFlags_t
48 #define os_mutex_t osRtxMutex_t
49 #define os_semaphore_t osRtxSemaphore_t
50 #define os_mp_info_t osRtxMpInfo_t
51 #define os_memory_pool_t osRtxMemoryPool_t
52 #define os_message_t osRtxMessage_t
53 #define os_message_queue_t osRtxMessageQueue_t
54 #define os_object_t osRtxObject_t
55 
56 // ==== Inline functions ====
57 
58 // Thread ID
59 __STATIC_INLINE os_thread_t *osRtxThreadId (osThreadId_t thread_id) {
60  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
61  return ((os_thread_t *)thread_id);
62 }
63 // Timer ID
64 __STATIC_INLINE os_timer_t *osRtxTimerId (osTimerId_t timer_id) {
65  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
66  return ((os_timer_t *)timer_id);
67 }
68 // Event Flags ID
69 __STATIC_INLINE os_event_flags_t *osRtxEventFlagsId (osEventFlagsId_t ef_id) {
70  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
71  return ((os_event_flags_t *)ef_id);
72 }
73 // Mutex ID
74 __STATIC_INLINE os_mutex_t *osRtxMutexId (osMutexId_t mutex_id) {
75  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
76  return ((os_mutex_t *)mutex_id);
77 }
78 // Semaphore ID
79 __STATIC_INLINE os_semaphore_t *osRtxSemaphoreId (osSemaphoreId_t semaphore_id) {
80  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
81  return ((os_semaphore_t *)semaphore_id);
82 }
83 // Memory Pool ID
84 __STATIC_INLINE os_memory_pool_t *osRtxMemoryPoolId (osMemoryPoolId_t mp_id) {
85  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
86  return ((os_memory_pool_t *)mp_id);
87 }
88 // Message Queue ID
89 __STATIC_INLINE os_message_queue_t *osRtxMessageQueueId (osMessageQueueId_t mq_id) {
90  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
91  return ((os_message_queue_t *)mq_id);
92 }
93 
94 // Generic Object
95 __STATIC_INLINE os_object_t *osRtxObject (void *object) {
96  //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 3]
97  return ((os_object_t *)object);
98 }
99 
100 // Thread Object
101 __STATIC_INLINE os_thread_t *osRtxThreadObject (os_object_t *object) {
102  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
103  return ((os_thread_t *)object);
104 }
105 // Timer Object
106 __STATIC_INLINE os_timer_t *osRtxTimerObject (os_object_t *object) {
107  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
108  return ((os_timer_t *)object);
109 }
110 // Event Flags Object
111 __STATIC_INLINE os_event_flags_t *osRtxEventFlagsObject (os_object_t *object) {
112  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
113  return ((os_event_flags_t *)object);
114 }
115 // Mutex Object
116 __STATIC_INLINE os_mutex_t *osRtxMutexObject (os_object_t *object) {
117  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
118  return ((os_mutex_t *)object);
119 }
120 // Semaphore Object
121 __STATIC_INLINE os_semaphore_t *osRtxSemaphoreObject (os_object_t *object) {
122  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
123  return ((os_semaphore_t *)object);
124 }
125 // Memory Pool Object
126 __STATIC_INLINE os_memory_pool_t *osRtxMemoryPoolObject (os_object_t *object) {
127  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
128  return ((os_memory_pool_t *)object);
129 }
130 // Message Queue Object
131 __STATIC_INLINE os_message_queue_t *osRtxMessageQueueObject (os_object_t *object) {
132  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
133  return ((os_message_queue_t *)object);
134 }
135 // Message Object
136 __STATIC_INLINE os_message_t *osRtxMessageObject (os_object_t *object) {
137  //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
138  return ((os_message_t *)object);
139 }
140 
141 // Kernel State
142 __STATIC_INLINE osKernelState_t osRtxKernelState (void) {
143  //lint -e{9030} -e{9034} "cast to enum"
144  return ((osKernelState_t)(osRtxInfo.kernel.state));
145 }
146 
147 // Thread State
148 __STATIC_INLINE osThreadState_t osRtxThreadState (const os_thread_t *thread) {
149  uint8_t state = thread->state & osRtxThreadStateMask;
150  //lint -e{9030} -e{9034} "cast to enum"
151  return ((osThreadState_t)state);
152 }
153 
154 // Thread Priority
155 __STATIC_INLINE osPriority_t osRtxThreadPriority (const os_thread_t *thread) {
156  //lint -e{9030} -e{9034} "cast to enum"
157  return ((osPriority_t)thread->priority);
158 }
159 
160 // Kernel Get State
161 __STATIC_INLINE uint8_t osRtxKernelGetState (void) {
162  return osRtxInfo.kernel.state;
163 }
164 
165 // Thread Get/Set Running
166 __STATIC_INLINE os_thread_t *osRtxThreadGetRunning (void) {
167  return osRtxInfo.thread.run.curr;
168 }
169 __STATIC_INLINE void osRtxThreadSetRunning (os_thread_t *thread) {
170  osRtxInfo.thread.run.curr = thread;
171 }
172 
173 
174 // ==== Library functions ====
175 
176 // Kernel Library functions
177 extern void osRtxKernelPreInit (void);
178 
179 // Thread Library functions
180 extern void osRtxThreadListPut (os_object_t *object, os_thread_t *thread);
181 extern os_thread_t *osRtxThreadListGet (os_object_t *object);
182 extern void osRtxThreadListSort (os_thread_t *thread);
183 extern void osRtxThreadListRemove (os_thread_t *thread);
184 extern void osRtxThreadReadyPut (os_thread_t *thread);
185 extern void osRtxThreadDelayTick (void);
186 extern uint32_t *osRtxThreadRegPtr (const os_thread_t *thread);
187 extern void osRtxThreadSwitch (os_thread_t *thread);
188 extern void osRtxThreadDispatch (os_thread_t *thread);
189 extern void osRtxThreadWaitExit (os_thread_t *thread, uint32_t ret_val, bool_t dispatch);
190 extern bool_t osRtxThreadWaitEnter (uint8_t state, uint32_t timeout);
191 extern void osRtxThreadStackCheck (void);
192 extern bool_t osRtxThreadStartup (void);
193 
194 // Timer Library functions
195 extern void osRtxTimerThread (void *argument);
196 
197 // Mutex Library functions
198 extern void osRtxMutexOwnerRelease (os_mutex_t *mutex_list);
199 
200 // Memory Heap Library functions
201 extern uint32_t osRtxMemoryInit (void *mem, uint32_t size);
202 extern void *osRtxMemoryAlloc(void *mem, uint32_t size, uint32_t type);
203 extern uint32_t osRtxMemoryFree (void *mem, void *block);
204 
205 // Memory Pool Library functions
206 extern uint32_t osRtxMemoryPoolInit (os_mp_info_t *mp_info, uint32_t block_count, uint32_t block_size, void *block_mem);
207 extern void *osRtxMemoryPoolAlloc (os_mp_info_t *mp_info);
208 extern osStatus_t osRtxMemoryPoolFree (os_mp_info_t *mp_info, void *block);
209 
210 // System Library functions
211 extern void osRtxTick_Handler (void);
212 extern void osRtxPendSV_Handler (void);
213 extern void osRtxPostProcess (os_object_t *object);
214 
215 
216 #endif // RTX_LIB_H_
osRtxThread_t * thread
< Thread Round Robin Info
Definition: rtx_os.h:300
CMSIS OS Tick header file.
uint8_t state
< Kernel Info
Definition: rtx_os.h:282
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.