summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2019-02-13efi_loader: fix EFI_FILE_PROTOCOL.GetInfo()Heinrich Schuchardt1-0/+4
We check the existence of files with fs_exist(). This function calls fs_close(). If we do not set the active block device again fs_opendir() fails and we do not set the flag EFI_FILE_DIRECTORY. Due to this error the `cd` command in the EFI shell fails. So let's add the missing set_blk_dev(fh) call. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13lib: vsprintf: avoid overflow printing UTF16 stringsHeinrich Schuchardt1-3/+7
We have to ensure while printing UTF16 strings that we do not exceed the end of the print buffer. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: Make HII a config optionAlexander Graf3-1/+18
Heinrich ran into issues with HII and iPXE which lead to #SErrors on his Odroid-C2 system. We definitely do not want to regress just yet, so let's not expose the HII protocols by default. Instead, let's make it a config option that people can play with This way, we can stabilize the code in tree without breaking any users. Once someone figures out, why this breaks iPXE (probably a NULL dereference), we can enable it by default. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de> --- v1 -> v2: - Remove HII selftest as well v2 -> v3: - Make config option
2019-02-13efi_loader: debug output for HII protocolsHeinrich Schuchardt2-26/+26
For correct indention use EFI_PRINT() instead of debug(). For printing efi_uintn_t or size_t use the %zu or %zx format code. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: fix HII testsHeinrich Schuchardt1-11/+0
efi_st_printf() does not support format code %ld. Anyway the format code for size_t would be %zu which isn't supported either. We do not want any divisions to avoid invalid references to integer arithmetic routines, cf. https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html. As a simple remedy remove the noisy messages from the output. They are not relevant for automated testing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: add HII database protocols testAKASHI Takahiro3-0/+1500
This efi_selftest tests HII database protocol and HII string protocol. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi: hii: add HII config routing/access protocolsAKASHI Takahiro3-1/+153
This patch is a place holder for HII configuration routing protocol and HII configuration access protocol. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi: hii: add keyboard layout package supportAKASHI Takahiro1-5/+142
Allow for handling keyboard layout package in HII database protocol. A package can be added or deleted in HII database protocol, but we don't set 'current' keyboard layout as there is no driver that requests a keyboard layout. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi: hii: add guid package supportAKASHI Takahiro1-6/+42
Allow for handling GUID package in HII database protocol. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: Initial HII database protocolsLeif Lindholm3-0/+935
This patch provides enough implementation of the following protocols to run EDKII's Shell.efi and UEFI SCT: * EfiHiiDatabaseProtocol * EfiHiiStringProtocol Not implemented are: * ExportPackageLists() * RegisterPackageNotify()/UnregisterPackageNotify() * SetKeyboardLayout() (i.e. *current* keyboard layout) HII database protocol in this patch series can handle only: * GUID package * string package * keyboard layout package (The other packages, except Device path package, will be necessary for interactive and graphical UI.) Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: GetNextVariableName() relies on REGEXHeinrich Schuchardt1-0/+1
Our implementation of GetNextVariableName() relies on CONFIG_REGEX=y. So EFI_LOADER has to select it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: fix GetNextVariableNameHeinrich Schuchardt1-1/+2
Our current implementation of GetNextVariableName() first collects all EFI variables. If none is found at all hexport_r() returns a zero length string terminated by \0 and the value 1 as number of bytes in the returned buffer. In this case GetNextVariableName() has to return EFI_NOT_FOUND. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: do not use symbolic linksHeinrich Schuchardt1-1/+0
Symbolic links are not supported on all file systems, e.g. not on FAT. So it is not wise to use them in our source tree. Use a qualified path to refer to lib/efi_loader/efi_freestanding.c in scripts/Makefile.lib instead. Reported-by: Alexander Graf <agraf@suse.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Fix build with O=] Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use library memcpy() in helloworld.efiHeinrich Schuchardt1-30/+6
Helloworld does not need its own memcpy() implementation anymore. Use the one provided in efi_freestanding.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use freestanding library for efi appsHeinrich Schuchardt1-0/+1
GCC requires that freestanding programs provide memcpy(), memmove(), memset(), and memcmp(). Add the library functions when building a *.efi files. The EFI selftests might use other compilation flags. So use a symbolic link to provide lib/efi_selftest/efi_freestanding.c and compile it separately. Reported-by: Alexander Graf <agraf@suse.de> Fixes: 5be444d14b38 ("efi_loader: consistent build flags for EFI applications") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: provide freestanding libraryHeinrich Schuchardt1-0/+90
GCC requires that freestanding programs provide memcpy(), memmove(), memset(), and memcmp(). Provide the required library functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: fix variables test for GetNextVariableName()AKASHI Takahiro1-5/+8
There is a bug in efi variables test. Fix it with some cosmetic improvements. Please note that efi variables test still fails at QueryVariableInfo() and GetVariable(), but this is not due to a change in this patch. ==8<== Testing EFI API implementation Selected test: 'variables' Setting up 'variables' Setting up 'variables' succeeded Executing 'variables' .../u-boot/lib/efi_selftest/efi_selftest_variables.c(60): TODO: QueryVariableInfo failed .../u-boot/lib/efi_selftest/efi_selftest_variables.c(131): TODO: GetVariable returned wrong length 7 .../u-boot/lib/efi_selftest/efi_selftest_variables.c(133): TODO: GetVariable returned wrong value Executing 'variables' succeeded Boot services terminated Summary: 0 failures ==>8== Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: implement GetNextVariableName()AKASHI Takahiro1-10/+146
The current GetNextVariableName() is a placeholder. With this patch, it works well as expected. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> rebased on efi-next Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: comments for variable servicesHeinrich Schuchardt1-5/+81
Comment the functions implementing the runtime variable services. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: remove duplicate function mem2hex()Heinrich Schuchardt1-14/+1
Replace duplicate function mem2hex() by inline function bin2hex(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: eliminate duplicate function hex2mem()Heinrich Schuchardt1-41/+3
Use existing inline function hex2bin() instead of defining a new one. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: consistent build flags for EFI applicationsHeinrich Schuchardt2-3/+3
At the same time adding and removing the -Os flag does not make any sense. Actually it leads to -Os not being used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use u16* for file nameHeinrich Schuchardt2-10/+10
UTF-16 strings in our code should all be u16 *. Fix an inconsistency for file names which may lead to a warning for printf("%ls", ). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: fix CopyMem()Heinrich Schuchardt1-1/+1
CopyMem() must support overlapping buffers. So replace memcpy() by memmove(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_driver: simplify error messageHeinrich Schuchardt1-2/+1
Stating the function module is sufficient. We don't need file and line number. Anyway the format code for the line number was incorrect (should be %d). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: tpl unit test, check return valuesHeinrich Schuchardt1-2/+2
For some API calls checks for the return values are missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: events unit test, check return valuesHeinrich Schuchardt1-3/+3
For some API calls checks for the return values are missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: SNP unit test on sandboxHeinrich Schuchardt1-0/+8
Running the simple network protocol test on the sandbox requires setting the environment variable ethact to a network interface connected to a DHCP server and ethrotate to 'no'. So let's make it an on-request test on the sandbox (selectable by setting environment variable efi_selftest). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: efi_set_variable use const void *Heinrich Schuchardt1-1/+1
The SetVariable() runtime service does not change the data passed to it. So mark the parameter as constant. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use const efi_guid_t * for variable servicesHeinrich Schuchardt2-10/+10
The runtime variable services never change GUIDs. So we should declare the GUID parameters as constant. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: move efi_init_obj_list() to a new efi_setup.cAKASHI Takahiro2-0/+87
The function, efi_init_obj_list(), can be shared in different pseudo efi applications, like bootefi/bootmgr as well as my efishell. Moreover, it will be utilized to extend efi initialization, for example, my "removable disk support" patch and "capsule-on-disk support" patch in the future. So with this patch, it will be moved to a new file, efi_setup.c, under lib/efi_loader and exported, making no changes in functionality. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Remove lines deactivated by #if 1 #else Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_selftest: allow building on ARMv7-MHeinrich Schuchardt1-3/+3
ARMv7-M only supports the Thumb instruction set. Our current crt0 code does not support it. With the patch we can build all unit tests of the EFI subsystem that do not require crt0. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: signature of StartImage and ExitHeinrich Schuchardt1-5/+5
We use u16* for Unicode strings and efi_uintn_t for UINTN. Correct the signature of efi_exit() and efi_start_image(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: fix memory allocation on sandboxHeinrich Schuchardt1-0/+6
Commit 7b78d6438a2b ("efi_loader: Reserve unaccessible memory") introduced a comparison between RAM top and RAM start that was not known at the time when the patch of commit 49759743bf09 ("efi_loader: eliminate sandbox addresses") was written. The sandbox uses an address space that is only relevant in the sandbox context. We have to map ram_top from the sandbox address space to the physical address space before using it in the EFI subsystem. Fixes: 49759743bf09 ("efi_loader: eliminate sandbox addresses") Fixes: 7b78d6438a2b ("efi_loader: Reserve unaccessible memory") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: efi_connect_controller() use %pDHeinrich Schuchardt1-1/+1
EFI_ENTRY in efi_connect_controller() should use %pD to print the remaining device path. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: efi_add_runtime_mmio()Heinrich Schuchardt1-1/+2
The first parameter of efi_add_runtime_mmio() is a pointer to a pointer. This should be reflected in the documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13lib: add u16_strcpy/strdup functionsAkashi, Takahiro1-0/+29
Add u16_strcpy() and u16_strdup(). The latter function will be used later in implementing efi HII database protocol. Signed-off-by: Akashi Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-11Merge branch 'master' of git://git.denx.de/u-boot-i2cTom Rini1-0/+33
- DM I2C improvements
2019-02-10Merge tag 'dm-pull-10feb19' of git://git.denx.de/u-boot-dmTom Rini1-7/+0
Samsung sound patches (applied for Samsung maintainer) Common sound support buildman environment support of-platdata documentation improvements
2019-02-09fdt: tegra: Drop COMPAT_AMS_AS3722Simon Glass1-1/+0
This is no-longer used. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-02-09fdt: samsung: Drop unused fdt_compat_id valuesSimon Glass1-6/+0
This enum still exists but we can shrink it a little based on recent driver-model conversions with samsung. Update it to remove unused items. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-02-09initcall: Move to inline functionAlexander Graf2-40/+0
The board_r init function was complaining that we are looping through an array, calling all our tiny init stubs sequentially via indirect function calls (which can't be speculated, so they are slow). The solution to that is pretty easy though. All we need to do is inline the function that loops through the functions and the compiler will automatically convert almost all indirect calls into direct inlined code. With this patch, the overall code size drops (by 40 bytes on riscv64) and boot time should become measurably faster for every target. Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-09hashtable: fix environment variable corruptionRoman Kapl1-3/+10
Only first previously deleted entry was recognized, leading hsearch_r to think that there was no previously deleted entry. It then conluded that a free entry was found, even if there were no free entries and it overwrote a random entry. This patch makes sure all deleted or free entries are always found and also introduces constants for the 0 and -1 numbers. Unit tests to excersise a simple hash table usage and catch the corruption were added. To trash your environment, simply run this loop: setenv i 0 while true; do setenv v_$i $i setenv v_$i setexpr i $i + 1 done Signed-off-by: Roman Kapl <rka@sysgo.com>
2019-02-08fdt: Introduce fdtdec_get_alias_highest_id()Michal Simek1-0/+33
Find out the highest alias ID used for certain subsystem. This call will be used for alocating IDs for i2c buses which are not described in DT. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-02-02Merge tag 'for-master-20190201' of git://git.denx.de/u-boot-rockchipTom Rini1-1/+3
u-boot-rockchip changes for 2019.04-rc1: * support for Chromebook Bob * full pinctrl driver using DTS properties * documentation improvements * I2S support for some Rockchip SoCs
2019-02-02lmb: handle more than one DRAM BANKSimon Goldschmidt1-5/+32
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank. This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp. Found-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-02-01lib: Allow using display_buffer() in SPLSimon Glass1-1/+3
At present this function uses printf() format strings that are not supported in SPL, so the output just consists of %llx strings on 64-bit. machines. Fix this by adding a special case. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2019-01-26hashtable: remove caps bufferHeinrich Schuchardt1-2/+1
slre_match() checks if caps == NULL. In this case it does not try to update it. So there is no need to create a buffer caps which we do not evaluate. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-01-26lib: lmb: cleanup var names and patman warningsSimon Goldschmidt1-44/+42
Change multiple usages of 'j' into 'rgn'; fix whitespace/coding style reported by patman. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-01-26lib: lmb: rename lmb_get_unreserved_size to lmb_get_free_sizeSimon Goldschmidt1-1/+1
As a follow-up, change the name of the newly introduced function 'lmb_get_unreserved_size' to 'lmb_get_free_size', which is more appropriate. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> [trini: Fix test/lib/lmb.c] Signed-off-by: Tom Rini <trini@konsulko.com>