summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-28Consolidate __assert_failed into one implementationAlex Kiernan
We had two implementations of __assert_failed which were almost identical, combine them into one. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
2018-04-28spl: Disable printf if not requiredAlex Kiernan
Now we have a guard for printf, disable it in the build if it's not selected. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
2018-04-28spl: Split sprintf, strto* from SPL serial in KconfigAlex Kiernan
When SPL serial is disabled, callers who need sprintf or strtoul fail because their inclusion is guarded by CONFIG_SPL_SERIAL_SUPPORT/ CONFIG_TPL_SERIAL_SUPPORT. Split printf, sprintf and strto into their own entries and then select all of them if SERIAL_SUPPORT is enabled to match the current behaviour. Include panic.o unconditionally as it can be called from anywhere which uses BUG_ON(). Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
2018-04-28lib/rsa: Kconfig: Remove superfluous 'depends on RSA'Eugeniu Rosca
RSA_SOFTWARE_EXP and RSA_FREESCALE_EXP are wrapped inside: if RSA ... endif So, remove the redundant "depends on RSA" from their depends expression. In addition, move SPL_RSA into the same "if RSA ... endif" block, since its only direct dependeny is CONFIG_RSA. This tidies up and simplifies reading of lib/rsa/Kconfig. No functional change intended. Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-04-27Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTRTom Rini
We have a large number of places where while we historically referenced gd in the code we no longer do, as well as cases where the code added that line "just in case" during development and never dropped it. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-23efi_selftest: test EFI_DEVICE_PATH_UTILITIES_PROTOCOLHeinrich Schuchardt
Provide unit tests for the EFI_DEVICE_PATH_UTILITIES_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-23efi_loader: complete EFI_DEVICE_PATH_UTILITIES_PROTOCOLHeinrich Schuchardt
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 Schuchardt
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: correctly determine length of empty device pathHeinrich Schuchardt
efi_dp_size() is meant to return the device path length without the end node. The length of a device path containing only an end node was incorrectly reported as 4. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-23efi_loader: fix AppendDevicePathHeinrich Schuchardt
The logic of the AppendDevicePath service of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL is incorrectly implemented: * if both paths are NULL an end node has to be returned * if both paths are not NULL the end node of the second device path has to be kept Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-23efi_loader: implement CreateDeviceNodeHeinrich Schuchardt
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-23efi_selftest: fix typo in efi_selftest_devicepath.cHeinrich Schuchardt
%s/provice/provide/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-23efi_selftest: do not execute test if setup failedHeinrich Schuchardt
Executing a test after failed setup may lead to unexpected behavior like an illegal memory access. So after a setup failure we should skip to teardown. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-23efi_loader: no support for ARMV7_NONSEC=yHeinrich Schuchardt
We do not support bootefi booting ARMv7 in non-secure mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-13Revert "Kconfig: cmd: Make networking command dependent on NET"Joe Hershberger
This reverts the parts of commit 3b3ea2c56ec4bc5588281fd103c744e608f8b25c where it changed the EFI dependency on NET. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Duncan Hare <dh@synoia.com>
2018-04-09Merge tag 'signed-efi-next' of git://github.com/agraf/u-bootTom Rini
Patch queue for efi - 2018-04-09 Highlights this time around: - Lots of minor spec compliance fixes - Support full range of GOP BLT commands - More fine grained error checking - Network fixes (init, DP) - Lots of other bug fixes...
2018-04-06efi_loader: Check machine type in the image headerIvan Gorinov
Check FileHeader.Machine to make sure the EFI executable image is built for the same architecture. For example, 32-bit U-Boot on x86 will print an error message instead of loading an x86_64 image and crashing. Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-05efi_loader: completely initialize networkHeinrich Schuchardt
Add missing network initialization code. Before the patch the network was only usable if a network command like dhcp or tftp had beed executed. This was visible when interrupting the console countdown and executing bootefi selftest for vexpress_ca15_tc2_defconfig. 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 Schuchardt
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_selftest: test getinfo(EFI_FILE_SYSTEM_INFO)Heinrich Schuchardt
Check that the getinfo() service of the file protocol correctly returns the partion label. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-05efi_selftest: partition label for test imageHeinrich Schuchardt
efi_selftest_disk_image.h contains a disk image. We use it to test the EFI_FILE_PROTOCOL. The patch sets the partition label to 'U-BOOT TEST'. 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 Schuchardt
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: use const for GUIDs in the EFI_FILE_PROTOCOLHeinrich Schuchardt
Use const efi_guid_t* when passing GUIDs. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04Merge git://git.denx.de/u-boot-sunxiTom Rini
Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-04efi_loader: use correct types in EFI_FILE_PROTOCOLHeinrich Schuchardt
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: ImageSize must be multiple of SectionAlignmentHeinrich Schuchardt
According to the Portable Executable and Common Object File Format Specification the image size must be a multiple of the alignment of sections. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: save image relocation address and sizeHeinrich Schuchardt
For analyzing crash output the relocation address and size are needed. Save them in the loaded image info. 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 Schuchardt
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: initialize device path on allocPatrick Wildt
Since the backing memory for a new device path can contain stale data we have to make sure that we zero the buffer. Otherwise some code paths that don't set all fields in a structure backed by this device path might contain unwanted stale data. Signed-off-by: Patrick Wildt <patrick@blueri.se> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: Fix network DP with DM_ETHAlexander Graf
When CONFIG_DM_ETH is set, we assemble the device path properly with a full device hierarchy. Our helper function dp_fill() even put the MAC node itself in it for us. However, for non-DM compatibility we also have code in that added the MAC node manually. That code now runs on top of the existing MAC node: Handle 0x3db2f6b0 /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ] /USBClass(0,0,9,0,0)/USBClass(424,9514,9,0,2)/MacAddr(b8:27:eb:e1:81:47,1) /MacAddr(b8:27:eb:e1:81:47,57)/EndEntire We obviously don't need the additional node and in fact, grub chokes on it and fails to match the DP against the ethernet device node. So this patch moves the additional MAC node into the non-DM code path: Handle 0x3db3fde0 /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ] /USBClass(0,0,9,0,0)/USBClass(424,9514,9,0,2)/MacAddr(b8:27:eb:e1:81:47,1) /EndEntire While at it, we also mark the non-DM MAC node as ethernet. Fixes: b66c60dde9d ("efi_loader: add device-path utils") Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: Fix return value for efi_add_runtime_mmioAlexander Graf
The efi_add_runtime_mmio function incorrectly returned the added address as return value rather than EFI_SUCCESS. Fix it by checking the return value of efi_add_memory_map properly. Fixes: f057cfef5dc ("efi_loader: exit status for efi_reset_system_init") Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: Optimize GOP moreAlexander Graf
The GOP path was optimized, but still not as fast as it should be. Let's push it even further by trimming the hot path into simple 32bit load/store operations for buf->vid 32bpp operations. Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: Optimize GOP switchAlexander Graf
We usually try to compile for size, not for speed. Unfortunately with the more powerful GOP infrastructure to handle all sorts of GOP operations, we end up slowing down our copying hot path quite a lot. So this patch moves the 4 possible GOP operation modes into separate functions which call a common function again. The end result of that is more optimized code that can properly do constant propagation throughout its switch() statements and thus removes compares in the hot path. Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: use __always_inline for pixel conversionHeinrich Schuchardt
We optimize for size using -Os so gcc might ignore 'inline'. Pixel conversions are called so often that we always want to inline them. 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 Schuchardt
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: use TPL_NOTIFY for network timer eventHeinrich Schuchardt
We use a timer to poll the network. iPXE is used for booting from iSCSI drives. It has been changed to run at TPL_CALLBACK most of the time (which is not what the UEFI spec recommends). By changing our timer to TPL_NOTIFY we can ensure that it is nevertheless executed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: correctly support parameter delta in BltHeinrich Schuchardt
In the Blt service of the EFI_GRAPHICS_OUTPUT_PROTOCOL the parameter delta is measured in bytes and not in pixels. The coding only supports delta being a multiple of four. The UEFI specification does not explicitly require this but as pixels have a size of four bytes we should be able to assume four byte alignment. The corresponding unit test is corrected, too. It can be launched with setenv efi_selftest block image transfer bootefi selftest Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_selftest: unit test for event groupsHeinrich Schuchardt
Supply a unit test for event groups. Create multiple events in an event group. Signal each event once and check that all events are notified once in each round. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_selftest: fix device tree unit testHeinrich Schuchardt
Include libfdt.h was moved by commit b08c8c487083 ("libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>") Fixes: e236200c7fa6 ("efi_selftest: check installation of the device tree") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi: Correct header order in efi_memorySimon Glass
The headers are not in the correct order. Fix this. Also drop libfdt_env.h since it is not needed. Signed-off-by: Simon Glass <sjg@chromium.org> Rebased Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: use constants in efi_allocate_pages()Heinrich Schuchardt
Using the existing predefined constants is less error prone and makes the code easier to read. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: show UEFI revision in helloworldHeinrich Schuchardt
Output the UEFI revision number in helloworld. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_selftest: unit test for EFI_SIMPLE_TEXT_INPUT_PROTOCOLHeinrich Schuchardt
Provide a unit test for the EFI_SIMPLE_TEXT_INPUT_PROTOCOL. The unicode character and the scan code are printed for text input. To run the test: setenv efi_selftest text input bootefi selftest Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: add missing EFI_RESET_PLATFORM_SPECIFICHeinrich Schuchardt
EFI_RESET_PLATFORM_SPECIFIC is one of the values that can be used for the EFI service ResetSystem. The missing definition is added. The value has to handled in efi_reset_system(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_selftest: test gop bitbltHeinrich Schuchardt
The test checks all block image transfer operations of the graphical output protocol. An animated submarine is shown. To run the test: setenv efi_selftest bock image transfer bootefi selftest Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: implement missing bit blit operations in gopHeinrich Schuchardt
With the patch all block image transfer operations of the EFI_GRAPHICS_OUTPUT_PROTOCOL are supported. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-04-04efi_loader: implement event groupsHeinrich Schuchardt
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 Schuchardt
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 Schuchardt
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>