summaryrefslogtreecommitdiff
path: root/include/efi_loader.h
AgeCommit message (Collapse)AuthorFilesLines
2019-04-23efi_loader: rework bootmgr/bootefi using load_image APIAKASHI Takahiro1-4/+1
In the current implementation, bootefi command and EFI boot manager don't use load_image API, instead, use more primitive and internal functions. This will introduce duplicated code and potentially unknown bugs as well as inconsistent behaviours. With this patch, do_efibootmgr() and do_boot_efi() are completely overhauled and re-implemented using load_image API. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Use efi_root as parent handle for the loaded image. LoadImage() should be called with BootPolicy = true by the boot manager. Avoid duplicate free_pool(). Eliminate variable memdp which is not needed after anymore due to "efi_loader: correctly split device path of loaded image". Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23efi_loader: export root node handleAKASHI Takahiro1-0/+3
This is a preparatory patch. The root node handle will be used as a dummy parent handle when invoking an EFI image from bootefi/bootmgr command. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Rebased. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-12efi_loader: export efi_install_multiple_protocol_interfacesHeinrich Schuchardt1-0/+3
Export function efi_install_multiple_protocol_interfaces() so that we can call it in others parts of the UEFI subsystem. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-07efi_loader: boottime: export efi_[un]load_image()AKASHI Takahiro1-0/+9
Those two functions will be used later to re-implement do_bootefi_exec(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-07efi_loader: boottime: add loaded image device path protocol to image handleAKASHI Takahiro1-0/+1
To meet UEFI spec v2.7a section 9.2, we should add EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL to image handle, instead of EFI_DEVICE_PATH_PROTOCOL. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-07efi_loader: set image_base and image_size to correct valuesAKASHI Takahiro1-4/+0
Currently, image's image_base points to an address where the image was temporarily uploaded for further loading. Since efi_loader relocates the image to final destination, image_base and image_size should reflect that. This bug was detected in UEFI SCT, "Loaded Image Protocol Test - test 2," which shows that 'Unload' function doesn't fit into a range suggested by image_base and image_size. TestCase/UEFI/EFI/Protocol/LoadedImage/BlackBoxTest/ LoadedImageBBTestMain.c:1002 Changes in this patch also includes: * reverts a patch, "efi_loader: save image relocation address and size" since newly added fields are no longer needed. * copy PE headers as well since those information will be needed for module loading, in particular, at gurb. (This bug was reported by Heinrich.) Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Rebase patch. Remove unused fields from struct efi_loaded_image_obj. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: use efi_start_image() for bootefiHeinrich Schuchardt1-0/+4
Remove the duplicate code in efi_do_enter() and use efi_start_image() to start the image invoked by the bootefi command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: set entry point in efi_load_pe()Heinrich Schuchardt1-2/+2
Up to now efi_load_pe() returns the entry point or NULL in case of an error. This does not allow to return correct error codes from LoadImage(). Let efi_load_pe() return a status code and fill in the entry point in the corresponding field of the image object. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: LoadImage: always allocate new pagesHeinrich Schuchardt1-1/+1
If we want to properly unload images in Exit() the memory should always be allocated in the same way. As we allocate memory when reading from file we should do the same when the original image is in memory. A further patch will be needed to free the memory when Exit() is called. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-13efi: hii: add HII config routing/access protocolsAKASHI Takahiro1-0/+4
This patch is a place holder for HII configuration routing protocol and HII configuration access protocol. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: Initial HII database protocolsLeif Lindholm1-0/+4
This patch provides enough implementation of the following protocols to run EDKII's Shell.efi and UEFI SCT: * EfiHiiDatabaseProtocol * EfiHiiStringProtocol Not implemented are: * ExportPackageLists() * RegisterPackageNotify()/UnregisterPackageNotify() * SetKeyboardLayout() (i.e. *current* keyboard layout) HII database protocol in this patch series can handle only: * GUID package * string package * keyboard layout package (The other packages, except Device path package, will be necessary for interactive and graphical UI.) Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: efi_set_variable use const void *Heinrich Schuchardt1-1/+1
The SetVariable() runtime service does not change the data passed to it. So mark the parameter as constant. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use const efi_guid_t * for variable servicesHeinrich Schuchardt1-7/+7
The runtime variable services never change GUIDs. So we should declare the GUID parameters as constant. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: move efi_init_obj_list() to a new efi_setup.cAKASHI Takahiro1-0/+2
The function, efi_init_obj_list(), can be shared in different pseudo efi applications, like bootefi/bootmgr as well as my efishell. Moreover, it will be utilized to extend efi initialization, for example, my "removable disk support" patch and "capsule-on-disk support" patch in the future. So with this patch, it will be moved to a new file, efi_setup.c, under lib/efi_loader and exported, making no changes in functionality. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Remove lines deactivated by #if 1 #else Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-03efi_loader: bootmgr: add load option helper functionsAKASHI Takahiro1-0/+23
In this patch, helper functions for an load option variable (BootXXXX) are added: * efi_deserialize_load_option(): parse a string into load_option data (renamed from parse_load_option and exported) * efi_serialize_load_option(): convert load_option data into a string Those functions will be used to implement efishell command. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: macro efi_size_in_pages()Heinrich Schuchardt1-1/+10
When allocating EFI memory pages the size in bytes has to be converted to pages. Provide a macro efi_size_in_pages() for this conversion. Use it in the EFI subsystem and correct related comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: add efi_dp_from_name()AKASHI Takahiro1-0/+4
Factor out efi_set_bootdev() and extract efi_dp_from_name(). This function will be used to set a boot device in efishell command. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: rename parent to headerHeinrich Schuchardt1-2/+7
Rename the component parent of some EFI objects to header. This avoids misunderstandings. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: eliminate handle memberHeinrich Schuchardt1-9/+17
A pointer to a struct efi_object is a handle. We do not need any handle member in this structure. Let's eliminate it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-10-16efi_loader: return type efi_console_register()Heinrich Schuchardt1-1/+1
Use a return type that can encompass the return value. This fixes CoverityScan CID 184090. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: refactor efi_setup_loaded_image()Heinrich Schuchardt1-7/+20
Create the handle of loaded images and the EFI_LOADED_IMAGE_PROTOCOL inside efi_setup_loaded_image(). Do not use local variables. Currently we expect the loaded image handle to point to the loaded image protocol. Additionally we have appended private fields to the protocol. With the patch the handle points to a loaded image object and the private fields are added here. This matches how we handle the net and the gop object. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: remove redundant statementHeinrich Schuchardt1-1/+9
ascii2unicode() always ends the u16 string with '\0'. Remove redundant assignment. Add description for efi_str_to_u16() and ascii2unicode(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: create root nodeHeinrich Schuchardt1-0/+9
Currently we assign a lot of protocols to loaded images though these protocols are not related to them. Instead they should be installed on a separate handle. Via the device path it is the parent to the devices like the network adapter. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: struct efi_simple_text_input_protocolHeinrich Schuchardt1-1/+1
%s/efi_simple_input_interface/efi_simple_text_input_protocol/ We should be consistent in the naming of the EFI protocol interface structures. The protocol is called EFI_SIMPLE_TEXT_INPUT_PROTOCOL. %s/ExtendedVerification/extended_verification/ Use consistent naming of function parameters. Do not use CamelCase. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: EFI_UNICODE_COLLATION_PROTOCOLHeinrich Schuchardt1-0/+5
The patch implements the EFI_UNICODE_COLLATION_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-09-23efi_loader: simplify ifdefsStephen Warren1-3/+3
Use CONFIG_IS_ENABLED(EFI_LOADER) to avoid explicitly checking CONFIG_SPL too. This simplifies the conditional. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-20efi_loader: update runtime services table crc32Heinrich Schuchardt1-0/+3
The crc32 of the runtime services table must be updated after detaching. efi_update_table_header_crc32() must be __efi_runtime. So move it to efi_runtime.c Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: remove unused efi_get_time_init()Heinrich Schuchardt1-1/+0
Remove unused function efi_get_time_init(). Initialization of the RTC has to be done in board bring up not in the EFI subsystem. There is no RTC device in the UEFI spec. The RTC is only accessed through the runtime services. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: allocate configuration table arrayHeinrich Schuchardt1-0/+3
The system table contains a link to the list of configurations tables. These include the device tree, SMBIOS table, and the ACPI table. This array is currently statically linked. With the patch it is allocated as EFI_RUNTIME_SERVICES_DATA. Due to the structure of the system table we cannot work with a linked list here. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: calculate crc32 for EFI tablesHeinrich Schuchardt1-0/+2
For the boot and runtime services tables and for the system table the crc32 has to be set in the header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: check map_key in ExitBootServicesHeinrich Schuchardt1-0/+3
The UEFI spec requires that the memory map key is checked in ExitBootServices(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-07-25efi_loader: Rename sections to allow for implicit dataAlexander Graf1-2/+2
Some times gcc may generate data that is then used within code that may be part of an efi runtime section. That data could be jump tables, constants or strings. In order to make sure we catch these, we need to ensure that gcc emits them into a section that we can relocate together with all the other efi runtime bits. This only works if the -ffunction-sections and -fdata-sections flags are passed and the efi runtime functions are in a section that starts with ".text". Up to now we had all efi runtime bits in sections that did not interfere with the normal section naming scheme, but this forces us to do so. Hence we need to move the efi_loader text/data/rodata sections before the global *(.text*) catch-all section. With this patch in place, we should hopefully have an easier time to extend the efi runtime functionality in the future. Signed-off-by: Alexander Graf <agraf@suse.de> [agraf: Fix x86_64 breakage]
2018-07-02efi_loader: Install ACPI configuration tablesBin Meng1-0/+8
ACPI tables can be passed via EFI configuration table to an EFI application. This is only supported on x86 so far. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-06-03efi: Update some comments related to smbios tablesSimon Glass1-0/+7
Clarify the operation of this code with some additional comments. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-06-03efi_loader: adjust definitions of variable servicesHeinrich Schuchardt1-9/+9
The definitons of the variable services are adjusted: - use efi_uintn_t instead of unsigned long - use u16 * instead of s16 * for Unicode strings - correct definition of QueryVariableInfo - rename efi_get_next_variable to efi_get_next_variable_name Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-05-29efi_loader: Use EFI_CACHELINE_SIZE in the image loader tooAlexander Graf1-0/+7
We were using our EFI_CACHELINE_SIZE define only in the runtime service code, but left the image loader to use plain CONFIG_SYS_CACHELINE_SIZE. This patch moves EFI_CACHELINE_SIZE into efi_loader.h and converts the image loader to use it. Signed-off-by: Alexander Graf <agraf@suse.de>
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>