diff options
| -rw-r--r-- | bsp/mini2440/Console.lnk | bin | 693 -> 0 bytes | |||
| -rw-r--r-- | bsp/mini2440/Makefile | 6 | ||||
| -rw-r--r-- | bsp/mini2440/run_module.c | 16 | ||||
| -rw-r--r-- | components/module/examples/application/basicapp/SConscript | 2 | ||||
| -rw-r--r-- | components/module/examples/application/basicapp/module_entry.c | 7 | ||||
| -rw-r--r-- | src/module.c | 9 |
6 files changed, 22 insertions, 18 deletions
diff --git a/bsp/mini2440/Console.lnk b/bsp/mini2440/Console.lnk Binary files differdeleted file mode 100644 index 192da3d2c9..0000000000 --- a/bsp/mini2440/Console.lnk +++ /dev/null diff --git a/bsp/mini2440/Makefile b/bsp/mini2440/Makefile deleted file mode 100644 index ee3c7bff07..0000000000 --- a/bsp/mini2440/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -CLEAN_FILES= *.bin *.map *.axf rtconfig.pyc .sconsign.dblite
-
-clean:
- find . \( -name "*.o" -o -name "*.bak" \) -type f -print | xargs rm -f
- rm -fr ./build
- rm -fr $(CLEAN_FILES)
diff --git a/bsp/mini2440/run_module.c b/bsp/mini2440/run_module.c index 372e67d1fe..a8d50776f5 100644 --- a/bsp/mini2440/run_module.c +++ b/bsp/mini2440/run_module.c @@ -18,16 +18,19 @@ #if defined(RT_USING_FINSH) && defined(RT_USING_MODULE)
#include <finsh.h>
-static char buffer[4096];
void run_module(const char* filename)
{
int fd, length;
char *module_name;
+ struct rt_module* module;
+ struct dfs_stat s;
+ char *buffer;
- rt_memset(buffer, 0, 4096);
+ stat(filename, &s);
+ buffer = (char *)rt_malloc(s.st_size);
fd = open(filename, O_RDONLY, 0);
- length = read(fd, buffer, 4096);
+ length = read(fd, buffer, s.st_size);
if (length <= 0)
{
rt_kprintf("check: read file failed\n");
@@ -36,7 +39,12 @@ void run_module(const char* filename) }
rt_kprintf("read %d bytes from file\n", length);
module_name = strrchr(filename, '/');
- rt_module_load(buffer, ++module_name);
+ module = rt_module_load((void *)buffer, ++module_name);
+ if(module != RT_NULL)
+ {
+ rt_module_run(module);
+ }
+
close(fd);
}
diff --git a/components/module/examples/application/basicapp/SConscript b/components/module/examples/application/basicapp/SConscript index e8f79a5fd9..286381b6bc 100644 --- a/components/module/examples/application/basicapp/SConscript +++ b/components/module/examples/application/basicapp/SConscript @@ -11,7 +11,7 @@ group['CCFLAGS'] = '' group['CPPPATH'] = [RTT_ROOT + '/components/module/interface'] group['CPPDEFINES'] = '' -target = 'hello.mo' +target = 'basicapp.mo' # add group to project list projects.append(group) diff --git a/components/module/examples/application/basicapp/module_entry.c b/components/module/examples/application/basicapp/module_entry.c index 1b523da100..ad3fb698c7 100644 --- a/components/module/examples/application/basicapp/module_entry.c +++ b/components/module/examples/application/basicapp/module_entry.c @@ -1,14 +1,17 @@ #include <rtthread.h>
#include <interface_help.h>
-extern int rt_application_entry();
+extern int rt_application_entry(void);
rt_shell_t ishell = RT_NULL;
int rt_module_entry(const void* shell, void** object_info)
{
/* init shell */
ishell = (rt_shell_t)shell;
- struct rt_module_info *info = (struct rt_module_info*)rt_malloc(sizeof(struct rt_module_info));
+
+ rt_kprintf("module entry\n");
+ struct rt_module_info *info = (struct rt_module_info*)
+ rt_malloc(sizeof(struct rt_module_info));
info->module_refs = 0;
info->module_type = RT_Module_Class_APP;
diff --git a/src/module.c b/src/module.c index decd8e6222..e624c40d3f 100644 --- a/src/module.c +++ b/src/module.c @@ -19,7 +19,7 @@ #include "module.h" #include "kservice.h" -#define RT_MODULE_DEBUG +/* #define RT_MODULE_DEBUG */ #ifdef RT_USING_MODULE #define elf_module ((Elf32_Ehdr *)module_ptr) @@ -262,7 +262,7 @@ struct rt_module* rt_module_load(void* module_ptr, const rt_uint8_t* name) if (IS_PROG(shdr[index]) && IS_AW(shdr[index])) { data_addr = (rt_uint32_t)ptr; - rt_kprintf("data section address 0x%x\n", data_addr); + /* rt_kprintf("data section address 0x%x\n", data_addr); */ rt_memcpy(ptr, (rt_uint8_t*)elf_module + shdr[index].sh_offset, shdr[index].sh_size); ptr += shdr[index].sh_size; } @@ -271,7 +271,7 @@ struct rt_module* rt_module_load(void* module_ptr, const rt_uint8_t* name) if (IS_NOPROG(shdr[index]) && IS_AW(shdr[index])) { bss_addr = (rt_uint32_t)ptr; - rt_kprintf("bss section address 0x%x\n", bss_addr); + /* rt_kprintf("bss section address 0x%x\n", bss_addr); */ rt_memset(ptr, 0, shdr[index].sh_size); } } @@ -309,7 +309,6 @@ struct rt_module* rt_module_load(void* module_ptr, const rt_uint8_t* name) if((ELF_ST_TYPE(sym->st_info) == STT_SECTION) || (ELF_ST_TYPE(sym->st_info) == STT_OBJECT)) { - rt_kprintf("section name %s\n", shstrab + shdr[sym->st_shndx].sh_name); if (rt_strncmp(shstrab + shdr[sym->st_shndx].sh_name, ELF_RODATA, 8) == 0) { /* relocate rodata section */ @@ -387,7 +386,7 @@ void rt_module_run(struct rt_module* module) { /* application */ module->module_thread = rt_thread_create(module->parent.name, - module->module_entry, RT_NULL, + module->module_info->exec_entry, RT_NULL, 512, 90, 10); module->module_thread->module_parent = module; rt_thread_startup(module->module_thread); |
