MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / finsh_system_init

Function finsh_system_init

components/finsh/shell.c:950–1018  ·  view source on GitHub ↗

* @ingroup group_finsh * * This function will initialize finsh shell */

Source from the content-addressed store, hash-verified

948 * This function will initialize finsh shell
949 */
950int finsh_system_init(void)
951{
952 rt_err_t result = RT_EOK;
953 rt_thread_t tid;
954
955#ifdef FINSH_USING_SYMTAB
956#ifdef __ARMCC_VERSION /* ARM C Compiler */
957 extern const int FSymTab$$Base;
958 extern const int FSymTab$$Limit;
959 finsh_system_function_init(&FSymTab$$Base, &FSymTab$$Limit);
960#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */
961 finsh_system_function_init(__section_begin("FSymTab"),
962 __section_end("FSymTab"));
963#elif defined (__GNUC__) || defined(__TI_COMPILER_VERSION__) || defined(__TASKING__)
964 /* GNU GCC Compiler and TI CCS */
965 extern const int __fsymtab_start;
966 extern const int __fsymtab_end;
967 finsh_system_function_init(&__fsymtab_start, &__fsymtab_end);
968#elif defined(__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
969 finsh_system_function_init(&__fsymtab_start, &__fsymtab_end);
970#elif defined(_MSC_VER)
971 unsigned int *ptr_begin, *ptr_end;
972
973 if (shell)
974 {
975 rt_kprintf("finsh shell already init.\n");
976 return RT_EOK;
977 }
978
979 ptr_begin = (unsigned int *)&__fsym_begin;
980 ptr_begin += (sizeof(struct finsh_syscall) / sizeof(unsigned int));
981 while (*ptr_begin == 0) ptr_begin ++;
982
983 ptr_end = (unsigned int *) &__fsym_end;
984 ptr_end --;
985 while (*ptr_end == 0) ptr_end --;
986
987 finsh_system_function_init(ptr_begin, ptr_end);
988#endif
989#endif
990
991#ifdef RT_USING_HEAP
992 /* create or set shell structure */
993 shell = (struct finsh_shell *)rt_calloc(1, sizeof(struct finsh_shell));
994 if (shell == RT_NULL)
995 {
996 rt_kprintf("no memory for shell\n");
997 return -1;
998 }
999 tid = rt_thread_create(FINSH_THREAD_NAME,
1000 finsh_thread_entry, RT_NULL,
1001 FINSH_THREAD_STACK_SIZE, FINSH_THREAD_PRIORITY, 10);
1002#else
1003 shell = &_shell;
1004 tid = &finsh_thread;
1005 result = rt_thread_init(&finsh_thread,
1006 FINSH_THREAD_NAME,
1007 finsh_thread_entry, RT_NULL,

Callers 15

rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rt_init_thread_entryFunction · 0.85
rtthread_startupFunction · 0.85
rt_init_thread_entryFunction · 0.85

Calls 8

rt_kprintfFunction · 0.85
rt_callocFunction · 0.85
rt_thread_createFunction · 0.85
rt_thread_initFunction · 0.85
rt_sem_initFunction · 0.85
finsh_set_prompt_modeFunction · 0.85
rt_thread_startupFunction · 0.85

Tested by

no test coverage detected