From 25e7ea1745a02f3673f025ca209d10e248b45e6b Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Sat, 29 May 2010 15:27:27 +0000 Subject: [PATCH] module developing, application can be run successfully git-svn-id: https://rt-thread.googlecode.com/svn/trunk@747 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/mini2440/Console.lnk | Bin 693 -> 0 bytes bsp/mini2440/Makefile | 6 ------ bsp/mini2440/run_module.c | 16 ++++++++++++---- .../examples/application/basicapp/SConscript | 2 +- .../application/basicapp/module_entry.c | 7 +++++-- src/module.c | 9 ++++----- 6 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 bsp/mini2440/Console.lnk delete mode 100644 bsp/mini2440/Makefile diff --git a/bsp/mini2440/Console.lnk b/bsp/mini2440/Console.lnk deleted file mode 100644 index 192da3d2c92cadbb240b9f424ed5e0b4fc0345ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 693 zcmaJ5-}~Ns_rCY;vH+Ce2qoaS5<6$qVd3p}v$b`v zz>a*hz8)0MR!{xnh2qM-ctH^J`|bQw_%&gwSI^^ESzo^hVQo91_oI3&iKxrt$6B7+>#$deUlPa@UJZ8FztST&;(+W?javYT$Ug$69t zV4#8+7=&pgMQdZ2iXs(8sZ!RAy3wmGr|M>OS8A7-RffjwIw7@zJz|!S0f>$evNFU3 z;UhZD?5#=-HviL`?%h-O3Sxn8)}RlOgFWl)V6Y4Q&&?iLil6Z^fKODhs#GzD8RbxJ zFk~4xW?v>F4{$WZ|Nl|wms@5akhyk$3(si-+_3Ggq9ldmIMm|kxEr00FoKU9Q3PoF S*~>KtDKi`;U!=YvWPJm`{BYp_ diff --git a/bsp/mini2440/Makefile b/bsp/mini2440/Makefile deleted file mode 100644 index ee3c7bff0..000000000 --- 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 372e67d1f..a8d50776f 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 -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 e8f79a5fd..286381b6b 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 1b523da10..ad3fb698c 100644 --- a/components/module/examples/application/basicapp/module_entry.c +++ b/components/module/examples/application/basicapp/module_entry.c @@ -1,14 +1,17 @@ #include #include -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 decd8e622..e624c40d3 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);