소스 검색

RTX5: improved MISRA compliance (static functions - local scope)

Robert Rostohar 8 년 전
부모
커밋
943578afd2

+ 2 - 2
CMSIS/RTOS2/RTX/Source/rtx_delay.c

@@ -30,7 +30,7 @@
 
 /// Wait for Timeout (Time Delay).
 /// \note API identical to osDelay
-osStatus_t svcRtxDelay (uint32_t ticks) {
+static osStatus_t svcRtxDelay (uint32_t ticks) {
 
   if (ticks != 0U) {
     if (!osRtxThreadWaitEnter(osRtxThreadWaitingDelay, ticks)) {
@@ -43,7 +43,7 @@ osStatus_t svcRtxDelay (uint32_t ticks) {
 
 /// Wait until specified time.
 /// \note API identical to osDelayUntil
-osStatus_t svcRtxDelayUntil (uint32_t ticks) {
+static osStatus_t svcRtxDelayUntil (uint32_t ticks) {
 
   ticks -= osRtxInfo.kernel.tick;
   if (ticks == 0xFFFFFFFFU) {

+ 9 - 9
CMSIS/RTOS2/RTX/Source/rtx_evflags.c

@@ -126,11 +126,11 @@ static uint32_t EventFlagsCheck (os_event_flags_t *ef, uint32_t flags, uint32_t
 }
 
 
-//  ==== Library functions ====
+//  ==== Post ISR processing ====
 
 /// Event Flags post ISR processing.
 /// \param[in]  ef              event flags object.
-void osRtxEventFlagsPostProcess (os_event_flags_t *ef) {
+static void osRtxEventFlagsPostProcess (os_event_flags_t *ef) {
   os_thread_t *thread;
   os_thread_t *thread_next;
   uint32_t     event_flags;
@@ -158,7 +158,7 @@ void osRtxEventFlagsPostProcess (os_event_flags_t *ef) {
 
 /// Create and Initialize an Event Flags object.
 /// \note API identical to osEventFlagsNew
-osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) {
+static osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) {
   os_event_flags_t *ef;
   uint8_t           flags;
   const char       *name;
@@ -217,7 +217,7 @@ osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) {
 
 /// Get name of an Event Flags object.
 /// \note API identical to osEventFlagsGetName
-const char *svcRtxEventFlagsGetName (osEventFlagsId_t ef_id) {
+static const char *svcRtxEventFlagsGetName (osEventFlagsId_t ef_id) {
   os_event_flags_t *ef = (os_event_flags_t *)ef_id;
 
   // Check parameters
@@ -239,7 +239,7 @@ const char *svcRtxEventFlagsGetName (osEventFlagsId_t ef_id) {
 
 /// Set the specified Event Flags.
 /// \note API identical to osEventFlagsSet
-uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) {
+static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) {
   os_event_flags_t *ef = (os_event_flags_t *)ef_id;
   os_thread_t      *thread;
   os_thread_t      *thread_next;
@@ -288,7 +288,7 @@ uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) {
 
 /// Clear the specified Event Flags.
 /// \note API identical to osEventFlagsClear
-uint32_t svcRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) {
+static uint32_t svcRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) {
   os_event_flags_t *ef = (os_event_flags_t *)ef_id;
   uint32_t          event_flags;
 
@@ -315,7 +315,7 @@ uint32_t svcRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) {
 
 /// Get the current Event Flags.
 /// \note API identical to osEventFlagsGet
-uint32_t svcRtxEventFlagsGet (osEventFlagsId_t ef_id) {
+static uint32_t svcRtxEventFlagsGet (osEventFlagsId_t ef_id) {
   os_event_flags_t *ef = (os_event_flags_t *)ef_id;
 
   // Check parameters
@@ -337,7 +337,7 @@ uint32_t svcRtxEventFlagsGet (osEventFlagsId_t ef_id) {
 
 /// Wait for one or more Event Flags to become signaled.
 /// \note API identical to osEventFlagsWait
-uint32_t svcRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) {
+static uint32_t svcRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) {
   os_event_flags_t *ef = (os_event_flags_t *)ef_id;
   os_thread_t      *running_thread;
   uint32_t          event_flags;
@@ -391,7 +391,7 @@ uint32_t svcRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t
 
 /// Delete an Event Flags object.
 /// \note API identical to osEventFlagsDelete
-osStatus_t svcRtxEventFlagsDelete (osEventFlagsId_t ef_id) {
+static osStatus_t svcRtxEventFlagsDelete (osEventFlagsId_t ef_id) {
   os_event_flags_t *ef = (os_event_flags_t *)ef_id;
   os_thread_t      *thread;
 

+ 30 - 42
CMSIS/RTOS2/RTX/Source/rtx_kernel.c

@@ -66,7 +66,7 @@ static void KernelUnblock (void) {
 
 /// Initialize the RTOS Kernel.
 /// \note API identical to osKernelInitialize
-osStatus_t svcRtxKernelInitialize (void) {
+static osStatus_t svcRtxKernelInitialize (void) {
 
   if (osRtxInfo.kernel.state == osRtxKernelReady) {
     EvrRtxKernelInitializeCompleted();
@@ -77,9 +77,6 @@ osStatus_t svcRtxKernelInitialize (void) {
     return osError;
   }
 
-  // Initialize osRtxInfo
-  memset(&osRtxInfo.kernel, 0, sizeof(osRtxInfo) - offsetof(osRtxInfo_t, kernel));
-
   if (osRtxConfig.thread_stack_size < (64U + 8U)) {
     EvrRtxKernelError(osRtxErrorInvalidThreadStack);
     return osError;
@@ -89,6 +86,18 @@ osStatus_t svcRtxKernelInitialize (void) {
     EvrRtxKernelError((int32_t)osError);
     return osError;
   }
+
+#if (DOMAIN_NS == 1)
+  // Initialize Secure Process Stack
+  if (TZ_InitContextSystem_S() == 0U) {
+    EvrRtxKernelError(osRtxErrorTZ_InitContext_S);
+    return osError;
+  }
+#endif
+
+  // Initialize osRtxInfo
+  memset(&osRtxInfo.kernel, 0, sizeof(osRtxInfo) - offsetof(osRtxInfo_t, kernel));
+
   osRtxInfo.isr_queue.data = osRtxConfig.isr_queue.data;
   osRtxInfo.isr_queue.max  = osRtxConfig.isr_queue.max;
 
@@ -180,14 +189,6 @@ osStatus_t svcRtxKernelInitialize (void) {
     }
   }
 
-#if (DOMAIN_NS == 1)
-  // Initialize Secure Process Stack
-  if (TZ_InitContextSystem_S() == 0U) {
-    EvrRtxKernelError(osRtxErrorTZ_InitContext_S);
-    return osError;
-  }
-#endif
-
   osRtxInfo.kernel.state = osRtxKernelReady;
 
   EvrRtxKernelInitializeCompleted();
@@ -197,7 +198,7 @@ osStatus_t svcRtxKernelInitialize (void) {
 
 ///  Get RTOS Kernel Information.
 /// \note API identical to osKernelGetInfo
-osStatus_t svcRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size) {
+static osStatus_t svcRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size) {
 
   if (version != NULL) {
     version->api    = osRtxVersionAPI;
@@ -218,14 +219,14 @@ osStatus_t svcRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_
 
 /// Get the current RTOS Kernel state.
 /// \note API identical to osKernelGetState
-osKernelState_t svcRtxKernelGetState (void) {
+static osKernelState_t svcRtxKernelGetState (void) {
   EvrRtxKernelGetState((osKernelState_t)(osRtxInfo.kernel.state));
   return ((osKernelState_t)(osRtxInfo.kernel.state));
 }
 
 /// Start the RTOS Kernel scheduler.
 /// \note API identical to osKernelStart
-osStatus_t svcRtxKernelStart (void) {
+static osStatus_t svcRtxKernelStart (void) {
   os_thread_t *thread;
 
   if (osRtxInfo.kernel.state != osRtxKernelReady) {
@@ -233,24 +234,10 @@ osStatus_t svcRtxKernelStart (void) {
     return osError;
   }
 
-  // Create Idle Thread
-  if (osRtxInfo.thread.idle == NULL) {
-    osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr);
-    if (osRtxInfo.thread.idle == NULL) {
-      EvrRtxKernelError((int32_t)osError);
-      return osError;
-    }
-  }
-
-  // Create Timer Thread
-  if (osRtxConfig.timer_mq_mcnt != 0U) {
-    if (osRtxInfo.timer.thread == NULL) {
-      osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr);
-      if (osRtxInfo.timer.thread == NULL) {
-        EvrRtxKernelError((int32_t)osError);
-        return osError;
-      }
-    }
+  // Thread startup (Idle and Timer Thread)
+  if (!osRtxThreadStartup()) {
+    EvrRtxKernelError((int32_t)osError);
+    return osError;
   }
 
   // Setup SVC and PendSV System Service Calls
@@ -258,6 +245,7 @@ osStatus_t svcRtxKernelStart (void) {
 
   // Setup RTOS Tick
   if (OS_Tick_Setup(osRtxConfig.tick_freq, OS_TICK_HANDLER) != 0) {
+    EvrRtxKernelError((int32_t)osError);
     return osError;
   }
   osRtxInfo.tick_irqn = OS_Tick_GetIRQn();
@@ -290,7 +278,7 @@ osStatus_t svcRtxKernelStart (void) {
 
 /// Lock the RTOS Kernel scheduler.
 /// \note API identical to osKernelLock
-int32_t svcRtxKernelLock (void) {
+static int32_t svcRtxKernelLock (void) {
   int32_t lock;
 
   switch (osRtxInfo.kernel.state) {
@@ -313,7 +301,7 @@ int32_t svcRtxKernelLock (void) {
  
 /// Unlock the RTOS Kernel scheduler.
 /// \note API identical to osKernelUnlock
-int32_t svcRtxKernelUnlock (void) {
+static int32_t svcRtxKernelUnlock (void) {
   int32_t lock;
 
   switch (osRtxInfo.kernel.state) {
@@ -336,7 +324,7 @@ int32_t svcRtxKernelUnlock (void) {
 
 /// Restore the RTOS Kernel scheduler lock state.
 /// \note API identical to osKernelRestoreLock
-int32_t svcRtxKernelRestoreLock (int32_t lock) {
+static int32_t svcRtxKernelRestoreLock (int32_t lock) {
   int32_t lock_new;
 
   switch (osRtxInfo.kernel.state) {
@@ -369,7 +357,7 @@ int32_t svcRtxKernelRestoreLock (int32_t lock) {
 
 /// Suspend the RTOS Kernel scheduler.
 /// \note API identical to osKernelSuspend
-uint32_t svcRtxKernelSuspend (void) {
+static uint32_t svcRtxKernelSuspend (void) {
   os_thread_t *thread;
   os_timer_t  *timer;
   uint32_t     delay;
@@ -406,7 +394,7 @@ uint32_t svcRtxKernelSuspend (void) {
 
 /// Resume the RTOS Kernel scheduler.
 /// \note API identical to osKernelResume
-void svcRtxKernelResume (uint32_t sleep_ticks) {
+static void svcRtxKernelResume (uint32_t sleep_ticks) {
   os_thread_t *thread;
   os_timer_t  *timer;
   uint32_t     delay;
@@ -469,21 +457,21 @@ void svcRtxKernelResume (uint32_t sleep_ticks) {
 
 /// Get the RTOS kernel tick count.
 /// \note API identical to osKernelGetTickCount
-uint32_t svcRtxKernelGetTickCount (void) {
+static uint32_t svcRtxKernelGetTickCount (void) {
   EvrRtxKernelGetTickCount(osRtxInfo.kernel.tick);
   return osRtxInfo.kernel.tick;
 }
 
 /// Get the RTOS kernel tick frequency.
 /// \note API identical to osKernelGetTickFreq
-uint32_t svcRtxKernelGetTickFreq (void) {
+static uint32_t svcRtxKernelGetTickFreq (void) {
   EvrRtxKernelGetTickFreq(osRtxConfig.tick_freq);
   return osRtxConfig.tick_freq;
 }
 
 /// Get the RTOS kernel system timer count.
 /// \note API identical to osKernelGetSysTimerCount
-uint32_t svcRtxKernelGetSysTimerCount (void) {
+static uint32_t svcRtxKernelGetSysTimerCount (void) {
   uint32_t tick;
   uint32_t count;
 
@@ -500,7 +488,7 @@ uint32_t svcRtxKernelGetSysTimerCount (void) {
 
 /// Get the RTOS kernel system timer frequency.
 /// \note API identical to osKernelGetSysTimerFreq
-uint32_t svcRtxKernelGetSysTimerFreq (void) {
+static uint32_t svcRtxKernelGetSysTimerFreq (void) {
   uint32_t freq = OS_Tick_GetClock();
   EvrRtxKernelGetSysTimerFreq(freq);
   return freq;

+ 13 - 126
CMSIS/RTOS2/RTX/Source/rtx_lib.h

@@ -65,26 +65,21 @@ __STATIC_INLINE void         osRtxThreadSetRunning (os_thread_t *thread) { osRtx
 //  ==== Library functions ====
 
 // Thread Library functions
-extern void         osRtxThreadListPut     (volatile os_object_t *object, os_thread_t *thread);
-extern os_thread_t *osRtxThreadListGet     (volatile os_object_t *object);
-extern void        *osRtxThreadListRoot    (os_thread_t  *thread);
-extern void         osRtxThreadListSort    (os_thread_t  *thread);
-extern void         osRtxThreadListRemove  (os_thread_t  *thread);
-extern void         osRtxThreadListUnlink  (os_thread_t **thread_list, os_thread_t *thread);
-extern void         osRtxThreadReadyPut    (os_thread_t  *thread);
-extern void         osRtxThreadDelayInsert (os_thread_t  *thread, uint32_t delay);
-extern void         osRtxThreadDelayRemove (os_thread_t  *thread);
-extern void         osRtxThreadDelayTick   (void);
-extern uint32_t    *osRtxThreadRegPtr      (os_thread_t  *thread);
-extern void         osRtxThreadBlock       (os_thread_t  *thread);
-extern void         osRtxThreadSwitch      (os_thread_t  *thread);
-extern void         osRtxThreadDispatch    (os_thread_t  *thread);
-extern void         osRtxThreadWaitExit    (os_thread_t  *thread, uint32_t ret_val, bool_t dispatch);
-extern bool_t       osRtxThreadWaitEnter   (uint8_t state, uint32_t timeout);
-extern void         osRtxThreadStackCheck  (void);
+extern void         osRtxThreadListPut    (volatile os_object_t *object, os_thread_t *thread);
+extern os_thread_t *osRtxThreadListGet    (volatile os_object_t *object);
+extern void         osRtxThreadListSort   (os_thread_t *thread);
+extern void         osRtxThreadListRemove (os_thread_t *thread);
+extern void         osRtxThreadReadyPut   (os_thread_t *thread);
+extern void         osRtxThreadDelayTick  (void);
+extern uint32_t    *osRtxThreadRegPtr     (os_thread_t *thread);
+extern void         osRtxThreadSwitch     (os_thread_t *thread);
+extern void         osRtxThreadDispatch   (os_thread_t *thread);
+extern void         osRtxThreadWaitExit   (os_thread_t *thread, uint32_t ret_val, bool_t dispatch);
+extern bool_t       osRtxThreadWaitEnter  (uint8_t state, uint32_t timeout);
+extern void         osRtxThreadStackCheck (void);
+extern bool_t       osRtxThreadStartup    (void);
 
 // Timer Library functions
-extern void osRtxTimerTick   (void);
 extern void osRtxTimerThread (void *argument);
 
 // Mutex Library functions
@@ -105,113 +100,5 @@ extern void osRtxTick_Handler   (void);
 extern void osRtxPendSV_Handler (void);
 extern void osRtxPostProcess    (os_object_t *object);
 
-// Post ISR processing functions
-extern void osRtxThreadPostProcess       (os_thread_t      *thread);
-extern void osRtxEventFlagsPostProcess   (os_event_flags_t *ef);
-extern void osRtxSemaphorePostProcess    (os_semaphore_t   *semaphore);
-extern void osRtxMemoryPoolPostProcess   (os_memory_pool_t *mp);
-extern void osRtxMessageQueuePostProcess (os_message_t     *msg);
-
-
-//  ==== Service Calls ====
-
-// Kernel Service Calls
-extern osStatus_t       svcRtxKernelInitialize       (void);
-extern osStatus_t       svcRtxKernelGetInfo          (osVersion_t *version, char *id_buf, uint32_t id_size);
-extern osKernelState_t  svcRtxKernelGetState         (void);
-extern osStatus_t       svcRtxKernelStart            (void);
-extern int32_t          svcRtxKernelLock             (void);
-extern int32_t          svcRtxKernelUnlock           (void);
-extern int32_t          svcRtxKernelRestoreLock      (int32_t lock);
-extern uint32_t         svcRtxKernelSuspend          (void);
-extern void             svcRtxKernelResume           (uint32_t sleep_ticks);
-extern uint32_t         svcRtxKernelGetTickCount     (void);
-extern uint32_t         svcRtxKernelGetTickFreq      (void);
-extern uint32_t         svcRtxKernelGetSysTimerCount (void);
-extern uint32_t         svcRtxKernelGetSysTimerFreq  (void);
-
-// Thread Service Calls
-extern osThreadId_t     svcRtxThreadNew          (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
-extern const char *     svcRtxThreadGetName      (osThreadId_t thread_id);
-extern osThreadId_t     svcRtxThreadGetId        (void);
-extern osThreadState_t  svcRtxThreadGetState     (osThreadId_t thread_id);
-extern uint32_t         svcRtxThreadGetStackSize (osThreadId_t thread_id);
-extern uint32_t         svcRtxThreadGetStackSpace(osThreadId_t thread_id);
-extern osStatus_t       svcRtxThreadSetPriority  (osThreadId_t thread_id, osPriority_t priority);
-extern osPriority_t     svcRtxThreadGetPriority  (osThreadId_t thread_id);
-extern osStatus_t       svcRtxThreadYield        (void);
-extern osStatus_t       svcRtxThreadSuspend      (osThreadId_t thread_id);
-extern osStatus_t       svcRtxThreadResume       (osThreadId_t thread_id);
-extern osStatus_t       svcRtxThreadDetach       (osThreadId_t thread_id);
-extern osStatus_t       svcRtxThreadJoin         (osThreadId_t thread_id);
-extern void             svcRtxThreadExit         (void);
-extern osStatus_t       svcRtxThreadTerminate    (osThreadId_t thread_id);
-extern uint32_t         svcRtxThreadGetCount     (void);
-extern uint32_t         svcRtxThreadEnumerate    (osThreadId_t *thread_array, uint32_t array_items);
-extern uint32_t         svcRtxThreadFlagsSet     (osThreadId_t thread_id, uint32_t flags);
-extern uint32_t         svcRtxThreadFlagsClear   (uint32_t flags);
-extern uint32_t         svcRtxThreadFlagsGet     (void);
-extern uint32_t         svcRtxThreadFlagsWait    (uint32_t flags, uint32_t options, uint32_t timeout);
-
-// Delay Service Calls
-extern osStatus_t       svcRtxDelay      (uint32_t ticks);
-extern osStatus_t       svcRtxDelayUntil (uint32_t ticks);
-
-// Timer Service Calls
-extern osTimerId_t      svcRtxTimerNew       (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
-extern const char *     svcRtxTimerGetName   (osTimerId_t timer_id);
-extern osStatus_t       svcRtxTimerStart     (osTimerId_t timer_id, uint32_t ticks);
-extern osStatus_t       svcRtxTimerStop      (osTimerId_t timer_id);
-extern uint32_t         svcRtxTimerIsRunning (osTimerId_t timer_id);
-extern osStatus_t       svcRtxTimerDelete    (osTimerId_t timer_id);
-
-// Event Flags Service Calls
-extern osEventFlagsId_t svcRtxEventFlagsNew     (const osEventFlagsAttr_t *attr);
-extern const char *     svcRtxEventFlagsGetName (osEventFlagsId_t ef_id);
-extern uint32_t         svcRtxEventFlagsSet     (osEventFlagsId_t ef_id, uint32_t flags);
-extern uint32_t         svcRtxEventFlagsClear   (osEventFlagsId_t ef_id, uint32_t flags);
-extern uint32_t         svcRtxEventFlagsGet     (osEventFlagsId_t ef_id);
-extern uint32_t         svcRtxEventFlagsWait    (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
-extern osStatus_t       svcRtxEventFlagsDelete  (osEventFlagsId_t ef_id);
-
-// Mutex Service Calls
-extern osMutexId_t      svcRtxMutexNew      (const osMutexAttr_t *attr);
-extern const char *     svcRtxMutexGetName  (osMutexId_t mutex_id);
-extern osStatus_t       svcRtxMutexAcquire  (osMutexId_t mutex_id, uint32_t timeout);
-extern osStatus_t       svcRtxMutexRelease  (osMutexId_t mutex_id);
-extern osThreadId_t     svcRtxMutexGetOwner (osMutexId_t mutex_id);
-extern osStatus_t       svcRtxMutexDelete   (osMutexId_t mutex_id);
-
-// Semaphore Service Calls
-extern osSemaphoreId_t  svcRtxSemaphoreNew     (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr);
-extern const char *     svcRtxSemaphoreGetName (osSemaphoreId_t semaphore_id);
-extern osStatus_t       svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id);
-extern osStatus_t       svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout);
-extern uint32_t         svcRtxSemaphoreGetCount(osSemaphoreId_t semaphore_id);
-extern osStatus_t       svcRtxSemaphoreDelete  (osSemaphoreId_t semaphore_id);
-
-// Memory Pool Service Calls
-extern osMemoryPoolId_t svcRtxMemoryPoolNew          (uint32_t blocks, uint32_t block_size, const osMemoryPoolAttr_t *attr);
-extern const char *     svcRtxMemoryPoolGetName      (osMemoryPoolId_t mp_id);
-extern void *           svcRtxMemoryPoolAlloc        (osMemoryPoolId_t mp_id, uint32_t timeout);
-extern osStatus_t       svcRtxMemoryPoolFree         (osMemoryPoolId_t mp_id, void *block);
-extern uint32_t         svcRtxMemoryPoolGetCapacity  (osMemoryPoolId_t mp_id);
-extern uint32_t         svcRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id);
-extern uint32_t         svcRtxMemoryPoolGetCount     (osMemoryPoolId_t mp_id);
-extern uint32_t         svcRtxMemoryPoolGetSpace     (osMemoryPoolId_t mp_id);
-extern osStatus_t       svcRtxMemoryPoolDelete       (osMemoryPoolId_t mp_id);
-
-// Message Queue Service Calls
-extern osMessageQueueId_t svcRtxMessageQueueNew         (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);
-extern const char *       svcRtxMessageQueueGetName     (osMessageQueueId_t mq_id);
-extern osStatus_t         svcRtxMessageQueuePut         (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t  msg_prio, uint32_t timeout);
-extern osStatus_t         svcRtxMessageQueueGet         (osMessageQueueId_t mq_id,       void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
-extern uint32_t           svcRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id);
-extern uint32_t           svcRtxMessageQueueGetMsgSize  (osMessageQueueId_t mq_id);
-extern uint32_t           svcRtxMessageQueueGetCount    (osMessageQueueId_t mq_id);
-extern uint32_t           svcRtxMessageQueueGetSpace    (osMessageQueueId_t mq_id);
-extern osStatus_t         svcRtxMessageQueueReset       (osMessageQueueId_t mq_id);
-extern osStatus_t         svcRtxMessageQueueDelete      (osMessageQueueId_t mq_id);
-
 
 #endif  // RTX_LIB_H_

+ 10 - 10
CMSIS/RTOS2/RTX/Source/rtx_mempool.c

@@ -152,7 +152,7 @@ osStatus_t osRtxMemoryPoolFree (os_mp_info_t *mp_info, void *block) {
 
 /// Memory Pool post ISR processing.
 /// \param[in]  mp              memory pool object.
-void osRtxMemoryPoolPostProcess (os_memory_pool_t *mp) {
+static void osRtxMemoryPoolPostProcess (os_memory_pool_t *mp) {
   void        *block;
   os_thread_t *thread;
 
@@ -178,7 +178,7 @@ void osRtxMemoryPoolPostProcess (os_memory_pool_t *mp) {
 
 /// Create and Initialize a Memory Pool object.
 /// \note API identical to osMemoryPoolNew
-osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr) {
+static osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr) {
   os_memory_pool_t *mp;
   void             *mp_mem;
   uint32_t          mp_size;
@@ -285,7 +285,7 @@ osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t block_size,
 
 /// Get name of a Memory Pool object.
 /// \note API identical to osMemoryPoolGetName
-const char *svcRtxMemoryPoolGetName (osMemoryPoolId_t mp_id) {
+static const char *svcRtxMemoryPoolGetName (osMemoryPoolId_t mp_id) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
 
   // Check parameters
@@ -307,7 +307,7 @@ const char *svcRtxMemoryPoolGetName (osMemoryPoolId_t mp_id) {
 
 /// Allocate a memory block from a Memory Pool.
 /// \note API identical to osMemoryPoolAlloc
-void *svcRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) {
+static void *svcRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
   void             *block;
 
@@ -347,7 +347,7 @@ void *svcRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) {
 
 /// Return an allocated memory block back to a Memory Pool.
 /// \note API identical to osMemoryPoolFree
-osStatus_t svcRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) {
+static osStatus_t svcRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
   os_thread_t      *thread;
   osStatus_t        status;
@@ -388,7 +388,7 @@ osStatus_t svcRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) {
 
 /// Get maximum number of memory blocks in a Memory Pool.
 /// \note API identical to osMemoryPoolGetCapacity
-uint32_t svcRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id) {
+static uint32_t svcRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
 
   // Check parameters
@@ -410,7 +410,7 @@ uint32_t svcRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id) {
 
 /// Get memory block size in a Memory Pool.
 /// \note API identical to osMemoryPoolGetBlockSize
-uint32_t svcRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id) {
+static uint32_t svcRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
 
   // Check parameters
@@ -432,7 +432,7 @@ uint32_t svcRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id) {
 
 /// Get number of memory blocks used in a Memory Pool.
 /// \note API identical to osMemoryPoolGetCount
-uint32_t svcRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id) {
+static uint32_t svcRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
 
   // Check parameters
@@ -454,7 +454,7 @@ uint32_t svcRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id) {
 
 /// Get number of memory blocks available in a Memory Pool.
 /// \note API identical to osMemoryPoolGetSpace
-uint32_t svcRtxMemoryPoolGetSpace (osMemoryPoolId_t mp_id) {
+static uint32_t svcRtxMemoryPoolGetSpace (osMemoryPoolId_t mp_id) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
 
   // Check parameters
@@ -476,7 +476,7 @@ uint32_t svcRtxMemoryPoolGetSpace (osMemoryPoolId_t mp_id) {
 
 /// Delete a Memory Pool object.
 /// \note API identical to osMemoryPoolDelete
-osStatus_t svcRtxMemoryPoolDelete (osMemoryPoolId_t mp_id) {
+static osStatus_t svcRtxMemoryPoolDelete (osMemoryPoolId_t mp_id) {
   os_memory_pool_t *mp = (os_memory_pool_t *)mp_id;
   os_thread_t      *thread;
 

+ 12 - 12
CMSIS/RTOS2/RTX/Source/rtx_msgqueue.c

@@ -148,11 +148,11 @@ static void MessageQueueRemove (os_message_queue_t *mq, const os_message_t *msg)
 }
 
 
-//  ==== Library functions ====
+//  ==== Post ISR processing ====
 
 /// Message Queue post ISR processing.
 /// \param[in]  msg             message object.
-void osRtxMessageQueuePostProcess (os_message_t *msg) {
+static void osRtxMessageQueuePostProcess (os_message_t *msg) {
   os_message_queue_t *mq;
   os_thread_t        *thread;
   uint32_t           *reg;
@@ -227,7 +227,7 @@ void osRtxMessageQueuePostProcess (os_message_t *msg) {
 
 /// Create and Initialize a Message Queue object.
 /// \note API identical to osMessageQueueNew
-osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) {
+static osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) {
   os_message_queue_t *mq;
   void               *mq_mem;
   uint32_t            mq_size;
@@ -339,7 +339,7 @@ osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t msg_size,
 
 /// Get name of a Message Queue object.
 /// \note API identical to osMessageQueueGetName
-const char *svcRtxMessageQueueGetName (osMessageQueueId_t mq_id) {
+static const char *svcRtxMessageQueueGetName (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
 
   // Check parameters
@@ -361,7 +361,7 @@ const char *svcRtxMessageQueueGetName (osMessageQueueId_t mq_id) {
 
 /// Put a Message into a Queue or timeout if Queue is full.
 /// \note API identical to osMessageQueuePut
-osStatus_t svcRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) {
+static osStatus_t svcRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
   os_message_t       *msg;
   os_thread_t        *thread;
@@ -435,7 +435,7 @@ osStatus_t svcRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr,
 
 /// Get a Message from a Queue or timeout if Queue is empty.
 /// \note API identical to osMessageQueueGet
-osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) {
+static osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
   os_message_t       *msg;
   os_thread_t        *thread;
@@ -514,7 +514,7 @@ osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8
 
 /// Get maximum number of messages in a Message Queue.
 /// \note API identical to osMessageGetCapacity
-uint32_t svcRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id) {
+static uint32_t svcRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
 
   // Check parameters
@@ -536,7 +536,7 @@ uint32_t svcRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id) {
 
 /// Get maximum message size in a Memory Pool.
 /// \note API identical to osMessageGetMsgSize
-uint32_t svcRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id) {
+static uint32_t svcRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
 
   // Check parameters
@@ -558,7 +558,7 @@ uint32_t svcRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id) {
 
 /// Get number of queued messages in a Message Queue.
 /// \note API identical to osMessageGetCount
-uint32_t svcRtxMessageQueueGetCount (osMessageQueueId_t mq_id) {
+static uint32_t svcRtxMessageQueueGetCount (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
 
   // Check parameters
@@ -580,7 +580,7 @@ uint32_t svcRtxMessageQueueGetCount (osMessageQueueId_t mq_id) {
 
 /// Get number of available slots for messages in a Message Queue.
 /// \note API identical to osMessageGetSpace
-uint32_t svcRtxMessageQueueGetSpace (osMessageQueueId_t mq_id) {
+static uint32_t svcRtxMessageQueueGetSpace (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
 
   // Check parameters
@@ -602,7 +602,7 @@ uint32_t svcRtxMessageQueueGetSpace (osMessageQueueId_t mq_id) {
 
 /// Reset a Message Queue to initial empty state.
 /// \note API identical to osMessageQueueReset
-osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) {
+static osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
   os_message_t       *msg;
   os_thread_t        *thread;
@@ -665,7 +665,7 @@ osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) {
 
 /// Delete a Message Queue object.
 /// \note API identical to osMessageQueueDelete
-osStatus_t svcRtxMessageQueueDelete (osMessageQueueId_t mq_id) {
+static osStatus_t svcRtxMessageQueueDelete (osMessageQueueId_t mq_id) {
   os_message_queue_t *mq = (os_message_queue_t *)mq_id;
   os_thread_t        *thread;
 

+ 6 - 6
CMSIS/RTOS2/RTX/Source/rtx_mutex.c

@@ -66,7 +66,7 @@ void osRtxMutexOwnerRelease (os_mutex_t *mutex_list) {
 
 /// Create and Initialize a Mutex object.
 /// \note API identical to osMutexNew
-osMutexId_t svcRtxMutexNew (const osMutexAttr_t *attr) {
+static osMutexId_t svcRtxMutexNew (const osMutexAttr_t *attr) {
   os_mutex_t *mutex;
   uint32_t    attr_bits;
   uint8_t     flags;
@@ -129,7 +129,7 @@ osMutexId_t svcRtxMutexNew (const osMutexAttr_t *attr) {
 
 /// Get name of a Mutex object.
 /// \note API identical to osMutexGetName
-const char *svcRtxMutexGetName (osMutexId_t mutex_id) {
+static const char *svcRtxMutexGetName (osMutexId_t mutex_id) {
   os_mutex_t *mutex = (os_mutex_t *)mutex_id;
 
   // Check parameters
@@ -151,7 +151,7 @@ const char *svcRtxMutexGetName (osMutexId_t mutex_id) {
 
 /// Acquire a Mutex or timeout if it is locked.
 /// \note API identical to osMutexAcquire
-osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) {
+static osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) {
   os_mutex_t  *mutex = (os_mutex_t *)mutex_id;
   os_thread_t *runnig_thread;
   osStatus_t   status;
@@ -231,7 +231,7 @@ osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) {
 
 /// Release a Mutex that was acquired by osMutexAcquire.
 /// \note API identical to osMutexRelease
-osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) {
+static osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) {
   os_mutex_t  *mutex = (os_mutex_t *)mutex_id;
   os_mutex_t  *mutex0;
   os_thread_t *thread;
@@ -323,7 +323,7 @@ osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) {
 
 /// Get Thread which owns a Mutex object.
 /// \note API identical to osMutexGetOwner
-osThreadId_t svcRtxMutexGetOwner (osMutexId_t mutex_id) {
+static osThreadId_t svcRtxMutexGetOwner (osMutexId_t mutex_id) {
   os_mutex_t *mutex = (os_mutex_t *)mutex_id;
 
   // Check parameters
@@ -351,7 +351,7 @@ osThreadId_t svcRtxMutexGetOwner (osMutexId_t mutex_id) {
 
 /// Delete a Mutex object.
 /// \note API identical to osMutexDelete
-osStatus_t svcRtxMutexDelete (osMutexId_t mutex_id) {
+static osStatus_t svcRtxMutexDelete (osMutexId_t mutex_id) {
   os_mutex_t  *mutex = (os_mutex_t *)mutex_id;
   os_mutex_t  *mutex0;
   os_thread_t *thread;

+ 8 - 8
CMSIS/RTOS2/RTX/Source/rtx_semaphore.c

@@ -95,11 +95,11 @@ static uint32_t SemaphoreTokenIncrement (os_semaphore_t *semaphore) {
 }
 
 
-//  ==== Library functions ====
+//  ==== Post ISR processing ====
 
 /// Semaphore post ISR processing.
 /// \param[in]  semaphore       semaphore object.
-void osRtxSemaphorePostProcess (os_semaphore_t *semaphore) {
+static void osRtxSemaphorePostProcess (os_semaphore_t *semaphore) {
   os_thread_t *thread;
 
   if (semaphore->state == osRtxObjectInactive) {
@@ -123,7 +123,7 @@ void osRtxSemaphorePostProcess (os_semaphore_t *semaphore) {
 
 /// Create and Initialize a Semaphore object.
 /// \note API identical to osSemaphoreNew
-osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) {
+static osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) {
   os_semaphore_t *semaphore;
   uint8_t         flags;
   const char     *name;
@@ -189,7 +189,7 @@ osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count,
 
 /// Get name of a Semaphore object.
 /// \note API identical to osSemaphoreGetName
-const char *svcRtxSemaphoreGetName (osSemaphoreId_t semaphore_id) {
+static const char *svcRtxSemaphoreGetName (osSemaphoreId_t semaphore_id) {
   os_semaphore_t *semaphore = (os_semaphore_t *)semaphore_id;
 
   // Check parameters
@@ -211,7 +211,7 @@ const char *svcRtxSemaphoreGetName (osSemaphoreId_t semaphore_id) {
 
 /// Acquire a Semaphore token or timeout if no tokens are available.
 /// \note API identical to osSemaphoreAcquire
-osStatus_t svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) {
+static osStatus_t svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) {
   os_semaphore_t *semaphore = (os_semaphore_t *)semaphore_id;
   osStatus_t      status;
 
@@ -253,7 +253,7 @@ osStatus_t svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeou
 
 /// Release a Semaphore token that was acquired by osSemaphoreAcquire.
 /// \note API identical to osSemaphoreRelease
-osStatus_t svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) {
+static osStatus_t svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) {
   os_semaphore_t *semaphore = (os_semaphore_t *)semaphore_id;
   os_thread_t    *thread;
   osStatus_t      status;
@@ -294,7 +294,7 @@ osStatus_t svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) {
 
 /// Get current Semaphore token count.
 /// \note API identical to osSemaphoreGetCount
-uint32_t svcRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id) {
+static uint32_t svcRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id) {
   os_semaphore_t *semaphore = (os_semaphore_t *)semaphore_id;
 
   // Check parameters
@@ -316,7 +316,7 @@ uint32_t svcRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id) {
 
 /// Delete a Semaphore object.
 /// \note API identical to osSemaphoreDelete
-osStatus_t svcRtxSemaphoreDelete (osSemaphoreId_t semaphore_id) {
+static osStatus_t svcRtxSemaphoreDelete (osSemaphoreId_t semaphore_id) {
   os_semaphore_t *semaphore = (os_semaphore_t *)semaphore_id;
   os_thread_t    *thread;
 

+ 65 - 27
CMSIS/RTOS2/RTX/Source/rtx_thread.c

@@ -175,7 +175,8 @@ os_thread_t *osRtxThreadListGet (volatile os_object_t *object) {
 
 /// Retrieve Thread list root.
 /// \param[in]  thread          thread object.
-void *osRtxThreadListRoot (os_thread_t *thread) {
+#ifndef EVR_RTX_DISABLE
+static void *osRtxThreadListRoot (os_thread_t *thread) {
   os_thread_t *thread0;
 
   thread0 = thread;
@@ -184,6 +185,7 @@ void *osRtxThreadListRoot (os_thread_t *thread) {
   }
   return thread0;
 }
+#endif
 
 /// Re-sort a Thread in linked Object list by Priority (Highest at Head).
 /// \param[in]  thread          thread object.
@@ -219,7 +221,7 @@ void osRtxThreadListRemove (os_thread_t *thread) {
 
 /// Unlink a Thread from specified linked list.
 /// \param[in]  thread          thread object.
-void osRtxThreadListUnlink (os_thread_t **thread_list, os_thread_t *thread) {
+static void osRtxThreadListUnlink (os_thread_t **thread_list, os_thread_t *thread) {
 
   if (thread->thread_next != NULL) {
     thread->thread_next->thread_prev = thread->thread_prev;
@@ -243,7 +245,7 @@ void osRtxThreadReadyPut (os_thread_t *thread) {
 /// Insert a Thread into the Delay list sorted by Delay (Lowest at Head).
 /// \param[in]  thread          thread object.
 /// \param[in]  delay           delay value.
-void osRtxThreadDelayInsert (os_thread_t *thread, uint32_t delay) {
+static void osRtxThreadDelayInsert (os_thread_t *thread, uint32_t delay) {
   os_thread_t *prev, *next;
 
   if (delay == osWaitForever) {
@@ -289,7 +291,7 @@ void osRtxThreadDelayInsert (os_thread_t *thread, uint32_t delay) {
 
 /// Remove a Thread from the Delay list.
 /// \param[in]  thread          thread object.
-void osRtxThreadDelayRemove (os_thread_t *thread) {
+static void osRtxThreadDelayRemove (os_thread_t *thread) {
 
   if (thread->delay == osWaitForever) {
     if ((thread->delay_prev != NULL) || (osRtxInfo.thread.wait_list == thread)) {
@@ -381,7 +383,7 @@ uint32_t *osRtxThreadRegPtr (os_thread_t *thread) {
 
 /// Block running Thread execution and register it as Ready to Run.
 /// \param[in]  thread          running thread object.
-void osRtxThreadBlock (os_thread_t *thread) {
+static void osRtxThreadBlock (os_thread_t *thread) {
   os_thread_t *prev, *next;
   int32_t      priority;
 
@@ -521,9 +523,12 @@ __WEAK void osRtxThreadStackCheck (void) {
   }
 }
 
+
+//  ==== Post ISR processing ====
+
 /// Thread post ISR processing.
 /// \param[in]  thread          thread object.
-void osRtxThreadPostProcess (os_thread_t *thread) {
+static void osRtxThreadPostProcess (os_thread_t *thread) {
   uint32_t thread_flags;
 
   if ((thread->state == osRtxThreadInactive) ||
@@ -546,7 +551,7 @@ void osRtxThreadPostProcess (os_thread_t *thread) {
 
 /// Create a thread and add it to Active Threads.
 /// \note API identical to osThreadNew
-osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
+static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
   os_thread_t  *thread;
   uint32_t      attr_bits;
   void         *stack_mem;
@@ -753,7 +758,7 @@ osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThrea
 
 /// Get name of a thread.
 /// \note API identical to osThreadGetName
-const char *svcRtxThreadGetName (osThreadId_t thread_id) {
+static const char *svcRtxThreadGetName (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -775,7 +780,7 @@ const char *svcRtxThreadGetName (osThreadId_t thread_id) {
 
 /// Return the thread ID of the current running thread.
 /// \note API identical to osThreadGetId
-osThreadId_t svcRtxThreadGetId (void) {
+static osThreadId_t svcRtxThreadGetId (void) {
   os_thread_t *thread;
 
   thread = osRtxThreadGetRunning();
@@ -785,7 +790,7 @@ osThreadId_t svcRtxThreadGetId (void) {
 
 /// Get current thread state of a thread.
 /// \note API identical to osThreadGetState
-osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id) {
+static osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -801,7 +806,7 @@ osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id) {
 
 /// Get stack size of a thread.
 /// \note API identical to osThreadGetStackSize
-uint32_t svcRtxThreadGetStackSize (osThreadId_t thread_id) {
+static uint32_t svcRtxThreadGetStackSize (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -823,7 +828,7 @@ uint32_t svcRtxThreadGetStackSize (osThreadId_t thread_id) {
 
 /// Get available stack space of a thread based on stack watermark recording during execution.
 /// \note API identical to osThreadGetStackSpace
-uint32_t svcRtxThreadGetStackSpace (osThreadId_t thread_id) {
+static uint32_t svcRtxThreadGetStackSpace (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
   uint32_t    *stack;
   uint32_t     space;
@@ -863,7 +868,7 @@ uint32_t svcRtxThreadGetStackSpace (osThreadId_t thread_id) {
 
 /// Change priority of a thread.
 /// \note API identical to osThreadSetPriority
-osStatus_t svcRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) {
+static osStatus_t svcRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -892,7 +897,7 @@ osStatus_t svcRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t priorit
 
 /// Get current priority of a thread.
 /// \note API identical to osThreadGetPriority
-osPriority_t svcRtxThreadGetPriority (osThreadId_t thread_id) {
+static osPriority_t svcRtxThreadGetPriority (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -915,7 +920,7 @@ osPriority_t svcRtxThreadGetPriority (osThreadId_t thread_id) {
 
 /// Pass control to next thread that is in state READY.
 /// \note API identical to osThreadYield
-osStatus_t svcRtxThreadYield (void) {
+static osStatus_t svcRtxThreadYield (void) {
   uint8_t      kernel_state;
   os_thread_t *thread_running;
   os_thread_t *thread_ready;
@@ -937,7 +942,7 @@ osStatus_t svcRtxThreadYield (void) {
 
 /// Suspend execution of a thread.
 /// \note API identical to osThreadSuspend
-osStatus_t svcRtxThreadSuspend (osThreadId_t thread_id) {
+static osStatus_t svcRtxThreadSuspend (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
   osStatus_t   status;
 
@@ -994,7 +999,7 @@ osStatus_t svcRtxThreadSuspend (osThreadId_t thread_id) {
 
 /// Resume execution of a thread.
 /// \note API identical to osThreadResume
-osStatus_t svcRtxThreadResume (osThreadId_t thread_id) {
+static osStatus_t svcRtxThreadResume (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -1054,7 +1059,7 @@ static void osRtxThreadFree (os_thread_t *thread) {
 
 /// Detach a thread (thread storage can be reclaimed when thread terminates).
 /// \note API identical to osThreadDetach
-osStatus_t svcRtxThreadDetach (osThreadId_t thread_id) {
+static osStatus_t svcRtxThreadDetach (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
 
   // Check parameters
@@ -1089,7 +1094,7 @@ osStatus_t svcRtxThreadDetach (osThreadId_t thread_id) {
 
 /// Wait for specified thread to terminate.
 /// \note API identical to osThreadJoin
-osStatus_t svcRtxThreadJoin (osThreadId_t thread_id) {
+static osStatus_t svcRtxThreadJoin (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
   osStatus_t   status;
 
@@ -1133,7 +1138,7 @@ osStatus_t svcRtxThreadJoin (osThreadId_t thread_id) {
 
 /// Terminate execution of current running thread.
 /// \note API identical to osThreadExit
-void svcRtxThreadExit (void) {
+static void svcRtxThreadExit (void) {
   os_thread_t *thread;
 
   // Check running thread
@@ -1180,7 +1185,7 @@ void svcRtxThreadExit (void) {
 
 /// Terminate execution of a thread.
 /// \note API identical to osThreadTerminate
-osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
+static osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
   os_thread_t *thread = (os_thread_t *)thread_id;
   osStatus_t   status;
 
@@ -1258,7 +1263,7 @@ osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
 
 /// Get number of active threads.
 /// \note API identical to osThreadGetCount
-uint32_t svcRtxThreadGetCount (void) {
+static uint32_t svcRtxThreadGetCount (void) {
   os_thread_t *thread;
   uint32_t     count;
 
@@ -1284,7 +1289,7 @@ uint32_t svcRtxThreadGetCount (void) {
 
 /// Enumerate active threads.
 /// \note API identical to osThreadEnumerate
-uint32_t svcRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items) {
+static uint32_t svcRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items) {
   os_thread_t *thread;
   uint32_t     count;
 
@@ -1323,7 +1328,7 @@ uint32_t svcRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items
 
 /// Set the specified Thread Flags of a thread.
 /// \note API identical to osThreadFlagsSet
-uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
+static uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
   os_thread_t *thread = (os_thread_t *)thread_id;
   uint32_t     thread_flags;
   uint32_t     thread_flags0;
@@ -1366,7 +1371,7 @@ uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
 
 /// Clear the specified Thread Flags of current running thread.
 /// \note API identical to osThreadFlagsClear
-uint32_t svcRtxThreadFlagsClear (uint32_t flags) {
+static uint32_t svcRtxThreadFlagsClear (uint32_t flags) {
   os_thread_t *thread;
   uint32_t     thread_flags;
 
@@ -1399,7 +1404,7 @@ uint32_t svcRtxThreadFlagsClear (uint32_t flags) {
 
 /// Get the current Thread Flags of current running thread.
 /// \note API identical to osThreadFlagsGet
-uint32_t svcRtxThreadFlagsGet (void) {
+static uint32_t svcRtxThreadFlagsGet (void) {
   os_thread_t *thread;
 
   thread = osRtxThreadGetRunning();
@@ -1422,7 +1427,7 @@ uint32_t svcRtxThreadFlagsGet (void) {
 
 /// Wait for one or more Thread Flags of the current running thread to become signaled.
 /// \note API identical to osThreadFlagsWait
-uint32_t svcRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout) {
+static uint32_t svcRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout) {
   os_thread_t *thread;
   uint32_t     thread_flags;
 
@@ -1522,6 +1527,39 @@ uint32_t isrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
 }
 
 
+//  ==== Library functions ====
+
+/// Thread startup (Idle and Timer Thread).
+/// \return true - success, false - failure.
+bool_t osRtxThreadStartup (void) {
+  bool_t ret = TRUE;
+
+  // Create Idle Thread
+  if (osRtxInfo.thread.idle == NULL) {
+    osRtxInfo.thread.idle = osRtxThreadId(
+      svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr)
+    );
+    if (osRtxInfo.thread.idle == NULL) {
+      ret = FALSE;
+    }
+  }
+
+  // Create Timer Thread
+  if (osRtxConfig.timer_mq_mcnt != 0U) {
+    if (osRtxInfo.timer.thread == NULL) {
+      osRtxInfo.timer.thread = osRtxThreadId(
+        svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr)
+      );
+      if (osRtxInfo.timer.thread == NULL) {
+        ret = FALSE;
+      }
+    }
+  }
+
+  return ret;
+}
+
+
 //  ==== Public API ====
 
 /// Create a thread and add it to Active Threads.

+ 7 - 7
CMSIS/RTOS2/RTX/Source/rtx_timer.c

@@ -84,7 +84,7 @@ static void TimerUnlink (const os_timer_t *timer) {
 //  ==== Library functions ====
 
 /// Timer Tick (called each SysTick).
-void osRtxTimerTick (void) {
+static void osRtxTimerTick (void) {
   os_timer_t *timer;
   osStatus_t  status;
 
@@ -133,7 +133,7 @@ __WEAK void osRtxTimerThread (void *argument) {
 
 /// Create and Initialize a timer.
 /// \note API identical to osTimerNew
-osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) {
+static osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) {
   os_timer_t *timer;
   uint8_t     flags;
   const char *name;
@@ -200,7 +200,7 @@ osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argume
 
 /// Get name of a timer.
 /// \note API identical to osTimerGetName
-const char *svcRtxTimerGetName (osTimerId_t timer_id) {
+static const char *svcRtxTimerGetName (osTimerId_t timer_id) {
   os_timer_t *timer = (os_timer_t *)timer_id;
 
   // Check parameters
@@ -222,7 +222,7 @@ const char *svcRtxTimerGetName (osTimerId_t timer_id) {
 
 /// Start or restart a timer.
 /// \note API identical to osTimerStart
-osStatus_t svcRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) {
+static osStatus_t svcRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) {
   os_timer_t *timer = (os_timer_t *)timer_id;
 
   // Check parameters
@@ -257,7 +257,7 @@ osStatus_t svcRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) {
 
 /// Stop a timer.
 /// \note API identical to osTimerStop
-osStatus_t svcRtxTimerStop (osTimerId_t timer_id) {
+static osStatus_t svcRtxTimerStop (osTimerId_t timer_id) {
   os_timer_t *timer = (os_timer_t *)timer_id;
 
   // Check parameters
@@ -283,7 +283,7 @@ osStatus_t svcRtxTimerStop (osTimerId_t timer_id) {
 
 /// Check if a timer is running.
 /// \note API identical to osTimerIsRunning
-uint32_t svcRtxTimerIsRunning (osTimerId_t timer_id) {
+static uint32_t svcRtxTimerIsRunning (osTimerId_t timer_id) {
   os_timer_t *timer = (os_timer_t *)timer_id;
   uint32_t    is_running;
 
@@ -307,7 +307,7 @@ uint32_t svcRtxTimerIsRunning (osTimerId_t timer_id) {
 
 /// Delete a timer.
 /// \note API identical to osTimerDelete
-osStatus_t svcRtxTimerDelete (osTimerId_t timer_id) {
+static osStatus_t svcRtxTimerDelete (osTimerId_t timer_id) {
   os_timer_t *timer = (os_timer_t *)timer_id;
 
   // Check parameters