2009-07-03 06:48:23 +08:00
|
|
|
/*
|
2013-03-30 16:14:38 +08:00
|
|
|
* RT-Thread finsh shell commands
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
2013-03-30 16:14:38 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* This file is part of RT-Thread (http://www.rt-thread.org)
|
|
|
|
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
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
|
2009-07-03 06:48:23 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
2010-02-25 00:06:52 +08:00
|
|
|
#include "finsh.h"
|
|
|
|
|
|
|
|
rt_inline unsigned int rt_list_len(const rt_list_t *l)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
unsigned int len = 0;
|
|
|
|
const rt_list_t *p = l;
|
2012-06-03 14:16:30 +08:00
|
|
|
while (p->next != l)
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
|
|
|
p = p->next;
|
2012-06-03 14:16:30 +08:00
|
|
|
len ++;
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
2012-12-31 13:33:46 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
return len;
|
2010-01-19 11:17:37 +08:00
|
|
|
}
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2010-04-14 08:40:20 +08:00
|
|
|
long hello(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("Hello RT-Thread!\n");
|
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
|
|
|
}
|
2010-02-25 00:06:52 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(hello, say hello world);
|
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
|
|
|
}
|
2010-02-25 00:06:52 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(version, show RT-Thread version information);
|
2014-01-05 14:57:58 +08:00
|
|
|
MSH_CMD_EXPORT(version, show RT-Thread version information);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
extern struct rt_object_information rt_object_container[];
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
static int object_name_maxlen(struct rt_list_node *list)
|
2016-06-13 11:08:23 +08:00
|
|
|
{
|
2012-04-23 14:04:12 +08:00
|
|
|
struct rt_list_node *node;
|
2016-06-13 13:29:18 +08:00
|
|
|
struct rt_object *object = NULL;
|
|
|
|
int max_length = 0, length;
|
2012-04-23 14:04:12 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_enter_critical();
|
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
|
|
|
object = rt_list_entry(node, struct rt_object, list);
|
2016-06-02 14:29:44 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
length = rt_strlen(object->name);
|
|
|
|
if (length > max_length) max_length = length;
|
2016-06-02 14:29:44 +08:00
|
|
|
}
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_exit_critical();
|
|
|
|
|
|
|
|
if (max_length > RT_NAME_MAX || max_length == 0) max_length = RT_NAME_MAX;
|
|
|
|
|
|
|
|
return max_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_inline void object_split(int len)
|
|
|
|
{
|
|
|
|
while (len--) rt_kprintf("-");
|
|
|
|
}
|
|
|
|
|
|
|
|
static long _list_thread(struct rt_list_node *list)
|
|
|
|
{
|
|
|
|
int maxlen;
|
|
|
|
rt_uint8_t *ptr;
|
|
|
|
struct rt_thread *thread;
|
|
|
|
struct rt_list_node *node;
|
2016-06-02 14:29:44 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
2016-07-13 09:37:23 +08:00
|
|
|
rt_kprintf("%-*.s pri status sp stack size max used left tick error\n", maxlen, "thread"); object_split(maxlen);
|
|
|
|
rt_kprintf( " --- ------- ---------- ---------- ------ ---------- ---\n");
|
2012-04-23 14:04:12 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
|
|
|
thread = rt_list_entry(node, struct rt_thread, list);
|
2016-07-13 09:37:23 +08:00
|
|
|
rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority);
|
2012-04-23 14:04:12 +08:00
|
|
|
|
|
|
|
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 ");
|
|
|
|
else if (thread->stat == RT_THREAD_CLOSE) rt_kprintf(" close ");
|
|
|
|
|
2015-10-11 15:38:08 +08:00
|
|
|
ptr = (rt_uint8_t *)thread->stack_addr;
|
2012-04-23 14:04:12 +08:00
|
|
|
while (*ptr == '#')ptr ++;
|
|
|
|
|
2016-06-02 14:29:44 +08:00
|
|
|
rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %03d\n",
|
2015-10-11 15:38:08 +08:00
|
|
|
thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
|
|
|
|
thread->stack_size,
|
2016-06-02 14:29:44 +08:00
|
|
|
(thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t) thread->stack_addr)) * 100
|
|
|
|
/ thread->stack_size,
|
2015-10-11 15:38:08 +08:00
|
|
|
thread->remaining_tick,
|
|
|
|
thread->error);
|
2012-04-23 14:04:12 +08:00
|
|
|
}
|
2015-10-11 15:38:08 +08:00
|
|
|
|
2012-04-23 14:04:12 +08:00
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_thread(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_thread(&rt_object_container[RT_Object_Class_Thread].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2010-02-25 00:06:52 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_thread, list thread);
|
2014-01-05 14:57:58 +08:00
|
|
|
MSH_CMD_EXPORT(list_thread, list thread);
|
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);
|
|
|
|
rt_kprintf("%s", thread->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
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_sem(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_semaphore *sem;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
if (maxlen < 9) maxlen = 9;
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s v suspend thread\n", maxlen, "semaphore"); object_split(maxlen);
|
|
|
|
rt_kprintf( " --- --------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
sem = (struct rt_semaphore *)(rt_list_entry(node, struct rt_object, list));
|
2012-12-31 13:33:46 +08:00
|
|
|
if (!rt_list_isempty(&sem->parent.suspend_thread))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %03d %d:",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
sem->parent.parent.name,
|
|
|
|
sem->value,
|
|
|
|
rt_list_len(&sem->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
show_wait_queue(&(sem->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %03d %d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
sem->parent.parent.name,
|
|
|
|
sem->value,
|
|
|
|
rt_list_len(&sem->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_sem(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_sem(&rt_object_container[RT_Object_Class_Semaphore].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_sem, list semaphone in system);
|
|
|
|
MSH_CMD_EXPORT(list_sem, list semaphore in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_EVENT
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_event(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_event *e;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s set suspend thread\n", maxlen, "event"); object_split(maxlen);
|
|
|
|
rt_kprintf(" ---------- --------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
e = (struct rt_event *)(rt_list_entry(node, struct rt_object, list));
|
|
|
|
if (!rt_list_isempty(&e->parent.suspend_thread))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s 0x%08x %03d:",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
e->parent.parent.name,
|
|
|
|
e->set,
|
|
|
|
rt_list_len(&e->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
show_wait_queue(&(e->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s 0x%08x 0\n",
|
|
|
|
maxlen, RT_NAME_MAX, e->parent.parent.name, e->set);
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_event(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_event(&rt_object_container[RT_Object_Class_Event].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_event, list event in system);
|
|
|
|
MSH_CMD_EXPORT(list_event, list event in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_MUTEX
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_mutex(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_mutex *m;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
rt_kprintf("%-*.s owner hold suspend thread\n", maxlen, "mutex"); object_split(maxlen);
|
|
|
|
rt_kprintf( " -------- ---- --------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
m = (struct rt_mutex *)(rt_list_entry(node, struct rt_object, list));
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %-8.*s %04d %d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
m->parent.parent.name,
|
|
|
|
RT_NAME_MAX,
|
|
|
|
m->owner->name,
|
|
|
|
m->hold,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_mutex(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_mutex(&rt_object_container[RT_Object_Class_Mutex].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_mutex, list mutex in system);
|
|
|
|
MSH_CMD_EXPORT(list_mutex, list mutex in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_MAILBOX
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_mailbox(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_mailbox *m;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s entry size suspend thread\n", maxlen, "mailbox"); object_split(maxlen);
|
|
|
|
rt_kprintf( " ---- ---- --------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
m = (struct rt_mailbox *)(rt_list_entry(node, struct rt_object, list));
|
|
|
|
if (!rt_list_isempty(&m->parent.suspend_thread))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %04d %04d %d:",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
m->size,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
show_wait_queue(&(m->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %04d %04d %d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
m->size,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_mailbox(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_mailbox(&rt_object_container[RT_Object_Class_MailBox].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_mailbox, list mail box in system);
|
|
|
|
MSH_CMD_EXPORT(list_mailbox, list mail box in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_MESSAGEQUEUE
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_msgqueue(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_messagequeue *m;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s entry suspend thread\n", maxlen, "msgqueue"); object_split(maxlen);
|
|
|
|
rt_kprintf( " ---- --------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
m = (struct rt_messagequeue *)(rt_list_entry(node, struct rt_object, list));
|
|
|
|
if (!rt_list_isempty(&m->parent.suspend_thread))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %04d %d:",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
show_wait_queue(&(m->parent.suspend_thread));
|
|
|
|
rt_kprintf("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %04d %d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
m->parent.parent.name,
|
|
|
|
m->entry,
|
|
|
|
rt_list_len(&m->parent.suspend_thread));
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_msgqueue(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_msgqueue(&rt_object_container[RT_Object_Class_MessageQueue].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_msgqueue, list message queue in system);
|
|
|
|
MSH_CMD_EXPORT(list_msgqueue, list message queue in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
#ifdef RT_USING_MEMHEAP
|
|
|
|
static long _list_memheap(struct rt_list_node *list)
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-06-03 14:16:30 +08:00
|
|
|
struct rt_memheap *mh;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s pool size max used size available size\n", maxlen, "memheap"); object_split(maxlen);
|
|
|
|
rt_kprintf( " ---------- ------------- --------------\n");
|
2012-06-03 14:16:30 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
|
|
|
mh = (struct rt_memheap *)rt_list_entry(node, struct rt_object, list);
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %-010d %-013d %-05d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
mh->parent.name,
|
|
|
|
mh->pool_size,
|
|
|
|
mh->max_used_size,
|
|
|
|
mh->available_size);
|
2012-06-03 14:16:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
long list_memheap(void)
|
|
|
|
{
|
|
|
|
return _list_memheap(&rt_object_container[RT_Object_Class_MemHeap].object_list);
|
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_memheap, list memory heap in system);
|
|
|
|
MSH_CMD_EXPORT(list_memheap, list memory heap in system);
|
2012-06-03 14:16:30 +08:00
|
|
|
#endif
|
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifdef RT_USING_MEMPOOL
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_mempool(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_mempool *mp;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s block total free suspend thread\n", maxlen, "mempool"); object_split(maxlen);
|
|
|
|
rt_kprintf( " ---- ---- ---- --------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
mp = (struct rt_mempool *)rt_list_entry(node, struct rt_object, list);
|
2012-04-29 20:19:29 +08:00
|
|
|
if (mp->suspend_thread_count > 0)
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %04d %04d %04d %d:",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
mp->parent.name,
|
|
|
|
mp->block_size,
|
|
|
|
mp->block_total_count,
|
|
|
|
mp->block_free_count,
|
|
|
|
mp->suspend_thread_count);
|
2012-04-29 20:19:29 +08:00
|
|
|
show_wait_queue(&(mp->suspend_thread));
|
2012-12-31 13:33:46 +08:00
|
|
|
rt_kprintf("\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %04d %04d %04d %d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
mp->parent.name,
|
|
|
|
mp->block_size,
|
|
|
|
mp->block_total_count,
|
|
|
|
mp->block_free_count,
|
|
|
|
mp->suspend_thread_count);
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_mempool(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_mempool(&rt_object_container[RT_Object_Class_MemPool].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2009-07-03 06:48:23 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_mempool, list memory pool in system)
|
2014-01-05 14:57:58 +08:00
|
|
|
MSH_CMD_EXPORT(list_mempool, list memory pool in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_timer(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_timer *timer;
|
|
|
|
struct rt_list_node *node;
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s periodic timeout flag\n", maxlen, "timer"); object_split(maxlen);
|
|
|
|
rt_kprintf( " ---------- ---------- -----------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
timer = (struct rt_timer *)(rt_list_entry(node, struct rt_object, list));
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s 0x%08x 0x%08x ",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
timer->parent.name,
|
|
|
|
timer->init_tick,
|
|
|
|
timer->timeout_tick);
|
2012-06-03 14:16:30 +08:00
|
|
|
if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
|
2012-12-31 13:33:46 +08:00
|
|
|
rt_kprintf("activated\n");
|
2012-06-03 14:16:30 +08:00
|
|
|
else
|
2012-12-31 13:33:46 +08:00
|
|
|
rt_kprintf("deactivated\n");
|
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
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_timer(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_timer(&rt_object_container[RT_Object_Class_Timer].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_timer, list timer in system);
|
|
|
|
MSH_CMD_EXPORT(list_timer, list timer in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_DEVICE
|
2010-04-22 00:59:06 +08:00
|
|
|
static long _list_device(struct rt_list_node *list)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_device *device;
|
|
|
|
struct rt_list_node *node;
|
2015-10-11 15:38:08 +08:00
|
|
|
char *const device_type_str[] =
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
|
|
|
"Character Device",
|
|
|
|
"Block Device",
|
|
|
|
"Network Interface",
|
|
|
|
"MTD Device",
|
|
|
|
"CAN Device",
|
|
|
|
"RTC",
|
|
|
|
"Sound Device",
|
2012-09-20 13:07:14 +08:00
|
|
|
"Graphic Device",
|
2012-06-14 01:16:22 +08:00
|
|
|
"I2C Bus",
|
2012-04-29 20:19:29 +08:00
|
|
|
"USB Slave Device",
|
|
|
|
"USB Host Bus",
|
|
|
|
"SPI Bus",
|
|
|
|
"SPI Device",
|
|
|
|
"SDIO Bus",
|
2015-10-11 15:38:08 +08:00
|
|
|
"PM Pseudo Device",
|
2013-08-20 14:27:28 +08:00
|
|
|
"Pipe",
|
|
|
|
"Portal Device",
|
2015-10-11 15:38:08 +08:00
|
|
|
"Timer Device",
|
|
|
|
"Miscellaneous Device",
|
2012-04-29 20:19:29 +08:00
|
|
|
"Unknown"
|
|
|
|
};
|
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s type ref count\n", maxlen, "device"); object_split(maxlen);
|
|
|
|
rt_kprintf( " -------------------- ----------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
device = (struct rt_device *)(rt_list_entry(node, struct rt_object, list));
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %-20s %-8d\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
2012-12-31 13:33:46 +08:00
|
|
|
device->parent.name,
|
|
|
|
(device->type <= RT_Device_Class_Unknown) ?
|
|
|
|
device_type_str[device->type] :
|
2014-06-18 11:18:43 +08:00
|
|
|
device_type_str[RT_Device_Class_Unknown],
|
|
|
|
device->ref_count);
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
2010-04-22 00:59:06 +08:00
|
|
|
|
|
|
|
long list_device(void)
|
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
return _list_device(&rt_object_container[RT_Object_Class_Device].object_list);
|
2010-04-22 00:59:06 +08:00
|
|
|
}
|
2014-01-05 14:57:58 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_device, list device in system);
|
|
|
|
MSH_CMD_EXPORT(list_device, list device in system);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
2010-04-13 01:37:37 +08:00
|
|
|
#ifdef RT_USING_MODULE
|
2010-11-23 09:20:53 +08:00
|
|
|
#include <rtm.h>
|
|
|
|
|
2010-04-14 08:40:20 +08:00
|
|
|
int list_module(void)
|
2010-04-13 01:37:37 +08:00
|
|
|
{
|
2016-06-13 13:29:18 +08:00
|
|
|
int maxlen;
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_module *module;
|
|
|
|
struct rt_list_node *list, *node;
|
2010-04-13 01:37:37 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
list = &rt_object_container[RT_Object_Class_Module].object_list;
|
2010-04-13 01:37:37 +08:00
|
|
|
|
2016-06-13 13:29:18 +08:00
|
|
|
maxlen = object_name_maxlen(list);
|
|
|
|
|
|
|
|
rt_kprintf("%-*.s ref address \n", maxlen, "module"); object_split(maxlen);
|
|
|
|
rt_kprintf( " -------- ------------\n");
|
2012-04-29 20:19:29 +08:00
|
|
|
for (node = list->next; node != list; node = node->next)
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
module = (struct rt_module *)(rt_list_entry(node, struct rt_object, list));
|
2016-06-13 13:29:18 +08:00
|
|
|
rt_kprintf("%-*.*s %-04d 0x%08x\n",
|
|
|
|
maxlen, RT_NAME_MAX,
|
|
|
|
module->parent.name, module->nref, module->module_space);
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
2011-06-09 00:33:12 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
return 0;
|
2010-11-23 09:20:53 +08:00
|
|
|
}
|
2014-03-12 08:47:10 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_module, list module in system);
|
|
|
|
MSH_CMD_EXPORT(list_module, list module in system);
|
2010-04-22 00:59:06 +08:00
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
int list_mod_detail(const char *name)
|
2010-11-23 09:20:53 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
int i;
|
|
|
|
struct rt_module *module;
|
2015-10-11 15:38:08 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
/* find module */
|
2012-06-03 14:16:30 +08:00
|
|
|
if ((module = rt_module_find(name)) != RT_NULL)
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
|
|
|
/* module has entry point */
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!(module->parent.flag & RT_MODULE_FLAG_WITHOUTENTRY))
|
2015-10-11 15:38:08 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
struct rt_thread *thread;
|
|
|
|
struct rt_list_node *tlist;
|
2012-06-03 14:16:30 +08:00
|
|
|
rt_uint8_t *ptr;
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
/* list main thread in module */
|
2012-06-03 14:16:30 +08:00
|
|
|
if (module->module_thread != RT_NULL)
|
2014-03-12 08:47:10 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
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);
|
|
|
|
|
|
|
|
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 ");
|
|
|
|
|
2015-10-11 15:38:08 +08:00
|
|
|
ptr = (rt_uint8_t *)thread->stack_addr;
|
2012-04-29 20:19:29 +08:00
|
|
|
while (*ptr == '#')ptr ++;
|
|
|
|
|
|
|
|
rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
|
2015-10-11 15:38:08 +08:00
|
|
|
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);
|
2014-03-12 08:47:10 +08:00
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
/* list sub thread in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_Thread].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_thread(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#ifdef RT_USING_SEMAPHORE
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list semaphored in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_Semaphore].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_sem(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_MUTEX
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list mutex in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_Mutex].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_mutex(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_EVENT
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list event in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_Event].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_event(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_MAILBOX
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list mailbox in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_MailBox].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_mailbox(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_MESSAGEQUEUE
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list message queue in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_MessageQueue].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
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);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_MEMPOOL
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list memory pool in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_MemPool].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_mempool(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RT_USING_DEVICE
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list device in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_Device].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_device(tlist);
|
2010-04-22 00:59:06 +08:00
|
|
|
#endif
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list timer in module */
|
|
|
|
tlist = &module->module_object[RT_Object_Class_Timer].object_list;
|
2012-06-03 14:16:30 +08:00
|
|
|
if (!rt_list_isempty(tlist)) _list_timer(tlist);
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
|
2015-10-11 15:38:08 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-04-13 01:37:37 +08:00
|
|
|
}
|
2011-05-16 09:18:43 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system)
|
2010-04-13 01:37:37 +08:00
|
|
|
#endif
|
|
|
|
|
2011-08-29 11:31:39 +08:00
|
|
|
long list(void)
|
2009-07-03 06:48:23 +08:00
|
|
|
{
|
2014-01-01 23:14:45 +08:00
|
|
|
#ifndef FINSH_USING_MSH_ONLY
|
2012-06-03 14:16:30 +08:00
|
|
|
struct finsh_syscall_item *syscall_item;
|
|
|
|
struct finsh_sysvar_item *sysvar_item;
|
2014-01-01 23:14:45 +08:00
|
|
|
#endif
|
2015-10-11 15:38:08 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("--Function List:\n");
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
struct finsh_syscall *index;
|
2012-12-31 13:33:46 +08:00
|
|
|
for (index = _syscall_table_begin;
|
2015-10-11 15:38:08 +08:00
|
|
|
index < _syscall_table_end;
|
|
|
|
FINSH_NEXT_SYSCALL(index))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2015-10-11 15:38:08 +08:00
|
|
|
/* skip the internal command */
|
|
|
|
if (strncmp((char *)index->name, "__", 2) == 0) continue;
|
2013-03-30 16:14:38 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifdef FINSH_USING_DESCRIPTION
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
2009-07-03 06:48:23 +08:00
|
|
|
#else
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%s\n", index->name);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-01 23:14:45 +08:00
|
|
|
#ifndef FINSH_USING_MSH_ONLY
|
2012-04-29 20:19:29 +08:00
|
|
|
/* list syscall list */
|
|
|
|
syscall_item = global_syscall_list;
|
|
|
|
while (syscall_item != NULL)
|
|
|
|
{
|
|
|
|
rt_kprintf("[l] %s\n", syscall_item->syscall.name);
|
|
|
|
syscall_item = syscall_item->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_kprintf("--Variable List:\n");
|
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
struct finsh_sysvar *index;
|
2013-01-22 12:44:47 +08:00
|
|
|
for (index = _sysvar_table_begin;
|
2015-10-11 15:38:08 +08:00
|
|
|
index < _sysvar_table_end;
|
|
|
|
FINSH_NEXT_SYSVAR(index))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifdef FINSH_USING_DESCRIPTION
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
2009-07-03 06:48:23 +08:00
|
|
|
#else
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%s\n", index->name);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
sysvar_item = global_sysvar_list;
|
|
|
|
while (sysvar_item != NULL)
|
|
|
|
{
|
|
|
|
rt_kprintf("[l] %s\n", sysvar_item->sysvar.name);
|
|
|
|
sysvar_item = sysvar_item->next;
|
|
|
|
}
|
2014-01-01 23:14:45 +08:00
|
|
|
#endif
|
2015-10-11 15:38:08 +08:00
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
return 0;
|
2009-07-03 06:48:23 +08:00
|
|
|
}
|
|
|
|
FINSH_FUNCTION_EXPORT(list, list all symbol in system)
|
|
|
|
|
2014-01-01 23:14:45 +08:00
|
|
|
#ifndef FINSH_USING_MSH_ONLY
|
2012-06-03 14:16:30 +08:00
|
|
|
static int str_is_prefix(const char *prefix, const char *str)
|
2009-09-29 21:07:29 +08:00
|
|
|
{
|
2012-04-29 20:19:29 +08:00
|
|
|
while ((*prefix) && (*prefix == *str))
|
|
|
|
{
|
|
|
|
prefix ++;
|
|
|
|
str ++;
|
|
|
|
}
|
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
if (*prefix == 0)
|
2012-12-31 13:33:46 +08:00
|
|
|
return 0;
|
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
static int str_common(const char *str1, const char *str2)
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
const char *str = str1;
|
2012-04-29 20:19:29 +08:00
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
while ((*str != 0) && (*str2 != 0) && (*str == *str2))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
|
|
|
str ++;
|
|
|
|
str2 ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (str - str1);
|
2009-09-29 21:07:29 +08:00
|
|
|
}
|
|
|
|
|
2012-06-03 14:16:30 +08:00
|
|
|
void list_prefix(char *prefix)
|
2009-09-29 21:07:29 +08:00
|
|
|
{
|
2012-06-03 14:16:30 +08:00
|
|
|
struct finsh_syscall_item *syscall_item;
|
|
|
|
struct finsh_sysvar_item *sysvar_item;
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_uint16_t func_cnt, var_cnt;
|
|
|
|
int length, min_length;
|
2012-06-03 14:16:30 +08:00
|
|
|
const char *name_ptr;
|
2012-04-29 20:19:29 +08:00
|
|
|
|
|
|
|
func_cnt = 0;
|
|
|
|
var_cnt = 0;
|
2012-12-31 13:33:46 +08:00
|
|
|
min_length = 0;
|
2012-04-29 20:19:29 +08:00
|
|
|
name_ptr = RT_NULL;
|
|
|
|
|
|
|
|
/* checks in system function call */
|
|
|
|
{
|
2012-12-31 13:33:46 +08:00
|
|
|
struct finsh_syscall *index;
|
|
|
|
for (index = _syscall_table_begin;
|
2015-10-11 15:38:08 +08:00
|
|
|
index < _syscall_table_end;
|
|
|
|
FINSH_NEXT_SYSCALL(index))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
2015-10-11 15:38:08 +08:00
|
|
|
/* skip internal command */
|
|
|
|
if (str_is_prefix("__", index->name) == 0) continue;
|
|
|
|
|
2012-04-29 20:19:29 +08:00
|
|
|
if (str_is_prefix(prefix, index->name) == 0)
|
|
|
|
{
|
|
|
|
if (func_cnt == 0)
|
|
|
|
{
|
|
|
|
rt_kprintf("--function:\n");
|
|
|
|
|
|
|
|
if (*prefix != 0)
|
|
|
|
{
|
|
|
|
/* set name_ptr */
|
|
|
|
name_ptr = index->name;
|
|
|
|
|
|
|
|
/* set initial length */
|
|
|
|
min_length = strlen(name_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func_cnt ++;
|
|
|
|
|
|
|
|
if (*prefix != 0)
|
|
|
|
{
|
|
|
|
length = str_common(name_ptr, index->name);
|
|
|
|
if (length < min_length)
|
|
|
|
min_length = length;
|
|
|
|
}
|
2009-09-29 21:07:29 +08:00
|
|
|
|
|
|
|
#ifdef FINSH_USING_DESCRIPTION
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
2009-09-29 21:07:29 +08:00
|
|
|
#else
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%s\n", index->name);
|
2009-09-29 21:07:29 +08:00
|
|
|
#endif
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checks in dynamic system function call */
|
|
|
|
syscall_item = global_syscall_list;
|
|
|
|
while (syscall_item != NULL)
|
|
|
|
{
|
|
|
|
if (str_is_prefix(prefix, syscall_item->syscall.name) == 0)
|
|
|
|
{
|
|
|
|
if (func_cnt == 0)
|
|
|
|
{
|
|
|
|
rt_kprintf("--function:\n");
|
|
|
|
if (*prefix != 0 && name_ptr == NULL)
|
|
|
|
{
|
|
|
|
/* set name_ptr */
|
|
|
|
name_ptr = syscall_item->syscall.name;
|
|
|
|
|
|
|
|
/* set initial length */
|
|
|
|
min_length = strlen(name_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func_cnt ++;
|
|
|
|
|
|
|
|
if (*prefix != 0)
|
|
|
|
{
|
|
|
|
length = str_common(name_ptr, syscall_item->syscall.name);
|
|
|
|
if (length < min_length)
|
|
|
|
min_length = length;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_kprintf("[l] %s\n", syscall_item->syscall.name);
|
|
|
|
}
|
|
|
|
syscall_item = syscall_item->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checks in system variable */
|
|
|
|
{
|
2015-10-11 15:38:08 +08:00
|
|
|
struct finsh_sysvar *index;
|
2013-01-22 12:44:47 +08:00
|
|
|
for (index = _sysvar_table_begin;
|
2015-10-11 15:38:08 +08:00
|
|
|
index < _sysvar_table_end;
|
|
|
|
FINSH_NEXT_SYSVAR(index))
|
2012-04-29 20:19:29 +08:00
|
|
|
{
|
|
|
|
if (str_is_prefix(prefix, index->name) == 0)
|
|
|
|
{
|
|
|
|
if (var_cnt == 0)
|
|
|
|
{
|
|
|
|
rt_kprintf("--variable:\n");
|
|
|
|
|
|
|
|
if (*prefix != 0 && name_ptr == NULL)
|
|
|
|
{
|
|
|
|
/* set name_ptr */
|
|
|
|
name_ptr = index->name;
|
|
|
|
|
|
|
|
/* set initial length */
|
|
|
|
min_length = strlen(name_ptr);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var_cnt ++;
|
|
|
|
|
|
|
|
if (*prefix != 0)
|
|
|
|
{
|
|
|
|
length = str_common(name_ptr, index->name);
|
|
|
|
if (length < min_length)
|
|
|
|
min_length = length;
|
|
|
|
}
|
2009-12-16 16:56:46 +08:00
|
|
|
|
2009-09-29 21:07:29 +08:00
|
|
|
#ifdef FINSH_USING_DESCRIPTION
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
2009-09-29 21:07:29 +08:00
|
|
|
#else
|
2012-04-29 20:19:29 +08:00
|
|
|
rt_kprintf("%s\n", index->name);
|
2009-09-29 21:07:29 +08:00
|
|
|
#endif
|
2012-04-29 20:19:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checks in dynamic system variable */
|
|
|
|
sysvar_item = global_sysvar_list;
|
|
|
|
while (sysvar_item != NULL)
|
|
|
|
{
|
|
|
|
if (str_is_prefix(prefix, sysvar_item->sysvar.name) == 0)
|
|
|
|
{
|
|
|
|
if (var_cnt == 0)
|
|
|
|
{
|
|
|
|
rt_kprintf("--variable:\n");
|
|
|
|
if (*prefix != 0 && name_ptr == NULL)
|
|
|
|
{
|
|
|
|
/* set name_ptr */
|
|
|
|
name_ptr = sysvar_item->sysvar.name;
|
|
|
|
|
|
|
|
/* set initial length */
|
|
|
|
min_length = strlen(name_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var_cnt ++;
|
|
|
|
|
|
|
|
if (*prefix != 0)
|
|
|
|
{
|
|
|
|
length = str_common(name_ptr, sysvar_item->sysvar.name);
|
|
|
|
if (length < min_length)
|
|
|
|
min_length = length;
|
|
|
|
}
|
|
|
|
|
|
|
|
rt_kprintf("[v] %s\n", sysvar_item->sysvar.name);
|
|
|
|
}
|
|
|
|
sysvar_item = sysvar_item->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only one matched */
|
|
|
|
if (name_ptr != NULL)
|
|
|
|
{
|
|
|
|
rt_strncpy(prefix, name_ptr, min_length);
|
|
|
|
}
|
2009-09-29 21:07:29 +08:00
|
|
|
}
|
2014-01-01 23:14:45 +08:00
|
|
|
#endif
|
2009-09-29 21:07:29 +08:00
|
|
|
|
2014-01-01 23:14:45 +08:00
|
|
|
#if defined(FINSH_USING_SYMTAB) && !defined(FINSH_USING_MSH_ONLY)
|
2009-07-03 06:48:23 +08:00
|
|
|
static int dummy = 0;
|
|
|
|
FINSH_VAR_EXPORT(dummy, finsh_type_int, dummy variable for finsh)
|
|
|
|
#endif
|