R_RTOS  0.1
DistributedRealTimeOperatingSystemfortheARMCortexMArchitecture
R_RTOS_inc.h File Reference

Defines, Typedefs and Macros for the whole system. More...

#include <stdint.h>
#include "R_RTOS_UsrDevs.h"

Go to the source code of this file.

Data Structures

union  partID
 Identifier for a message queue participant. More...
 
union  sysTickEleIDUnion
 Unified ID of a system tick element. More...
 
struct  sysTickTMRStruc
 Structure to keep track of system tick timer objects. More...
 
struct  mqData
 Circular array backed fixed size buffer for data entities. More...
 
struct  msgQMsgProvStruc
 Message Queue provider for a mail box. More...
 
struct  tskMsgProvStruc
 Task messaging provider for a mail box. More...
 
struct  sysMsgProvStruc
 System messaging provider for a mail box. More...
 
union  msgPrvdrsUnion
 Union of all available message providers. More...
 
struct  tskMailBox
 Task mailbox for messaging services. More...
 
struct  tmrFktCallStruc
 Structure of a function call related to a software timer. More...
 
struct  sysTckFktCallstruc
 Structure of a function call related to a system tick timer. More...
 
struct  msgFktCallStruc
 Structure of a function call related to a message queue. More...
 
struct  dummyFktCallStruc
 Structure of a dummy function call. More...
 
struct  sysFkt
 Union structure to unify the different types of system function calls. More...
 
union  sysFkt::fktCallTypeUnion
 Union of function call types. More...
 
struct  semStruc
 Struct for semaphore maintenance. More...
 
union  semStruc::semSignalUnion
 Signaling counter for each type of semaphore. More...
 
struct  mtxStruc
 Struct for Mutex maintenance. More...
 
struct  evtStruc
 Struct for Event maintenance. More...
 
struct  sysTimerStruc
 Struct for system timer maintenance. More...
 
struct  tskTimerStruc
 Struct for task timer maintenance. More...
 
struct  timerStruc
 Struct for timer maintenance. More...
 
union  timerStruc::specTimerUnion
 Union of specialized timers. More...
 
struct  syncEleStruc
 unified structure for all synchronization mechanism objects. More...
 
union  syncEleStruc::syncEleHandle
 Unified specialized SyncEle Handles. More...
 
struct  syncEleStruc::syncEleHandle::evtSyncEle
 Event syncEleStruc::syncEleHandle. More...
 
struct  syncEleStruc::syncEleHandle::tmrSyncEle
 Timer syncEleStruc::syncEleHandle. More...
 
struct  syncEleStruc::syncEleHandle::semSyncEle
 Semaphore syncEleStruc::syncEleHandle. More...
 
struct  syncEleStruc::syncEleHandle::mtxSyncEle
 Mutex syncEleStruc::syncEleHandle. More...
 
struct  syncEleStruc::syncEleHandle::mntrSyncEle
 Monitor syncEleStruc::syncEleHandle. More...
 
struct  advTskPrio_struc
 Contains the TskPrio visible to the system and the real TskPrio. More...
 
struct  tskTCB
 Task Control Block. More...
 
struct  gStruc_OS_FLAGS
 Struct for OS flags. More...
 

Macros

#define NULL   ((void *)0x0u)
 NULL pointer. More...
 
#define ABS(x)   (((x)<0) ? (-1*(x)) : (x))
 Get absolute value of x. More...
 
#define OFFSETOF(type, field)    ((uint8_t) &(((type *) 0)->field))
 Implementation of the OFFSETOF makro to retrieve the offset of a structure member.
 
#define MAX_TASKS   NR_OF_TSKS
 Maximum number of tasks in the system. More...
 
#define MY_STACK_SIZE   ((StackSize)0x80u)
 Default value for a task's stack size.
 
#define IDLE_TSK_STACK_SIZE   ((StackSize)0x60u)
 Stack size for the IDLE Task.
 
#define STACK_BLOCK_SIZE   ((uint8_t)0x4u)
 Size of one stack element in byte.
 
#define MSGQ_TSK_ID_POS   (uint8_t)0x0u
 Position of the user/task id in PartiID.
 
#define MSGQ_SYS_ID_POS   (uint8_t)0x1u
 Position of the system id in PartiID.
 
#define SYS_ID_MSK   (uint16_t)0xFF00u
 Mask for the system id in PartiID.
 
