09 Dec, 2019

1 commit

  • Part of the env cleanup moved this out of the environment code and into
    the net code. However, this helper is sometimes needed even when the net
    stack isn't included.

    Move the helper to lib/net_utils.c like it's similarly-purposed
    string_to_ip(). Also rename the moved function to similar naming.

    Signed-off-by: Joe Hershberger
    Reported-by: Ondrej Jirman

    Joe Hershberger
     

07 Dec, 2019

1 commit


03 Dec, 2019

1 commit


31 Oct, 2019

1 commit

  • With this patch, when setting UEFI variable with "env set -e" command,
    we will be able to
    - specify vendor guid with "-guid guid",
    - specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
    respectively with "-bs" and "-rt",
    - append a value instead of overwriting with "-a",
    - use memory as variable's value instead of explicit values given
    at the command line with "-i address,size"

    If guid is not explicitly given, default value will be used.

    Meanwhile, "env print -e," will be modified so that it will NOT dump
    a variable's value if '-n' is specified.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Heinrich Schuchardt

    AKASHI Takahiro
     

12 Aug, 2019

9 commits

  • 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
    Acked-by: Joe Hershberger
    Reviewed-by: Simon Goldschmidt
    [trini: Fixup apalis-tk1.c]
    Signed-off-by: Tom Rini

    Simon Glass
     
  • Avoid using a typedef here which is unnecessary. Add an 'env_' prefix to
    both the enum and its members to make it clear that these are related to
    the environment.

    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

    Simon Glass
     
  • 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

    Simon Glass
     
  • U-Boot is not supposed to use typedef for structs anymore. Also this name
    is the same as the ENTRY() macro used in assembler files, and 'entry'
    itself is widely used in U-Boot (>8k matches).

    Drop the typedef and rename the struct to env_entry to reduce confusion.

    Signed-off-by: Simon Glass
    Acked-by: Joe Hershberger

    Simon Glass
     
  • 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
    Signed-off-by: Simon Glass

    Simon Glass
     
  • Move this function to the new header file and rename it so it has an env_
    prefix.

    Acked-by: Joe Hershberger
    Signed-off-by: Simon Glass

    Simon Glass
     
  • This function fits better with the network subsystem, so move it.

    Signed-off-by: Simon Glass
    Suggested-by: Joe Hershberger

    Simon Glass
     
  • Move envmatch() over to the new header file. Also rename it to env_match()
    to better line up with other functions.

    Signed-off-by: Simon Glass
    Acked-by: Joe Hershberger

    Simon Glass
     
  • Move this function over to the new header file. Also rename it to have an
    env_ prefix like the other functions.

    Signed-off-by: Simon Glass
    Acked-by: Joe Hershberger

    Simon Glass
     

18 Jul, 2019

1 commit

  • 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

    squashed fixes
    - start message with "Erasing"
    - mark erase-function as optional
    - env: separate eraseenv from saveenv

    Suggested-by: Simon Goldschmidt
    Reviewed-by: Simon Goldschmidt

    Frank Wunderlich
     

13 Jul, 2019

1 commit

  • Add sub-command 'env info' to display environment information:
    - env_valid : is environment valid
    - env_ready : is environment imported into hash table
    - env_use_default : is default environment using

    This command can be optionally used for evaluation in scripts:
    [-d] : evaluate whether default environment is used
    [-p] : evaluate whether environment can be persisted
    The result of multiple evaluations will be combined with AND.

    Signed-off-by: Leo Ruan
    Signed-off-by: Mark Jonas
    Reviewed-by: Simon Glass
    [trini: Do not enable by default]
    Signed-off-by: Tom Rini

    Leo Ruan
     

12 Jun, 2019

1 commit


06 Jun, 2019

1 commit


05 Jun, 2019

1 commit


25 Feb, 2019

1 commit


16 Jan, 2019

1 commit


01 Oct, 2018

1 commit


21 Jul, 2018

2 commits

  • While the `env export` can take as parameters variables to be exported,
    `env import` does not have such a mechanism of variable selection.

    Let's add the ability to add parameters at the end of the command for
    variables to be imported.

    Every env variable from the env to be imported passed by parameter to
    this command will override the value of the variable in the current env.

    If a variable exists in the current env but not in the imported env, if
    this variable is passed as a parameter to env import, the variable will
    be unset ONLY if the -d option is passed to env import, otherwise the
    current value of the variable is kept.

    If a variable exists in the imported env, the variable in the current
    env will be set to the value of the one from the imported env.

    All the remaining variables are left untouched.

    As the size parameter of env import is positional but optional, let's
    add the possibility to use the sentinel '-' for when we don't want to
    give the size parameter (when the env is '\0' terminated) but we pass a
    list of variables at the end of the command.

    env import addr
    env import addr -
    env import addr size
    env import addr - foo1 foo2
    env import addr size foo1 foo2

    are all valid.

    env import -c addr
    env import -c addr -
    env import -c addr - foo1 foo2

    are all invalid because they don't pass the size parameter required for
    checking, while the following are valid.

    env import addr size
    env import addr size foo1 foo2

    Nothing's changed for the other parameters or the overall behaviour.

    One of its use case could be to load a secure environment from the
    signed U-Boot binary and load only a handful of variables from an
    other, unsecure, environment without completely losing control of
    U-Boot.

    Signed-off-by: Quentin Schulz
    Tested-by: Alex Kiernan
    Tested-by: Stephen Warren

    Quentin Schulz
     
  • The error message should start with `## Error: ` so that it's easily
    detectable by tests without needing to have a complex regexp for
    matching all possible error message patterns.

    Let's add the `## Error: ` prefix to the error messages since it's the
    one already in use.

    Suggested-by: Stephen Warren
    Signed-off-by: Quentin Schulz
    Reviewed-by: Simon Glass
    Reviewed-by: Stephen Warren
    Tested-by: Stephen Warren

    Quentin Schulz
     

