05 Mar, 2018

1 commit

  • Thomas reported U-Boot failed to build host tools if libfdt-devel
    package is installed because tools include libfdt headers from
    /usr/include/ instead of using internal ones.

    This commit moves the header code:
    include/libfdt.h -> include/linux/libfdt.h
    include/libfdt_env.h -> include/linux/libfdt_env.h

    and replaces include directives:
    #include -> #include
    #include -> #include

    Reported-by: Thomas Petazzoni
    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

28 Feb, 2018

1 commit


10 Feb, 2018

1 commit


29 Jan, 2018

2 commits

  • If 'bootefi hello' or 'bootefi selftest' can be executed depends on the
    configuration.

    If an invalid non-numeric 1st argument is passed to bootefi, e.g.
    'bootefi hola', this string is converted to 0 and U-Boot jumps to
    this typically invalid address.

    With the patch the online help is shown instead.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • EFI calls are usually defined as asmlinkage. That means we pass all parameters
    to functions via the stack x86_32.

    On x86_64 however, we need to also stick to the MS ABI calling conventions,
    which the EFIAPI define conveniently handles for us. Most EFI functions were
    also marked with EFIAPI, except for the entry call.

    So this patch adjusts all entry calls to use EFIAPI instead of the manual
    asmlinkage attribute.

    While at it, we also change the prototype of the entry point to return
    efi_status_t instead of ulong, as this is the correct prototype definition.

    Signed-off-by: Alexander Graf

    ---

    v1 -> v2:

    - Use efi_status_t in all occurences

    Alexander Graf
     

23 Jan, 2018

3 commits

  • This patch provides
    * a uclass for EFI drivers
    * a EFI driver for block devices

    For each EFI driver the uclass
    * creates a handle
    * adds the driver binding protocol

    The uclass provides the bind, start, and stop entry points for the driver
    binding protocol.

    In bind() and stop() it checks if the controller implements the protocol
    supported by the EFI driver. In the start() function it calls the bind()
    function of the EFI driver. In the stop() function it destroys the child
    controllers.

    The EFI block driver binds to controllers implementing the block io
    protocol.

    When the bind function of the EFI block driver is called it creates a
    new U-Boot block device. It installs child handles for all partitions and
    installs the simple file protocol on these.

    The read and write functions of the EFI block driver delegate calls to the
    controller that it is bound to.

    A usage example is as following:

    U-Boot loads the iPXE snp.efi executable. iPXE connects an iSCSI drive and
    exposes a handle with the block IO protocol. It calls ConnectController.

    Now the EFI block driver installs the partitions with the simple file
    protocol.

    iPXE uses the simple file protocol to load Grub or the Linux Kernel.

    Signed-off-by: Heinrich Schuchardt
    [agraf: add comment on calloc len]
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • The device tree is needed at runtime. So we have to store it in
    EFI_RUNTIME_SERVICES_DATA memory.

    The UEFI spec recommends to store all configuration tables in
    EFI_RUNTIME_SERVICES_DATA memory.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • We should consistently use the efi_handle_t typedef when
    referring to handles.

    Signed-off-by: Heinrich Schuchardt
    Reviewed-by: Simon Glass
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

01 Dec, 2017

8 commits

  • The handle of a loaded image is the value of the handle
    member of the loaded image info object and not the
    address of the loaded image info.

    Reviewed-by: Simon Glass
    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • When trying to load an image from a non-existent USB key, U-Boot v2017.11
    crashes on my x86 platform:

    => load usb 0:1 03000000 abc
    General Protection
    EIP: 0010:[] EFLAGS: 00010286
    Original EIP :[]
    ...

    This used to work in v2017.09. Testing has shown, that this bug was
    introduced with patch 95c5553e [efi_loader: refactor boot device and
    loaded_image handling].

    This patch now checks if a valid "desc" is returned from blk_get_dev()
    and only continues when "desc" is available. Resulting in this cmd
    output (again):

    => load usb 0:1 03000000 abc
    ** Bad device usb 0 **

    Signed-off-by: Stefan Roese
    Reviewed-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Stefan Roese
     
  • Use environment variable bootargs used as load options
    for bootefi payloads.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • After executing bootefi selftest
    * restore GD
    * unlink the load image handle
    * return 0 or 1 and not a truncated efi_status_t.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • Environment variable efi_selftest is passed as load options
    to the selftest application. It is used to select a single
    test to be executed.

    The load options are an UTF8 string. Yet I decided to keep
    the name propertiy of the tests as char[] to reduce code
    size.

    Special value 'list' displays a list of all available tests.

    Tests get an on_request property. If this property is set
    the tests are only executed if explicitly requested.

    The invocation of efi_selftest is changed to reflect that
    bootefi selftest with efi_selftest = 'list' will call the
    Exit bootservice.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • Currently we pass bootefi_device_path and bootefi_image_path as
    device and image path without initializing them. They may carry
    values from previous calls to bootefi.

    With the patch the variables are initialized valid dummy values.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • Where ulong or unsigned long are used to hold an EFI status
    code we should consistenly use efi_status_t.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • The watchdog is initialized with a 5 minute timeout period.
    It can be reset by SetWatchdogTimer.
    It is stopped by ExitBoottimeServices.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

