diff --git a/app/shell/shell.c b/app/shell/shell.c index 89421736..bc760edd 100644 --- a/app/shell/shell.c +++ b/app/shell/shell.c @@ -9,16 +9,11 @@ #include #include -static void shell_init(const struct app_descriptor *app) { - console_init(); -} - static void shell_entry(const struct app_descriptor *app, void *args) { console_start(); } APP_START(shell) -.init = shell_init, .entry = shell_entry, APP_END diff --git a/lib/console/console.c b/lib/console/console.c index 1dce14bd..8bb56e61 100644 --- a/lib/console/console.c +++ b/lib/console/console.c @@ -21,6 +21,8 @@ #include #endif +// Whether to enable command line history. Uses a nonzero +// amount of memory, probably shouldn't enable for memory constrained devices. #ifndef CONSOLE_ENABLE_HISTORY #define CONSOLE_ENABLE_HISTORY 1 #endif @@ -36,8 +38,6 @@ #define MAX_NUM_ARGS 16 -#define HISTORY_LEN 16 - #define LOCAL_TRACE 0 #define WHITESPACE " \t" @@ -55,10 +55,10 @@ static bool abort_script; #if CONSOLE_ENABLE_HISTORY /* command history stuff */ -static char *history; // HISTORY_LEN rows of LINE_LEN chars a piece -static uint history_next; +#define HISTORY_LEN 16 +static char history[HISTORY_LEN * LINE_LEN]; +static uint history_next = 0; -static void init_history(void); static void add_history(const char *line); static uint start_history_cursor(void); static const char *next_history(uint *cursor); @@ -98,16 +98,6 @@ STATIC_COMMAND("repeat", "repeats command multiple times", &cmd_repeat) #endif STATIC_COMMAND_END(help); -int console_init(void) { - LTRACE_ENTRY; - -#if CONSOLE_ENABLE_HISTORY - init_history(); -#endif - - return 0; -} - #if CONSOLE_ENABLE_HISTORY static int cmd_history(int argc, const cmd_args *argv) { dump_history(); @@ -137,12 +127,6 @@ static void dump_history(void) { } } -static void init_history(void) { - /* allocate and set up the history buffer */ - history = calloc(1, HISTORY_LEN * LINE_LEN); - history_next = 0; -} - static void add_history(const char *line) { // reject some stuff if (line[0] == 0) diff --git a/lib/console/include/lib/console.h b/lib/console/include/lib/console.h index 88a4539c..43aa0fcd 100644 --- a/lib/console/include/lib/console.h +++ b/lib/console/include/lib/console.h @@ -17,7 +17,6 @@ #include /* external api */ -int console_init(void); void console_start(void); int console_run_script(const char *string); int console_run_script_locked(const char *string); // special case from inside a command diff --git a/target/sifive-e/rules.mk b/target/sifive-e/rules.mk index 348575ca..8e9fb372 100644 --- a/target/sifive-e/rules.mk +++ b/target/sifive-e/rules.mk @@ -15,6 +15,7 @@ GLOBAL_DEFINES += SIFIVE_FREQ=16000000 MODULE_SRCS := $(LOCAL_DIR)/target.c # set some global defines based on capability +GLOBAL_DEFINES += CONSOLE_ENABLE_HISTORY=0 GLOBAL_DEFINES += PLATFORM_HAS_DYNAMIC_TIMER=1 GLOBAL_DEFINES += ARCH_RISCV_CLINT_BASE=0x02000000 GLOBAL_DEFINES += ARCH_RISCV_MTIME_RATE=32768 diff --git a/target/stellaris-launchpad/rules.mk b/target/stellaris-launchpad/rules.mk index 20588460..f8b8c3aa 100644 --- a/target/stellaris-launchpad/rules.mk +++ b/target/stellaris-launchpad/rules.mk @@ -6,6 +6,7 @@ STELLARIS_CHIP := LM4F120H5QR PLATFORM := stellaris GLOBAL_DEFINES += \ + CONSOLE_ENABLE_HISTORY=0 \ TARGET_HAS_DEBUG_LED=1 \ CRYSTAL_FREQ=16000000