20 Jul, 2018

4 commits

  • 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
    Acked-by: Igor Grinberg

    Yaniv Levinsky
     
  • The function set_default_vars() in common.c adds H_INTERACTIVE to the
    h_import() flag, but the function has no way of telling if the command
    actually was user directed like this flag suggest. The flag should be
    set by the calling function do_env_default() in nvedit.c instead, where
    the command is certainty user directed.

    Move the H_INTERACTIVE flag from set_default_vars() to do_env_default().

    Signed-off-by: Yaniv Levinsky
    Acked-by: Igor Grinberg

    Yaniv Levinsky
     
  • 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
    Acked-by: Igor Grinberg

    Yaniv Levinsky
     
  • The naming convention for flags in nvedit.c is:
    * The hashtable flag (defined in search.h) is named "env_flag"
    * The command flag argument (defined in command.h) is named "flag"

    This convention is kept in functions like do_env_print(), do_env_set()
    and do_env_delete(), but not in do_env_default().

    Rename the hashtable flag in do_env_default() from "flag" to "env_flag".
    Rename the command flag in do_env_default() from "__flag" to "flag".

    No functional change.

    Signed-off-by: Yaniv Levinsky
    Reviewed-by: Igor Grinberg

    Yaniv Levinsky
     

13 Jun, 2018

1 commit


07 May, 2018

1 commit

  • 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

    Tom Rini
     

09 Apr, 2018

1 commit

  • 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
     

01 Feb, 2018

1 commit

  • env_get_f calls env_get_char to load single characters from the
    environment. However, the return value of env_get_char was not
    checked for errors. Now if the env driver does not support the
    .get_char call, env_get_f did not notice this and looped over the
    whole size of the environment, calling env_get_char over 8000
    times with the default settings, just to return an error in the
    end.

    Fix this by checking if env_get_char returns < 0.

    Signed-off-by: Simon Goldschmidt
    Acked-by: Maxime Ripard

    Simon Goldschmidt
     

27 Jan, 2018

1 commit

  • 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
    Reviewed-by: Lukasz Majewski
    Reviewed-by: Simon Glass
    Signed-off-by: Maxime Ripard

    Maxime Ripard
     

16 Oct, 2017

1 commit


07 Oct, 2017

1 commit

  • The recent changes to these files did not completely fix the previous
    issues, or introduced different (minor) issues. In cmd/gpt.c we need to
    dereference str_disk_guid to be sure that malloc worked. In
    cmd/nvedit.c we need to be careful that we can also fit in that leading
    space when adding to the string. And in tools/fit_image.c we need to
    re-work the error handling slightly in fit_import_data() so that we only
    call munmap() once. We have two error paths here, one where we have an
    fd to close and one where we do not. Adjust labels to match this.

    Reported-by: Coverity (CID: 167366, 167367, 167370)
    Signed-off-by: Tom Rini

    Tom Rini
     

06 Oct, 2017

1 commit

  • When we have multiple messages provided, we need to be sure that we do
    not exceed the length of our 'message' buffer. In the for loop, make
    sure that pos is not larger than message. Only copy in at most however
    much of the message buffer remains. Finally, if we have not reached the
    end of the message buffer, put in a space and NULL, and if we have,
    ensure the buffer is now NULL termined.

    Reported-by: Coverity (CID: 165116)
    Signed-off-by: Tom Rini

    Tom Rini
     

04 Oct, 2017

1 commit

  • U-Boot widely uses error() as a bit noisier variant of printf().

    This macro causes name conflict with the following line in
    include/linux/compiler-gcc.h:

    # define __compiletime_error(message) __attribute__((error(message)))

    This prevents us from using __compiletime_error(), and makes it
    difficult to fully sync BUILD_BUG macros with Linux. (Notice
    Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)

    Let's convert error() into now treewide-available pr_err().

    Done with the help of Coccinelle, excluing tools/ directory.

    The semantic patch I used is as follows:

    //
    @@@@
    -error
    +pr_err
    (...)
    //

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Simon Glass
    [trini: Re-run Coccinelle]
    Signed-off-by: Tom Rini

    Masahiro Yamada
     

16 Aug, 2017

4 commits