2009-07-03 06:48:23 +08:00
|
|
|
/*
|
2022-07-04 09:38:50 +08:00
|
|
|
* Copyright (c) 2006-2022, RT-Thread Development Team
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
2018-10-14 19:28:18 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2006-04-30 Bernard first implementation
|
|
|
|
* 2006-05-04 Bernard add list_thread,
|
|
|
|
* list_sem,
|
|
|
|
* list_timer
|
|
|
|
* 2006-05-20 Bernard add list_mutex,
|
|
|
|
* list_mailbox,
|
|
|
|
* list_msgqueue,
|
|
|
|
* list_event,
|
|
|
|
* list_fevent,
|
|
|
|
* list_mempool
|
|
|
|
* 2006-06-03 Bernard display stack information in list_thread
|
|
|
|
* 2006-08-10 Bernard change version to invoke rt_show_version
|
|
|
|
* 2008-09-10 Bernard update the list function for finsh syscall
|
|
|
|
* list and sysvar list
|
|
|
|
* 2009-05-30 Bernard add list_device
|
2012-04-29 20:19:29 +08:00
|
|
|
* 2010-04-21 yi.qiu add list_module
|
|
|
|
* 2012-04-29 goprife improve the command line auto-complete feature.
|
2012-06-03 14:16:30 +08:00
|
|
|
* 2012-06-02 lgnq add list_memheap
|
2012-10-22 11:12:21 +08:00
|
|
|
* 2012-10-22 Bernard add MS VC++ patch.
|
2016-06-13 11:08:23 +08:00
|
|
|
* 2016-06-02 armink beautify the list_thread command
|
2018-11-22 14:40:43 +08:00
|
|
|
* 2018-11-22 Jesven list_thread add smp support
|
2021-03-08 18:19:04 +08:00
|
|
|
* 2018-12-27 Jesven Fix the problem that disable interrupt too long in list_thread
|
2018-12-27 16:31:22 +08:00
|
|
|
* Provide protection for the "first layer of objects" when list_*
|
2021-03-08 18:19:04 +08:00
|
|
|
* 2020-04-07 chenhui add clear
|
2022-07-04 09:38:50 +08:00
|
|
|
* 2022-07-02 Stanley Lwin add list command
|
2009-07-03 06:48:23 +08:00
|
|
|
*/
|
|
|
|
|
2018-11-22 14:40:43 +08:00
|
|
|
#include <rthw.h>
|
2009-07-03 06:48:23 +08:00
|
|
|
#include <rtthread.h>
|
2021-08-23 17:30:05 +08:00
|
|
|
#include <string.h>
|
2018-11-07 14:31:32 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_FINSH
|
2021-08-23 17:30:05 +08:00
|
|
|
#include <finsh.h>
|
2010-02-25 00:06:52 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
#define LIST_FIND_OBJ_NR 8
|
|
|
|
|
2020-05-28 20:57:43 +08:00
|
|
|
static long clear(void)
|
2020-04-07 20:19:33 +08:00
|
|
|
{
|
|
|
|
rt_kprintf("\x1b[2J\x1b[H");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
MSH_CMD_EXPORT(clear, clear the terminal screen);
|
2020-04-07 20:19:33 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
extern void rt_show_version(void);
|
2010-04-14 08:40:20 +08:00
|
|
|
long version(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_show_version();
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-03-29 14:41:08 +08:00
|
|
|
MSH_CMD_EXPORT(version, show RT-Thread version information);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_inline void object_split(int len)
|
2016-06-13 11:08:23 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
while (len--) rt_kprintf("-");
|
2016-06-13 13:29:18 +08:00
|
|
|
}
|
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
typedef struct
|
2016-06-13 13:29:18 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_list_t *list;
|
|
|
|
rt_list_t **array;
|
|
|
|
rt_uint8_t type;
|
|
|
|
int nr; /* input: max nr, can't be 0 */
|
|
|
|
int nr_out; /* out: got nr */
|
|
|
|
} list_get_next_t;
|
|
|
|
|
|
|
|
static void list_find_init(list_get_next_t *p, rt_uint8_t type, rt_list_t **array, int nr)
|
|
|
|
{
|
|
|
|
struct rt_object_information *info;
|
|
|
|
rt_list_t *list;
|
|
|
|
|
2018-12-27 17:48:38 +08:00
|
|
|
info = rt_object_get_information((enum rt_object_class_type)type);
|
2018-12-27 16:31:22 +08:00
|
|
|
list = &info->object_list;
|
|
|
|
|
|
|
|
p->list = list;
|
|
|
|
p->type = type;
|
|
|
|
p->array = array;
|
|
|
|
p->nr = nr;
|
|
|
|
p->nr_out = 0;
|
2016-06-13 13:29:18 +08:00
|
|
|
}
|
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
static rt_list_t *list_get_next(rt_list_t *current, list_get_next_t *arg)
|
2016-06-13 13:29:18 +08:00
|
|
|
{
|
2018-12-26 11:51:35 +08:00
|
|
|
int first_flag = 0;
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_list_t *node, *list;
|
|
|
|
rt_list_t **array;
|
|
|
|
int nr;
|
2016-06-02 14:29:44 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
arg->nr_out = 0;
|
|
|
|
|
|
|
|
if (!arg->nr || !arg->type)
|
|
|
|
{
|
|
|
|
return (rt_list_t *)RT_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = arg->list;
|
2018-12-26 11:51:35 +08:00
|
|
|
|
|
|
|
if (!current) /* find first */
|
|
|
|
{
|
|
|
|
node = list;
|
|
|
|
first_flag = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
node = current;
|
|
|
|
}
|
|
|
|
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
if (!first_flag)
|
2018-12-26 11:51:35 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
struct rt_object *obj;
|
2018-12-26 11:51:35 +08:00
|
|
|
/* The node in the list? */
|
2018-12-27 16:31:22 +08:00
|
|
|
obj = rt_list_entry(node, struct rt_object, list);
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != arg->type)
|
2018-12-26 11:51:35 +08:00
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
return (rt_list_t *)RT_NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
nr = 0;
|
|
|
|
array = arg->array;
|
|
|
|
while (1)
|
2018-12-26 11:51:35 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
node = node->next;
|
|
|
|
|
|
|
|
if (node == list)
|
|
|
|
{
|
|
|
|
node = (rt_list_t *)RT_NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nr++;
|
|
|
|
*array++ = node;
|
|
|
|
if (nr == arg->nr)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2018-12-26 11:51:35 +08:00
|
|
|
}
|
2021-03-08 18:19:04 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
arg->nr_out = nr;
|
|
|
|
return node;
|
|
|
|
}
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_thread(void)
|
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
const char *item_title = "thread";
|
|
|
|
int maxlen;
|
2018-12-26 11:51:35 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_Thread, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-26 11:51:35 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
maxlen = RT_NAME_MAX;
|
2018-12-26 11:51:35 +08:00
|
|
|
|
2018-11-22 14:40:43 +08:00
|
|
|
#ifdef RT_USING_SMP
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s cpu bind pri status sp stack size max used left tick error\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" --- ---- --- ------- ---------- ---------- ------ ---------- ---\n");
|
2018-11-22 14:40:43 +08:00
|
|
|
#else
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s pri status sp stack size max used left tick error\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" --- ------- ---------- ---------- ------ ---------- ---\n");
|
2018-11-22 14:40:43 +08:00
|
|
|
#endif /*RT_USING_SMP*/
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
next = list_get_next(next, &find_arg);
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_thread thread_info, *thread;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* copy info */
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_memcpy(&thread_info, obj, sizeof thread_info);
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
thread = (struct rt_thread *)obj;
|
2018-12-27 16:31:22 +08:00
|
|
|
{
|
|
|
|
rt_uint8_t stat;
|
|
|
|
rt_uint8_t *ptr;
|
|
|
|
|
2018-11-22 14:40:43 +08:00
|
|
|
#ifdef RT_USING_SMP
|
2018-12-27 16:31:22 +08:00
|
|
|
if (thread->oncpu != RT_CPU_DETACHED)
|
2023-04-04 21:06:27 +08:00
|
|
|
rt_kprintf("%-*.*s %3d %3d %4d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->oncpu, thread->bind_cpu, thread->current_priority);
|
2018-12-27 16:31:22 +08:00
|
|
|
else
|
2023-04-04 21:06:27 +08:00
|
|
|
rt_kprintf("%-*.*s N/A %3d %4d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->bind_cpu, thread->current_priority);
|
2012-04-23 14:04:12 +08:00
|
|
|
|
2018-11-22 14:40:43 +08:00
|
|
|
#else
|
2023-04-04 21:06:27 +08:00
|
|
|
rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->parent.name, thread->current_priority);
|
2018-11-22 14:40:43 +08:00
|
|
|
#endif /*RT_USING_SMP*/
|
2018-12-27 16:31:22 +08:00
|
|
|
stat = (thread->stat & RT_THREAD_STAT_MASK);
|
|
|
|
if (stat == RT_THREAD_READY) rt_kprintf(" ready ");
|
2022-12-03 12:07:44 +08:00
|
|
|
else if ((stat & RT_THREAD_SUSPEND_MASK) == RT_THREAD_SUSPEND_MASK) rt_kprintf(" suspend");
|
2018-12-27 16:31:22 +08:00
|
|
|
else if (stat == RT_THREAD_INIT) rt_kprintf(" init ");
|
|
|
|
else if (stat == RT_THREAD_CLOSE) rt_kprintf(" close ");
|
2019-01-13 14:22:13 +08:00
|
|
|
else if (stat == RT_THREAD_RUNNING) rt_kprintf(" running");
|
2012-04-23 14:04:12 +08:00
|
|
|
|
2018-11-11 15:56:02 +08:00
|
|
|
#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
|
2018-12-27 16:31:22 +08:00
|
|
|
ptr = (rt_uint8_t *)thread->stack_addr + thread->stack_size - 1;
|
|
|
|
while (*ptr == '#')ptr --;
|
|
|
|
|
|
|
|
rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %03d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
((rt_ubase_t)thread->sp - (rt_ubase_t)thread->stack_addr),
|
|
|
|
thread->stack_size,
|
|
|
|
((rt_ubase_t)ptr - (rt_ubase_t)thread->stack_addr) * 100 / thread->stack_size,
|
|
|
|
thread->remaining_tick,
|
|
|
|
thread->error);
|
2018-11-11 15:56:02 +08:00
|
|
|
#else
|
2018-12-27 16:31:22 +08:00
|
|
|
ptr = (rt_uint8_t *)thread->stack_addr;
|
2022-06-29 14:21:21 +08:00
|
|
|
while (*ptr == '#') ptr ++;
|
|
|
|
rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %s\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
thread->stack_size + ((rt_ubase_t)thread->stack_addr - (rt_ubase_t)thread->sp),
|
|
|
|
thread->stack_size,
|
|
|
|
(thread->stack_size - ((rt_ubase_t) ptr - (rt_ubase_t) thread->stack_addr)) * 100
|
|
|
|
/ thread->stack_size,
|
|
|
|
thread->remaining_tick,
|
2022-06-29 14:21:21 +08:00
|
|
|
rt_strerror(thread->error));
|
2018-11-11 15:56:02 +08:00
|
|
|
#endif
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-04-23 14:04:12 +08:00
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2018-12-26 11:51:35 +08:00
|
|
|
|
|
|
|
return 0;
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
static void show_wait_queue(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_thread *thread;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
|
|
|
thread = rt_list_entry(node, struct rt_thread, tlist);
|
2023-04-04 21:06:27 +08:00
|
|
|
rt_kprintf("%.*s", RT_NAME_MAX, thread->parent.name);
|
2012-12-31 13:33:46 +08:00
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
if (node->next != list)
|
2012-12-31 13:33:46 +08:00
|
|
|
rt_kprintf("/");
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RT_USING_SEMAPHORE
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_sem(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2018-03-13 13:27:37 +08:00
|
|
|
const char *item_title = "semaphore";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_Semaphore, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s v suspend thread\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" --- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_semaphore *sem;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
sem = (struct rt_semaphore *)obj;
|
2018-12-27 16:31:22 +08:00
|
|
|
if (!rt_list_isempty(&sem->parent.suspend_thread))
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %03d %d:",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
sem->parent.parent.name,
|
|
|
|
sem->value,
|
|
|
|
rt_list_len(&sem->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
show_wait_queue(&(sem->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %03d %d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
sem->parent.parent.name,
|
|
|
|
sem->value,
|
|
|
|
rt_list_len(&sem->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_SEMAPHORE */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_EVENT
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_event(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2018-03-13 13:27:37 +08:00
|
|
|
const char *item_title = "event";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_Event, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s set suspend thread\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" ---------- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_event *e;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
e = (struct rt_event *)obj;
|
|
|
|
if (!rt_list_isempty(&e->parent.suspend_thread))
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s 0x%08x %03d:",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
e->parent.parent.name,
|
|
|
|
e->set,
|
|
|
|
rt_list_len(&e->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
show_wait_queue(&(e->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s 0x%08x 0\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX, e->parent.parent.name, e->set);
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_EVENT */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_MUTEX
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_mutex(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2018-03-13 13:27:37 +08:00
|
|
|
const char *item_title = "mutex";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_Mutex, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2018-03-13 13:27:37 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s owner hold priority suspend thread \n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
2022-10-19 11:37:57 +08:00
|
|
|
rt_kprintf(" -------- ---- -------- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_mutex *m;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
m = (struct rt_mutex *)obj;
|
2022-10-19 11:37:57 +08:00
|
|
|
if (!rt_list_isempty(&m->parent.suspend_thread))
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %-8.*s %04d %8d %04d ",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
m->parent.parent.name,
|
|
|
|
RT_NAME_MAX,
|
2023-04-04 21:06:27 +08:00
|
|
|
m->owner->parent.name,
|
2021-08-23 17:30:05 +08:00
|
|
|
m->hold,
|
2022-10-19 11:37:57 +08:00
|
|
|
m->priority,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
|
|
|
show_wait_queue(&(m->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %-8.*s %04d %8d %04d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
m->parent.parent.name,
|
|
|
|
RT_NAME_MAX,
|
2023-04-04 21:06:27 +08:00
|
|
|
m->owner->parent.name,
|
2022-10-19 11:37:57 +08:00
|
|
|
m->hold,
|
|
|
|
m->priority,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
|
|
|
}
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_MUTEX */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_MAILBOX
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_mailbox(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2016-09-07 23:45:39 +08:00
|
|
|
const char *item_title = "mailbox";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_MailBox, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s entry size suspend thread\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" ---- ---- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_mailbox *m;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
m = (struct rt_mailbox *)obj;
|
|
|
|
if (!rt_list_isempty(&m->parent.suspend_thread))
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %04d %04d %d:",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
m->size,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
show_wait_queue(&(m->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %04d %04d %d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
m->size,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_MAILBOX */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_MESSAGEQUEUE
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_msgqueue(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2016-09-07 23:45:39 +08:00
|
|
|
const char *item_title = "msgqueue";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_MessageQueue, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s entry suspend thread\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" ---- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_messagequeue *m;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
m = (struct rt_messagequeue *)obj;
|
|
|
|
if (!rt_list_isempty(&m->parent.suspend_thread))
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %04d %d:",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
show_wait_queue(&(m->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %04d %d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_MESSAGEQUEUE */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
#ifdef RT_USING_MEMHEAP
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_memheap(void)
|
2012-06-03 14:16:30 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2018-03-13 13:27:37 +08:00
|
|
|
const char *item_title = "memheap";
|
2012-06-03 14:16:30 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_MemHeap, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s pool size max used size available size\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" ---------- ------------- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
do
|
2012-06-03 14:16:30 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_memheap *mh;
|
2012-06-03 14:16:30 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
2012-06-03 14:16:30 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_hw_interrupt_enable(level);
|
2017-12-12 07:38:02 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
mh = (struct rt_memheap *)obj;
|
|
|
|
|
|
|
|
rt_kprintf("%-*.*s %-010d %-013d %-05d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
mh->parent.name,
|
|
|
|
mh->pool_size,
|
|
|
|
mh->max_used_size,
|
|
|
|
mh->available_size);
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
return 0;
|
2012-06-03 14:16:30 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_MEMHEAP */
|
2012-06-03 14:16:30 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifdef RT_USING_MEMPOOL
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_mempool(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2018-03-13 13:27:37 +08:00
|
|
|
const char *item_title = "mempool";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_MemPool, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s block total free suspend thread\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" ---- ---- ---- --------------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_mempool *mp;
|
2019-09-16 16:55:40 +08:00
|
|
|
int suspend_thread_count;
|
|
|
|
rt_list_t *node;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
mp = (struct rt_mempool *)obj;
|
2019-09-16 16:55:40 +08:00
|
|
|
|
|
|
|
suspend_thread_count = 0;
|
2019-09-17 11:02:34 +08:00
|
|
|
rt_list_for_each(node, &mp->suspend_thread)
|
2019-09-16 16:55:40 +08:00
|
|
|
{
|
|
|
|
suspend_thread_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (suspend_thread_count > 0)
|
2018-12-27 16:31:22 +08:00
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %04d %04d %04d %d:",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
mp->parent.name,
|
|
|
|
mp->block_size,
|
|
|
|
mp->block_total_count,
|
|
|
|
mp->block_free_count,
|
|
|
|
suspend_thread_count);
|
2018-12-27 16:31:22 +08:00
|
|
|
show_wait_queue(&(mp->suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("%-*.*s %04d %04d %04d %d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
mp->parent.name,
|
|
|
|
mp->block_size,
|
|
|
|
mp->block_total_count,
|
|
|
|
mp->block_free_count,
|
|
|
|
suspend_thread_count);
|
2018-12-27 16:31:22 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_MEMPOOL */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2018-12-27 16:31:22 +08:00
|
|
|
long list_timer(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2018-03-13 13:27:37 +08:00
|
|
|
const char *item_title = "timer";
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_Timer, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s periodic timeout activated mode\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
2021-11-25 15:30:36 +08:00
|
|
|
rt_kprintf(" ---------- ---------- ----------- ---------\n");
|
2021-08-23 17:30:05 +08:00
|
|
|
do
|
2021-11-25 15:33:50 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_timer *timer;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
timer = (struct rt_timer *)obj;
|
|
|
|
rt_kprintf("%-*.*s 0x%08x 0x%08x ",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
timer->parent.name,
|
|
|
|
timer->init_tick,
|
|
|
|
timer->timeout_tick);
|
2018-12-27 16:31:22 +08:00
|
|
|
if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
|
2021-11-25 15:30:36 +08:00
|
|
|
rt_kprintf("activated ");
|
|
|
|
else
|
|
|
|
rt_kprintf("deactivated ");
|
|
|
|
if (timer->parent.flag & RT_TIMER_FLAG_PERIODIC)
|
|
|
|
rt_kprintf("periodic\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
else
|
2021-11-25 15:30:36 +08:00
|
|
|
rt_kprintf("one shot\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
rt_kprintf("current tick:0x%08x\n", rt_tick_get());
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RT_USING_DEVICE
|
2022-04-19 22:46:42 +08:00
|
|
|
static char *const device_type_str[RT_Device_Class_Unknown] =
|
2018-12-27 16:31:22 +08:00
|
|
|
{
|
|
|
|
"Character Device",
|
|
|
|
"Block Device",
|
|
|
|
"Network Interface",
|
|
|
|
"MTD Device",
|
|
|
|
"CAN Device",
|
|
|
|
"RTC",
|
|
|
|
"Sound Device",
|
|
|
|
"Graphic Device",
|
|
|
|
"I2C Bus",
|
|
|
|
"USB Slave Device",
|
|
|
|
"USB Host Bus",
|
2021-08-17 18:20:13 +08:00
|
|
|
"USB OTG Bus",
|
2018-12-27 16:31:22 +08:00
|
|
|
"SPI Bus",
|
|
|
|
"SPI Device",
|
|
|
|
"SDIO Bus",
|
|
|
|
"PM Pseudo Device",
|
|
|
|
"Pipe",
|
|
|
|
"Portal Device",
|
|
|
|
"Timer Device",
|
|
|
|
"Miscellaneous Device",
|
2019-02-12 10:15:26 +08:00
|
|
|
"Sensor Device",
|
2019-06-12 09:38:32 +08:00
|
|
|
"Touch Device",
|
2020-10-12 18:15:01 +08:00
|
|
|
"Phy Device",
|
2021-03-19 13:26:12 +08:00
|
|
|
"Security Device",
|
2022-04-07 15:46:38 +08:00
|
|
|
"WLAN Device",
|
|
|
|
"Pin Device",
|
|
|
|
"ADC Device",
|
|
|
|
"DAC Device",
|
|
|
|
"WDT Device",
|
|
|
|
"PWM Device",
|
2023-06-17 10:33:03 +08:00
|
|
|
"Bus Device",
|
2018-12-27 16:31:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
long list_device(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2022-04-20 10:56:11 +08:00
|
|
|
rt_base_t level;
|
2018-12-27 16:31:22 +08:00
|
|
|
list_get_next_t find_arg;
|
|
|
|
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
|
2021-08-23 17:30:05 +08:00
|
|
|
rt_list_t *next = (rt_list_t *)RT_NULL;
|
2022-04-19 22:46:42 +08:00
|
|
|
const char *device_type;
|
2018-12-27 16:31:22 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2016-09-07 23:45:39 +08:00
|
|
|
const char *item_title = "device";
|
|
|
|
|
2021-08-23 17:30:05 +08:00
|
|
|
list_find_init(&find_arg, RT_Object_Class_Device, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
maxlen = RT_NAME_MAX;
|
2016-06-13 13:29:18 +08:00
|
|
|
|
2022-12-21 16:09:53 +08:00
|
|
|
rt_kprintf("%-*.*s type ref count\n", maxlen, maxlen, item_title);
|
2021-08-23 17:30:05 +08:00
|
|
|
object_split(maxlen);
|
|
|
|
rt_kprintf(" -------------------- ----------\n");
|
2018-12-27 16:31:22 +08:00
|
|
|
do
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2018-12-27 16:31:22 +08:00
|
|
|
next = list_get_next(next, &find_arg);
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < find_arg.nr_out; i++)
|
|
|
|
{
|
|
|
|
struct rt_object *obj;
|
|
|
|
struct rt_device *device;
|
|
|
|
|
|
|
|
obj = rt_list_entry(obj_list[i], struct rt_object, list);
|
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
|
|
|
|
{
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_hw_interrupt_enable(level);
|
|
|
|
|
|
|
|
device = (struct rt_device *)obj;
|
2022-04-19 22:46:42 +08:00
|
|
|
device_type = "Unknown";
|
|
|
|
if (device->type < RT_Device_Class_Unknown &&
|
|
|
|
device_type_str[device->type] != RT_NULL)
|
|
|
|
{
|
|
|
|
device_type = device_type_str[device->type];
|
|
|
|
}
|
2018-12-27 16:31:22 +08:00
|
|
|
rt_kprintf("%-*.*s %-20s %-8d\n",
|
2021-08-23 17:30:05 +08:00
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
device->parent.name,
|
2022-04-19 22:46:42 +08:00
|
|
|
device_type,
|
2021-08-23 17:30:05 +08:00
|
|
|
device->ref_count);
|
2018-12-27 16:31:22 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
2021-08-23 17:30:05 +08:00
|
|
|
while (next != (rt_list_t *)RT_NULL);
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_DEVICE */
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2022-07-04 09:38:50 +08:00
|
|
|
int cmd_list(int argc, char **argv)
|
|
|
|
{
|
|
|
|
if(argc == 2)
|
|
|
|
{
|
|
|
|
if(strcmp(argv[1], "thread") == 0)
|
|
|
|
{
|
|
|
|
list_thread();
|
|
|
|
}
|
|
|
|
else if(strcmp(argv[1], "timer") == 0)
|
|
|
|
{
|
|
|
|
list_timer();
|
|
|
|
}
|
|
|
|
#ifdef RT_USING_SEMAPHORE
|
|
|
|
else if(strcmp(argv[1], "sem") == 0)
|
|
|
|
{
|
|
|
|
list_sem();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_SEMAPHORE */
|
|
|
|
#ifdef RT_USING_EVENT
|
|
|
|
else if(strcmp(argv[1], "event") == 0)
|
|
|
|
{
|
|
|
|
list_event();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_EVENT */
|
|
|
|
#ifdef RT_USING_MUTEX
|
|
|
|
else if(strcmp(argv[1], "mutex") == 0)
|
|
|
|
{
|
|
|
|
list_mutex();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_MUTEX */
|
|
|
|
#ifdef RT_USING_MAILBOX
|
|
|
|
else if(strcmp(argv[1], "mailbox") == 0)
|
|
|
|
{
|
|
|
|
list_mailbox();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_MAILBOX */
|
|
|
|
#ifdef RT_USING_MESSAGEQUEUE
|
|
|
|
else if(strcmp(argv[1], "msgqueue") == 0)
|
|
|
|
{
|
|
|
|
list_msgqueue();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_MESSAGEQUEUE */
|
2022-11-19 03:37:05 +08:00
|
|
|
#ifdef RT_USING_MEMHEAP
|
|
|
|
else if(strcmp(argv[1], "memheap") == 0)
|
|
|
|
{
|
|
|
|
list_memheap();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_MEMHEAP */
|
2022-07-04 09:38:50 +08:00
|
|
|
#ifdef RT_USING_MEMPOOL
|
|
|
|
else if(strcmp(argv[1], "mempool") == 0)
|
|
|
|
{
|
|
|
|
list_mempool();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_MEMPOOL */
|
|
|
|
#ifdef RT_USING_DEVICE
|
|
|
|
else if(strcmp(argv[1], "device") == 0)
|
|
|
|
{
|
|
|
|
list_device();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_DEVICE */
|
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
else if(strcmp(argv[1], "fd") == 0)
|
|
|
|
{
|
|
|
|
extern int list_fd(void);
|
|
|
|
list_fd();
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_DFS */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
goto _usage;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_usage:
|
|
|
|
rt_kprintf("Usage: list [options]\n");
|
|
|
|
rt_kprintf("[options]:\n");
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list threads\n", "thread");
|
|
|
|
rt_kprintf(" %-12s - list timers\n", "timer");
|
2022-07-04 09:38:50 +08:00
|
|
|
#ifdef RT_USING_SEMAPHORE
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list semaphores\n", "sem");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_SEMAPHORE */
|
|
|
|
#ifdef RT_USING_MUTEX
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list mutexs\n", "mutex");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_MUTEX */
|
|
|
|
#ifdef RT_USING_EVENT
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list events\n", "event");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_EVENT */
|
|
|
|
#ifdef RT_USING_MAILBOX
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list mailboxs\n", "mailbox");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_MAILBOX */
|
|
|
|
#ifdef RT_USING_MESSAGEQUEUE
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list message queues\n", "msgqueue");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_MESSAGEQUEUE */
|
2022-11-19 03:37:05 +08:00
|
|
|
#ifdef RT_USING_MEMHEAP
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list memory heaps\n", "memheap");
|
2022-11-19 03:37:05 +08:00
|
|
|
#endif /* RT_USING_MEMHEAP */
|
2022-07-04 09:38:50 +08:00
|
|
|
#ifdef RT_USING_MEMPOOL
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list memory pools\n", "mempool");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_MEMPOOL */
|
|
|
|
#ifdef RT_USING_DEVICE
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list devices\n", "device");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_DEVICE */
|
|
|
|
#ifdef RT_USING_DFS
|
2022-12-06 18:00:13 +08:00
|
|
|
rt_kprintf(" %-12s - list file descriptors\n", "fd");
|
2022-07-04 09:38:50 +08:00
|
|
|
#endif /* RT_USING_DFS */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
MSH_CMD_EXPORT_ALIAS(cmd_list, list, list objects);
|
|
|
|
|
2018-11-07 14:31:32 +08:00
|
|
|
#endif /* RT_USING_FINSH */
|