cmd.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * File : cmd.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-04-30 Bernard first implementation
  13. * 2006-05-04 Bernard add list_thread,
  14. * list_sem,
  15. * list_timer
  16. * 2006-05-20 Bernard add list_mutex,
  17. * list_mailbox,
  18. * list_msgqueue,
  19. * list_event,
  20. * list_fevent,
  21. * list_mempool
  22. * 2006-06-03 Bernard display stack information in list_thread
  23. * 2006-08-10 Bernard change version to invoke rt_show_version
  24. * 2008-09-10 Bernard update the list function for finsh syscall
  25. * list and sysvar list
  26. * 2009-05-30 Bernard add list_device
  27. * 2010-04-21 yi.qiu add list_module
  28. */
  29. #include <rtthread.h>
  30. #include "finsh.h"
  31. // Copy from kservice.h because we can not use it out of the kernel.
  32. // Ugly. Should let kservice.h avaliable for applications?
  33. rt_inline int rt_list_isempty(const rt_list_t *l)
  34. {
  35. return l->next == l;
  36. }
  37. rt_inline unsigned int rt_list_len(const rt_list_t *l)
  38. {
  39. unsigned int len = 0;
  40. const rt_list_t *p = l;
  41. while( p->next != l )
  42. {
  43. p = p->next;
  44. len++;
  45. }
  46. return len;
  47. }
  48. long hello(void)
  49. {
  50. rt_kprintf("Hello RT-Thread!\n");
  51. return 0;
  52. }
  53. FINSH_FUNCTION_EXPORT(hello, say hello world);
  54. extern void rt_show_version(void);
  55. long version(void)
  56. {
  57. rt_show_version();
  58. return 0;
  59. }
  60. FINSH_FUNCTION_EXPORT(version, show RT-Thread version information);
  61. #define rt_list_entry(node, type, member) \
  62. ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))
  63. extern struct rt_object_information rt_object_container[];
  64. static long _list_thread(struct rt_list_node* list)
  65. {
  66. struct rt_thread *thread;
  67. struct rt_list_node *node;
  68. rt_uint8_t* ptr;
  69. rt_kprintf(" thread pri status sp stack size max used left tick error\n");
  70. rt_kprintf("-------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
  71. for (node = list->next; node != list; node = node->next)
  72. {
  73. thread = rt_list_entry(node, struct rt_thread, list);
  74. rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
  75. if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
  76. else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
  77. else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
  78. ptr = (rt_uint8_t*)thread->stack_addr;
  79. while (*ptr == '#')ptr ++;
  80. rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
  81. thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
  82. thread->stack_size,
  83. thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
  84. thread->remaining_tick,
  85. thread->error);
  86. }
  87. return 0;
  88. }
  89. long list_thread(void)
  90. {
  91. return _list_thread(&rt_object_container[RT_Object_Class_Thread].object_list);
  92. }
  93. FINSH_FUNCTION_EXPORT(list_thread, list thread);
  94. #if 0
  95. long dump_thread(rt_thread_t tid)
  96. {
  97. rt_uint8_t *ptr;
  98. rt_uint32_t sp;
  99. rt_thread_t thread;
  100. rt_kprintf(" thread pri status sp stack size max used left tick error\n");
  101. rt_kprintf("-------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
  102. thread = rt_thread_self();
  103. if ((thread == tid) || (tid == RT_NULL)) /* it's current thread */
  104. {
  105. ptr = (rt_uint8_t*)thread->stack_addr;
  106. while (*ptr == '#')ptr ++;
  107. sp = (rt_uint32_t)__current_sp();
  108. rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
  109. if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
  110. else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
  111. else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
  112. rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
  113. thread->stack_size + ((rt_uint32_t)thread->stack_addr - sp),
  114. thread->stack_size,
  115. thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
  116. thread->remaining_tick,
  117. thread->error);
  118. }
  119. else
  120. {
  121. thread = tid;
  122. sp = (rt_uint32_t)thread->sp;
  123. ptr = (rt_uint8_t*)thread->stack_addr;
  124. while (*ptr == '#')ptr ++;
  125. rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
  126. if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
  127. else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
  128. else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
  129. rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
  130. thread->stack_size + ((rt_uint32_t)thread->stack_addr - sp),
  131. thread->stack_size,
  132. thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
  133. thread->remaining_tick,
  134. thread->error);
  135. }
  136. return 0;
  137. }
  138. #endif
  139. static void show_wait_queue(struct rt_list_node* list)
  140. {
  141. struct rt_thread *thread;
  142. struct rt_list_node *node;
  143. for (node = list->next; node != list; node = node->next)
  144. {
  145. thread = rt_list_entry(node, struct rt_thread, tlist);
  146. rt_kprintf("%s", thread->name);
  147. if (node->next != list) rt_kprintf("/");
  148. }
  149. }
  150. #ifdef RT_USING_SEMAPHORE
  151. static long _list_sem(struct rt_list_node *list)
  152. {
  153. struct rt_semaphore *sem;
  154. struct rt_list_node *node;
  155. rt_kprintf("semaphore v suspend thread\n");
  156. rt_kprintf("-------- --- --------------\n");
  157. for (node = list->next; node != list; node = node->next)
  158. {
  159. sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list));
  160. if( !rt_list_isempty(&sem->parent.suspend_thread) )
  161. {
  162. rt_kprintf("%-8s %03d %d:", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread) );
  163. show_wait_queue(&(sem->parent.suspend_thread));
  164. rt_kprintf("\n");
  165. }
  166. else
  167. {
  168. rt_kprintf("%-8s %03d %d\n", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread));
  169. }
  170. }
  171. return 0;
  172. }
  173. long list_sem(void)
  174. {
  175. return _list_sem(&rt_object_container[RT_Object_Class_Semaphore].object_list);
  176. }
  177. FINSH_FUNCTION_EXPORT(list_sem, list semaphone in system)
  178. #endif
  179. #ifdef RT_USING_EVENT
  180. static long _list_event(struct rt_list_node *list)
  181. {
  182. struct rt_event *e;
  183. struct rt_list_node *node;
  184. rt_kprintf("event set suspend thread\n");
  185. rt_kprintf("-------- ---------- --------------\n");
  186. for (node = list->next; node != list; node = node->next)
  187. {
  188. e = (struct rt_event*)(rt_list_entry(node, struct rt_object, list));
  189. rt_kprintf("%-8s 0x%08x %03d\n", e->parent.parent.name, e->set, rt_list_len(&e->parent.suspend_thread));
  190. }
  191. return 0;
  192. }
  193. long list_event(void)
  194. {
  195. return _list_event(&rt_object_container[RT_Object_Class_Event].object_list);
  196. }
  197. FINSH_FUNCTION_EXPORT(list_event, list event in system)
  198. #endif
  199. #ifdef RT_USING_MUTEX
  200. static long _list_mutex(struct rt_list_node *list)
  201. {
  202. struct rt_mutex *m;
  203. struct rt_list_node *node;
  204. rt_kprintf("mutex owner hold suspend thread\n");
  205. rt_kprintf("-------- -------- ---- --------------\n");
  206. for (node = list->next; node != list; node = node->next)
  207. {
  208. m = (struct rt_mutex*)(rt_list_entry(node, struct rt_object, list));
  209. rt_kprintf("%-8s %-8s %04d %d\n", m->parent.parent.name, m->owner->name, m->hold, rt_list_len(&m->parent.suspend_thread));
  210. }
  211. return 0;
  212. }
  213. long list_mutex(void)
  214. {
  215. return _list_mutex(&rt_object_container[RT_Object_Class_Mutex].object_list);
  216. }
  217. FINSH_FUNCTION_EXPORT(list_mutex, list mutex in system)
  218. #endif
  219. #ifdef RT_USING_MAILBOX
  220. static long _list_mailbox(struct rt_list_node *list)
  221. {
  222. struct rt_mailbox *m;
  223. struct rt_list_node *node;
  224. rt_kprintf("mailbox entry size suspend thread\n");
  225. rt_kprintf("-------- ---- ---- --------------\n");
  226. for (node = list->next; node != list; node = node->next)
  227. {
  228. m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list));
  229. if( !rt_list_isempty(&m->parent.suspend_thread) )
  230. {
  231. rt_kprintf("%-8s %04d %04d %d:", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread));
  232. show_wait_queue(&(m->parent.suspend_thread));
  233. rt_kprintf("\n");
  234. }
  235. else
  236. {
  237. rt_kprintf("%-8s %04d %04d %d\n", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread));
  238. }
  239. }
  240. return 0;
  241. }
  242. long list_mailbox(void)
  243. {
  244. return _list_mailbox(&rt_object_container[RT_Object_Class_MailBox].object_list);
  245. }
  246. FINSH_FUNCTION_EXPORT(list_mailbox, list mail box in system)
  247. #endif
  248. #ifdef RT_USING_MESSAGEQUEUE
  249. static long _list_msgqueue(struct rt_list_node *list)
  250. {
  251. struct rt_messagequeue *m;
  252. struct rt_list_node *node;
  253. rt_kprintf("msgqueue entry suspend thread\n");
  254. rt_kprintf("-------- ---- --------------\n");
  255. for (node = list->next; node != list; node = node->next)
  256. {
  257. m = (struct rt_messagequeue*)(rt_list_entry(node, struct rt_object, list));
  258. if( !rt_list_isempty(&m->parent.suspend_thread) )
  259. {
  260. rt_kprintf("%-8s %04d %d:", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread));
  261. show_wait_queue(&(m->parent.suspend_thread));
  262. rt_kprintf("\n");
  263. }
  264. else
  265. {
  266. rt_kprintf("%-8s %04d %d\n", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread));
  267. }
  268. }
  269. return 0;
  270. }
  271. long list_msgqueue(void)
  272. {
  273. return _list_msgqueue(&rt_object_container[RT_Object_Class_MessageQueue].object_list);
  274. }
  275. FINSH_FUNCTION_EXPORT(list_msgqueue, list message queue in system)
  276. #endif
  277. #ifdef RT_USING_MEMPOOL
  278. static long _list_mempool(struct rt_list_node *list)
  279. {
  280. struct rt_mempool *mp;
  281. struct rt_list_node *node;
  282. rt_kprintf("mempool block total free suspend thread\n");
  283. rt_kprintf("-------- ---- ---- ---- --------------\n");
  284. for (node = list->next; node != list; node = node->next)
  285. {
  286. mp = (struct rt_mempool*)rt_list_entry(node, struct rt_object, list);
  287. if (mp->suspend_thread_count > 0)
  288. {
  289. rt_kprintf("%-8s %04d %04d %04d %d:", mp->parent.name,
  290. mp->block_size, mp->block_total_count, mp->block_free_count,
  291. mp->suspend_thread_count);
  292. show_wait_queue(&(mp->suspend_thread));
  293. rt_kprintf("\n");
  294. }
  295. else
  296. {
  297. rt_kprintf("%-8s %04d %04d %04d %d\n", mp->parent.name,
  298. mp->block_size, mp->block_total_count, mp->block_free_count,
  299. mp->suspend_thread_count);
  300. }
  301. }
  302. return 0;
  303. }
  304. long list_mempool(void)
  305. {
  306. return _list_mempool(&rt_object_container[RT_Object_Class_MemPool].object_list);
  307. }
  308. FINSH_FUNCTION_EXPORT(list_mempool, list memory pool in system)
  309. #endif
  310. static long _list_timer(struct rt_list_node *list)
  311. {
  312. struct rt_timer *timer;
  313. struct rt_list_node *node;
  314. rt_kprintf("timer periodic timeout flag\n");
  315. rt_kprintf("-------- ---------- ---------- -----------\n");
  316. for (node = list->next; node != list; node = node->next)
  317. {
  318. timer = (struct rt_timer*)(rt_list_entry(node, struct rt_object, list));
  319. rt_kprintf("%-8s 0x%08x 0x%08x ", timer->parent.name, timer->init_tick, timer->timeout_tick);
  320. if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED) rt_kprintf("activated\n");
  321. else rt_kprintf("deactivated\n");
  322. }
  323. rt_kprintf("current tick:0x%08x\n", rt_tick_get());
  324. return 0;
  325. }
  326. long list_timer(void)
  327. {
  328. return _list_timer(&rt_object_container[RT_Object_Class_Timer].object_list);
  329. }
  330. FINSH_FUNCTION_EXPORT(list_timer, list timer in system)
  331. #ifdef RT_USING_DEVICE
  332. static long _list_device(struct rt_list_node *list)
  333. {
  334. struct rt_device *device;
  335. struct rt_list_node *node;
  336. const char *device_type_str[] =
  337. {
  338. "Character Device",
  339. "Block Device",
  340. "Network Interface",
  341. "MTD Device",
  342. "CAN",
  343. "RTC",
  344. "Unknown"
  345. };
  346. rt_kprintf("device type \n");
  347. rt_kprintf("-------- ---------- \n");
  348. for (node = list->next; node != list; node = node->next)
  349. {
  350. device = (struct rt_device*)(rt_list_entry(node, struct rt_object, list));
  351. rt_kprintf("%-8s %-8s \n", device->parent.name, device_type_str[device->type]);
  352. }
  353. return 0;
  354. }
  355. long list_device(void)
  356. {
  357. return _list_device(&rt_object_container[RT_Object_Class_Device].object_list);
  358. }
  359. FINSH_FUNCTION_EXPORT(list_device, list device in system)
  360. #endif
  361. #ifdef RT_USING_MODULE
  362. int list_module(void)
  363. {
  364. struct rt_module *module;
  365. struct rt_list_node *list, *node;
  366. list = &rt_object_container[RT_Object_Class_Module].object_list;
  367. for (node = list->next; node != list; node = node->next)
  368. {
  369. struct rt_list_node *tlist;
  370. struct rt_thread *thread;
  371. rt_uint8_t* ptr;
  372. module = (struct rt_module*)(rt_list_entry(node, struct rt_object, list));
  373. rt_kprintf("______________________________________________________________________\n");
  374. rt_kprintf("[module]%-8s \n", module->parent.name);
  375. /* list main thread in module */
  376. if(module->module_thread != RT_NULL)
  377. {
  378. rt_kprintf(" main thread pri status sp stack size max used left tick error\n");
  379. rt_kprintf("------------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
  380. thread = module->module_thread;
  381. rt_kprintf("%-8s 0x%02x", thread->name, thread->current_priority);
  382. if (thread->stat == RT_THREAD_READY) rt_kprintf(" ready ");
  383. else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
  384. else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
  385. ptr = (rt_uint8_t*)thread->stack_addr;
  386. while (*ptr == '#')ptr ++;
  387. rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
  388. thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
  389. thread->stack_size,
  390. thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
  391. thread->remaining_tick,
  392. thread->error);
  393. }
  394. /* list sub thread in module */
  395. tlist = &module->module_object[RT_Object_Class_Thread].object_list;
  396. if(!rt_list_isempty(tlist)) _list_thread(tlist);
  397. #ifdef RT_USING_SEMAPHORE
  398. /* list semaphored in module */
  399. tlist = &module->module_object[RT_Object_Class_Semaphore].object_list;
  400. if(!rt_list_isempty(tlist)) _list_sem(tlist);
  401. #endif
  402. #ifdef RT_USING_MUTEX
  403. /* list mutex in module */
  404. tlist = &module->module_object[RT_Object_Class_Mutex].object_list;
  405. if(!rt_list_isempty(tlist)) _list_mutex(tlist);
  406. #endif
  407. #ifdef RT_USING_EVENT
  408. /* list event in module */
  409. tlist = &module->module_object[RT_Object_Class_Event].object_list;
  410. if(!rt_list_isempty(tlist)) _list_event(tlist);
  411. #endif
  412. #ifdef RT_USING_MAILBOX
  413. /* list mailbox in module */
  414. tlist = &module->module_object[RT_Object_Class_MailBox].object_list;
  415. if(!rt_list_isempty(tlist)) _list_mailbox(tlist);
  416. #endif
  417. #ifdef RT_USING_MESSAGEQUEUE
  418. /* list message queue in module */
  419. tlist = &module->module_object[RT_Object_Class_MessageQueue].object_list;
  420. if(!rt_list_isempty(tlist)) _list_msgqueue(tlist);
  421. #endif
  422. #ifdef RT_USING_MEMPOOL
  423. /* list memory pool in module */
  424. tlist = &module->module_object[RT_Object_Class_MemPool].object_list;
  425. if(!rt_list_isempty(tlist)) _list_mempool(tlist);
  426. #endif
  427. #ifdef RT_USING_DEVICE
  428. /* list device in module */
  429. tlist = &module->module_object[RT_Object_Class_Device].object_list;
  430. if(!rt_list_isempty(tlist)) _list_device(tlist);
  431. #endif
  432. /* list timer in module */
  433. tlist = &module->module_object[RT_Object_Class_Timer].object_list;
  434. if(!rt_list_isempty(tlist)) _list_timer(tlist);
  435. }
  436. rt_kprintf("______________________________________________________________________\n");
  437. return 0;
  438. }
  439. FINSH_FUNCTION_EXPORT(list_module, list module in system)
  440. #endif
  441. int list()
  442. {
  443. struct finsh_syscall_item* syscall_item;
  444. struct finsh_sysvar_item* sysvar_item;
  445. rt_kprintf("--Function List:\n");
  446. {
  447. struct finsh_syscall* index;
  448. for (index = _syscall_table_begin; index < _syscall_table_end; index ++)
  449. {
  450. #ifdef FINSH_USING_DESCRIPTION
  451. rt_kprintf("%-16s -- %s\n", index->name, index->desc);
  452. #else
  453. rt_kprintf("%s\n", index->name);
  454. #endif
  455. }
  456. }
  457. /* list syscall list */
  458. syscall_item = global_syscall_list;
  459. while (syscall_item != NULL)
  460. {
  461. rt_kprintf("[l] %s\n", syscall_item->syscall.name);
  462. syscall_item = syscall_item->next;
  463. }
  464. rt_kprintf("--Variable List:\n");
  465. {
  466. struct finsh_sysvar* index;
  467. for (index = _sysvar_table_begin; index < _sysvar_table_end; index ++)
  468. {
  469. #ifdef FINSH_USING_DESCRIPTION
  470. rt_kprintf("%-16s -- %s\n", index->name, index->desc);
  471. #else
  472. rt_kprintf("%s\n", index->name);
  473. #endif
  474. }
  475. }
  476. sysvar_item = global_sysvar_list;
  477. while (sysvar_item != NULL)
  478. {
  479. rt_kprintf("[l] %s\n", sysvar_item->sysvar.name);
  480. sysvar_item = sysvar_item->next;
  481. }
  482. return 0;
  483. }
  484. FINSH_FUNCTION_EXPORT(list, list all symbol in system)
  485. static int str_is_prefix(const char* prefix, const char* str)
  486. {
  487. while ((*prefix) && (*prefix == *str))
  488. {
  489. prefix ++;
  490. str ++;
  491. }
  492. if (*prefix == 0) return 0;
  493. return -1;
  494. }
  495. void list_prefix(char* prefix)
  496. {
  497. struct finsh_syscall_item* syscall_item;
  498. struct finsh_sysvar_item* sysvar_item;
  499. rt_uint16_t func_cnt, var_cnt;
  500. const char* name_ptr;
  501. func_cnt = 0;
  502. var_cnt = 0;
  503. name_ptr = RT_NULL;
  504. {
  505. struct finsh_syscall* index;
  506. for (index = _syscall_table_begin; index < _syscall_table_end; index ++)
  507. {
  508. if (str_is_prefix(prefix, index->name) == 0)
  509. {
  510. if (func_cnt == 0)
  511. rt_kprintf("--function:\n");
  512. func_cnt ++;
  513. /* set name_ptr */
  514. name_ptr = index->name;
  515. #ifdef FINSH_USING_DESCRIPTION
  516. rt_kprintf("%-16s -- %s\n", index->name, index->desc);
  517. #else
  518. rt_kprintf("%s\n", index->name);
  519. #endif
  520. }
  521. }
  522. }
  523. /* list syscall list */
  524. syscall_item = global_syscall_list;
  525. while (syscall_item != NULL)
  526. {
  527. if (str_is_prefix(prefix, syscall_item->syscall.name) == 0)
  528. {
  529. if (func_cnt == 0)
  530. rt_kprintf("--function:\n");
  531. func_cnt ++;
  532. /* set name_ptr */
  533. name_ptr = syscall_item->syscall.name;
  534. rt_kprintf("[l] %s\n", syscall_item->syscall.name);
  535. }
  536. syscall_item = syscall_item->next;
  537. }
  538. {
  539. struct finsh_sysvar* index;
  540. for (index = _sysvar_table_begin; index < _sysvar_table_end; index ++)
  541. {
  542. if (str_is_prefix(prefix, index->name) == 0)
  543. {
  544. if (var_cnt == 0)
  545. rt_kprintf("--variable:\n");
  546. var_cnt ++;
  547. /* set name ptr */
  548. name_ptr = index->name;
  549. #ifdef FINSH_USING_DESCRIPTION
  550. rt_kprintf("%-16s -- %s\n", index->name, index->desc);
  551. #else
  552. rt_kprintf("%s\n", index->name);
  553. #endif
  554. }
  555. }
  556. }
  557. sysvar_item = global_sysvar_list;
  558. while (sysvar_item != NULL)
  559. {
  560. if (str_is_prefix(prefix, sysvar_item->sysvar.name) == 0)
  561. {
  562. if (var_cnt == 0)
  563. rt_kprintf("--variable:\n");
  564. var_cnt ++;
  565. /* set name ptr */
  566. name_ptr = sysvar_item->sysvar.name;
  567. rt_kprintf("[l] %s\n", sysvar_item->sysvar.name);
  568. }
  569. sysvar_item = sysvar_item->next;
  570. }
  571. /* only one matched */
  572. if ((func_cnt + var_cnt) == 1)
  573. {
  574. rt_strncpy(prefix, name_ptr, strlen(name_ptr));
  575. }
  576. }
  577. #ifdef FINSH_USING_SYMTAB
  578. static int dummy = 0;
  579. FINSH_VAR_EXPORT(dummy, finsh_type_int, dummy variable for finsh)
  580. #endif