#define TSK_ID_MSK   (uint16_t)0x00FFu
 Mask for the user/task id in PartiID.
 
#define TSK_ID_IDLE   ((TskID)0x0u)
 Reserved TskID for the IDLE Task. More...
 
#define TSK_ID_NO_TSK   TSK_ID_IDLE
 Reserved ID for no task. More...
 
#define AMOUNT_SYS_FKT   (uint8_t)0x8u
 Number of user defined system functions. More...
 
#define SYSFKT_INVALID_SYSFKT_ID   (SysFktID)0xFFu
 Indicates an invalid system function ID. More...
 
#define MAKE_SYS_ID(id)    (uint16_t)((uint16_t)((uint8_t)id & (uint8_t)0xFFu) << (uint8_t)0x8u)
 Given the id as uint8_t compute the system id to use as PartiID.
 
#define MAKE_TSK_ID(id)    (uint16_t)(uint16_t)((uint8_t)id & (uint8_t)0xFFu)
 Given the id as uint8_t compute the user/task id to use as PartiID.
 
#define MQ_IS_TSK_ID(id)   (uint8_t)((uint16_t)id & (uint16_t)0xFFu)
 Given the id as uint16_t (fullID of partiID) evaluate whether the id belongs to a task or not.
 
#define CREATE_EVT_MSK(evtNr)    (EVTQSlots)((EVTQSlots)0x1u << evtNr)
 Makro that can be used to create an event mask for a group of event flags. More...
 
#define TSK_GETSTATE(pTsk)   (TskState)(pTsk->tskState)
 Given a pointer to a TskTCB, retrieve the current state of the task.
 
#define TSK_STATE_IS_ERROR(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_ERROR)
 Evaluate if the task is in an error state.
 
#define TSK_STATE_IS_ACTIVE(pTsk)   (TskState)(TSK_GETSTATE(pTsk) & TSK_STATE_ACTIVE)
 Evaluate if the task is in an active state.
 
#define TSK_STATE_IS_ACTIVE_RUNNING(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_ACTIVE_RUNNING )
 Evalutate if the task is currently in the ACTIVE_RUNNING state.
 
#define TSK_STATE_IS_ACTIVE_SUSPENDED(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_ACTIVE_SUSPENDED )
 Evalutate if the task is currently in the ACTIVE_SUSPENDED state.
 
#define TSK_STATE_IS_ACTIVE_READY(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_ACTIVE_READY )
 Evalutate if the task is currently in the ACTIVE_READY state.
 
#define TSK_STATE_IS_ACTIVE_CRITSEC(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_ACTIVE_CRITSEC )
 Evalutate if the task is currently in the ACTIVE_CRITSEC state. More...
 
#define TSK_STATE_IS_WAITING(pTsk)   (TskState)(TSK_GETSTATE(pTsk) & TSK_STATE_WAITING)
 Evalutate if the task is in a waiting state.
 
#define TSK_STATE_IS_WAITING_TMR(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_WAITING_TMR)
 Evalutate if the task is in a waiting state, waiting for a software timer to expire.
 
#define TSK_STATE_IS_WAITING_MSGRCV(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_WAITING_MSGRCV)
 Evalutate if the task is in a waiting state, waiting for a message to be received.
 
#define TSK_STATE_IS_WAITING_MSGSND(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_WAITING_MSGSND)
 Evalutate if the task is in a waiting state, waiting for a message to be send.
 
#define TSK_STATE_IS_WAITING_EVT(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_WAITING_EVT)
 Evalutate if the task is in a waiting state, waiting for an event or a group of events.
 
#define TSK_STATE_IS_WAITING_SEM(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_WAITING_SEM)
 Evalutate if the task is in a waiting state, waiting for an occupied semaphore.
 
#define TSK_STATE_IS_WAITING_MNTR(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_WAITING_MNTR)
 Evalutate if the task is in a waiting state, waiting for a currently blocked monitor.
 
#define TSK_STATE_IS_UNINIT(pTsk)   (TskState)(TSK_GETSTATE(pTsk) & TSK_STATE_UNINIT)
 Evalutate if the task is in an uninitialized state. More...
 
#define TSK_STATE_IS_UNINIT_UNINIT(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_UNINIT_UNINIT)
 Evalutate if the task has not yet been initialized correctly.
 
