lmb_alloc_base() is just calling lmb_alloc_base_flags() with LMB_NONE.
There's not much we gain from this abstraction, so let's remove the
former add the flags argument to lmb_alloc_base() and make the code
a bit easier to follow.
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 3075708017)
lmb_alloc_addr() is just calling lmb_alloc_addr_flags() with LMB_NONE
There's not much we gain from this abstraction, so let's remove the
latter, add a flags argument to lmb_alloc_addr() and make the code a
bit easier to follow.
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 15e0c5e390)
Even if CONFIG_ULIB is enabled it may not actually be in use. If not,
we still need the EFI-runtime relocation to happen. Adjust the condition
in efi_runtime_relocate() to fix this.
For static linking with ulib examples, provide weak symbol definitions
for __efi_runtime_rel_start and __efi_runtime_rel_stop. These symbols
are normally defined in linker scripts but need fallback definitions
when linking statically against libu-boot.a.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This cannot work with the shared library at present, since the symbols
are not defined. Disable it for now.
Signed-off-by: Simon Glass <sjg@chromium.org>
The EFI loader has some code to check the size (rows and columns) of an
attached terminal. Move this over to the serial uclass so that it can be
used elsewhere.
Create a new CONFIG_SERIAL_TERM_PRESENT to control whether it should be
used. Enable that for the EFI loader to preserve existing behaviour.
Adjust the implementation so that it returns a useful error code on
failure. Put the ESC and cESC values in the serial.h header.
Series-changes: 3
- Update comment for serial_query_size()
Signed-off-by: Simon Glass <sjg@chromium.org>
Rather than accessing the EFI loader's structure, create an
efi_get_boot() function to match that used by the app, so that the
call to protocols_per_handle() can operate in the app as well.
Signed-off-by: Simon Glass <sjg@chromium.org>
This file contains some useful utility functions which are not specific
to the EFI loader. Move them to lib/efi so they can be used by the app.
Signed-off-by: Simon Glass <sjg@chromium.org>
This printf() extension is useful for the app. Add an implementation of
efi_dp_str() so that it works as expected.
Signed-off-by: Simon Glass <sjg@chromium.org>
The global-variable GUID is already set in the common device_path.c file
but its declaration is only in the efi_loader header.
Move it and also move over the FDT GUIDs.
Signed-off-by: Simon Glass <sjg@chromium.org>
These functions are useful for the app as well as the loader.
For now, efi_set_load_options() calls efi_search_protocol() which is
still in the loader, but we can provide an 'app' version when needed. It
doesn't seem worth keeping that one function in a separate file.
Signed-off-by: Simon Glass <sjg@chromium.org>
Checking if a variable is a load option is useful for the app, so move
efi_varname_is_load_option() and u16_tohex() into a new helper.c file.
Signed-off-by: Simon Glass <sjg@chromium.org>
It is useful to be able to see the available tables in the app, so
enable this subcommand. Provide an implementation of efi_get_sys_table()
that works for the EFI loader.
Signed-off-by: Simon Glass <sjg@chromium.org>
Use the smbios_info struct in this function, so it can deal with any
version of SMBIOS table.
Also update smbios_update_version_full() to work the same way.
Drop find_next_header() which is now unused.
Signed-off-by: Simon Glass <sjg@chromium.org>
The EFI app will eventually execute binaries, but it does not enable
the CONFIG_EFI_LOADER option. So move the option to a common directory.
Signed-off-by: Simon Glass <sjg@chromium.org>
efi_binary_run_dp() calls efi_init_obj_list() which is specific to the
EFI loader. Move this into a new file within lib/efi_loader
Similarly, move efi_run_image() since the app will need a different
implementation.
Signed-off-by: Simon Glass <sjg@chromium.org>
Move this function and some dependencies into the lib/efi directory so
that it can be used by the app, which does not enable CONFIG_EFI_LOADER
Since the networking has an #ifdef add CONFIG_EFI_LOADER to it, since
the definitions are in efi_loader.h for now.
Signed-off-by: Simon Glass <sjg@chromium.org>
Most of these utility functions are useful for the app, so move them
into the common directory.
Move the GUIDs used by this file from their various other location, so
they are available to the app, even if it doesn't enabled EFI_LOADER
Fix the rather large number of checkpath warnings in this file, except
for the lwip one, best left to the maintainer to sort out.
One noteable change is adding a return value to dp_fill() for the case
where an option is not enabled but its uclass is referenced. This
presuambly never happens during execution, since if the uclass is not
supported there can be no device in that uclass and therefore nothing
will ever request its path. So just handle this like an invalid device.
Signed-off-by: Simon Glass <sjg@chromium.org>
This function calculates the parent size in many places and does the
same addition in most cases. Create a variable for the parent_size and
another for the size, so we can do the addition once at the end.
The uclass array is too sparse to consider an array.
Signed-off-by: Simon Glass <sjg@chromium.org>
Move disabling of interrupts to bootm_final() so it is done for bootm
and EFI boot paths. Drop the now-duplicate calls.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add this call to the bootm_final() function, dropping it from RISC-V
Add a flag to ensure that cleanup_before_linux() is not called when
booting an EFI app.
Signed-off-by: Simon Glass <sjg@chromium.org>
This work-around dates from 2019 and grub 2.04 which is quite old. New
builds of grub don't have the problem and old boards presumably use an
older U-Boot, so don't need this.
Drop it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Make use of this function, adding some pieces needed by RISC-V
Drop the udc_disconnect() from EFI_LOADER since it is now done in
bootm_final()
Signed-off-by: Simon Glass <sjg@chromium.org>
There is no guarantee that the RNG device has a sequence number of zero.
Use the first available device instead, by default.
This resolved a failure to find the device with qemu-x86_64 when the
virtio device is used.
Signed-off-by: Simon Glass <sjg@chromium.org>
Define MACH_QEMU whenever ARCH_QEMU_ARM is used.
Some of the uses of ARCH_QEMU_ARM with efi_loader should clearly apply
to all QEMU variables, so update these.
Signed-off-by: Simon Glass <sjg@chromium.org>
This existing function does not have any context associated with it.
Rename it so that fs_read() can be used for the new FS uclass.
Signed-off-by: Simon Glass <sjg@chromium.org>
The EFI boot manager relies on having an IP address before trying to
boot an EFI HTTP(s) boot entry. However, defining it as a boot or
pre-boot command is not always the right answer since it will
unconditionally add delay to the board boot, even if we don't boot
over the network.
So let's do a DHCP request from the boot manager, if 'ipaddr' is
empty and fail early if we don't have an address.
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
Create a Kconfig which indicates that EFI functionality is in use,
either as a client (EFI app / stub) or provider (EFI loader). This will
make it easier to share code between these two parts of U-Boot
Signed-off-by: Simon Glass <sjg@chromium.org>
This directory was created when U-Boot gained the ability to run as an
EFI app in 2015. Since then the EFI-loader feature has been added.
The code in lib/efi is not actually used by the loader, so the name is
confusing.
Rename the directory to efi_client to indicate that it includes files
just for U-Boot being a client of EFI, i.e. the EFI app and stub.
Signed-off-by: Simon Glass <sjg@chromium.org>
This exported symbol has a very generic name. Rename it to indicate that
it relates to EFI and device-paths.
Fix checkpatch warnings related to use of multiple assignments.
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
These functions are useful for the EFI app. As a first step towards
making these available outside lib/efi_loader, create a separate header
file and include it where needed. Add proper comments to the functions,
since many are missing at present.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tom reports that generating the ESL file we need for authenticated
capsule updates fails to work on azure which expects a RO git tree.
Move it to $(objtree)
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
When converting an IPv4 device path node to text, the
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL will produce the following string:
IPv4(5.6.7.8,TCP,UDP,0x6,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)
This string erroneously contains multiple protocols: TCP, UDP and 0x6.
Add the missing `break' statements in the dp_msging() function to fix this
and obtain the following expected string instead:
IPv4(5.6.7.8,TCP,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)
Fixes: aaf63429a1 ("efi_loader: add IPv4() to device path to text protocol")
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Adriano Cordova <adrianox@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Do not try to create an initrd device path nor try to register
an initrd with the EFI_LOAD_FILE2_PROTOCOL if none is provided.
Handle initrd installation in efi_binary_run_dp with
efi_install_initrd, imitating what is done for the fdt.
Fixes: 36835a9105 ("efi_loader: binary_run: register an initrd")
Reported-by: Weizhao Ouyang <o451686892@gmail.com>
Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
Tested-by: Weizhao Ouyang <o451686892@gmail.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Imitate in dtbdump what initrddump does for color,
newlines and input handling. The output parsing in
the CI is strict and with the current output the CI
is not recongnizing the prompt '=>'.
Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>