12 Oct, 2017

1 commit

  • When we don't have a real device/image path, such as 'bootefi hello',
    construct a mem-mapped device-path.

    This fixes 'bootefi hello' after devicepath refactoring.

    Fixes: 95c5553ea2 ("efi_loader: refactor boot device and loaded_image handling")
    Signed-off-by: Rob Clark
    Acked-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Rob Clark
     

21 Sep, 2017

2 commits

  • efi_exit() already restores gd, so we shouldn't EFI_EXIT() on the
    otherside of the longjmp().

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     
  • ad503ffe9c6 efi_loader: refactor boot device and loaded_image handling
    leads to an error when building with CONFIG_CMD_BOOTEFI_SELFTEST=y
    This patch fixes the problem.

    Fixes: ad503ffe9c6 efi_loader: refactor boot device and loaded_image handling
    Signed-off-by: Heinrich Schuchardt
    Reviewed-by: Rob Clark
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

20 Sep, 2017

3 commits

  • Similar to a "real" UEFI implementation, the bootmgr looks at the
    BootOrder and BootXXXX variables to try to find an EFI payload to load
    and boot. This is added as a sub-command of bootefi.

    The idea is that the distro bootcmd would first try loading a payload
    via the bootmgr, and then if that fails (ie. first boot or corrupted
    EFI variables) it would fallback to loading bootaa64.efi. (Which
    would then load fallback.efi which would look for \EFI\*\boot.csv and
    populate BootOrder and BootXXXX based on what it found.)

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     
  • Add EFI variable support, mapping to u-boot environment variables.
    Variables are pretty important for setting up boot order, among other
    things. If the board supports saveenv, then it will be called in
    ExitBootServices() to persist variables set by the efi payload. (For
    example, fallback.efi configuring BootOrder and BootXXXX load-option
    variables.)

    Variables are *not* currently exposed at runtime, post ExitBootServices.
    On boards without a dedicated device for storage, which the loaded OS
    is not trying to also use, this is rather tricky. One idea, at least
    for boards that can persist RAM across reboot, is to keep a "journal"
    of modified variables in RAM, and then turn halt into a reboot into
    u-boot, plus store variables, plus halt. Whatever the solution, it
    likely involves some per-board support.

    Mapping between EFI variables and u-boot variables:

    efi_$guid_$varname = {attributes}(type)value

    For example:

    efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_OsIndicationsSupported=
    "{ro,boot,run}(blob)0000000000000000"
    efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_BootOrder=
    "(blob)00010000"

    The attributes are a comma separated list of these possible
    attributes:

    + ro - read-only
    + boot - boot-services access
    + run - runtime access

    NOTE: with current implementation, no variables are available after
    ExitBootServices, and all are persisted (if possible).

    If not specified, the attributes default to "{boot}".

    The required type is one of:

    + utf8 - raw utf8 string
    + blob - arbitrary length hex string

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     
  • Get rid of the hacky fake boot-device and duplicate device-path
    constructing (which needs to match what efi_disk and efi_net do).
    Instead convert over to use efi_device_path helpers to construct
    device-paths, and use that to look up the actual boot device.

    Also, extract out a helper to plug things in properly to the
    loaded_image. In a following patch we'll want to re-use this in
    efi_load_image() to handle the case of loading an image from a
    file_path.

    Signed-off-by: Rob Clark
    Signed-off-by: Alexander Graf

    Rob Clark
     

19 Sep, 2017

