📄 cmd.c.svn-base
字号:
/* * File : cmd.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.fayfayspace.org/license/LICENSE. * * 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 */#include <rtthread.h>#include "finsh.h"long hello(){ rt_kprintf("Hello RT-Thread!\n"); return 0;}long version(){ rt_kprintf(" \\ | /\n"); rt_kprintf("- RT - Thread Operating System\n"); rt_kprintf(" / | \\ 0.0.2 build %s\n", __DATE__); rt_kprintf(" 2006 Copyright by rt-thread team\n"); return 0;}#define rt_list_entry(node, type, member) \ ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))extern struct rt_object_information rt_object_container[];int list_thread(){ struct rt_thread *thread; struct rt_list_node *list, *node; rt_uint8* ptr; list = &rt_object_container[RT_Object_Class_Thread].object_list; rt_kprintf(" thread pri status sp stack size max used left tick error\n"); rt_kprintf("-------- ---- ------- ---------- ---------- ---------- ---------- ---\n"); for (node = list->next; node != list; node = node->next) { thread = rt_list_entry(node, struct rt_thread, list); rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority); if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready "); else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend"); else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init "); ptr = (rt_uint8*)thread->stack_addr; while (*ptr == '#')ptr ++; rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n", thread->stack_size + ((rt_uint32)thread->stack_addr - (rt_uint32)thread->sp), thread->stack_size, thread->stack_size - ((rt_uint32) ptr - (rt_uint32)thread->stack_addr), thread->remaining_tick, thread->error); } return 0;}int list_sem(){ struct rt_semaphore *sem; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_Semaphore].object_list; rt_kprintf("semaphore v suspend thread\n"); rt_kprintf("-------- --- --------------\n"); for (node = list->next; node != list; node = node->next) { sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s %03d %d\n", sem->parent.parent.name, sem->value, sem->parent.suspend_thread_count); } return 0;}int list_fevent(){ struct rt_fast_event *e; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_FastEvent].object_list; rt_kprintf("fevent set \n"); rt_kprintf("-------- ----------\n"); for (node = list->next; node != list; node = node->next) { e = (struct rt_fast_event*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s 0x%08x\n", e->parent.name, e->set); } return 0;}int list_event(){ struct rt_event *e; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_Event].object_list; rt_kprintf("event set suspend thread\n"); rt_kprintf("-------- ---------- --------------\n"); for (node = list->next; node != list; node = node->next) { e = (struct rt_event*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s 0x%08x %03d\n", e->parent.parent.name, e->set, e->parent.suspend_thread_count); } return 0;}int list_mutex(){ struct rt_mutex *m; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_Mutex].object_list; rt_kprintf("mutex owner hold suspend thread\n"); rt_kprintf("-------- -------- ---- --------------\n"); for (node = list->next; node != list; node = node->next) { m = (struct rt_mutex*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s %-8s %04d %d\n", m->parent.parent.name, m->owner->name, m->hold, m->parent.suspend_thread_count); } return 0;}int list_mailbox(){ struct rt_mailbox *m; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_MailBox].object_list; rt_kprintf("mailbox entry size suspend thread\n"); rt_kprintf("-------- ---- ---- --------------\n"); for (node = list->next; node != list; node = node->next) { m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s %04d %04d %d\n", m->parent.parent.name, m->entry, m->size, m->parent.suspend_thread_count); } return 0;}int list_msgqueue(){ struct rt_messagequeue *m; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_MessageQueue].object_list; rt_kprintf("msgqueue entry suspend thread\n"); rt_kprintf("-------- ---- --------------\n"); for (node = list->next; node != list; node = node->next) { m = (struct rt_messagequeue*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s %04d %d\n", m->parent.parent.name, m->entry, m->parent.suspend_thread_count); } return 0;}int list_mempool(){ struct rt_mempool *mp; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_MemPool].object_list; rt_kprintf("mempool block total free suspend thread\n"); rt_kprintf("-------- ---- ---- ---- --------------\n"); for (node = list->next; node != list; node = node->next) { mp = (struct rt_mempool*)rt_list_entry(node, struct rt_object, list); rt_kprintf("%-8s %04d %04d %04d %d\n", mp->parent.name, mp->block_size, mp->block_total_count, mp->block_free_count, mp->suspend_thread_count); } return 0;}int list_timer(){ struct rt_timer *timer; struct rt_list_node *list, *node; list = &rt_object_container[RT_Object_Class_Timer].object_list; rt_kprintf("timer periodic timeout flag\n"); rt_kprintf("-------- ---------- ---------- -----------\n"); for (node = list->next; node != list; node = node->next) { timer = (struct rt_timer*)(rt_list_entry(node, struct rt_object, list)); rt_kprintf("%-8s 0x%08x 0x%08x ", timer->parent.name, timer->init_tick, timer->timeout_tick); if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED) rt_kprintf("activated\n"); else rt_kprintf("deactivated\n"); } rt_kprintf("current tick:0x%08x\n", rt_tick_get()); return 0;}extern struct finsh_syscall global_syscall_table[];extern struct finsh_sysvar global_sysvar_table [];int list(){ register int i; rt_kprintf("--Function List:\n"); i = 0; while (global_syscall_table[i].name != NULL) { rt_kprintf("%s\n", global_syscall_table[i].name); i ++; } rt_kprintf("--Variable List:\n"); i = 0; while (global_sysvar_table[i].name != NULL) { rt_kprintf("%s\n", global_sysvar_table[i].name); i ++; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -