unified: Invoke kernel object initialization with SYS_INIT macro

Kernel object initialization needs to follow the common initialization
scheme.

Change-Id: I6693678ed7c4975b3c588061013fa0c5d24968c3
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
This commit is contained in:
Dmitriy Korovkin 2016-09-09 11:24:27 -04:00 committed by Benjamin Walsh
commit 284042d746
7 changed files with 30 additions and 32 deletions

View file

@ -373,12 +373,6 @@ extern bool k_timer_pool_is_empty(void);
extern uint32_t k_cycle_get_32(void);
#if (CONFIG_NUM_DYNAMIC_TIMERS > 0)
extern void _k_dyamic_timer_init(void);
#else
#define _k_dyamic_timer_init()
#endif
/**
* data transfers (basic)
*/
@ -899,12 +893,6 @@ struct k_mbox {
struct k_mbox name = \
K_MBOX_INITIALIZER(name) \
#if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0)
extern void _k_mbox_init(void);
#else
#define _k_mbox_init()
#endif
extern void k_mbox_init(struct k_mbox *mbox);
extern int k_mbox_put(struct k_mbox *mbox, struct k_mbox_msg *msg,
@ -954,12 +942,6 @@ struct k_pipe {
#define K_PIPE_SIZE(buffer_size) (sizeof(struct k_pipe) + buffer_size)
#if (CONFIG_NUM_PIPE_ASYNC_MSGS > 0)
extern void _k_pipes_init(void);
#else
#define _k_pipes_init() do { } while (0)
#endif
/**
* @brief Runtime initialization of a pipe
*
@ -1078,8 +1060,6 @@ struct k_mem_map {
#define K_MEM_MAP_SIZE(map_num_blocks, map_block_size) \
(sizeof(struct k_mem_map) + ((map_num_blocks) * (map_block_size)))
extern void _k_mem_map_init(void);
extern void k_mem_map_init(struct k_mem_map *map, int num_blocks,
int block_size, void *buffer);
extern int k_mem_map_alloc(struct k_mem_map *map, void **mem, int32_t timeout);

View file

@ -270,13 +270,6 @@ static void nano_init(struct tcs *dummy_thread)
/* perform any architecture-specific initialization */
nanoArchInit();
/* handle any kernel objects that require run-time initialization */
_k_mem_map_init();
_k_mbox_init();
_k_dyamic_timer_init();
_k_pipes_init();
}
#ifdef CONFIG_STACK_CANARIES

View file

@ -26,6 +26,7 @@
#include <string.h>
#include <wait_q.h>
#include <misc/dlist.h>
#include <init.h>
#if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0)
@ -55,16 +56,21 @@ K_STACK_DEFINE(async_msg_free, CONFIG_NUM_MBOX_ASYNC_MSGS);
*
* @return N/A
*/
void _k_mbox_init(void)
static int init_mbox_module(struct device *dev)
{
ARG_UNUSED(dev);
int i;
for (i = 0; i < CONFIG_NUM_MBOX_ASYNC_MSGS; i++) {
async_msg[i].thread.flags = K_DUMMY;
k_stack_push(&async_msg_free, (uint32_t)&async_msg[i]);
}
return 0;
}
SYS_INIT(init_mbox_module, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
/**
* @brief Allocate an asynchronous message descriptor.
*

View file

@ -22,6 +22,7 @@
#include <wait_q.h>
#include <misc/dlist.h>
#include <sched.h>
#include <init.h>
extern struct k_mem_map _k_mem_map_ptr_start[];
extern struct k_mem_map _k_mem_map_ptr_end[];
@ -56,13 +57,16 @@ static void create_free_list(struct k_mem_map *map)
*
* @return N/A
*/
void _k_mem_map_init(void)
static int init_mem_map_module(struct device *dev)
{
ARG_UNUSED(dev);
struct k_mem_map *map;
for (map = _k_mem_map_ptr_start; map < _k_mem_map_ptr_end; map++) {
create_free_list(map);
}
return 0;
}
/**
@ -164,3 +168,5 @@ void k_mem_map_free(struct k_mem_map *map, void **mem)
irq_unlock(key);
}
SYS_INIT(init_mem_map_module, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);

View file

@ -640,4 +640,4 @@ void k_free(void *ptr)
k_mem_pool_free(&mem_block);
}
SYS_INIT(init_static_pools, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(init_static_pools, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);

View file

@ -27,6 +27,7 @@
#include <sections.h>
#include <wait_q.h>
#include <misc/dlist.h>
#include <init.h>
struct k_pipe_desc {
unsigned char *buffer; /* Position in src/dest buffer */
@ -63,15 +64,20 @@ K_STACK_DEFINE(pipe_async_msgs, CONFIG_NUM_PIPE_ASYNC_MSGS);
*
* @return N/A
*/
void _k_pipes_init(void)
static int init_pipes_module(struct device *dev)
{
ARG_UNUSED(dev);
for (int i = 0; i < CONFIG_NUM_PIPE_ASYNC_MSGS; i++) {
async_msg[i].thread.flags = K_DUMMY;
async_msg[i].thread.swap_data = &async_msg[i].desc;
k_stack_push(&pipe_async_msgs, (uint32_t)&async_msg[i]);
}
return 0;
}
SYS_INIT(init_pipes_module, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
void k_pipe_init(struct k_pipe *pipe, unsigned char *buffer, size_t size)
{
pipe->buffer = buffer;

View file

@ -18,6 +18,7 @@
#include <misc/debug/object_tracing_common.h>
#include <wait_q.h>
#include <sched.h>
#include <init.h>
/**
* @brief Timer expire handler
@ -85,8 +86,10 @@ static struct k_timer _dynamic_timers[CONFIG_NUM_DYNAMIC_TIMERS];
static sys_dlist_t _timer_pool;
/* Initialize the pool of timers for dynamic timer allocation */
void _k_dyamic_timer_init(void)
static int init_dyamic_timers(struct device *dev)
{
ARG_UNUSED(dev);
int i;
int n_timers = ARRAY_SIZE(_dynamic_timers);
@ -96,6 +99,7 @@ void _k_dyamic_timer_init(void)
sys_dlist_append(&_timer_pool,
&_dynamic_timers[i].timeout.node);
}
return 0;
}
/**
@ -151,6 +155,9 @@ bool k_timer_pool_is_empty(void)
k_sched_unlock();
return is_empty;
}
SYS_INIT(init_dyamic_timers, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
#endif /* (CONFIG_NUM_DYNAMIC_TIMERS > 0) */
/**