summaryrefslogtreecommitdiff
path: root/include/efi_loader.h
AgeCommit message (Collapse)AuthorFilesLines
2018-05-11SPDX: 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: complete EFI_DEVICE_PATH_UTILITIES_PROTOCOLHeinrich Schuchardt1-0/+9
The missing services of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL are implemented. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-23efi_loader: correcty determine total device path lengthHeinrich Schuchardt1-1/+4
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-23efi_loader: implement CreateDeviceNodeHeinrich Schuchardt1-1/+4
Implement the CreateDeviceNode service of the device path utility protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-05efi_loader: new functions to print loaded image informationHeinrich Schuchardt1-0/+5
Introduce functions to print information about loaded images. If we want to analyze an exception in an EFI image we need the offset between the PC and the start of the loaded image. With efi_print_image_info() we can print the necessary information for a single image, e.g. UEFI image [0xbffe6000:0xbffe631f] pc=0x138 '/\snp.efi' efi_print_image_infos() provides output for all loaded images. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-05efi_loader: implement EFI_FILE_SYSTEM_INFOHeinrich Schuchardt1-0/+2
Implement the information type EFI_FILE_SYSTEM_INFO in the service GetInfo() of the EFI_FILE_PROTOCOL. The volume label is not available in U-Boot. As a work-around use the partition name instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-05efi_loader: ascii2unicode(): add trailing \0Heinrich Schuchardt1-0/+1
When converting an ASCII string to UTF-16 don't forget to copy the trailing \0. 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-1/+6
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/+10
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-5/+6
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: 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: efi_get_time_init should return status codeHeinrich Schuchardt1-1/+1
All EFI initialization functions should return a status code. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: exit status for efi_reset_system_initHeinrich Schuchardt1-3/+8
efi_reset_system_init provides the architecture or board specific initialization of the EFI subsystem. Errors should be caught and signalled by a return code. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: consistently return efi_status_t efi_watchdog_registerHeinrich Schuchardt1-1/+1
efi_watchdog_register() should always return a status code and not a boolean value. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: return efi_status_t from efi_net_registerHeinrich Schuchardt1-1/+1
Consistently return status codes form efi_net_register(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: return efi_status_t from efi_gop_registerHeinrich Schuchardt1-1/+1
All initialization routines should return a status code instead of a boolean. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Convert warnings to debug() prints] Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: efi_smbios_register should have a return valueHeinrich Schuchardt1-1/+1
Errors may occur inside efi_smbios_register(). - Return a status code. - Remove unused variables. - Use constants where applicable. Suggested-by: Simon Glass <sjg@chromium.org> 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/+4
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-02-10efi_loader: correct efi_disk_registerHeinrich Schuchardt1-1/+1
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 <jsg@jsg.id.au> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Jonathan Gray <jsg@jsg.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-02-10efi_driver: return type of efi_driver_init()Heinrich Schuchardt1-1/+1
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_driver: EFI block driverHeinrich Schuchardt1-0/+2
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 <xypron.glpk@gmx.de> [agraf: add comment on calloc len] Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: add check_tpl parameter to efi_signal_eventHeinrich Schuchardt1-1/+1
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-23efi_loader: provide function to get last node of a device pathHeinrich Schuchardt1-0/+3
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: make efi_disk_create_partitions a global symbolHeinrich Schuchardt1-0/+4
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: provide a function to create a partition nodeHeinrich Schuchardt1-0/+2
Provide new function efi_dp_part_node() to create a device node for a partition. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: make efi_block_io_guid a global symbolHeinrich Schuchardt1-0/+2
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: return NULL from device path functionsHeinrich Schuchardt1-3/+3
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: consistently use efi_handle_t for handlesHeinrich Schuchardt1-6/+8
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-23efi_loader: implement ConnectControllerHeinrich Schuchardt1-0/+2
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-23efi_loader: debug output installed device pathHeinrich Schuchardt1-3/+4
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-23efi_loader: list of open protocol infosHeinrich Schuchardt1-1/+14
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>
2017-12-17efi_loader: new function efi_delete_handle()Heinrich Schuchardt1-0/+2
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-17efi_loader: return status from efi_setup_loaded_image()Heinrich Schuchardt1-3/+5
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-0/+2
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: manage protocols in a linked listHeinrich Schuchardt1-2/+4
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: efi_console: use helper functionsHeinrich Schuchardt1-10/+2
Use helper functions efi_created_handle and efi_add_protocol for creating the console handles and instaling the respective protocols. This change is needed if we want to move from an array of protocols to a linked list of protocols. Eliminate EFI_PROTOCOL_OBJECT which is not used anymore. Currently we have not defined protocol interfaces to be const. So efi_con_out and efi_console_control cannot be defined as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: helper functions for protocol managementHeinrich Schuchardt1-0/+12
This patch provides helper functions to manage protocols. efi_search_protocol - find a protocol on a handle efi_add_protocol - install a protocol on a handle efi_remove_protocol - remove a protocol from a handle efi_remove_all_protocols - remove all protocols from a handle Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: argument of efi_search_obj should be constHeinrich Schuchardt1-1/+1
The argument of efi_search_obj is not changed so it should be marked as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: make efi_create_handle non-staticHeinrich Schuchardt1-0/+2
Export function efi_create_handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: efi_dp_match should have const argumentsHeinrich Schuchardt1-1/+2
efi_dp_match does not change its arguments. So they should be marked as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: rework efi_search_objHeinrich Schuchardt1-0/+2
EFI_HANDLEs are used both in boottime and in runtime services. efi_search_obj is a function that can be used to validate handles. So let's make it accessible via efi_loader.h. We can simplify the coding using list_for_each_entry. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: consistently use efi_uintn_t in boot servicesHeinrich Schuchardt1-6/+6
Consistenly use efi_uintn_t wherever the UEFI spec uses UINTN in boot services interfaces. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: replace UINTN by efi_uintn_tHeinrich Schuchardt1-2/+2
UINTN is used in the UEFI specification for unsigned integers matching the bitness of the CPU. Types in U-Boot should be lower case. The patch replaces it by efi_uintn_t. Suggested-by: Simon Glass <sjg@chromium.org> Suggested-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: guard against double inclusion of efi_loader.hHeinrich Schuchardt1-1/+6
Use a define to detect double inclusion of efi_loader.h. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: implement SetWatchdogTimerHeinrich Schuchardt1-0/+4
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 <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-12efi_loader: Add mem-mapped for fallbackRob Clark1-0/+3
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 <robdclark@gmail.com> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-09efi_loader: use type bool for event statesHeinrich Schuchardt1-4/+4
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 <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-05efi_loader: support 16 protocols per efi_objectHeinrich Schuchardt1-2/+2
8 protocols per efi_object is insufficient for iPXE. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: add bootmgrRob Clark1-0/+6
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 <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-09-20efi_loader: efi variable supportRob Clark1-0/+10
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 <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>