module update
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@946 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
1b55b00533
commit
7fd452b8a6
21
src/idle.c
21
src/idle.c
|
@ -104,14 +104,6 @@ void rt_thread_idle_excute(void)
|
||||||
/* detach module's main thread */
|
/* detach module's main thread */
|
||||||
module->module_thread = RT_NULL;
|
module->module_thread = RT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if sub thread list and main thread are all enmpy */
|
|
||||||
if((module->module_thread == RT_NULL) &&
|
|
||||||
rt_list_isempty(&module->module_object[RT_Object_Class_Thread].object_list) )
|
|
||||||
{
|
|
||||||
/* unload module */
|
|
||||||
rt_module_unload(module);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* release thread's stack */
|
/* release thread's stack */
|
||||||
|
@ -119,8 +111,21 @@ void rt_thread_idle_excute(void)
|
||||||
|
|
||||||
/* delete thread object */
|
/* delete thread object */
|
||||||
rt_object_delete((rt_object_t)thread);
|
rt_object_delete((rt_object_t)thread);
|
||||||
|
|
||||||
|
#ifdef RT_USING_MODULE
|
||||||
|
if(module != RT_NULL)
|
||||||
|
{
|
||||||
|
/* if sub thread list and main thread are all empty */
|
||||||
|
if((module->module_thread == RT_NULL) &&
|
||||||
|
rt_list_isempty(&module->module_object[RT_Object_Class_Thread].object_list) )
|
||||||
|
{
|
||||||
|
/* unload module */
|
||||||
|
rt_module_unload(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rt_thread_idle_entry(void* parameter)
|
static void rt_thread_idle_entry(void* parameter)
|
||||||
|
|
179
src/module.c
179
src/module.c
|
@ -19,8 +19,8 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "kservice.h"
|
#include "kservice.h"
|
||||||
|
|
||||||
/* #define RT_MODULE_DEBUG */
|
#define RT_MODULE_DEBUG
|
||||||
#ifdef RT_USING_MODULE
|
/* #ifdef RT_USING_MODULE */
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
#define elf_module ((Elf32_Ehdr *)module_ptr)
|
#define elf_module ((Elf32_Ehdr *)module_ptr)
|
||||||
|
@ -104,7 +104,8 @@ static int rt_module_arm_relocate(struct rt_module* module, Elf32_Rel *rel, Elf3
|
||||||
*where = (Elf32_Addr)sym_val;
|
*where = (Elf32_Addr)sym_val;
|
||||||
#ifdef RT_MODULE_DEBUG
|
#ifdef RT_MODULE_DEBUG
|
||||||
rt_kprintf("R_ARM_JUMP_SLOT: 0x%x -> 0x%x 0x%x\n", where, *where, sym_val);
|
rt_kprintf("R_ARM_JUMP_SLOT: 0x%x -> 0x%x 0x%x\n", where, *where, sym_val);
|
||||||
#endif break;
|
#endif
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +343,7 @@ rt_err_t rt_module_unload(rt_module_t module)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct rt_object* object;
|
struct rt_object* object;
|
||||||
struct rt_list_node *list, *node;
|
struct rt_list_node *list;
|
||||||
|
|
||||||
#ifdef RT_MODULE_DEBUG
|
#ifdef RT_MODULE_DEBUG
|
||||||
rt_kprintf("rt_module_unload %s\n", module->parent.name);
|
rt_kprintf("rt_module_unload %s\n", module->parent.name);
|
||||||
|
@ -355,29 +356,167 @@ rt_err_t rt_module_unload(rt_module_t module)
|
||||||
if (module->module_thread->stat == RT_THREAD_READY)
|
if (module->module_thread->stat == RT_THREAD_READY)
|
||||||
rt_thread_suspend(module->module_thread);
|
rt_thread_suspend(module->module_thread);
|
||||||
|
|
||||||
/* delete all module object */
|
/* delete threads */
|
||||||
for(i = RT_Object_Class_Thread; i < RT_Object_Class_Module; i++)
|
list = &module->module_object[RT_Object_Class_Thread].object_list;
|
||||||
|
while(list->next != list)
|
||||||
{
|
{
|
||||||
list = &module->module_object[i].object_list;
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
for (node = list->next; node != list; node = node->next)
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
{
|
{
|
||||||
object = rt_list_entry(node, struct rt_object, list);
|
/* detach static objcet */
|
||||||
if (rt_object_is_systemobject(object) == RT_EOK)
|
rt_thread_detach((rt_thread_t)object);
|
||||||
{
|
}
|
||||||
/* detach static objcet */
|
else
|
||||||
rt_object_detach(object);
|
{
|
||||||
}
|
/* delete dynamic object */
|
||||||
else
|
rt_thread_delete((rt_thread_t)object);
|
||||||
{
|
}
|
||||||
/* delete dynamic object */
|
}
|
||||||
rt_object_delete(object);
|
|
||||||
}
|
#ifdef RT_USING_SEMAPHORE
|
||||||
|
/* delete semaphores */
|
||||||
|
list = &module->module_object[RT_Object_Class_Thread].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_sem_detach((rt_sem_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_sem_delete((rt_sem_t)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_MUTEX
|
||||||
|
/* delete mutexs*/
|
||||||
|
list = &module->module_object[RT_Object_Class_Mutex].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_mutex_detach((rt_mutex_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_mutex_delete((rt_mutex_t)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_EVENT
|
||||||
|
/* delete mailboxs */
|
||||||
|
list = &module->module_object[RT_Object_Class_Event].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_event_detach((rt_event_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_event_delete((rt_event_t)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_MAILBOX
|
||||||
|
/* delete mailboxs */
|
||||||
|
list = &module->module_object[RT_Object_Class_MailBox].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_mb_detach((rt_mailbox_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_mb_delete((rt_mailbox_t)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_MESSAGEQUEUE
|
||||||
|
/* delete msgqueues */
|
||||||
|
list = &module->module_object[RT_Object_Class_MessageQueue].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_mq_detach((rt_mq_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_mq_delete((rt_mq_t)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_MEMPOOL
|
||||||
|
/* delete mempools */
|
||||||
|
list = &module->module_object[RT_Object_Class_MemPool].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_mp_detach((rt_mp_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_mp_delete((rt_mp_t)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_DEVICE
|
||||||
|
/* delete devices */
|
||||||
|
list = &module->module_object[RT_Object_Class_Device].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
rt_device_unregister((rt_device_t)object);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* delete timers */
|
||||||
|
list = &module->module_object[RT_Object_Class_Timer].object_list;
|
||||||
|
while(list->next != list)
|
||||||
|
{
|
||||||
|
object = rt_list_entry(list->next, struct rt_object, list);
|
||||||
|
if (rt_object_is_systemobject(object) == RT_EOK)
|
||||||
|
{
|
||||||
|
/* detach static objcet */
|
||||||
|
rt_timer_detach((rt_timer_t)object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* delete dynamic object */
|
||||||
|
rt_timer_delete((rt_timer_t)object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* release module memory */
|
/* release module memory */
|
||||||
rt_free(module->module_space);
|
rt_free(module->module_space);
|
||||||
rt_object_delete((struct rt_object *)module);
|
rt_object_delete((rt_object_t)module);
|
||||||
|
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue