PAL A Platform Abstraction Layer connects the mbed-client with the underlying platform.

- Main Page
- Data Structures
- Files

- File List
- Globals

pal_rtos.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016 ARM Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 * Licensed under the Apache License, Version 2.0 (the License); you may
5 * not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #ifndef _PAL_RTOS_H
19 #define _PAL_RTOS_H
20
21 #include <stdint.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include "pal_macros.h"
28 #include "pal_types.h"
29
31 #define PAL_RTOS_WAIT_FOREVER PAL_MAX_UINT32
32
34 typedef uintptr_t palThreadID_t;
35 typedef uintptr_t palTimerID_t;
36 typedef uintptr_t palMutexID_t;
37 typedef uintptr_t palSemaphoreID_t;
38 typedef uintptr_t palMemoryPoolID_t;
39 typedef uintptr_t palMessageQID_t;
40
42 typedef enum palTimerType {
43 palOsTimerOnce = 0,
44 palOsTimerPeriodic = 1
45 } palTimerType_t;
46
48 typedef void(*palTimerFuncPtr)(void const *funcArgument);
49
51 typedef void(*palThreadFuncPtr)(void const *funcArgument);
52
54 typedef enum pal_osPriority {
55 PAL_osPriorityIdle = -3,
56 PAL_osPriorityLow = -2,
57 PAL_osPriorityBelowNormal = -1,
58 PAL_osPriorityNormal = 0,
59 PAL_osPriorityAboveNormal = +1,
60 PAL_osPriorityHigh = +2,
61 PAL_osPriorityRealtime = +3,
62 PAL_osPriorityError = 0x84
63 } palThreadPriority_t;
65 typedef struct pal_threadLocalStore{
68 void* storeData;
69 } palThreadLocalStore_t;
70
71 //------- system general functions
74 void pal_osReboot(void);
75
76 //------- system tick functions
81 uint32_t pal_osKernelSysTick(void);
82
86 uint64_t pal_osKernelSysTick64(void);
87
94 uint64_t pal_osKernelSysTickMicroSec(uint64_t microseconds);
95
102 uint64_t pal_osKernelSysMilliSecTick(uint64_t sysTicks);
103
107 uint64_t pal_osKernelSysTickFrequency(void);
108
126 palStatus_t pal_osThreadCreate(palThreadFuncPtr function, void* funcArgument, palThreadPriority_t priority, uint32_t stackSize, uint32_t* stackPtr, palThreadLocalStore_t* store, palThreadID_t* threadID);
127
128
136 palStatus_t pal_osThreadTerminate(palThreadID_t* threadID);
137
142 palThreadID_t pal_osThreadGetId(void);
143
146 void* pal_osThreadGetLocalStore(void);
147
154 palStatus_t pal_osDelay(uint32_t milliseconds);
155
168 palStatus_t pal_osTimerCreate(palTimerFuncPtr function, void* funcArgument, palTimerType_t timerType, palTimerID_t* timerID);
169
177 palStatus_t pal_osTimerStart(palTimerID_t timerID, uint32_t millisec);
178
183 palStatus_t pal_osTimerStop(palTimerID_t timerID);
184
192 palStatus_t pal_osTimerDelete(palTimerID_t* timerID);
193
201 palStatus_t pal_osMutexCreate(palMutexID_t* mutexID);
202
216 palStatus_t pal_osMutexWait(palMutexID_t mutexID, uint32_t millisec);
217
223 palStatus_t pal_osMutexRelease(palMutexID_t mutexID);
224
235 palStatus_t pal_osMutexDelete(palMutexID_t* mutexID);
236
245 palStatus_t pal_osSemaphoreCreate(uint32_t count, palSemaphoreID_t* semaphoreID);
246
258 palStatus_t pal_osSemaphoreWait(palSemaphoreID_t semaphoreID, uint32_t millisec, int32_t* countersAvailable);
259
266 palStatus_t pal_osSemaphoreRelease(palSemaphoreID_t semaphoreID);
267
277 palStatus_t pal_osSemaphoreDelete(palSemaphoreID_t* semaphoreID);
278
288 palStatus_t pal_osPoolCreate(uint32_t blockSize, uint32_t blockCount, palMemoryPoolID_t* memoryPoolID);
289
296 void* pal_osPoolAlloc(palMemoryPoolID_t memoryPoolID);
297
304 void* pal_osPoolCAlloc(palMemoryPoolID_t memoryPoolID);
305
313 palStatus_t pal_osPoolFree(palMemoryPoolID_t memoryPoolID, void* block);
314
321 palStatus_t pal_osPoolDestroy(palMemoryPoolID_t* memoryPoolID);
322
323
332 palStatus_t pal_osMessageQueueCreate(uint32_t messageQSize, palMessageQID_t* messageQID);
333
342 palStatus_t pal_osMessagePut(palMessageQID_t messageQID, uint32_t info, uint32_t timeout);
343
355 palStatus_t pal_osMessageGet(palMessageQID_t messageQID, uint32_t timeout, uint32_t* messageValue);
356
363 palStatus_t pal_osMessageQueueDestroy(palMessageQID_t* messageQID);
364
372 int32_t pal_osAtomicIncrement(int32_t* valuePtr, int32_t increment);
373
374
375
376
385 void dbgPrintf( const char* function, uint32_t line, const char * format, ... );
386
387 #define PAL_PRINTF( ARGS...) \
388 dbgPrintf(__FUNCTION__,__LINE__, ARGS);
389
390
391
392
393
394 #ifdef __cplusplus
395 }
396 #endif
397 #endif //_PAL_RTOS_H
pal_osSemaphoreRelease
palStatus_t pal_osSemaphoreRelease(palSemaphoreID_t semaphoreID)
Definition: pal_rtos.c:205
pal_osAtomicIncrement
int32_t pal_osAtomicIncrement(int32_t *valuePtr, int32_t increment)
Definition: pal_rtos.c:284
palSemaphoreID_t
uintptr_t palSemaphoreID_t
Definition: pal_rtos.h:37
pal_threadLocalStore
Definition: pal_rtos.h:67
pal_osMessageQueueCreate
palStatus_t pal_osMessageQueueCreate(uint32_t messageQSize, palMessageQID_t *messageQID)
Definition: pal_rtos.c:256
pal_osTimerDelete
palStatus_t pal_osTimerDelete(palTimerID_t *timerID)
Definition: pal_rtos.c:157
pal_osPoolDestroy
palStatus_t pal_osPoolDestroy(palMemoryPoolID_t *memoryPoolID)
Definition: pal_rtos.c:249
pal_osKernelSysTick
uint32_t pal_osKernelSysTick(void)
Definition: pal_rtos.c:31
pal_osMessagePut
palStatus_t pal_osMessagePut(palMessageQID_t messageQID, uint32_t info, uint32_t timeout)
Definition: pal_rtos.c:263
pal_osThreadGetId
palThreadID_t pal_osThreadGetId(void)
Definition: pal_rtos.c:114
pal_osMutexCreate
palStatus_t pal_osMutexCreate(palMutexID_t *mutexID)
Definition: pal_rtos.c:164
pal_osTimerCreate
palStatus_t pal_osTimerCreate(palTimerFuncPtr function, void *funcArgument, palTimerType_t timerType, palTimerID_t *timerID)
Definition: pal_rtos.c:136
palTimerType_t
enum palTimerType palTimerType_t
Timers types supported in PAL.
pal_osSemaphoreCreate
palStatus_t pal_osSemaphoreCreate(uint32_t count, palSemaphoreID_t *semaphoreID)
Definition: pal_rtos.c:191
pal_osTimerStart
palStatus_t pal_osTimerStart(palTimerID_t timerID, uint32_t millisec)
Definition: pal_rtos.c:143
PAL_osPriorityHigh
Definition: pal_rtos.h:60
PAL_osPriorityError
Definition: pal_rtos.h:62
palTimerFuncPtr
void(* palTimerFuncPtr)(void const *funcArgument)
PAL timer function prototype.
Definition: pal_rtos.h:48
PAL_osPriorityLow
Definition: pal_rtos.h:56
pal_osPriority
pal_osPriority
Available priorities in PAL implementation, each priority can appear only once.
Definition: pal_rtos.h:54
palThreadLocalStore_t
struct pal_threadLocalStore palThreadLocalStore_t
pal_osPoolFree
palStatus_t pal_osPoolFree(palMemoryPoolID_t memoryPoolID, void *block)
Definition: pal_rtos.c:241
pal_osPoolCreate
palStatus_t pal_osPoolCreate(uint32_t blockSize, uint32_t blockCount, palMemoryPoolID_t *memoryPoolID)
Definition: pal_rtos.c:219
PAL_osPriorityRealtime
Definition: pal_rtos.h:61
palMutexID_t
uintptr_t palMutexID_t
Definition: pal_rtos.h:36
palThreadFuncPtr
void(* palThreadFuncPtr)(void const *funcArgument)
PAL thread function prototype.
Definition: pal_rtos.h:51
palMessageQID_t
uintptr_t palMessageQID_t
Definition: pal_rtos.h:39
palOsTimerPeriodic
Definition: pal_rtos.h:44
pal_osPoolCAlloc
void * pal_osPoolCAlloc(palMemoryPoolID_t memoryPoolID)
Definition: pal_rtos.c:233
pal_osSemaphoreDelete
palStatus_t pal_osSemaphoreDelete(palSemaphoreID_t *semaphoreID)
Definition: pal_rtos.c:212
palOsTimerOnce
Definition: pal_rtos.h:43
pal_osThreadTerminate
palStatus_t pal_osThreadTerminate(palThreadID_t *threadID)
Definition: pal_rtos.c:107
palTimerType
palTimerType
Timers types supported in PAL.
Definition: pal_rtos.h:42
pal_osReboot
void pal_osReboot(void)
Definition: pal_rtos.c:26
pal_types.h
palThreadPriority_t
enum pal_osPriority palThreadPriority_t
Available priorities in PAL implementation, each priority can appear only once.
pal_osMutexRelease
palStatus_t pal_osMutexRelease(palMutexID_t mutexID)
Definition: pal_rtos.c:178
pal_osKernelSysMilliSecTick
uint64_t pal_osKernelSysMilliSecTick(uint64_t sysTicks)
Definition: pal_rtos.c:68
pal_osPoolAlloc
void * pal_osPoolAlloc(palMemoryPoolID_t memoryPoolID)
Definition: pal_rtos.c:226
pal_osTimerStop
palStatus_t pal_osTimerStop(palTimerID_t timerID)
Definition: pal_rtos.c:150
pal_osThreadCreate
palStatus_t pal_osThreadCreate(palThreadFuncPtr function, void *funcArgument, palThreadPriority_t priority, uint32_t stackSize, uint32_t *stackPtr, palThreadLocalStore_t *store, palThreadID_t *threadID)
Definition: pal_rtos.c:82
palMemoryPoolID_t
uintptr_t palMemoryPoolID_t
Definition: pal_rtos.h:38
palTimerID_t
uintptr_t palTimerID_t
Definition: pal_rtos.h:35
PAL_osPriorityAboveNormal
Definition: pal_rtos.h:59
pal_macros.h
pal_osKernelSysTickMicroSec
uint64_t pal_osKernelSysTickMicroSec(uint64_t microseconds)
Definition: pal_rtos.c:61
pal_osKernelSysTick64
uint64_t pal_osKernelSysTick64(void)
Definition: pal_rtos.c:39
dbgPrintf
void dbgPrintf(const char *function, uint32_t line, const char *format,...)
Definition: pal_rtos.c:297
pal_osMutexWait
palStatus_t pal_osMutexWait(palMutexID_t mutexID, uint32_t millisec)
Definition: pal_rtos.c:171
pal_osMessageQueueDestroy
palStatus_t pal_osMessageQueueDestroy(palMessageQID_t *messageQID)
Definition: pal_rtos.c:277
pal_osSemaphoreWait
palStatus_t pal_osSemaphoreWait(palSemaphoreID_t semaphoreID, uint32_t millisec, int32_t *countersAvailable)
Definition: pal_rtos.c:198
pal_osDelay
palStatus_t pal_osDelay(uint32_t milliseconds)
Definition: pal_rtos.c:128
PAL_osPriorityNormal
Definition: pal_rtos.h:58
palThreadID_t
uintptr_t palThreadID_t
Primitives IDs types declarations.
Definition: pal_rtos.h:34
pal_osThreadGetLocalStore
void * pal_osThreadGetLocalStore(void)
Definition: pal_rtos.c:121
PAL_osPriorityIdle
Definition: pal_rtos.h:55
palStatus_t
int32_t palStatus_t
Definition: pal_types.h:31
pal_osMessageGet
palStatus_t pal_osMessageGet(palMessageQID_t messageQID, uint32_t timeout, uint32_t *messageValue)
Definition: pal_rtos.c:270
pal_threadLocalStore::storeData
void * storeData
Definition: pal_rtos.h:68
pal_osKernelSysTickFrequency
uint64_t pal_osKernelSysTickFrequency(void)
Definition: pal_rtos.c:75
pal_osMutexDelete
palStatus_t pal_osMutexDelete(palMutexID_t *mutexID)
Definition: pal_rtos.c:185
PAL_osPriorityBelowNormal
Definition: pal_rtos.h:57