mirror of https://github.com/RT-Thread/rt-thread
module clean up
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@915 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
3c2c5df6e8
commit
446799244a
|
@ -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_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_find(char* name);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
26
src/module.c
26
src/module.c
|
@ -12,9 +12,9 @@
|
|||
* 2010-01-09 Bernard first version
|
||||
* 2010-04-09 yi.qiu implement based on first version
|
||||
*/
|
||||
|
||||
#include <rtm.h>
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtm.h>
|
||||
|
||||
#include "string.h"
|
||||
#include "kservice.h"
|
||||
|
@ -35,19 +35,33 @@
|
|||
#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))
|
||||
|
||||
struct rt_module* rt_current_module;
|
||||
static struct rt_module* rt_current_module;
|
||||
|
||||
/**
|
||||
* This function will return self module object
|
||||
*
|
||||
* @return the self thread object
|
||||
* @return the self module object
|
||||
*
|
||||
*/
|
||||
rt_module_t rt_module_self (void)
|
||||
{
|
||||
/* return 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)
|
||||
{
|
||||
Elf32_Addr *where, tmp;
|
||||
|
@ -289,6 +303,10 @@ rt_err_t rt_module_unload(rt_module_t module)
|
|||
struct rt_object* object;
|
||||
struct rt_list_node *list, *node;
|
||||
|
||||
#ifdef RT_MODULE_DEBUG
|
||||
rt_kprintf("rt_module_unload %s\n", module->parent.name);
|
||||
#endif
|
||||
|
||||
/* check parameter */
|
||||
RT_ASSERT(module != RT_NULL);
|
||||
|
||||
|
|
14
src/object.c
14
src/object.c
|
@ -21,10 +21,6 @@
|
|||
|
||||
#include "kservice.h"
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
extern struct rt_module* rt_current_module;
|
||||
#endif
|
||||
|
||||
#define _OBJ_CONTAINER_LIST_INIT(c) \
|
||||
{&(rt_object_container[c].object_list), &(rt_object_container[c].object_list)}
|
||||
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
|
|||
|
||||
#ifdef RT_USING_MODULE
|
||||
/* get module object information */
|
||||
information = (rt_current_module != RT_NULL) ?
|
||||
&rt_current_module->module_object[type] : &rt_object_container[type];
|
||||
information = (rt_module_self() != RT_NULL) ?
|
||||
&rt_module_self()->module_object[type] : &rt_object_container[type];
|
||||
#else
|
||||
/* get object information */
|
||||
information = &rt_object_container[type];
|
||||
|
@ -261,11 +257,11 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char* name)
|
|||
|
||||
#ifdef RT_USING_MODULE
|
||||
/* get module object information */
|
||||
information = (rt_current_module != RT_NULL) ?
|
||||
&rt_current_module->module_object[type] : &rt_object_container[type];
|
||||
information = (rt_module_self() != RT_NULL) ?
|
||||
&rt_module_self()->module_object[type] : &rt_module_self()[type];
|
||||
#else
|
||||
/* get object information */
|
||||
information = &rt_object_container[type];
|
||||
information = &rt_module_self()[type];
|
||||
#endif
|
||||
|
||||
object = (struct rt_object*)rt_malloc(information->object_size);
|
||||
|
|
|
@ -38,9 +38,6 @@ rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
|
|||
struct rt_thread* rt_current_thread;
|
||||
|
||||
rt_uint8_t rt_current_priority;
|
||||
#ifdef RT_USING_MODULE
|
||||
extern struct rt_module* rt_current_module;
|
||||
#endif
|
||||
|
||||
#if RT_THREAD_PRIORITY_MAX > 32
|
||||
/* maximun priority level, 256 */
|
||||
|
@ -267,8 +264,8 @@ void rt_schedule()
|
|||
rt_current_thread = to_thread;
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
rt_current_module = (rt_current_thread->module_parent != RT_NULL) ?
|
||||
rt_current_thread->module_parent : RT_NULL;
|
||||
rt_module_set ((rt_current_thread->module_parent != RT_NULL) ?
|
||||
rt_current_thread->module_parent : RT_NULL);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
|
|
|
@ -32,10 +32,6 @@ extern rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
|
|||
extern struct rt_thread* rt_current_thread;
|
||||
extern rt_uint8_t rt_current_priority;
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
extern struct rt_module* rt_current_module;
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
extern rt_list_t rt_thread_defunct;
|
||||
#endif
|
||||
|
@ -82,7 +78,7 @@ static rt_err_t _rt_thread_init(struct rt_thread* thread,
|
|||
#ifdef RT_USING_MODULE
|
||||
/* init 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
|
||||
|
||||
/* init user data */
|
||||
|
|
Loading…
Reference in New Issue