summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* efi_loader: implement a file deleteAKASHI Takahiro2018-09-231-1/+13
| | | | | | | | 'Delete' will be implemented here by calling fs_unlink() which relies on underlying file system's implementation. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: file: support creating a directoryAKASHI Takahiro2018-09-231-4/+10
| | | | | | | | | | | | | In efi world, there is no obvious "mkdir" interface, instead, Open() with EFI_FILE_MODE_CREATE in mode parameter and EFI_FILE_DIRECTORY in attributes parameter creates a directory. In this patch, efi_file_open() is extended so as to accept such a combination of parameters and call u-boot's mkdir interface for expected action. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: typos in efi_console.cHeinrich Schuchardt2018-09-231-4/+4
| | | | | | | Fix a few typos. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: struct efi_simple_text_input_protocolHeinrich Schuchardt2018-09-232-4/+4
| | | | | | | | | | | | | | %s/efi_simple_input_interface/efi_simple_text_input_protocol/ We should be consistent in the naming of the EFI protocol interface structures. The protocol is called EFI_SIMPLE_TEXT_INPUT_PROTOCOL. %s/ExtendedVerification/extended_verification/ Use consistent naming of function parameters. Do not use CamelCase. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_selftest: EFI_UNICODE_COLLATION_PROTOCOLHeinrich Schuchardt2018-09-232-0/+261
| | | | | | | Provide a unit test for the EFI_UNICODE_COLLATION_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: EFI_UNICODE_COLLATION_PROTOCOLHeinrich Schuchardt2018-09-233-3/+347
| | | | | | | The patch implements the EFI_UNICODE_COLLATION_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* lib: charset: upper/lower case conversionHeinrich Schuchardt2018-09-232-0/+57
| | | | | | | Provide functions for upper and lower case conversion. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Add console handle references to in/out/errAlexander Graf2018-09-231-0/+6
| | | | | | | | | | | We register the console in/out protocol on the loaded image handle, but never tell anyone about it in the systab. Because of this Shell.efi can not find the input protocol. So let's add a proper reference. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: use correct documentation styleHeinrich Schuchardt2018-09-231-1/+1
| | | | | | | | | We have moved generating html documentation with Sphinx. %s/Return Value/Return/g Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: description efi_update_capsule()Heinrich Schuchardt2018-09-231-1/+1
| | | | | | | Correct the description of efi_update_capsule(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix typos in efi_runtime.cHeinrich Schuchardt2018-09-231-7/+8
| | | | | | | Fix multiple typos Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix typos in efi_boottime.cHeinrich Schuchardt2018-09-231-21/+21
| | | | | | | Fix numerous typos. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* Revert "Revert "efi_loader: efi_allocate_pages is too restrictive""Stephen Warren2018-09-231-1/+1
| | | | | | | | | | This reverts commit ccfc78b820e5e431c5bd73b072e7536a972e1710. Now that the underlying issue is fixed, we can revert the revert and hence restore the original EFI code. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* lib: charset: remove obsolete functionsHeinrich Schuchardt2018-09-231-79/+0
| | | | | | | | | | Remove functions: - utf8_to_utf16() - utf16_strcpy() - utf16_strdup() Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: don't use unlimited stack as bufferHeinrich Schuchardt2018-09-231-7/+13
| | | | | | | | | The length of a string printed to the console by the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is not limited by the UEFI spec. Hence should not allocate a buffer for it on the stack. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: remove limit on variable lengthHeinrich Schuchardt2018-09-231-22/+30
| | | | | | | | The EFI spec does not provide a length limit for variables. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* lib: vsprintf: correct printing of Unicode stringsHeinrich Schuchardt2018-09-231-9/+4
| | | | | | | | The width and precision of the printf() function refer to the number of characters not to the number of bytes printed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* test: unit tests for Unicode functionsHeinrich Schuchardt2018-09-231-1/+3
| | | | | | | Provide unit tests for Unicode functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* lib: charset: utility functions for UnicodeHeinrich Schuchardt2018-09-231-3/+233
| | | | | | | | | | | | | | | utf8_get() - get next UTF-8 code point from buffer utf8_put() - write UTF-8 code point to buffer utf8_utf16_strnlen() - length of a utf-8 string after conversion to utf-16 utf8_utf16_strncpy() - copy a utf-8 string to utf-16 utf16_get() - get next UTF-16 code point from buffer utf16_put() - write UTF-16 code point to buffer utf16_strnlen() - number of codes points in a utf-16 string utf16_utf8_strnlen() - length of a utf-16 string after conversion to utf-8 utf16_utf8_strncpy() - copy a utf-16 string to utf-8 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: rename utf16_strlen, utf16_strnlenHeinrich Schuchardt2018-09-236-8/+12
| | | | | | | | | | | The function names utf16_strlen() and utf16_strnlen() are misnomers. The functions do not count utf-16 characters but non-zero words. So let's rename them to u16_strlen and u16_strnlen(). In utf16_dup() avoid assignment in if clause. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* lib: build charset.o only if neededHeinrich Schuchardt2018-09-232-5/+12
| | | | | | | charset.o is only needed for the EFI subsystem Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* vsprintf.c: use #if CONFIG_IS_ENABLED(EFI_LOADER)Heinrich Schuchardt2018-09-231-4/+4
| | | | | | | | Using CONFIG_IS_ENABLED(EFI_LOADER) allows to simply the #if statements. Suggested-by: Alexander Graf <agraf@suse.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Pass address to fs_read()Alexander Graf2018-09-231-1/+4
| | | | | | | | | | | | | The fs_read() function wants to get an address rather than the pointer to a buffer. So let's convert the passed buffer from pointer back a the address to make efi_loader on sandbox happier. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>