#define TSK_STATE_IS_UNINIT_FAILED(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_UNINIT_FAILED)
 Evalutate if the task is in an uninitialized state due to a system failure.
 
#define TSK_STATE_IS_UNINIT_ENDED(pTsk)   (TskState)(TSK_GETSTATE(pTsk) == TSK_STATE_UNINIT_ENDED)
 Evalutate if the task is in an uninitialized state because it finished its execution.
 
#define SEM_NR_OF_TSK_REF_BYTES   (uint8_t)((NR_OF_TSKS >> 3) + 1)
 Bytes needed to create a mask for all available tasks.
 
#define NR_OF_MEMPOOLS   (uint8_t)0x7u
 Number of memory pools.
 
#define OS_FULL_DISPATCH   ((OsCode)0x2u)
 Indicates whether additional context switching is needed. might be deprecated.
 
#define OS_DISPATCH_NEEDED   ((OsCode)0x1u)
 Indicates whether a dispatch is needed. might be deprecated.
 
#define RET_NOK   ((RetCode)0x0u)
 Indicates that there was a failure or faulty or unexpected behavior.
 
#define RET_OK   ((RetCode)0x1u)
 Indicates that everything was/is ok.
 
#define RET_MEM_ALLOC_FAIL_TCB   ((RetCode)0x1Au)
 Indicates that the allocation of a task's TskTCB failed.
 
#define RET_MEM_ALLOC_FAIL_STACK   ((RetCode)0x1Cu)
 Indicates that stack allocation failed.
 
#define RET_TSK_TOO_MANY   ((RetCode)0x2Fu)
 Indicates that there are currently too many tasks in the system.
 
#define RET_TSK_NO_IDLE_TSK   ((RetCode)0x20u)
 Indicates that there is no IDLE Task.
 
#define RET_TSK_CONFLICTING_IDLE_TSK   ((RetCode)0x21u)
 Indicates that there is already a conflicting IDLE Task.
 
#define RET_TSK_STILL_RUNNING   ((RetCode)0x24u)
 Indicates that a task is still running.
 
#define RET_TSK_IS_ABOUT_TO_RUN   ((RetCode)0x25u)
 Indicates that a task is about to run.
 
#define RET_STCK_ERR_FULL   ((RetCode)0x3Fu)
 Indicates that the stack was/is full.
 
#define RET_STCK_ERR_EMPTY   ((RetCode)0x30u)
 Indicates that the stack was/is empty.
 
#define RET_STCK_ERR_INDEX_OVERFLOW   ((RetCode)0x31u)
 Indicates a stack overflow occurred.
 
#define RET_STCK_ERR_INDEX_UNDERFLOW   ((RetCode)0x32u)
 Indicates a stack underflow occurred.
 
#define RET_STCK_NO_STCKELEM_PTR   ((RetCode)0x33u)
 Indicates that there was no pointer to an element on the stack.
 
#define RET_STCK_NO_STCKPTR   ((RetCode)0x34u)
 Indicates that there was no stack pointer.
 

Typedefs

typedef void(* FktCall) (void)
 Function pointer with no arguments and no return.
 
typedef void(* FktCallOneArg) (void *)
 Function pointer with one arguments and no return.
 
typedef uint8_t SysFktID
 System function ID.
 
typedef uint16_t StackSize
 Used to describe the size of a stack.
 
typedef uint32_t StackTypeT
 Base type of a stack element.
 
typedef StackTypeTStackPtrT
 Pointer to a StackTypeT. More...
 
typedef uint8_t DataSize
 Size of the data in a data container.
 
typedef uint32_t * Data
 Data to store in a data container.
 
typedef uint8_t QPrio
 Priority of a message queue.
 
typedef void(* CallBackOnDataRecv) (Data)
 Pointer to a function with one Data input parameter and void as return.
 
typedef uint8_t QID
 Identifier for a message queue.
 
typedef uint8_t MsgCntr
 Counter for messages.
 
typedef union partID PartID
 Identifier for a message queue participant. More...
 
typedef uint8_t SemNr
 Number of a semaphore.
 
typedef uint8_t SemCntr
 Used as a counter variable for semaphores.
 
typedef uint8_t MtxNr
 Number of a Mutex.
 
typedef uint8_t EvtNr
 Number of an event.
 
typedef uint32_t EvtMsk
 Used for event masks.
 