3 commits

  • A testing framework for the EFI API is provided.
    It can be executed with the 'bootefi selftest' command.

    It is coded in a way that at a later stage we may turn it
    into a standalone EFI application. The current build system
    does not allow this yet.

    All tests use a driver model and are run in three phases:
    setup, execute, teardown.

    A test may be setup and executed at boottime,
    it may be setup at boottime and executed at runtime,
    or it may be setup and executed at runtime.

    After executing all tests the system is reset.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • In scripts/Makefile.lib we build section including helloworld.efi.
    This allows to load the EFI binary with command 'bootefi hello'.

    scripts/Makefile.lib contains explicit references to strings
    containing helloworld and hello_world. This makes it impossible
    to generalize the coding to accomodate additional built in
    EFI binaries.

    Let us rename the variables __efi_hello_world_* to
    __efi_helloworld_*.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • Command 'bootefi hello' currently uses CONFIG_SYS_LOAD_ADDR
    as loading address.

    qemu machines have by default 128 MiB RAM.
    CONFIG_SYS_LOAD_ADDR for x86 is 0x20000000 (512 MiB).
    This causes 'bootefi hello' to fail.

    We should use the environment variable loadaddr if available.
    It defaults to 0x1000000 (16 MiB) on qemu_x86.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

12 Aug, 2017

1 commit


26 Jul, 2017

1 commit

  • Before commit 7cbc12415d ("efi_loader: initalize EFI object list
    only once") we recreated the world on every bootefi invocation.

    That included the object tree as well as the configuration tables.

    Now however we don't recreate them, which means we must not explicitly
    override the configuration tables, as otherwise we may lose our SMBIOS
    table from the configuration table list on second bootefi invocation.

    This patch makes bootefi call our normal configuration table modification
    APIs to add/remove the FDT instead of recreating all tables from scratch.
    That way the SMBIOS table gets preserved across multiple invocations.

    Signed-off-by: Alexander Graf

    Alexander Graf
     

24 Jul, 2017

3 commits


19 Jul, 2017

6 commits

  • Set up a timer event and the WaitForKey event.
    In the notify function of the timer event check for console input
    and signal the WaitForKey event accordingly.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    xypron.glpk@gmx.de
     
  • Currenty any EFI status other than EFI_SUCCESS is reported as
    Application terminated, r = -22

    With the patch the status code returned by the EFI application
    is printed.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    xypron.glpk@gmx.de
     
  • The Unified Extensible Firmware Interface Specification, version 2.7,
    defines in chapter 2.1.2 - UEFI Application that an EFI application may
    either directly return or call EFI_BOOT_SERVICES.Exit().

    Unfortunately U-Boot makes the incorrect assumption that
    EFI_BOOT_SERVICES.Exit() is always called.

    So the following application leads to a memory exception on the aarch64
    architecture when returning:

    EFI_STATUS efi_main(
    EFI_HANDLE handle,
    EFI_SYSTEM_TABlE systable) {
    return EFI_SUCCESS;
    }

    With this patch the entry point is stored in the image handle.

    The new wrapper function do_enter is used to call the EFI entry point.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    xypron.glpk@gmx.de
     
  • ConvertPathToText is implemented for
    * type 4 - media device path
    * subtype 4 - file path

    This is the kind of device path we hand out for block devices.

    All other cases may be implemented later.

    Signed-off-by: Heinrich Schuchardt
    [agraf: fix whitespace]
    Signed-off-by: Alexander Graf

    xypron.glpk@gmx.de
     
  • The UEFI specification requires that LocateProtol finds the first
    handle supporting the protocol and to return a pointer to its
    interface.

    So we have to assign the protocols to an efi_object and not use
    any separate storage.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    xypron.glpk@gmx.de
     
  • efi_open_protocol was implemented to call a protocol specific open
    function to retrieve the protocol interface.

    The UEFI specification does not know of such a function.

    It is not possible to implement InstallProtocolInterface with the
    current design.

    With the patch the protocol interface itself is stored in the list
    of installed protocols of an efi_object instead of an open function.

    Signed-off-by: Heinrich Schuchardt
    [agraf: fix efi gop support]
    Signed-off-by: Alexander Graf

    xypron.glpk@gmx.de
     

03 Jul, 2017

1 commit


01 Jun, 2017

1 commit


28 Jan, 2017

1 commit


19 Jan, 2017

1 commit

  • For 64-bit kernel, there is a warning about x1-x3 nonzero in violation
    of boot protocol. To fix this issue, input argument 4 is added for
    armv8_switch_to_el2 and armv8_switch_to_el1. The input argument 4 will
    be set to the right value, such as zero.

    Signed-off-by: Alison Wang
    Reviewed-by: Alexander Graf
    Tested-by: Ryan Harkin
    Tested-by: Michal Simek
    Reviewed-by: York Sun

    Alison Wang