summaryrefslogtreecommitdiff
path: root/lib/efi_loader
AgeCommit message (Collapse)Author
2017-07-31efi_loader: Fix warning in efi_gopAlexander Graf
Commit ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCD") dropped the explicit (void*) cast for fb_base in efi gop support for CONFIG_LCD without DM. This patch adds it back, eliminating the now occuring warning again Fixes: ca9193d2b16 ("efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCD") Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-28efi_loader: indent entry/exit prints to show nesting levelRob Clark
This should make it easier to see when a callback back to UEFI world calls back in to the u-boot world, and generally match up EFI_ENTRY() and EFI_EXIT() calls. Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: remove static from const var] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-28efi_loader: add checking for incorrect use of EFI_ENTRY/EXITRob Clark
Missing an EFI_ENTRY() or doubling up EFI_EXIT() leads to non-obvious crashes. Let's add some error checking. Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: fix bogus assert() and fix app_gd breakage] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-28efi_loader: Add an EFI_CALL() macroRob Clark
Rather than open-coding EFI_EXIT() + callback + EFI_ENTRY(), introduce an EFI_CALL() macro. This makes callbacks into UEFI world (of which there will be more in the future) more concise and easier to locate in the code. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-28efi_loader: add some missing breaksRob Clark
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-26efi_loader: fix bug in efi_get_memory_mapRob Clark
When booting shim -> fallback -> shim -> grub -> linux the memory map is a bit larger than the size linux passes in on the first call. But in the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size to linux so it would loop forever. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-26efi_loader: Improve install_configuration_tableAlexander Graf
The INSTALL_CONFIGURATION_TABLE callback also provides the ability to remove table entries. This patch adds that functionality. Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-26efi_loader: remove more double EFI_EXIT() in efi_disk.cRob Clark
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-26efi_loader: remove double EFI_EXIT() with efi_unsupportedRob Clark
Probably this went unnoticed before, but it causes problems with addition of 804b1d73 ("efi_loader: log EFI return values too") Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-25efi_loader: expose protocols via GUIDRob Clark
shim.efi (or rather gnu-efi's LibLocateProtocol() which shim.efi uses) resolves protocols via efi_locate_handle() so the console protocols need to be added to the efi object list. Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: whitespace fixes] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-25efi_loader: implement ProtocolsPerHandlexypron.glpk@gmx.de
Boot service ProtocolsPerHandle is implemented in efi_protocols_per_handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_loader: parameter types for CreateEvent, SetTimerxypron.glpk@gmx.de
The first argument 'type' of CreateEvent is an 32bit unsigned integer bitmap and not an enum. The second argument 'type' of SetTimer take values of an enum which is called EFI_TIMER_DELAY in the UEFI standard. To avoid confusion rename efi_event_type to efi_timer_delay. Reported-by: Alexander Graf <agraf@suse.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_console: use EFIAPI for callback functionsxypron.glpk@gmx.de
The call to efi_create_event requires notification functions flagged as EFIAPI. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_loader: workaround for grub lsefi bugRob Clark
Patch has also been sent to fix grub to not ignore the error returned and treat protocol_buffer_count as valid. But that that might take a while to trickle into distro's, so this workaround might be useful. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_loader: implement ConvertDeviceNodeToTextxypron.glpk@gmx.de
Move the logic for converting a node to text from efi_convert_device_path_to_text to convert_device_node_to_text. Provide a wrapper function convert_device_node_to_text_ext. As we use only shallow device paths so we can call directly call efi_device_node_to_text from efi_device_path_to_text. Add output for MAC addresses. Add output for not yet supported types/subtypes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_memory: return MapKeyxypron.glpk@gmx.de
efi_get_memory_map should set a defined value for map_key. We later can introduce the test against this value in efi_exit_boot_services as required by the UEFI standard. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_memory: do parameter checks firstxypron.glpk@gmx.de
The parameter checks should be done first. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_loader: gop: fixes for CONFIG_DM_VIDEO without CONFIG_LCDRob Clark
Make EFI GOP support work with DM_VIDEO but without legacy LCD. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-24efi_loader: move guidcmp to headerRob Clark
Want to re-use this for file protocol, which I'm working on. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: correctly implement 100ns conversionxypron.glpk@gmx.de
In efi_set_timer we receive the trigger time in intervals of 100 ns. We should convert it to intervals of 1000 ns by 64bit division. The patch supplies function efi_div10 that uses multiplication to implement the missing 64 bit division. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_console: set up eventsxypron.glpk@gmx.de
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: refactor efi_set_timerxypron.glpk@gmx.de
efi_set_timer is refactored to make the function callable internally. Wrapper function efi_set_timer_ext is provided for EFI applications. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: refactor efi_create_eventxypron.glpk@gmx.de
efi_create_event is refactored to make it possible to call it internally. For EFI applications wrapper function efi_create_event_ext is created. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: correct size for tpl levelxypron.glpk@gmx.de
The UEFI standard defines the type for the tpl level as EFI_TPL alias UINTN. UINTN is an integer is defined as an unsigned integer of native width. So we can use size_t for the definition. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: implement multiple event supportxypron.glpk@gmx.de
Up to now the boot time supported only a single event. This patch now allows four events. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: use struct efi_event * instead of void *xypron.glpk@gmx.de
In our implementation the internal structure of events is known. So use the known type instead of void. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_memory: avoid NULL dereference in efi_free_poolxypron.glpk@gmx.de
If efi_free_pool is called with argument NULL an illegal memory access occurs. So let's check the parameter on entry. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: disk: iterate only over valid block devicesxypron.glpk@gmx.de
The efi_loader currently stops iterating over the available block devices stopping at the first device that fails. This may imply that no block device is found. With the patch efi_loader only iterates over valid devices. It is based on patch 06d592bf52f6 (dm: core: Add uclass_first/next_device_check()) which is currently in u-boot-dm.git. For testing I used an odroid-c2 with a dts including &sd_emmc_a { status = "okay"; }; This device does not exist on the board and cannot be initialized. Without the patch: => bootefi hello ## Starting EFI application at 01000000 ... WARNING: Invalid device tree, expect boot to fail mmc_init: -95, time 1806 Found 0 disks Hello, world! ## Application terminated, r = 0 With the patch: => bootefi hello ## Starting EFI application at 01000000 ... WARNING: Invalid device tree, expect boot to fail mmc_init: -95, time 1806 Scanning disk mmc@70000.blk... Scanning disk mmc@72000.blk... Card did not respond to voltage select! mmc_init: -95, time 9 Scanning disk mmc@74000.blk... Found 3 disks Hello, world! ## Application terminated, r = 0 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: implement EFI_DEVICE_PATH_TO_TEXT_PROTOCOLxypron.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 <xypron.glpk@gmx.de> [agraf: fix whitespace] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: reimplement efi_locate_protocolxypron.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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: implement LocateHandleBufferxypron.glpk@gmx.de
UEFI boot service LocateHandleBuffer is implemented by calling efi_allocate_handle and efi_locate_handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: refactor efi_locate_handlexypron.glpk@gmx.de
To implement LocateHandleBuffer we need to call efi_locate_handle internally without running through EFI_EXIT. So put EFI_ENTRY and EFI_EXIT into a new wrapper function efi_locate_handle_ext. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: implement InstallMultipleProtocolInterfacesxypron.glpk@gmx.de
Implement InstallMultipleProtocolInterfaces in function efi_install_multiple_protocol_interfaces by repeatedly calling efi_install_protocol_interface. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: refactor efi_uninstall_protocol_interfacexypron.glpk@gmx.de
For the implementation of UninstallMultipleProtocolInterfaces we need to call efi_uninstall_protocol_interface. In internal calls we should not pass through EFI_EXIT. The patch introduces a wrapper function efi_uninstall_protocol_interface_ext. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: refactor efi_install_protocol_interfacexypron.glpk@gmx.de
For the implementation of InstallMultipleProtocolInterfaces we need to call efi_install_protocol_interface. In internal calls we should not pass through EFI_EXIT. The patch introduces a wrapper function efi_install_protocol_interface_ext. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: implement UninstallProtocolInterfacexypron.glpk@gmx.de
Without the patch efi_uninstall_protocol_interface always returns an error. With the patch protocols without interface can be uninstalled. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: implement InstallProtocolInterfacexypron.glpk@gmx.de
efi_install_protocol_interface up to now only returned an error code. The patch implements the UEFI specification for InstallProtocolInterface with the exception that it will not create new handles. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: efi_open_protocol: parameter checksxypron.glpk@gmx.de
Add all parameter checks for function efi_open_protocol that do not depend on a locking table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-19efi_loader: refactor efi_open_protocolxypron.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 <xypron.glpk@gmx.de> [agraf: fix efi gop support] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-04efi_loader: abort on unsupported relocation typexypron.glpk@gmx.de
If a relocation type is not supported loading the EFI binary should be aborted. Writing a message only is insufficient. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: use a() != b coding style] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-04efi_loader: efi_handle_protocol set attributesxypron.glpk@gmx.de
UEFI spec 2.7 indicates that HandleProtocol can be implemented by calling OpenProtocol with attributes = EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL. Currently we pass attributes = 0 to efi_open_protocol. 0 is not a valid value when calling OpenProtocol. This does not cause any errors yet because our implementation of OpenProtocol is incomplete. We should pass the correct value to enable a fully compliant implementation of OpenProtocol in the future. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-03efi_loader: add static to local functionsMasahiro Yamada
These are locally used in lib/efi_loader/efi_boottime.c Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-03efi_loader: check CreateEvent() parametersJonathan Gray
Add some of the invalid parameter checks described in the UEFI specification for CreateEvent(). This does not include checking the validity of the type and tpl parameters. Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: fix checkpatch.pl indent warning] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-07-03efi_loader: run CreateEvent() notify function based on flagsJonathan Gray
The UEFI specification states that the tpl, function and context arguments are to be ignored if neither EVT_NOTIFY_WAIT or EVT_NOTIFY_SIGNAL are specified. This matches observed behaviour with an AMI EDK2 based UEFI implementation. Skip calling the notify function if neither flag is present. Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-03-14efi: Add a hook to allow adding memory mappingYork Sun
Instead of adding all memory banks, add a hook so individual SoC/board can has its own implementation. Signed-off-by: York Sun <york.sun@nxp.com> CC: Alexander Graf <agraf@suse.de> Reviewed-by: Alexander Graf <agraf@suse.de>
2017-01-28disk: convert CONFIG_ISO_PARTITION to KconfigPatrick Delaunay
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
2017-01-09lib: gitignore *.elf and *.so generated by efi_loaderLadislav Michl
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
2016-11-27efi_loader: Allow to compile helloworld.efi w/o bundling itAlexander Graf
Today we can compile a self-contained hello world efi test binary that allows us to quickly verify whether the EFI loader framwork works. We can use that binary outside of the self-contained test case though, by providing it to a to-be-tested system via tftp. This patch separates compilation of the helloworld.efi file from including it in the u-boot binary for "bootefi hello". It also modifies the efi_loader test case to enable travis to pick up the compiled file. Because we're now no longer bloating the resulting u-boot binary, we can enable compilation always, giving us good travis test coverage. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-11-17ls2080: Exit dpaa only right before exiting U-BootAlexander Graf
On ls2080 we have a separate network fabric component which we need to shut down before we enter Linux (or any other OS). Along with that also comes configuration of the fabric using a description file. Today we always stop and configure the fabric in the boot script and (again) exit it on device tree generation. This works ok for the normal booti case, but with bootefi the payload we're running may still want to access the network. So let's add a new fsl_mc command that defers configuration and stopping the hardware to when we actually exit U-Boot, so that we can still use the fabric from an EFI payload. For existing boot scripts, nothing should change with this patch. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: York Sun <york.sun@nxp.com> [agraf: Fix x86 build]
2016-11-14x86: Enable EFI loader supportSimon Glass
Enable this so that EFI applications (notably grub) can be run under U-Boot on x86 platforms. At present the 'hello world' EFI application is not supported for the qemu-x86_efi_payload64 board. That board builds a payload consisting of a 64-bit header and a 32-bit U-Boot, which is incompatible with the way the EFI loader builds its EFI application. The following error is obtained: x86_64-linux-ld.bfd: i386 architecture of input file `lib/efi_loader/helloworld.o' is incompatible with i386:x86-64 output This could be corrected with additional Makefile rules. For now, this feature is disabled for that board. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [agraf: drop hello kconfig bits] Signed-off-by: Alexander Graf <agraf@suse.de>