提交 d3e4d469 编写于 作者: B bernard.xiong

add finsh information section in ld script.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@125 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 34367d5e
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
extern char rt_serial_getc(void); extern char rt_serial_getc(void);
#endif #endif
#define FINSH_USING_HISTORY #define FINSH_USING_HISTORY
#if defined(__CC_ARM) /* ARMCC compiler */ #if defined(__CC_ARM) /* ARMCC compiler */
...@@ -47,7 +43,7 @@ extern char rt_serial_getc(void); ...@@ -47,7 +43,7 @@ extern char rt_serial_getc(void);
#pragma section="FSymTab" #pragma section="FSymTab"
#pragma section="VSymTab" #pragma section="VSymTab"
#endif #endif
#elif defined(__GCC__) #elif defined(__GNUC__)
#ifdef FINSH_USING_SYMTAB #ifdef FINSH_USING_SYMTAB
extern int __fsymtab_start; extern int __fsymtab_start;
extern int __fsymtab_end; extern int __fsymtab_end;
...@@ -206,7 +202,7 @@ void finsh_thread_entry(void* parameter) ...@@ -206,7 +202,7 @@ void finsh_thread_entry(void* parameter)
#endif #endif
stat = WAIT_NORMAL; stat = WAIT_NORMAL;
current_history = 0; current_history = 0;
use_history = 0; use_history = 0;
finsh_init(&parser); finsh_init(&parser);
...@@ -225,11 +221,11 @@ void finsh_thread_entry(void* parameter) ...@@ -225,11 +221,11 @@ void finsh_thread_entry(void* parameter)
char ch; char ch;
#ifndef RT_USING_DEVICE #ifndef RT_USING_DEVICE
ch = rt_serial_getc(); ch = rt_serial_getc();
if (ch != 0) if (ch != 0)
#else #else
rt_err_t rx_result; rt_err_t rx_result;
rx_result = rt_device_read(finsh_device, 0, &ch, 1); rx_result = rt_device_read(finsh_device, 0, &ch, 1);
if (ch != 0 && rx_result == 1) if (ch != 0 && rx_result == 1)
#endif #endif
{ {
...@@ -257,48 +253,48 @@ void finsh_thread_entry(void* parameter) ...@@ -257,48 +253,48 @@ void finsh_thread_entry(void* parameter)
if (stat == WAIT_FUNC_KEY) if (stat == WAIT_FUNC_KEY)
{ {
stat = WAIT_NORMAL; stat = WAIT_NORMAL;
if (ch == 0x41) /* up key */ if (ch == 0x41) /* up key */
{ {
/* prev history */ /* prev history */
if (current_history > 0)current_history --; if (current_history > 0)current_history --;
else else
{ {
current_history = 0; current_history = 0;
continue; continue;
} }
/* copy the history command */ /* copy the history command */
memcpy(line, &finsh_cmd_history[current_history][0], memcpy(line, &finsh_cmd_history[current_history][0],
FINSH_CMD_SIZE); FINSH_CMD_SIZE);
pos = strlen(line); pos = strlen(line);
use_history = 1; use_history = 1;
} }
else if (ch == 0x42) /* down key */ else if (ch == 0x42) /* down key */
{ {
/* next history */ /* next history */
if (current_history < finsh_history_count - 1) if (current_history < finsh_history_count - 1)
current_history ++; current_history ++;
else else
{ {
current_history = finsh_history_count - 1; current_history = finsh_history_count - 1;
continue; continue;
} }
memcpy(line, &finsh_cmd_history[current_history][0], memcpy(line, &finsh_cmd_history[current_history][0],
FINSH_CMD_SIZE); FINSH_CMD_SIZE);
pos = strlen(line); pos = strlen(line);
use_history = 1; use_history = 1;
} }
if (use_history) if (use_history)
{ {
rt_kprintf("\033[2K\r"); rt_kprintf("\033[2K\r");
rt_kprintf("finsh>>%s", line); rt_kprintf("finsh>>%s", line);
continue; continue;
} }
} }
#endif #endif
/* /*
* handle tab key * handle tab key
...@@ -306,8 +302,8 @@ void finsh_thread_entry(void* parameter) ...@@ -306,8 +302,8 @@ void finsh_thread_entry(void* parameter)
if (ch == '\t') if (ch == '\t')
{ {
/* auto complete */ /* auto complete */
finsh_auto_complete(&line[0]); finsh_auto_complete(&line[0]);
/* re-calculate position */ /* re-calculate position */
pos = strlen(line); pos = strlen(line);
continue; continue;
} }
...@@ -316,20 +312,20 @@ void finsh_thread_entry(void* parameter) ...@@ -316,20 +312,20 @@ void finsh_thread_entry(void* parameter)
* handle backspace key * handle backspace key
*/ */
if (ch == 0x7f) if (ch == 0x7f)
{ {
if (pos != 0) rt_kprintf("%c", ch); if (pos != 0) rt_kprintf("%c", ch);
line[pos--] = 0; line[pos--] = 0;
if (pos < 0) pos = 0; if (pos < 0) pos = 0;
continue; continue;
} }
line[pos] = ch; line[pos] = ch;
rt_kprintf("%c", line[pos]); rt_kprintf("%c", line[pos]);
/* if it's the end of line, break */ /* if it's the end of line, break */
if (line[pos] == 0xd || line[pos] == 0xa) if (line[pos] == 0xd || line[pos] == 0xa)
{ {
/* change to ';' and break */ /* change to ';' and break */
line[pos] = ';'; line[pos] = ';';
break; break;
...@@ -338,18 +334,18 @@ void finsh_thread_entry(void* parameter) ...@@ -338,18 +334,18 @@ void finsh_thread_entry(void* parameter)
pos ++; pos ++;
} }
} }
} }
if (pos == 0) if (pos == 0)
{ {
rt_kprintf("\n"); rt_kprintf("\n");
continue; continue;
} }
#ifdef FINSH_USING_HISTORY #ifdef FINSH_USING_HISTORY
if (use_history == 0) if (use_history == 0)
{ {
/* push history */ /* push history */
if (finsh_history_count >= FINSH_HISTORY_LINES) if (finsh_history_count >= FINSH_HISTORY_LINES)
{ {
/* move history */ /* move history */
...@@ -358,23 +354,23 @@ void finsh_thread_entry(void* parameter) ...@@ -358,23 +354,23 @@ void finsh_thread_entry(void* parameter)
{ {
memcpy(&finsh_cmd_history[index][0], memcpy(&finsh_cmd_history[index][0],
&finsh_cmd_history[index + 1][0], FINSH_CMD_SIZE); &finsh_cmd_history[index + 1][0], FINSH_CMD_SIZE);
} }
memset(&finsh_cmd_history[index][0], 0, FINSH_CMD_SIZE); memset(&finsh_cmd_history[index][0], 0, FINSH_CMD_SIZE);
memcpy(&finsh_cmd_history[index][0], line, pos); memcpy(&finsh_cmd_history[index][0], line, pos);
/* it's the maximum history */ /* it's the maximum history */
finsh_history_count = FINSH_HISTORY_LINES; finsh_history_count = FINSH_HISTORY_LINES;
} }
else else
{ {
memset(&finsh_cmd_history[finsh_history_count][0], 0, FINSH_CMD_SIZE); memset(&finsh_cmd_history[finsh_history_count][0], 0, FINSH_CMD_SIZE);
memcpy(&finsh_cmd_history[finsh_history_count][0], line, pos); memcpy(&finsh_cmd_history[finsh_history_count][0], line, pos);
/* increase count and set current history position */ /* increase count and set current history position */
finsh_history_count ++; finsh_history_count ++;
} }
} }
current_history = finsh_history_count; current_history = finsh_history_count;
#endif #endif
rt_kprintf("\n"); rt_kprintf("\n");
...@@ -441,6 +437,8 @@ void finsh_system_init() ...@@ -441,6 +437,8 @@ void finsh_system_init()
finsh_system_var_init(__section_begin("VSymTab"), finsh_system_var_init(__section_begin("VSymTab"),
__section_end("VSymTab")); __section_end("VSymTab"));
#elif defined (__GNUC__) /* GNU GCC Compiler */ #elif defined (__GNUC__) /* GNU GCC Compiler */
finsh_system_function_init(&__fsymtab_start, &__fsymtab_end);
finsh_system_var_init(&__vsymtab_start, &__vsymtab_start);
#endif #endif
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册