summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' of git://git.denx.de/u-boot-shTom Rini2019-04-112-16/+47
|\ | | | | | | - Various rmobile fixes
| * lib: fdt: Allow LZO and GZIP DT compression in U-BootMarek Vasut2019-04-092-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Add required Kconfig symbols, Makefile bits and macro fixes in a few places to support LZO and DT compression in U-Boot. This can save a lot of space with multi-DTB fitImages. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
| * lib: fdt: Allow enabling both LZO and GZIP DT compressionMarek Vasut2019-04-091-6/+13
| | | | | | | | | | | | | | | | | | | | | | Allow enabling both LZO and GZIP DT compression in SPL and fix a bug where if the GZIP decompression failed, the LZO decompression would not even be attempted. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
| * lib: fdt: Split fdtdec_setup_memory_banksize()Marek Vasut2019-04-091-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Split fdtdec_setup_memory_banksize() into fdtdec_setup_memory_banksize_fdt(), which allows the caller to pass custom blob into the function and the original fdtdec_setup_memory_banksize(), which uses the gd->fdt_blob. This is useful when configuring the DRAM properties from a FDT blob fragment passed in by the firmware. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * lib: fdt: Split fdtdec_setup_mem_size_base()Marek Vasut2019-04-091-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Split fdtdec_setup_mem_size_base() into fdtdec_setup_mem_size_base_fdt(), which allows the caller to pass custom blob into the function and the original fdtdec_setup_mem_size_base(), which uses the gd->fdt_blob. This is useful when configuring the DRAM properties from a FDT blob fragment passed in by the firmware. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | efi_loader: correct CTRL-A - CTRL-Z console inputHeinrich Schuchardt2019-04-071-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | In the extended text input protocol CTRL-A - CTRL-Z have to be signaled as Unicode characters a-z or A-Z depending on the shift state and not as 0x01 to 0x1a. Update Python unit test. This patch is required for using the EFI shell `edit` command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: enable file SetInfo()Heinrich Schuchardt2019-04-071-2/+65
| | | | | | | | | | | | | | | | | | | | | | EFI shell command edit uses the SetInfo() methods to unset the read only attribute of the file to be edited. So let efi_file_setinfo() return success in this case. Return an error if the function is called for to rename or resize a file as we do not support this yet. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: correct file creationHeinrich Schuchardt2019-04-071-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | The EFI shell expects that after opening a file with EFI_FILE_MODE_CREATE GetInfo() succeeds. Up to now we do not actually create the file when method Open() of the EFI_FILE_PROTOCOL is called. If method Open() of the EFI_FILE_PROTOCOL is called with EFI_FILE_MODE_CREATE and the file does not yet exist, call fs_write() with a buffer size of zero to actually create the file. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: debug output file handle in efi_file_open()Heinrich Schuchardt2019-04-071-2/+4
| | | | | | | | | | | | | | | | For debugging it is helpful to know the address of the file handle created by the Open() method of the EFI file protocol. So let's write it with EFI_PRINT(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: boottime: export efi_[un]load_image()AKASHI Takahiro2019-04-071-7/+7
| | | | | | | | | | | | | | | | Those two functions will be used later to re-implement do_bootefi_exec(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: boottime: add loaded image device path protocol to image handleAKASHI Takahiro2019-04-072-7/+14
| | | | | | | | | | | | | | | | | | To meet UEFI spec v2.7a section 9.2, we should add EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL to image handle, instead of EFI_DEVICE_PATH_PROTOCOL. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: variables PlatformLang and PlatformLangCodesHeinrich Schuchardt2019-04-071-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | Since TianoCore EDK2 commit d65f2cea36d1 ("ShellPkg/CommandLib: Locate proper UnicodeCollation instance") in edk2 the UEFI Shell crashes if EFI variable PlatformLang is not defined. As this variable is anyway prescribed in the UEFI 2.7 spec let's define it to L"en-US". Use the same value for PlatformLangCodes that defines the list of all supported languages. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: EFI_PRINT instead of debug for memory servicesHeinrich Schuchardt2019-04-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | For debug messages inside EFI API functions we should use the EFI_PRINT macro which gives us well aligned output like: EFI: Entry efi_allocate_pool_ext(4, 14, 000000007edd7718) EFI: efi_add_memory_map: 0x7dcfa000 0x1 4 yes EFI: Exit: efi_allocate_pool_ext: 0 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: EFI_PRINT instead of debug for variable servicesHeinrich Schuchardt2019-04-071-5/+5
| | | | | | | | | | | | | | | | | | | | | | For debug messages inside EFI API functions we should use the EFI_PRINT macro which gives us well aligned output like: EFI: Entry efi_get_variable("PlatformLang" ...) EFI: get 'efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_PlatformLang' EFI: Exit: efi_get_variable: 14 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: parameter checks in StartImage and Exit()Heinrich Schuchardt2019-04-071-0/+27
| | | | | | | | | | | | | | | | | | | | Add parameter checks in the StartImage() and Exit() boottime services: - check that the image handle is valid and has the loaded image protocol installed - in StartImage() record the current image - in Exit() check that the image is the current image Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: rearrange boottime service functionsHeinrich Schuchardt2019-04-071-109/+109
| | | | | | | | | | | | To avoid forward declarations move efi_start_image() and efi_exit() down. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: sanity checks when freeing memoryHeinrich Schuchardt2019-04-071-18/+58
| | | | | | | | | | | | | | | | | | | | | | | | Use a checksum to validate that efi_free_pool() is only called for memory allocated by efi_allocated_pool(). Add a plausibility check to efi_free_pages() checking that the address passed is page aligned. Update related function comments to match Sphinx style. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_selftest: check image_base, image_sizeHeinrich Schuchardt2019-04-071-5/+53
| | | | | | | | | | | | | | In efi_selftest_start_image_exit.c test the image_base and image_size are correctly set in the loaded image protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: set image_base and image_size to correct valuesAKASHI Takahiro2019-04-071-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, image's image_base points to an address where the image was temporarily uploaded for further loading. Since efi_loader relocates the image to final destination, image_base and image_size should reflect that. This bug was detected in UEFI SCT, "Loaded Image Protocol Test - test 2," which shows that 'Unload' function doesn't fit into a range suggested by image_base and image_size. TestCase/UEFI/EFI/Protocol/LoadedImage/BlackBoxTest/ LoadedImageBBTestMain.c:1002 Changes in this patch also includes: * reverts a patch, "efi_loader: save image relocation address and size" since newly added fields are no longer needed. * copy PE headers as well since those information will be needed for module loading, in particular, at gurb. (This bug was reported by Heinrich.) Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Rebase patch. Remove unused fields from struct efi_loaded_image_obj. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: bootmgr: support BootNext and BootCurrent variable behaviorAKASHI Takahiro2019-04-071-4/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See UEFI v2.7, section 3.1.2 for details of the specification. With efidebug command, you can run any EFI boot option as follows: => efi boot add 1 SHELL ... => efi boot add 2 HELLO ... => efi boot order 1 2 => efi bootmgr (starting SHELL ...) => efi boot next 2 => efi bootmgr (starting HELLO ...) => env print -e <snip ...> BootCurrent: {boot,run}(blob) 00000000: 02 00 .. BootOrder: {boot,run}(blob) 00000000: 01 00 02 00 .... Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: release file buffer after loading imageHeinrich Schuchardt2019-04-071-32/+18
|/ | | | | | | | | | | | | Commit 0e18f584de59 ("efi_loader: LoadImage: always allocate new pages") ensured that whether we load an image from file or from memory we end up with the same number of newly allocated buffers. But essentially we ended up with one buffer too many in both cases: efi_load_pe() copies and rebases the UEFI image. We do not need the buffer with the file contents afterwards. Fixes: 0e18f584de59 ("efi_loader: LoadImage: always allocate new pages") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* fix compile error on macOS Mojave默默2019-04-031-1/+8
|
* Merge branch '2019-03-29-master-imports'Tom Rini2019-03-291-1/+1
|\ | | | | | | | | | | | | | | - Bugfixes: - mmc: correct the HS400 initialization process - configs: ti: Move FIT image load address to avoid overwrite - lib: time: update module enable MACRO - Add mbrugger as RPi board maintainer, correct agraf's email address.
| * lib: time: update module enable MACROKever Yang2019-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | We'd better use correct way to check if module has enabled. for we have 3 timer MACRO: - CONFIG_TIMER - CONFIG_SPL_TIMER - CONFIG_TPL_TIMER Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* | efi_loader: TODO for the EFI file protocolHeinrich Schuchardt2019-03-271-0/+4
| | | | | | | | | | | | | | | | | | | | We currently only support EFI_FILE_PROTOCOL_REVISION while UEFI specs 2.4 - 2.7 prescribe EFI_FILE_PROTOCOL_REVISION2. Add a todo. Add missing constants for the EFI file protocol revision. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_selftest: avoid double free in dp utilities testHeinrich Schuchardt2019-03-271-5/+0
|/ | | | | | | Avoid duplicate FreePool() in unit test for the device patch utilities protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* rsa: check that pointer checksum isn't NULL before using itPhilippe Reynes2019-03-251-1/+2
| | | | | | | | | The pointer checksum were used before checking that it isn't NULL. We move the code that use it after the check. Reported-by: Coverity (CID: 185835) Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* efi_selftest: fix test_hii_string_get_string()Heinrich Schuchardt2019-03-201-13/+4
| | | | | | | | | The check testing the string result of get_string() returned the wrong result. The result was ignored. Use efi_st_strcmp_16_8() for the string comparison. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: superfluous conversion in efi_file_open()Heinrich Schuchardt2019-03-201-1/+1
| | | | | | | printf("%ls", ..) expects u16 * as argument to print. There is not need for a conversion to wchar_t *. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: remove superfluous check in efi_setup_loaded_image()Heinrich Schuchardt2019-03-201-4/+2
| | | | | | | | It does not make any sense to check if a pointer is NULL if we have dereferenced it before. Reported-by: Coverity (CID 185827) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: missing return in efi_get_next_variable_name()Heinrich Schuchardt2019-03-201-1/+1
| | | | | | | Add a missing return statement in efi_get_next_variable_name(). Reported-by: Coverity (CID 185834) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: endless loop in add_strings_package()Heinrich Schuchardt2019-03-201-3/+2
| | | | | | | | Avoid an endless loop in add_strings_package(). Suggested-by: Takahiro Akashi <takahiro.akashi@linaro.org> Reported-by: Coverity (CID 185833) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correct parameter size in efi_allocate_poolHeinrich Schuchardt2019-03-201-2/+3
| | | | | | | | | | efi_allocate_pages() expects a (uint64_t *) pointer to pass the address of the assigned memory. If we pass the address of a pointer here, an illegal memory access occurs on 32bit systems. Fixes: 282a06cbcae8 ("efi_loader: Expose U-Boot addresses in memory map for sandbox") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix build error for freestanding.oHeinrich Schuchardt2019-03-141-0/+11
| | | | | | | | | | | | | | Since commit f51a226436a87 ("efi_loader: provide freestanding library") in parallel builds errors lib/efi_selftest/../efi_loader/efi_freestanding.o: file not recognized: File truncated occur. Obviously make cannot correctly sequence parallel builds with a dependency like ../efi_loader/efi_freestanding.o. Fixes: f51a226436a87 ("efi_loader: provide freestanding library") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Fix serial console size detectionMatthias Brugger2019-03-101-27/+35
| | | | | | | | | | | | | | | | | | | Function term_read_reply tries to read from the serial console until the end_char was read. This can hang forever if we are, for some reason, not able to read the full response (e.g. serial buffer too small, frame error). This patch moves the timeout detection into term_read_reply() to assure we will make progress. Fixes: 6bb591f704 ("efi_loader: query serial console size reliably") Signed-off-by: Matthias Brugger <mbrugger@suse.com> Throw missing error when an incomplete reply for the cursor position is received. Change type of argument of term_get_char() *s32. This renders the function reusable in efi_cin_read_key(). Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: HII protocols: debug messagesHeinrich Schuchardt2019-03-021-18/+18
| | | | | | | | | | | When package types are not supported by our implementation of the HII database protocol supported error messages are displayed. Essentially the output is only needed for debugging. By using EFI_PRINT() the messages are only written for in debug mode and with correct indentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: HII protocols: fix new_package_list()Heinrich Schuchardt2019-03-021-1/+1
| | | | | | | | | | | | | | In new_package_list() we call new_packagelist() to create a new package list. Next we try to add the packages which fails for form packages. Due to this error we call free_packagelist(). Now in free_packagelist() list_del() is called for an uninitialized field hii->link. This leads to changing random memory addresses. To solve the problem move the initialization of hii->link to new_packagelist(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* efi_loader: do not add \ in efi_fs_from_name()Heinrich Schuchardt2019-03-021-6/+1
| | | | | | | | | | | | | In the `efidebug boot add` command we do not want an unsolicited leading backslash added to the file name. There is no good reason to mark a loaded file with a backslash as absolute. Anyway when reading files the file name will be interpreted as relative to root directory of the device. So let's get rid of this backslash. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: define load option attributesAKASHI Takahiro2019-02-251-4/+0
| | | | | | | See UEFI specification v2.7a, section 3.1.3, "Load Option Processing." Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix entry count in bootmgrHeinrich Schuchardt2019-02-251-4/+0
| | | | | | | | | | | | Since commit 914df75b0c97 ("efi_loader: fix EFI entry counting") entry_count is already set to 1 before efi_bootmgr_load() is called. So we should not increment it when entering the function. Without the patch an assert error occurs in efi_get_variable() if DEBUG is defined. Fixes: 914df75b0c97 ("efi_loader: fix EFI entry counting") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: error message if BootOrder not definedHeinrich Schuchardt2019-02-251-1/+3
| | | | | | | | For booting via `bootefi bootmgr` it is necessary that the EFI variable BootOrder is defined. Provide a diagnostic message if the variable is missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* tpm: simplify: tpm_set_global_lock()Heinrich Schuchardt2019-02-191-3/+1
| | | | | | | | When in pack_byte_string() memcpy() is called for size 0 the source buffer address has no relevance. So we can use NULL here. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* efi_loader: do not miss last relocation blockHeinrich Schuchardt2019-02-161-1/+1
| | | | | | | | | If the last block in the relocation table contains only a single relocation, the current coding ignores it. Fix the determination of the end of the relocation table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: documentation of image loaderHeinrich Schuchardt2019-02-161-9/+19
| | | | | | | | | - Add missing function descriptions. - Update existing function descriptions to match Sphinx style. - Add lib/efi_loader/efi_image_loader.c to the input files for Sphinx generated documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix EFI entry countingHeinrich Schuchardt2019-02-161-1/+2
| | | | | | | | | | | | | `bootefi selftest` fails on qemu-x86_defconfig if efi_selftest() is not invoked using EFI_CALL(). Likewise we call the entry point of EFI payloads with EFI_CALL(efi_start_image()). entry_count indicates if we are in U-Boot (1) or in EFI payload code (0). As we start in U-Boot code the initial value has to be 1. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: use efi_start_image() for bootefiHeinrich Schuchardt2019-02-161-3/+3
| | | | | | | Remove the duplicate code in efi_do_enter() and use efi_start_image() to start the image invoked by the bootefi command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: set entry point in efi_load_pe()Heinrich Schuchardt2019-02-162-20/+23
| | | | | | | | | | Up to now efi_load_pe() returns the entry point or NULL in case of an error. This does not allow to return correct error codes from LoadImage(). Let efi_load_pe() return a status code and fill in the entry point in the corresponding field of the image object. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: LoadImage: always allocate new pagesHeinrich Schuchardt2019-02-162-31/+71
| | | | | | | | | | If we want to properly unload images in Exit() the memory should always be allocated in the same way. As we allocate memory when reading from file we should do the same when the original image is in memory. A further patch will be needed to free the memory when Exit() is called. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: error handling in efi_setup_loaded_image()Heinrich Schuchardt2019-02-161-12/+21
| | | | | | | | | | In case of an error we should set the returned pointers to NULL. This ensures that an illegal free does not occur even if the caller calls free() for the handles. If protocols cannot be installed, release all resources. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib/vsprintf: print '?' for illegal Unicode sequenceHeinrich Schuchardt2019-02-161-0/+2
| | | | | | | | | Commit 0e66c10a7d80 ("lib: vsprintf: avoid overflow printing UTF16 strings") broke the Unicode unit tests: an illegal UTF16 code point should be printed as '?'. Fixes: 0e66c10a7d80 ("lib: vsprintf: avoid overflow printing UTF16 strings") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>