mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-06 17:12:01 +08:00
Merge pull request #4970 from cndabai/master
Remove C Style Command Shell
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
#include "board.h"
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -30,8 +30,8 @@ extern void rt_hw_serial_init(void);
|
||||
|
||||
/*@{*/
|
||||
#ifdef RT_USING_FINSH
|
||||
extern int finsh_system_init(void);
|
||||
extern void finsh_set_device(char* device);
|
||||
extern int finsh_system_init(void);
|
||||
extern void finsh_set_device(const char *device);
|
||||
#endif
|
||||
|
||||
extern int rt_application_init(void);
|
||||
@@ -39,11 +39,11 @@ extern void rt_hw_sdcard_init(void);
|
||||
extern int rt_hw_luminaryif_init(void);
|
||||
|
||||
#ifdef __CC_ARM
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
#elif __ICCARM__
|
||||
#pragma section="HEAP"
|
||||
#pragma section="HEAP"
|
||||
#else
|
||||
extern int __bss_end;
|
||||
extern int __bss_end;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -56,13 +56,13 @@ extern int __bss_end;
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void assert_failed(u8* file, u32 line)
|
||||
void assert_failed(u8 *file, u32 line)
|
||||
{
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
|
||||
while (1) ;
|
||||
while (1) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,76 +71,76 @@ void assert_failed(u8* file, u32 line)
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
#ifdef __CC_ARM
|
||||
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)LM3S_SRAM_END);
|
||||
rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)LM3S_SRAM_END);
|
||||
#elif __ICCARM__
|
||||
rt_system_heap_init(__segment_end("HEAP"), (void*)LM3S_SRAM_END);
|
||||
rt_system_heap_init(__segment_end("HEAP"), (void *)LM3S_SRAM_END);
|
||||
#else
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void*)&__bss_end, (void*)LM3S_SRAM_END);
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void *)&__bss_end, (void *)LM3S_SRAM_END);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
/* init module system */
|
||||
rt_system_module_init();
|
||||
#ifdef RT_USING_MODULE
|
||||
/* init module system */
|
||||
rt_system_module_init();
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
eth_system_device_init();
|
||||
eth_system_device_init();
|
||||
|
||||
/* register ethernetif device */
|
||||
rt_hw_luminaryif_init();
|
||||
/* register ethernetif device */
|
||||
rt_hw_luminaryif_init();
|
||||
#endif
|
||||
|
||||
/* init hardware serial device */
|
||||
rt_hw_serial_init();
|
||||
/* init hardware serial device */
|
||||
rt_hw_serial_init();
|
||||
#ifdef RT_USING_DFS
|
||||
/* init sd card device */
|
||||
rt_hw_sdcard_init();
|
||||
/* init sd card device */
|
||||
rt_hw_sdcard_init();
|
||||
#endif
|
||||
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
/* init finsh */
|
||||
finsh_system_init();
|
||||
/* init finsh */
|
||||
finsh_system_init();
|
||||
#ifdef RT_USING_DEVICE
|
||||
finsh_set_device("uart1");
|
||||
finsh_set_device("uart1");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include "board.h"
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -30,8 +30,8 @@ extern void rt_hw_serial_init(void);
|
||||
|
||||
/*@{*/
|
||||
#ifdef RT_USING_FINSH
|
||||
extern int finsh_system_init(void);
|
||||
extern void finsh_set_device(char* device);
|
||||
extern int finsh_system_init(void);
|
||||
extern void finsh_set_device(const char *device);
|
||||
#endif
|
||||
|
||||
extern int rt_application_init(void);
|
||||
@@ -39,11 +39,11 @@ extern void rt_hw_sdcard_init(void);
|
||||
extern int rt_hw_luminaryif_init(void);
|
||||
|
||||
#ifdef __CC_ARM
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
#elif __ICCARM__
|
||||
#pragma section="HEAP"
|
||||
#pragma section="HEAP"
|
||||
#else
|
||||
extern int __bss_end;
|
||||
extern int __bss_end;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -56,13 +56,13 @@ extern int __bss_end;
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void __error__(char* file, unsigned long line)
|
||||
void __error__(char *file, unsigned long line)
|
||||
{
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
|
||||
while (1) ;
|
||||
while (1) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,77 +71,77 @@ void __error__(char* file, unsigned long line)
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
#if LM3S_EXT_SRAM == 1
|
||||
/* init sdram */
|
||||
rt_system_heap_init((void*)LM3S_EXT_SRAM_BEGIN, (void*)LM3S_EXT_SRAM_END);
|
||||
/* init sdram */
|
||||
rt_system_heap_init((void *)LM3S_EXT_SRAM_BEGIN, (void *)LM3S_EXT_SRAM_END);
|
||||
#else
|
||||
#ifdef __CC_ARM
|
||||
rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)LM3S_SRAM_END);
|
||||
rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)LM3S_SRAM_END);
|
||||
#elif __ICCARM__
|
||||
rt_system_heap_init(__segment_end("HEAP"), (void*)LM3S_SRAM_END);
|
||||
rt_system_heap_init(__segment_end("HEAP"), (void *)LM3S_SRAM_END);
|
||||
#else
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void*)&__bss_end, (void*)LM3S_SRAM_END);
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void *)&__bss_end, (void *)LM3S_SRAM_END);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
eth_system_device_init();
|
||||
eth_system_device_init();
|
||||
|
||||
/* register ethernetif device */
|
||||
rt_hw_luminaryif_init();
|
||||
/* register ethernetif device */
|
||||
rt_hw_luminaryif_init();
|
||||
#endif
|
||||
|
||||
/* init hardware serial device */
|
||||
rt_hw_serial_init();
|
||||
/* init hardware serial device */
|
||||
rt_hw_serial_init();
|
||||
#ifdef RT_USING_DFS
|
||||
/* init sd card device */
|
||||
rt_hw_sdcard_init();
|
||||
/* init sd card device */
|
||||
rt_hw_sdcard_init();
|
||||
#endif
|
||||
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
/* init finsh */
|
||||
finsh_system_init();
|
||||
/* init finsh */
|
||||
finsh_system_init();
|
||||
#ifdef RT_USING_DEVICE
|
||||
finsh_set_device("uart1");
|
||||
finsh_set_device("uart1");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
rtthread_startup();
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include "board.h"
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -30,8 +30,8 @@ extern void rt_hw_serial_init(void);
|
||||
|
||||
/*@{*/
|
||||
#ifdef RT_USING_FINSH
|
||||
extern int finsh_system_init(void);
|
||||
extern void finsh_set_device(char* device);
|
||||
extern int finsh_system_init(void);
|
||||
extern void finsh_set_device(const char *device);
|
||||
#endif
|
||||
|
||||
extern int rt_application_init(void);
|
||||
@@ -39,11 +39,11 @@ extern void rt_hw_sdcard_init(void);
|
||||
extern int rt_hw_luminaryif_init(void);
|
||||
|
||||
#ifdef __CC_ARM
|
||||
extern int Image$$ER_ZI$$ZI$$Limit;
|
||||
extern int Image$$ER_ZI$$ZI$$Limit;
|
||||
#elif __ICCARM__
|
||||
#pragma section="HEAP"
|
||||
#pragma section="HEAP"
|
||||
#else
|
||||
extern int __bss_end;
|
||||
extern int __bss_end;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -56,13 +56,13 @@ extern int __bss_end;
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void __error__(char* file, unsigned long line)
|
||||
void __error__(char *file, unsigned long line)
|
||||
{
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
rt_kprintf("\n\r Wrong parameter value detected on\r\n");
|
||||
rt_kprintf(" file %s\r\n", file);
|
||||
rt_kprintf(" line %d\r\n", line);
|
||||
|
||||
while (1) ;
|
||||
while (1) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,77 +71,77 @@ void __error__(char* file, unsigned long line)
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
#if LM3S_EXT_SRAM == 1
|
||||
/* init sdram */
|
||||
rt_system_heap_init((void*)LM3S_EXT_SRAM_BEGIN, (void*)LM3S_EXT_SRAM_END);
|
||||
/* init sdram */
|
||||
rt_system_heap_init((void *)LM3S_EXT_SRAM_BEGIN, (void *)LM3S_EXT_SRAM_END);
|
||||
#else
|
||||
#ifdef __CC_ARM
|
||||
rt_system_heap_init((void*)&Image$$ER_ZI$$ZI$$Limit, (void*)LM3S_SRAM_END);
|
||||
rt_system_heap_init((void *)&Image$$ER_ZI$$ZI$$Limit, (void *)LM3S_SRAM_END);
|
||||
#elif __ICCARM__
|
||||
rt_system_heap_init(__segment_end("HEAP"), (void*)LM3S_SRAM_END);
|
||||
rt_system_heap_init(__segment_end("HEAP"), (void *)LM3S_SRAM_END);
|
||||
#else
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void*)&__bss_end, (void*)LM3S_SRAM_END);
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void *)&__bss_end, (void *)LM3S_SRAM_END);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
eth_system_device_init();
|
||||
eth_system_device_init();
|
||||
|
||||
/* register ethernetif device */
|
||||
rt_hw_luminaryif_init();
|
||||
/* register ethernetif device */
|
||||
rt_hw_luminaryif_init();
|
||||
#endif
|
||||
|
||||
/* init hardware serial device */
|
||||
rt_hw_serial_init();
|
||||
/* init hardware serial device */
|
||||
rt_hw_serial_init();
|
||||
#ifdef RT_USING_DFS
|
||||
/* init sd card device */
|
||||
rt_hw_sdcard_init();
|
||||
/* init sd card device */
|
||||
rt_hw_sdcard_init();
|
||||
#endif
|
||||
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
/* init finsh */
|
||||
finsh_system_init();
|
||||
/* init finsh */
|
||||
finsh_system_init();
|
||||
#ifdef RT_USING_DEVICE
|
||||
finsh_set_device("uart1");
|
||||
finsh_set_device("uart1");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
rtthread_startup();
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -138,5 +138,5 @@ static void reboot(uint8_t argc, char **argv)
|
||||
{
|
||||
rt_hw_cpu_reset();
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
|
||||
MSH_CMD_EXPORT(reboot, Reboot System);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
@@ -138,6 +138,6 @@ static void reboot(uint8_t argc, char **argv)
|
||||
{
|
||||
rt_hw_cpu_reset();
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
|
||||
MSH_CMD_EXPORT(reboot, Reboot System);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ static void reboot(uint8_t argc, char **argv)
|
||||
{
|
||||
rt_hw_cpu_reset();
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
|
||||
MSH_CMD_EXPORT(reboot, Reboot System);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
/* SysTick configuration */
|
||||
|
||||
@@ -255,7 +255,7 @@ static void reboot(uint8_t argc, char **argv)
|
||||
{
|
||||
rt_hw_cpu_reset();
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
|
||||
MSH_CMD_EXPORT(reboot, Reboot System);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -144,7 +144,7 @@ rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
static int adc(int argc, char **argv)
|
||||
{
|
||||
@@ -232,4 +232,4 @@ static int adc(int argc, char **argv)
|
||||
}
|
||||
MSH_CMD_EXPORT(adc, adc function);
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
@@ -141,7 +141,7 @@ rt_err_t rt_dac_disabled(rt_dac_device_t dev, rt_uint32_t channel)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
static int dac(int argc, char **argv)
|
||||
{
|
||||
@@ -228,4 +228,4 @@ static int dac(int argc, char **argv)
|
||||
}
|
||||
MSH_CMD_EXPORT(dac, dac function);
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
@@ -198,7 +198,7 @@ rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *c
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_pwm_enable, pwm_enable, enable pwm by channel.);
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_pwm_set, pwm_set, set pwm.);
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
static int pwm_enable(int argc, char **argv)
|
||||
{
|
||||
int result = 0;
|
||||
@@ -323,5 +323,5 @@ _exit:
|
||||
}
|
||||
MSH_CMD_EXPORT(pwm_get, pwm_get <pwm_dev> <channel>);
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
@@ -278,7 +278,7 @@ int mtd_nand_erase_all(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
static void mtd_nand(int argc, char **argv)
|
||||
{
|
||||
/* If the number of arguments less than 2 */
|
||||
@@ -346,16 +346,16 @@ help:
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(mtd_nand, MTD nand device test function);
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
#ifndef RT_USING_FINSH_ONLY
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nandid, nand_id, read ID - nandid(name));
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_read, nand_read, read page in nand - nand_read(name, block, page));
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_readoob, nand_readoob, read spare data in nand - nand_readoob(name, block, page));
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_write, nand_write, write dump data to nand - nand_write(name, block, page));
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_erase, nand_erase, nand_erase(name, block));
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_erase_all, nand_erase_all, erase all of nand device - nand_erase_all(name, block));
|
||||
#endif /* FINSH_USING_MSH_ONLY */
|
||||
#endif /* RT_USING_FINSH_ONLY */
|
||||
|
||||
#endif /* defined(RT_MTD_NAND_DEBUG) && defined(RT_USING_FINSH) */
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
/**
|
||||
* get date and time or set (local timezone) [year month day hour min sec]
|
||||
@@ -283,6 +283,6 @@ static void date(uint8_t argc, char **argv)
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(date, get date and time or set (local timezone) [year month day hour min sec])
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
#endif /* RT_USING_RTC */
|
||||
|
||||
@@ -155,7 +155,7 @@ static void sensor_fifo(int argc, char **argv)
|
||||
|
||||
rt_device_control(dev, RT_SENSOR_CTRL_SET_ODR, (void *)20);
|
||||
}
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
MSH_CMD_EXPORT(sensor_fifo, Sensor fifo mode test function);
|
||||
#endif
|
||||
|
||||
@@ -219,7 +219,7 @@ static void sensor_int(int argc, char **argv)
|
||||
}
|
||||
rt_device_control(dev, RT_SENSOR_CTRL_SET_ODR, (void *)20);
|
||||
}
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
MSH_CMD_EXPORT(sensor_int, Sensor interrupt mode test function);
|
||||
#endif
|
||||
|
||||
@@ -268,7 +268,7 @@ static void sensor_polling(int argc, char **argv)
|
||||
}
|
||||
rt_device_close(dev);
|
||||
}
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
MSH_CMD_EXPORT(sensor_polling, Sensor polling mode test function);
|
||||
#endif
|
||||
|
||||
@@ -496,6 +496,6 @@ static void sensor(int argc, char **argv)
|
||||
LOG_W("Unknown command, please enter 'sensor' get help information!");
|
||||
}
|
||||
}
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
MSH_CMD_EXPORT(sensor, sensor test function);
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <rtdevice.h>
|
||||
#include "spi_flash.h"
|
||||
#include "spi_flash_sfud.h"
|
||||
@@ -508,7 +509,7 @@ __error:
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
|
||||
#if defined(RT_USING_FINSH)
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
@@ -773,6 +774,6 @@ static void sf(uint8_t argc, char **argv) {
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(sf, SPI Flash operate.);
|
||||
#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
|
||||
#endif /* defined(RT_USING_FINSH) */
|
||||
|
||||
#endif /* RT_USING_SFUD */
|
||||
|
||||
@@ -586,7 +586,7 @@ static int wifi_msh(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
|
||||
#if defined(RT_USING_FINSH)
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(wifi_msh, __cmd_wifi, wifi command.);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
menu "Command shell"
|
||||
|
||||
config RT_USING_FINSH
|
||||
bool "finsh shell"
|
||||
bool
|
||||
default n
|
||||
|
||||
config RT_USING_MSH
|
||||
bool "msh shell"
|
||||
select RT_USING_FINSH
|
||||
default y
|
||||
|
||||
if RT_USING_FINSH
|
||||
if RT_USING_MSH
|
||||
|
||||
config FINSH_THREAD_NAME
|
||||
string "The finsh thread name"
|
||||
string "The msh thread name"
|
||||
default "tshell"
|
||||
config FINSH_USING_HISTORY
|
||||
bool "Enable command history feature"
|
||||
@@ -31,11 +36,11 @@ config FINSH_ECHO_DISABLE_DEFAULT
|
||||
default n
|
||||
|
||||
config FINSH_THREAD_PRIORITY
|
||||
int "The priority level value of finsh thread"
|
||||
int "The priority level value of thread"
|
||||
default 20
|
||||
|
||||
config FINSH_THREAD_STACK_SIZE
|
||||
int "The stack size for finsh thread"
|
||||
int "The stack size for thread"
|
||||
default 4096
|
||||
|
||||
config FINSH_CMD_SIZE
|
||||
@@ -58,23 +63,9 @@ config FINSH_PASSWORD_MAX
|
||||
default RT_NAME_MAX
|
||||
endif
|
||||
|
||||
config FINSH_USING_MSH
|
||||
bool "Using module shell"
|
||||
default y
|
||||
|
||||
if FINSH_USING_MSH
|
||||
config FINSH_USING_MSH_DEFAULT
|
||||
bool "Using module shell in default"
|
||||
default y
|
||||
|
||||
config FINSH_USING_MSH_ONLY
|
||||
bool "Only using module shell"
|
||||
default n
|
||||
|
||||
config FINSH_ARG_MAX
|
||||
int "The command arg num for shell"
|
||||
int "The number of arguments for a shell command"
|
||||
default 10
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -1,39 +1,17 @@
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Split('''
|
||||
shell.c
|
||||
cmd.c
|
||||
msh.c
|
||||
''')
|
||||
|
||||
fsh_src = Split('''
|
||||
finsh_compiler.c
|
||||
finsh_error.c
|
||||
finsh_heap.c
|
||||
finsh_init.c
|
||||
finsh_node.c
|
||||
finsh_ops.c
|
||||
finsh_parser.c
|
||||
finsh_var.c
|
||||
finsh_vm.c
|
||||
finsh_token.c
|
||||
''')
|
||||
|
||||
msh_src = Glob('msh.c')
|
||||
|
||||
if GetDepend('RT_USING_DFS'):
|
||||
msh_src += ['msh_file.c']
|
||||
|
||||
if not GetDepend('FINSH_USING_SYMTAB'):
|
||||
src += ['symbol.c']
|
||||
if GetDepend('FINSH_USING_MSH'):
|
||||
src = src + msh_src
|
||||
if not GetDepend('FINSH_USING_MSH_ONLY'):
|
||||
src = src + fsh_src
|
||||
src += ['msh_file.c']
|
||||
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('finsh', src, depend = ['RT_USING_FINSH'], CPPPATH = CPPPATH)
|
||||
group = DefineGroup('msh', src, depend = ['RT_USING_FINSH'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,239 +11,155 @@
|
||||
#define __FINSH_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "finsh_api.h"
|
||||
|
||||
/* -- the beginning of option -- */
|
||||
#define FINSH_NAME_MAX 16 /* max length of identifier */
|
||||
#define FINSH_NODE_MAX 16 /* max number of node */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma section("FSymTab$f",read)
|
||||
#endif
|
||||
|
||||
#define FINSH_HEAP_MAX 128 /* max length of heap */
|
||||
#define FINSH_STRING_MAX 128 /* max length of string */
|
||||
#define FINSH_VARIABLE_MAX 8 /* max number of variable */
|
||||
typedef long (*syscall_func)(void);
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
#ifdef __TI_COMPILER_VERSION__
|
||||
#define __TI_FINSH_EXPORT_FUNCTION(f) PRAGMA(DATA_SECTION(f,"FSymTab"))
|
||||
#endif
|
||||
#ifdef FINSH_USING_DESCRIPTION
|
||||
#ifdef _MSC_VER
|
||||
#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
const char __fsym_##cmd##_desc[] = #desc; \
|
||||
__declspec(allocate("FSymTab$f")) \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
__fsym_##cmd##_desc, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
#pragma comment(linker, "/merge:FSymTab=mytext")
|
||||
|
||||
#define FINSH_STACK_MAX 64 /* max stack size */
|
||||
#define FINSH_TEXT_MAX 128 /* max text segment size */
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
__TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
const char __fsym_##cmd##_desc[] = #desc; \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
__fsym_##cmd##_desc, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define HEAP_ALIGNMENT 4 /* heap alignment */
|
||||
#else
|
||||
#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] RT_SECTION(".rodata.name") = #cmd; \
|
||||
const char __fsym_##cmd##_desc[] RT_SECTION(".rodata.name") = #desc; \
|
||||
RT_USED const struct finsh_syscall __fsym_##cmd RT_SECTION("FSymTab")= \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
__fsym_##cmd##_desc, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define FINSH_GET16(x) (*(x)) | (*((x)+1) << 8)
|
||||
#define FINSH_GET32(x) (rt_ubase_t)(*(x)) | ((rt_ubase_t)*((x)+1) << 8) | \
|
||||
((rt_ubase_t)*((x)+2) << 16) | ((rt_ubase_t)*((x)+3) << 24)
|
||||
#endif
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
__declspec(allocate("FSymTab$f")) \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
#pragma comment(linker, "/merge:FSymTab=mytext")
|
||||
|
||||
#define FINSH_SET16(x, v) \
|
||||
do \
|
||||
{ \
|
||||
*(x) = (v) & 0x00ff; \
|
||||
(*((x)+1)) = (v) >> 8; \
|
||||
} while ( 0 )
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
__TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define FINSH_SET32(x, v) \
|
||||
do \
|
||||
{ \
|
||||
*(x) = (rt_uint32_t)(v) & 0x000000ff; \
|
||||
(*((x)+1)) = ((rt_uint32_t)(v) >> 8) & 0x000000ff; \
|
||||
(*((x)+2)) = ((rt_uint32_t)(v) >> 16) & 0x000000ff; \
|
||||
(*((x)+3)) = ((rt_uint32_t)(v) >> 24); \
|
||||
} while ( 0 )
|
||||
#else
|
||||
#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
RT_USED const struct finsh_syscall __fsym_##cmd RT_SECTION("FSymTab")= \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
/* -- the end of option -- */
|
||||
|
||||
/* std header file */
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FINSH_VERSION_MAJOR 1
|
||||
#define FINSH_VERSION_MINOR 0
|
||||
#endif
|
||||
#endif /* end of FINSH_USING_DESCRIPTION */
|
||||
#endif /* end of FINSH_USING_SYMTAB */
|
||||
|
||||
/**
|
||||
* @addtogroup finsh
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This macro exports a system function to finsh shell.
|
||||
*
|
||||
* @param name the name of function.
|
||||
* @param desc the description of function, which will show in help.
|
||||
*/
|
||||
/*@{*/
|
||||
#define FINSH_ERROR_OK 0 /**< No error */
|
||||
#define FINSH_ERROR_INVALID_TOKEN 1 /**< Invalid token */
|
||||
#define FINSH_ERROR_EXPECT_TYPE 2 /**< Expect a type */
|
||||
#define FINSH_ERROR_UNKNOWN_TYPE 3 /**< Unknown type */
|
||||
#define FINSH_ERROR_VARIABLE_EXIST 4 /**< Variable exist */
|
||||
#define FINSH_ERROR_EXPECT_OPERATOR 5 /**< Expect a operator */
|
||||
#define FINSH_ERROR_MEMORY_FULL 6 /**< Memory full */
|
||||
#define FINSH_ERROR_UNKNOWN_OP 7 /**< Unknown operator */
|
||||
#define FINSH_ERROR_UNKNOWN_NODE 8 /**< Unknown node */
|
||||
#define FINSH_ERROR_EXPECT_CHAR 9 /**< Expect a character */
|
||||
#define FINSH_ERROR_UNEXPECT_END 10 /**< Unexpect end */
|
||||
#define FINSH_ERROR_UNKNOWN_TOKEN 11 /**< Unknown token */
|
||||
#define FINSH_ERROR_NO_FLOAT 12 /**< Float not supported */
|
||||
#define FINSH_ERROR_UNKNOWN_SYMBOL 13 /**< Unknown symbol */
|
||||
#define FINSH_ERROR_NULL_NODE 14 /**< Null node */
|
||||
/*@}*/
|
||||
#define FINSH_FUNCTION_EXPORT(name, desc)
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This macro exports a system function with an alias name to finsh shell.
|
||||
*
|
||||
* @param name the name of function.
|
||||
* @param alias the alias name of function.
|
||||
* @param desc the description of function, which will show in help.
|
||||
*/
|
||||
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This macro exports a command to module shell.
|
||||
*
|
||||
* @param command the name of command.
|
||||
* @param desc the description of command, which will show in help.
|
||||
*/
|
||||
#define MSH_CMD_EXPORT(command, desc) \
|
||||
MSH_FUNCTION_EXPORT_CMD(command, command, desc)
|
||||
#define MSH_CMD_EXPORT_ALIAS(command, alias, desc) \
|
||||
MSH_FUNCTION_EXPORT_CMD(command, alias, desc)
|
||||
|
||||
/* system call table */
|
||||
struct finsh_syscall
|
||||
{
|
||||
const char *name; /* the name of system call */
|
||||
#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
|
||||
const char *desc; /* description of system call */
|
||||
#endif
|
||||
syscall_func func; /* the function address of system call */
|
||||
};
|
||||
|
||||
/* system call item */
|
||||
struct finsh_syscall_item
|
||||
{
|
||||
struct finsh_syscall_item* next; /* next item */
|
||||
struct finsh_syscall_item *next; /* next item */
|
||||
struct finsh_syscall syscall; /* syscall */
|
||||
};
|
||||
extern struct finsh_syscall_item *global_syscall_list;
|
||||
|
||||
/* system variable table */
|
||||
struct finsh_sysvar
|
||||
{
|
||||
const char* name; /* the name of variable */
|
||||
#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
|
||||
const char* desc; /* description of system variable */
|
||||
#endif
|
||||
uint8_t type; /* the type of variable */
|
||||
void* var ; /* the address of variable */
|
||||
};
|
||||
extern struct finsh_syscall_item *global_syscall_list;
|
||||
extern struct finsh_syscall *_syscall_table_begin, *_syscall_table_end;
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(__x86_64__))
|
||||
struct finsh_syscall* finsh_syscall_next(struct finsh_syscall* call);
|
||||
struct finsh_sysvar* finsh_sysvar_next(struct finsh_sysvar* call);
|
||||
#define FINSH_NEXT_SYSCALL(index) index=finsh_syscall_next(index)
|
||||
#define FINSH_NEXT_SYSVAR(index) index=finsh_sysvar_next(index)
|
||||
struct finsh_syscall *finsh_syscall_next(struct finsh_syscall *call);
|
||||
#define FINSH_NEXT_SYSCALL(index) index=finsh_syscall_next(index)
|
||||
#else
|
||||
#define FINSH_NEXT_SYSCALL(index) index++
|
||||
#define FINSH_NEXT_SYSVAR(index) index++
|
||||
#define FINSH_NEXT_SYSCALL(index) index++
|
||||
#endif
|
||||
|
||||
/* system variable item */
|
||||
struct finsh_sysvar_item
|
||||
{
|
||||
struct finsh_sysvar_item *next; /* next item */
|
||||
struct finsh_sysvar sysvar; /* system variable */
|
||||
};
|
||||
extern struct finsh_sysvar *_sysvar_table_begin, *_sysvar_table_end;
|
||||
extern struct finsh_sysvar_item* global_sysvar_list;
|
||||
/* find out system call, which should be implemented in user program */
|
||||
struct finsh_syscall *finsh_syscall_lookup(const char *name);
|
||||
|
||||
/* find out system variable, which should be implemented in user program */
|
||||
struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
|
||||
|
||||
|
||||
struct finsh_token
|
||||
{
|
||||
char eof;
|
||||
char replay;
|
||||
|
||||
int position;
|
||||
uint8_t current_token;
|
||||
|
||||
union {
|
||||
char char_value;
|
||||
int int_value;
|
||||
long long_value;
|
||||
} value;
|
||||
uint8_t string[FINSH_STRING_MAX];
|
||||
|
||||
uint8_t* line;
|
||||
};
|
||||
|
||||
#define FINSH_IDTYPE_VAR 0x01
|
||||
#define FINSH_IDTYPE_SYSVAR 0x02
|
||||
#define FINSH_IDTYPE_SYSCALL 0x04
|
||||
#define FINSH_IDTYPE_ADDRESS 0x08
|
||||
struct finsh_node
|
||||
{
|
||||
uint8_t node_type; /* node node_type */
|
||||
uint8_t data_type; /* node data node_type */
|
||||
uint8_t idtype; /* id node information */
|
||||
|
||||
union { /* value node */
|
||||
char char_value;
|
||||
short short_value;
|
||||
int int_value;
|
||||
long long_value;
|
||||
void* ptr;
|
||||
} value;
|
||||
union
|
||||
{
|
||||
/* point to variable identifier or function identifier */
|
||||
struct finsh_var *var;
|
||||
struct finsh_sysvar *sysvar;
|
||||
struct finsh_syscall*syscall;
|
||||
}id;
|
||||
|
||||
/* sibling and child node */
|
||||
struct finsh_node *sibling, *child;
|
||||
};
|
||||
|
||||
struct finsh_parser
|
||||
{
|
||||
uint8_t* parser_string;
|
||||
|
||||
struct finsh_token token;
|
||||
struct finsh_node* root;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* The basic data type in finsh shell
|
||||
*/
|
||||
enum finsh_type {
|
||||
finsh_type_unknown = 0, /**< unknown data type */
|
||||
finsh_type_void, /**< void */
|
||||
finsh_type_voidp, /**< void pointer */
|
||||
finsh_type_char, /**< char */
|
||||
finsh_type_uchar, /**< unsigned char */
|
||||
finsh_type_charp, /**< char pointer */
|
||||
finsh_type_short, /**< short */
|
||||
finsh_type_ushort, /**< unsigned short */
|
||||
finsh_type_shortp, /**< short pointer */
|
||||
finsh_type_int, /**< int */
|
||||
finsh_type_uint, /**< unsigned int */
|
||||
finsh_type_intp, /**< int pointer */
|
||||
finsh_type_long, /**< long */
|
||||
finsh_type_ulong, /**< unsigned long */
|
||||
finsh_type_longp /**< long pointer */
|
||||
};
|
||||
|
||||
/* init finsh environment */
|
||||
int finsh_init(struct finsh_parser* parser);
|
||||
/* flush finsh node, text segment */
|
||||
int finsh_flush(struct finsh_parser* parser);
|
||||
/* reset all of finsh */
|
||||
int finsh_reset(struct finsh_parser* parser);
|
||||
#ifdef RT_USING_DEVICE
|
||||
void finsh_set_device(const char* device_name);
|
||||
void finsh_set_device(const char *device_name);
|
||||
#endif
|
||||
|
||||
/* run finsh parser to generate abstract synatx tree */
|
||||
void finsh_parser_run (struct finsh_parser* parser, const unsigned char* string);
|
||||
/* run compiler to compile abstract syntax tree */
|
||||
int finsh_compiler_run(struct finsh_node* node);
|
||||
/* run finsh virtual machine */
|
||||
void finsh_vm_run(void);
|
||||
|
||||
/* get variable value */
|
||||
struct finsh_var* finsh_var_lookup(const char* name);
|
||||
/* get bottom value of stack */
|
||||
long finsh_stack_bottom(void);
|
||||
|
||||
/* get error number of finsh */
|
||||
uint8_t finsh_errno(void);
|
||||
/* get error string */
|
||||
const char* finsh_error_string(uint8_t type);
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This function appends a system call to finsh runtime environment
|
||||
* @param name the name of system call
|
||||
* @param func the function pointer of system call
|
||||
*/
|
||||
void finsh_syscall_append(const char* name, syscall_func func);
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This function appends a system variable to finsh runtime environment
|
||||
* @param name the name of system variable
|
||||
* @param type the data type of system variable
|
||||
* @param addr the address of system variable
|
||||
*/
|
||||
void finsh_sysvar_append(const char* name, uint8_t type, void* addr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef FINSH_API_H__
|
||||
#define FINSH_API_H__
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma section("FSymTab$f",read)
|
||||
#pragma section("VSymTab",read)
|
||||
#endif
|
||||
|
||||
typedef long (*syscall_func)(void);
|
||||
|
||||
/* system call table */
|
||||
struct finsh_syscall
|
||||
{
|
||||
const char* name; /* the name of system call */
|
||||
#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
|
||||
const char* desc; /* description of system call */
|
||||
#endif
|
||||
syscall_func func; /* the function address of system call */
|
||||
};
|
||||
extern struct finsh_syscall *_syscall_table_begin, *_syscall_table_end;
|
||||
|
||||
/* find out system call, which should be implemented in user program */
|
||||
struct finsh_syscall* finsh_syscall_lookup(const char* name);
|
||||
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
|
||||
#ifdef __TI_COMPILER_VERSION__
|
||||
#define __TI_FINSH_EXPORT_FUNCTION(f) PRAGMA(DATA_SECTION(f,"FSymTab"))
|
||||
#define __TI_FINSH_EXPORT_VAR(v) PRAGMA(DATA_SECTION(v,"VSymTab"))
|
||||
#endif
|
||||
|
||||
#ifdef FINSH_USING_DESCRIPTION
|
||||
#ifdef _MSC_VER
|
||||
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
const char __fsym_##cmd##_desc[] = #desc; \
|
||||
__declspec(allocate("FSymTab$f")) \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
__fsym_##cmd##_desc, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
#pragma comment(linker, "/merge:FSymTab=mytext")
|
||||
|
||||
#define FINSH_VAR_EXPORT(name, type, desc) \
|
||||
const char __vsym_##name##_name[] = #name; \
|
||||
const char __vsym_##name##_desc[] = #desc; \
|
||||
__declspec(allocate("VSymTab")) \
|
||||
const struct finsh_sysvar __vsym_##name = \
|
||||
{ \
|
||||
__vsym_##name##_name, \
|
||||
__vsym_##name##_desc, \
|
||||
type, \
|
||||
(void*)&name \
|
||||
};
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
__TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
const char __fsym_##cmd##_desc[] = #desc; \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
__fsym_##cmd##_desc, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define FINSH_VAR_EXPORT(name, type, desc) \
|
||||
__TI_FINSH_EXPORT_VAR(__vsym_##name); \
|
||||
const char __vsym_##name##_name[] = #name; \
|
||||
const char __vsym_##name##_desc[] = #desc; \
|
||||
const struct finsh_sysvar __vsym_##name = \
|
||||
{ \
|
||||
__vsym_##name##_name, \
|
||||
__vsym_##name##_desc, \
|
||||
type, \
|
||||
(void*)&name \
|
||||
};
|
||||
|
||||
#else
|
||||
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] RT_SECTION(".rodata.name") = #cmd; \
|
||||
const char __fsym_##cmd##_desc[] RT_SECTION(".rodata.name") = #desc; \
|
||||
RT_USED const struct finsh_syscall __fsym_##cmd RT_SECTION("FSymTab")= \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
__fsym_##cmd##_desc, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define FINSH_VAR_EXPORT(name, type, desc) \
|
||||
const char __vsym_##name##_name[] RT_SECTION(".rodata.name") = #name; \
|
||||
const char __vsym_##name##_desc[] RT_SECTION(".rodata.name") = #desc; \
|
||||
RT_USED const struct finsh_sysvar __vsym_##name RT_SECTION("VSymTab")= \
|
||||
{ \
|
||||
__vsym_##name##_name, \
|
||||
__vsym_##name##_desc, \
|
||||
type, \
|
||||
(void*)&name \
|
||||
};
|
||||
|
||||
#endif
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
__declspec(allocate("FSymTab$f")) \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
#pragma comment(linker, "/merge:FSymTab=mytext")
|
||||
|
||||
#define FINSH_VAR_EXPORT(name, type, desc) \
|
||||
const char __vsym_##name##_name[] = #name; \
|
||||
__declspec(allocate("VSymTab")) const struct finsh_sysvar __vsym_##name = \
|
||||
{ \
|
||||
__vsym_##name##_name, \
|
||||
type, \
|
||||
(void*)&name \
|
||||
};
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
__TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
const struct finsh_syscall __fsym_##cmd = \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define FINSH_VAR_EXPORT(name, type, desc) \
|
||||
__TI_FINSH_EXPORT_VAR(__vsym_##name); \
|
||||
const char __vsym_##name##_name[] = #name; \
|
||||
const struct finsh_sysvar __vsym_##name = \
|
||||
{ \
|
||||
__vsym_##name##_name, \
|
||||
type, \
|
||||
(void*)&name \
|
||||
};
|
||||
|
||||
#else
|
||||
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
|
||||
const char __fsym_##cmd##_name[] = #cmd; \
|
||||
RT_USED const struct finsh_syscall __fsym_##cmd RT_SECTION("FSymTab")= \
|
||||
{ \
|
||||
__fsym_##cmd##_name, \
|
||||
(syscall_func)&name \
|
||||
};
|
||||
|
||||
#define FINSH_VAR_EXPORT(name, type, desc) \
|
||||
const char __vsym_##name##_name[] = #name; \
|
||||
RT_USED const struct finsh_sysvar __vsym_##name RT_SECTION("VSymTab")= \
|
||||
{ \
|
||||
__vsym_##name##_name, \
|
||||
type, \
|
||||
(void*)&name \
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* end of FINSH_USING_DESCRIPTION */
|
||||
#endif /* end of FINSH_USING_SYMTAB */
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This macro exports a system function to finsh shell.
|
||||
*
|
||||
* @param name the name of function.
|
||||
* @param desc the description of function, which will show in help.
|
||||
*/
|
||||
#define FINSH_FUNCTION_EXPORT(name, desc) \
|
||||
FINSH_FUNCTION_EXPORT_CMD(name, name, desc)
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This macro exports a system function with an alias name to finsh shell.
|
||||
*
|
||||
* @param name the name of function.
|
||||
* @param alias the alias name of function.
|
||||
* @param desc the description of function, which will show in help.
|
||||
*/
|
||||
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
|
||||
FINSH_FUNCTION_EXPORT_CMD(name, alias, desc)
|
||||
|
||||
/**
|
||||
* @ingroup finsh
|
||||
*
|
||||
* This macro exports a command to module shell.
|
||||
*
|
||||
* @param command the name of command.
|
||||
* @param desc the description of command, which will show in help.
|
||||
*/
|
||||
#ifdef FINSH_USING_MSH
|
||||
#define MSH_CMD_EXPORT(command, desc) \
|
||||
FINSH_FUNCTION_EXPORT_CMD(command, __cmd_##command, desc)
|
||||
#define MSH_CMD_EXPORT_ALIAS(command, alias, desc) \
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(command, __cmd_##alias, desc)
|
||||
#else
|
||||
#define MSH_CMD_EXPORT(command, desc)
|
||||
#define MSH_CMD_EXPORT_ALIAS(command, alias, desc)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#include "finsh_error.h"
|
||||
|
||||
uint8_t global_errno;
|
||||
|
||||
static const char * finsh_error_string_table[] =
|
||||
{
|
||||
"No error",
|
||||
"Invalid token",
|
||||
"Expect a type",
|
||||
"Unknown type",
|
||||
"Variable exist",
|
||||
"Expect a operater",
|
||||
"Memory full",
|
||||
"Unknown operator",
|
||||
"Unknown node",
|
||||
"Expect a character",
|
||||
"Unexpect end",
|
||||
"Unknown token",
|
||||
"Float not supported",
|
||||
"Unknown symbol",
|
||||
"Null node"
|
||||
};
|
||||
|
||||
int finsh_error_init()
|
||||
{
|
||||
global_errno = FINSH_ERROR_OK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int finsh_error_set(uint8_t type)
|
||||
{
|
||||
global_errno = type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t finsh_errno()
|
||||
{
|
||||
return global_errno;
|
||||
}
|
||||
|
||||
const char* finsh_error_string(uint8_t type)
|
||||
{
|
||||
return finsh_error_string_table[type];
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_ERROR_H__
|
||||
#define __FINSH_ERROR_H__
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
int finsh_error_init(void);
|
||||
|
||||
/* get error number */
|
||||
uint8_t finsh_errno(void);
|
||||
|
||||
int finsh_error_set(uint8_t type);
|
||||
const char* finsh_error_string(uint8_t type);
|
||||
|
||||
#endif
|
||||
@@ -1,279 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#include <finsh.h>
|
||||
|
||||
#include "finsh_var.h"
|
||||
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
uint8_t finsh_heap[FINSH_HEAP_MAX];
|
||||
struct finsh_block_header
|
||||
{
|
||||
uint32_t length;
|
||||
struct finsh_block_header* next;
|
||||
};
|
||||
#define BLOCK_HEADER(x) (struct finsh_block_header*)(x)
|
||||
#define finsh_block_get_header(data) (struct finsh_block_header*)((uint8_t*)data - sizeof(struct finsh_block_header))
|
||||
#define finsh_block_get_data(header) (uint8_t*)((struct finsh_block_header*)header + 1)
|
||||
#define HEAP_ALIGN_SIZE(size) (((size) + HEAP_ALIGNMENT - 1) & ~(HEAP_ALIGNMENT-1))
|
||||
|
||||
static struct finsh_block_header* free_list;
|
||||
static struct finsh_block_header* allocate_list;
|
||||
|
||||
static void finsh_heap_gc(void);
|
||||
|
||||
static void finsh_block_insert(struct finsh_block_header** list, struct finsh_block_header* header);
|
||||
static void finsh_block_remove(struct finsh_block_header** list, struct finsh_block_header* header);
|
||||
static void finsh_block_split(struct finsh_block_header* header, size_t size);
|
||||
static void finsh_block_merge(struct finsh_block_header** list, struct finsh_block_header* header);
|
||||
|
||||
int finsh_heap_init(void)
|
||||
{
|
||||
/* clear heap to zero */
|
||||
memset(&finsh_heap[0], 0, sizeof(finsh_heap));
|
||||
|
||||
/* init free and alloc list */
|
||||
free_list = BLOCK_HEADER(&finsh_heap[0]);
|
||||
free_list->length = FINSH_HEAP_MAX - sizeof(struct finsh_block_header);
|
||||
free_list->next = NULL;
|
||||
|
||||
allocate_list = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* allocate a block from heap
|
||||
*/
|
||||
void* finsh_heap_allocate(size_t size)
|
||||
{
|
||||
struct finsh_block_header* header;
|
||||
|
||||
size = HEAP_ALIGN_SIZE(size);
|
||||
|
||||
/* find the first fit block */
|
||||
for (header = free_list;
|
||||
((header != NULL) && (header->length <= size + sizeof(struct finsh_block_header)));
|
||||
header = header->next) ;
|
||||
|
||||
if (header == NULL)
|
||||
{
|
||||
finsh_heap_gc();
|
||||
|
||||
/* find the first fit block */
|
||||
for (header = free_list;
|
||||
((header != NULL) && (header->length < size + sizeof(struct finsh_block_header)));
|
||||
header = header->next) ;
|
||||
|
||||
/* there is no memory */
|
||||
if (header == NULL) return NULL;
|
||||
}
|
||||
|
||||
/* split block */
|
||||
finsh_block_split(header, size);
|
||||
|
||||
/* remove from free list */
|
||||
finsh_block_remove(&free_list, header);
|
||||
header->next = NULL;
|
||||
|
||||
/* insert to allocate list */
|
||||
finsh_block_insert(&allocate_list, header);
|
||||
|
||||
memset(finsh_block_get_data(header), 0, size);
|
||||
|
||||
return finsh_block_get_data(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* release the allocated block
|
||||
*/
|
||||
void finsh_heap_free(void*ptr)
|
||||
{
|
||||
struct finsh_block_header* header;
|
||||
|
||||
/* get block header */
|
||||
header = finsh_block_get_header(ptr);
|
||||
|
||||
/* remove from allocate list */
|
||||
finsh_block_remove(&allocate_list, header);
|
||||
|
||||
/* insert to free list */
|
||||
finsh_block_insert(&free_list, header);
|
||||
finsh_block_merge(&free_list, header);
|
||||
}
|
||||
|
||||
/**
|
||||
* garbage collector
|
||||
*/
|
||||
static void finsh_heap_gc(void)
|
||||
{
|
||||
int i;
|
||||
struct finsh_block_header *header, *temp;
|
||||
|
||||
temp = NULL;
|
||||
|
||||
/* find the first fit block */
|
||||
for (header = allocate_list; header != NULL; )
|
||||
{
|
||||
for (i = 0; i < FINSH_VARIABLE_MAX; i ++)
|
||||
{
|
||||
if (global_variable[i].type != finsh_type_unknown)
|
||||
{
|
||||
if (global_variable[i].value.ptr == finsh_block_get_data(header))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
temp = header;
|
||||
header = header->next;
|
||||
|
||||
/* this block is an unused block, release it */
|
||||
if (i == FINSH_VARIABLE_MAX)
|
||||
{
|
||||
finsh_heap_free(finsh_block_get_data(temp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* insert a block to list
|
||||
*/
|
||||
void finsh_block_insert(struct finsh_block_header** list, struct finsh_block_header* header)
|
||||
{
|
||||
struct finsh_block_header* node;
|
||||
|
||||
if (*list == NULL)
|
||||
{
|
||||
*list = header;
|
||||
return;
|
||||
}
|
||||
|
||||
/* find out insert point */
|
||||
node = *list;
|
||||
|
||||
if (node > header)
|
||||
{
|
||||
/* insert node in the header of list */
|
||||
header->next = node;
|
||||
*list = header;
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (node = *list; node; node = node->next)
|
||||
{
|
||||
if (node->next > header) break;
|
||||
|
||||
if (node->next == NULL) break;
|
||||
}
|
||||
}
|
||||
|
||||
/* insert node */
|
||||
if (node->next != NULL) header->next = node->next;
|
||||
node->next = header;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove block from list
|
||||
*/
|
||||
void finsh_block_remove(struct finsh_block_header** list, struct finsh_block_header* header)
|
||||
{
|
||||
struct finsh_block_header* node;
|
||||
|
||||
node = *list;
|
||||
if (node == header)
|
||||
{
|
||||
/* remove list header */
|
||||
*list = header->next;
|
||||
header->next = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (node = *list; node != NULL; node = node->next)
|
||||
{
|
||||
if (node->next == header)
|
||||
{
|
||||
node->next = header->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* split block
|
||||
*/
|
||||
void finsh_block_split(struct finsh_block_header* header, size_t size)
|
||||
{
|
||||
struct finsh_block_header* next;
|
||||
|
||||
/*
|
||||
* split header into two node:
|
||||
* header->next->...
|
||||
*/
|
||||
next = BLOCK_HEADER((uint8_t*)header + sizeof(struct finsh_block_header) + size);
|
||||
next->length = header->length - sizeof(struct finsh_block_header) - size;
|
||||
header->length = size;
|
||||
next->next = header->next;
|
||||
|
||||
header->next = next;
|
||||
}
|
||||
|
||||
void finsh_block_merge(struct finsh_block_header** list, struct finsh_block_header* header)
|
||||
{
|
||||
struct finsh_block_header* prev_node;
|
||||
struct finsh_block_header* next_node;
|
||||
|
||||
next_node = header->next;
|
||||
|
||||
if (*list == header) prev_node = NULL;
|
||||
else
|
||||
{
|
||||
/* find out the previous header */
|
||||
for (prev_node = *list; prev_node; prev_node =prev_node->next)
|
||||
{
|
||||
if (prev_node->next == header)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* try merge node */
|
||||
|
||||
/* merge to previous node */
|
||||
if (prev_node != NULL &&
|
||||
((uint8_t*)prev_node + prev_node->length + sizeof(struct finsh_block_header)
|
||||
== (uint8_t*)header))
|
||||
{
|
||||
/* is it close to next node? */
|
||||
if ((next_node != NULL) &&
|
||||
((uint8_t*)header + header->length + sizeof(struct finsh_block_header)
|
||||
== (uint8_t*)next_node))
|
||||
{
|
||||
/* merge three node */
|
||||
prev_node->length += header->length + next_node->length +
|
||||
2 * sizeof(struct finsh_block_header);
|
||||
|
||||
prev_node->next = next_node->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_node->length += header->length + sizeof(struct finsh_block_header);
|
||||
prev_node->next = header->next;
|
||||
}
|
||||
}
|
||||
else /* merge to last node */
|
||||
if ( (next_node != NULL) &&
|
||||
((uint8_t*)header + header->length + sizeof(struct finsh_block_header)
|
||||
== (uint8_t*)next_node))
|
||||
{
|
||||
header->length += next_node->length + sizeof(struct finsh_block_header);
|
||||
header->next = next_node->next;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#include <finsh.h>
|
||||
|
||||
#ifndef __FINSH_HEAP_H__
|
||||
#define __FINSH_HEAP_H__
|
||||
|
||||
int finsh_heap_init(void);
|
||||
void* finsh_heap_allocate(size_t size);
|
||||
void finsh_heap_free(void*ptr);
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#include <finsh.h>
|
||||
|
||||
#include "finsh_node.h"
|
||||
#include "finsh_vm.h"
|
||||
#include "finsh_parser.h"
|
||||
#include "finsh_var.h"
|
||||
#include "finsh_error.h"
|
||||
#include "finsh_heap.h"
|
||||
|
||||
int finsh_init(struct finsh_parser* parser)
|
||||
{
|
||||
finsh_parser_init(parser);
|
||||
|
||||
/* finsh init */
|
||||
finsh_node_init();
|
||||
finsh_var_init();
|
||||
finsh_error_init();
|
||||
finsh_heap_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
long finsh_stack_bottom()
|
||||
{
|
||||
return finsh_vm_stack[0].long_value;
|
||||
}
|
||||
|
||||
int finsh_flush(struct finsh_parser* parser)
|
||||
{
|
||||
finsh_parser_init(parser);
|
||||
|
||||
/* finsh init */
|
||||
finsh_node_init();
|
||||
finsh_error_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int finsh_reset(struct finsh_parser* parser)
|
||||
{
|
||||
/* finsh init */
|
||||
finsh_node_init();
|
||||
finsh_var_init();
|
||||
finsh_error_init();
|
||||
finsh_heap_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#include <finsh.h>
|
||||
|
||||
#include "finsh_node.h"
|
||||
#include "finsh_error.h"
|
||||
#include "finsh_var.h"
|
||||
#include "finsh_heap.h"
|
||||
|
||||
struct finsh_node global_node_table[FINSH_NODE_MAX];
|
||||
|
||||
int finsh_node_init()
|
||||
{
|
||||
memset(global_node_table, 0, sizeof(global_node_table));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_allocate(uint8_t type)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* find an empty entry */
|
||||
for (i = 0; i < FINSH_NODE_MAX; i ++)
|
||||
{
|
||||
if (global_node_table[i].node_type == FINSH_NODE_UNKNOWN) break;
|
||||
}
|
||||
|
||||
if (i == FINSH_NODE_MAX) return NULL;
|
||||
|
||||
/* fill type field */
|
||||
global_node_table[i].node_type = type;
|
||||
|
||||
/* return this allocated node */
|
||||
return &global_node_table[i];
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_new_id(char* id)
|
||||
{
|
||||
struct finsh_node* node;
|
||||
void* symbol;
|
||||
unsigned char type;
|
||||
|
||||
symbol = NULL;
|
||||
type = 0;
|
||||
node = NULL;
|
||||
|
||||
/* lookup variable firstly */
|
||||
symbol = (void*)finsh_var_lookup(id);
|
||||
if (symbol == NULL)
|
||||
{
|
||||
/* then lookup system variable */
|
||||
symbol = (void*)finsh_sysvar_lookup(id);
|
||||
if (symbol == NULL)
|
||||
{
|
||||
/* then lookup system call */
|
||||
symbol = (void*)finsh_syscall_lookup(id);
|
||||
if (symbol != NULL) type = FINSH_IDTYPE_SYSCALL;
|
||||
}
|
||||
else type = FINSH_IDTYPE_SYSVAR;
|
||||
}
|
||||
else type = FINSH_IDTYPE_VAR;
|
||||
|
||||
if (symbol != NULL)
|
||||
{
|
||||
/* allocate a new node */
|
||||
node = finsh_node_allocate(FINSH_NODE_ID);
|
||||
|
||||
/* allocate node error */
|
||||
if (node == NULL)
|
||||
{
|
||||
finsh_error_set(FINSH_ERROR_MEMORY_FULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fill node value according type */
|
||||
switch (type)
|
||||
{
|
||||
case FINSH_IDTYPE_VAR:
|
||||
node->id.var = (struct finsh_var*)symbol;
|
||||
break;
|
||||
|
||||
case FINSH_IDTYPE_SYSVAR:
|
||||
node->id.sysvar = (struct finsh_sysvar*)symbol;
|
||||
break;
|
||||
|
||||
case FINSH_IDTYPE_SYSCALL:
|
||||
node->id.syscall = (struct finsh_syscall*)symbol;
|
||||
break;
|
||||
}
|
||||
/* fill identifier type */
|
||||
node->idtype = type;
|
||||
}
|
||||
else finsh_error_set(FINSH_ERROR_UNKNOWN_SYMBOL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_new_char(char c)
|
||||
{
|
||||
struct finsh_node* node;
|
||||
|
||||
node = finsh_node_allocate(FINSH_NODE_VALUE_CHAR);
|
||||
if (node == NULL)
|
||||
{
|
||||
finsh_error_set(FINSH_ERROR_MEMORY_FULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->value.char_value = c;
|
||||
return node;
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_new_int(int i)
|
||||
{
|
||||
struct finsh_node* node;
|
||||
|
||||
node = finsh_node_allocate(FINSH_NODE_VALUE_INT);
|
||||
if (node == NULL)
|
||||
{
|
||||
finsh_error_set(FINSH_ERROR_MEMORY_FULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->value.int_value = i;
|
||||
return node;
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_new_long(long l)
|
||||
{
|
||||
struct finsh_node* node;
|
||||
|
||||
node = finsh_node_allocate(FINSH_NODE_VALUE_LONG);
|
||||
if (node == NULL)
|
||||
{
|
||||
finsh_error_set(FINSH_ERROR_MEMORY_FULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->value.long_value = l;
|
||||
return node;
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_new_string(char* s)
|
||||
{
|
||||
struct finsh_node* node;
|
||||
|
||||
node = finsh_node_allocate(FINSH_NODE_VALUE_STRING);
|
||||
if (node == NULL)
|
||||
{
|
||||
finsh_error_set(FINSH_ERROR_MEMORY_FULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* make string */
|
||||
node->value.ptr = finsh_heap_allocate(strlen(s) + 1);
|
||||
strncpy(node->value.ptr, s, strlen(s));
|
||||
((uint8_t*)node->value.ptr)[strlen(s)] = '\0';
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
struct finsh_node* finsh_node_new_ptr(void* ptr)
|
||||
{
|
||||
struct finsh_node* node;
|
||||
|
||||
node = finsh_node_allocate(FINSH_NODE_VALUE_NULL);
|
||||
if (node == NULL)
|
||||
{
|
||||
finsh_error_set(FINSH_ERROR_MEMORY_FULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->value.ptr = ptr;
|
||||
return node;
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_NODE_H__
|
||||
#define __FINSH_NODE_H__
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
#define FINSH_NODE_UNKNOWN 0
|
||||
#define FINSH_NODE_ID 1
|
||||
|
||||
#define FINSH_NODE_VALUE_CHAR 2
|
||||
#define FINSH_NODE_VALUE_INT 3
|
||||
#define FINSH_NODE_VALUE_LONG 4
|
||||
#define FINSH_NODE_VALUE_STRING 5
|
||||
#define FINSH_NODE_VALUE_NULL 6
|
||||
|
||||
#define FINSH_NODE_SYS_ADD 7
|
||||
#define FINSH_NODE_SYS_SUB 8
|
||||
#define FINSH_NODE_SYS_MUL 9
|
||||
#define FINSH_NODE_SYS_DIV 10
|
||||
#define FINSH_NODE_SYS_MOD 11
|
||||
#define FINSH_NODE_SYS_AND 12
|
||||
#define FINSH_NODE_SYS_OR 13
|
||||
#define FINSH_NODE_SYS_XOR 14
|
||||
#define FINSH_NODE_SYS_BITWISE 15
|
||||
#define FINSH_NODE_SYS_SHL 16
|
||||
#define FINSH_NODE_SYS_SHR 17
|
||||
#define FINSH_NODE_SYS_FUNC 18
|
||||
#define FINSH_NODE_SYS_ASSIGN 19
|
||||
#define FINSH_NODE_SYS_CAST 20
|
||||
#define FINSH_NODE_SYS_PREINC 21
|
||||
#define FINSH_NODE_SYS_PREDEC 22
|
||||
#define FINSH_NODE_SYS_INC 23
|
||||
#define FINSH_NODE_SYS_DEC 24
|
||||
#define FINSH_NODE_SYS_GETVALUE 25
|
||||
#define FINSH_NODE_SYS_GETADDR 26
|
||||
#define FINSH_NODE_SYS_NULL 27
|
||||
|
||||
#define FINSH_DATA_TYPE_VOID 0x00
|
||||
#define FINSH_DATA_TYPE_BYTE 0x01
|
||||
#define FINSH_DATA_TYPE_WORD 0x02
|
||||
#define FINSH_DATA_TYPE_DWORD 0x03
|
||||
#define FINSH_DATA_TYPE_PTR 0x10
|
||||
|
||||
#define FINSH_NODE_VALUE 0
|
||||
#define FINSH_NODE_ADDRESS 1
|
||||
#define FINSH_NODE_FUNCTION 2
|
||||
|
||||
int finsh_node_init(void);
|
||||
|
||||
struct finsh_node* finsh_node_allocate(uint8_t type);
|
||||
struct finsh_node* finsh_node_new_id(char* id);
|
||||
struct finsh_node* finsh_node_new_char(char c);
|
||||
struct finsh_node* finsh_node_new_int(int i);
|
||||
struct finsh_node* finsh_node_new_long(long l);
|
||||
struct finsh_node* finsh_node_new_string(char* s);
|
||||
struct finsh_node* finsh_node_new_ptr(void* ptr);
|
||||
|
||||
#define finsh_node_sibling(node) ((node)->sibling)
|
||||
#define finsh_node_child(node) ((node)->child)
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_OP_H__
|
||||
#define __FINSH_OP_H__
|
||||
|
||||
#include "finsh_vm.h"
|
||||
|
||||
/*
|
||||
* FinC VM specification
|
||||
* Memory
|
||||
* .VAR
|
||||
*
|
||||
* .STACK
|
||||
*
|
||||
* .HEAP
|
||||
*
|
||||
* .TEXT
|
||||
* OP [op1]
|
||||
*/
|
||||
|
||||
#define FINSH_OP_NOOP 0x00
|
||||
|
||||
/* add @ r1 = r2 + r3 */
|
||||
#define FINSH_OP_ADD_BYTE 0x01
|
||||
#define FINSH_OP_ADD_WORD 0x02
|
||||
#define FINSH_OP_ADD_DWORD 0x03
|
||||
|
||||
/* sub @ r1 = r2 - r3 */
|
||||
#define FINSH_OP_SUB_BYTE 0x04
|
||||
#define FINSH_OP_SUB_WORD 0x05
|
||||
#define FINSH_OP_SUB_DWORD 0x06
|
||||
|
||||
/* div @ r1 = r2 / r3 */
|
||||
#define FINSH_OP_DIV_BYTE 0x07
|
||||
#define FINSH_OP_DIV_WORD 0x08
|
||||
#define FINSH_OP_DIV_DWORD 0x09
|
||||
|
||||
/* mod @ r1 = r2 % r3 */
|
||||
#define FINSH_OP_MOD_BYTE 0x0A
|
||||
#define FINSH_OP_MOD_WORD 0x0B
|
||||
#define FINSH_OP_MOD_DWORD 0x0C
|
||||
|
||||
/* mul @ r1 = r2 * r3 */
|
||||
#define FINSH_OP_MUL_BYTE 0x0D
|
||||
#define FINSH_OP_MUL_WORD 0x0E
|
||||
#define FINSH_OP_MUL_DWORD 0x0F
|
||||
|
||||
/* and @ r1 = r2 & r3 */
|
||||
#define FINSH_OP_AND_BYTE 0x10
|
||||
#define FINSH_OP_AND_WORD 0x11
|
||||
#define FINSH_OP_AND_DWORD 0x12
|
||||
|
||||
/* or @ r1 = r2 | r3 */
|
||||
#define FINSH_OP_OR_BYTE 0x13
|
||||
#define FINSH_OP_OR_WORD 0x14
|
||||
#define FINSH_OP_OR_DWORD 0x15
|
||||
|
||||
/* xor @ r1 = r2 ^ r3 */
|
||||
#define FINSH_OP_XOR_BYTE 0x16
|
||||
#define FINSH_OP_XOR_WORD 0x17
|
||||
#define FINSH_OP_XOR_DWORD 0x18
|
||||
|
||||
/* bw @ r1 = ~r2 */
|
||||
#define FINSH_OP_BITWISE_BYTE 0x19
|
||||
#define FINSH_OP_BITWISE_WORD 0x1A
|
||||
#define FINSH_OP_BITWISE_DWORD 0x1B
|
||||
|
||||
/* shl @ r1 = r2 << r3 */
|
||||
#define FINSH_OP_SHL_BYTE 0x1C
|
||||
#define FINSH_OP_SHL_WORD 0x1D
|
||||
#define FINSH_OP_SHL_DWORD 0x1E
|
||||
|
||||
/* shr @ r1 = r2 >> r3 */
|
||||
#define FINSH_OP_SHR_BYTE 0x1F
|
||||
#define FINSH_OP_SHR_WORD 0x20
|
||||
#define FINSH_OP_SHR_DWORD 0x21
|
||||
|
||||
/* ld @ r1 = [r2] */
|
||||
#define FINSH_OP_LD_BYTE 0x22
|
||||
#define FINSH_OP_LD_WORD 0x23
|
||||
#define FINSH_OP_LD_DWORD 0x24
|
||||
|
||||
#define FINSH_OP_LD_VALUE_BYTE 0x25
|
||||
#define FINSH_OP_LD_VALUE_WORD 0x26
|
||||
#define FINSH_OP_LD_VALUE_DWORD 0x27
|
||||
|
||||
/* st @ [r2] = r1 */
|
||||
#define FINSH_OP_ST_BYTE 0x28
|
||||
#define FINSH_OP_ST_WORD 0x29
|
||||
#define FINSH_OP_ST_DWORD 0x2A
|
||||
|
||||
/* pop */
|
||||
#define FINSH_OP_POP 0x2B
|
||||
|
||||
/* call r1 @ [r1](stack) */
|
||||
#define FINSH_OP_SYSCALL 0x2C
|
||||
|
||||
/* load value from stack */
|
||||
#define FINSH_OP_LD_VALUE_BYTE_STACK 0x2D
|
||||
#define FINSH_OP_LD_VALUE_WORD_STACK 0x2E
|
||||
#define FINSH_OP_LD_VALUE_DWORD_STACK 0x2F
|
||||
|
||||
/* halt */
|
||||
#define FINSH_OP_HALT 0xFF
|
||||
|
||||
typedef void (*op_func)();
|
||||
extern const op_func op_table[];
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_PARSER_H__
|
||||
#define __FINSH_PARSER_H__
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
int finsh_parser_init(struct finsh_parser* self);
|
||||
void finsh_parser_run(struct finsh_parser* self, const uint8_t* string);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_TOKEN_H__
|
||||
#define __FINSH_TOKEN_H__
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
enum finsh_token_type
|
||||
{
|
||||
finsh_token_type_left_paren = 1, /* ( */
|
||||
finsh_token_type_right_paren , /* ) */
|
||||
finsh_token_type_comma , /* , */
|
||||
finsh_token_type_semicolon , /* ; */
|
||||
finsh_token_type_mul , /* * */
|
||||
finsh_token_type_add , /* + */
|
||||
finsh_token_type_inc , /* ++ */
|
||||
finsh_token_type_sub , /* - */
|
||||
finsh_token_type_dec , /* -- */
|
||||
finsh_token_type_div , /* / */
|
||||
finsh_token_type_mod , /* % */
|
||||
finsh_token_type_assign , /* = */
|
||||
finsh_token_type_and, /* & */
|
||||
finsh_token_type_or, /* | */
|
||||
finsh_token_type_xor, /* ^ */
|
||||
finsh_token_type_bitwise, /* ~ */
|
||||
finsh_token_type_shl, /* << */
|
||||
finsh_token_type_shr, /* >> */
|
||||
finsh_token_type_comments, /* // */
|
||||
/*-- data type --*/
|
||||
finsh_token_type_void, /* void */
|
||||
finsh_token_type_char, /* char */
|
||||
finsh_token_type_short, /* short */
|
||||
finsh_token_type_int, /* int */
|
||||
finsh_token_type_long, /* long */
|
||||
finsh_token_type_unsigned, /* unsigned */
|
||||
/* data value type */
|
||||
finsh_token_type_value_char, /* v:char */
|
||||
finsh_token_type_value_int, /* v:int */
|
||||
finsh_token_type_value_long, /* v:long */
|
||||
finsh_token_type_value_string, /* v:string */
|
||||
finsh_token_type_value_null, /* NULL */
|
||||
/*-- others --*/
|
||||
finsh_token_type_identifier, /* ID */
|
||||
finsh_token_type_bad, /* bad token */
|
||||
finsh_token_type_eof
|
||||
};
|
||||
|
||||
#define finsh_token_position(self) (self)->position
|
||||
#define finsh_token_replay(self) (self)->replay = 1
|
||||
|
||||
void finsh_token_init(struct finsh_token* self, uint8_t* script);
|
||||
|
||||
enum finsh_token_type finsh_token_token(struct finsh_token* self);
|
||||
void finsh_token_get_token(struct finsh_token* self, uint8_t* token);
|
||||
|
||||
#endif
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
* 2012-04-27 Bernard fixed finsh_var_delete issue which
|
||||
* is found by Grissiom.
|
||||
*/
|
||||
#include <finsh.h>
|
||||
#include "finsh_var.h"
|
||||
|
||||
struct finsh_var global_variable[FINSH_VARIABLE_MAX];
|
||||
struct finsh_sysvar_item* global_sysvar_list;
|
||||
|
||||
int finsh_var_init()
|
||||
{
|
||||
memset(global_variable, 0, sizeof(global_variable));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int finsh_var_insert(const char* name, int type)
|
||||
{
|
||||
int i, empty;
|
||||
|
||||
empty = -1;
|
||||
for (i = 0; i < FINSH_VARIABLE_MAX; i ++)
|
||||
{
|
||||
/* there is a same name variable exist. */
|
||||
if (strncmp(global_variable[i].name, name, FINSH_NAME_MAX) == 0)
|
||||
return -1;
|
||||
|
||||
if (global_variable[i].type == finsh_type_unknown && empty == -1)
|
||||
{
|
||||
empty = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* there is no empty entry */
|
||||
if (empty == -1) return -1;
|
||||
|
||||
/* insert entry */
|
||||
strncpy(global_variable[empty].name, name, FINSH_NAME_MAX);
|
||||
global_variable[empty].type = type;
|
||||
|
||||
/* return the offset */
|
||||
return empty;
|
||||
}
|
||||
|
||||
int finsh_var_delete(const char* name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FINSH_VARIABLE_MAX; i ++)
|
||||
{
|
||||
if (strncmp(global_variable[i].name, name, FINSH_NAME_MAX) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* can't find variable */
|
||||
if (i == FINSH_VARIABLE_MAX) return -1;
|
||||
|
||||
memset(&global_variable[i], 0, sizeof(struct finsh_var));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct finsh_var* finsh_var_lookup(const char* name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < FINSH_VARIABLE_MAX; i ++)
|
||||
{
|
||||
if (strncmp(global_variable[i].name, name, FINSH_NAME_MAX) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* can't find variable */
|
||||
if (i == FINSH_VARIABLE_MAX) return NULL;
|
||||
|
||||
return &global_variable[i];
|
||||
}
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
void finsh_sysvar_append(const char* name, uint8_t type, void* var_addr)
|
||||
{
|
||||
/* create a sysvar */
|
||||
struct finsh_sysvar_item* item;
|
||||
|
||||
item = (struct finsh_sysvar_item*) rt_malloc (sizeof(struct finsh_sysvar_item));
|
||||
if (item != NULL)
|
||||
{
|
||||
item->next = NULL;
|
||||
item->sysvar.name = rt_strdup(name);
|
||||
item->sysvar.type = type;
|
||||
item->sysvar.var = var_addr;
|
||||
|
||||
if (global_sysvar_list == NULL)
|
||||
{
|
||||
global_sysvar_list = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
item->next = global_sysvar_list;
|
||||
global_sysvar_list = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
struct finsh_sysvar* finsh_sysvar_lookup(const char* name)
|
||||
{
|
||||
struct finsh_sysvar* index;
|
||||
struct finsh_sysvar_item* item;
|
||||
|
||||
for (index = _sysvar_table_begin;
|
||||
index < _sysvar_table_end;
|
||||
FINSH_NEXT_SYSVAR(index))
|
||||
{
|
||||
if (strcmp(index->name, name) == 0)
|
||||
return index;
|
||||
}
|
||||
|
||||
/* find in sysvar list */
|
||||
item = global_sysvar_list;
|
||||
while (item != NULL)
|
||||
{
|
||||
if (strncmp(item->sysvar.name, name, strlen(name)) == 0)
|
||||
{
|
||||
return &(item->sysvar);
|
||||
}
|
||||
|
||||
/* move to next item */
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
/* can't find variable */
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_VAR_H__
|
||||
#define __FINSH_VAR_H__
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
/*
|
||||
* The variable in finsh is put in data segment as a global variable.
|
||||
* The 'finsh_var' structure presents the structure of variable in data segment.
|
||||
*/
|
||||
struct finsh_var
|
||||
{
|
||||
char name[FINSH_NAME_MAX + 1]; /* the name of variable */
|
||||
|
||||
uint8_t type; /* the type of variable */
|
||||
|
||||
/* variable value */
|
||||
union {
|
||||
char char_value;
|
||||
short short_value;
|
||||
int int_value;
|
||||
long long_value;
|
||||
void* ptr;
|
||||
}value;
|
||||
};
|
||||
extern struct finsh_var global_variable[];
|
||||
|
||||
int finsh_var_init(void);
|
||||
int finsh_var_insert(const char* name, int type);
|
||||
int finsh_var_delete(const char* name);
|
||||
struct finsh_var* finsh_var_lookup(const char* name);
|
||||
|
||||
#endif
|
||||
@@ -1,363 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#include <finsh.h>
|
||||
|
||||
#include "finsh_vm.h"
|
||||
#include "finsh_ops.h"
|
||||
#include "finsh_var.h"
|
||||
|
||||
/* stack */
|
||||
union finsh_value finsh_vm_stack[FINSH_STACK_MAX];
|
||||
/* text segment */
|
||||
uint8_t text_segment[FINSH_TEXT_MAX];
|
||||
|
||||
union finsh_value* finsh_sp; /* stack pointer */
|
||||
uint8_t* finsh_pc; /* PC */
|
||||
|
||||
/* syscall list, for dynamic system call register */
|
||||
struct finsh_syscall_item* global_syscall_list = NULL;
|
||||
|
||||
// #define FINSH_VM_DISASSEMBLE
|
||||
void finsh_vm_run()
|
||||
{
|
||||
uint8_t op;
|
||||
|
||||
/* if you want to disassemble the byte code, please define FINSH_VM_DISASSEMBLE */
|
||||
#ifdef FINSH_VM_DISASSEMBLE
|
||||
void finsh_disassemble();
|
||||
finsh_disassemble();
|
||||
#endif
|
||||
|
||||
/* set sp(stack pointer) to the beginning of stack */
|
||||
finsh_sp = &finsh_vm_stack[0];
|
||||
|
||||
/* set pc to the beginning of text segment */
|
||||
finsh_pc = &text_segment[0];
|
||||
|
||||
while ((finsh_pc - &text_segment[0] >= 0) &&
|
||||
(finsh_pc - &text_segment[0] < FINSH_TEXT_MAX))
|
||||
{
|
||||
/* get op */
|
||||
op = *finsh_pc++;
|
||||
|
||||
/* call op function */
|
||||
op_table[op]();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
void finsh_syscall_append(const char* name, syscall_func func)
|
||||
{
|
||||
/* create the syscall */
|
||||
struct finsh_syscall_item* item;
|
||||
|
||||
item = (struct finsh_syscall_item*)rt_malloc(sizeof(struct finsh_syscall_item));
|
||||
if (item != RT_NULL)
|
||||
{
|
||||
item->next = NULL;
|
||||
item->syscall.name = rt_strdup(name);
|
||||
item->syscall.func = func;
|
||||
|
||||
if (global_syscall_list == NULL)
|
||||
{
|
||||
global_syscall_list = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
item->next = global_syscall_list;
|
||||
global_syscall_list = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
struct finsh_syscall* finsh_syscall_lookup(const char* name)
|
||||
{
|
||||
struct finsh_syscall* index;
|
||||
struct finsh_syscall_item* item;
|
||||
|
||||
for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
|
||||
{
|
||||
if (strcmp(index->name, name) == 0)
|
||||
return index;
|
||||
}
|
||||
|
||||
/* find on syscall list */
|
||||
item = global_syscall_list;
|
||||
while (item != NULL)
|
||||
{
|
||||
if (strncmp(item->syscall.name, name, strlen(name)) == 0)
|
||||
{
|
||||
return &(item->syscall);
|
||||
}
|
||||
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef FINSH_VM_DISASSEMBLE
|
||||
void finsh_disassemble()
|
||||
{
|
||||
uint8_t *pc, op;
|
||||
|
||||
pc = &text_segment[0];
|
||||
while (*pc != 0)
|
||||
{
|
||||
op = *pc;
|
||||
switch (op)
|
||||
{
|
||||
case FINSH_OP_ADD_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("addb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SUB_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("subb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_DIV_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("divb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_MOD_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("modb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_MUL_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("mulb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_AND_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("andb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_OR_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("orb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_XOR_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("xorb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_BITWISE_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("bwb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SHL_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("shlb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SHR_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("shrb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("ldb %d\n", *pc++);
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_VALUE_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("ldb [0x%x]\n", FINSH_GET32(pc));
|
||||
pc += 4;
|
||||
break;
|
||||
|
||||
case FINSH_OP_ST_BYTE:
|
||||
pc ++;
|
||||
rt_kprintf("stb\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_ADD_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("addw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SUB_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("subw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_DIV_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("divw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_MOD_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("modw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_MUL_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("mulw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_AND_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("andw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_OR_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("orw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_XOR_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("xorw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_BITWISE_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("bww\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SHL_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("shlw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SHR_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("shrw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("ldw %d\n", FINSH_GET16(pc));
|
||||
pc += 2;
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_VALUE_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("ldw [0x%x]\n", FINSH_GET32(pc));
|
||||
pc += 4;
|
||||
break;
|
||||
|
||||
case FINSH_OP_ST_WORD:
|
||||
pc ++;
|
||||
rt_kprintf("stw\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_ADD_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("addd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SUB_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("subd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_DIV_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("divd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_MOD_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("modd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_MUL_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("muld\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_AND_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("andd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_OR_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("ord\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_XOR_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("xord\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_BITWISE_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("bwd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SHL_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("shld\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_SHR_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("shrd\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("ldd 0x%x\n", FINSH_GET32(pc));
|
||||
pc += 4;
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_VALUE_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("ldd [0x%x]\n", FINSH_GET32(pc));
|
||||
pc += 4;
|
||||
break;
|
||||
|
||||
case FINSH_OP_ST_DWORD:
|
||||
pc ++;
|
||||
rt_kprintf("std\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_POP:
|
||||
rt_kprintf("pop\n");
|
||||
pc ++;
|
||||
break;
|
||||
|
||||
case FINSH_OP_SYSCALL:
|
||||
pc ++;
|
||||
rt_kprintf("syscall %d\n", *pc++);
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_VALUE_BYTE_STACK:
|
||||
pc ++;
|
||||
rt_kprintf("ldb [sp]\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_VALUE_WORD_STACK:
|
||||
pc ++;
|
||||
rt_kprintf("ldw [sp]\n");
|
||||
break;
|
||||
|
||||
case FINSH_OP_LD_VALUE_DWORD_STACK:
|
||||
pc ++;
|
||||
rt_kprintf("ldd [sp]\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
#ifndef __FINSH_VM_H__
|
||||
#define __FINSH_VM_H__
|
||||
|
||||
#include <finsh.h>
|
||||
|
||||
#include "finsh_var.h"
|
||||
|
||||
union finsh_value {
|
||||
char char_value;
|
||||
short short_value;
|
||||
long long_value;
|
||||
void* ptr;
|
||||
};
|
||||
|
||||
extern union finsh_value* finsh_sp; /* stack pointer */
|
||||
extern uint8_t* finsh_pc; /* PC */
|
||||
|
||||
/* stack */
|
||||
extern union finsh_value finsh_vm_stack[FINSH_STACK_MAX];
|
||||
/* text segment */
|
||||
extern uint8_t text_segment[FINSH_TEXT_MAX];
|
||||
|
||||
void finsh_vm_run(void);
|
||||
//void finsh_disassemble(void);
|
||||
|
||||
#endif
|
||||
@@ -10,61 +10,27 @@
|
||||
* 2017-07-19 Aubr.Cool limit argc to RT_FINSH_ARG_MAX
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#ifndef FINSH_ARG_MAX
|
||||
#define FINSH_ARG_MAX 8
|
||||
#endif
|
||||
|
||||
#include "msh.h"
|
||||
#include <finsh.h>
|
||||
#include <shell.h>
|
||||
#include "shell.h"
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
#include <dlmodule.h>
|
||||
#endif
|
||||
|
||||
#ifndef FINSH_ARG_MAX
|
||||
#define FINSH_ARG_MAX 8
|
||||
#include <dlmodule.h>
|
||||
#endif
|
||||
|
||||
typedef int (*cmd_function_t)(int argc, char **argv);
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef FINSH_USING_MSH_ONLY
|
||||
rt_bool_t msh_is_used(void)
|
||||
{
|
||||
return RT_TRUE;
|
||||
}
|
||||
#else
|
||||
#ifdef FINSH_USING_MSH_DEFAULT
|
||||
static rt_bool_t __msh_state = RT_TRUE;
|
||||
#else
|
||||
static rt_bool_t __msh_state = RT_FALSE;
|
||||
#endif
|
||||
rt_bool_t msh_is_used(void)
|
||||
{
|
||||
return __msh_state;
|
||||
}
|
||||
|
||||
static int msh_exit(int argc, char **argv)
|
||||
{
|
||||
/* return to finsh shell mode */
|
||||
__msh_state = RT_FALSE;
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(msh_exit, __cmd_exit, return to RT-Thread shell mode.);
|
||||
|
||||
static int msh_enter(void)
|
||||
{
|
||||
/* enter module shell mode */
|
||||
__msh_state = RT_TRUE;
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(msh_enter, msh, use module shell);
|
||||
#endif
|
||||
|
||||
int msh_help(int argc, char **argv)
|
||||
{
|
||||
rt_kprintf("RT-Thread shell commands:\n");
|
||||
@@ -75,11 +41,10 @@ int msh_help(int argc, char **argv)
|
||||
index < _syscall_table_end;
|
||||
FINSH_NEXT_SYSCALL(index))
|
||||
{
|
||||
if (strncmp(index->name, "__cmd_", 6) != 0) continue;
|
||||
#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
|
||||
rt_kprintf("%-16s - %s\n", &index->name[6], index->desc);
|
||||
rt_kprintf("%-16s - %s\n", index->name, index->desc);
|
||||
#else
|
||||
rt_kprintf("%s ", &index->name[6]);
|
||||
rt_kprintf("%s ", index->name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -87,7 +52,7 @@ int msh_help(int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(msh_help, __cmd_help, RT-Thread shell help.);
|
||||
MSH_CMD_EXPORT_ALIAS(msh_help, help, RT - Thread shell help.);
|
||||
|
||||
int cmd_ps(int argc, char **argv)
|
||||
{
|
||||
@@ -102,7 +67,7 @@ int cmd_ps(int argc, char **argv)
|
||||
list_thread();
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(cmd_ps, __cmd_ps, List threads in the system.);
|
||||
MSH_CMD_EXPORT_ALIAS(cmd_ps, ps, List threads in the system.);
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
int cmd_free(int argc, char **argv)
|
||||
@@ -117,7 +82,7 @@ int cmd_free(int argc, char **argv)
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(cmd_free, __cmd_free, Show the memory usage in the system.);
|
||||
MSH_CMD_EXPORT_ALIAS(cmd_free, free, Show the memory usage in the system.);
|
||||
#endif
|
||||
|
||||
static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
@@ -128,7 +93,8 @@ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
rt_size_t i;
|
||||
|
||||
ptr = cmd;
|
||||
position = 0; argc = 0;
|
||||
position = 0;
|
||||
argc = 0;
|
||||
|
||||
while (position < length)
|
||||
{
|
||||
@@ -136,13 +102,14 @@ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
while ((*ptr == ' ' || *ptr == '\t') && position < length)
|
||||
{
|
||||
*ptr = '\0';
|
||||
ptr ++; position ++;
|
||||
ptr ++;
|
||||
position ++;
|
||||
}
|
||||
|
||||
if(argc >= FINSH_ARG_MAX)
|
||||
if (argc >= FINSH_ARG_MAX)
|
||||
{
|
||||
rt_kprintf("Too many args ! We only Use:\n");
|
||||
for(i = 0; i < argc; i++)
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
rt_kprintf("%s ", argv[i]);
|
||||
}
|
||||
@@ -155,8 +122,10 @@ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
/* handle string */
|
||||
if (*ptr == '"')
|
||||
{
|
||||
ptr ++; position ++;
|
||||
argv[argc] = ptr; argc ++;
|
||||
ptr ++;
|
||||
position ++;
|
||||
argv[argc] = ptr;
|
||||
argc ++;
|
||||
|
||||
/* skip this string */
|
||||
while (*ptr != '"' && position < length)
|
||||
@@ -165,15 +134,19 @@ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
{
|
||||
if (*(ptr + 1) == '"')
|
||||
{
|
||||
ptr ++; position ++;
|
||||
ptr ++;
|
||||
position ++;
|
||||
}
|
||||
}
|
||||
ptr ++; position ++;
|
||||
ptr ++;
|
||||
position ++;
|
||||
}
|
||||
if (position >= length) break;
|
||||
|
||||
/* skip '"' */
|
||||
*ptr = '\0'; ptr ++; position ++;
|
||||
*ptr = '\0';
|
||||
ptr ++;
|
||||
position ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,7 +154,8 @@ static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
|
||||
argc ++;
|
||||
while ((*ptr != ' ' && *ptr != '\t') && position < length)
|
||||
{
|
||||
ptr ++; position ++;
|
||||
ptr ++;
|
||||
position ++;
|
||||
}
|
||||
if (position >= length) break;
|
||||
}
|
||||
@@ -199,10 +173,8 @@ static cmd_function_t msh_get_cmd(char *cmd, int size)
|
||||
index < _syscall_table_end;
|
||||
FINSH_NEXT_SYSCALL(index))
|
||||
{
|
||||
if (strncmp(index->name, "__cmd_", 6) != 0) continue;
|
||||
|
||||
if (strncmp(&index->name[6], cmd, size) == 0 &&
|
||||
index->name[6 + size] == '\0')
|
||||
if (strncmp(index->name, cmd, size) == 0 &&
|
||||
index->name[size] == '\0')
|
||||
{
|
||||
cmd_func = (cmd_function_t)index->func;
|
||||
break;
|
||||
@@ -340,7 +312,7 @@ static int _msh_exec_lwp(char *cmd, rt_size_t length)
|
||||
int fd = -1;
|
||||
char *pg_name;
|
||||
|
||||
extern int exec(char*, int, char**);
|
||||
extern int exec(char *, int, char **);
|
||||
|
||||
/* find the size of first command */
|
||||
while ((cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t') && cmd0_size < length)
|
||||
@@ -612,9 +584,7 @@ void msh_auto_complete(char *prefix)
|
||||
for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
|
||||
{
|
||||
/* skip finsh shell function */
|
||||
if (strncmp(index->name, "__cmd_", 6) != 0) continue;
|
||||
|
||||
cmd_name = (const char *) &index->name[6];
|
||||
cmd_name = (const char *) index->name;
|
||||
if (strncmp(prefix, cmd_name, strlen(prefix)) == 0)
|
||||
{
|
||||
if (min_length == 0)
|
||||
@@ -642,6 +612,4 @@ void msh_auto_complete(char *prefix)
|
||||
|
||||
return ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
rt_bool_t msh_is_used(void);
|
||||
int msh_exec(char *cmd, rt_size_t length);
|
||||
void msh_auto_complete(char *prefix);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#if defined(FINSH_USING_MSH) && defined(RT_USING_DFS)
|
||||
#if defined(RT_USING_FINSH) && defined(RT_USING_DFS)
|
||||
|
||||
#include <finsh.h>
|
||||
#include "msh.h"
|
||||
@@ -144,7 +144,7 @@ int msh_exec_script(const char *cmd_line, int size)
|
||||
}
|
||||
|
||||
#ifdef DFS_USING_WORKDIR
|
||||
extern char working_directory[];
|
||||
extern char working_directory[];
|
||||
#endif
|
||||
|
||||
static int cmd_ls(int argc, char **argv)
|
||||
@@ -614,19 +614,19 @@ static int cmd_tail(int argc, char **argv)
|
||||
rt_uint32_t required_lines = 0;
|
||||
rt_uint32_t after_xxx_line = 0;
|
||||
|
||||
if(argc < 2)
|
||||
if (argc < 2)
|
||||
{
|
||||
rt_kprintf("Usage: tail [-n numbers] <filename>\n");
|
||||
return -1;
|
||||
}
|
||||
else if(argc == 2)
|
||||
else if (argc == 2)
|
||||
{
|
||||
required_lines = 10; /* default: 10 lines from tail */
|
||||
file_name = argv[1];
|
||||
}
|
||||
else if(rt_strcmp(argv[1], "-n") == 0)
|
||||
else if (rt_strcmp(argv[1], "-n") == 0)
|
||||
{
|
||||
if(argv[2][0] != '+')
|
||||
if (argv[2][0] != '+')
|
||||
{
|
||||
required_lines = atoi(argv[2]);
|
||||
}
|
||||
@@ -659,9 +659,9 @@ static int cmd_tail(int argc, char **argv)
|
||||
|
||||
rt_kprintf("\nTotal Number of lines:%d\n", total_lines);
|
||||
|
||||
if(after_xxx_line != 0)
|
||||
if (after_xxx_line != 0)
|
||||
{
|
||||
if(total_lines > after_xxx_line)
|
||||
if (total_lines > after_xxx_line)
|
||||
{
|
||||
required_lines = total_lines - after_xxx_line;
|
||||
}
|
||||
@@ -700,7 +700,7 @@ static int cmd_tail(int argc, char **argv)
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(cmd_tail, tail, print the last N-lines data of the given file);
|
||||
MSH_CMD_EXPORT_ALIAS(cmd_tail, tail, print the last N - lines data of the given file);
|
||||
|
||||
#endif /* defined(FINSH_USING_MSH) && defined(RT_USING_DFS) */
|
||||
#endif /* defined(RT_USING_FINSH) && defined(RT_USING_DFS) */
|
||||
|
||||
|
||||
@@ -19,75 +19,62 @@
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#include "finsh.h"
|
||||
#include "shell.h"
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#include "msh.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stdio.h> /* for putchar */
|
||||
#endif
|
||||
#if defined(RT_USING_DFS)
|
||||
#include <dfs_posix.h>
|
||||
#endif /* RT_USING_DFS */
|
||||
|
||||
/* finsh thread */
|
||||
#ifndef RT_USING_HEAP
|
||||
static struct rt_thread finsh_thread;
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE];
|
||||
struct finsh_shell _shell;
|
||||
static struct rt_thread finsh_thread;
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE];
|
||||
struct finsh_shell _shell;
|
||||
#endif
|
||||
|
||||
/* finsh symtab */
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
struct finsh_syscall *_syscall_table_begin = NULL;
|
||||
struct finsh_syscall *_syscall_table_end = NULL;
|
||||
struct finsh_sysvar *_sysvar_table_begin = NULL;
|
||||
struct finsh_sysvar *_sysvar_table_end = NULL;
|
||||
struct finsh_syscall *_syscall_table_begin = NULL;
|
||||
struct finsh_syscall *_syscall_table_end = NULL;
|
||||
#endif
|
||||
|
||||
struct finsh_shell *shell;
|
||||
static char *finsh_prompt_custom = RT_NULL;
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(__x86_64__))
|
||||
struct finsh_syscall* finsh_syscall_next(struct finsh_syscall* call)
|
||||
struct finsh_syscall *finsh_syscall_next(struct finsh_syscall *call)
|
||||
{
|
||||
unsigned int *ptr;
|
||||
ptr = (unsigned int*) (call + 1);
|
||||
while ((*ptr == 0) && ((unsigned int*)ptr < (unsigned int*) _syscall_table_end))
|
||||
ptr = (unsigned int *)(call + 1);
|
||||
while ((*ptr == 0) && ((unsigned int *)ptr < (unsigned int *) _syscall_table_end))
|
||||
ptr ++;
|
||||
|
||||
return (struct finsh_syscall*)ptr;
|
||||
return (struct finsh_syscall *)ptr;
|
||||
}
|
||||
|
||||
struct finsh_sysvar* finsh_sysvar_next(struct finsh_sysvar* call)
|
||||
{
|
||||
unsigned int *ptr;
|
||||
ptr = (unsigned int*) (call + 1);
|
||||
while ((*ptr == 0) && ((unsigned int*)ptr < (unsigned int*) _sysvar_table_end))
|
||||
ptr ++;
|
||||
|
||||
return (struct finsh_sysvar*)ptr;
|
||||
}
|
||||
#endif /* defined(_MSC_VER) || (defined(__GNUC__) && defined(__x86_64__)) */
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
int finsh_set_prompt(const char * prompt)
|
||||
int finsh_set_prompt(const char *prompt)
|
||||
{
|
||||
if(finsh_prompt_custom)
|
||||
if (finsh_prompt_custom)
|
||||
{
|
||||
rt_free(finsh_prompt_custom);
|
||||
finsh_prompt_custom = RT_NULL;
|
||||
}
|
||||
|
||||
/* strdup */
|
||||
if(prompt)
|
||||
if (prompt)
|
||||
{
|
||||
finsh_prompt_custom = (char *)rt_malloc(strlen(prompt)+1);
|
||||
if(finsh_prompt_custom)
|
||||
finsh_prompt_custom = (char *)rt_malloc(strlen(prompt) + 1);
|
||||
if (finsh_prompt_custom)
|
||||
{
|
||||
strcpy(finsh_prompt_custom, prompt);
|
||||
}
|
||||
@@ -97,14 +84,10 @@ int finsh_set_prompt(const char * prompt)
|
||||
}
|
||||
#endif /* RT_USING_HEAP */
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
#endif /* RT_USING_DFS */
|
||||
#define _MSH_PROMPT "msh "
|
||||
|
||||
const char *finsh_get_prompt(void)
|
||||
{
|
||||
#define _MSH_PROMPT "msh "
|
||||
#define _PROMPT "finsh "
|
||||
static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {0};
|
||||
|
||||
/* check prompt mode */
|
||||
@@ -114,17 +97,12 @@ const char *finsh_get_prompt(void)
|
||||
return finsh_prompt;
|
||||
}
|
||||
|
||||
if(finsh_prompt_custom)
|
||||
if (finsh_prompt_custom)
|
||||
{
|
||||
strncpy(finsh_prompt, finsh_prompt_custom, sizeof(finsh_prompt)-1);
|
||||
strncpy(finsh_prompt, finsh_prompt_custom, sizeof(finsh_prompt) - 1);
|
||||
return finsh_prompt;
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
if (msh_is_used()) strcpy(finsh_prompt, _MSH_PROMPT);
|
||||
else
|
||||
#endif
|
||||
strcpy(finsh_prompt, _PROMPT);
|
||||
strcpy(finsh_prompt, _MSH_PROMPT);
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
|
||||
/* get current working directory */
|
||||
@@ -288,7 +266,8 @@ rt_uint32_t finsh_get_echo()
|
||||
* @return result, RT_EOK on OK, -RT_ERROR on the new password length is less than
|
||||
* FINSH_PASSWORD_MIN or greater than FINSH_PASSWORD_MAX
|
||||
*/
|
||||
rt_err_t finsh_set_password(const char *password) {
|
||||
rt_err_t finsh_set_password(const char *password)
|
||||
{
|
||||
rt_ubase_t level;
|
||||
rt_size_t pw_len = rt_strlen(password);
|
||||
|
||||
@@ -372,71 +351,12 @@ static void finsh_wait_auth(void)
|
||||
|
||||
static void shell_auto_complete(char *prefix)
|
||||
{
|
||||
|
||||
rt_kprintf("\n");
|
||||
#ifdef FINSH_USING_MSH
|
||||
if (msh_is_used() == RT_TRUE)
|
||||
{
|
||||
msh_auto_complete(prefix);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
extern void list_prefix(char * prefix);
|
||||
list_prefix(prefix);
|
||||
#endif
|
||||
}
|
||||
msh_auto_complete(prefix);
|
||||
|
||||
rt_kprintf("%s%s", FINSH_PROMPT, prefix);
|
||||
}
|
||||
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
void finsh_run_line(struct finsh_parser *parser, const char *line)
|
||||
{
|
||||
const char *err_str;
|
||||
|
||||
if(shell->echo_mode)
|
||||
rt_kprintf("\n");
|
||||
finsh_parser_run(parser, (unsigned char *)line);
|
||||
|
||||
/* compile node root */
|
||||
if (finsh_errno() == 0)
|
||||
{
|
||||
finsh_compiler_run(parser->root);
|
||||
}
|
||||
else
|
||||
{
|
||||
err_str = finsh_error_string(finsh_errno());
|
||||
rt_kprintf("%s\n", err_str);
|
||||
}
|
||||
|
||||
/* run virtual machine */
|
||||
if (finsh_errno() == 0)
|
||||
{
|
||||
char ch;
|
||||
finsh_vm_run();
|
||||
|
||||
ch = (unsigned char)finsh_stack_bottom();
|
||||
if (ch > 0x20 && ch < 0x7e)
|
||||
{
|
||||
rt_kprintf("\t'%c', %d, 0x%08x\n",
|
||||
(unsigned char)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom());
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("\t%d, 0x%08x\n",
|
||||
(unsigned int)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom());
|
||||
}
|
||||
}
|
||||
|
||||
finsh_flush(parser);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
static rt_bool_t shell_handle_history(struct finsh_shell *shell)
|
||||
{
|
||||
@@ -508,10 +428,6 @@ void finsh_thread_entry(void *parameter)
|
||||
shell->echo_mode = 0;
|
||||
#endif
|
||||
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
finsh_init(&shell->parser);
|
||||
#endif
|
||||
|
||||
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
|
||||
/* set console device as shell device */
|
||||
if (shell->device == RT_NULL)
|
||||
@@ -694,26 +610,9 @@ void finsh_thread_entry(void *parameter)
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
shell_push_history(shell);
|
||||
#endif
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
if (msh_is_used() == RT_TRUE)
|
||||
{
|
||||
if (shell->echo_mode)
|
||||
rt_kprintf("\n");
|
||||
msh_exec(shell->line, shell->line_position);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
/* add ';' and run the command line */
|
||||
shell->line[shell->line_position] = ';';
|
||||
|
||||
if (shell->line_position != 0) finsh_run_line(&shell->parser, shell->line);
|
||||
else
|
||||
if (shell->echo_mode) rt_kprintf("\n");
|
||||
#endif
|
||||
}
|
||||
if (shell->echo_mode)
|
||||
rt_kprintf("\n");
|
||||
msh_exec(shell->line, shell->line_position);
|
||||
|
||||
rt_kprintf(FINSH_PROMPT);
|
||||
memset(shell->line, 0, sizeof(shell->line));
|
||||
@@ -766,23 +665,14 @@ void finsh_system_function_init(const void *begin, const void *end)
|
||||
_syscall_table_end = (struct finsh_syscall *) end;
|
||||
}
|
||||
|
||||
void finsh_system_var_init(const void *begin, const void *end)
|
||||
{
|
||||
_sysvar_table_begin = (struct finsh_sysvar *) begin;
|
||||
_sysvar_table_end = (struct finsh_sysvar *) end;
|
||||
}
|
||||
|
||||
#if defined(__ICCARM__) || defined(__ICCRX__) /* for IAR compiler */
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
#pragma section="FSymTab"
|
||||
#pragma section="VSymTab"
|
||||
#pragma section="FSymTab"
|
||||
#endif
|
||||
#elif defined(__ADSPBLACKFIN__) /* for VisaulDSP++ Compiler*/
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
extern "asm" int __fsymtab_start;
|
||||
extern "asm" int __fsymtab_end;
|
||||
extern "asm" int __vsymtab_start;
|
||||
extern "asm" int __vsymtab_end;
|
||||
extern "asm" int __fsymtab_start;
|
||||
extern "asm" int __fsymtab_end;
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma section("FSymTab$a", read)
|
||||
@@ -820,32 +710,21 @@ int finsh_system_init(void)
|
||||
#ifdef __ARMCC_VERSION /* ARM C Compiler */
|
||||
extern const int FSymTab$$Base;
|
||||
extern const int FSymTab$$Limit;
|
||||
extern const int VSymTab$$Base;
|
||||
extern const int VSymTab$$Limit;
|
||||
finsh_system_function_init(&FSymTab$$Base, &FSymTab$$Limit);
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
finsh_system_var_init(&VSymTab$$Base, &VSymTab$$Limit);
|
||||
#endif
|
||||
#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */
|
||||
finsh_system_function_init(__section_begin("FSymTab"),
|
||||
__section_end("FSymTab"));
|
||||
finsh_system_var_init(__section_begin("VSymTab"),
|
||||
__section_end("VSymTab"));
|
||||
#elif defined (__GNUC__) || defined(__TI_COMPILER_VERSION__) || defined(__TASKING__)
|
||||
/* GNU GCC Compiler and TI CCS */
|
||||
extern const int __fsymtab_start;
|
||||
extern const int __fsymtab_end;
|
||||
extern const int __vsymtab_start;
|
||||
extern const int __vsymtab_end;
|
||||
finsh_system_function_init(&__fsymtab_start, &__fsymtab_end);
|
||||
finsh_system_var_init(&__vsymtab_start, &__vsymtab_end);
|
||||
#elif defined(__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
|
||||
finsh_system_function_init(&__fsymtab_start, &__fsymtab_end);
|
||||
finsh_system_var_init(&__vsymtab_start, &__vsymtab_end);
|
||||
#elif defined(_MSC_VER)
|
||||
unsigned int *ptr_begin, *ptr_end;
|
||||
|
||||
if(shell)
|
||||
if (shell)
|
||||
{
|
||||
rt_kprintf("finsh shell already init.\n");
|
||||
return RT_EOK;
|
||||
|
||||
@@ -15,20 +15,20 @@
|
||||
#include "finsh.h"
|
||||
|
||||
#ifndef FINSH_THREAD_PRIORITY
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#endif
|
||||
#ifndef FINSH_THREAD_STACK_SIZE
|
||||
#define FINSH_THREAD_STACK_SIZE 2048
|
||||
#define FINSH_THREAD_STACK_SIZE 2048
|
||||
#endif
|
||||
#ifndef FINSH_CMD_SIZE
|
||||
#define FINSH_CMD_SIZE 80
|
||||
#define FINSH_CMD_SIZE 80
|
||||
#endif
|
||||
|
||||
#define FINSH_OPTION_ECHO 0x01
|
||||
|
||||
#define FINSH_PROMPT finsh_get_prompt()
|
||||
const char* finsh_get_prompt(void);
|
||||
int finsh_set_prompt(const char * prompt);
|
||||
const char *finsh_get_prompt(void);
|
||||
int finsh_set_prompt(const char *prompt);
|
||||
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
#ifndef FINSH_HISTORY_LINES
|
||||
@@ -49,7 +49,7 @@ int finsh_set_prompt(const char * prompt);
|
||||
#endif /* FINSH_USING_AUTH */
|
||||
|
||||
#ifndef FINSH_THREAD_NAME
|
||||
#define FINSH_THREAD_NAME "tshell"
|
||||
#define FINSH_THREAD_NAME "tshell"
|
||||
#endif
|
||||
|
||||
enum input_stat
|
||||
@@ -64,7 +64,7 @@ struct finsh_shell
|
||||
|
||||
enum input_stat stat;
|
||||
|
||||
rt_uint8_t echo_mode:1;
|
||||
rt_uint8_t echo_mode: 1;
|
||||
rt_uint8_t prompt_mode: 1;
|
||||
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
@@ -74,10 +74,6 @@ struct finsh_shell
|
||||
char cmd_history[FINSH_HISTORY_LINES][FINSH_CMD_SIZE];
|
||||
#endif
|
||||
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
struct finsh_parser parser;
|
||||
#endif
|
||||
|
||||
char line[FINSH_CMD_SIZE + 1];
|
||||
rt_uint16_t line_position;
|
||||
rt_uint16_t line_curpos;
|
||||
@@ -95,16 +91,16 @@ void finsh_set_echo(rt_uint32_t echo);
|
||||
rt_uint32_t finsh_get_echo(void);
|
||||
|
||||
int finsh_system_init(void);
|
||||
void finsh_set_device(const char* device_name);
|
||||
const char* finsh_get_device(void);
|
||||
void finsh_set_device(const char *device_name);
|
||||
const char *finsh_get_device(void);
|
||||
char finsh_getchar(void);
|
||||
|
||||
rt_uint32_t finsh_get_prompt_mode(void);
|
||||
void finsh_set_prompt_mode(rt_uint32_t prompt_mode);
|
||||
|
||||
#ifdef FINSH_USING_AUTH
|
||||
rt_err_t finsh_set_password(const char *password);
|
||||
const char *finsh_get_password(void);
|
||||
rt_err_t finsh_set_password(const char *password);
|
||||
const char *finsh_get_password(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-03-22 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#if defined(RT_USING_FINSH) && !defined(FINSH_USING_SYMTAB)
|
||||
|
||||
#include "finsh.h"
|
||||
|
||||
long hello(void);
|
||||
long version(void);
|
||||
long list(void);
|
||||
long list_thread(void);
|
||||
long list_sem(void);
|
||||
long list_mutex(void);
|
||||
long list_fevent(void);
|
||||
long list_event(void);
|
||||
long list_mailbox(void);
|
||||
long list_msgqueue(void);
|
||||
long list_mempool(void);
|
||||
long list_timer(void);
|
||||
|
||||
struct finsh_syscall _syscall_table[] =
|
||||
{
|
||||
{"hello", hello},
|
||||
{"version", version},
|
||||
{"list", list},
|
||||
{"list_thread", list_thread},
|
||||
#ifdef RT_USING_SEMAPHORE
|
||||
{"list_sem", list_sem},
|
||||
#endif
|
||||
#ifdef RT_USING_MUTEX
|
||||
{"list_mutex", list_mutex},
|
||||
#endif
|
||||
#ifdef RT_USING_FEVENT
|
||||
{"list_fevent", list_fevent},
|
||||
#endif
|
||||
#ifdef RT_USING_EVENT
|
||||
{"list_event", list_event},
|
||||
#endif
|
||||
#ifdef RT_USING_MAILBOX
|
||||
{"list_mb", list_mailbox},
|
||||
#endif
|
||||
#ifdef RT_USING_MESSAGEQUEUE
|
||||
{"list_mq", list_msgqueue},
|
||||
#endif
|
||||
#ifdef RT_USING_MEMPOOL
|
||||
{"list_memp", list_mempool},
|
||||
#endif
|
||||
{"list_timer", list_timer},
|
||||
};
|
||||
struct finsh_syscall *_syscall_table_begin = &_syscall_table[0];
|
||||
struct finsh_syscall *_syscall_table_end = &_syscall_table[sizeof(_syscall_table) / sizeof(struct finsh_syscall)];
|
||||
|
||||
struct finsh_sysvar *_sysvar_table_begin = NULL;
|
||||
struct finsh_sysvar *_sysvar_table_end = NULL;
|
||||
|
||||
#endif /* RT_USING_FINSH && !FINSH_USING_SYMTAB */
|
||||
|
||||
@@ -302,7 +302,7 @@ int remove(const char *filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) && defined(RT_USING_MODULE) && defined(RT_USING_DFS)
|
||||
#if defined(RT_USING_FINSH) && defined(RT_USING_MODULE) && defined(RT_USING_DFS)
|
||||
/* use system(const char *string) implementation in the msh */
|
||||
#else
|
||||
int system(const char *string)
|
||||
|
||||
@@ -68,7 +68,7 @@ if RT_USING_AT
|
||||
config AT_USING_CLI
|
||||
bool "Enable CLI(Command-Line Interface) for AT commands"
|
||||
default y
|
||||
depends on FINSH_USING_MSH
|
||||
depends on RT_USING_FINSH
|
||||
|
||||
config AT_PRINT_RAW_CMD
|
||||
bool "Enable print RAW format AT command communication data"
|
||||
|
||||
@@ -66,8 +66,6 @@ static void tftp_server(uint8_t argc, char **argv)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(tftp_server, start tftp server.);
|
||||
|
||||
#if defined(FINSH_USING_MSH)
|
||||
MSH_CMD_EXPORT(tftp_server, start tftp server.);
|
||||
#endif /* defined(FINSH_USING_MSH) */
|
||||
|
||||
#endif /* defined(RT_USING_FINSH) */
|
||||
|
||||
@@ -66,8 +66,6 @@ static void tftp_server(uint8_t argc, char **argv)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(tftp_server, start tftp server.);
|
||||
|
||||
#if defined(FINSH_USING_MSH)
|
||||
MSH_CMD_EXPORT(tftp_server, start tftp server.);
|
||||
#endif /* defined(FINSH_USING_MSH) */
|
||||
|
||||
#endif /* defined(RT_USING_FINSH) */
|
||||
|
||||
@@ -66,8 +66,6 @@ static void tftp_server(uint8_t argc, char **argv)
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(tftp_server, start tftp server.);
|
||||
|
||||
#if defined(FINSH_USING_MSH)
|
||||
MSH_CMD_EXPORT(tftp_server, start tftp server.);
|
||||
#endif /* defined(FINSH_USING_MSH) */
|
||||
|
||||
#endif /* defined(RT_USING_FINSH) */
|
||||
|
||||
@@ -1075,7 +1075,7 @@ const char *ulog_global_filter_kw_get(void)
|
||||
return ulog.filter.keyword;
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
|
||||
#ifdef(RT_USING_FINSH)
|
||||
#include <finsh.h>
|
||||
|
||||
static void _print_lvl_info(void)
|
||||
@@ -1250,7 +1250,7 @@ static void ulog_filter(uint8_t argc, char **argv)
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(ulog_filter, Show ulog filter settings);
|
||||
#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
|
||||
#endif defined(RT_USING_FINSH)
|
||||
#endif /* ULOG_USING_FILTER */
|
||||
|
||||
rt_err_t ulog_backend_register(ulog_backend_t backend, const char *name, rt_bool_t support_color)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user