typedef uint32_t EVTQSlots
 Used as a bitarry for slots of an event queue.
 
typedef uint16_t WaitTime
 Time to wait for a Timer.
 
typedef uint32_t SysTime
 Used to describe a systemtime.
 
typedef uint8_t SysTicks
 Amount of SysTicks.
 
typedef uint16_t TmrTime
 Used to describe the time of a software timer.
 
typedef uint32_t LifeTime
 Used to describe time in the system as a timestamp.
 
typedef uint8_t TskID
 Task identification number (ID).
 
typedef uint8_t TskPrioLvl
 Used to set the size of the task priorities.
 
typedef uint8_t tskStateT
 Used to set the size of the task states.
 
typedef FktCall TskStartAddr
 function pointer to a task's function with no arguments and no return.
 
typedef FktCall TskEndAddr
 function pointer to a function which shall be called if a task finishes its execution.
 
typedef uint8_t SyncEleID
 ID of the synchronization element. More...
 
typedef enum mntrAccssType ACCSSType
 Enumeration of the access types for access on a monitor.
 
typedef enum dataTypes DataType
 Enumeration of data types for data stored within another structure.
 
typedef enum timerTypeEn TimerType
 Enumeration of all the different types of software timers.
 
typedef enum tskPrio TskPrio
 Task priority level.
 
typedef enum tskState TskState
 Possible states of tasks. More...
 
typedef enum tskSettings TskSettings
 Settings of a task...
 
typedef enum evtType EvtType
 Enumeration of all the event types in the system.
 
typedef enum syncEleType SyncEleType
 Enumeration of synchronization element types.
 
typedef enum sysTckObjTypeEnum SysTckEleType
 Enumeration of the objects served by the system tick timer mechanism. More...
 
typedef union sysTickEleIDUnion SysTickEleID
 Unified ID of a system tick element. More...
 
typedef struct sysTickTMRStruc SysTickTMR
 Structure to keep track of system tick timer objects.
 
typedef const uint32_t * CData
 pointer a constant double word (32 bit) of data.
 
typedef CDataPCData
 Pointer to a CData.
 
typedef struct mqData MQData
 Circular array backed fixed size buffer for data entities. More...
 
typedef struct msgQMsgProvStruc MsgQMsgProv
 Message Queue provider for a mail box. More...
 
typedef uint8_t MsgID
 ID of a message.
 
typedef struct tskMsgProvStruc TskMsgProv
 Task messaging provider for a mail box. More...
 
typedef struct sysMsgProvStruc SysMsgProv
 System messaging provider for a mail box. More...
 
typedef enum msgProvTypeEnum MsgProvType
 Types of message providers.
 
typedef union msgPrvdrsUnion MsgPrvdrs
 Union of all available message providers.
 
typedef struct tskMailBox TskMB
 Task mailbox for messaging services. More...
 
typedef struct tmrFktCallStruc TmrFktCall
 Structure of a function call related to a software timer.
 
typedef struct sysTckFktCallstruc SysTckFktCall
 Structure of a function call related to a system tick timer.
 
typedef struct msgFktCallStruc MsgFktCall
 Structure of a function call related to a message queue.
 
typedef struct dummyFktCallStruc DummyFktCall
 Structure of a dummy function call.
 
typedef struct sysFkt SysFkt
 Union structure to unify the different types of system function calls. More...
 
typedef enum semTypeEnum SemType
 Enumeartion of Semaphore types.
 
typedef struct semStruc Sem
 Struct for semaphore maintenance. More...
 
typedef struct mtxStruc Mtx
 Struct for Mutex maintenance. More...
 
typedef struct evtStruc Evt
 Struct for Event maintenance. More...
 
typedef struct sysTimerStruc SysTimer
 Struct for system timer maintenance.
 
typedef struct tskTimerStruc TskTimer
 Struct for task timer maintenance.
 
typedef struct timerStruc Timer
 Struct for timer maintenance.
 
typedef struct syncEleStruc SyncEle
 unified structure for all synchronization mechanism objects. More...
 
typedef struct advTskPrio_struc AdvTskPrio
 Contains the TskPrio visible to the system and the real TskPrio. More...
 
typedef struct tskTCB TskTCB
 Task Control Block. More...
 
typedef uint8_t OsCode
 Codes for OS functionality. More...
 
typedef uint8_t RetCode
 Return codes for functions.
 
