mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-03-27 09:32:28 +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 */
|
||||
|
||||
18
src/idle.c
18
src/idle.c
@@ -175,24 +175,6 @@ void rt_thread_idle_excute(void)
|
||||
/* delete thread object */
|
||||
rt_object_delete((rt_object_t)thread);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
if (module != RT_NULL)
|
||||
{
|
||||
extern rt_err_t rt_module_destroy(rt_module_t module);
|
||||
|
||||
/* 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))
|
||||
{
|
||||
module->nref --;
|
||||
}
|
||||
|
||||
/* destroy module */
|
||||
if (module->nref == 0)
|
||||
rt_module_destroy(module);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
751
src/module.c
751
src/module.c
File diff suppressed because it is too large
Load Diff
74
src/object.c
74
src/object.c
@@ -252,15 +252,9 @@ void rt_object_init(struct rt_object *object,
|
||||
register rt_base_t temp;
|
||||
struct rt_object_information *information;
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
/* get module object information */
|
||||
information = (rt_module_self() != RT_NULL) ?
|
||||
&rt_module_self()->module_object[type] : rt_object_get_information(type);
|
||||
#else
|
||||
/* get object information */
|
||||
information = rt_object_get_information(type);
|
||||
RT_ASSERT(information != RT_NULL);
|
||||
#endif
|
||||
|
||||
/* initialize object's parameters */
|
||||
|
||||
@@ -324,18 +318,9 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
|
||||
|
||||
RT_DEBUG_NOT_IN_INTERRUPT;
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
/*
|
||||
* get module object information,
|
||||
* module object should be managed by kernel object container
|
||||
*/
|
||||
information = (rt_module_self() != RT_NULL && (type != RT_Object_Class_Module)) ?
|
||||
&rt_module_self()->module_object[type] : rt_object_get_information(type);
|
||||
#else
|
||||
/* get object information */
|
||||
information = rt_object_get_information(type);
|
||||
RT_ASSERT(information != RT_NULL);
|
||||
#endif
|
||||
|
||||
object = (struct rt_object *)RT_KERNEL_MALLOC(information->object_size);
|
||||
if (object == RT_NULL)
|
||||
@@ -458,65 +443,6 @@ rt_object_t rt_object_find(const char *name, rt_uint8_t type)
|
||||
/* which is invoke in interrupt status */
|
||||
RT_DEBUG_NOT_IN_INTERRUPT;
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
/* check whether to find a object inside a module. */
|
||||
{
|
||||
const char *name_ptr;
|
||||
int module_name_length;
|
||||
|
||||
name_ptr = name;
|
||||
while ((*name_ptr != '\0') && (*name_ptr != '/'))
|
||||
name_ptr ++;
|
||||
|
||||
if (*name_ptr == '/')
|
||||
{
|
||||
struct rt_module *module = RT_NULL;
|
||||
|
||||
/* get the name length of module */
|
||||
module_name_length = name_ptr - name;
|
||||
|
||||
/* enter critical */
|
||||
rt_enter_critical();
|
||||
|
||||
/* find module */
|
||||
information = rt_object_get_information(RT_Object_Class_Module);
|
||||
RT_ASSERT(information != RT_NULL);
|
||||
|
||||
for (node = information->object_list.next;
|
||||
node != &(information->object_list);
|
||||
node = node->next)
|
||||
{
|
||||
object = rt_list_entry(node, struct rt_object, list);
|
||||
if ((rt_strncmp(object->name, name, module_name_length) == 0) &&
|
||||
(module_name_length == RT_NAME_MAX || object->name[module_name_length] == '\0'))
|
||||
{
|
||||
/* get module */
|
||||
module = (struct rt_module *)object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rt_exit_critical();
|
||||
|
||||
/* there is no this module inside the system */
|
||||
if (module == RT_NULL) return RT_NULL;
|
||||
|
||||
/* get the object pool of module */
|
||||
information = &(module->module_object[type]);
|
||||
|
||||
/* get object name */
|
||||
while ((*name_ptr == '/') && (*name_ptr != '\0')) name_ptr ++;
|
||||
if (*name_ptr == '\0')
|
||||
{
|
||||
if (type == RT_Object_Class_Module) return object;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
/* point to the object name */
|
||||
name = name_ptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* enter critical */
|
||||
rt_enter_critical();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user