summaryrefslogtreecommitdiffstats
path: root/common/cmd_nvedit.c
Commit message (Collapse)AuthorAgeFilesLines
* env: make "env default" selective, check and applyGerlando Falauto2012-09-181-6/+34
| | | | | | | | | | | | Change the syntax (user API) for "env default": -f: override write-once variables var... : accept individual variable(s) -a: all (resetting the whole env is NOT the default behavior) Enable variable checking and make changes effective by enabling do_apply argument to himport_r(). Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
* env: check and apply changes on delete/destroyGerlando Falauto2012-09-181-1/+1
| | | | | Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Reviewed-by: Marek Vasut <marex@denx.de>
* env: add check/apply logic to himport_r()Gerlando Falauto2012-09-181-1/+2
| | | | | | | | | | | | | | | | | | | Change hashtable so that a callback function will decide whether a variable can be overwritten, and possibly apply the changes. So add a new field to struct hsearch_data: o "apply" callback function to check whether a variable can be overwritten, and possibly immediately apply the changes; when NULL, no check is performed. And a new argument to himport_r(): o "do_apply": whether to call the apply callback function NOTE: This patch does not change the current behavior. Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Reviewed-by: Marek Vasut <marex@denx.de>
* env: make himport_r() selective on variablesGerlando Falauto2012-09-181-1/+2
| | | | | | | | | | | | Add 2 new arguments to himport_r(): o "nvars", "vars": number and list of variables to take into account (0 means ALL) NOTE: This patch does not change the current behaviour. Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Reviewed-by: Marek Vasut <marex@denx.de>
* env: unify logic to check and apply changesGerlando Falauto2012-09-181-49/+92
| | | | | | | | | | | | | | The logic of checking special parameters (e.g. baudrate, stdin, stdout, for a valid value and/or whether can be overwritten) and applying the new value to the running system is now all within a single function env_check_apply() which can be called whenever changes are made to the environment, no matter if by set, default or import. With this patch env_check_apply() is only called by "env set", retaining previous behavior. Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Reviewed-by: Marek Vasut <marex@denx.de>
* env: cosmetic: drop assignment i = iomux_doenv()Gerlando Falauto2012-09-181-3/+2
| | | | | | | | | iomux_doenv() can only return 0 or 1. So there is no need to save its return value in variable i, as checking its truth value within an if statement is enough. Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Reviewed-by: Marek Vasut <marex@denx.de>
* env import/export: Remove from help if disabledBenoît Thébaudeau2012-09-181-0/+4
| | | | | | Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* Block: Remove MG DISK supportMarek Vasut2012-06-211-2/+1
| | | | | | | | This driver is unused and obsolete. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: unsik Kim <donari75@gmail.com>
* common/cmd_nvedit.c: Fix GCC 4.6 warningAnatolij Gustschin2012-05-221-1/+0
| | | | | | | cmd_nvedit.c: In function '_do_env_set': cmd_nvedit.c:207:9: warning: unused variable 'bd' [-Wunused-variable] Signed-off-by: Anatolij Gustschin <agust@denx.de>
* net: punt bd->bi_ip_addrMike Frysinger2012-05-151-15/+1
| | | | | | | | | This field gets read in one place (by "bdinfo"), and we can replace that with getenv("ipaddr"). After all, the bi_ip_addr field is kept up-to-date implicitly with the value of the ipaddr env var. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
* powerpc/corenet_ds: Slave reads ENV from master when boot from SRIOLiu Gang2012-04-241-1/+2
| | | | | | | | | | | | | | | | | | | | When boot from SRIO, slave's ENV can be stored in master's memory space, then slave can fetch the ENV through SRIO interface. NOTE: Because the slave can not erase, write master's NOR flash by SRIO interface, so it can not modify the ENV parameters stored in master's NOR flash using "saveenv" or other commands. Master needs to: 1. Put the slave's ENV into it's own memory space. 2. Set an inbound SRIO window covered slave's ENV stored in master's memory space. Slave needs to: 1. Set a specific TLB entry in order to fetch ucode and ENV from master. 2. Set a LAW entry with the TargetID SRIO1 or SRIO2 for ucode and ENV. Signed-off-by: Liu Gang <Gang.Liu@freescale.com> Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
* Add support for loading and saving the environment to a FAT partitionMaximilian Schwerin2012-03-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The following must be defined: CONFIG_ENV_IS_IN_FAT Enable this saving environment to FAT. FAT_ENV_INTERFACE Interface the FAT resides on (e.g. mmc). FAT_ENV_DEVICE The interface device number (e.g. 0 for mmc0) FAT_ENV_PART The device part (e.g. 1 for mmc0:1) FAT_ENV_FILE The filename of the environment file. Author: Maximilian Schwerin <mvs@tigris.de> Removed dead DEBUG comment. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Convert cmd_usage() calls in common to use a return valueSimon Glass2012-03-061-11/+11
| | | | | | | | | Change all files in common/ to use CMD_RET_USAGE instead of calling cmd_usage() directly. I'm not completely sure about this patch since the code since impact is small (100 byte or so on ARM) and it might need splitting into smaller patches. But for now here it is. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: add possibility for readline_into_buffer timeoutHeiko Schocher2012-02-121-1/+1
| | | | | | | | | add possibility to add a timeout when reading a line into a buffer. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Mike Frysinger <vapier@gentoo.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* common/cmd_nvedit.c: Fix size calculation in do_env_import()Horst Kronstorfer2011-12-191-1/+1
| | | | | | | | do_env_import() missed the final '\0' terminator when calculating the size of an environment data block. This led to an erroneous 'bad CRC, import failed' message for a checksum protected environment (-c.) Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
* common/cmd_nvedit.c: Add missing 'env save' preproc guardHorst Kronstorfer2011-12-121-0/+2
| | | | Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
* cmd_nvedit.c: Fix compiler warning introduced by checkpatch cleanupKumar Gala2011-11-271-1/+1
| | | | | | | | | cmd_nvedit.c: In function 'do_env_grep': cmd_nvedit.c:182:3: warning: suggest parentheses around assignment used as truth value Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Igor Grinberg <grinberg@compulab.co.il>
* env: clean cmd_nvedit.c checkpatch and code styleIgor Grinberg2011-11-221-52/+47
| | | | | | | | | | | | | | Cleanup the cmd_nvedit.c checkpatch warnings, errors and coding style. There are 10 wanrings left about the simple_strtoul() function: WARNING: simple_strtoul is obsolete, use kstrtoul instead #359: FILE: cmd_nvedit.c:359: + load_addr = simple_strtoul(argv[2], NULL, 16); ... total: 0 errors, 10 warnings, 1043 lines checked Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
* common: move extern char console_buffer[] to common.hIgor Grinberg2011-11-221-1/+0
| | | | | | | | | Extract all extern declarations for console_buffer[] out of c files into the common.h header. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Cc: Frank Gottschling <fgottschling@eltec.de> Cc: Murray Jensen <Murray.Jensen@csiro.au>
* Fix warnings in cmd_nvedit.cSimon Glass2011-11-221-2/+2
| | | | | | | | This printf() string should be %ld now that uintptr_t is defined as long. Also fix a size_t error. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* env: allow to export only selected variablesWolfgang Denk2011-11-081-12/+21
| | | | | | | | | | | | | | New syntax: env export [-t | -b | -c] [-s size] addr [var ...] With this change it is possible to provide a list of variables names that shall be exported. Whenno arguments are given, the whole environment gets exported. NOTE: The new handling of the "size" argument means a change to the user API. Signed-off-by: Wolfgang Denk <wd@denx.de>
* tftpput: add save_addr and save_size global variablesSimon Glass2011-10-261-0/+2
| | | | | | We need something akin to load_addr to handle saving data. Signed-off-by: Simon Glass <sjg@chromium.org>
* Add setenv_ulong() and setenv_addr()Simon Glass2011-10-261-0/+30
| | | | | | | It seems we put numbers and addresses into environment variables a lot. We should have some functions to do this. Signed-off-by: Simon Glass <sjg@chromium.org>
* Add getenv_ulong() to read an integer from an environment variableSimon Glass2011-10-231-0/+20
| | | | | | | | This is not an uncommon operation in U-Boot, so let's put it in a common function. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* GCC4.6: Squash warning in cmd_nvedit.cMarek Vasut2011-10-011-2/+1
| | | | | | | | cmd_nvedit.c: In function ‘do_env_edit’: cmd_nvedit.c:463:6: warning: variable ‘len’ set but not used [-Wunused-but-set-variable] Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
* Constify getenv(), setenv() and hash code functionsWolfgang Denk2011-07-301-6/+7
| | | | | | | | | | | This is needed to get rid of build warnings like main.c:311: warning: passing argument 2 of 'setenv' discards qualifiers from pointer target type which result from commit 09c2e90 "unify version_string". Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Andreas Bießmann <andreas.devel@googlemail.com>
* cmd_nvedit.c: make error message more helpfulWolfgang Denk2011-05-121-1/+2
| | | | | | | | | | | | | | | | | When calling getenv_f() with a too small buffer, it would print an error message like this: env_buf too small [32] This is not really helpful as it does not give any indication which of the calls might have failed. Change this into: env_buf [32 bytes] too small for value of "hwconfig" so we know at least which variable caused the overflow; this usually allows to quickly find the related code as well. Signed-off-by: Wolfgang Denk <wd@denx.de>
* cmd_nvedit.c: clean up with checkpatchMacpaul Lin2011-04-301-75/+73
| | | | | | | Code clean up of cmd_nvedit.c by using checkpatch.pl. Signed-off-by: Macpaul Lin <macpaul@andestech.com> Acked-by: Detlev Zundel <dzu@denx.de>
* common: add a grepenv commandKim Phillips2011-04-281-3/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | u-boot environments, esp. when boards are shared across multiple users, can get pretty large and time consuming to visually parse. The grepenv command this patch adds can be used in lieu of printenv to facilitate searching. grepenv works like printenv but limits its output only to environment strings (variable name and value pairs) that match the user specified substring. the following examples are on a board with a 5313 byte environment that spans multiple screen pages: Example 1: summarize ethernet configuration: => grepenv eth TSEC etact=FM1@DTSEC2 eth=FM1@DTSEC4 ethact=FM1@DTSEC2 eth1addr=00:E0:0C:00:8b:01 eth2addr=00:E0:0C:00:8b:02 eth3addr=00:E0:0C:00:8b:03 eth4addr=00:E0:0C:00:8b:04 eth5addr=00:E0:0C:00:8b:05 eth6addr=00:E0:0C:00:8b:06 eth7addr=00:E0:0C:00:8b:07 eth8addr=00:E0:0C:00:8b:08 eth9addr=00:E0:0C:00:8b:09 ethaddr=00:E0:0C:00:8b:00 netdev=eth0 uprcw=setenv ethact $eth;setenv filename p4080ds/R_PPSXX_0xe/rcw_0xe_2sgmii_rev2_high.bin;setenv start 0xe8000000;protect off all;run upimage;protect on all upuboot=setenv ethact $eth;setenv filename u-boot.bin;setenv start eff80000;protect off all;run upimage;protect on all upucode=setenv ethact $eth;setenv filename fsl_fman_ucode_P4080_101_6.bin;setenv start 0xef000000;protect off all;run upimage;protect on all usdboot=setenv ethact $eth;tftp 1000000 $dir/$bootfile;tftp 2000000 $dir/initramfs.cpio.gz.uboot;tftp c00000 $dir/p4080ds-usdpaa.dtb;setenv bootargs root=/dev/ram rw console=ttyS0,115200 $othbootargs;bootm 1000000 2000000 c00000; => Example 2: detect unused env vars: => grepenv etact etact=FM1@DTSEC2 => Example 3: reveal hardcoded variables; e.g., for fdtaddr: => grepenv fdtaddr fdtaddr=c00000 nfsboot=setenv bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate $othbootargs;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr - $fdtaddr ramboot=setenv bootargs root=/dev/ram rw console=$consoledev,$baudrate $othbootargs;tftp $ramdiskaddr $ramdiskfile;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr $ramdiskaddr $fdtaddr => grep $fdtaddr fdtaddr=c00000 my_boot=bootm 0x40000000 0x41000000 0x00c00000 my_dtb=tftp 0x00c00000 $prefix/p4080ds.dtb nohvboot=tftp 1000000 $dir/$bootfile;tftp 2000000 $dir/$ramdiskfile;tftp c00000 $dir/$fdtfile;setenv bootargs root=/dev/ram rw ramdisk_size=0x10000000 console=ttyS0,115200;bootm 1000000 2000000 c00000; => This patch also enables the grepenv command by default on corenet_ds based boards (and repositions the DHCP command entry to keep the list sorted). Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Cc: Kumar Gala <kumar.gala@freescale.com> Cc: Andy Fleming <afleming@freescale.com>
* Fix typo in #error: IS_IN_NOWHERE vs. IS_NOWHERELoïc Minier2011-04-261-1/+1
| | | | Signed-off-by: Loïc Minier <loic.minier@linaro.org>
* env: make import/export optionalMike Frysinger2011-04-131-0/+8
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* cmd_nvedit: use explicit typecast for printfAndreas Bießmann2011-04-121-2/+2
| | | | | | | | | | | This patch fixes warnings in MAKEALL for avr32: ---8<--- cmd_nvedit.c: In function 'do_env_export': cmd_nvedit.c:663: warning: format '%zX' expects type 'size_t', but argument 3 has type 'ssize_t' --->8--- Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
* load_addr: move to common env codeMike Frysinger2011-01-091-0/+2
| | | | | | | | | Rather than keep the load_addr definition with the bootm code (which just happens to use this), move it to the common env code. This way we can disable bootm support completely while retaining load_addr usage with many other commands. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* hashtable: drop all non-reentrant versionsMike Frysinger2010-12-171-9/+9
| | | | | | | | | | | The non-reentrant versions of the hashtable functions operate on a single shared hashtable. So if two different people try using these funcs for two different purposes, they'll cause problems for the other. Avoid this by converting all existing hashtable consumers over to the reentrant versions and then punting the non-reentrant ones. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* autocomplete: remove runtime handler installMike Frysinger2010-11-281-8/+12
| | | | | | | | | | | Rather than add runtime overhead of installing completion handlers, do it statically at build time. This requires a new build time helper macro to declare a command and the completion handler at the same time. Then we convert the env related funcs over to this. This gives an opportunity to also unify the U_BOOT_CMD macros. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* common/cmd_nvedit: Use return value of cmd_usageThomas Weber2010-11-271-12/+6
| | | | | | | | Use the return value of cmd_usage instead of ignoring this and returning a 1. Signed-off-by: Thomas Weber <weber@corscience.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* Common/cmd_nvedit: Check for env subcommandThomas Weber2010-11-271-0/+3
| | | | | | | The env command needs one subcommand. If this is not available print the usage help. Signed-off-by: Thomas Weber <weber@corscience.de>
* Replace CONFIG_RELOC_FIXUP_WORKS by CONFIG_NEEDS_MANUAL_RELOCWolfgang Denk2010-10-291-1/+1
| | | | | | | | | | | By now, the majority of architectures have working relocation support, so the few remaining architectures have become exceptions. To make this more obvious, we make working relocation now the default case, and flag the remaining cases with CONFIG_NEEDS_MANUAL_RELOC. Signed-off-by: Wolfgang Denk <wd@denx.de> Tested-by: Heiko Schocher <hs@denx.de> Tested-by: Reinhard Meyer <u-boot@emk-elektronik.de>
* env: fix cmd_env_sub fct pointers if CONFIG_RELOC_FIXUP_WORKS is not definedHeiko Schocher2010-10-061-0/+7
| | | | | | | | | | | | | | | | | | | commit ea882baf9c17cd142c99e3ff640d3ab01daa5cec introduces a command_sub_table for the "env" command. On arm, avr32, m68k, mips and sparc architectures, relocation needs manual fixups, so add these fixups for this sub command table too. Tested on arm/qong board. mips board (Ben NanoNote) from Xiangfu Liu arm/AT91 board from Reinhard Meyer Signed-off-by: Heiko Schocher <hs@denx.de> cc: Wolfgang Denk <wd@denx.de> cc: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp> cc: Xiangfu Liu <xiangfu@openmobilefree.net> cc: Reinhard Meyer <u-boot@emk-elektronik.de> cc: sshtylyov@mvista.com
* New implementation for internal handling of environment variables.Wolfgang Denk2010-09-191-201/+467
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: * Old environment code used a pessimizing implementation: - variable lookup used linear search => slow - changed/added variables were added at the end, i. e. most frequently used variables had the slowest access times => slow - each setenv() would calculate the CRC32 checksum over the whole environment block => slow * "redundant" envrionment was locked down to two copies * No easy way to implement features like "reset to factory defaults", or to select one out of several pre-defined (previously saved) sets of environment settings ("profiles") * No easy way to import or export environment settings ====================================================================== API Changes: - Variable names starting with '#' are no longer allowed I didn't find any such variable names being used; it is highly recommended to follow standard conventions and start variable names with an alphanumeric character - "printenv" will now print a backslash at the end of all but the last lines of a multi-line variable value. Multi-line variables have never been formally defined, allthough there is no reason not to use them. Now we define rules how to deal with them, allowing for import and export. - Function forceenv() and the related code in saveenv() was removed. At the moment this is causing build problems for the only user of this code (schmoogie - which has no entry in MAINTAINERS); may be fixed later by implementing the "env set -f" feature. Inconsistencies: - "printenv" will '\\'-escape the '\n' in multi-line variables, while "printenv var" will not do that. ====================================================================== Advantages: - "printenv" output much better readable (sorted) - faster! - extendable (additional variable properties can be added) - new, powerful features like "factory reset" or easy switching between several different environment settings ("profiles") Disadvantages: - Image size grows by typically 5...7 KiB (might shrink a bit again on systems with redundant environment with a following patch series) ====================================================================== Implemented: - env command with subcommands: - env print [arg ...] same as "printenv": print environment - env set [-f] name [arg ...] same as "setenv": set (and delete) environment variables ["-f" - force setting even for read-only variables - not implemented yet.] - end delete [-f] name not implemented yet ["-f" - force delete even for read-only variables] - env save same as "saveenv": save environment - env export [-t | -b | -c] addr [size] export internal representation (hash table) in formats usable for persistent storage or processing: -t: export as text format; if size is given, data will be padded with '\0' bytes; if not, one terminating '\0' will be added (which is included in the "filesize" setting so you can for exmple copy this to flash and keep the termination). -b: export as binary format (name=value pairs separated by '\0', list end marked by double "\0\0") -c: export as checksum protected environment format as used for example by "saveenv" command addr: memory address where environment gets stored size: size of output buffer With "-c" and size is NOT given, then the export command will format the data as currently used for the persistent storage, i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and prepend a valid CRC32 checksum and, in case of resundant environment, a "current" redundancy flag. If size is given, this value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32 checksum and redundancy flag will be inserted. With "-b" and "-t", always only the real data (including a terminating '\0' byte) will be written; here the optional size argument will be used to make sure not to overflow the user provided buffer; the command will abort if the size is not sufficient. Any remainign space will be '\0' padded. On successful return, the variable "filesize" will be set. Note that filesize includes the trailing/terminating '\0' byte(s). Usage szenario: create a text snapshot/backup of the current settings: => env export -t 100000 => era ${backup_addr} +${filesize} => cp.b 100000 ${backup_addr} ${filesize} Re-import this snapshot, deleting all other settings: => env import -d -t ${backup_addr} - env import [-d] [-t | -b | -c] addr [size] import external format (text or binary) into hash table, optionally deleting existing values: -d: delete existing environment before importing; otherwise overwrite / append to existion definitions -t: assume text format; either "size" must be given or the text data must be '\0' terminated -b: assume binary format ('\0' separated, "\0\0" terminated) -c: assume checksum protected environment format addr: memory address to read from size: length of input data; if missing, proper '\0' termination is mandatory - env default -f reset default environment: drop all environment settings and load default environment - env ask name [message] [size] same as "askenv": ask for environment variable - env edit name same as "editenv": edit environment variable - env run same as "run": run commands in an environment variable ====================================================================== TODO: - drop default env as implemented now; provide a text file based initialization instead (eventually using several text files to incrementally build it from common blocks) and a tool to convert it into a binary blob / object file. - It would be nice if we could add wildcard support for environment variables; this is needed for variable name auto-completion, but it would also be nice to be able to say "printenv ip*" or "printenv *addr*" - Some boards don't link any more due to the grown code size: DU405, canyonlands, sequoia, socrates. => cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>, Stefan Roese <sr@denx.de>, Heiko Schocher <hs@denx.de> - Dropping forceenv() causes build problems on schmoogie => cc: Sergey Kubushyn <ksi@koi8.net> - Build tested on PPC and ARM only; runtime tested with NOR and NAND flash only => needs testing!! Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>, Cc: Stefan Roese <sr@denx.de>, Cc: Heiko Schocher <hs@denx.de> Cc: Sergey Kubushyn <ksi@koi8.net>
* Make getenv() work before relocation.Wolfgang Denk2010-09-191-11/+18
| | | | | | | | | | | | | | | | | | | So far, getenv() would work before relocation is most cases, even though it was not intended to be used that way. When switching to a hash table based implementation, this would break a number of boards. For convenience, we make getenv() check if it's running before relocation and, if so, use getenv_f() internally. Note that this is limited to simple cases, as we use a small static buffer (32 bytes) in the global data for this purpose. For this reason, it is also not a good idea to convert all current uses of getenv_f() into getenv() - some of the existing use cases need to be able to deal with longer variable values, so getenv_f() is still needed and recommended for use before relocation. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Remove support for CONFIG_HAS_UID and "forceenv" commandWolfgang Denk2010-09-191-13/+0
| | | | | | | | | | | | This (undocumented) concept was only in use for the MVSMR and davinci_schmoogie Sergey Kubushyn <ksi@koi8.net> boards. Drop it for now. If really needed, it should be reimplemented later in the context of the new environment command set. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Andre Schwarz <andre.schwarz@matrix-vision.de> Cc: Sergey Kubushyn <ksi@koi8.net> Acked-by: Sergey Kubushyn <ksi@koi8.net>
* Save environment data to mmc.Terry Lv2010-09-191-1/+2
| | | | | | | | This patch is to save environment data to mmc card. It uses interfaces defined in generic mmc. Signed-off-by: Terry Lv <r65388@freescale.com> Acked-by: Stefano Babic <sbabic@denx.de>
* getenv_f(): fix handling of too short buffersWolfgang Denk2010-08-091-6/+12
| | | | | | | | Fix error handling in getenv_f() when the user provided buffer is too short to hold the variable name; make sure to truncate and NUL-terminate without overwriting the buffer limits. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Rename getenv_r() into getenv_f()Wolfgang Denk2010-08-041-1/+1
| | | | | | | | | | | | | | | | | | | While running from flash, i. e. before relocation, we have only a limited C runtime environment without writable data segment. In this phase, some configurations (for example with environment in EEPROM) must not use the normal getenv(), but a special function. This function had been called getenv_r(), with the idea that the "_r" suffix would mean the same as in the _r_eentrant versions of some of the C library functions (for example getdate vs. getdate_r, getgrent vs. getgrent_r, etc.). Unfortunately this was a misleading name, as in U-Boot the "_r" generally means "running from RAM", i. e. _after_ relocation. To avoid confusion, rename into getenv_f() [as "running from flash"] Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Detlev Zundel <dzu@denx.de>
* cmd_usage(): simplify return code handlingWolfgang Denk2010-07-241-14/+8
| | | | | | | | | | | | | | | | Lots of code use this construct: cmd_usage(cmdtp); return 1; Change cmd_usage() let it return 1 - then we can replace all these ocurrances by return cmd_usage(cmdtp); This fixes a few places with incorrect return code handling, too. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Make sure that argv[] argument pointers are not modified.Wolfgang Denk2010-07-041-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hush shell dynamically allocates (and re-allocates) memory for the argument strings in the "char *argv[]" argument vector passed to commands. Any code that modifies these pointers will cause serious corruption of the malloc data structures and crash U-Boot, so make sure the compiler can check that no such modifications are being done by changing the code into "char * const argv[]". This modification is the result of debugging a strange crash caused after adding a new command, which used the following argument processing code which has been working perfectly fine in all Unix systems since version 6 - but not so in U-Boot: int main (int argc, char **argv) { while (--argc > 0 && **++argv == '-') { /* ====> */ while (*++*argv) { switch (**argv) { case 'd': debug++; break; ... default: usage (); } } } ... } The line marked "====>" will corrupt the malloc data structures and usually cause U-Boot to crash when the next command gets executed by the shell. With the modification, the compiler will prevent this with an error: increment of read-only location '*argv' N.B.: The code above can be trivially rewritten like this: while (--argc > 0 && **++argv == '-') { char *arg = *argv; while (*++arg) { switch (*arg) { ... Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* Remove AmigaOneG3SE boardWolfgang Denk2010-06-231-12/+0
| | | | | | | | | | The AmigaOneG3SE board has been orphaned or a very long time, and broken for more than 12 releases resp. more than 3 years. As nobody seems to be interested any more in this stuff we may as well ged rid of it, especially as it clutters many areas of the code so it is a continuous pain for all kinds of ongoing work. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Add 'editenv' commandPeter Tyser2009-10-271-0/+40
| | | | | | | | | The editenv command can be used to edit an environment variable. Editing an environment variable is useful when one wants to tweak an existing variable, for example fix a typo or change the baudrate in the 'bootargs' environment variable. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* setenv(): Delete 0-length environment variablesPeter Tyser2009-10-271-1/+1
| | | | | | | | | | | | Previously setenv() would only delete an environment variable if it was passed a NULL string pointer as a value. It should also delete an environment variable when it encounters a valid string pointer of 0-length. This change/fix is generally useful and is necessary for the upcoming "editenv" command. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
OpenPOWER on IntegriCloud