提交 a124e7bd 编写于 作者: B bernard

add initialization debug code

上级 b96b3561
......@@ -13,7 +13,7 @@
#ifdef RT_DFS_ELM_USE_LFN
static int gbk2uni_fd = -1;
static int uni2gbk_fd = -1;
void ff_convert_init()
int ff_convert_init()
{
gbk2uni_fd = open(GBK2UNI_FILE, O_RDONLY, 0);
if (gbk2uni_fd < 0)
......@@ -22,6 +22,7 @@ void ff_convert_init()
uni2gbk_fd = open(UNI2GBK_FILE, O_RDONLY, 0);
if (uni2gbk_fd < 0)
rt_kprintf("Unable to open Unicode to GBK look up table.\r\n");
return 0;
}
INIT_APP_EXPORT(ff_convert_init);
......
......@@ -500,7 +500,7 @@ int dfs_statfs(const char *path, struct statfs *buffer)
#ifdef RT_USING_DFS_MNTTABLE
int dfs_mount_table(void)
{
int index;
int index = 0;
while (1)
{
......
......@@ -134,8 +134,8 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
return (ret > 0) ? count : ret;
}
rt_err_t rt_i2c_core_init(void)
int rt_i2c_core_init(void)
{
return rt_mutex_init(&i2c_core_lock, "i2c_core_lock", RT_IPC_FLAG_FIFO);
}
INIT_COMPONENT_EXPORT(rt_i2c_core_init);
......@@ -96,7 +96,7 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
rt_uint16_t flags,
rt_uint8_t *buf,
rt_uint32_t count);
rt_err_t rt_i2c_core_init(void);
int rt_i2c_core_init(void);
#ifdef __cplusplus
}
......
......@@ -34,7 +34,7 @@
*
* @return none.
*/
void rt_usb_host_init(void)
int rt_usb_host_init(void)
{
ucd_t drv;
#ifdef RT_USB_CLASS_HID
......@@ -80,5 +80,8 @@ void rt_usb_host_init(void)
/* register hub class driver */
drv = rt_usb_class_driver_hub();
rt_usb_class_driver_register(drv);
return 0;
}
INIT_COMPONENT_EXPORT(rt_usb_host_init);
......@@ -52,6 +52,16 @@ INIT_EXPORT(rti_end,"7");
void rt_components_board_init(void)
{
#ifndef _MSC_VER
#if RT_DEBUG_INIT
int result;
const struct rt_init_desc *desc;
for (desc = &__rt_init_desc_rti_start; desc < &__rt_init_desc_rti_board_end; desc ++)
{
rt_kprintf("initialize %s", desc->fn_name);
result = desc->fn();
rt_kprintf(":%d done\n", result);
}
#else
const init_fn_t *fn_ptr;
for (fn_ptr = &__rt_init_rti_start; fn_ptr < &__rt_init_rti_board_end; fn_ptr++)
......@@ -59,6 +69,7 @@ void rt_components_board_init(void)
(*fn_ptr)();
}
#endif
#endif
}
/**
......@@ -67,12 +78,25 @@ void rt_components_board_init(void)
void rt_components_init(void)
{
#ifndef _MSC_VER
#if RT_DEBUG_INIT
int result;
const struct rt_init_desc *desc;
rt_kprintf("do components intialization.\n");
for (desc = &__rt_init_desc_rti_board_end; desc < &__rt_init_desc_rti_end; desc ++)
{
rt_kprintf("initialize %s", desc->fn_name);
result = desc->fn();
rt_kprintf(":%d done\n", result);
}
#else
const init_fn_t *fn_ptr;
for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++)
{
(*fn_ptr)();
}
#endif
#else
#ifdef RT_USING_MODULE
rt_system_module_init();
......
......@@ -63,6 +63,10 @@
#define RT_DEBUG_IPC 0
#endif
#ifndef RT_DEBUG_INIT
#define RT_DEBUG_INIT 0
#endif
/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK 1
......
......@@ -181,8 +181,20 @@ typedef int (*init_fn_t)(void);
#ifdef _MSC_VER /* we do not support MS VC++ compiler */
#define INIT_EXPORT(fn, level)
#else
#if RT_DEBUG_INIT
struct rt_init_desc
{
const char* fn_name;
const init_fn_t fn;
};
#define INIT_EXPORT(fn, level) \
const char __rti_##fn##_name[] = #fn; \
const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
{ __rti_##fn##_name, fn};
#else
#define INIT_EXPORT(fn, level) \
const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
#endif
#endif
#else
#define INIT_EXPORT(fn, level)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册