Mistake on this page? Email us
pal_rtos.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // Copyright 2016-2019 ARM Ltd.
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://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,
14 // WITHOUT 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 #ifndef _PAL_RTOS_H
20 #define _PAL_RTOS_H
21 
22 #ifndef _PAL_H
23  #error "Please do not include this file directly, use pal.h instead"
24 #endif
25 
26 #include <stdint.h>
27 #include <string.h> //memcpy
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include "pal.h" //added for PAL_INITIAL_RANDOM_SIZE value
35 
45 #define PAL_TICK_TO_MILLI_FACTOR 1000
47 
49 typedef uintptr_t palThreadID_t;
50 typedef uintptr_t palTimerID_t;
51 typedef uintptr_t palMutexID_t;
52 typedef uintptr_t palSemaphoreID_t;
53 typedef uintptr_t palMemoryPoolID_t;
54 typedef uintptr_t palMessageQID_t;
55 
57 typedef enum palTimerType {
61 
62 
64 typedef void(*palTimerFuncPtr)(void const *funcArgument);
65 
67 typedef void(*palThreadFuncPtr)(void const *funcArgument);
68 
70 typedef enum pal_osPriority {
87 typedef struct pal_threadLocalStore{
91  void* storeData;
93 
94 typedef struct pal_timeVal{
95  int32_t pal_tv_sec;
96  int32_t pal_tv_usec;
98 
99 
100 //------- system general functions
106 void pal_osReboot(void);
107 
108 //------- system tick functions
114 uint64_t pal_osKernelSysTick(void);
115 
116 
123 uint64_t pal_osKernelSysTickMicroSec(uint64_t microseconds);
124 
131 uint64_t pal_osKernelSysMilliSecTick(uint64_t sysTicks);
132 
138 uint64_t pal_osKernelSysTickFrequency(void);
139 
155 palStatus_t pal_osThreadCreateWithAlloc(palThreadFuncPtr function, void* funcArgument, palThreadPriority_t priority, uint32_t stackSize, palThreadLocalStore_t* store, palThreadID_t* threadID);
156 
166 palStatus_t pal_osThreadTerminate(palThreadID_t* threadID);
167 
172 palThreadID_t pal_osThreadGetId(void);
173 
180 palStatus_t pal_osDelay(uint32_t milliseconds);
181 
194 palStatus_t pal_osTimerCreate(palTimerFuncPtr function, void* funcArgument, palTimerType_t timerType, palTimerID_t* timerID);
195 
204 palStatus_t pal_osTimerStart(palTimerID_t timerID, uint32_t millisec);
205 
210 palStatus_t pal_osTimerStop(palTimerID_t timerID);
211 
219 palStatus_t pal_osTimerDelete(palTimerID_t* timerID);
220 
228 palStatus_t pal_osMutexCreate(palMutexID_t* mutexID);
229 
241 palStatus_t pal_osMutexWait(palMutexID_t mutexID, uint32_t millisec);
242 
248 palStatus_t pal_osMutexRelease(palMutexID_t mutexID);
249 
260 palStatus_t pal_osMutexDelete(palMutexID_t* mutexID);
261 
270 palStatus_t pal_osSemaphoreCreate(uint32_t count, palSemaphoreID_t* semaphoreID);
271 
284 palStatus_t pal_osSemaphoreWait(palSemaphoreID_t semaphoreID, uint32_t millisec, int32_t* countersAvailable);
285 
292 palStatus_t pal_osSemaphoreRelease(palSemaphoreID_t semaphoreID);
293 
303 palStatus_t pal_osSemaphoreDelete(palSemaphoreID_t* semaphoreID);
304 
312 int32_t pal_osAtomicIncrement(int32_t* valuePtr, int32_t increment);
313 
323 palStatus_t pal_RTOSInitialize(void* opaqueContext);
324 
325 
332 
333 
334 
335 #ifdef __cplusplus
336 }
337 #endif
338 #endif //_PAL_RTOS_H
palStatus_t pal_osSemaphoreRelease(palSemaphoreID_t semaphoreID)
Release a semaphore token.
int32_t pal_osAtomicIncrement(int32_t *valuePtr, int32_t increment)
Perform an atomic increment for a signed 32-bit value.
PAL. This file contains the general API to initiate and destroy the PAL component. This is part of the PAL service API.
uintptr_t palSemaphoreID_t
Definition: pal_rtos.h:52
int32_t pal_tv_usec
Microseconds.
Definition: pal_rtos.h:96
Thread local store struct.
Definition: pal_rtos.h:90
palStatus_t pal_osTimerDelete(palTimerID_t *timerID)
Delete a timer object.
Definition: pal_rtos.h:71
palStatus_t pal_osThreadCreateWithAlloc(palThreadFuncPtr function, void *funcArgument, palThreadPriority_t priority, uint32_t stackSize, palThreadLocalStore_t *store, palThreadID_t *threadID)
Allocates memory for the thread stack, creates and starts the thread function inside the PAL platform...
Definition: pal_rtos.h:79
palStatus_t pal_RTOSDestroy(void)
palThreadID_t pal_osThreadGetId(void)
Get the ID of the current thread.
palStatus_t pal_osMutexCreate(palMutexID_t *mutexID)
Create and initialize a mutex object.
Definition: pal_rtos.h:78
palStatus_t pal_osTimerCreate(palTimerFuncPtr function, void *funcArgument, palTimerType_t timerType, palTimerID_t *timerID)
Create a timer.
enum palTimerType palTimerType_t
Timer types supported in PAL.
palStatus_t pal_osSemaphoreCreate(uint32_t count, palSemaphoreID_t *semaphoreID)
Create and initialize a semaphore object.
palStatus_t pal_osTimerStart(palTimerID_t timerID, uint32_t millisec)
Start or restart a timer.
uint64_t pal_osKernelSysTick(void)
Get the RTOS kernel system timer counter.
Definition: pal_rtos.h:80
Definition: pal_rtos.h:84
void(* palTimerFuncPtr)(void const *funcArgument)
PAL timer function prototype.
Definition: pal_rtos.h:64
Definition: pal_rtos.h:73
pal_osPriority
Available priorities in PAL implementation, each priority can appear only once.
Definition: pal_rtos.h:70
struct pal_timeVal pal_timeVal_t
Definition: pal_rtos.h:74
struct pal_threadLocalStore palThreadLocalStore_t
Thread local store struct.
palStatus_t pal_RTOSInitialize(void *opaqueContext)
Definition: pal_rtos.h:82
uintptr_t palMutexID_t
Definition: pal_rtos.h:51
void(* palThreadFuncPtr)(void const *funcArgument)
PAL thread function prototype.
Definition: pal_rtos.h:67
uintptr_t palMessageQID_t
Definition: pal_rtos.h:54
Definition: pal_rtos.h:59
Definition: pal_rtos.h:81
palStatus_t pal_osSemaphoreDelete(palSemaphoreID_t *semaphoreID)
Delete a semaphore object.
int32_t pal_tv_sec
Seconds.
Definition: pal_rtos.h:95
Definition: pal_rtos.h:58
palStatus_t pal_osThreadTerminate(palThreadID_t *threadID)
Terminate the thread and free the data allocated for it.
palTimerType
Timer types supported in PAL.
Definition: pal_rtos.h:57
void pal_osReboot(void)
Initiates a system reboot.
Definition: pal_rtos.h:83
enum pal_osPriority palThreadPriority_t
Thread priority levels for PAL threads - each thread must have a different priority.
palStatus_t pal_osMutexRelease(palMutexID_t mutexID)
Release a mutex that was obtained by osMutexWait.
uint64_t pal_osKernelSysMilliSecTick(uint64_t sysTicks)
Converts kernel system ticks to milliseconds.
palStatus_t pal_osTimerStop(palTimerID_t timerID)
Stop a timer.
uintptr_t palMemoryPoolID_t
Definition: pal_rtos.h:53
uintptr_t palTimerID_t
Definition: pal_rtos.h:50
Definition: pal_rtos.h:77
uint64_t pal_osKernelSysTickMicroSec(uint64_t microseconds)
Converts a value from microseconds to kernel system ticks.
palStatus_t pal_osMutexWait(palMutexID_t mutexID, uint32_t millisec)
Wait until a mutex becomes available.
palStatus_t pal_osSemaphoreWait(palSemaphoreID_t semaphoreID, uint32_t millisec, int32_t *countersAvailable)
Wait until a semaphore token becomes available.
palStatus_t pal_osDelay(uint32_t milliseconds)
Wait for a specified time period in milliseconds.
Definition: pal_rtos.h:76
uintptr_t palThreadID_t
Primitive ID type declarations.
Definition: pal_rtos.h:49
Definition: pal_rtos.h:72
int32_t palStatus_t
Definition: pal_types.h:55
Definition: pal_rtos.h:94
void * storeData
Definition: pal_rtos.h:91
uint64_t pal_osKernelSysTickFrequency(void)
Get the system tick frequency.
palStatus_t pal_osMutexDelete(palMutexID_t *mutexID)
Delete a mutex object.
Definition: pal_rtos.h:75