typedef uint16_t MemSize
 Type for memory size.
 
typedef struct gStruc_OS_FLAGS BitsOSFlags
 Struct for OS flags. More...
 
typedef enum svcCode SVCCode
 Contains the SVCCode for the SVC Call.
 

Enumerations

Detailed Description

Defines, Typedefs and Macros for the whole system.

Author
Christian Neuberger (Neube.nosp@m.rger.nosp@m.Ch503.nosp@m.44@t.nosp@m.h-nue.nosp@m.rnbe.nosp@m.rg.de)
Date
26.11.2015

Macro Definition Documentation

#define ABS (   x)    (((x)<0) ? (-1*(x)) : (x))

Get absolute value of x.

Remove sign from a signed value, so to speak compute its absolute value.

#define AMOUNT_SYS_FKT   (uint8_t)0x8u

Number of user defined system functions.

Note
User defined.
#define NULL   ((void *)0x0u)

NULL pointer.

Due to the fact that this is a void pointer it can be casted to whatever pointer type needed.

#define SYSFKT_INVALID_SYSFKT_ID   (SysFktID)0xFFu

Indicates an invalid system function ID.

This define should be used whenever the validity of a SysFktID has to be evaluated.

Typedef Documentation

typedef struct gStruc_OS_FLAGS BitsOSFlags

Struct for OS flags.

These Flags control the execution of low level OS functions (e.g. scheduler, context switch, low power functionalities).

typedef uint8_t OsCode

Codes for OS functionality.

might be deprecated

typedef struct sysFkt SysFkt

Union structure to unify the different types of system function calls.

Since every system function call depending on its context has a different handle, yet is kept in the same sysFkt array this union is introduced. Data specific to the context can be stored alongside to the function address.

Enumeration Type Documentation

enum svcCode

Contains the SVCCode for the SVC Call.

Enumerator
SVC_OS_START 

Start the OS.

SVC_TSK_INIT 

Initialize a task.

SVC_TSK_SETPRIO 

Set a task's priority.

SVC_TSK_ACTV 

Activate a task.

SVC_TSK_KILL 

Kill a task.

SVC_TSK_SET_CRIT 

Set critical execution state.

SVC_TSK_RESET_CRIT 

Reset critical execution state.

SVC_MTX_TAKE 

Attempt to take a mutex.

SVC_MTX_GIVE 

Give back an occupied mutex.

SVC_SEM_WAIT 

Take a semaphore.

SVC_SEM_SIGNAL 

Release a semaphore.

SVC_MNTR_INIT_MNTR 

Initialize Monitor.

SVC_MNTR_REQ_READ_ACC 

Request read access to monitor.

SVC_MNTR_REQ_WRITE_ACC 

Request write access to monitor.

SVC_MNTR_REL_ACC 

Release current access to monitor.

SVC_EVT_SEND 

Send an event.

SVC_EVT_RECV 

Wait for an event.

SVC_TMR_SET 

Set up a timer.

SVC_SYSTCK_SET 

Set a system tick timer.

SVC_MSGQ_CRT_Q 

create a new message queue

SVC_MSGQ_DEL_Q 

delete an existing message queue

SVC_MSGQ_REG_PUB 

Register to a message queue as a publisher.

SVC_MSGQ_REG_TSK_SUB 

Register to a message queue as a subscriber.

SVC_MSGQ_REG_SYS_SUB 

Register system function to a message queue as a subscriber.

SVC_MSGQ_MSG_PUB 

Publish a message to a message queue.

SVC_MSGQ_MSG_READ 

Read a message from a message queue.

SVC_MSGQ_MSG_READALLNEW 

Read all new messages from a message queue.

SVC_MSGQ_MSG_READALL 

Read all messages from a message queue.

SVC_MSGQ_MSG_TAKE 

Read and destroy a message from a message queue.

SVC_MSGQ_MSG_TAKEALLNEW 

Read and destroy all new messages from a message queue.

SVC_MSGQ_MSG_TAKEALL 

Read and destroy all messages from a message queue.

SVC_OS_SCHEDULE 

Call the scheduler.

SVC_CALL_FKT_PRIV 

Call a function with privileges using main stack.

SVC_LP_ENTER 

Enter low power mode.

SVC_TRC_OUPUT 

Output the trace buffer.

SVC_OS_ERROR 

OS ERROR.