summaryrefslogtreecommitdiff
path: root/include/environment.h
Commit message (Collapse)AuthorAgeFilesLines
* env: Rename environment.h to env_internal.hSimon Glass2019-08-111-270/+0
| | | | | | | | | | | | | | This file contains lots of internal details about the environment. Most code can include env.h instead, calling the functions there as needed. Rename this file and add a comment at the top to indicate its internal nature. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> [trini: Fixup apalis-tk1.c] Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Move TOTAL_MALLOC_LEN to environment.hSimon Glass2019-08-111-0/+14
| | | | | | | | | | | | | | This declaration is only used in three files. Although it relates to malloc() it is actually only used during malloc() init. It uses CONFIG options including CONFIG_ENV_ADDR which are defined only in environment.h so this header must be included anyway, for TOTAL_MALLOC_LEN to be correct. Nove it to environment.h to simplify the common file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
* env: Rename the redundancy flagsSimon Glass2019-08-111-4/+1
| | | | | | | | Add an ENV prefix to these two flags so that it is clear what they relate to. Also move them to env.h since they are part of the public API. Use an enum rather than a #define to tie them together. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move env_valid to env.hSimon Glass2019-08-111-7/+0
| | | | | | | | This enum is somewhat widely used to determine if the environment is valid or not. Move it to the common environment header file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Rename environment to embedded_environmentSimon Glass2019-08-111-1/+1
| | | | | | | | | The name 'environment' is widely used in U-Boot so is not a very useful name of a variable. Rename it to better indicate its purpose. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
* env: Move env_reloc() to env.hSimon Glass2019-08-111-4/+0
| | | | | | | Move env_reloc() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move env_get_char() to env.hSimon Glass2019-08-111-10/+0
| | | | | | | Move env_get_char() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move get/set_default_env() to env.hSimon Glass2019-08-111-6/+0
| | | | | | | | Move these functions to the new header file and rename set_default_env() to env_set_default() so that it has a consistent env_ prefix. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Drop env_crc_update()Simon Glass2019-08-111-3/+0
| | | | | | | This function is not defined or used in U-Boot. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Move env import/export functions to env.hSimon Glass2019-08-111-12/+0
| | | | | | | Move these functions to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move env_load/save functions to env.hSimon Glass2019-08-111-21/+0
| | | | | | | Move these function to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move set_default_vars to env.hSimon Glass2019-08-111-3/+0
| | | | | | | | Move this function to the new header file and rename it so it has an env_ prefix. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move env_fix_drivers() to env.hSimon Glass2019-08-111-5/+0
| | | | | | Move this function over to the new header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: net: Move eth_parse_enetaddr() to net.c/hSimon Glass2019-08-111-2/+0
| | | | | | | This function fits better with the network subsystem, so move it. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Move eth_env_get/set_enetaddr() to env.hSimon Glass2019-08-111-2/+0
| | | | | | | Move these two functions over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: register erase commandFrank Wunderlich2019-07-181-0/+17
| | | | | | | | | | | | | | | | | this patch adds basic changes for adding a erase-subcommand to env with this command the environment stored on non-volatile storage written by saveenv can be cleared. Signed-off-by: Frank Wunderlich <frank-w@public-files.de> squashed fixes - start message with "Erasing" - mark erase-function as optional - env: separate eraseenv from saveenv Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
* env: fix allow to build multiple environmentsRajesh Bhagat2019-01-171-9/+0
| | | | | | | | | | | | | | Patch fixes build error when enabling CONFIG_ENV_IS_IN_SPI_FLAS and CONFIG_ENV_IS_IN_MMC at the same time mentioned issue in below link: Refer: https://lists.denx.de/pipermail/u-boot/2018-February/319565.html build error when enabling CONFIG_ENV_IS_IN_SPI_FLASH and CONFIG_ENV_IS_IN_MMC at the same time. Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com> Reviewed-by: York Sun <york.sun@nxp.com>
* env: allow flash and nand env driver to compile togetherRajesh Bhagat2018-12-041-1/+0
| | | | | | | | Define env_ptr as static in flash and nand env driver to allow these to compile together. Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com> Reviewed-by: York Sun <york.sun@nxp.com>
* env: common: accept flags on reset to default envYaniv Levinsky2018-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The function set_default_env() sets the hashtable flags for import_r(). Formally set_default_env() doesn't accept flags from its callers. In practice the caller can (un)set the H_INTERACTIVE flag, but it has to be done using the first character of the function's string argument. Other flags like H_FORCE can't be set by the caller. Change the function to accept flags argument. The benefits are: 1. The caller will have to explicitly set the H_INTERACTIVE flag, instead of un-setting it using a special char in a string. 2. Add the ability to propagate flags from the caller to himport(), especially the H_FORCE flag from do_env_default() in nvedit.c that currently gets ignored for "env default -a -f" commands. 3. Flags and messages will not be coupled together. A caller will be able to set flags without passing a string and vice versa. Please note: The propagation of H_FORCE from do_env_default() does not introduce any functional changes, because currently himport_r() is set to destroy the old environment regardless if H_FORCE flag is set or not. More changes are needed to utilize the propagation of H_FORCE. Signed-off-by: Yaniv Levinsky <yaniv.levinsky@compulab.co.il> Acked-by: Igor Grinberg <grinberg@compulab.co.il>
* cmd: nvedit: propagate envflag to set_default_varsYaniv Levinsky2018-07-191-1/+1
| | | | | | | | | | | | | | | | | | The env_flag in do_env_default() doesn't get propagated and therefore gets ignored by himport_r(). This breaks to ability to "forcibly" reset variables to their default values using the environment command. Scenario example of the problem: # setenv kernel uImage # setenv .flags kernel:so # env default -f kernel ## Error: Can't overwrite "kernel" himport_r: can't insert "kernel=zImage" into hash table Change the call path so it will pass the flag correctly. Signed-off-by: Yaniv Levinsky <yaniv.levinsky@compulab.co.il> Acked-by: Igor Grinberg <grinberg@compulab.co.il>
* u-boot: Fix several typosShyam Saini2018-06-131-1/+1
| | | | | | | 's/environemnt/environment/' and 's/Environemnt/Environment/' Signed-off-by: Shyam Saini <shyam@amarulasolutions.com>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Relocate env drivers if manual reloc is requiredSiva Durga Prasad Paladugu2018-04-161-0/+5
| | | | | | | | | | Relocate env drivers if manual relocation is enabled. This patch fixes the issue of u-boot hang incase if env is present in any of the flash devices. Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* net: Move enetaddr env access code to env config instead of net configAlex Kiernan2018-04-081-0/+4
| | | | | | | | | | | | | | | | | | | | In order that we can use eth_env_* even when CONFIG_NET isn't set, move these functions to environment code from net code. This fixes failures such as: board/ti/am335x/built-in.o: In function `board_late_init': board/ti/am335x/board.c:752: undefined reference to `eth_env_set_enetaddr' u-boot/board/ti/am335x/board.c:766: undefined reference to `eth_env_set_enetaddr' which caters for use cases such as: commit f411b5cca48f ("board: am335x: Always set eth/eth1addr environment variable") when Ethernet is required in Linux, but not U-Boot. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
* env: restore old env_get_char() behaviourGoldschmidt Simon2018-02-161-11/+0
| | | | | | | | | | | | With multiple environments, the 'get_char' callback for env drivers does not really make sense any more because it is only supported by two drivers (eeprom and nvram). To restore single character loading for these drivers, override 'env_get_char_spec'. Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
* env: Fix env_load_locationYork Sun2018-02-161-1/+1
| | | | | | | | | | | | | Commit 7d714a24d725 ("env: Support multiple environments") added static variable env_load_location. When saving environmental variables, this variable is presumed to have the value set before. In case the value was set before relocation and U-Boot runs from a NOR flash, this variable wasn't writable. This causes failure when saving the environment. To save this location, global data must be used instead. Signed-off-by: York Sun <york.sun@nxp.com> CC: Maxime Ripard <maxime.ripard@free-electrons.com>
* env: move more common code to env_import_redundSimon Goldschmidt2018-02-011-1/+2
| | | | | | | | | | | | | | There is more common code in mmc, nand and ubi env drivers that can be shared by moving to env_import_redund. For this, a status/error value whether the buffers were loaded are passed as additional parameters to env_import_redund. Ideally, these are already returned to the env driver by the storage driver. This is the case for mmc, nand and ubi, so for this change, code deduplicated. Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
* env: Pass additional parameters to the env lookup functionMaxime Ripard2018-01-271-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | In preparation for the multiple environment support, let's introduce two new parameters to the environment driver lookup function: the priority and operation. The operation parameter is meant to identify, obviously, the operation you might want to perform on the environment. The priority is a number passed to identify the environment priority you want to retrieve. The lowest priority parameter (0) will be the primary source. Combining the two parameters allow you to support multiple environments through different priorities, and to change those priorities between read and writes operations. This is especially useful to implement migration mechanisms where you want to always use the same environment first, be it to read or write, while the common case is more likely to use the same environment it has read from to write it to. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
* cmd: nvedit: Get rid of the env lookupMaxime Ripard2018-01-271-7/+0
| | | | | | | | | | | | | | | | | | | The nvedit command is the only user of env_driver_lookup_default outside of the environment code itself, and it uses it only to print the environment it's about to save to during env save. As we're about to rework the environment to be able to handle multiple environment sources, we might not have an idea of what environment backend is going to be used before trying (and possibly failing for some). Therefore, it makes sense to remove that message and move it to the env_save function itself. As a side effect, we also can get rid of the call to env_driver_lookup_default that is also about to get refactored. Reviewed-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
* env: Remove CONFIG_ENV_AES supportTom Rini2017-11-211-11/+1
| | | | | | | This support has been deprecated since v2017.09 due to security issues. We now remove this support. Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Drop CONFIG_ENV_IS_IN_DATAFLASHTuomas Tynkkynen2017-10-161-1/+0
| | | | | | | | Last user of this option went away in commit: fdc7718999 ("board: usb_a9263: Update to support DT and DM") Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
* env: Adjust the load() method to return an errorSimon Glass2017-08-161-1/+3
| | | | | | | | | | | The load() methods have inconsistent behaviour on error. Some of them load an empty default environment. Some load an environment containing an error message. Others do nothing. As a step in the right direction, have the method return an error code. Then the caller could handle this itself in a consistent way. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Adjust the get_char() method to return an intSimon Glass2017-08-161-2/+2
| | | | | | | | In principle this can fail, e.g. if the index is out of range. Adjust the driver signature to allow returning an error code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Rename some other getenv()-related functionsSimon Glass2017-08-161-1/+1
| | | | | | | | | | | | | | We are now using an env_ prefix for environment functions. Rename these other functions as well, for consistency: getenv_vlan() getenv_bootm_size() getenv_bootm_low() getenv_bootm_mapsize() env_get_default() Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Drop saveenv() in favour of env_save()Simon Glass2017-08-151-0/+7
| | | | | | | | | Use the env_save() function directly now that there is only one implementation of saveenv(). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Denk <wd@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Drop env_relocate_spec() in favour of env_load()Simon Glass2017-08-151-2/+7
| | | | | | | | | This is a strange name for a function that loads the environment. There is now only one implementation of this function, so use the new env_load() function directly instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Drop env_get_char_spec()Simon Glass2017-08-151-4/+10
| | | | | | | | We only have a single implementation of this function now and it is called env_get_char(). Drop the old function and the weak version. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Drop the env_name_spec globalSimon Glass2017-08-151-4/+15
| | | | | | | | Add a name to the driver and use that instead of the global variable declared by each driver. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Drop common init() functionsSimon Glass2017-08-151-1/+2
| | | | | | | | | Most of the init() implementations just use the default environment. Adjust env_init_new() to do this automatically, and drop the redundant code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Create a location driver for each locationSimon Glass2017-08-151-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set up a location driver for each supported environment location. At present this just points to the global functions and is not used. A later patch will switch this over to use private functions in each driver. There are several special cases here in various drivers to handle peculiarities of certain boards: 1. Some boards define CONFIG_ENV_IS_IN_FAT and CONFIG_SPL_ENV_SUPPORT but do not actually load the environment in SPL. The env load code was optimised out before but with the driver, it is not. Therefore a special case is added to env/fat.c. The correct fix (depending on board testing might be to disable CONFIG_SPL_ENV_SUPPORT. 2. A similar situations happens with CONFIG_ENV_IS_IN_FLASH. Some boards do not actually load the environment in SPL, so to reduce code size we need to drop that code. A similar fix may be possible with these boards, or it may be possible to adjust the environment CONFIG settings. Added to the above is that the CONFIG_SPL_ENV_SUPPORT option does not apply when the environment is in flash. Obviously the above has been discovered through painful and time-consuming trial and error. Hopefully board maintainers can take a look and figure out what is actually needed. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Add an enum for environment stateSimon Glass2017-08-151-0/+7
| | | | | | | | At present we have three states for the environment, numbered 0, 1 and 2. Add an enum to record this to avoid open-coded values. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: common: Make env_get_addr/get_char_memory() staticSimon Glass2017-08-151-4/+0
| | | | | | | | These functions are not used outside this file. Make them static and order them to avoid forward declarations. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Add generic redundant environment implementationFiach Antaw2017-07-221-0/+5
| | | | | | | | | | | All current environments that implement redundancy use almost identical implementations. This patch implements the env_nand implementation as a function in env_common, and updates the env_export function to export an env_nand-style 'flags' field by default. Signed-off-by: Fiach Antaw <fiach.antaw@uqconnect.edu.au> Reviewed-by: Tom Rini <trini@konsulko.com>
* common: Move environment choice to KconfigMaxime Ripard2017-04-071-0/+2
| | | | | | | | | | | | | | | The environment location is something that might change per board (depending on what storage options are availaible there) or depending on the user choice (when we have several options). Instead of hardcoding it in our configuration header, create a Kconfig choice with the options we use for now, and the symbols that depend on it. Once done, also remove the irrelevant sunxi defines. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
* Various, accumulated typos collected from around the tree.Robert P. J. Day2016-10-061-3/+2
| | | | | | | | | | | | | | | | | | | | | Fix various misspellings of: * deprecated * partition * preceding,preceded * preparation * its versus it's * export * existing * scenario * redundant * remaining * value * architecture Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Reviewed-by: Jagan Teki <jteki@openedev.com> Reviewed-by: Stefan Roese <sr@denx.de>
* env_mmc: support env partition setup in runtimeDmitry Lifshitz2014-08-011-0/+3
| | | | | | | | | | | | Add callback with __weak annotation to allow setup of environment partition number in runtime from a board file. Propagate mmc_switch_part() return value into init_mmc_for_env() instead of -1 in case of failure. Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
* env_mmc: add mmc_get_env_addr() prototypeDmitry Lifshitz2014-08-011-0/+6
| | | | | | | Add missing mmc_get_env_addr() prototype in environment.h Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
* env: Implement support for encrypting environmentMarek Vasut2014-03-211-1/+11
| | | | | | | | | Add function which allows encrypting the whole environment block with AES-128-CBC. The key for the environment is retrieved by env_aes_cbc_get_key() function, which must be implemented on a per-board basis. Signed-off-by: Marek Vasut <marex@denx.de>
* env: Add env_export() wrapperMarek Vasut2014-03-211-0/+3
| | | | | | | | Implement env_export() wrapper, so that all implementers of saveenv() don't have to call hexport_r(), crc32() etc. sequence . This trims down a bit of code duplication. Signed-off-by: Marek Vasut <marex@denx.de>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>