10 Feb, 2018

2 commits

  • efi_disk_register should return as status code (efi_status_t).

    Disks with zero blocks should be reported as 'not ready' without throwing
    an error.

    This patch solves a problem running OpenBSD on system configured with
    CONFIG_BLK=n (e.g. i.MX6).

    Reported-by: Jonathan Gray
    Signed-off-by: Heinrich Schuchardt
    Tested-by: Jonathan Gray
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • Change the return type of efi_driver_init() to efi_status_t.

    efi_driver_init() calls efi_add_driver() which returns an efi_status_t
    value. efi_driver_init() should not subject this value to a conversion to
    int losing high bits on 64bit systems.

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

    Heinrich Schuchardt
     

23 Jan, 2018

11 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
     
  • In ExitBootServices we need to signal events irrespective of the current
    TPL level. A new parameter check_tpl is added to efi_signal_event().

    Function efi_console_timer_notify() gets some comments.

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

    Heinrich Schuchardt
     
  • On a block device and its partitions the same protocols can be
    installed. To tell the apart we can use the type of the last
    node of the device path which is not the end node.

    The patch provides a utility function to find this last node.

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

    Heinrich Schuchardt
     
  • Up to now we have been using efi_disk_create_partitions() to create
    partitions for block devices that existed before starting an EFI
    application.

    We need to call it for block devices created by EFI
    applications at run time. The EFI application will define the
    handle for the block device and install a device path protocol
    on it. We have to use this device path as stem for the partition
    device paths.

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

    Heinrich Schuchardt
     
  • Provide new function efi_dp_part_node() to create a device
    node for a partition.

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

    Heinrich Schuchardt
     
  • The GUID of the EFI_BLOCK_IO_PROTOCOL is needed in different code
    parts. To avoid duplication make efi_block_io_guid a global symbol.

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

    Heinrich Schuchardt
     
  • For the construction of device paths we need to call the
    AllocatePool service. We should not ignore if it fails due to an
    out of memory situation.

    This patch changes the device path functions to return NULL if
    the memory allocation fails.

    Additional patches will be needed to fix the callers.

    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
     
  • Implement the ConnectController boot service.

    A unit test is supplied in a subsequent patch.

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

    Heinrich Schuchardt
     
  • When a device path protocol is installed write the device
    path to the console in debug mode.

    For printing the new macro EFI_PRINT is used, which can be reused
    for future diagnostic output.

    Remove unused EFI_PRINT_GUID macro

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

    Heinrich Schuchardt
     
  • Add a list of open protocol infos to each protocol of a handle.

    Provide helper functions to access the list items.

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

    Heinrich Schuchardt
     

17 Dec, 2017

2 commits


01 Dec, 2017

12 commits


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
     

09 Oct, 2017

1 commit

  • Queued and signaled describe boolean states of events.
    So let's use type bool and rename the structure members to is_queued
    and is_signaled.

    Update the comments for is_queued and is_signaled.

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

    Heinrich Schuchardt
     

05 Oct, 2017

1 commit


20 Sep, 2017

6 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
     
  • fallback.efi (and probably other things) use UEFI's simple-file-system
    protocol and file support to search for OS's to boot.

    Signed-off-by: Rob Clark
    [agraf: whitespace fixes, unsigned fixes]
    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
     
  • It needs to handle more device-path node types, and also multiple levels
    of path hierarchy. To simplify this, initially construct utf8 string to
    a temporary buffer, and then allocate the real utf16 buffer that is
    returned. This should be mostly for debugging or at least not critical-
    path so an extra copy won't hurt, and is saner than the alternative.

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

    Rob Clark
     
  • Helpers to construct device-paths from devices, partitions, files, and
    for parsing and manipulating device-paths.

    For non-legacy devices, this will use u-boot's device-model to construct
    device-paths which include bus hierarchy to construct device-paths. For
    legacy devices we still fake it, but slightly more convincingly.

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

    Rob Clark
     

19 Sep, 2017

4 commits

  • For the correct implementation of the task priority level (TPL)
    calling the notification function must be queued.

    Add a status field 'queued' to events.

    In function efi_signal_event set status queued if a notification
    function exists and reset it after we have called the function.
    A later patch will add a check of the TPL here.

    In efi_create_event and efi_close_event unset the queued status.

    In function efi_wait_for_event and efi_check_event
    queue the notification function.

    In efi_timer_check call the efi_notify_event
    if the status queued is set.
    For all timer events set status signaled.

    In efi_console_timer_notify set the signaled state of the
    WaitForKey event.

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

    Heinrich Schuchardt
     
  • 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
     
  • Macro EFI_CALL was introduced to call an UEFI function.
    Unfortunately it does not support return values.
    Most UEFI functions have a return value.

    So let's rename EFI_CALL to EFI_CALL_VOID and introduce a
    new EFI_CALL macro that supports return values.

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

    Heinrich Schuchardt
     
  • To understand what is happening in OpenProtocol or LocateProtocol
    it is necessary to know the protocol interface GUID.
    Let's write a debug message.

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

    Heinrich Schuchardt