lib/cmsis_rtos_v2: Update to newer timeout API
Mostly simple. Note that the CMSIS RTOS2 API specifies timeout values in system ticks instead of milliseconds, so the conversions here are able to elide a conversion that the original code had to do. That's a good thing, but does mean that in practice runtime behavior will not be 1:1 identical. Also note that the switch away from legacy timeouts involved a change to 64 bit timeouts by default, which pushed tests/portability/cmsis_rtos_v2 over the limit on qemu_xtensa. Unfortunately CMSIS stacks have a fixed limit we can't increase, so I turned off 64 bit timeouts (CMSIS apps won't need them by definition anyway -- their API is 32 bit). Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
4d417034e9
commit
7e3d43b558
|
@ -9,7 +9,6 @@ config CMSIS_RTOS_V2
|
|||
depends on THREAD_MONITOR
|
||||
depends on INIT_STACKS
|
||||
depends on NUM_PREEMPT_PRIORITIES >= 56
|
||||
select LEGACY_TIMEOUT_API
|
||||
help
|
||||
This enables CMSIS RTOS v2 API support. This is an OS-integration
|
||||
layer which allows applications using CMSIS RTOS V2 APIs to build
|
||||
|
|
|
@ -133,7 +133,8 @@ uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags,
|
|||
retval = k_poll(&events->poll_event, 1, K_FOREVER);
|
||||
break;
|
||||
default:
|
||||
retval = k_poll(&events->poll_event, 1, timeout_ms);
|
||||
retval = k_poll(&events->poll_event, 1,
|
||||
K_MSEC(timeout_ms));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,6 @@
|
|||
#include <kernel.h>
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
/* Currently the timing implementations for timeouts and osDelay
|
||||
* assume that the arguments are in Zephyr ticks, even though ARM
|
||||
* documentation and at least some of our test code assume they are
|
||||
* milliseconds. They must match for now.
|
||||
*/
|
||||
BUILD_ASSERT(CONFIG_SYS_CLOCK_TICKS_PER_SEC == 1000);
|
||||
|
||||
extern u32_t z_tick_get_32(void);
|
||||
|
||||
/**
|
||||
|
@ -132,7 +125,7 @@ osStatus_t osDelay(uint32_t ticks)
|
|||
return osErrorISR;
|
||||
}
|
||||
|
||||
k_sleep(k_ticks_to_ms_floor64(ticks));
|
||||
k_sleep(K_TICKS(ticks));
|
||||
|
||||
return osOK;
|
||||
}
|
||||
|
@ -149,7 +142,7 @@ osStatus_t osDelayUntil(uint32_t ticks)
|
|||
}
|
||||
|
||||
ticks_elapsed = osKernelGetTickCount();
|
||||
k_sleep(k_ticks_to_ms_floor64(ticks - ticks_elapsed));
|
||||
k_sleep(K_TICKS(ticks - ticks_elapsed));
|
||||
|
||||
return osOK;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ void *osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout)
|
|||
} else {
|
||||
retval = k_mem_slab_alloc(
|
||||
(struct k_mem_slab *)(&mslab->z_mslab),
|
||||
(void **)&ptr, k_ticks_to_ms_floor64(timeout));
|
||||
(void **)&ptr, K_TICKS(timeout));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
|
|
@ -104,7 +104,7 @@ osStatus_t osMessageQueuePut(osMessageQueueId_t msgq_id, const void *msg_ptr,
|
|||
retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr, K_FOREVER);
|
||||
} else {
|
||||
retval = k_msgq_put(&msgq->z_msgq, (void *)msg_ptr,
|
||||
k_ticks_to_ms_floor64(timeout));
|
||||
K_TICKS(timeout));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
@ -142,7 +142,7 @@ osStatus_t osMessageQueueGet(osMessageQueueId_t msgq_id, void *msg_ptr,
|
|||
retval = k_msgq_get(&msgq->z_msgq, msg_ptr, K_FOREVER);
|
||||
} else {
|
||||
retval = k_msgq_get(&msgq->z_msgq, msg_ptr,
|
||||
k_ticks_to_ms_floor64(timeout));
|
||||
K_TICKS(timeout));
|
||||
}
|
||||
|
||||
if (retval == 0) {
|
||||
|
|
|
@ -94,7 +94,7 @@ osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
|
|||
status = k_mutex_lock(&mutex->z_mutex, K_NO_WAIT);
|
||||
} else {
|
||||
status = k_mutex_lock(&mutex->z_mutex,
|
||||
k_ticks_to_ms_floor64(timeout));
|
||||
K_TICKS(timeout));
|
||||
}
|
||||
|
||||
if (status == -EBUSY) {
|
||||
|
|
|
@ -77,7 +77,7 @@ osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout)
|
|||
status = k_sem_take(&semaphore->z_semaphore, K_NO_WAIT);
|
||||
} else {
|
||||
status = k_sem_take(&semaphore->z_semaphore,
|
||||
k_ticks_to_ms_floor64(timeout));
|
||||
K_TICKS(timeout));
|
||||
}
|
||||
|
||||
if (status == -EBUSY) {
|
||||
|
|
|
@ -117,7 +117,8 @@ uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout)
|
|||
retval = k_poll(&tid->poll_event, 1, K_FOREVER);
|
||||
break;
|
||||
default:
|
||||
retval = k_poll(&tid->poll_event, 1, timeout_ms);
|
||||
retval = k_poll(&tid->poll_event, 1,
|
||||
K_MSEC(timeout_ms));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type,
|
|||
osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks)
|
||||
{
|
||||
struct cv2_timer *timer = (struct cv2_timer *)timer_id;
|
||||
u32_t millisec = k_ticks_to_ms_floor64(ticks);
|
||||
|
||||
if (timer == NULL) {
|
||||
return osErrorParameter;
|
||||
|
@ -91,9 +90,10 @@ osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks)
|
|||
}
|
||||
|
||||
if (timer->type == osTimerOnce) {
|
||||
k_timer_start(&timer->z_timer, millisec, K_NO_WAIT);
|
||||
k_timer_start(&timer->z_timer, K_TICKS(ticks), K_NO_WAIT);
|
||||
} else if (timer->type == osTimerPeriodic) {
|
||||
k_timer_start(&timer->z_timer, millisec, millisec);
|
||||
k_timer_start(&timer->z_timer,
|
||||
K_TICKS(ticks), K_TICKS(ticks));
|
||||
}
|
||||
|
||||
timer->status = ACTIVE;
|
||||
|
|
|
@ -13,6 +13,4 @@ CONFIG_SCHED_SCALABLE=y
|
|||
CONFIG_CMSIS_V2_MEM_SLAB_MAX_DYNAMIC_SIZE=128
|
||||
CONFIG_CMSIS_V2_THREAD_MAX_COUNT=23
|
||||
CONFIG_CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT=10
|
||||
|
||||
# The Zephyr CMSIS emulation assumes that ticks are ms, currently
|
||||
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
|
||||
CONFIG_TIMEOUT_64BIT=n
|
||||
|
|
Loading…
Reference in a new issue