Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 21332b5

Browse files
author
Janne Kiiskilä
committed
CMSIS/RTOS support for mbedOS 5.5 release
Further changes to PAL to make it work with mbed OS 5.5.
1 parent d92a2a5 commit 21332b5

File tree

8 files changed

+22
-12
lines changed

8 files changed

+22
-12
lines changed

Source/PAL-Impl/Modules/RTOS/pal_rtos.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ palThreadID_t pal_osThreadGetId(void)
118118
return result;
119119
}
120120

121-
void* pal_osThreadGetLocalStore(void)
121+
palThreadLocalStore_t* pal_osThreadGetLocalStore(void)
122122
{
123-
void* result;
123+
palThreadLocalStore_t* result = NULL;
124+
124125
result = pal_plat_osThreadGetLocalStore();
125126
return result;
126127
}

Source/PAL-Impl/Services-API/pal_configuration.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ extern "C" {
3030
#define PAL_RTOS_64BIT_TICK_SUPPORTED false /* add pal support for asynchronous sockets */
3131
#define PAL_UNIQUE_THREAD_PRIORITY (!defined(PAL_IGNORE_UNIQUE_THREAD_PRIORITY))/* if defined code skips the uniqueness priority check */
3232

33+
//! This define is used to determine the size of the initial random buffer (in bytes) held by PAL for random the algorithm.
34+
#define PAL_INITIAL_RANDOM_SIZE 48
35+
3336
//! number of valid priorities limits the number of threads- if priorities are added this value should be increased
3437
#define PAL_MAX_NUMBER_OF_THREADS 7
3538

Source/PAL-Impl/Services-API/pal_errors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ typedef enum {
6262
PAL_ERR_RTOS_PRIORITY = PAL_ERR_RTOS_ERROR_BASE + 0x84,/*! PAL mapping of CMSIS error osErrorPriority : system cannot determine priority or thread has illegal priority.*/
6363
PAL_ERR_RTOS_NO_MEMORY = PAL_ERR_RTOS_ERROR_BASE + 0x85,/*! PAL mapping of CMSIS error osErrorNoMemory : system is out of memory: it was impossible to allocate or reserve memory for the operation.*/
6464
PAL_ERR_RTOS_VALUE = PAL_ERR_RTOS_ERROR_BASE + 0x86,/*! PAL mapping of CMSIS error osErrorValue : value of a parameter is out of range.*/
65+
PAL_ERR_RTOS_TRNG_FAILED = PAL_ERR_RTOS_ERROR_BASE + 0x87, /*! True Random Number Failed */
66+
PAL_ERR_RTOS_TASK = PAL_ERR_RTOS_ERROR_BASE + 0x88,/*! PAL mapping - Cannot kill own task. */
6567
PAL_ERR_RTOS_OS = PAL_ERR_RTOS_ERROR_BASE + 0xFF,/*! PAL mapping of CMSIS error osErrorOS : unspecified RTOS error: run-time error but no other error message fits.*/
6668
// network errors
6769
PAL_ERR_SOCKET_ERROR_BASE = (-1 << PAL_ERR_MODULE_NET), /*! generic socket error */

Source/PAL-Impl/Services-API/pal_rtos.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ extern "C" {
2727
#include "pal_macros.h"
2828
#include "pal_types.h"
2929

30+
#define PRIORITY_INDEX_OFFSET 3
31+
3032
//! Wait forever define. used for Semaphores and Mutexes
3133
#define PAL_RTOS_WAIT_FOREVER PAL_MAX_UINT32
3234

@@ -143,7 +145,7 @@ palThreadID_t pal_osThreadGetId(void);
143145

144146
/*! Get the storage of current thread
145147
* \return the storage of the current thread */
146-
void* pal_osThreadGetLocalStore(void);
148+
palThreadLocalStore_t* pal_osThreadGetLocalStore(void);
147149

148150
/*! Wait for a specified time period in milliseconds.
149151
*

Source/PAL-Impl/Services-API/pal_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ extern "C" {
2727

2828
#define PAL_SUCCESS 0
2929
#define NULLPTR 0
30+
#define PAL_INVALID_THREAD 0xFFFFFFFF
31+
3032

3133
typedef int32_t palStatus_t;
3234

Source/Port/Platform-API/pal_plat_rtos.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ palStatus_t pal_plat_RTOSInitialize(void* opaqueContext);
6060

6161
/*! De-Initialize thread objects.
6262
*/
63-
void pal_plat_RTOSDestroy(void);
63+
palStatus_t pal_plat_RTOSDestroy(void);
6464

6565
/*! Get the RTOS kernel system timer counter.
6666
*
@@ -69,7 +69,7 @@ void pal_plat_RTOSDestroy(void);
6969
* \note The required tick counter is the OS (platform) kernel system tick counter.
7070
* \note This counter wraps around very often (for example, once every 42 sec for 100Mhz).
7171
*/
72-
uint32_t pal_plat_osKernelSysTick();
72+
uint64_t pal_plat_osKernelSysTick(void);
7373

7474
/*! Get the RTOS kernel system timer counter.
7575
*
@@ -132,7 +132,7 @@ palThreadID_t pal_plat_osThreadGetId();
132132
/*! Get the storage of the current thread.
133133
* \return The storage of the current thread.
134134
*/
135-
void* pal_plat_osThreadGetLocalStore();
135+
palThreadLocalStore_t* pal_plat_osThreadGetLocalStore();
136136

137137
/*! Wait for a specified period of time in milliseconds.
138138
*

Source/Port/Reference-Impl/mbedOS/RTOS/pal_plat_rtos.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
#define PAL_NUM_OF_THREAD_INSTANCES 1
4040
#define PAL_MAX_SEMAPHORE_COUNT 1024
4141

42-
PAL_PRIVATE uint8_t g_randomBuffer[PAL_INITIAL_RANDOM_SIZE] = {0};
43-
PAL_PRIVATE bool g_randInitiated = false;
42+
uint8_t g_randomBuffer[PAL_INITIAL_RANDOM_SIZE] = {0};
43+
static bool g_randInitiated = false;
4444

4545
typedef struct palThreadFuncWrapper{
4646
palTimerFuncPtr realThreadFunc;
@@ -98,7 +98,7 @@ typedef struct palMessageQ{
9898
}palMessageQ_t;
9999

100100

101-
inline PAL_PRIVATE void setDefaultThreadValues(palThread_t* thread)
101+
inline static void setDefaultThreadValues(palThread_t* thread)
102102
{
103103
#if PAL_UNIQUE_THREAD_PRIORITY
104104
g_palThreadPriorities[thread->osThread.priority+PRIORITY_INDEX_OFFSET] = false;
@@ -132,7 +132,7 @@ inline PAL_PRIVATE void setDefaultThreadValues(palThread_t* thread)
132132
* @param[in] dbPointer: data base pointer.
133133
* @param[in] index: the index in the data base to be cleaned.
134134
*/
135-
PAL_PRIVATE void threadCleanUp(void* dbPointer, uint32_t index)
135+
static void threadCleanUp(void* dbPointer, uint32_t index)
136136
{
137137
palThread_t* threadsDB = (palThread_t*)dbPointer;
138138

@@ -149,7 +149,7 @@ PAL_PRIVATE void threadCleanUp(void* dbPointer, uint32_t index)
149149
*
150150
* @param[in] arg: data structure which contains the real data about the thread.
151151
*/
152-
PAL_PRIVATE void threadFunctionWrapper(void const* arg)
152+
static void threadFunctionWrapper(void const* arg)
153153
{
154154
palThreadFuncWrapper_t* threadWrapper = (palThreadFuncWrapper_t*)arg;
155155

Test/Common/pal_rtos_test_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ timerArgument_t timerArgs;
2626
void palThreadFunc1(void const *argument)
2727
{
2828
palThreadID_t threadID = 10;
29-
uint32_t* threadStorage = NULL;
29+
pal_osThreadGetLocalStore* threadStorage = NULL;
3030
threadsArgument_t *tmp = (threadsArgument_t*)argument;
3131
#ifdef MUTEX_UNITY_TEST
3232
palStatus_t status = PAL_SUCCESS;

0 commit comments

Comments
 (0)