mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-24 05:04:10 +08:00
[Kernel] Remove object container in module feature.
This commit is contained in:
@@ -614,113 +614,6 @@ int list_module(void)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(list_module, list module in system);
|
||||
MSH_CMD_EXPORT(list_module, list module in system);
|
||||
|
||||
int list_mod_detail(const char *name)
|
||||
{
|
||||
int i;
|
||||
struct rt_module *module;
|
||||
|
||||
/* find module */
|
||||
if ((module = rt_module_find(name)) != RT_NULL)
|
||||
{
|
||||
/* module has entry point */
|
||||
if (!(module->parent.flag & RT_MODULE_FLAG_WITHOUTENTRY))
|
||||
{
|
||||
struct rt_thread *thread;
|
||||
struct rt_list_node *tlist;
|
||||
rt_uint8_t *ptr;
|
||||
|
||||
/* list main thread in module */
|
||||
if (module->module_thread != RT_NULL)
|
||||
{
|
||||
rt_uint8_t stat;
|
||||
|
||||
rt_kprintf("main thread pri status sp stack size max used left tick error\n");
|
||||
rt_kprintf("------------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
|
||||
thread = module->module_thread;
|
||||
rt_kprintf("%-8.*s 0x%02x", RT_NAME_MAX, thread->name, thread->current_priority);
|
||||
|
||||
stat = (thread->stat & RT_THREAD_STAT_MASK);
|
||||
if (stat == RT_THREAD_READY) rt_kprintf(" ready ");
|
||||
else if (stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
|
||||
else if (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);
|
||||
}
|
||||
|
||||
/* list sub thread in module */
|
||||
tlist = &module->module_object[RT_Object_Class_Thread].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_thread(tlist);
|
||||
#ifdef RT_USING_SEMAPHORE
|
||||
/* list semaphored in module */
|
||||
tlist = &module->module_object[RT_Object_Class_Semaphore].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_sem(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_MUTEX
|
||||
/* list mutex in module */
|
||||
tlist = &module->module_object[RT_Object_Class_Mutex].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_mutex(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_EVENT
|
||||
/* list event in module */
|
||||
tlist = &module->module_object[RT_Object_Class_Event].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_event(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_MAILBOX
|
||||
/* list mailbox in module */
|
||||
tlist = &module->module_object[RT_Object_Class_MailBox].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_mailbox(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_MESSAGEQUEUE
|
||||
/* list message queue in module */
|
||||
tlist = &module->module_object[RT_Object_Class_MessageQueue].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_msgqueue(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_MEMHEAP
|
||||
/* list memory heap in module */
|
||||
tlist = &module->module_object[RT_Object_Class_MemHeap].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_memheap(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_MEMPOOL
|
||||
/* list memory pool in module */
|
||||
tlist = &module->module_object[RT_Object_Class_MemPool].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_mempool(tlist);
|
||||
#endif
|
||||
#ifdef RT_USING_DEVICE
|
||||
/* list device in module */
|
||||
tlist = &module->module_object[RT_Object_Class_Device].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_device(tlist);
|
||||
#endif
|
||||
/* list timer in module */
|
||||
tlist = &module->module_object[RT_Object_Class_Timer].object_list;
|
||||
if (!rt_list_isempty(tlist)) _list_timer(tlist);
|
||||
}
|
||||
|
||||
if (module->nsym > 0)
|
||||
{
|
||||
rt_kprintf("symbol address \n");
|
||||
rt_kprintf("-------- ----------\n");
|
||||
|
||||
/* list module export symbols */
|
||||
for (i = 0; i < module->nsym; i++)
|
||||
{
|
||||
rt_kprintf("%s 0x%x\n",
|
||||
module->symtab[i].name, module->symtab[i].addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system)
|
||||
#endif
|
||||
|
||||
long list(void)
|
||||
|
||||
@@ -333,7 +333,7 @@ int msh_exec(char *cmd, rt_size_t length)
|
||||
{
|
||||
return cmd_ret;
|
||||
}
|
||||
#ifdef RT_USING_MODULE
|
||||
#if defined(RT_USING_MODULE) && defined(RT_USING_DFS)
|
||||
if (msh_exec_module(cmd, length) == 0)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_PTHREADS
|
||||
#ifdef RT_USING_PTHREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
@@ -126,7 +126,7 @@ _open_r(struct _reent *ptr, const char *file, int flags, int mode)
|
||||
#endif
|
||||
}
|
||||
|
||||
_ssize_t
|
||||
_ssize_t
|
||||
_read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
|
||||
{
|
||||
#ifndef RT_USING_DFS
|
||||
@@ -372,7 +372,7 @@ void *_calloc_r (struct _reent *ptr, size_t size, size_t len)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
_free_r (struct _reent *ptr, void *addr)
|
||||
{
|
||||
rt_free (addr);
|
||||
@@ -387,43 +387,20 @@ _exit (int status)
|
||||
module = rt_module_self();
|
||||
if (module != RT_NULL)
|
||||
{
|
||||
struct rt_list_node *list;
|
||||
struct rt_object *object;
|
||||
|
||||
rt_enter_critical();
|
||||
|
||||
/* delete all threads in the module */
|
||||
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_TRUE)
|
||||
{
|
||||
/* detach static object */
|
||||
rt_thread_detach((rt_thread_t)object);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* delete dynamic object */
|
||||
rt_thread_delete((rt_thread_t)object);
|
||||
}
|
||||
}
|
||||
/* delete main thread */
|
||||
rt_thread_delete(module->module_thread);
|
||||
rt_exit_critical();
|
||||
rt_thread_suspend(rt_thread_self());
|
||||
|
||||
/* re-schedule */
|
||||
rt_schedule();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
rt_kprintf("thread:%s exit with %d\n", rt_thread_self()->name, status);
|
||||
RT_ASSERT(0);
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
_system(const char *s)
|
||||
{
|
||||
/* not support this call */
|
||||
|
||||
Reference in New Issue
Block a user