lib: cmsis_rtos_v1: Minor refactor of CMSIS implemetation
Add few missing NULL checks to avoid crash. Also, minor refactor of signal code and disable osFeature_Wait to signify osWait function not implemented. Signed-off-by: Praful Swarnakar <praful.swarnakar@intel.com>
This commit is contained in:
parent
41a0fb937e
commit
bbad5c3fad
3 changed files with 13 additions and 11 deletions
|
@ -61,7 +61,7 @@
|
||||||
#define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available
|
#define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available
|
||||||
#define osFeature_Signals 8 ///< maximum number of Signal Flags available per thread
|
#define osFeature_Signals 8 ///< maximum number of Signal Flags available per thread
|
||||||
#define osFeature_Semaphore 30 ///< maximum count for \ref osSemaphoreCreate function
|
#define osFeature_Semaphore 30 ///< maximum count for \ref osSemaphoreCreate function
|
||||||
#define osFeature_Wait 1 ///< osWait function: 1=available, 0=not available
|
#define osFeature_Wait 0 ///< osWait function: 1=available, 0=not available
|
||||||
#define osFeature_SysTick 1 ///< osKernelSysTick functions: 1=available, 0=not available
|
#define osFeature_SysTick 1 ///< osKernelSysTick functions: 1=available, 0=not available
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -20,15 +20,16 @@ void *k_thread_other_custom_data_get(struct k_thread *thread_id)
|
||||||
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
|
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
|
||||||
{
|
{
|
||||||
int sig, key;
|
int sig, key;
|
||||||
osThreadDef_t *thread_def =
|
|
||||||
(osThreadDef_t *)k_thread_other_custom_data_get(
|
|
||||||
(struct k_thread *)thread_id);
|
|
||||||
|
|
||||||
if (_is_in_isr() || (thread_id == NULL) ||
|
if ((thread_id == NULL) || (!signals) ||
|
||||||
(signals >= (1 << (osFeature_Signals + 1)))) {
|
(signals >= (1 << (osFeature_Signals + 1)))) {
|
||||||
return 0x80000000;
|
return 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osThreadDef_t *thread_def =
|
||||||
|
(osThreadDef_t *)k_thread_other_custom_data_get(
|
||||||
|
(struct k_thread *)thread_id);
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
sig = thread_def->signal_results;
|
sig = thread_def->signal_results;
|
||||||
thread_def->signal_results |= signals;
|
thread_def->signal_results |= signals;
|
||||||
|
@ -45,15 +46,16 @@ int32_t osSignalSet(osThreadId thread_id, int32_t signals)
|
||||||
int32_t osSignalClear(osThreadId thread_id, int32_t signals)
|
int32_t osSignalClear(osThreadId thread_id, int32_t signals)
|
||||||
{
|
{
|
||||||
int sig, key;
|
int sig, key;
|
||||||
osThreadDef_t *thread_def =
|
|
||||||
(osThreadDef_t *)k_thread_other_custom_data_get(
|
|
||||||
(struct k_thread *)thread_id);
|
|
||||||
|
|
||||||
if (_is_in_isr() || (thread_id == NULL) ||
|
if (_is_in_isr() || (thread_id == NULL) || (!signals) ||
|
||||||
(signals >= (1 << (osFeature_Signals + 1)))) {
|
(signals >= (1 << (osFeature_Signals + 1)))) {
|
||||||
return 0x80000000;
|
return 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osThreadDef_t *thread_def =
|
||||||
|
(osThreadDef_t *)k_thread_other_custom_data_get(
|
||||||
|
(struct k_thread *)thread_id);
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
sig = thread_def->signal_results;
|
sig = thread_def->signal_results;
|
||||||
thread_def->signal_results &= ~(signals);
|
thread_def->signal_results &= ~(signals);
|
||||||
|
|
|
@ -48,7 +48,7 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *arg)
|
||||||
__ASSERT(thread_def->stacksize <= CONFIG_CMSIS_THREAD_MAX_STACK_SIZE,
|
__ASSERT(thread_def->stacksize <= CONFIG_CMSIS_THREAD_MAX_STACK_SIZE,
|
||||||
"invalid stack size\n");
|
"invalid stack size\n");
|
||||||
|
|
||||||
if (thread_def->instances == 0) {
|
if ((thread_def == NULL) || (thread_def->instances == 0)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ osPriority osThreadGetPriority(osThreadId thread_id)
|
||||||
k_tid_t thread = (k_tid_t)thread_id;
|
k_tid_t thread = (k_tid_t)thread_id;
|
||||||
u32_t priority;
|
u32_t priority;
|
||||||
|
|
||||||
if (_is_in_isr()) {
|
if ((thread_id == NULL) || (_is_in_isr())) {
|
||||||
return osPriorityError;
|
return osPriorityError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue