pico]OS
1.0.4
|
pico]OS main include file More...
Go to the source code of this file.
Data Structures | |
struct | PICOEVENT |
Event info structure. More... | |
struct | PICOTASK |
Task info structure. More... |
Macros | |
#define | E_OK 0 |
No Error (the operation was successful) | |
#define | E_FAIL 1 |
The operation failed. | |
#define | E_NOMEM 2 |
The System ran out of memory. | |
#define | E_ARG 3 |
The given argument is wrong or inacceptable. | |
#define | E_FORB 4 |
The operation is forbidden at the current operation stage. | |
#define | E_NOMORE 5 |
For query operations: End of query (no more elements) | |
#define | E_NOTFOUND 6 |
The query operation was not successfull. | |
#define | MS(msec) ((UINT_t)((1L*HZ*(msec))/1000)) |
#define | HZ (timerticks per second) |
#define | POS_TIMEAFTER(x, y) ((((SJIF_t)(x)) - ((SJIF_t)(y))) >= 0) |
#define | POSLIST_ELEMENT(elem, type, member) |
#define | POSLIST_IS_EMPTY(plisthead) ((plisthead)->next == (POSLIST_t*)(plisthead)) |
#define | POSLIST_NEXT_ENTRY(plist) (plist)->next |
#define | POSLIST_PREV_ENTRY(plist) (plist)->prev |
#define | POSLIST_FIRST_ENTRY(plisthead) (plisthead)->next |
#define | POSLIST_LAST_ENTRY(plisthead) (plisthead)->prev |
#define | POSLIST_IS_FIRST_ENTRY(element) ((element)->prev==(element)->head) |
#define | POSLIST_IS_LAST_ENTRY(element) ((element)->next==(element)->head) |
#define | POSLIST_IS_END(plisthead, element) ((element)==(POSLIST_t*)(plisthead)) |
#define | POSLIST_FOR_EACH_ENTRY(plisthead, runvar) |
#define | POSLIST_FOREACH_BEGIN(plisthead, runvar, type, listmember) |
#define | POSLIST_FOREACH_END |
#define | P_ASSERT(text, x) if (!(x)) POSCALL p_pos_assert((const char*)(text), __FILE__, __LINE__) |
pico]OS assertion macro. | |
#define | POS_SETTASKNAME(taskhandle, taskname) |
This macro assigns a name to a pico]OS task. | |
#define | POS_SETEVENTNAME(eventhandle, name) |
This macro assigns a name to a pico]OS event. |
Typedefs | |
typedef signed MVAR_t | VAR_t |
Signed machine variable type. This variable type is the fastest for the target architecture. | |
typedef unsigned MVAR_t | UVAR_t |
Unsigned machine variable type. This variable type is the fastest for the target architecture. | |
typedef signed MINT_t | INT_t |
Signed integer. | |
typedef unsigned MINT_t | UINT_t |
Unsigned integer. | |
typedef unsigned MPTR_t | MEMPTR_t |
Memory pointer type. | |
typedef VAR_t | SJIF_t |
Signed type of JIF_t. | |
typedef UVAR_t | JIF_t |
Timer counter type. Can be UVAR_t or UINT_t. | |
typedef void(* | POSTASKFUNC_t )(void *arg) |
Generic function pointer. | |
typedef void(* | POSINTFUNC_t )(UVAR_t arg) |
Software interrupt callback function pointer. | |
typedef void(* | POSIDLEFUNC_t )(void) |
Idle task function pointer. | |
typedef struct POSSEMA * | POSSEMA_t |
Handle to a semaphore object. | |
typedef struct POSMUTEX * | POSMUTEX_t |
Handle to a mutex object. | |
typedef struct POSFLAG * | POSFLAG_t |
Handle to a flag object. | |
typedef struct POSTIMER * | POSTIMER_t |
Handle to a timer object. | |
typedef volatile INT_t | POSATOMIC_t |
Atomic variable. | |
typedef struct POSLIST | POSLIST_t |
List variable. This variable type is used as running variable of a list or as list link. | |
typedef struct POSLISTHEAD | POSLISTHEAD_t |
List variable. This variable defines the head of a list. | |
typedef struct POSTASK * | POSTASK_t |
Task environment structure. | |
typedef struct PICOEVENT | PICOEVENT |
Event info structure. | |
typedef struct PICOTASK | PICOTASK |
Task info structure. |
Enumerations | |
enum | PTASKSTATE { task_notExisting = 0, task_created = 1, task_running = 2, task_suspended = 3, task_sleeping = 4, task_waitingForSemaphore = 5, task_waitingForSemaphoreWithTimeout = 6, task_waitingForMutex = 7, task_waitingForMutexWithTimeout = 8, task_waitingForFlag = 9, task_waitingForFlagWithTimeout = 10, task_waitingForMessage = 11, task_waitingForMessageWithTimeout = 12 } |
Task states (used for debugging when POSCFG_FEATURE_DEBUGHELP is set to 1) More... | |
enum | PEVENTTYPE { event_semaphore = 0, event_mutex = 1, event_flags = 2 } |
Event types (used for debugging when POSCFG_FEATURE_DEBUGHELP is set to 1) More... |
Functions | |
POSFROMEXT UVAR_t POSCALL | p_pos_findbit (const UVAR_t bitfield) |
POSFROMEXT UVAR_t POSCALL | p_pos_findbit (const UVAR_t bitfield, UVAR_t rrOffset) |
POSFROMEXT void POSCALL | p_pos_initArch (void) |
POSFROMEXT void POSCALL | p_pos_initTask (POSTASK_t task, void *stackstart, POSTASKFUNC_t funcptr, void *funcarg) |
POSFROMEXT VAR_t POSCALL | p_pos_initTask (POSTASK_t task, UINT_t stacksize, POSTASKFUNC_t funcptr, void *funcarg) |
POSFROMEXT void POSCALL | p_pos_freeStack (POSTASK_t task) |
POSFROMEXT void POSCALL | p_pos_lock (void) |
POSFROMEXT void POSCALL | p_pos_unlock (void) |
POSFROMEXT VAR_t POSCALL | p_pos_initTask (POSTASK_t task, POSTASKFUNC_t funcptr, void *funcarg) |
POSFROMEXT void POSCALL | p_pos_startFirstContext (void) |
POSFROMEXT void POSCALL | p_pos_softContextSwitch (void) |
POSFROMEXT void POSCALL | p_pos_intContextSwitch (void) |
POSFROMEXT void POSCALL | p_pos_intContextSwitchPending (void) |
POSEXTERN void POSCALL | c_pos_intEnter (void) |
POSEXTERN void POSCALL | c_pos_intExit (void) |
POSEXTERN void POSCALL | c_pos_intExitQuick (void) |
POSEXTERN void POSCALL | c_pos_timerInterrupt (void) |
POSEXTERN void POSCALL | posTaskYield (void) |
POSEXTERN void POSCALL | posTaskSleep (UINT_t ticks) |
POSEXTERN POSTASK_t POSCALL | posTaskCreate (POSTASKFUNC_t funcptr, void *funcarg, VAR_t priority, void *stackstart) |
POSEXTERN void POSCALL | posInit (POSTASKFUNC_t firstfunc, void *funcarg, VAR_t priority, void *stackFirstTask, void *stackIdleTask) |
POSEXTERN POSTASK_t POSCALL | posTaskCreate (POSTASKFUNC_t funcptr, void *funcarg, VAR_t priority, UINT_t stacksize) |
POSEXTERN void POSCALL | posInit (POSTASKFUNC_t firstfunc, void *funcarg, VAR_t priority, UINT_t taskStackSize, UINT_t idleStackSize) |
POSEXTERN POSTASK_t POSCALL | posTaskCreate (POSTASKFUNC_t funcptr, void *funcarg, VAR_t priority) |
POSEXTERN void POSCALL | posInit (POSTASKFUNC_t firstfunc, void *funcarg, VAR_t priority) |
POSEXTERN void POSCALL | posTaskExit (void) |
POSEXTERN POSTASK_t POSCALL | posTaskGetCurrent (void) |
POSEXTERN VAR_t POSCALL | posTaskUnused (POSTASK_t taskhandle) |
POSEXTERN VAR_t POSCALL | posTaskSetPriority (POSTASK_t taskhandle, VAR_t priority) |
POSEXTERN VAR_t POSCALL | posTaskGetPriority (POSTASK_t taskhandle) |
POSEXTERN void POSCALL | posTaskSchedLock (void) |
POSEXTERN void POSCALL | posTaskSchedUnlock (void) |
POSEXTERN void *POSCALL | posTaskGetUserspace (void) |
POSEXTERN POSIDLEFUNC_t POSCALL | posInstallIdleTaskHook (POSIDLEFUNC_t idlefunc) |
POSEXTERN POSSEMA_t POSCALL | posSemaCreate (INT_t initcount) |
POSEXTERN void POSCALL | posSemaDestroy (POSSEMA_t sema) |
POSEXTERN VAR_t POSCALL | posSemaGet (POSSEMA_t sema) |
POSEXTERN VAR_t POSCALL | posSemaSignal (POSSEMA_t sema) |
POSEXTERN VAR_t POSCALL | posSemaWait (POSSEMA_t sema, UINT_t timeoutticks) |
POSEXTERN POSMUTEX_t POSCALL | posMutexCreate (void) |
POSEXTERN void POSCALL | posMutexDestroy (POSMUTEX_t mutex) |
POSEXTERN VAR_t POSCALL | posMutexTryLock (POSMUTEX_t mutex) |
POSEXTERN VAR_t POSCALL | posMutexLock (POSMUTEX_t mutex) |
POSEXTERN VAR_t POSCALL | posMutexUnlock (POSMUTEX_t mutex) |
POSEXTERN void *POSCALL | posMessageAlloc (void) |
POSEXTERN void POSCALL | posMessageFree (void *buf) |
POSEXTERN VAR_t POSCALL | posMessageSend (void *buf, POSTASK_t taskhandle) |
POSEXTERN void *POSCALL | posMessageGet (void) |
POSEXTERN VAR_t POSCALL | posMessageAvailable (void) |
POSEXTERN void *POSCALL | posMessageWait (UINT_t timeoutticks) |
POSEXTERN POSFLAG_t POSCALL | posFlagCreate (void) |
POSEXTERN void POSCALL | posFlagDestroy (POSFLAG_t flg) |
POSEXTERN VAR_t POSCALL | posFlagSet (POSFLAG_t flg, UVAR_t flgnum) |
POSEXTERN VAR_t POSCALL | posFlagGet (POSFLAG_t flg, UVAR_t mode) |
POSEXTERN VAR_t POSCALL | posFlagWait (POSFLAG_t flg, UINT_t timeoutticks) |
POSEXTERN POSTIMER_t POSCALL | posTimerCreate (void) |
POSEXTERN VAR_t POSCALL | posTimerSet (POSTIMER_t tmr, POSSEMA_t sema, UINT_t waitticks, UINT_t periodticks) |
POSEXTERN VAR_t POSCALL | posTimerStart (POSTIMER_t tmr) |
POSEXTERN VAR_t POSCALL | posTimerStop (POSTIMER_t tmr) |
POSEXTERN void POSCALL | posTimerDestroy (POSTIMER_t tmr) |
POSEXTERN VAR_t POSCALL | posTimerFired (POSTIMER_t tmr) |
POSEXTERN void POSCALL | posSoftInt (UVAR_t intno, UVAR_t param) |
POSEXTERN VAR_t POSCALL | posSoftIntSetHandler (UVAR_t intno, POSINTFUNC_t inthandler) |
POSEXTERN VAR_t POSCALL | posSoftIntDelHandler (UVAR_t intno) |
POSEXTERN void POSCALL | posAtomicSet (POSATOMIC_t *var, INT_t value) |
POSEXTERN INT_t POSCALL | posAtomicGet (POSATOMIC_t *var) |
POSEXTERN INT_t POSCALL | posAtomicAdd (POSATOMIC_t *var, INT_t value) |
POSEXTERN INT_t POSCALL | posAtomicSub (POSATOMIC_t *var, INT_t value) |
POSEXTERN void POSCALL | posListAdd (POSLISTHEAD_t *listhead, UVAR_t pos, POSLIST_t *new) |
POSEXTERN POSLIST_t *POSCALL | posListGet (POSLISTHEAD_t *listhead, UVAR_t pos, UINT_t timeout) |
POSEXTERN void POSCALL | posListRemove (POSLIST_t *listelem) |
POSEXTERN void POSCALL | posListJoin (POSLISTHEAD_t *baselisthead, UVAR_t pos, POSLISTHEAD_t *joinlisthead) |
POSEXTERN UINT_t POSCALL | posListLen (POSLISTHEAD_t *listhead) |
POSEXTERN void POSCALL | posListInit (POSLISTHEAD_t *listhead) |
POSEXTERN void POSCALL | posListTerm (POSLISTHEAD_t *listhead) |
Variables | |
POSEXTERN volatile POSTASK_t | posCurrentTask_g |
Global task variable. This variable points to the environment structure of the currently active task. | |
POSEXTERN volatile POSTASK_t | posNextTask_g |
Global task variable. This variable points to the environment structure of the next task that shall be scheduled. | |
POSEXTERN volatile UVAR_t | posInInterrupt_g |
Global flag variable. This variable is nonzero when the CPU is currently executing an interrupt service routine. | |
POSEXTERN volatile UVAR_t | posRunning_g |
Global flag variable. This variable is nonzero when the operating system is initialized and running. | |
VAR_t | errno |
Unix style error variable. This variable is global for the currently runnig task. | |
POSEXTERN volatile JIF_t | jiffies |
Global timer variable. The jiffies counter variable is incremented HZ times per second. | |
struct PICOTASK * | picodeb_taskhistory [3] |
This array contains the last 3 tasks that run. | |
struct PICOTASK * | picodeb_tasklist |
Pointer to the list of active tasks. | |
struct PICOEVENT * | picodeb_eventlist |
Pointer to the list of all system events. |
pico]OS main include file
#define MS | ( | msec | ) | ((UINT_t)((1L*HZ*(msec))/1000)) |
Convert milliseconds into HZ timer ticks. This macro is used to convert milliseconds into the timer tick rate (see HZ define). Example: Use posTaskSleep(MS(1000)) to sleep 1000 ms.
typedef signed MINT_t INT_t |
Signed integer.
The bit size can be changed by the user by defining MINT_t to something other than int in the port configuration file. This integer type is used by the operating system e.g. for semaphore counters and timer.
Memory pointer type.
This variable type is an integer with the width of the address lines of memory architecure. The bit width is equal to the width of a void-pointer. This variable type is needed by the operating system for lossless typecasting of void pointers to integers. MPTR_t is a define that is set in the port configuration file. When MPTR_t is not set, it defaults to long.
typedef volatile INT_t POSATOMIC_t |
Atomic variable.
typedef struct POSFLAG* POSFLAG_t |
Handle to a flag object.
typedef void(* POSINTFUNC_t)(UVAR_t arg) |
Software interrupt callback function pointer.
The parameter arg is the value that was dropped in the call to posSoftInt.
typedef struct POSLIST POSLIST_t |
List variable. This variable type is used as running variable of a list or as list link.
typedef struct POSLISTHEAD POSLISTHEAD_t |
List variable. This variable defines the head of a list.
typedef struct POSMUTEX* POSMUTEX_t |
Handle to a mutex object.
typedef struct POSSEMA* POSSEMA_t |
Handle to a semaphore object.
typedef struct POSTASK* POSTASK_t |
Task environment structure.
Most members of this structure are private, and are hidden from the user. The user can add its own members to the structure. For this purpose the user must define the macro POS_USERTASKDATA in the pico]OS configuration file. Here is an example of this macro:
Note that the stackptr variable is required by most of the architecture ports. The stack array is an example of how to include the stack frame into the task environment structure (e.g. when POSCFG_TASKSTACKTYPE is defined to 2).
typedef void(* POSTASKFUNC_t)(void *arg) |
Generic function pointer.
arg | optional argument, can be NULL if not used. |
typedef struct POSTIMER* POSTIMER_t |
Handle to a timer object.
typedef unsigned MINT_t UINT_t |
Unsigned integer.
The bit size can be changed by the user by defining MINT_t to something other than int in the pico]OS configuration file. This integer type is used by the operating system e.g. for semaphore counters and timer.
Unsigned machine variable type. This variable type is the fastest for the target architecture.
Signed machine variable type. This variable type is the fastest for the target architecture.
VAR_t errno |
Unix style error variable. This variable is global for the currently runnig task.
POSEXTERN volatile POSTASK_t posCurrentTask_g |
Global task variable. This variable points to the environment structure of the currently active task.
POSEXTERN volatile UVAR_t posInInterrupt_g |
Global flag variable. This variable is nonzero when the CPU is currently executing an interrupt service routine.
POSEXTERN volatile POSTASK_t posNextTask_g |
Global task variable. This variable points to the environment structure of the next task that shall be scheduled.
POSEXTERN volatile UVAR_t posRunning_g |
Global flag variable. This variable is nonzero when the operating system is initialized and running.