Skip to content

Commit f4248a9

Browse files
committed
[Finsh] Add script feature for msh.
1 parent 147901c commit f4248a9

File tree

6 files changed

+340
-163
lines changed

6 files changed

+340
-163
lines changed

components/finsh/SConscript

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ finsh_token.c
2222
''')
2323

2424
msh_src = Split('''
25-
msh_cmd.c
2625
msh.c
26+
msh_cmd.c
27+
msh_file.c
2728
''')
2829

2930
CPPPATH = [cwd]

components/finsh/cmd.c

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ static long _list_thread(struct rt_list_node *list)
9999
else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
100100
else if (thread->stat == RT_THREAD_CLOSE) rt_kprintf(" close ");
101101

102-
ptr = (rt_uint8_t*)thread->stack_addr;
102+
ptr = (rt_uint8_t *)thread->stack_addr;
103103
while (*ptr == '#')ptr ++;
104104

105105
rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
106-
thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
107-
thread->stack_size,
108-
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
109-
thread->remaining_tick,
110-
thread->error);
106+
thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
107+
thread->stack_size,
108+
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
109+
thread->remaining_tick,
110+
thread->error);
111111
}
112-
112+
113113
return 0;
114114
}
115115

@@ -148,7 +148,7 @@ static long _list_sem(struct rt_list_node *list)
148148
sem = (struct rt_semaphore *)(rt_list_entry(node, struct rt_object, list));
149149
if (!rt_list_isempty(&sem->parent.suspend_thread))
150150
{
151-
rt_kprintf("%-8.*s %03d %d:",
151+
rt_kprintf("%-8.*s %03d %d:",
152152
RT_NAME_MAX,
153153
sem->parent.parent.name,
154154
sem->value,
@@ -448,7 +448,7 @@ static long _list_device(struct rt_list_node *list)
448448
{
449449
struct rt_device *device;
450450
struct rt_list_node *node;
451-
char * const device_type_str[] =
451+
char *const device_type_str[] =
452452
{
453453
"Character Device",
454454
"Block Device",
@@ -464,11 +464,11 @@ static long _list_device(struct rt_list_node *list)
464464
"SPI Bus",
465465
"SPI Device",
466466
"SDIO Bus",
467-
"PM Pseudo Device",
467+
"PM Pseudo Device",
468468
"Pipe",
469469
"Portal Device",
470-
"Timer Device",
471-
"Miscellaneous Device",
470+
"Timer Device",
471+
"Miscellaneous Device",
472472
"Unknown"
473473
};
474474

@@ -507,13 +507,13 @@ int list_module(void)
507507

508508
list = &rt_object_container[RT_Object_Class_Module].object_list;
509509

510-
rt_kprintf("module name ref\n");
511-
rt_kprintf("------------ --------\n");
510+
rt_kprintf("module name ref address \n");
511+
rt_kprintf("------------ -------- ------------\n");
512512
for (node = list->next; node != list; node = node->next)
513513
{
514514
module = (struct rt_module *)(rt_list_entry(node, struct rt_object, list));
515-
rt_kprintf("%-16.*s %-04d\n",
516-
RT_NAME_MAX, module->parent.name, module->nref);
515+
rt_kprintf("%-16.*s %-04d 0x%08x\n",
516+
RT_NAME_MAX, module->parent.name, module->nref, module->module_space);
517517
}
518518

519519
return 0;
@@ -525,13 +525,13 @@ int list_mod_detail(const char *name)
525525
{
526526
int i;
527527
struct rt_module *module;
528-
528+
529529
/* find module */
530530
if ((module = rt_module_find(name)) != RT_NULL)
531531
{
532532
/* module has entry point */
533533
if (!(module->parent.flag & RT_MODULE_FLAG_WITHOUTENTRY))
534-
{
534+
{
535535
struct rt_thread *thread;
536536
struct rt_list_node *tlist;
537537
rt_uint8_t *ptr;
@@ -548,15 +548,15 @@ int list_mod_detail(const char *name)
548548
else if (thread->stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
549549
else if (thread->stat == RT_THREAD_INIT) rt_kprintf(" init ");
550550

551-
ptr = (rt_uint8_t*)thread->stack_addr;
551+
ptr = (rt_uint8_t *)thread->stack_addr;
552552
while (*ptr == '#')ptr ++;
553553

554554
rt_kprintf(" 0x%08x 0x%08x 0x%08x 0x%08x %03d\n",
555-
thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
556-
thread->stack_size,
557-
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
558-
thread->remaining_tick,
559-
thread->error);
555+
thread->stack_size + ((rt_uint32_t)thread->stack_addr - (rt_uint32_t)thread->sp),
556+
thread->stack_size,
557+
thread->stack_size - ((rt_uint32_t) ptr - (rt_uint32_t)thread->stack_addr),
558+
thread->remaining_tick,
559+
thread->error);
560560
}
561561

562562
/* list sub thread in module */
@@ -607,18 +607,18 @@ int list_mod_detail(const char *name)
607607
if (!rt_list_isempty(tlist)) _list_timer(tlist);
608608
}
609609

610-
if (module->nsym > 0)
611-
{
612-
rt_kprintf("symbol address \n");
613-
rt_kprintf("-------- ----------\n");
614-
615-
/* list module export symbols */
616-
for (i=0; i<module->nsym; i++)
617-
{
618-
rt_kprintf("%s 0x%x\n",
619-
module->symtab[i].name, module->symtab[i].addr);
620-
}
621-
}
610+
if (module->nsym > 0)
611+
{
612+
rt_kprintf("symbol address \n");
613+
rt_kprintf("-------- ----------\n");
614+
615+
/* list module export symbols */
616+
for (i = 0; i < module->nsym; i++)
617+
{
618+
rt_kprintf("%s 0x%x\n",
619+
module->symtab[i].name, module->symtab[i].addr);
620+
}
621+
}
622622
}
623623

624624
return 0;
@@ -632,16 +632,16 @@ long list(void)
632632
struct finsh_syscall_item *syscall_item;
633633
struct finsh_sysvar_item *sysvar_item;
634634
#endif
635-
635+
636636
rt_kprintf("--Function List:\n");
637637
{
638638
struct finsh_syscall *index;
639639
for (index = _syscall_table_begin;
640-
index < _syscall_table_end;
641-
FINSH_NEXT_SYSCALL(index))
640+
index < _syscall_table_end;
641+
FINSH_NEXT_SYSCALL(index))
642642
{
643-
/* skip the internal command */
644-
if (strncmp((char*)index->name, "__", 2) == 0) continue;
643+
/* skip the internal command */
644+
if (strncmp((char *)index->name, "__", 2) == 0) continue;
645645

646646
#ifdef FINSH_USING_DESCRIPTION
647647
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
@@ -664,8 +664,8 @@ long list(void)
664664
{
665665
struct finsh_sysvar *index;
666666
for (index = _sysvar_table_begin;
667-
index < _sysvar_table_end;
668-
FINSH_NEXT_SYSVAR(index))
667+
index < _sysvar_table_end;
668+
FINSH_NEXT_SYSVAR(index))
669669
{
670670
#ifdef FINSH_USING_DESCRIPTION
671671
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
@@ -682,7 +682,7 @@ long list(void)
682682
sysvar_item = sysvar_item->next;
683683
}
684684
#endif
685-
685+
686686
return 0;
687687
}
688688
FINSH_FUNCTION_EXPORT(list, list all symbol in system)
@@ -732,12 +732,12 @@ void list_prefix(char *prefix)
732732
{
733733
struct finsh_syscall *index;
734734
for (index = _syscall_table_begin;
735-
index < _syscall_table_end;
736-
FINSH_NEXT_SYSCALL(index))
735+
index < _syscall_table_end;
736+
FINSH_NEXT_SYSCALL(index))
737737
{
738-
/* skip internal command */
739-
if (str_is_prefix("__", index->name) == 0) continue;
740-
738+
/* skip internal command */
739+
if (str_is_prefix("__", index->name) == 0) continue;
740+
741741
if (str_is_prefix(prefix, index->name) == 0)
742742
{
743743
if (func_cnt == 0)
@@ -807,10 +807,10 @@ void list_prefix(char *prefix)
807807

808808
/* checks in system variable */
809809
{
810-
struct finsh_sysvar* index;
810+
struct finsh_sysvar *index;
811811
for (index = _sysvar_table_begin;
812-
index < _sysvar_table_end;
813-
FINSH_NEXT_SYSVAR(index))
812+
index < _sysvar_table_end;
813+
FINSH_NEXT_SYSVAR(index))
814814
{
815815
if (str_is_prefix(prefix, index->name) == 0)
816816
{

0 commit comments

Comments
 (0)