Fix readline_into_buffer() with CONFIG_CMDLINE_EDITING before relocating
When CONFIG_CMDLINE_EDITING is enabled, readline_into_buffer() doesn't work before relocating to RAM because command history is written into a global array that is not writable before relocation. This patch defers to the no-editing and no-history code in readline_into_buffer() if it is called before relocation. Signed-off-by: James Yang <James.Yang@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
parent
726c0f1e5f
commit
597f6c26a1
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include <post.h>
|
#include <post.h>
|
||||||
|
|
||||||
#if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST)
|
#if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) || defined(CONFIG_CMDLINE_EDITING)
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -67,11 +67,9 @@ static int abortboot(int);
|
|||||||
|
|
||||||
char console_buffer[CFG_CBSIZE]; /* console I/O buffer */
|
char console_buffer[CFG_CBSIZE]; /* console I/O buffer */
|
||||||
|
|
||||||
#ifndef CONFIG_CMDLINE_EDITING
|
|
||||||
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
|
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
|
||||||
static char erase_seq[] = "\b \b"; /* erase sequence */
|
static char erase_seq[] = "\b \b"; /* erase sequence */
|
||||||
static char tab_seq[] = " "; /* used to expand TABs */
|
static char tab_seq[] = " "; /* used to expand TABs */
|
||||||
#endif /* CONFIG_CMDLINE_EDITING */
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOOT_RETRY_TIME
|
#ifdef CONFIG_BOOT_RETRY_TIME
|
||||||
static uint64_t endtime = 0; /* must be set, default is instant timeout */
|
static uint64_t endtime = 0; /* must be set, default is instant timeout */
|
||||||
@ -947,11 +945,26 @@ int readline_into_buffer (const char *const prompt, char * buffer)
|
|||||||
initted = 1;
|
initted = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts (prompt);
|
|
||||||
|
|
||||||
rc = cread_line(prompt, p, &len);
|
/*
|
||||||
return rc < 0 ? rc : len;
|
* History uses a global array which is not
|
||||||
#else
|
* writable until after relocation to RAM.
|
||||||
|
* Revert to non-history version if still
|
||||||
|
* running from flash.
|
||||||
|
*/
|
||||||
|
if (gd->flags & GD_FLG_RELOC) {
|
||||||
|
if (!initted) {
|
||||||
|
hist_init();
|
||||||
|
initted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
puts (prompt);
|
||||||
|
|
||||||
|
rc = cread_line(prompt, p, &len);
|
||||||
|
return rc < 0 ? rc : len;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
#endif /* CONFIG_CMDLINE_EDITING */
|
||||||
char * p_buf = p;
|
char * p_buf = p;
|
||||||
int n = 0; /* buffer index */
|
int n = 0; /* buffer index */
|
||||||
int plen = 0; /* prompt length */
|
int plen = 0; /* prompt length */
|
||||||
@ -1047,12 +1060,13 @@ int readline_into_buffer (const char *const prompt, char * buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CMDLINE_EDITING */
|
#ifdef CONFIG_CMDLINE_EDITING
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_CMDLINE_EDITING
|
|
||||||
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen)
|
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
@ -1082,7 +1096,6 @@ static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen)
|
|||||||
(*np)--;
|
(*np)--;
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CMDLINE_EDITING */
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user