summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbernard <[email protected]>2013-07-24 07:33:48 +0800
committerbernard <[email protected]>2013-07-24 07:33:48 +0800
commita124e7bd22445ce90fc39419268d1b27e74ffd45 (patch)
tree6e10260ee04b990bf021b93b87aa2f7e04f1bb12
parentb96b35613f2cdc8118f083a3e2795788915319d7 (diff)
add initialization debug code
-rw-r--r--components/dfs/filesystems/elmfat/option/ccfile.c3
-rw-r--r--components/dfs/src/dfs_fs.c4
-rw-r--r--components/drivers/i2c/i2c_core.c4
-rw-r--r--components/drivers/include/drivers/i2c.h2
-rw-r--r--components/drivers/usb/usbhost/core/usbhost.c5
-rw-r--r--components/init/components.c24
-rw-r--r--include/rtdebug.h4
-rw-r--r--include/rtdef.h16
8 files changed, 53 insertions, 9 deletions
diff --git a/components/dfs/filesystems/elmfat/option/ccfile.c b/components/dfs/filesystems/elmfat/option/ccfile.c
index e91db8c702..594cbe71a1 100644
--- a/components/dfs/filesystems/elmfat/option/ccfile.c
+++ b/components/dfs/filesystems/elmfat/option/ccfile.c
@@ -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);
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index 8b77aa978b..0b2dea8866 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -500,12 +500,12 @@ 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)
{
if (mount_table[index].path == RT_NULL) break;
-
+
if (dfs_mount(mount_table[index].device_name,
mount_table[index].path,
mount_table[index].filesystemtype,
diff --git a/components/drivers/i2c/i2c_core.c b/components/drivers/i2c/i2c_core.c
index 0449cc723c..f274f70fcd 100644
--- a/components/drivers/i2c/i2c_core.c
+++ b/components/drivers/i2c/i2c_core.c
@@ -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);
diff --git a/components/drivers/include/drivers/i2c.h b/components/drivers/include/drivers/i2c.h
index e2bdcb06bb..b6f5273722 100644
--- a/components/drivers/include/drivers/i2c.h
+++ b/components/drivers/include/drivers/i2c.h
@@ -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
}
diff --git a/components/drivers/usb/usbhost/core/usbhost.c b/components/drivers/usb/usbhost/core/usbhost.c
index 9c0665d28c..f40bd71528 100644
--- a/components/drivers/usb/usbhost/core/usbhost.c
+++ b/components/drivers/usb/usbhost/core/usbhost.c
@@ -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);
+
diff --git a/components/init/components.c b/components/init/components.c
index 83e13f22cd..44ff11361a 100644
--- a/components/init/components.c
+++ b/components/init/components.c
@@ -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();
diff --git a/include/rtdebug.h b/include/rtdebug.h
index adcea8a8bf..ebf85d6dba 100644
--- a/include/rtdebug.h
+++ b/include/rtdebug.h
@@ -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
diff --git a/include/rtdef.h b/include/rtdef.h
index 1d64ae54f4..a3d13bfc44 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -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
- #define INIT_EXPORT(fn, level) \
- const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
+ #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)