module developing

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@625 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
qiuyiuestc 2010-04-16 00:53:48 +00:00
parent 9921361162
commit 0d7a1c0be7
4 changed files with 149 additions and 5 deletions

View File

@ -344,13 +344,44 @@ int list_module(void)
list = &rt_object_container[RT_Object_Class_Module].object_list; list = &rt_object_container[RT_Object_Class_Module].object_list;
rt_kprintf("module entry stack size\n"); rt_kprintf("module entry stack size\n");
rt_kprintf("-------- ---------- ----------\n"); rt_kprintf("-------- ---------- ----------\n");
for (node = list->next; node != list; node = node->next) for (node = list->next; node != list; node = node->next)
{ {
struct rt_thread *thread;
struct rt_list_node *tlist, *tnode;
rt_uint8_t* ptr;
module = (struct rt_device*)(rt_list_entry(node, struct rt_object, list)); module = (struct rt_device*)(rt_list_entry(node, struct rt_object, list));
rt_kprintf("%-8s 0x%08x 0x%08x \n", module->parent.name, (rt_uint32_t)module->module_entry, rt_kprintf("%-8s 0x%08x 0x%08x \n", module->parent.name, (rt_uint32_t)module->module_entry,
module->stack_size); module->stack_size);
tlist = &module->module_object[RT_Object_Class_Thread].object_list;
if(tlist->next != tlist)
{
rt_kprintf(" sub-thread pri status sp stack size max used left tick error\n");
rt_kprintf("-------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
}
for (tnode = tlist->next; tnode != tlist; tnode = tnode->next)
{
thread = rt_list_entry(tnode, struct rt_thread, tlist);
rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
ptr = (rt_uint8_t*)thread->stack_addr;
while (*ptr == '#')ptr ++;
rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
thread->stack_size,
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
thread->remaining_tick,
thread->error);
}
} }
return 0; return 0;

View File

@ -186,6 +186,10 @@ struct rt_module* rt_module_load(void* module_ptr, const rt_uint8_t* name)
struct rt_module* module = RT_NULL; struct rt_module* module = RT_NULL;
rt_uint8_t *ptr, *strtab, *shstrab; rt_uint8_t *ptr, *strtab, *shstrab;
#ifdef RT_MODULE_DEBUG
rt_kprintf("rt_module_load: %s\n", name);
#endif
/* check ELF header */ /* check ELF header */
if (rt_memcmp(elf_module->e_ident, ELFMAG, SELFMAG) != 0 || if (rt_memcmp(elf_module->e_ident, ELFMAG, SELFMAG) != 0 ||
elf_module->e_ident[EI_CLASS] != ELFCLASS32) elf_module->e_ident[EI_CLASS] != ELFCLASS32)

112
src/rtm.c
View File

