RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
cmd.c 文件参考
#include <rthw.h>
#include <rtthread.h>
#include <string.h>
#include <finsh.h>
+ cmd.c 的引用(Include)关系图:

浏览该文件的源代码.

宏定义

#define LIST_DFS_OPT_ID   0x100
 
#define LIST_FIND_OBJ_NR   8
 

函数

 MSH_CMD_EXPORT (clear, clear the terminal screen)
 
 MSH_CMD_EXPORT (version, show RT-Thread version information)
 
rt_inline void object_split (int len)
 
long list_thread (void)
 
long list_sem (void)
 
long list_event (void)
 
long list_mutex (void)
 
long list_mailbox (void)
 
long list_msgqueue (void)
 
long list_mempool (void)
 
long list_timer (void)
 
long list_device (void)
 
 MSH_CMD_EXPORT_ALIAS (cmd_list, list, list objects, optenable)
 

宏定义说明

◆ LIST_DFS_OPT_ID

#define LIST_DFS_OPT_ID   0x100

在文件 cmd.c44 行定义.

◆ LIST_FIND_OBJ_NR

#define LIST_FIND_OBJ_NR   8

在文件 cmd.c45 行定义.

函数说明

◆ MSH_CMD_EXPORT() [1/2]

MSH_CMD_EXPORT ( clear ,
clear the terminal screen )

◆ MSH_CMD_EXPORT() [2/2]

MSH_CMD_EXPORT ( version ,
show RT-Thread version information )

◆ object_split()

rt_inline void object_split ( int len)

在文件 cmd.c63 行定义.

64{
65 while (len--) rt_kprintf("-");
66}
#define rt_kprintf(...)

引用了 rt_kprintf.

+ 这是这个函数的调用关系图:

◆ list_thread()

long list_thread ( void )

在文件 cmd.c159 行定义.

