PAL
A Platform Abstraction Layer connects the mbed-client with the underlying platform.
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 {
46 
48 typedef void(*palTimerFuncPtr)(void const *funcArgument);
49 
51 typedef void(*palThreadFuncPtr)(void const *funcArgument);
52 
54 typedef enum pal_osPriority {
65 typedef struct pal_threadLocalStore{
68  void* storeData;
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
palStatus_t pal_osSemaphoreRelease(palSemaphoreID_t semaphoreID)
Definition: pal_rtos.c:205
int32_t pal_osAtomicIncrement(int32_t *valuePtr, int32_t increment)
Definition: pal_rtos.c:284
uintptr_t palSemaphoreID_t
Definition: pal_rtos.h:37
Definition: pal_rtos.h:67
palStatus_t pal_osMessageQueueCreate(uint32_t messageQSize, palMessageQID_t *messageQID)
Definition: pal_rtos.c:256
palStatus_t pal_osTimerDelete(palTimerID_t *timerID)
Definition: pal_rtos.c:157
palStatus_t pal_osPoolDestroy(palMemoryPoolID_t *memoryPoolID)
Definition: pal_rtos.c:249
uint32_t pal_osKernelSysTick(void)
Definition: pal_rtos.c:31
palStatus_t pal_osMessagePut(palMessageQID_t messageQID, uint32_t info, uint32_t timeout)
Definition: pal_rtos.c:263
palThreadID_t pal_osThreadGetId(void)
Definition: pal_rtos.c:114
palStatus_t pal_osMutexCreate(palMutexID_t *mutexID)
Definition: pal_rtos.c:164
palStatus_t pal_osTimerCreate(palTimerFuncPtr function, void *funcArgument, palTimerType_t timerType, palTimerID_t *timerID)
Definition: pal_rtos.c:136
enum palTimerType palTimerType_t
Timers types supported in PAL.
palStatus_t pal_osSemaphoreCreate(uint32_t count, palSemaphoreID_t *semaphoreID)
Definition: pal_rtos.c:191
palStatus_t pal_osTimerStart(palTimerID_t timerID, uint32_t millisec)
Definition: pal_rtos.c:143
Definition: pal_rtos.h:60
Definition: pal_rtos.h:62
void(* palTimerFuncPtr)(void const *funcArgument)
PAL timer function prototype.
Definition: pal_rtos.h:48
Definition: pal_rtos.h:56
pal_osPriority
Available priorities in PAL implementation, each priority can appear only once.
Definition: pal_rtos.h:54
struct pal_threadLocalStore palThreadLocalStore_t
palStatus_t pal_osPoolFree(palMemoryPoolID_t memoryPoolID, void *block)
Definition: pal_rtos.c:241
palStatus_t pal_osPoolCreate(uint32_t blockSize, uint32_t blockCount, palMemoryPoolID_t *memoryPoolID)
Definition: pal_rtos.c:219
Definition: pal_rtos.h:61
uintptr_t palMutexID_t
Definition: pal_rtos.h:36
void(* palThreadFuncPtr)(void const *funcArgument)
PAL thread function prototype.
Definition: pal_rtos.h:51
uintptr_t palMessageQID_t
Definition: pal_rtos.h:39
Definition: pal_rtos.h:44
void * pal_osPoolCAlloc(palMemoryPoolID_t memoryPoolID)
Definition: pal_rtos.c:233
palStatus_t pal_osSemaphoreDelete(palSemaphoreID_t *semaphoreID)
Definition: pal_rtos.c:212
Definition: pal_rtos.h:43
palStatus_t pal_osThreadTerminate(palThreadID_t *threadID)
Definition: pal_rtos.c:107
palTimerType
Timers types supported in PAL.
Definition: pal_rtos.h:42
void pal_osReboot(void)
Definition: pal_rtos.c:26
enum pal_osPriority palThreadPriority_t
Available priorities in PAL implementation, each priority can appear only once.
palStatus_t pal_osMutexRelease(palMutexID_t mutexID)
Definition: pal_rtos.c:178
uint64_t pal_osKernelSysMilliSecTick(uint64_t sysTicks)
Definition: pal_rtos.c:68
void * pal_osPoolAlloc(palMemoryPoolID_t memoryPoolID)
Definition: pal_rtos.c:226
palStatus_t pal_osTimerStop(palTimerID_t timerID)
Definition: pal_rtos.c:150
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
uintptr_t palMemoryPoolID_t
Definition: pal_rtos.h:38
uintptr_t palTimerID_t
Definition: pal_rtos.h:35
Definition: pal_rtos.h:59
uint64_t pal_osKernelSysTickMicroSec(uint64_t microseconds)
Definition: pal_rtos.c:61
uint64_t pal_osKernelSysTick64(void)
Definition: pal_rtos.c:39
void dbgPrintf(const char *function, uint32_t line, const char *format,...)
Definition: pal_rtos.c:297
palStatus_t pal_osMutexWait(palMutexID_t mutexID, uint32_t millisec)
Definition: pal_rtos.c:171
palStatus_t pal_osMessageQueueDestroy(palMessageQID_t *messageQID)
Definition: pal_rtos.c:277
palStatus_t pal_osSemaphoreWait(palSemaphoreID_t semaphoreID, uint32_t millisec, int32_t *countersAvailable)
Definition: pal_rtos.c:198
palStatus_t pal_osDelay(uint32_t milliseconds)
Definition: pal_rtos.c:128
Definition: pal_rtos.h:58
uintptr_t palThreadID_t
Primitives IDs types declarations.
Definition: pal_rtos.h:34
void * pal_osThreadGetLocalStore(void)
Definition: pal_rtos.c:121
Definition: pal_rtos.h:55
int32_t palStatus_t
Definition: pal_types.h:31
palStatus_t pal_osMessageGet(palMessageQID_t messageQID, uint32_t timeout, uint32_t *messageValue)
Definition: pal_rtos.c:270
void * storeData
Definition: pal_rtos.h:68
uint64_t pal_osKernelSysTickFrequency(void)
Definition: pal_rtos.c:75
palStatus_t pal_osMutexDelete(palMutexID_t *mutexID)
Definition: pal_rtos.c:185
Definition: pal_rtos.h:57