summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbernard <[email protected]>2013-07-22 07:46:10 +0800
committerbernard <[email protected]>2013-07-22 07:46:10 +0800
commitb96b35613f2cdc8118f083a3e2795788915319d7 (patch)
tree4318798c8331e2b65b27ae9f1949df3a31ffce4f
parentadc678dabbcccd1f17cc1392882934ed5791a2b8 (diff)
add mount table
-rw-r--r--components/dfs/filesystems/elmfat/option/ccfile.c1
-rw-r--r--components/dfs/include/dfs_fs.h11
-rw-r--r--components/dfs/src/dfs_fs.c27
-rw-r--r--include/rtdef.h8
-rw-r--r--include/rtthread.h2
-rw-r--r--src/module.c8
6 files changed, 49 insertions, 8 deletions
diff --git a/components/dfs/filesystems/elmfat/option/ccfile.c b/components/dfs/filesystems/elmfat/option/ccfile.c
index 34c97372c1..e91db8c702 100644
--- a/components/dfs/filesystems/elmfat/option/ccfile.c
+++ b/components/dfs/filesystems/elmfat/option/ccfile.c
@@ -23,6 +23,7 @@ void ff_convert_init()
if (uni2gbk_fd < 0)
rt_kprintf("Unable to open Unicode to GBK look up table.\r\n");
}
+INIT_APP_EXPORT(ff_convert_init);
rt_uint16_t ff_convert(rt_uint16_t src, rt_uint32_t dir)
{
diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h
index e8f42f6631..3fa999c344 100644
--- a/components/dfs/include/dfs_fs.h
+++ b/components/dfs/include/dfs_fs.h
@@ -82,6 +82,16 @@ struct dfs_partition
rt_sem_t lock;
};
+/* mount table */
+struct dfs_mount_tbl
+{
+ const char *device_name;
+ const char *path;
+ const char *filesystemtype;
+ unsigned long rwflag;
+ const void *data;
+};
+
int dfs_register(const struct dfs_filesystem_operation *ops);
struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
rt_err_t dfs_filesystem_get_partition(struct dfs_partition *part,
@@ -98,6 +108,7 @@ int dfs_unmount(const char *specialfile);
/* extern variable */
extern const struct dfs_filesystem_operation *filesystem_operation_table[];
extern struct dfs_filesystem filesystem_table[];
+extern const struct dfs_mount_tbl mount_table[];
extern char working_directory[];
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index c7fb80eff3..8b77aa978b 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -497,6 +497,33 @@ int dfs_statfs(const char *path, struct statfs *buffer)
return -1;
}
+#ifdef RT_USING_DFS_MNTTABLE
+int dfs_mount_table(void)
+{
+ int index;
+
+ 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,
+ mount_table[index].rwflag,
+ mount_table[index].data) != 0)
+ {
+ rt_kprintf("mount fs[%s] on %s failed.\n", mount_table[index].filesystemtype,
+ mount_table[index].path);
+ return -RT_ERROR;
+ }
+
+ index ++;
+ }
+ return 0;
+}
+INIT_ENV_EXPORT(dfs_mount_table);
+#endif
+
#ifdef RT_USING_FINSH
#include <finsh.h>
void mkfs(const char *fs_name, const char *device_name)
diff --git a/include/rtdef.h b/include/rtdef.h
index cb1fb7a9a9..1d64ae54f4 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -191,10 +191,16 @@ typedef int (*init_fn_t)(void);
/* board init routines will be called in board_init() function */
#define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1")
/* device/component/fs/app init routines will be called in init_thread */
+/* device initialization */
#define INIT_DEVICE_EXPORT(fn) INIT_EXPORT(fn, "2")
+/* components initialization (dfs, lwip, ...) */
#define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "3")
+/* file system initialization (dfs-elm, dfs-rom, ...) */
#define INIT_FS_EXPORT(fn) INIT_EXPORT(fn, "4")
-#define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "5")
+/* environment initialization (mount disk, ...) */
+#define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
+/* appliation initialization (rtgui application etc ...) */
+#define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6")
/* event length */
#define RT_EVENT_LENGTH 32
diff --git a/include/rtthread.h b/include/rtthread.h
index 6c3b11134d..28c0192291 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -452,7 +452,7 @@ rt_uint8_t rt_interrupt_get_nest(void);
/**
* application module
*/
-void rt_system_module_init(void);
+int rt_system_module_init(void);
/**
* @addtogroup KernelService
diff --git a/src/module.c b/src/module.c
index 5469d46523..ac689dbade 100644
--- a/src/module.c
+++ b/src/module.c
@@ -80,7 +80,7 @@ static struct rt_module_symtab *_rt_module_symtab_end = RT_NULL;
*
* This function will initialize system module
*/
-void rt_system_module_init(void)
+int rt_system_module_init(void)
{
#ifdef __GNUC__
extern int __rtmsymtab_start;
@@ -100,6 +100,7 @@ void rt_system_module_init(void)
/* initialize heap semaphore */
rt_sem_init(&mod_sem, "module", 1, RT_IPC_FLAG_FIFO);
#endif
+ return 0;
}
INIT_COMPONENT_EXPORT(rt_system_module_init);
@@ -805,9 +806,6 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
if (elf_module->e_entry != 0)
{
- rt_uint32_t *stack_size;
- rt_uint8_t *priority;
-
#ifdef RT_USING_SLAB
/* init module memory allocator */
module->mem_list = RT_NULL;
@@ -1180,8 +1178,6 @@ rt_err_t rt_module_destroy(rt_module_t module)
*/
rt_err_t rt_module_unload(rt_module_t module)
{
- int i;
- rt_err_t result;
struct rt_object *object;
struct rt_list_node *list;