160{
161 rt_base_t level;
162 list_get_next_t find_arg;
163 struct rt_object_information *info;
164 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
165 rt_list_t *next = (rt_list_t *)RT_NULL;
166 const char *item_title = "thread";
167 const size_t tcb_strlen = sizeof(void *) * 2 + 2;
168 int maxlen;
169
170 list_find_init(&find_arg, RT_Object_Class_Thread, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
171 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
172
173 maxlen = RT_NAME_MAX;
174
175#ifdef RT_USING_SMP
176 rt_kprintf("%-*.*s cpu bind pri status sp stack size max used left tick error tcb addr\n", maxlen, maxlen, item_title);
177 object_split(maxlen);
178 rt_kprintf(" --- ---- --- ------- ---------- ---------- ------ ---------- -------");
179 rt_kprintf(" ");
180 object_split(tcb_strlen);
181 rt_kprintf("\n");
182#else
183 rt_kprintf("%-*.*s pri status sp stack size max used left tick error tcb addr\n", maxlen, maxlen, item_title);
184 object_split(maxlen);
185 rt_kprintf(" --- ------- ---------- ---------- ------ ---------- -------");
186 rt_kprintf(" ");
187 object_split(tcb_strlen);
188 rt_kprintf("\n");
189#endif /*RT_USING_SMP*/
190
191 do
192 {
193 next = list_get_next(next, &find_arg);
194 {
195 int i;
196 for (i = 0; i < find_arg.nr_out; i++)
197 {
198 struct rt_object *obj;
199 struct rt_thread thread_info, *thread;
200
201 obj = rt_list_entry(obj_list[i], struct rt_object, list);
202 level = rt_spin_lock_irqsave(&info->spinlock);
203
204 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
205 {
206 rt_spin_unlock_irqrestore(&info->spinlock, level);
207 continue;
208 }
209 /* copy info */
210 rt_memcpy(&thread_info, obj, sizeof thread_info);
211 rt_spin_unlock_irqrestore(&info->spinlock, level);
212
213 thread = (struct rt_thread *)obj;
214 {
216 rt_uint8_t *ptr;
217
218#ifdef RT_USING_SMP
219 /* no synchronization applied since it's only for debug */
220 if (RT_SCHED_CTX(thread).oncpu != RT_CPU_DETACHED)
221 rt_kprintf("%-*.*s %3d %3d %4d ", maxlen, RT_NAME_MAX,
222 thread->parent.name, RT_SCHED_CTX(thread).oncpu,
223 RT_SCHED_CTX(thread).bind_cpu,
224 RT_SCHED_PRIV(thread).current_priority);
225 else
226 rt_kprintf("%-*.*s N/A %3d %4d ", maxlen, RT_NAME_MAX,
227 thread->parent.name,
228 RT_SCHED_CTX(thread).bind_cpu,
229 RT_SCHED_PRIV(thread).current_priority);
230
231#else
232 /* no synchronization applied since it's only for debug */
233 rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->parent.name, RT_SCHED_PRIV(thread).current_priority);
234#endif /*RT_USING_SMP*/
235 stat = (RT_SCHED_CTX(thread).stat & RT_THREAD_STAT_MASK);
236 if (stat == RT_THREAD_READY) rt_kprintf(" ready ");
238 else if (stat == RT_THREAD_INIT) rt_kprintf(" init ");
239 else if (stat == RT_THREAD_CLOSE) rt_kprintf(" close ");
240 else if (stat == RT_THREAD_RUNNING) rt_kprintf(" running");
241
242#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
243 ptr = (rt_uint8_t *)thread->stack_addr + thread->stack_size - 1;
244 while (*ptr == '#')ptr --;
245
246 rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %s %p\n",
247 ((rt_ubase_t)thread->sp - (rt_ubase_t)thread->stack_addr),
248 thread->stack_size,
249 ((rt_ubase_t)ptr - (rt_ubase_t)thread->stack_addr) * 100 / thread->stack_size,
250 thread->remaining_tick,
251 rt_strerror(thread->error),
252 thread);
253#else
254 ptr = (rt_uint8_t *)thread->stack_addr;
255 while (*ptr == '#') ptr ++;
256 rt_kprintf(" 0x%08x 0x%08x %02d%% 0x%08x %s %p\n",
257 thread->stack_size + ((rt_ubase_t)thread->stack_addr - (rt_ubase_t)thread->sp),
258 thread->stack_size,
259 (thread->stack_size - ((rt_ubase_t) ptr - (rt_ubase_t) thread->stack_addr)) * 100
260 / thread->stack_size,
261 RT_SCHED_PRIV(thread).remaining_tick,
262 rt_strerror(thread->error),
263 thread);
264#endif
265 }
266 }
267 }
268 }
269 while (next != (rt_list_t *)RT_NULL);
270
271 return 0;
272}
#define LIST_FIND_OBJ_NR
定义 cmd.c:45
rt_inline void object_split(int len)
定义 cmd.c:63
int stat(const char *file, struct stat *buf)
rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock)
This function will disable the local interrupt and then lock the spinlock, will lock the thread sched...
void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level)
This function will unlock the spinlock and then restore current cpu interrupt status,...
@ RT_Object_Class_Thread
@ RT_Object_Class_Static
#define rt_list_entry(node, type, member)
get the struct for this entry
#define RT_THREAD_CLOSE
#define RT_THREAD_READY
#define RT_THREAD_STAT_MASK
#define RT_THREAD_RUNNING
#define RT_THREAD_SUSPEND_MASK
#define RT_THREAD_INIT
#define RT_SCHED_CTX(thread)
#define RT_SCHED_PRIV(thread)
rt_int32_t rt_base_t
unsigned char rt_uint8_t
struct rt_list_node rt_list_t
rt_uint32_t rt_ubase_t
#define RT_NULL
struct rt_spinlock spinlock
rt_uint8_t type
const char * name
void * stack_addr
rt_err_t error
struct rt_object parent
void * sp
rt_uint32_t stack_size

引用了 rt_thread::error, LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_thread::parent, rt_kprintf, rt_list_entry, RT_NULL, RT_Object_Class_Static, RT_Object_Class_Thread, RT_SCHED_CTX, RT_SCHED_PRIV, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), RT_THREAD_CLOSE, RT_THREAD_INIT, RT_THREAD_READY, RT_THREAD_RUNNING, RT_THREAD_STAT_MASK, RT_THREAD_SUSPEND_MASK, rt_thread::sp, rt_object_information::spinlock, rt_thread::stack_addr, rt_thread::stack_size, stat() , 以及 rt_object::type.

