aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_boottime.c
AgeCommit message (Collapse)AuthorFilesLines
2018-06-03efi_loader: remove unnecessary includeHeinrich Schuchardt1-1/+0
asm/global_data.h is already included via common.h. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-05-10SPDX: Convert a few files that were missed beforeTom Rini1-2/+1
As part of the main conversion a few files were missed. These files had additional whitespace after the '*' and before the SPDX tag and my previous regex was too strict. This time I did a grep for all SPDX tags and then filtered out anything that matched the correct styles. Fixes: 83d290c56fab ("SPDX: Convert all of our single license tags to Linux Kernel style") Reported-by: Heinrich Schuchardt <xypron.debian@gmx.de> Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-23efi_loader: correcty determine total device path lengthHeinrich Schuchardt1-2/+2
Device paths may consist of multiple instances. Up to now we have only considered the size of the first instance. For the services of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL in most cases the total length of the device path is relevant. So let's rename efi_dp_size() to efi_dp_instance_size() and create a new function efi_dp_size() that calculates the total device path length. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: use correct types in EFI_FILE_PROTOCOLHeinrich Schuchardt1-2/+3
In the EFI_FILE_PROTOCOL buffer sizes and positions are passed as UINTN and not as u64. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: use efi_uintn_t for LoadImageHeinrich Schuchardt1-2/+2
We generally use efi_uintn_t where the UEFI spec uses UINTN. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: RestoreTPL should execute queued eventsHeinrich Schuchardt1-0/+5
When the TPL is lowered queued events may become eligible for execution. iPXE uses the following pattern to request event execution: bs->RestoreTPL ( TPL_APPLICATION ); bs->RaiseTPL ( TPL_CALLBACK ); Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: implement event groupsHeinrich Schuchardt1-21/+78
If an event of a group event is signaled all other events of the same group are signaled too. Function efi_signal_event is renamed to efi_queue_event. A new function efi_signal_event is introduced that checks if an event belongs to a group and than signals all events of the group. Event group notifciation is implemented for ExitBootServices, InstallConfigurationTable, and ResetSystem. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: define GUIDS for event groupsHeinrich Schuchardt1-0/+16
Event groups are used to signal multiple events at the same time. They are identified by GUIDs. This patch provided the predefined GUIDs of UEFI specification 2.7. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: manage events in a linked listHeinrich Schuchardt1-105/+87
Lift the limit on the number of events by using a linked list. This also allows to have events with type == 0. This patch is based on Rob's patch efi_loader: fix events https://lists.denx.de/pipermail/u-boot/2017-October/309348.html Suggested-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: fix formatting errorsHeinrich Schuchardt1-22/+26
Fix formatting errors in efi_boottime.c indicated by scripts/checkpatch.py. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: clear signaled state in CheckEventHeinrich Schuchardt1-2/+5
CheckEvent must clear the signaled state. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: check parameter in InstallConfigurationTableHeinrich Schuchardt1-0/+3
Check that parameter guid is not NULL. This avoids a possible NULL pointer exception. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: support device tree for bootefi selftestHeinrich Schuchardt1-0/+2
The second argument of the bootefi command should always be usable to specify a device tree. This was missing for bootefi selftest and bootefi hello. Proper error handling is added. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: Initial EFI_DEVICE_PATH_UTILITIES_PROTOCOLLeif Lindholm1-0/+6
Not complete, but enough for Shell.efi and SCT.efi. We'll implement the rest as needed or once we have SCT running properly so there is a way to validate the interface against the conformance test suite. Initial skeleton written by Leif, and then implementation by Rob. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> [Fill initial skeleton] Signed-off-by: Rob Clark <robdclark@gmail.com> [Rebase on v2018.03-rc1] Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: remove deprecated ConsoleControlProtocolHeinrich Schuchardt1-5/+0
The console control protocol is not defined in the UEFI standard. It exists in EDK2's EdkCompatiblityPkg package. But this package is deprecated according to https://github.com/tianocore/tianocore.github.io/wiki/Differences-between-EDK-and-EDK-II Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: parameter checks for LoadImageHeinrich Schuchardt1-0/+20
Add parameter checks in efi_load_image(). Check memory allocation is successful in efi_load_image(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-03-05libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>Masahiro Yamada1-1/+1
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 <libfdt.h> -> #include <linux/libfdt.h> #include <libfdt_env.h> -> #include <linux/libfdt_env.h> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-02-10efi_loader: do not use 2.0.5 as UEFI revision numberHeinrich Schuchardt1-1/+1
Currently the UEFI revision number in the system table header is set to 2.0.5. This version number does not refer to any existing version of the UEFI standard. Set the revision number to 2.7. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Mark Kettenis <kettenis@openbsd.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-02-10efi_loader: create stub for CreateEventExHeinrich Schuchardt1-0/+33
Currently we set the function pointer for the CreateEventEx boot service to NULL. When called this would lead to an immediate failure. A function stub is provided which handles the case that the boot service is called without an event group and returns EFI_UNSUPPORTED otherwise. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-28efi_loader: do not install NULL as device pathHeinrich Schuchardt1-9/+11
In an image is loaded from memory we do not have a device path. Do not install NULL as device path in this case. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-28efi_loader: Call Exit() on return from payload in StartImage()Alexander Graf1-2/+7
When a UEFI payload just returns instead of calling the Exit() callback, we handle that in efi_do_enter() and call Exit on its behalf, so that the loaded_image->exit_status value is correct. We were missing that logic in StartImage(). Call it there too. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-28efi_loader: fix comments in indent_string()Heinrich Schuchardt1-3/+6
Provide a better description for indent_string. Fix a typo. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-28efi_loader: Always use EFIAPI instead of asmlinkageAlexander Graf1-2/+2
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 <agraf@suse.de> --- v1 -> v2: - Use efi_status_t in all occurences
2018-01-22efi_loader: fix ExitBootServicesHeinrich Schuchardt1-5/+29
This patch lets the implementation of ExitBootServices conform to the UEFI standard. The timer events must be disabled before calling the notification functions of the exit boot services events. The boot services must be disabled in the system table. The handles in the system table should be defined as efi_handle_t. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: add check_tpl parameter to efi_signal_eventHeinrich Schuchardt1-7/+8
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: fix StartImage bootserviceHeinrich Schuchardt1-1/+2
The calling convention for the entry point of an EFI image is always 'asmlinkage'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: print device path when entering efi_load_imageHeinrich Schuchardt1-1/+1
Use %pD to print the device path instead of its address when entering efi_load_image. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: consistently use efi_handle_t for handlesHeinrich Schuchardt1-23/+26
We should consistently use the efi_handle_t typedef when referring to handles. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: disconnect controllers in UninstallProtocolHeinrich Schuchardt1-6/+23
The UninstallProtocol boot service should first try to disconnect controllers that have been connected with EFI_OPEN_PROTOCOL_BY_DRIVER. If the protocol is still opened by an agent, it should be closed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: implement DisconnectControllerHeinrich Schuchardt1-22/+262
Unfortunately we need a forward declaration because both OpenProtocol and CloseProtocol have to call DisconnectController. And DisconnectController calls both OpenProtcol and CloseProtocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: fix signature of efi_disconnect_controllerHeinrich Schuchardt1-3/+4
Handles should be passed as efi_handle_t and not as void *. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: implement ConnectControllerHeinrich Schuchardt1-24/+163
Implement the ConnectController boot service. A unit test is supplied in a subsequent patch. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: debug output installed device pathHeinrich Schuchardt1-0/+2
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: implement OpenProtocolInformationHeinrich Schuchardt1-1/+41
efi_open_protocol_information provides the agent and controller handles as well as the attributes and open count of an protocol on a handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: fix counting error] Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: open_info in CloseProtocolHeinrich Schuchardt1-1/+25
efi_open_protocol and efi_close_protocol have to keep track of opened protocols. Check if the protocol was opened for the same agent and controller. Remove all open protocol information for this pair. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: open_info in OpenProtocolHeinrich Schuchardt1-4/+103
efi_open_protocol has to keep track of opened protocols. OpenProtocol enters the agent and controller handle information into this list. A unit test is supplied with a subsequent patch. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: list of open protocol infosHeinrich Schuchardt1-0/+35
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: simplify efi_remove_all_protocolsHeinrich Schuchardt1-6/+3
Replace list_for_each_safe() and list_entry() by list_for_each_entry_safe(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: correctly call imagesHeinrich Schuchardt1-8/+28
Avoid a failed assertion when an EFI app calls an EFI app. Avoid that the indent level increases when calling 'bootefi hello' repeatedly. Avoid negative indent level when an EFI app calls an EFI app that calls an EFI app (e.g. iPXE loads grub which starts the kernel). Return the status code of a loaded image that returns without calling the Exit boot service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-22efi_loader: use wide string do define firmware vendorHeinrich Schuchardt1-2/+1
As the U-Boot is compiled with -fshort-wchar we can define the firmware vendor constant as wide string. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-16efi_loader: error handling in efi_load_image()Heinrich Schuchardt1-16/+15
If a failure occurs when trying to load an image, it is insufficient to free() the EFI object. We must remove it from the object list, too. Otherwise a use after free will occur the next time we iterate over the object list. Furthermore errors in setting up the image should be handled. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-16efi_loader: new function efi_delete_handle()Heinrich Schuchardt1-86/+100
Provide a function to remove a handle from the object list after removing all protocols. To avoid forward declarations other functions have to move up in the coding. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-16efi_loader: return status from efi_setup_loaded_image()Heinrich Schuchardt1-4/+7
efi_setup_loaded_image() should return an error code indicating if an error has occurred. An error occurs if a protocol cannot be installed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: helper function to add EFI object to listHeinrich Schuchardt1-7/+33
To avoid duplicate coding provide a helper function that initializes an EFI object and adds it to the EFI object list. efi_exit() is the only place where we dereference a handle to obtain a protocol interface. Add a comment to the function. Suggested-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: pass handle of loaded imageHeinrich Schuchardt1-1/+1
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 <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: manage protocols in a linked listHeinrich Schuchardt1-56/+51
Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: simplify efi_open_protocolHeinrich Schuchardt1-30/+6
Use function efi_search_protocol. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: reimplement LocateDevicePathHeinrich Schuchardt1-30/+76
The current implementation of efi_locate_device_path does not match the UEFI specification. It completely ignores the protocol parameters. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: refactor efi_setup_loaded_imageHeinrich Schuchardt1-14/+25
Use helper functions to add protocols. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: simplify efi_locate_protocolHeinrich Schuchardt1-12/+6
Use helper function efi_search_protocol. Do not print protocol guid twice in debug mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>