提交 407f922a 编写于 作者: qiuyiuestc's avatar qiuyiuestc

fix module unload issue

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2001 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 b36c2860
...@@ -31,7 +31,7 @@ extern "C" { ...@@ -31,7 +31,7 @@ extern "C" {
/*@{*/ /*@{*/
/* RT-Thread version information */ /* RT-Thread version information */
#define RT_VERSION 1L /**< major version number */ #define RT_VERSION 1L /**< major version number */
#define RT_SUBVERSION 1L /**< minor version number */ #define RT_SUBVERSION 1L /**< minor version number */
#define RT_REVISION 0L /**< revise version number */ #define RT_REVISION 0L /**< revise version number */
...@@ -150,7 +150,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset ...@@ -150,7 +150,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset
#define RT_EEMPTY 4 /**< The resource is empty */ #define RT_EEMPTY 4 /**< The resource is empty */
#define RT_ENOMEM 5 /**< No memory */ #define RT_ENOMEM 5 /**< No memory */
#define RT_ENOSYS 6 /**< No system */ #define RT_ENOSYS 6 /**< No system */
#define RT_EBUSY 7 /**< Busy */ #define RT_EBUSY 7 /**< Busy */
#define RT_EIO 8 /**< IO error */ #define RT_EIO 8 /**< IO error */
/*@}*/ /*@}*/
...@@ -592,9 +592,9 @@ enum rt_device_class_type ...@@ -592,9 +592,9 @@ enum rt_device_class_type
RT_Device_Class_Graphic, /**< Graphic device */ RT_Device_Class_Graphic, /**< Graphic device */
RT_Device_Class_I2C, /**< I2C device */ RT_Device_Class_I2C, /**< I2C device */
RT_Device_Class_USBDevice, /**< USB slave device */ RT_Device_Class_USBDevice, /**< USB slave device */
RT_Device_Class_USBHost, /**< USB host bus */ RT_Device_Class_USBHost, /**< USB host bus */
RT_Device_Class_SPIBUS, /**< SPI bus device */ RT_Device_Class_SPIBUS, /**< SPI bus device */
RT_Device_Class_SPIDevice, /**< SPI device */ RT_Device_Class_SPIDevice, /**< SPI device */
RT_Device_Class_SDIO, /**< SDIO bus device */ RT_Device_Class_SDIO, /**< SDIO bus device */
RT_Device_Class_Unknown /**< unknown device */ RT_Device_Class_Unknown /**< unknown device */
}; };
...@@ -781,10 +781,12 @@ struct rt_module ...@@ -781,10 +781,12 @@ struct rt_module
rt_uint32_t stack_size; /**< priority of module's thread */ rt_uint32_t stack_size; /**< priority of module's thread */
rt_uint32_t thread_priority; rt_uint32_t thread_priority;
#ifdef RT_USING_SLAB
/* module memory allocator */ /* module memory allocator */
void *mem_list; /**< module's free memory list */ void *mem_list; /**< module's free memory list */
void *page_array; /**< module's using pages */ void *page_array; /**< module's using pages */
rt_uint32_t page_cnt; /**< module's using pages count */ rt_uint32_t page_cnt; /**< module's using pages count */
#endif
rt_uint32_t nsym; /**< number of symbol in the module */ rt_uint32_t nsym; /**< number of symbol in the module */
struct rt_module_symtab *symtab; /**< module symbol table */ struct rt_module_symtab *symtab; /**< module symbol table */
......
...@@ -374,15 +374,15 @@ static struct rt_module* _load_shared_object(const char *name, void *module_ptr) ...@@ -374,15 +374,15 @@ static struct rt_module* _load_shared_object(const char *name, void *module_ptr)
if (module_size == 0) if (module_size == 0)
{ {
rt_kprintf(" module size error\n"); rt_kprintf(" module size error\n");
return RT_NULL;
return module;
} }
/* allocate module */ /* allocate module */
module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name); module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name);
if (!module) if (!module) return RT_NULL;
return RT_NULL;
module->nref = 0;
/* allocate module space */ /* allocate module space */
module->module_space = rt_malloc(module_size); module->module_space = rt_malloc(module_size);
if (module->module_space == RT_NULL) if (module->module_space == RT_NULL)
...@@ -774,10 +774,10 @@ rt_module_t rt_module_load(const char *name, void *module_ptr) ...@@ -774,10 +774,10 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
if (elf_module->e_entry != 0) if (elf_module->e_entry != 0)
{ {
#ifdef RT_USING_SLAB
/* init module memory allocator */ /* init module memory allocator */
module->mem_list = RT_NULL; module->mem_list = RT_NULL;
#ifdef RT_USING_SLAB
/* create page array */ /* create page array */
module->page_array = (void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info)); module->page_array = (void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info));
module->page_cnt = 0; module->page_cnt = 0;
...@@ -1527,7 +1527,6 @@ void *rt_module_realloc(void *ptr, rt_size_t size) ...@@ -1527,7 +1527,6 @@ void *rt_module_realloc(void *ptr, rt_size_t size)
} }
} }
} }
#endif
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
#include <finsh.h> #include <finsh.h>
...@@ -1569,3 +1568,5 @@ FINSH_FUNCTION_EXPORT(list_mempage, list module using memory page information) ...@@ -1569,3 +1568,5 @@ FINSH_FUNCTION_EXPORT(list_mempage, list module using memory page information)
#endif #endif
#endif #endif
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册