@ -17,7 +17,9 @@
/* some buildin kernel symbol */ /* some buildin kernel symbol */
/* thread symbol */ /*
* thread interface symbol
*/
RTM_EXPORT(rt_thread_init) RTM_EXPORT(rt_thread_init)
RTM_EXPORT(rt_thread_detach) RTM_EXPORT(rt_thread_detach)
RTM_EXPORT(rt_thread_create) RTM_EXPORT(rt_thread_create)
@ -32,5 +34,111 @@ RTM_EXPORT(rt_thread_suspend)
RTM_EXPORT(rt_thread_resume) RTM_EXPORT(rt_thread_resume)
RTM_EXPORT(rt_thread_timeout) RTM_EXPORT(rt_thread_timeout)
/* kservice symbol */ #ifdef RT_USING_SEMAPHORE
/*
* semaphore interface symbol
*/
RTM_EXPORT(rt_sem_init)
RTM_EXPORT(rt_sem_detach)
RTM_EXPORT(rt_sem_create)
RTM_EXPORT(rt_sem_delete)
RTM_EXPORT(rt_sem_take)
RTM_EXPORT(rt_sem_trytake)
RTM_EXPORT(rt_sem_release)
RTM_EXPORT(rt_sem_control)
#endif
#ifdef RT_USING_MUTEX
/*
* mutex interface symbol
*/
RTM_EXPORT(rt_mutex_init)
RTM_EXPORT(rt_mutex_detach)
RTM_EXPORT(rt_mutex_create)
RTM_EXPORT(rt_mutex_delete)
RTM_EXPORT(rt_mutex_take)
RTM_EXPORT(rt_mutex_release)
RTM_EXPORT(rt_mutex_control)
#endif
#ifdef RT_USING_EVENT
/*
* event interface symbol
*/
RTM_EXPORT(rt_event_init)
RTM_EXPORT(rt_event_detach)
RTM_EXPORT(rt_event_create)
RTM_EXPORT(rt_event_delete)
RTM_EXPORT(rt_event_send)
RTM_EXPORT(rt_event_recv)
RTM_EXPORT(rt_event_control)
#endif
#ifdef RT_USING_MAILBOX
/*
* mailbox interface symbol
*/
RTM_EXPORT(rt_mb_init)
RTM_EXPORT(rt_mb_detach)
RTM_EXPORT(rt_mb_create)
RTM_EXPORT(rt_mb_delete)
RTM_EXPORT(rt_mb_send)
RTM_EXPORT(rt_mb_recv)
RTM_EXPORT(rt_mb_control)
#endif
#ifdef RT_USING_MESSAGEQUEUE
/*
* message queue interface symbol
*/
RTM_EXPORT(rt_mq_init)
RTM_EXPORT(rt_mq_detach)
RTM_EXPORT(rt_mq_create)
RTM_EXPORT(rt_mq_delete)
RTM_EXPORT(rt_mq_send)
RTM_EXPORT(rt_mq_urgent)
RTM_EXPORT(rt_mq_recv)
RTM_EXPORT(rt_mq_control)
#endif
#ifdef RT_USING_MEMPOOL
/*
* memory pool interface symbol
*/
RTM_EXPORT(rt_mp_init)
RTM_EXPORT(rt_mp_detach)
RTM_EXPORT(rt_mp_create)
RTM_EXPORT(rt_mp_delete)
RTM_EXPORT(rt_mp_alloc)
RTM_EXPORT(rt_mp_free)
#endif
#ifdef RT_USING_HEAP
/*
* heap memory interface symbol
*/
RTM_EXPORT(rt_malloc)
RTM_EXPORT(rt_free)
RTM_EXPORT(rt_realloc)
RTM_EXPORT(rt_calloc)
#endif
/*
* clock & timer interface symbol
*/
RTM_EXPORT(rt_tick_get)
RTM_EXPORT(rt_tick_from_millisecond)
RTM_EXPORT(rt_system_timer_init)
RTM_EXPORT(rt_system_timer_thread_init)
RTM_EXPORT(rt_timer_init)
RTM_EXPORT(rt_timer_detach)
RTM_EXPORT(rt_timer_create)
RTM_EXPORT(rt_timer_delete)
RTM_EXPORT(rt_timer_start)
RTM_EXPORT(rt_timer_stop)
RTM_EXPORT(rt_timer_control)
/*
* kservice interface symbol
*/
RTM_EXPORT(rt_kprintf) RTM_EXPORT(rt_kprintf)

View File

@ -19,6 +19,7 @@
* 2006-09-05 Bernard add 32 priority level support * 2006-09-05 Bernard add 32 priority level support
* 2006-09-24 Bernard add rt_system_scheduler_start function * 2006-09-24 Bernard add rt_system_scheduler_start function
* 2009-09-16 Bernard fix _rt_scheduler_stack_check * 2009-09-16 Bernard fix _rt_scheduler_stack_check
* 2010-04-11 yi.qiu add module feature
*/ */
#include <rtthread.h> #include <rtthread.h>
@ -264,8 +265,8 @@ void rt_schedule()
rt_current_thread = to_thread; rt_current_thread = to_thread;
#ifdef RT_USING_MODULE #ifdef RT_USING_MODULE
if(rt_current_thread->module_parent != RT_NULL) rt_current_module = (rt_current_thread->module_parent != RT_NULL) ?
rt_current_module = rt_current_thread->module_parent; rt_current_thread->module_parent : RT_NULL;
#endif #endif
#ifdef RT_USING_HOOK #ifdef RT_USING_HOOK