summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: correct EFI_BLOCK_IO_PROTOCOL definitionsHeinrich Schuchardt2018-01-221-4/+4
| | | | | | | | | | Add the revision constants. Depending on the revision additional fields are needed in the media descriptor. Use efi_uintn_t for number of bytes to read or write. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: make efi_disk_create_partitions a global symbolHeinrich Schuchardt2018-01-221-24/+60
| | | | | | | | | | | | | | | 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>
* efi_loader: provide a function to create a partition nodeHeinrich Schuchardt2018-01-221-36/+70
| | | | | | | | 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>
* efi_loader: make efi_block_io_guid a global symbolHeinrich Schuchardt2018-01-221-1/+1
| | | | | | | | 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>
* efi_loader: efi_disk_register: correctly determine if_type_nameHeinrich Schuchardt2018-01-221-1/+1
| | | | | | | | The interface type name can be used to look up the interface type. Don't confound it with the driver name which may be different. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix StartImage bootserviceHeinrich Schuchardt2018-01-221-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>
* efi_loader: check tables in helloworld.efiHeinrich Schuchardt2018-01-221-0/+26
| | | | | | | Check if the device tree and the SMBIOS table are available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: allocate correct memory type for EFI imageHeinrich Schuchardt2018-01-221-24/+40
| | | | | | | | | | | The category of memory allocated for an EFI image should depend on its type (application, bootime service driver, runtime service driver). Our helloworld.efi built on arm64 has an illegal image type. Treat it like an EFI application. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: print device path when entering efi_load_imageHeinrich Schuchardt2018-01-221-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>
* efi_loader: correct find simple file system protocolHeinrich Schuchardt2018-01-221-10/+29
| | | | | | | | | | | In contrast to the description the code did not split the device path into device part and file part. The code should use the installed protocol and not refer to the internal structure of the the disk object. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: address of the simple file system protocolHeinrich Schuchardt2018-01-221-1/+1
| | | | | | | | | When installing the the simple file system protocol we have to path the address of the structure and not the address of a pointer to the structure. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: return NULL from device path functionsHeinrich Schuchardt2018-01-221-6/+36
| | | | | | | | | | | | | | 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>
* efi_loader: consistently use efi_handle_t for handlesHeinrich Schuchardt2018-01-222-26/+29
| | | | | | | | | 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>
* efi_selftest: test for (Dis)ConnectControllerHeinrich Schuchardt2018-01-222-0/+386
| | | | | | | | | | This unit test checks the following protocol services: ConnectController, DisconnectController, InstallProtocol, UninstallProtocol, OpenProtocol, CloseProtcol, OpenProtocolInformation Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: remove todo in device path testHeinrich Schuchardt2018-01-221-15/+25
| | | | | | | | | | | The installation of UninstallProtocol is functional now. So we do not expect errors when calling it. Call UninstallProtocol with correct level of indirection for parameter handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: remove todo in manage protocolsHeinrich Schuchardt2018-01-221-11/+11
| | | | | | | | The installation of UninstallProtocols is functional now. So we do not expect errors when calling it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: disconnect controllers in UninstallProtocolHeinrich Schuchardt2018-01-221-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>
* efi_loader: implement DisconnectControllerHeinrich Schuchardt2018-01-221-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>
* efi_loader: fix signature of efi_disconnect_controllerHeinrich Schuchardt2018-01-221-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>
* efi_loader: implement ConnectControllerHeinrich Schuchardt2018-01-221-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>
* efi_loader: debug output installed device pathHeinrich Schuchardt2018-01-221-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>
* efi_loader: implement OpenProtocolInformationHeinrich Schuchardt2018-01-221-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>
* efi_loader: open_info in CloseProtocolHeinrich Schuchardt2018-01-221-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>
* efi_loader: open_info in OpenProtocolHeinrich Schuchardt2018-01-221-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>
* efi_loader: list of open protocol infosHeinrich Schuchardt2018-01-221-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>
* efi_selftest: do not try to close device path protocolHeinrich Schuchardt2018-01-221-4/+4
| | | | | | | | | | | CloseProtocol cannot be called without agent handle. There is no need to close the device path protocol if it has been opened without agent handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: simplify efi_remove_all_protocolsHeinrich Schuchardt2018-01-221-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>
* efi_selftest: colored test outputHeinrich Schuchardt2018-01-222-15/+23
| | | | | | | | | | | | | | | Add color coding to output: test section blue success green errors red todo yellow summary white others light gray Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> [agraf: Fold in move of set_attribute before the print] Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correctly call imagesHeinrich Schuchardt2018-01-221-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>
* vsprintf.c: add EFI device path printingHeinrich Schuchardt2018-01-221-6/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For debugging efi_loader we need the capability to print EFI device paths. With this patch we can write: debug("device path: %pD", dp); A possible output would be device path: /MemoryMapped(0x0,0x3ff93a82,0x3ff93a82) This enhancement is not available when building without EFI support and neither in the SPL nor in the API example. A test is provided. It can be executed in the sandbox with command ut_print. The development for EFI support in the sandbox is currently in branch u-boot-dm/efi-working. The branch currently lacks commit 6ea8b580f06b ("efi_loader: correct DeviceNodeToText for media types"). Ater rebasing the aforementioned branch on U-Boot v2018.01 the test is executed successfully. Without EFI support in the sandbox the test is simply skipped. 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>
* efi_loader: text output for device path end nodeHeinrich Schuchardt2018-01-221-0/+2
| | | | | | | | Without the patch a device path consisting only of an end node is displayed as '/UNKNOWN(007f,00ff)'. It should be displayed as '/'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: do not cut off u16 strings when printingHeinrich Schuchardt2018-01-221-4/+8
| | | | | | | | | | | Device paths can be very long. Due to a limited output buffer the output for device paths is cut off. We can avoid this by directly calling the boottime service with the the device path string. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Remove coloring code change] Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: avoid superfluous messages for task priority levelsHeinrich Schuchardt2018-01-221-6/+9
| | | | | | | | | | In the task priority levels test debug output is written even if no failure is detected. Remove this distracting output. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: avoid superfluous messages for event servicesHeinrich Schuchardt2018-01-221-3/+5
| | | | | | | | | | In the event services test debug output is written even if no failure is detected. Remove this distracting output. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: use correct format string for unsigned longHeinrich Schuchardt2018-01-221-4/+4
| | | | | | | | virt_size is of type unsigned long. So it should be printed with %ul. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: add comments to memory functionsHeinrich Schuchardt2018-01-221-2/+42
| | | | | | | | | Add comments describing memory functions. Fix the formatting of a function declaration. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: use wide string do define firmware vendorHeinrich Schuchardt2018-01-221-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>
* efi_loader: support device path for IDE and SCSI disksHeinrich Schuchardt2018-01-222-0/+78
| | | | | | | | | Correctly create the device path for IDE and SCSI disks. Support for SATA remains to be done in a future patch. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: create full device path for block devicesHeinrich Schuchardt2018-01-221-2/+16
| | | | | | | | | When creating the device path of a block device it has to comprise the block device itself and should not end at its parent. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* lib: fdtdec: Fix some style violationsMario Six2018-01-211-14/+15
| | | | | | | | Fix some style violations in fdtdec.c, and reduce the scope of some variables. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
* lib: fdtdec: Fix whitespace style violationsMario Six2018-01-211-26/+30
| | | | | | | Fix some whitespace-related style violations in fdtdec.c. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
* fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATERob Clark2018-01-151-12/+23
| | | | | | | | | | | | | | Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc. In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot. Signed-off-by: Rob Clark <robdclark@gmail.com> [trini: Update board_fdt_blob_setup #if check] Signed-off-by: Tom Rini <trini@konsulko.com>
* Move CONFIG_PANIC_HANG to KconfigMasahiro Yamada2017-12-261-0/+10
| | | | | | | | Freescale (NXP) boards have lots of defconfig files per board. I used "imply PANIC_HANG" for them. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: York Sun <york.sun@nxp.com>
* efi_loader: Setup logical_partition media informationEmmanuel Vadot2017-12-191-0/+2
| | | | | | | | When adding a partition, set the logical_partition member in the media structure as mandated by the UEFI spec. Signed-off-by: Emmanuel Vadot <manu@freebsd.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: comments for dp_part_fill()Heinrich Schuchardt2017-12-161-1/+8
| | | | | | | | Add a description for dp_part_fill(). Reword a comment in the function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correct DeviceNodeToText for media typesHeinrich Schuchardt2017-12-161-12/+31
| | | | | | | | When converting device nodes and paths to text we should stick to the UEFI spec. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correctly setup device paths for block devicesHeinrich Schuchardt2017-12-161-2/+2
| | | | | | | | | | | According to the UEFI spec the numbering of partitions has to start with 1. Partion number 0 is reserved for the optional device path for the complete block device. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correctly determine if an MMC device is an SD-cardHeinrich Schuchardt2017-12-161-3/+21
| | | | | | | | The SD cards and eMMC devices have different device nodes. The current coding interpretes all MMC devices as eMMC. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: error handling in efi_load_image()Heinrich Schuchardt2017-12-161-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>
* efi_loader: new function efi_delete_handle()Heinrich Schuchardt2017-12-161-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>