+ 函数调用图:

◆ list_sem()

long list_sem ( void )

在文件 cmd.c275 行定义.

276{
277 rt_base_t level;
278 list_get_next_t find_arg;
279 struct rt_object_information *info;
280 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
281 rt_list_t *next = (rt_list_t *)RT_NULL;
282
283 int maxlen;
284 const char *item_title = "semaphore";
285
286 list_find_init(&find_arg, RT_Object_Class_Semaphore, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
287 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
288
289 maxlen = RT_NAME_MAX;
290
291 rt_kprintf("%-*.*s v suspend thread\n", maxlen, maxlen, item_title);
292 object_split(maxlen);
293 rt_kprintf(" --- --------------\n");
294
295 do
296 {
297 next = list_get_next(next, &find_arg);
298 {
299 int i;
300 for (i = 0; i < find_arg.nr_out; i++)
301 {
302 struct rt_object *obj;
303 struct rt_semaphore *sem;
304
305 obj = rt_list_entry(obj_list[i], struct rt_object, list);
306 level = rt_spin_lock_irqsave(&info->spinlock);
307 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
308 {
309 rt_spin_unlock_irqrestore(&info->spinlock, level);
310 continue;
311 }
312 rt_spin_unlock_irqrestore(&info->spinlock, level);
313
314 sem = (struct rt_semaphore *)obj;
316 {
317 rt_kprintf("%-*.*s %03d %d:",
318 maxlen, RT_NAME_MAX,
319 sem->parent.parent.name,
320 sem->value,
323 rt_kprintf("\n");
324 }
325 else
326 {
327 rt_kprintf("%-*.*s %03d %d\n",
328 maxlen, RT_NAME_MAX,
329 sem->parent.parent.name,
330 sem->value,
332 }
333 }
334 }
335 }
336 while (next != (rt_list_t *)RT_NULL);
337
338 return 0;
339}
void rt_susp_list_print(rt_list_t *list)
Print thread on suspend list to system console
定义 ipc.c:290
@ RT_Object_Class_Semaphore
rt_inline int rt_list_isempty(const rt_list_t *l)
tests whether a list is empty
rt_inline unsigned int rt_list_len(const rt_list_t *l)
get the list length
struct rt_object parent
rt_list_t suspend_thread
rt_uint16_t value
struct rt_ipc_object parent

引用了 LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_ipc_object::parent, rt_semaphore::parent, rt_kprintf, rt_list_entry, rt_list_isempty(), rt_list_len(), RT_NULL, RT_Object_Class_Semaphore, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_susp_list_print(), rt_object_information::spinlock, rt_ipc_object::suspend_thread, rt_object::type , 以及 rt_semaphore::value.

+ 函数调用图:

◆ list_event()

long list_event ( void )

在文件 cmd.c343 行定义.

344{
345 rt_base_t level;
346 list_get_next_t find_arg;
347 struct rt_object_information *info;
348 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
349 rt_list_t *next = (rt_list_t *)RT_NULL;
350
351 int maxlen;
352 const char *item_title = "event";
353
354 list_find_init(&find_arg, RT_Object_Class_Event, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
355 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
356
357 maxlen = RT_NAME_MAX;
358
359 rt_kprintf("%-*.*s set suspend thread\n", maxlen, maxlen, item_title);
360 object_split(maxlen);
361 rt_kprintf(" ---------- --------------\n");
362
363 do
364 {
365 next = list_get_next(next, &find_arg);
366 {
367 int i;
368 for (i = 0; i < find_arg.nr_out; i++)
369 {
370 struct rt_object *obj;
371 struct rt_event *e;
372
373 obj = rt_list_entry(obj_list[i], struct rt_object, list);
374 level = rt_spin_lock_irqsave(&info->spinlock);
375 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
376 {
377 rt_spin_unlock_irqrestore(&info->spinlock, level);
378 continue;
379 }
380
381 rt_spin_unlock_irqrestore(&info->spinlock, level);
382
383 e = (struct rt_event *)obj;
385 {
386 rt_kprintf("%-*.*s 0x%08x %03d:",
387 maxlen, RT_NAME_MAX,
388 e->parent.parent.name,
389 e->set,
392 rt_kprintf("\n");
393 }
394 else
395 {
396 rt_kprintf("%-*.*s 0x%08x 0\n",
397 maxlen, RT_NAME_MAX, e->parent.parent.name, e->set);
398 }
399 }
400 }
401 }
402 while (next != (rt_list_t *)RT_NULL);
403
404 return 0;
405}
@ RT_Object_Class_Event
rt_uint32_t set
struct rt_ipc_object parent

引用了 LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_event::parent, rt_ipc_object::parent, rt_kprintf, rt_list_entry, rt_list_isempty(), rt_list_len(), RT_NULL, RT_Object_Class_Event, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_susp_list_print(), rt_event::set, rt_object_information::spinlock, rt_ipc_object::suspend_thread , 以及 rt_object::type.

+ 函数调用图:

◆ list_mutex()

long list_mutex ( void )

在文件 cmd.c409 行定义.

410{
411 rt_base_t level;
412 list_get_next_t find_arg;
413 struct rt_object_information *info;
414 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
415 rt_list_t *next = (rt_list_t *)RT_NULL;
416
417 int maxlen;
418 const char *item_title = "mutex";
419
420 list_find_init(&find_arg, RT_Object_Class_Mutex, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
421 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
422
423 maxlen = RT_NAME_MAX;
424
425 rt_kprintf("%-*.*s owner hold priority suspend thread \n", maxlen, maxlen, item_title);
426 object_split(maxlen);
427 rt_kprintf(" -------- ---- -------- --------------\n");
428
429 do
430 {
431 next = list_get_next(next, &find_arg);
432 {
433 int i;
434 for (i = 0; i < find_arg.nr_out; i++)
435 {
436 struct rt_object *obj;
437 struct rt_mutex *m;
438
439 obj = rt_list_entry(obj_list[i], struct rt_object, list);
440 level = rt_spin_lock_irqsave(&info->spinlock);
441 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
442 {
443 rt_spin_unlock_irqrestore(&info->spinlock, level);
444 continue;
445 }
446
447 rt_spin_unlock_irqrestore(&info->spinlock, level);
448
449 m = (struct rt_mutex *)obj;
451 {
452 rt_kprintf("%-*.*s %-8.*s %04d %8d %04d ",
453 maxlen, RT_NAME_MAX,
454 m->parent.parent.name,
455 RT_NAME_MAX,
456 m->owner->parent.name,
457 m->hold,
458 m->priority,
461 rt_kprintf("\n");
462 }
463 else
464 {
465 rt_kprintf("%-*.*s %-8.*s %04d %8d %04d\n",
466 maxlen, RT_NAME_MAX,
467 m->parent.parent.name,
468 RT_NAME_MAX,
469 m->owner->parent.name,
470 m->hold,
471 m->priority,
473 }
474 }
475 }
476 }
477 while (next != (rt_list_t *)RT_NULL);
478
479 return 0;
480}
@ RT_Object_Class_Mutex
struct rt_ipc_object parent
rt_uint8_t priority
struct rt_thread * owner
rt_uint8_t hold

引用了 rt_mutex::hold, LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_mutex::owner, rt_ipc_object::parent, rt_mutex::parent, rt_thread::parent, rt_mutex::priority, rt_kprintf, rt_list_entry, rt_list_isempty(), rt_list_len(), RT_NULL, RT_Object_Class_Mutex, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_susp_list_print(), rt_object_information::spinlock, rt_ipc_object::suspend_thread , 以及 rt_object::type.

+ 函数调用图:

◆ list_mailbox()

long list_mailbox ( void )

在文件 cmd.c484 行定义.

485{
486 rt_base_t level;
487 list_get_next_t find_arg;
488 struct rt_object_information *info;
489 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
490 rt_list_t *next = (rt_list_t *)RT_NULL;
491
492 int maxlen;
493 const char *item_title = "mailbox";
494
495 list_find_init(&find_arg, RT_Object_Class_MailBox, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
496 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
497
498 maxlen = RT_NAME_MAX;
499
500 rt_kprintf("%-*.*s entry size suspend thread\n", maxlen, maxlen, item_title);
501 object_split(maxlen);
502 rt_kprintf(" ---- ---- --------------\n");
503
504 do
505 {
506 next = list_get_next(next, &find_arg);
507 {
508 int i;
509 for (i = 0; i < find_arg.nr_out; i++)
510 {
511 struct rt_object *obj;
512 struct rt_mailbox *m;
513
514 obj = rt_list_entry(obj_list[i], struct rt_object, list);
515 level = rt_spin_lock_irqsave(&info->spinlock);
516 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
517 {
518 rt_spin_unlock_irqrestore(&info->spinlock, level);
519 continue;
520 }
521
522 rt_spin_unlock_irqrestore(&info->spinlock, level);
523
524 m = (struct rt_mailbox *)obj;
526 {
527 rt_kprintf("%-*.*s %04d %04d %d:",
528 maxlen, RT_NAME_MAX,
529 m->parent.parent.name,
530 m->entry,
531 m->size,
534 rt_kprintf("\n");
535 }
536 else
537 {
538 rt_kprintf("%-*.*s %04d %04d %d\n",
539 maxlen, RT_NAME_MAX,
540 m->parent.parent.name,
541 m->entry,
542 m->size,
544 }
545
546 }
547 }
548 }
549 while (next != (rt_list_t *)RT_NULL);
550
551 return 0;
552}
@ RT_Object_Class_MailBox
struct rt_ipc_object parent
rt_uint16_t entry
rt_uint16_t size

引用了 rt_mailbox::entry, LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_ipc_object::parent, rt_mailbox::parent, rt_kprintf, rt_list_entry, rt_list_isempty(), rt_list_len(), RT_NULL, RT_Object_Class_MailBox, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_susp_list_print(), rt_mailbox::size, rt_object_information::spinlock, rt_ipc_object::suspend_thread , 以及 rt_object::type.

+ 函数调用图:

◆ list_msgqueue()

long list_msgqueue ( void )

在文件 cmd.c556 行定义.

557{
558 rt_base_t level;
559 list_get_next_t find_arg;
560 struct rt_object_information *info;
561 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
562 rt_list_t *next = (rt_list_t *)RT_NULL;
563
564 int maxlen;
565 const char *item_title = "msgqueue";
566
567 list_find_init(&find_arg, RT_Object_Class_MessageQueue, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
568 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
569
570 maxlen = RT_NAME_MAX;
571
572 rt_kprintf("%-*.*s entry suspend thread\n", maxlen, maxlen, item_title);
573 object_split(maxlen);
574 rt_kprintf(" ---- --------------\n");
575 do
576 {
577 next = list_get_next(next, &find_arg);
578 {
579 int i;
580 for (i = 0; i < find_arg.nr_out; i++)
581 {
582 struct rt_object *obj;
583 struct rt_messagequeue *m;
584
585 obj = rt_list_entry(obj_list[i], struct rt_object, list);
586 level = rt_spin_lock_irqsave(&info->spinlock);
587 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
588 {
589 rt_spin_unlock_irqrestore(&info->spinlock, level);
590 continue;
591 }
592
593 rt_spin_unlock_irqrestore(&info->spinlock, level);
594
595 m = (struct rt_messagequeue *)obj;
597 {
598 rt_kprintf("%-*.*s %04d %d:",
599 maxlen, RT_NAME_MAX,
600 m->parent.parent.name,
601 m->entry,
604 rt_kprintf("\n");
605 }
606 else
607 {
608 rt_kprintf("%-*.*s %04d %d\n",
609 maxlen, RT_NAME_MAX,
610 m->parent.parent.name,
611 m->entry,
613 }
614 }
615 }
616 }
617 while (next != (rt_list_t *)RT_NULL);
618
619 return 0;
620}
@ RT_Object_Class_MessageQueue
struct rt_ipc_object parent
rt_uint16_t entry

引用了 rt_messagequeue::entry, LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_ipc_object::parent, rt_messagequeue::parent, rt_kprintf, rt_list_entry, rt_list_isempty(), rt_list_len(), RT_NULL, RT_Object_Class_MessageQueue, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_susp_list_print(), rt_object_information::spinlock, rt_ipc_object::suspend_thread , 以及 rt_object::type.

+ 函数调用图:

◆ list_mempool()

long list_mempool ( void )

在文件 cmd.c682 行定义.

683{
684 rt_base_t level;
685 list_get_next_t find_arg;
686 struct rt_object_information *info;
687 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
688 rt_list_t *next = (rt_list_t *)RT_NULL;
689
690 int maxlen;
691 const char *item_title = "mempool";
692
693 list_find_init(&find_arg, RT_Object_Class_MemPool, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
694 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
695
696 maxlen = RT_NAME_MAX;
697
698 rt_kprintf("%-*.*s block total free suspend thread\n", maxlen, maxlen, item_title);
699 object_split(maxlen);
700 rt_kprintf(" ---- ---- ---- --------------\n");
701 do
702 {
703 next = list_get_next(next, &find_arg);
704 {
705 int i;
706 for (i = 0; i < find_arg.nr_out; i++)
707 {
708 struct rt_object *obj;
709 struct rt_mempool *mp;
710 int suspend_thread_count;
711 rt_list_t *node;
712
713 obj = rt_list_entry(obj_list[i], struct rt_object, list);
714 level = rt_spin_lock_irqsave(&info->spinlock);
715 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
716 {
717 rt_spin_unlock_irqrestore(&info->spinlock, level);
718 continue;
719 }
720
721 rt_spin_unlock_irqrestore(&info->spinlock, level);
722
723 mp = (struct rt_mempool *)obj;
724
725 suspend_thread_count = 0;
727 {
728 suspend_thread_count++;
729 }
730
731 if (suspend_thread_count > 0)
732 {
733 rt_kprintf("%-*.*s %04d %04d %04d %d:",
734 maxlen, RT_NAME_MAX,
735 mp->parent.name,
736 mp->block_size,
739 suspend_thread_count);
741 rt_kprintf("\n");
742 }
743 else
744 {
745 rt_kprintf("%-*.*s %04d %04d %04d %d\n",
746 maxlen, RT_NAME_MAX,
747 mp->parent.name,
748 mp->block_size,
751 suspend_thread_count);
752 }
753 }
754 }
755 }
756 while (next != (rt_list_t *)RT_NULL);
757
758 return 0;
759}
@ RT_Object_Class_MemPool
#define rt_list_for_each(pos, head)
rt_size_t block_total_count
rt_size_t block_size
rt_list_t suspend_thread
struct rt_object parent
rt_size_t block_free_count

引用了 rt_mempool::block_free_count, rt_mempool::block_size, rt_mempool::block_total_count, LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_mempool::parent, rt_kprintf, rt_list_entry, rt_list_for_each, RT_NULL, RT_Object_Class_MemPool, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_susp_list_print(), rt_object_information::spinlock, rt_mempool::suspend_thread , 以及 rt_object::type.

+ 函数调用图:

◆ list_timer()

long list_timer ( void )

在文件 cmd.c762 行定义.

763{
764 rt_base_t level;
765 list_get_next_t find_arg;
766 struct rt_object_information *info;
767 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
768 rt_list_t *next = (rt_list_t *)RT_NULL;
769
770 int maxlen;
771 const char *item_title = "timer";
772
773 list_find_init(&find_arg, RT_Object_Class_Timer, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
774 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
775
776 maxlen = RT_NAME_MAX;
777
778 rt_kprintf("%-*.*s periodic timeout activated mode\n", maxlen, maxlen, item_title);
779 object_split(maxlen);
780 rt_kprintf(" ---------- ---------- ----------- ---------\n");
781 do
782 {
783 next = list_get_next(next, &find_arg);
784 {
785 int i;
786 for (i = 0; i < find_arg.nr_out; i++)
787 {
788 struct rt_object *obj;
789 struct rt_timer *timer;
790
791 obj = rt_list_entry(obj_list[i], struct rt_object, list);
792 level = rt_spin_lock_irqsave(&info->spinlock);
793 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
794 {
795 rt_spin_unlock_irqrestore(&info->spinlock, level);
796 continue;
797 }
798
799 rt_spin_unlock_irqrestore(&info->spinlock, level);
800
801 timer = (struct rt_timer *)obj;
802 rt_kprintf("%-*.*s 0x%08x 0x%08x ",
803 maxlen, RT_NAME_MAX,
804 timer->parent.name,
805 timer->init_tick,
806 timer->timeout_tick);
808 rt_kprintf("activated ");
809 else
810 rt_kprintf("deactivated ");
812 rt_kprintf("periodic\n");
813 else
814 rt_kprintf("one shot\n");
815
816 }
817 }
818 }
819 while (next != (rt_list_t *)RT_NULL);
820
821 rt_kprintf("current tick:0x%08x\n", rt_tick_get());
822
823 return 0;
824}
#define RT_TIMER_FLAG_ACTIVATED
#define RT_TIMER_FLAG_PERIODIC
rt_tick_t rt_tick_get(void)
This function will return current tick from operating system startup.
定义 clock.c:69
@ RT_Object_Class_Timer
rt_uint8_t flag
struct rt_object parent
rt_tick_t init_tick
rt_tick_t timeout_tick

引用了 rt_object::flag, rt_timer::init_tick, LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_timer::parent, rt_kprintf, rt_list_entry, RT_NULL, RT_Object_Class_Static, RT_Object_Class_Timer, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_tick_get(), RT_TIMER_FLAG_ACTIVATED, RT_TIMER_FLAG_PERIODIC, rt_object_information::spinlock, rt_timer::timeout_tick , 以及 rt_object::type.

+ 函数调用图:

◆ list_device()

long list_device ( void )

在文件 cmd.c862 行定义.

863{
864 rt_base_t level;
865 list_get_next_t find_arg;
866 struct rt_object_information *info;
867 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
868 rt_list_t *next = (rt_list_t *)RT_NULL;
869 const char *device_type;
870
871 int maxlen;
872 const char *item_title = "device";
873
874 list_find_init(&find_arg, RT_Object_Class_Device, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
875 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
876
877 maxlen = RT_NAME_MAX;
878
879 rt_kprintf("%-*.*s type ref count\n", maxlen, maxlen, item_title);
880 object_split(maxlen);
881 rt_kprintf(" -------------------- ----------\n");
882 do
883 {
884 next = list_get_next(next, &find_arg);
885 {
886 int i;
887 for (i = 0; i < find_arg.nr_out; i++)
888 {
889 struct rt_object *obj;
890 struct rt_device *device;
891
892 obj = rt_list_entry(obj_list[i], struct rt_object, list);
893 level = rt_spin_lock_irqsave(&info->spinlock);
894 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
895 {
896 rt_spin_unlock_irqrestore(&info->spinlock, level);
897 continue;
898 }
899
900 rt_spin_unlock_irqrestore(&info->spinlock, level);
901
902 device = (struct rt_device *)obj;
903 device_type = "Unknown";
904 if (device->type < RT_Device_Class_Unknown &&
905 device_type_str[device->type] != RT_NULL)
906 {
907 device_type = device_type_str[device->type];
908 }
909 rt_kprintf("%-*.*s %-20s %-8d\n",
910 maxlen, RT_NAME_MAX,
911 device->parent.name,
912 device_type,
913 device->ref_count);
914
915 }
916 }
917 }
918 while (next != (rt_list_t *)RT_NULL);
919
920 return 0;
921}
@ RT_Device_Class_Unknown
@ RT_Object_Class_Device
enum rt_device_class_type type
rt_uint8_t ref_count
struct rt_object parent

引用了 LIST_FIND_OBJ_NR, rt_object::name, rt_object_information::object_list, object_split(), rt_device::parent, rt_device::ref_count, RT_Device_Class_Unknown, rt_kprintf, rt_list_entry, RT_NULL, RT_Object_Class_Device, RT_Object_Class_Static, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_object_information::spinlock, rt_device::type , 以及 rt_object::type.

+ 函数调用图:

◆ MSH_CMD_EXPORT_ALIAS()

MSH_CMD_EXPORT_ALIAS ( cmd_list ,
list ,
list objects,
optenable  )