summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: efi_dp_get_next_instance() superfluous statementHeinrich Schuchardt2018-10-161-1/+0
| | | | | | | Remove a superfluous statement in efi_dp_get_next_instance(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: creating new handle in controller testHeinrich Schuchardt2018-10-161-0/+2
| | | | | | | | | | | When the last protocol interface is uninstalled the handle is deleted but this does not set the value of the handle to NULL. To create a new handle with OpenProtocolInterface the value of the handle must be NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix typo in efi_boottime.cHeinrich Schuchardt2018-10-161-1/+1
| | | | | | | %s/conncected/connected/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Fix warning in efi_load_image()Tom Rini2018-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | As observed with clang: lib/efi_loader/efi_boottime.c:1624:7: warning: variable 'info' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (ret != EFI_SUCCESS) ^~~~~~~~~~~~~~~~~~ lib/efi_loader/efi_boottime.c:1653:7: note: uninitialized use occurs here free(info); ^~~~ lib/efi_loader/efi_boottime.c:1624:3: note: remove the 'if' if its condition is always false if (ret != EFI_SUCCESS) ^~~~~~~~~~~~~~~~~~~~~~~ lib/efi_loader/efi_boottime.c:1602:31: note: initialize the variable 'info' to silence this warning struct efi_loaded_image *info; ^ = NULL Rather than change how we unwind the function it makes the most sense to initialize info to NULL so that we can continue to pass it to free(). Fixes: c982874e930d ("efi_loader: refactor efi_setup_loaded_image()") Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: remove lcd.h from efi_net.cHeinrich Schuchardt2018-10-161-1/+0
| | | | | | | Remove superfluous include. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: memory leak in efi_set_variable()Heinrich Schuchardt2018-10-161-2/+4
| | | | | | | | | | Do not leak native_name if out of memory. This addresses CoverityScan CID 184095. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: superfluous statement in is_dir()Heinrich Schuchardt2018-10-161-1/+8
| | | | | | | | | | | When is_dir() is called we have already execute set_blk_dev(fh). So don't call it again. This fixes CoverityScan CID 184093. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: return type efi_console_register()Heinrich Schuchardt2018-10-161-1/+3
| | | | | | | | | | 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>
* efi_loader: error handling in read_console()Heinrich Schuchardt2018-10-161-3/+8
| | | | | | | | | | | getc() might return an error code. Avoid an incorrect converison to Unicode. This addresses CoverityScan CID 184087. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, ...)Heinrich Schuchardt2018-10-161-3/+3
| | | | | | | | The first parameter of efi_allocate_pool is a memory type. It cannot be EFI_ALLOCATE_ANY_PAGES. Use EFI_BOOT_SERVICES_DATA instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correct signature of GetPosition, SetPositionHeinrich Schuchardt2018-10-162-10/+59
| | | | | | | | | | | | | | | | | The UEFI spec requires that file positions are passed as u64 in GetPosition() and SetPosition(). Check if the file handle points to a directory in GetPosition(). Provide a unit test for GetPosition() and SetPosition(). Fix Coverity warning CID 184079 (CONSTANT_EXPRESSION_RESULT). Add comments. Fixes: b6dd57773719 ("efi_loader: use correct types in EFI_FILE_PROTOCOL") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix relocation on x86_64Heinrich Schuchardt2018-10-161-4/+12
| | | | | | | | | | | | | | | | | Currently the relocation of the EFI runtime on x86_64 fails. This renders the EFI subsystem unusable. The ELF relocation records for x86_64 contain an addend field. Always write the function name into error messages related to the EFI runtime relocation. Break an excessively long line. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* Revert "fdt: fdtdec_setup_memory_banksize() use livetree"Michal Simek2018-10-151-21/+23
| | | | | | | | | This reverts commit c35a7d375ec8f0a8ee343ae4868be3242172632e. This commit is breaking SPL on zc706. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Patrice Chotard <patrice.chotard@st.com> [on STM32F746-disco]
* tpm: Add a few new commands for v1Simon Glass2018-10-091-3/+65
| | | | | | | These are needed for the 2018 version of Chromium OS vboot. Add an implementation for TPM v1, with v2 to come later. Signed-off-by: Simon Glass <sjg@chromium.org>
* tpm: Tidy up logging in tpm-common.cSimon Glass2018-10-091-3/+7
| | | | | | | At present this file uses logging but it should use the new macros. Update it and add a log message for an error. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Remove fdtdec_decode_region() functionSimon Glass2018-10-091-83/+0
| | | | | | | This function is not used in U-Boot now. Remove it along with its 'memory' version. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Allow libfdt in TPLSimon Glass2018-10-091-0/+10
| | | | | | | In some cases (e.g. sandbox with verified boot) it is useful to support libfdt in TPL. Update the Kconfig to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
* serial: Allow serial to be absent in TPLSimon Glass2018-10-091-2/+3
| | | | | | | | At present this option applies to SPL, but it should be available in TPL also, and separately. Change to using CONFIG_IS_ENABLED(), add a new Kconfig option and fix up hang(). Signed-off-by: Simon Glass <sjg@chromium.org>
* tpm: Add support for SPL and TPLSimon Glass2018-10-092-3/+29
| | | | | | | At present the tpm can only be used in U-Boot proper. Updated it to work in SPL and TPL also. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini2018-10-021-20/+16
|\ | | | | | | | | | | | | This is the PR for SPI-NAND changes along with few spi changes. [trini: Re-sync changes for ls1012afrwy_qspi*_defconfig] Signed-off-by: Tom Rini <trini@konsulko.com>
| * lib: strto: fix metric suffix parsing in strtoul[l]Miquel Raynal2018-09-201-12/+10
| | | | | | | | | | | | | | | | | | | | While 1kB or 1kiB will be parsed correctly, 1k will return the right amount, but the metric suffix will not be escaped once the char pointer updated. Fix this situation by simplifying the move of the endp pointer. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Stefan Roese <sr@denx.de>
| * lib: strto: parse all lowercase metric prefixes in ustrtoul[l]Miquel Raynal2018-09-201-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both ustrtoul and ustrtoull interpret 1k but not 1m or 1g. Even if the SI symbols for Mega and Giga are 'M' and 'G', certain entries of eg. mtdparts also use (wrongly) the metric prefix 'm' and 'g'. I do not see how parsing lowercase prefixes could break anything, so parse them like their uppercase counterpart. Also, even though kiB is not equal to kB in general, lets not change U-Boot behavior and always use kiB and kB (same applies for MiB vs. MB and GiB vs. GB) as a representation for 1024 instead of 1000. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Stefan Roese <sr@denx.de>
* | fdt: fdtdec_setup_memory_banksize() use livetreeJens Wiklander2018-09-291-23/+21
| | | | | | | | | | | | | | Converts fdtdec_setup_memory_banksize() to use ofnode functions instead. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
* | efi_loader: refactor efi_setup_loaded_image()Heinrich Schuchardt2018-09-232-58/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: Disable efi selftest on sandbox for nowAlexander Graf2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | The EFI selftest does not succeed on Sandbox yet. The network support seems to need some love to actually make our current tests succeed. So let's disable running the selftest on sandbox for now until "make tests" just works. Then we can have more amazing CI than ever. Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: remove efi_exit_caches()Heinrich Schuchardt2018-09-231-28/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since GRUB patch d0c070179d4d ("arm/efi: Switch to arm64 linux loader", 2018-07-09) we do not need a workaround for GRUB on 32bit ARM anymore. So let's eliminate function efi_exit_caches(). This will require Linux distributions to update grub-efi-arm to the GRUB git HEAD (a tag containing the aforementioned GRUB patch is not available yet). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: remove redundant statementHeinrich Schuchardt2018-09-231-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>
* | efi_loader: create root nodeHeinrich Schuchardt2018-09-234-22/+80
| | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: avoid out of bound access in efi_get_variable()Heinrich Schuchardt2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In efi_get_variable() a string is longer than the allocated space which results in overwriting the linked list of malloc(). The prefixes used for variables are 41 characters long, e.g. efi_67029eb5-0af2-f6b1-da53-fcb566dd1ce6_ Change PREFIX_LEN to 41. Fixes: faff21556748 ("efi_loader: remove limit on variable length") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_driver: convert function descriptions to Sphinx styleHeinrich Schuchardt2018-09-231-32/+54
| | | | | | | | | | | | | | | | Convert the function descriptions to Sphinx style. efi_driver_init() is cCalled by efi_init_obj_list(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: query serial console size reliablyHeinrich Schuchardt2018-09-231-13/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | Not all terminals understand CSI [18t for querying the console size. We should adhere to escape sequences documented in the console_codes manpage and the ECMA-48 standard. So here we follow a different approach. We position the cursor to the bottom right and query its position. Before leaving the function we restore the original cursor position. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: Merge memory map entriesAlexander Graf2018-09-231-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | We currently do not combine memory entries that are adjacent and have the same attributes. The problem with that is that our memory map can easily grow multiple hundreds of entries in a simple UEFI Shell environment. So let's make sure we always combine all entries to make the memory map as small as possible. That way every other piece of code that loops through it should also gain some nice speed ups. Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_selftest: missing braces in efi_selftest_textinputex.cHeinrich Schuchardt2018-09-231-1/+1
| | | | | | | | | | | | | | | | gcc 4.8.4 wants to see all levels of braces when initializing a structure to zeros. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: check parameter new_handle of efi_file_open()Heinrich Schuchardt2018-09-231-1/+1
| | | | | | | | | | | | | | | | We should not check parameter file twice. We should check parameter new_handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: terminal left upper corner is [1, 1]Heinrich Schuchardt2018-09-231-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | For the VT102 and the Linux console the left upper corner is [1, 1]. EFI uses [0, 0] as left upper corner. Check parameters of the SetCursorPosition() service. Use CSI H like EDK2 for positioning. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: more debug info for efi_file_getinfo()Heinrich Schuchardt2018-09-231-1/+1
| | | | | | | | | | | | | | | | efi_file_getinfo() is called with a GUID. In EFI_ENTRY use %pUl as format type. This way the GUID is printed in debug mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi: Correct the operation of efi_file_write()Simon Glass2018-09-231-4/+2
| | | | | | | | | | | | | | | | We should not directly cast between pointers and addresses since it breaks sandbox. Fix this and simplify the code in file_read(). Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi: sandbox: Enable EFI loader build for sandboxSimon Glass2018-09-231-1/+1
| | | | | | | | | | | | | | | | This allows this feature to build within sandbox. This is useful for testing. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: loosen check of parameters of efi_file_open()Heinrich Schuchardt2018-09-231-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | The UEFI spec requires that attributes are only set for when EFI_FILE_MODE_CREATE is set in open_mode. The SCT tries to read a directory with EFI_FILE_DIRECTORY. As EDK2 allows this we should not be more strict. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: provide description of file_open()Heinrich Schuchardt2018-09-231-2/+12
| | | | | | | | | | | | | | Replace urban slang by proper description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: check parameters of efi_file_open()Heinrich Schuchardt2018-09-231-4/+26
| | | | | | | | | | | | | | Check the parameters of efi_file_open(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_selftest: test key notification functionsHeinrich Schuchardt2018-09-231-7/+66
| | | | | | | | | | | | | | | | Use a key notification function to leave the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: implement key notify functionsHeinrich Schuchardt2018-09-231-3/+98
| | | | | | | | | | | | | | | | Implement registering and unregistreing key notify functions in the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_selftest: test EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLHeinrich Schuchardt2018-09-232-0/+140
| | | | | | | | | | | | | | Provide a unit test for the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: support modifiers for F1 - F4Heinrich Schuchardt2018-09-231-25/+39
| | | | | | | | | | | | | | | | Support modifiers for F1 - F4. Add support for letters with ALT key. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLHeinrich Schuchardt2018-09-231-22/+231
| | | | | | | | | | | | | | | | | | | | This patch implements the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. The implementation of notification functions is postponed to a later patch. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_selftest: use WaitForKey to test text inputHeinrich Schuchardt2018-09-231-3/+24
| | | | | | | | | | | | | | | | We should test the WaitForKey event. Testing for EFI_NOT_READY can be done after resetting the console. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: rework event handling for consoleHeinrich Schuchardt2018-09-231-38/+137
| | | | | | | | | | | | | | | | | | | | Preread the next key in the console timer event. The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL requires to trigger registered key notification functions based on the prefetched key. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_selftest: refactor text input testHeinrich Schuchardt2018-09-232-107/+95
| | | | | | | | | | | | | | Move reusable utility functions to efi_selftest_util.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* | efi_loader: support Unicode text inputHeinrich Schuchardt2018-09-232-54/+96
| | | | | | | | | | | | | | | | | | | | | | Up to now the EFI_TEXT_INPUT_PROTOCOL only supported ASCII characters. With the patch it can consume UTF-8 from the console. Currently only the serial console and the console can deliver UTF-8. Local consoles are restricted to ASCII. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>