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

module clean up

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@915 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 3c2c5df6
...@@ -304,9 +304,9 @@ rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void* arg); ...@@ -304,9 +304,9 @@ rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void* arg);
rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr); rt_module_t rt_module_load(const rt_uint8_t* name, void* module_ptr);
rt_err_t rt_module_unload(rt_module_t module); rt_err_t rt_module_unload(rt_module_t module);
rt_module_t rt_module_find(char* name); rt_err_t rt_module_self_set (rt_module_t module);
rt_module_t rt_module_self (void); rt_module_t rt_module_self (void);
rt_module_t rt_module_find(char* name);
#endif #endif
/* /*
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
* 2010-01-09 Bernard first version * 2010-01-09 Bernard first version
* 2010-04-09 yi.qiu implement based on first version * 2010-04-09 yi.qiu implement based on first version
*/ */
#include <rtm.h>
#include <rtthread.h> #include <rtthread.h>
#include <rtm.h>
#include "string.h" #include "string.h"
#include "kservice.h" #include "kservice.h"
...@@ -35,19 +35,33 @@ ...@@ -35,19 +35,33 @@
#define IS_AX(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_EXECINSTR)) #define IS_AX(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_EXECINSTR))
#define IS_AW(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_WRITE)) #define IS_AW(s) ((s.sh_flags & SHF_ALLOC) && (s.sh_flags & SHF_WRITE))
struct rt_module* rt_current_module; static struct rt_module* rt_current_module;
/** /**
* This function will return self module object * This function will return self module object
* *
* @return the self thread object * @return the self module object
* *
*/ */
rt_module_t rt_module_self (void) rt_module_t rt_module_self (void)
{ {
/* return current module */
return rt_current_module; return rt_current_module;
} }
/**
* This function will set current module object
*
* @return RT_EOK
*/
rt_err_t rt_module_set (rt_module_t module)
{
/* set current module */
rt_current_module = module;
return RT_EOK;
}
static int rt_module_arm_relocate(struct rt_module* module, Elf32_Rel *rel, Elf32_Addr sym_val) static int rt_module_arm_relocate(struct rt_module* module, Elf32_Rel *rel, Elf32_Addr sym_val)
{ {
Elf32_Addr *where, tmp; Elf32_Addr *where, tmp;
...@@ -289,6 +303,10 @@ rt_err_t rt_module_unload(rt_module_t module) ...@@ -289,6 +303,10 @@ rt_err_t rt_module_unload(rt_module_t module)
struct rt_object* object; struct rt_object* object;
struct rt_list_node *list, *node; struct rt_list_node *list, *node;
#ifdef RT_MODULE_DEBUG
rt_kprintf("rt_module_unload %s\n", module->parent.name);
#endif
/* check parameter */ /* check parameter */
RT_ASSERT(module != RT_NULL); RT_ASSERT(module != RT_NULL);
......
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
#include "kservice.h" #include "kservice.h"
#ifdef RT_USING_MODULE
extern struct rt_module* rt_current_module;
#endif
#define _OBJ_CONTAINER_LIST_INIT(c) \ #define _OBJ_CONTAINER_LIST_INIT(c) \
{&(rt_object_container[c].object_list), &(rt_object_container[c].object_list)} {&(rt_object_container[c].object_list), &(rt_object_container[c].object_list)}
struct rt_object_information rt_object_container[RT_Object_Class_Unknown] = struct rt_object_information rt_object_container[RT_Object_Class_Unknown] =
...@@ -182,8 +178,8 @@ void rt_object_init(struct rt_object* object, enum rt_object_class_type type, co ...@@ -182,8 +178,8 @@ void rt_object_init(struct rt_object* object, enum rt_object_class_type type, co
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
/* get module object information */ /* get module object information */
information = (rt_current_module != RT_NULL) ? information = (rt_module_self() != RT_NULL) ?
&rt_current_module->module_object[type] : &rt_object_container[type]; &rt_module_self()->module_object[type] : &rt_object_container[type];
#else #else
/* get object information */ /* get object information */
information = &rt_object_container[type]; information = &rt_object_container[type];
...@@ -261,11 +257,11 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char* name) ...@@ -261,11 +257,11 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char* name)
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
/* get module object information */ /* get module object information */
information = (rt_current_module != RT_NULL) ? information = (rt_module_self() != RT_NULL) ?
&rt_current_module->module_object[type] : &rt_object_container[type]; &rt_module_self()->module_object[type] : &rt_module_self()[type];
#else #else
/* get object information */ /* get object information */
information = &rt_object_container[type]; information = &rt_module_self()[type];
#endif #endif
object = (struct rt_object*)rt_malloc(information->object_size); object = (struct rt_object*)rt_malloc(information->object_size);
......
...@@ -38,9 +38,6 @@ rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX]; ...@@ -38,9 +38,6 @@ rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
struct rt_thread* rt_current_thread; struct rt_thread* rt_current_thread;
rt_uint8_t rt_current_priority; rt_uint8_t rt_current_priority;
#ifdef RT_USING_MODULE
extern struct rt_module* rt_current_module;
#endif
#if RT_THREAD_PRIORITY_MAX > 32 #if RT_THREAD_PRIORITY_MAX > 32
/* maximun priority level, 256 */ /* maximun priority level, 256 */
...@@ -267,8 +264,8 @@ void rt_schedule() ...@@ -267,8 +264,8 @@ void rt_schedule()
rt_current_thread = to_thread; rt_current_thread = to_thread;
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
rt_current_module = (rt_current_thread->module_parent != RT_NULL) ? rt_module_set ((rt_current_thread->module_parent != RT_NULL) ?
rt_current_thread->module_parent : RT_NULL; rt_current_thread->module_parent : RT_NULL);
#endif #endif
#ifdef RT_USING_HOOK #ifdef RT_USING_HOOK
......
...@@ -32,10 +32,6 @@ extern rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX]; ...@@ -32,10 +32,6 @@ extern rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
extern struct rt_thread* rt_current_thread; extern struct rt_thread* rt_current_thread;
extern rt_uint8_t rt_current_priority; extern rt_uint8_t rt_current_priority;
#ifdef RT_USING_MODULE
extern struct rt_module* rt_current_module;
#endif
#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
extern rt_list_t rt_thread_defunct; extern rt_list_t rt_thread_defunct;
#endif #endif
...@@ -82,7 +78,7 @@ static rt_err_t _rt_thread_init(struct rt_thread* thread, ...@@ -82,7 +78,7 @@ static rt_err_t _rt_thread_init(struct rt_thread* thread,
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
/* init module parent */ /* init module parent */
thread->module_parent = thread->module_parent =
(rt_current_module != RT_NULL) ? rt_current_module : RT_NULL; (rt_module_self() != RT_NULL) ? rt_module_self() : RT_NULL;
#endif #endif
/* init user data */ /* init user data */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册