unified: Eliminate support for dynamic timers

Gets rid of official support for dynamic timer allocation
in the unified kernel, since users can easily define and
initialize timers at any time. Legacy support for dynamic
timers is maintained for backwards compatibility reasons
for the time being ...

Change-Id: I12b3e25914fe11e3886065bee4e96fb96f59b299
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2016-10-07 15:54:11 -05:00 committed by Peter Mitsis
commit 1d07bd1bff
4 changed files with 19 additions and 15 deletions

View file

@ -290,11 +290,6 @@ struct k_timer {
extern void k_timer_init(struct k_timer *timer, void *data);
#if (CONFIG_NUM_DYNAMIC_TIMERS > 0)
extern struct k_timer *k_timer_alloc(void);
extern void k_timer_free(struct k_timer *timer);
#endif
extern void k_timer_start(struct k_timer *timer,
int32_t duration, int32_t period,
void (*handler)(void *), void *handler_arg,
@ -355,8 +350,6 @@ extern int64_t k_uptime_delta(int64_t *reftime);
extern uint32_t k_uptime_delta_32(int64_t *reftime);
extern bool k_timer_pool_is_empty(void);
extern uint32_t k_cycle_get_32(void);
/**

View file

@ -655,8 +655,14 @@ static inline int nano_stack_pop(struct nano_stack *stack, uint32_t *data,
#define ktimer_t struct k_timer *
#define task_timer_alloc k_timer_alloc
#define task_timer_free k_timer_free
#if (CONFIG_NUM_DYNAMIC_TIMERS > 0)
extern struct k_timer *_k_timer_alloc(void);
#define task_timer_alloc _k_timer_alloc
extern void _k_timer_free(struct k_timer *timer);
#define task_timer_free _k_timer_free
#endif
extern void task_timer_start(ktimer_t timer, int32_t duration,
int32_t period, ksem_t sema);

View file

@ -83,6 +83,8 @@ void k_timer_init(struct k_timer *timer, void *data)
#if (CONFIG_NUM_DYNAMIC_TIMERS > 0)
/* Implements legacy API support for dynamic timers */
static struct k_timer _dynamic_timers[CONFIG_NUM_DYNAMIC_TIMERS];
static sys_dlist_t _timer_pool;
@ -110,7 +112,7 @@ static int init_dyamic_timers(struct device *dev)
*
* @return pointer to the new timer structure
*/
struct k_timer *k_timer_alloc(void)
struct k_timer *_k_timer_alloc(void)
{
k_sched_lock();
@ -133,7 +135,7 @@ struct k_timer *k_timer_alloc(void)
*
* @return N/A
*/
void k_timer_free(struct k_timer *timer)
void _k_timer_free(struct k_timer *timer)
{
k_timer_stop(timer);
k_sched_lock();
@ -147,7 +149,7 @@ void k_timer_free(struct k_timer *timer)
*
* @return true if the timer pool is empty, false otherwise
*/
bool k_timer_pool_is_empty(void)
bool _k_timer_pool_is_empty(void)
{
k_sched_lock();

View file

@ -31,9 +31,12 @@ This module tests the following microkernel timer routines:
#include "fifo_timeout.c"
#ifndef CONFIG_KERNEL_V2
#ifdef CONFIG_KERNEL_V2
extern bool _k_timer_pool_is_empty(void); /* For white box testing only */
#define timer_pool_is_empty _k_timer_pool_is_empty
#else
extern struct nano_lifo _k_timer_free; /* For white box testing only */
static inline bool k_timer_pool_is_empty(void)
static inline bool timer_pool_is_empty(void)
{
return (bool)(_k_timer_free.list == NULL);
}
@ -267,7 +270,7 @@ int testLowTimerGet(void)
/* Whitebox test to ensure that all timers were allocated. */
if (!k_timer_pool_is_empty()) {
if (!timer_pool_is_empty()) {
TC_ERROR("** Not all timers were allocated!\n");
}