R_RTOS  0.1
DistributedRealTimeOperatingSystemfortheARMCortexMArchitecture
R_RTOS_services.h
Go to the documentation of this file.
1 
9 #ifndef HEADERS_R_RTOS_SERVICES_H_
10 #define HEADERS_R_RTOS_SERVICES_H_
11 
12 #include "R_RTOS_inc.h"
13 
14 #ifndef __STATIC_INLINE
15 #define __STATIC_INLINE static inline
16 #endif
17 
28 #define INPUT_ARG_1(input) __asm volatile( "movs r0, %0 \n"::"l"(input) :)
29 
40 #define INPUT_ARG_2(input) __asm volatile( "movs r1, %0 \n"::"l"(input) :)
41 
52 #define INPUT_ARG_3(input) __asm volatile( "movs r2, %0 \n"::"l"(input) :)
53 
64 #define INPUT_ARG_4(input) __asm volatile( "movs r3, %0 \n"::"l"(input) :)
65 
75 #define OUTPUT_ARG(output) __asm volatile( "mrs r1, msp \n ldr r0, [r1] \n movs %0, r0 \n":"=l"(output): :"memory")
76 
85 #define SVC( svcCode ) __asm volatile( "svc %[svc_code] \n" : : [svc_code]"I"(svcCode) : )
86 
87 __attribute__( ( always_inline ) ) __STATIC_INLINE void svc_os_StartOS( void )
88 {
89  SVC( SVC_OS_START );
90  while ( 1 )
91  {
92  ;
93  }
94 }
95 
96 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tsk_InitTsk(
97  const TskID tskID,
98  const TskStartAddr const tskAddr,
99  const TskStartAddr const tskEndAddr,
100  const StackSize stckSze )
101 {
102  INPUT_ARG_1( tskID );
103  INPUT_ARG_2( tskAddr );
104  INPUT_ARG_3( tskEndAddr );
105  INPUT_ARG_4( stckSze );
106  SVC( SVC_TSK_INIT );
107  RetCode returnVal;
108  OUTPUT_ARG( returnVal );
109  return returnVal;
110 }
111 
112 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tsk_SetTskPrio(
113  const TskID tskID,
114  const TskPrio tskPrio )
115 {
116  INPUT_ARG_1( tskID );
117  INPUT_ARG_2( tskPrio );
118  SVC( SVC_TSK_SETPRIO );
119  RetCode returnVal;
120  OUTPUT_ARG( returnVal );
121  return returnVal;
122 }
123 
124 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tsk_ActvTsk(
125  const TskID tskID )
126 {
127  INPUT_ARG_1( tskID );
128  SVC( SVC_TSK_ACTV );
129  RetCode returnVal;
130  OUTPUT_ARG( returnVal );
131  return returnVal;
132 }
133 
134 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tsk_KillTsk(
135  TskTCB* const tsk )
136 {
137  INPUT_ARG_1( tsk );
138  SVC( SVC_TSK_KILL );
139  RetCode returnVal;
140  OUTPUT_ARG( returnVal );
141  return returnVal;
142 }
143 
144 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tsk_setTskCriticalState(
145  void )
146 {
148  RetCode returnVal;
149  OUTPUT_ARG( returnVal );
150  return returnVal;
151 }
152 
153 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tsk_resetTskCriticalState(
154  void )
155 {
157  RetCode returnVal;
158  OUTPUT_ARG( returnVal );
159  return returnVal;
160 }
161 
162 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_mtx_TakeMtx(
163  const MtxNr mtxNr,
164  PTskTCB const tsk,
165  const SysTicks maxTimeToWait )
166 {
167  INPUT_ARG_1( mtxNr );
168  INPUT_ARG_2( tsk );
169  INPUT_ARG_3( maxTimeToWait );
170  SVC( SVC_MTX_TAKE );
171  RetCode returnVal;
172  OUTPUT_ARG( returnVal );
173  return returnVal;
174 }
175 
176 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_mtx_GiveMtx(
177  const MtxNr mtxNr,
178  PTskTCB const tsk )
179 {
180  INPUT_ARG_1( mtxNr );
181  INPUT_ARG_2( tsk );
182  SVC( SVC_MTX_GIVE );
183  RetCode returnVal;
184  OUTPUT_ARG( returnVal );
185  return returnVal;
186 }
187 
188 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_sem_wait(
189  const SemNr semNr,
190  PTskTCB const tsk,
191  const SysTicks maxTimeToWait )
192 {
193  INPUT_ARG_1( semNr );
194  INPUT_ARG_2( tsk );
195  INPUT_ARG_3( maxTimeToWait );
196  SVC( SVC_SEM_WAIT );
197  RetCode returnVal;
198  OUTPUT_ARG( returnVal );
199  return returnVal;
200 }
201 
202 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_sem_signal(
203  const SemNr semNr,
204  PTskTCB const tsk )
205 {
206  INPUT_ARG_1( semNr );
207  INPUT_ARG_2( tsk );
208  SVC( SVC_SEM_SIGNAL );
209  RetCode returnVal;
210  OUTPUT_ARG( returnVal );
211  return returnVal;
212 }
213 
214 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_mntr_init_mntr(
215  const MntrNr mntrNr,
216  const Data data )
217 {
218  INPUT_ARG_1( mntrNr );
219  INPUT_ARG_2( data );
221  RetCode returnVal;
222  OUTPUT_ARG( returnVal );
223  return returnVal;
224 }
225 
226 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_mntr_ReqReadAccs(
227  const MntrNr mntrNr,
228  PTskTCB const tsk )
229 {
230  INPUT_ARG_1( mntrNr );
231  INPUT_ARG_2( tsk );
233  RetCode returnVal;
234  OUTPUT_ARG( returnVal );
235  return returnVal;
236 }
237 
238 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_mntr_ReqWriteAccs(
239  const MntrNr mntrNr,
240  PTskTCB const tsk )
241 {
242  INPUT_ARG_1( mntrNr );
243  INPUT_ARG_2( tsk );
245  RetCode returnVal;
246  OUTPUT_ARG( returnVal );
247  return returnVal;
248 }
249 
250 
251 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_mntr_RelAccs(
252  const MntrNr mntrNr )
253 {
254  INPUT_ARG_1( mntrNr );
256  RetCode returnVal;
257  OUTPUT_ARG( returnVal );
258  return returnVal;
259 }
260 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_evt_SendEvt(
261  const EvtNr evt )
262 {
263  INPUT_ARG_1( evt );
264  SVC( SVC_EVT_SEND );
265  RetCode returnVal;
266  OUTPUT_ARG( returnVal );
267  return returnVal;
268 }
269 
270 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_evt_RecvEvt(
271  PTskTCB const tsk,
272  EVTQSlots evtMask,
273  const SysTicks maxTimeToWait )
274 {
275  INPUT_ARG_1( tsk );
276  INPUT_ARG_2( evtMask );
277  INPUT_ARG_3( maxTimeToWait );
278  SVC( SVC_EVT_RECV );
279  RetCode returnVal;
280  OUTPUT_ARG( returnVal );
281  return returnVal;
282 }
283 
284 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_tmr_SetTimer(
285  const WaitTime msToWait,
286  TskTCB* const tsk )
287 {
288  INPUT_ARG_1( msToWait );
289  INPUT_ARG_2( tsk );
290  SVC( SVC_TMR_SET );
291  RetCode returnVal;
292  OUTPUT_ARG( returnVal );
293  return returnVal;
294 }
295 
296 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_sysTck_SetTimer(
297  const SysTicks ticksToWait,
298  TskID const tskID )
299 {
300  INPUT_ARG_1( ticksToWait );
301  INPUT_ARG_2( tskID );
302  SVC( SVC_SYSTCK_SET );
303  RetCode returnVal;
304  OUTPUT_ARG( returnVal );
305  return returnVal;
306 }
307 
308 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_CrtQ(
309  const QID msgQID )
310 {
311  INPUT_ARG_1( msgQID );
312  SVC( SVC_MSGQ_CRT_Q );
313  RetCode returnVal;
314  OUTPUT_ARG( returnVal );
315  return returnVal;
316 }
317 
318 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_DelQ(
319  const QID msgQID )
320 {
321  INPUT_ARG_1( msgQID );
322  SVC( SVC_MSGQ_DEL_Q );
323  RetCode returnVal;
324  OUTPUT_ARG( returnVal );
325  return returnVal;
326 }
327 
328 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_RegPub(
329  PTskTCB const tsk,
330  const QID msgQID )
331 {
332  INPUT_ARG_1( tsk );
333  INPUT_ARG_2( msgQID );
335  RetCode returnVal;
336  OUTPUT_ARG( returnVal );
337  return returnVal;
338 }
339 
340 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_RegTskSub(
341  PTskTCB const tsk,
342  const QID msgQID )
343 {
344  INPUT_ARG_1( tsk );
345  INPUT_ARG_2( msgQID );
347  RetCode returnVal;
348  OUTPUT_ARG( returnVal );
349  return returnVal;
350 }
351 
352 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_RegSysSub(
353  const SysFktID sysID,
354  const QID msgQID )
355 {
356  INPUT_ARG_1( sysID );
357  INPUT_ARG_2( msgQID );
359  RetCode returnVal;
360  OUTPUT_ARG( returnVal );
361  return returnVal;
362 }
363 
364 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_PubMsg(
365  const QID msgQID,
366  const DataSize dataSize,
367  const DataType dataType,
368  CData const data )
369 {
370  INPUT_ARG_1( msgQID );
371  INPUT_ARG_2( dataSize );
372  INPUT_ARG_3( dataType );
373  INPUT_ARG_4( data );
375  RetCode returnVal;
376  OUTPUT_ARG( returnVal );
377  return returnVal;
378 }
379 
380 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_MsgRead(
381  const QID msgQID,
382  const TskID tskID,
383  const PMQData * dataBuffer )
384 {
385  INPUT_ARG_1( msgQID );
386  INPUT_ARG_2( tskID );
387  INPUT_ARG_3( dataBuffer );
389  RetCode returnVal;
390  OUTPUT_ARG( returnVal );
391  return returnVal;
392 }
393 
394 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_MsgRead_AllNew(
395  const QID msgQID,
396  const TskID tskID,
397  Data dataBuffer )
398 {
399  INPUT_ARG_1( msgQID );
400  INPUT_ARG_2( tskID );
401  INPUT_ARG_3( dataBuffer );
403  RetCode returnVal;
404  OUTPUT_ARG( returnVal );
405  return returnVal;
406 }
407 
408 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_MsgRead_All(
409  const QID msgQID,
410  const TskID tskID,
411  Data dataBuffer )
412 {
413  INPUT_ARG_1( msgQID );
414  INPUT_ARG_2( tskID );
415  INPUT_ARG_3( dataBuffer );
417  RetCode returnVal;
418  OUTPUT_ARG( returnVal );
419  return returnVal;
420 }
421 
422 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_MsgTake(
423  const QID msgQID,
424  const TskID tskID,
425  Data dataBuffer )
426 {
427  INPUT_ARG_1( msgQID );
428  INPUT_ARG_2( tskID );
429  INPUT_ARG_3( dataBuffer );
431  RetCode returnVal;
432  OUTPUT_ARG( returnVal );
433  return returnVal;
434 }
435 
436 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_MsgTake_AllNew(
437  const QID msgQID,
438  const TskID tskID,
439  Data dataBuffer )
440 {
441  INPUT_ARG_1( msgQID );
442  INPUT_ARG_2( tskID );
443  INPUT_ARG_3( dataBuffer );
445  RetCode returnVal;
446  OUTPUT_ARG( returnVal );
447  return returnVal;
448 }
449 
450 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_msgq_MsgTake_All(
451  const QID msgQID,
452  const TskID tskID,
453  Data dataBuffer )
454 {
455  INPUT_ARG_1( msgQID );
456  INPUT_ARG_2( tskID );
457  INPUT_ARG_3( dataBuffer );
459  RetCode returnVal;
460  OUTPUT_ARG( returnVal );
461  return returnVal;
462 }
463 
464 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_os_Scheduler( void )
465 {
466  SVC( SVC_OS_SCHEDULE );
467  RetCode returnVal;
468  OUTPUT_ARG( returnVal );
469  return returnVal;
470 }
471 
472 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_cll_FktWithPrivileges(
473  const TskStartAddr const fktToCall )
474 {
475  INPUT_ARG_1( fktToCall );
477  RetCode returnVal;
478  OUTPUT_ARG( returnVal );
479  return returnVal;
480 }
481 
482 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_lp_EnterLPMode(
483  void )
484 {
485  SVC( SVC_LP_ENTER );
486  RetCode returnVal;
487  OUTPUT_ARG( returnVal );
488  return returnVal;
489 }
490 
491 __attribute__( ( always_inline )) __STATIC_INLINE RetCode svc_trc_OutputTrace(
492  void *msg )
493 {
494  INPUT_ARG_1( msg );
495  SVC( SVC_TRC_OUPUT );
496  RetCode returnVal;
497  OUTPUT_ARG( returnVal );
498  return returnVal;
499 }
500 
501 #endif /* HEADERS_R_RTOS_SERVICES_H_ */
Initialize Monitor.
Definition: R_RTOS_inc.h:1528
uint8_t SysTicks
Amount of SysTicks.
Definition: R_RTOS_inc.h:511
Start the OS.
Definition: R_RTOS_inc.h:1517
Kill a task.
Definition: R_RTOS_inc.h:1521
Call the scheduler.
Definition: R_RTOS_inc.h:1548
Enter low power mode.
Definition: R_RTOS_inc.h:1550
uint32_t EVTQSlots
Used as a bitarry for slots of an event queue.
Definition: R_RTOS_inc.h:490
#define OUTPUT_ARG(output)
Retrieves an return value from a preceding function call and stores it into output.
Definition: R_RTOS_services.h:75
Output the trace buffer.
Definition: R_RTOS_inc.h:1551
uint8_t QID
Identifier for a message queue.
Definition: R_RTOS_inc.h:416
Reset critical execution state.
Definition: R_RTOS_inc.h:1523
Defines, Typedefs and Macros for the whole system.
delete an existing message queue
Definition: R_RTOS_inc.h:1537
Read and destroy a message from a message queue.
Definition: R_RTOS_inc.h:1545
Give back an occupied mutex.
Definition: R_RTOS_inc.h:1525
Publish a message to a message queue.
Definition: R_RTOS_inc.h:1541
uint8_t DataSize
Size of the data in a data container.
Definition: R_RTOS_inc.h:395
Set critical execution state.
Definition: R_RTOS_inc.h:1522
Read and destroy all new messages from a message queue.
Definition: R_RTOS_inc.h:1546
uint8_t MtxNr
Number of a Mutex.
Definition: R_RTOS_inc.h:462
Activate a task.
Definition: R_RTOS_inc.h:1520
uint8_t SemNr
Number of a semaphore.
Definition: R_RTOS_inc.h:445
Call a function with privileges using main stack.
Definition: R_RTOS_inc.h:1549
Read a message from a message queue.
Definition: R_RTOS_inc.h:1542
Request write access to monitor.
Definition: R_RTOS_inc.h:1530
uint32_t * Data
Data to store in a data container.
Definition: R_RTOS_inc.h:400
FktCall TskStartAddr
function pointer to a task's function with no arguments and no return.
Definition: R_RTOS_inc.h:548
Register system function to a message queue as a subscriber.
Definition: R_RTOS_inc.h:1540
uint16_t WaitTime
Time to wait for a Timer.
Definition: R_RTOS_inc.h:501
Register to a message queue as a publisher.
Definition: R_RTOS_inc.h:1538
uint8_t TskID
Task identification number (ID).
Definition: R_RTOS_inc.h:532
Release a semaphore.
Definition: R_RTOS_inc.h:1527
enum dataTypes DataType
Enumeration of data types for data stored within another structure.
Wait for an event.
Definition: R_RTOS_inc.h:1533
#define SVC(svcCode)
SVC Call with the given svcCode.
Definition: R_RTOS_services.h:85
const uint32_t * CData
pointer a constant double word (32 bit) of data.
Definition: R_RTOS_inc.h:887
Release current access to monitor.
Definition: R_RTOS_inc.h:1531
#define INPUT_ARG_2(input)
Sets input as the second input argument for a following function call.
Definition: R_RTOS_services.h:40
#define INPUT_ARG_4(input)
Sets input as the fourth input argument for a following function call.
Definition: R_RTOS_services.h:64
create a new message queue
Definition: R_RTOS_inc.h:1536
#define INPUT_ARG_3(input)
Sets input as the third input argument for a following function call.
Definition: R_RTOS_services.h:52
Task Control Block.
Definition: R_RTOS_inc.h:1322
tskPrio
Task priority level.
Definition: R_RTOS_inc.h:692
#define INPUT_ARG_1(input)
Sets input as the first input argument for a following function call.
Definition: R_RTOS_services.h:28
Circular array backed fixed size buffer for data entities.
Definition: R_RTOS_inc.h:904
Register to a message queue as a subscriber.
Definition: R_RTOS_inc.h:1539
Set up a timer.
Definition: R_RTOS_inc.h:1534
Send an event.
Definition: R_RTOS_inc.h:1532
Take a semaphore.
Definition: R_RTOS_inc.h:1526
uint8_t SysFktID
System function ID.
Definition: R_RTOS_inc.h:361
Read all new messages from a message queue.
Definition: R_RTOS_inc.h:1543
uint16_t StackSize
Used to describe the size of a stack.
Definition: R_RTOS_inc.h:371
Read and destroy all messages from a message queue.
Definition: R_RTOS_inc.h:1547
Read all messages from a message queue.
Definition: R_RTOS_inc.h:1544
Set a task's priority.
Definition: R_RTOS_inc.h:1519
Set a system tick timer.
Definition: R_RTOS_inc.h:1535
uint8_t RetCode
Return codes for functions.
Definition: R_RTOS_inc.h:1424
enum tskPrio TskPrio
Task priority level.
uint8_t EvtNr
Number of an event.
Definition: R_RTOS_inc.h:481
Initialize a task.
Definition: R_RTOS_inc.h:1518
Attempt to take a mutex.
Definition: R_RTOS_inc.h:1524
Request read access to monitor.
Definition: R_RTOS_inc.h:1529