diff options
author | Michael Brandt <Michael.Brandt@stericsson.com> | 2009-11-09 11:28:12 +0100 |
---|---|---|
committer | Michael Brandt <Michael.Brandt@stericsson.com> | 2009-11-09 11:28:12 +0100 |
commit | c5fd9311b6c59a5fb4c6e7188c8bef96e3e2d86d (patch) | |
tree | 9a088934787ff75338f1e400587f7aa63d8edf66 /common | |
parent | ebabdb43046d5ac115b6b53c8e606e3035c32371 (diff) | |
parent | b91b8f74fe9ded18344c3d03080a4abc07254502 (diff) |
Merge branch 'master' of http://git.denx.de/u-boot
Diffstat (limited to 'common')
-rwxr-xr-x | common/Makefile | 3 | ||||
-rwxr-xr-x | common/cmd_nvedit.c | 42 | ||||
-rw-r--r-- | common/env_embedded.c | 7 | ||||
-rw-r--r-- | common/fdt_support.c | 22 | ||||
-rw-r--r-- | common/main.c | 18 |
5 files changed, 85 insertions, 7 deletions
diff --git a/common/Makefile b/common/Makefile index f85b6d319..7ba449505 100755 --- a/common/Makefile +++ b/common/Makefile @@ -52,6 +52,9 @@ COBJS-y += env_common.o COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o +COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o +COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o +COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 91dec157e..6040a9996 100755 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -42,6 +42,9 @@ #include <common.h> #include <command.h> #include <environment.h> +#if defined(CONFIG_CMD_EDITENV) +#include <malloc.h> +#endif #include <watchdog.h> #include <serial.h> #include <linux/stddef.h> @@ -401,7 +404,7 @@ int _do_setenv (int flag, int argc, char *argv[]) int setenv (char *varname, char *varvalue) { char *argv[4] = { "setenv", varname, varvalue, NULL }; - if (varvalue == NULL) + if ((varvalue == NULL) || (varvalue[0] == '\0')) return _do_setenv (0, 2, argv); else return _do_setenv (0, 3, argv); @@ -504,6 +507,34 @@ int do_askenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) #endif /************************************************************************ + * Interactively edit an environment variable + */ +#if defined(CONFIG_CMD_EDITENV) +int do_editenv(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + char buffer[CONFIG_SYS_CBSIZE]; + char *init_val; + int len; + + if (argc < 2) { + cmd_usage(cmdtp); + return 1; + } + + /* Set read buffer to initial value or empty sting */ + init_val = getenv(argv[1]); + if (init_val) + len = sprintf(buffer, "%s", init_val); + else + buffer[0] = '\0'; + + readline_into_buffer("edit: ", buffer); + + return setenv(argv[1], buffer); +} +#endif /* CONFIG_CMD_EDITENV */ + +/************************************************************************ * Look up variable from environment, * return address of storage for that variable, * or NULL if not found @@ -598,6 +629,15 @@ int envmatch (uchar *s1, int i2) /**************************************************/ +#if defined(CONFIG_CMD_EDITENV) +U_BOOT_CMD( + editenv, 2, 0, do_editenv, + "edit environment variable", + "name\n" + " - edit environment variable 'name'" +); +#endif + U_BOOT_CMD( printenv, CONFIG_SYS_MAXARGS, 1, do_printenv, "print environment variables", diff --git a/common/env_embedded.c b/common/env_embedded.c index e27e1cd27..ae6cac439 100644 --- a/common/env_embedded.c +++ b/common/env_embedded.c @@ -41,6 +41,11 @@ #endif /* + * Generate embedded environment table + * inside U-Boot image, if needed. + */ +#if defined(ENV_IS_EMBEDDED) +/* * Only put the environment in it's own section when we are building * U-Boot proper. The host based program "tools/envcrc" does not need * a seperate section. Note that ENV_CRC is only defined when building @@ -205,3 +210,5 @@ unsigned long env_size __PPCTEXT__ = sizeof(env_t); * Add in absolutes. */ GEN_ABS(env_offset, CONFIG_ENV_OFFSET); + +#endif /* ENV_IS_EMBEDDED */ diff --git a/common/fdt_support.c b/common/fdt_support.c index 9adaeb3db..f89a3eef6 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -22,6 +22,7 @@ */ #include <common.h> +#include <stdio_dev.h> #include <linux/ctype.h> #include <linux/types.h> #include <asm/global_data.h> @@ -90,6 +91,23 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, } #ifdef CONFIG_OF_STDOUT_VIA_ALIAS + +#ifdef CONFIG_SERIAL_MULTI +static void fdt_fill_multisername(char *sername, size_t maxlen) +{ + const char *outname = stdio_devices[stdout]->name; + + if (strcmp(outname, "serial") > 0) + strncpy(sername, outname, maxlen); + + /* eserial? */ + if (strcmp(outname + 1, "serial") > 0) + strncpy(sername, outname + 1, maxlen); +} +#else +static inline void fdt_fill_multisername(char *sername, size_t maxlen) {} +#endif /* CONFIG_SERIAL_MULTI */ + static int fdt_fixup_stdout(void *fdt, int chosenoff) { int err = 0; @@ -98,7 +116,9 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff) char sername[9] = { 0 }; const char *path; - sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1); + fdt_fill_multisername(sername, sizeof(sername) - 1); + if (!sername[0]) + sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1); err = node = fdt_path_offset(fdt, "/aliases"); if (node >= 0) { diff --git a/common/main.c b/common/main.c index 026edd1db..10d890417 100644 --- a/common/main.c +++ b/common/main.c @@ -715,16 +715,17 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len) { unsigned long num = 0; unsigned long eol_num = 0; - unsigned long rlen; unsigned long wlen; char ichar; int insert = 1; int esc_len = 0; - int rc = 0; char esc_save[8]; + int init_len = strlen(buf); + + if (init_len) + cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len); while (1) { - rlen = 1; #ifdef CONFIG_BOOT_RETRY_TIME while (!tstc()) { /* while no incoming data */ if (retry_time >= 0 && get_ticks() > endtime) @@ -923,7 +924,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len) cread_add_to_hist(buf); hist_cur = hist_add_idx; - return (rc); + return 0; } #endif /* CONFIG_CMDLINE_EDITING */ @@ -940,6 +941,12 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len) */ int readline (const char *const prompt) { + /* + * If console_buffer isn't 0-length the user will be prompted to modify + * it instead of entering it from scratch as desired. + */ + console_buffer[0] = '\0'; + return readline_into_buffer(prompt, console_buffer); } @@ -964,7 +971,8 @@ int readline_into_buffer (const char *const prompt, char * buffer) initted = 1; } - puts (prompt); + if (prompt) + puts (prompt); rc = cread_line(prompt, p, &len); return rc < 0 ? rc : len; |