aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2017-12-01efi_loader: efi_disk: check return value of callocHeinrich Schuchardt1-0/+13
Calloc may return NULL. We should check the return value. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: efi_gop: check calloc return valueHeinrich Schuchardt1-0/+4
Calloc may return NULL. We have to check the return value. Fixes: be8d324191f efi_loader: Add GOP support Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader implement UninstallMultipleProtocolInterfacesHeinrich Schuchardt1-1/+39
Implement UninstallMultipleProtocolInterfaces. The efi_uninstall_multipled_protocol_interfaces tries to uninstall protocols one by one. If an error occurs all uninstalled protocols are reinstalled. As the implementation efi_uninstall_protocol_interface is still incomplete the function will fail. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: debug output efi_install_protocol_interfaceHeinrich Schuchardt1-0/+5
efi_install_protocol_interface should provide the created or provided handle in the debug output. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: fix typo efi_install_multiple_protocol_interfacesHeinrich Schuchardt1-1/+1
%s/occured/occurred/g 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-6/+3
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: rework efi_locate_handleHeinrich Schuchardt1-12/+32
Check the parameters in efi_locate_handle. Use list_for_each_entry instead of list_for_each. 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 Schuchardt7-37/+37
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 Schuchardt2-7/+7
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: eliminate efi_uninstall_protocol_interface_extHeinrich Schuchardt1-30/+12
As we now have EFI_CALL there is no need for separate functions efi_uninstall_protocol_interface_ext and efi_uninstall_protocol_interface. 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: eliminate efi_install_protocol_interface_extHeinrich Schuchardt1-37/+15
As we now have EFI_CALL there is no need for separate functions efi_install_protocol_interface_ext and efi_install_protocol_interface. 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_selftest: test protocol managementHeinrich Schuchardt2-0/+357
This unit test checks the following protocol services: InstallProtocolInterface, UninstallProtocolInterface, InstallMultipleProtocolsInterfaces, UninstallMultipleProtocolsInterfaces, HandleProtocol, ProtocolsPerHandle, LocateHandle, LocateHandleBuffer. As UninstallProtocolInterface and UninstallMultipleProtocolsInterfaces are not completely implemented a TODO message will shown for their failure. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: capitalize EFI_LOCATE_SEARCH_TYPE valuesHeinrich Schuchardt1-3/+3
Constants should be capitalized. So rename the values of enum efi_locate_search_type. 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: set parent handle in efi_load_imageHeinrich Schuchardt1-0/+2
The parent_handle of the loaded image must be set. Set the system table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: provide test for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLHeinrich Schuchardt2-0/+56
The following services are tested: OutputString, TestString, SetAttribute. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: test reboot by watchdogHeinrich Schuchardt1-11/+57
A test is added that verifies that the watchdog timer actually causes a reboot upon timeout. The test is only executed on request using setenv efi_selftest watchdog reboot bootefi selftest Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: allow to select a single test for executionHeinrich Schuchardt3-8/+99
Environment variable efi_selftest is passed as load options to the selftest application. It is used to select a single test to be executed. The load options are an UTF8 string. Yet I decided to keep the name propertiy of the tests as char[] to reduce code size. Special value 'list' displays a list of all available tests. Tests get an on_request property. If this property is set the tests are only executed if explicitly requested. The invocation of efi_selftest is changed to reflect that bootefi selftest with efi_selftest = 'list' will call the Exit bootservice. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: deduplicate codeHeinrich Schuchardt1-29/+42
Move duplicate code to the new function efi_st_do_tests. Suggested-by: Alexander Graf <agraf@suse.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: efi_st_memcmp should return 0Heinrich Schuchardt1-1/+1
If the compared memory areas match the return value should be 0. We should not use the unrelated constant EFI_ST_SUCCESS. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: reformat codeHeinrich Schuchardt1-2/+2
Remove superfluous spaces. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: new function utf8_to_utf16Heinrich Schuchardt1-1/+56
Provide a conversion function from utf8 to utf16. Add missing #include <linux/types.h> in include/charset.h. Remove superfluous #include <common.h> in lib/charset.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_selftest: provide test for watchdog timerHeinrich Schuchardt2-1/+189
The test verifies that resetting the watchdog timer ensures that it is not called during the timeout period. Testing that the watchdog timer actually executes a reset would require a test outside the efi_selftest framework. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-12-01efi_loader: implement SetWatchdogTimerHeinrich Schuchardt3-15/+93
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-12-01efi_loader: move efi_search_obj up in codeHeinrich Schuchardt1-20/+21
To avoid a forward declaration move efi_search_obj before all protocol services functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-11-30Merge branch 'rmobile-mx' of git://git.denx.de/u-boot-shTom Rini1-6/+18
2017-11-29spl: make CONFIG_OF_EMBED pass dts through fdtgrepGoldschmidt Simon1-0/+4
Building spl with CONFIG_OF_EMBED enabled results in an error message on my board: "SPL image too big". This is because the fdtgrep build step is only executed for CONFIG_OF_SEPARATE. Fix this by moving the fdtgrep build step ('cmd_fdtgreo') from scripts/Makefile.spl to dts/Makefile so that the reduced dtb is available for all kinds of spl builds. The resulting variable name for the embedded device tree blob changes, too, which is why common.h and fdtdec.c have tiny changes. Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-11-30fdtdec: Support parsing multiple /memory nodesMarek Vasut1-6/+18
It is legal to have multiple /memory nodes in a device tree . Currently, fdtdec_setup_memory_size() only supports parsing the first node . This patch extends the function such that if a particular /memory node does no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still allows for more DRAM banks, the code moves on to the next memory node and checks it's "reg"s. This makes it possible to handle both systems with single memory node with multiple entries and systems with multiple memory nodes with single entry. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Tom Rini <trini@konsulko.com> Cc: Simon Glass <sjg@chromium.org>
2017-11-28Merge git://git.denx.de/u-boot-socfpgaTom Rini1-0/+2
2017-11-27Merge git://www.denx.de/git/u-boot-imxTom Rini1-0/+3
Signed-off-by: Tom Rini <trini@konsulko.com>
2017-11-26fdt: Add compatible strings for Arria 10Tien Fong Chee1-0/+2
Add compatible strings for Intel Arria 10 SoCFPGA device. Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
2017-11-20rtc: add support for s35392aNandor Han1-0/+3
Add support for S35392A RTC. The driver supports both U-Boot driver models. Signed-off-by: Nandor Han <nandor.han@ge.com> Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk> Cc: Heiko Schocher <hs@denx.de>
2017-11-19Merge git://git.denx.de/u-boot-dmTom Rini1-2/+58
2017-11-17tpm: add more missing va_end()André Draszik1-1/+4
While commit 36d35345b1f6 ("tpm: add missing va_end") added some missing calls to va_end(), it missed a few places. Signed-off-by: André Draszik <adraszik@tycoint.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-11-17tpm: add tpm_get_random()André Draszik1-0/+43
Add a function to obtain random data from the TPM. Signed-off-by: André Draszik <adraszik@tycoint.com> Added commit message, add cast to min() Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
2017-11-17lib: libfdt: wrap scripts/dtc/libfdt/* where possibleMasahiro Yamada7-1483/+24
lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files: fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c Make them a wrapper of scripts/dtc/libfdt/*. This is exactly what Linux does to sync libfdt. In order to make is possible, import <linux/libfdt.h> and <linux/libfdt_env.h> from Linux 4.14-rc5. Unfortunately, U-Boot locally modified the following 3 files: fdt_ro.c fdt_wip.c fdt_rw.c The fdt_region.c is U-Boot own file. I did not touch them in order to avoid unpredictable impact. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-17libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/*Masahiro Yamada1-50/+1
Fortunately, U-Boot did not modify libfdt_internal.h locally. Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-17libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*Masahiro Yamada1-67/+0
Fortunately, U-Boot did not modify fdt.h locally. Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-17pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefileMasahiro Yamada2-572/+0
The pylibfdt is used by dtoc (and, indirectly by binman), but there is no reason why it must be generated in the tools/ directory. Recently, U-Boot switched over to the bundled DTC, and the directory structure under scripts/dtc/ now mirrors the upstream DTC project. So, scripts/dtc/pylibfdt is the best location. I also rewrote the Makefile in a cleaner Kbuild style. The scripts from the upstream have been moved as follows: lib/libfdt/pylibfdt/setup.py -> scripts/dtc/pylibfdt/setup.py lib/libfdt/pylibfdt/libfdt.i -> scripts/dtc/pylibfdt/libfdt.i_shipped The .i_shipped is coped to .i during building because the .i must be located in the objtree when we build it out of tree. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-16tpm: fix reading of permanent flagsAndré Draszik1-1/+11
The offset of the permanent flags structure is in a different place in the response compared to what the code is doing, which gives us a completely useless result. Fix by replacing hand-crafted code with generic parser infrastructure. Signed-off-by: André Draszik <adraszik@tycoint.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-10-29efi_loader: Disable env_save() call on bootAlexander Graf1-4/+1
With the introduction of EFI variable support, we also wanted to persist these EFI variables. However, the way it was implemented we ended up persisting all U-Boot environment variables on every EFI boot. That could potentially lead to unexpected side effects because variables that were not supposed to be written to persisted env get written. It also means we may end up writing the environment more often than we should. For this release, let's just disable EFI variable persistence and instead implement it properly for the next one. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Fixes: ad644e7c182 ("efi_loader: efi variable support") Signed-off-by: Alexander Graf <agraf@suse.de> Acked-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2017-10-13Merge tag 'signed-efi-next' of git://github.com/agraf/u-bootTom Rini14-222/+1559
Patch queue for efi - 2017-10-13 This is the second batch of amazing improvements for efi_loader in 2017.11: - New self tests to verify our own code - A few bug fixes - colored text support - event and SNP improvements, should get us close to iPXE working
2017-10-13efi_selftest: correctly check return valuesHeinrich Schuchardt2-2/+2
When cancelling the timer we should check the return value provided by the set_timer service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-12efi_loader: console support for color attributesRob Clark1-2/+25
Shell.efi uses this, and supporting color attributes makes things look nicer. Map the EFI fg/bg color attributes to ANSI escape sequences. Not all colors have a perfect match, but spec just says "Devices supporting a different number of text colors are required to emulate the above colors to the best of the device’s capabilities". Signed-off-by: Rob Clark <robdclark@gmail.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <agraf@suse.de> [agraf: s/unsigned/unsigned int/] Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-12efi_loader: Add mem-mapped for fallbackRob Clark2-0/+33
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-10efi_loader: don't increment part twice per loopJonathan Gray1-1/+0
Correct a mistake in the part number handling of commit 16a73b249d138fedeb188710533902ed7aac1ddc and only increment part once per loop. Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-10efi_loader: search all possible disk partitionsJonathan Gray1-8/+12
When searching for partitions don't stop if a partition is not present for a given partition number as there may be valid partitions after. Search for up to MAX_SEARCH_PARTITIONS matching the other callers of part_get_info(). This allows OpenBSD to boot via the efi_loader on rpi_3 again after changes made after U-Boot 2017.09. With MBR partitioning OpenBSD will by default use the fourth partition for the 0xA6 (OpenBSD) partition. Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-09efi_selftest: error handling in SNP testHeinrich Schuchardt1-1/+8
Avoid NULL pointer dereference after setup failed due to a missing network. 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-10-09efi_loader: comments for functions add missing @returnHeinrich Schuchardt1-1/+8
For some functions the @return description is missing. Fix typo. 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-10-09efi_loader: Fix disk dp's for pre-DM/legacy devicesRob Clark1-0/+11
This fixes an issue with OpenBSD's bootloader, and I think should also fix a similar issue with grub2 on legacy devices. In the legacy case we were creating disk objects for the partitions, but not also the parent device. Reported-by: Jonathan Gray <jsg@jsg.id.au> Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2017-10-09efi_loader: avoid NULL dereference in efi_dp_matchHeinrich Schuchardt1-1/+2
When calling bootefi hello twice a kernel dump occurs. Neither bootefi hello nor bootefi selftest have an image device patch. So do not try to dereference the NULL value. Fixes: 95c5553ea26 efi_loader: refactor boot device and loaded_image handling Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>