summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-01-23efi_driver: EFI block driverHeinrich Schuchardt11-1/+595
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_selftest: add missing LF in test outputHeinrich Schuchardt2-2/+2
The output of the minicapps lacks a line feed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: store DT in EFI_RUNTIME_SERVICES_DATA memoryHeinrich Schuchardt1-2/+2
The device tree is needed at runtime. So we have to store it in EFI_RUNTIME_SERVICES_DATA memory. The UEFI spec recommends to store all configuration tables in EFI_RUNTIME_SERVICES_DATA memory. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_selftest: test start imageHeinrich Schuchardt7-0/+406
This pair of tests checks the StartImage boot service. Each test loads an EFI application into memory and starts it. One returns by calling the Exit boot service. The other returns directly. The tests are not built on x86_64 because the relocation code for the efi binary cannot be created. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_loader: fix ExitBootServicesHeinrich Schuchardt2-8/+32
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-23efi_loader: add check_tpl parameter to efi_signal_eventHeinrich Schuchardt3-11/+20
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 Schuchardt2-0/+23
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: correct EFI_BLOCK_IO_PROTOCOL definitionsHeinrich Schuchardt2-6/+14
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>
2018-01-23efi_loader: make efi_disk_create_partitions a global symbolHeinrich Schuchardt2-24/+64
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 Schuchardt2-36/+72
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 Schuchardt2-1/+3
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: efi_disk_register: correctly determine if_type_nameHeinrich Schuchardt1-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>
2018-01-23efi_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-23efi_loader: check tables in helloworld.efiHeinrich Schuchardt1-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>
2018-01-23efi_loader: allocate correct memory type for EFI imageHeinrich Schuchardt1-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>
2018-01-23efi_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-23efi_loader: correct find simple file system protocolHeinrich Schuchardt1-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>
2018-01-23efi_loader: address of the simple file system protocolHeinrich Schuchardt1-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>
2018-01-23efi_loader: return NULL from device path functionsHeinrich Schuchardt2-9/+39
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 Schuchardt5-46/+53
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_selftest: test for (Dis)ConnectControllerHeinrich Schuchardt2-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>
2018-01-23efi_selftest: remove todo in device path testHeinrich Schuchardt1-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>
2018-01-23efi_selftest: remove todo in manage protocolsHeinrich Schuchardt1-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>
2018-01-23efi_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-23efi_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-23efi_loader: fix signature of efi_disconnect_controllerHeinrich Schuchardt2-5/+8
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-23efi_loader: implement ConnectControllerHeinrich Schuchardt3-24/+187
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 Schuchardt2-3/+6
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: 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-23efi_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-23efi_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-23efi_loader: list of open protocol infosHeinrich Schuchardt2-1/+49
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-23efi_selftest: do not try to close device path protocolHeinrich Schuchardt1-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>
2018-01-23efi_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-23efi_selftest: colored test outputHeinrich Schuchardt3-25/+40
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>
2018-01-23tools: provide a tool to convert a binary file to an includeHeinrich Schuchardt4-0/+111
For testing EFI disk management we need an in-memory image of a disk. The tool file2include converts a file to a C include. The file is separated into strings of 8 bytes. Only the non-zero strings are written to the include. The output format has been designed to maintain readability. #define EFI_ST_DISK_IMG { 0x00010000, { \ {0x000001b8, "\x94\x37\x69\xfc\x00\x00\x00\x00"}, /* .7i..... */ \ {0x000001c0, "\x02\x00\x83\x02\x02\x00\x01\x00"}, /* ........ */ \ {0x000001c8, "\x00\x00\x7f\x00\x00\x00\x00\x00"}, /* ........ */ \ {0x000001f8, "\x00\x00\x00\x00\x00\x00\x55\xaa"}, /* ......U. */ \ ... {0x00006000, "\x48\x65\x6c\x6c\x6f\x20\x77\x6f"}, /* Hello wo */ \ {0x00006008, "\x72\x6c\x64\x21\x0a\x00\x00\x00"}, /* rld!.... */ \ {0, NULL} } } As the disk image needed for testing contains mostly zeroes a high compression ratio can be attained. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_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-23vsprintf.c: add EFI device path printingHeinrich Schuchardt3-6/+81
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>
2018-01-23efi_loader: text output for device path end nodeHeinrich Schuchardt1-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>
2018-01-23MAINTAINERS: correct entry for lib/efi*/Heinrich Schuchardt1-1/+1
lib/efi* indicates files efi* in directory lib. lib/efi*/ indicates all files in directories lib/efi*. Fixes: 623b3a579765 efi_selftest: provide an EFI selftest application Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-01-23efi_selftest: do not cut off u16 strings when printingHeinrich Schuchardt1-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>
2018-01-23efi_selftest: avoid superfluous messages for task priority levelsHeinrich Schuchardt1-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>
2018-01-23efi_selftest: avoid superfluous messages for event servicesHeinrich Schuchardt1-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>
2018-01-23efi_loader: use correct format string for unsigned longHeinrich Schuchardt1-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>
2018-01-23efi_loader: add comments to memory functionsHeinrich Schuchardt1-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>
2018-01-23efi_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>
2018-01-23efi_loader: support device path for IDE and SCSI disksHeinrich Schuchardt3-0/+93
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>
2018-01-23efi_loader: create full device path for block devicesHeinrich Schuchardt1-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>
2018-01-22Merge git://git.denx.de/u-boot-dmTom Rini12-131/+207
2018-01-21lib: fdtdec: Fix some style violationsMario Six1-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>