summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib: fdtdec: Fix some style violationsMario Six2018-01-211-14/+15
| | | | | | | | Fix some style violations in fdtdec.c, and reduce the scope of some variables. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
* lib: fdtdec: Fix whitespace style violationsMario Six2018-01-211-26/+30
| | | | | | | Fix some whitespace-related style violations in fdtdec.c. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
* fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATERob Clark2018-01-151-12/+23
| | | | | | | | | | | | | | Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc. In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot. Signed-off-by: Rob Clark <robdclark@gmail.com> [trini: Update board_fdt_blob_setup #if check] Signed-off-by: Tom Rini <trini@konsulko.com>
* Move CONFIG_PANIC_HANG to KconfigMasahiro Yamada2017-12-261-0/+10
| | | | | | | | Freescale (NXP) boards have lots of defconfig files per board. I used "imply PANIC_HANG" for them. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: York Sun <york.sun@nxp.com>
* efi_loader: Setup logical_partition media informationEmmanuel Vadot2017-12-191-0/+2
| | | | | | | | When adding a partition, set the logical_partition member in the media structure as mandated by the UEFI spec. Signed-off-by: Emmanuel Vadot <manu@freebsd.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: comments for dp_part_fill()Heinrich Schuchardt2017-12-161-1/+8
| | | | | | | | Add a description for dp_part_fill(). Reword a comment in the function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correct DeviceNodeToText for media typesHeinrich Schuchardt2017-12-161-12/+31
| | | | | | | | When converting device nodes and paths to text we should stick to the UEFI spec. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correctly setup device paths for block devicesHeinrich Schuchardt2017-12-161-2/+2
| | | | | | | | | | | According to the UEFI spec the numbering of partitions has to start with 1. Partion number 0 is reserved for the optional device path for the complete block device. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correctly determine if an MMC device is an SD-cardHeinrich Schuchardt2017-12-161-3/+21
| | | | | | | | The SD cards and eMMC devices have different device nodes. The current coding interpretes all MMC devices as eMMC. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: error handling in efi_load_image()Heinrich Schuchardt2017-12-161-16/+15
| | | | | | | | | | | | If a failure occurs when trying to load an image, it is insufficient to free() the EFI object. We must remove it from the object list, too. Otherwise a use after free will occur the next time we iterate over the object list. Furthermore errors in setting up the image should be handled. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: new function efi_delete_handle()Heinrich Schuchardt2017-12-161-86/+100
| | | | | | | | | | | Provide a function to remove a handle from the object list after removing all protocols. To avoid forward declarations other functions have to move up in the coding. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: return status from efi_setup_loaded_image()Heinrich Schuchardt2017-12-161-4/+7
| | | | | | | | | | efi_setup_loaded_image() should return an error code indicating if an error has occurred. An error occurs if a protocol cannot be installed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Ensure efi_dp_find_obj() finds exact matchesAlexander Graf2017-12-161-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When calling efi_dp_find_obj(), we usually want to find the *exact* match of an object for a given device path. However, I ran into a nasty corner case where I had the following objects with paths available: Handle 0x9feffa70 /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ]/USB(6,0)/EndEntire Handle 0x9feffb58 /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ]/USB(6,0)/HD(1,800,32000,2de808cb00000000,1,1)/EndEntire and was searching for /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ]/USB(6,0)/HD(1,800,32000,2de808cb00000000,1,1)/EndEntire But because our device path search looked for any substring match, it would return /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ]/USB(6,0)/EndEntire because that path is a full substring of the path we were searching for. So this patch adapts the device path search logic to always look for exact matches first. The way we distinguish between those cases is by looking at whether our caller actually deals with remainders. As a side effect, the code as is from all I can tell now never does a substring match anymore, because it always gets called with rem=NULL, so we always only do exact matches now. Reported-by: Jonathan Gray <jsg@jsg.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: helloworld.c: Explicitly use .rodata for loaded_image_guidAlexander Graf2017-12-161-1/+2
| | | | | | | | | | | | | | | | | | | | | Commit bbf75dd9345d0b ("efi_loader: output load options in helloworld") introduced a const variable in efi_main() called loaded_image_guid which got populated from a constant struct. While you would usually expect a compiler to realize that this variable should really just be a global pointer to .rodata, gcc disagrees and instead puts it on the stack. Unfortunately in some implementations of gcc it does so my calling memcpy() which we do not implement in our hello world environment. So let's explicitly move it to a global variable which in turn puts it in .rodata reliably and gets rid of the memcpy(). Fixes: bbf75dd9345d0b ("efi_loader: output load options in helloworld") Reported-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Florian Fainelli <f.fainelli@gmail.com>
* Merge tag 'signed-efi-next' of git://github.com/agraf/u-bootTom Rini2017-12-0525-597/+2206
|\ | | | | | | | | | | | | | | | | | | Patch queue for efi - 2017-12-05 Highlights for this release: - Dynamic EFI object creation (lists instead of static arrays) - EFI selftest improvements - Minor fixes
| * efi_stub: Use efi_uintn_tAlexander Graf2017-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | Commit f5a2a93892f ("efi_loader: consistently use efi_uintn_t in boot services") changed the internal EFI API header without adapting its existing EFI stub users. Let's adapt the EFI stub as well. Fixes: f5a2a93892f ("efi_loader: consistently use efi_uintn_t in boot services") Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader helloworld.efi: Fix building with -OsAlexander Graf2017-12-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Depending on your compiler, when compiling the hello world efi binary with -Os, gcc might think it's a smart idea to replace common patterns such as memory copies with explicit calls to memcpy(). While that sounds great at first, we don't have any memcpy() available in our helloworld build target. So let's indicate to gcc that we really do want to have the code be built as freestanding. Fixes: bbf75dd9 ("efi_loader: output load options in helloworld") Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: Fix partition offsetsAlexander Graf2017-12-011-47/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 884bcf6f65 (efi_loader: use proper device-paths for partitions) tried to introduce the el torito scheme to all partition table types: Spawn individual disk objects for each partition on a disk. Unfortunately, that code ended up creating partitions with offset=0 which meant that anyone accessing these objects gets data from the raw block device instead of the partition. Furthermore, all the el torito logic to spawn devices for partitions was duplicated. So let's merge the two code paths and give partition disk objects good offsets to work from, so that payloads can actually make use of them. Fixes: 884bcf6f65 (efi_loader: use proper device-paths for partitions) Reported-by: Yousaf Kaukab <yousaf.kaukab@suse.com> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: add missing breaksRob Clark2017-12-011-0/+2
| | | | | | | | | | | | | | | | | | | | Otherwise with GUID partition types you would end up with things like: .../HD(Part0,Sig6252c819-4624-4995-8d16-abc9cd5d4130)/HD(Part0,MBRType=02,SigType=02) Signed-off-by: Rob Clark <robdclark@gmail.com> [agraf: rebased] Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: comments for EFI_DEVICE_PATH_TO_TEXT_PROTOCOLHeinrich Schuchardt2017-12-011-0/+24
| | | | | | | | | | | | | | | | Provide comments for efi_convert_device_node_to_text() and efi_convert_device_path_to_text(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: helper function to add EFI object to listHeinrich Schuchardt2017-12-014-16/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid duplicate coding provide a helper function that initializes an EFI object and adds it to the EFI object list. efi_exit() is the only place where we dereference a handle to obtain a protocol interface. Add a comment to the function. Suggested-by: Alexander Graf <agraf@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: pass handle of loaded imageHeinrich Schuchardt2017-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | The handle of a loaded image is the value of the handle member of the loaded image info object and not the address of the loaded image info. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: output load options in helloworldHeinrich Schuchardt2017-12-011-2/+35
| | | | | | | | | | | | | | | | | | | | | | | | We need to test if we pass a valid image handle when loading and EFI application. This cannot be done in efi_selftest as it is not loaded as an image. So let's enhance helloworld a bit. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_selftest: add missing line feedHeinrich Schuchardt2017-12-011-1/+1
| | | | | | | | | | | | | | | | Add a missing line feed for an error message. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_selftest: compile without special compiler flagsHeinrich Schuchardt2017-12-011-25/+0
| | | | | | | | | | | | | | | | | | | | | | As the selftest is not compiled as an EFI binary we do not need special compiler flags. This avoids the checkarmreloc error on vexpress_ca15_tc2. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: manage protocols in a linked listHeinrich Schuchardt2017-12-014-56/+54
| | | | | | | | | | | | Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: simplify find_objHeinrich Schuchardt2017-12-011-24/+19
| | | | | | | | | | | | | | | | Use function efi_search_protocol(). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: simplify efi_open_protocolHeinrich Schuchardt2017-12-011-30/+6
| | | | | | | | | | | | | | | | Use function efi_search_protocol. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_gop: use efi_add_protocolHeinrich Schuchardt2017-12-011-5/+10
| | | | | | | | | | | | | | | | Use efi_add_protocol to add protocol. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_net: use efi_add_protocolHeinrich Schuchardt2017-12-011-14/+20
| | | | | | | | | | | | | | | | Use efi_add_protocol to add protocols. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_disk: use efi_add_protocolHeinrich Schuchardt2017-12-011-16/+23
| | | | | | | | | | | | | | | | Use efi_add_protocol to install protocols. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_selftest: test EFI_DEVICE_PATH_TO_TEXT_PROTOCOLHeinrich Schuchardt2017-12-012-0/+393
| | | | | | | | | | | | | | Provide a test for the EFI_DEVICE_PATH_TO_TEXT_PROTOCOL protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: reimplement LocateDevicePathHeinrich Schuchardt2017-12-011-30/+76
| | | | | | | | | | | | | | | | | | | | The current implementation of efi_locate_device_path does not match the UEFI specification. It completely ignores the protocol parameters. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: fix efi_convert_device_node_to_textHeinrich Schuchardt2017-12-011-66/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to implement to different functions for the EFI_DEVICE_PATH_TO_TEXT_PROTOCOL: ConvertDeviceNodeToText ConvertDevicePathToText A recent patch screwed up efi_convert_device_node_to_text to expect a device path and not a node. The patch makes both service functions work again. efi_convert_device_node_to_text is renamed to efi_convert_single_device_node_to_text and efi_convert_device_node_to_text_ext is renamed to efi_convert_device_node_to_text to avoid future confusion. A test of ConvertDeviceNodeToText will be provided in a follow-up patch. Fixes: adae4313cdd efi_loader: flesh out device-path to text Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_dp_str should print path not nodeHeinrich Schuchardt2017-12-011-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | efi_dp_str is meant to print a device path and not a device node. The old coding only worked because efi_convert_device_node_to_text was screwed up to expect paths instead of nodes. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: size of media device path node represenationHeinrich Schuchardt2017-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | In the format specifier we want to specify the maximum width in case an ending \0 is missing. So slen must be used as precision and not as field width. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: helloworld.c: remove superfluous includeHeinrich Schuchardt2017-12-011-1/+0
| | | | | | | | | | | | | | Remove a superfluous include from helloworld.c Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: initialise partition_signature memoryJonathan Gray2017-12-011-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Zero partition_signature in the efi_device_path_hard_drive_path structure when signature_type is 0 (no signature) as required by the UEFI specification. This is required so that efi_dp_match() will work as expected when doing memcmp() comparisons. Previously uninitialised memory would cause it not match nodes when it should have when the signature type was not GUID. Corrects a problem where the loaded image protocol would not return a device path with MEDIA_DEVICE causing the OpenBSD bootloader to fail on rpi_3 and other targets. v2: Also handle signature_type 1 (MBR) as described in the specification Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Tested-by: Artturi Alm <artturi.alm@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_console: use helper functionsHeinrich Schuchardt2017-12-011-13/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use helper functions efi_created_handle and efi_add_protocol for creating the console handles and instaling the respective protocols. This change is needed if we want to move from an array of protocols to a linked list of protocols. Eliminate EFI_PROTOCOL_OBJECT which is not used anymore. Currently we have not defined protocol interfaces to be const. So efi_con_out and efi_console_control cannot be defined as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: refactor efi_setup_loaded_imageHeinrich Schuchardt2017-12-011-14/+25
| | | | | | | | | | | | | | Use helper functions to add protocols. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: simplify efi_locate_protocolHeinrich Schuchardt2017-12-011-12/+6
| | | | | | | | | | | | | | | | | | Use helper function efi_search_protocol. Do not print protocol guid twice in debug mode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: simplify efi_uninstall_protocol_interfaceHeinrich Schuchardt2017-12-011-27/+11
| | | | | | | | | | | | | | | | Use function efi_search_obj, efi_search_protocol and efi_remove_protocol to simplify the coding. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: simplify efi_searchHeinrich Schuchardt2017-12-011-9/+6
| | | | | | | | | | | | | | | | | | Use helper function efi_search_protocol in efi_search. Add missing comments. Put default handling into default branch of switch statement. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: simplify efi_install_protocol_interfaceHeinrich Schuchardt2017-12-011-36/+2
| | | | | | | | | | | | | | Use helper functio efi_add_protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: helper functions for protocol managementHeinrich Schuchardt2017-12-011-0/+119
| | | | | | | | | | | | | | | | | | | | | | This patch provides helper functions to manage protocols. efi_search_protocol - find a protocol on a handle efi_add_protocol - install a protocol on a handle efi_remove_protocol - remove a protocol from a handle efi_remove_all_protocols - remove all protocols from a handle Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_selftest: test for graphics output protocolHeinrich Schuchardt2017-12-012-0/+98
| | | | | | | | | | | | | | Supply a test for the graphics output protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_gop: use correct types for parametersHeinrich Schuchardt2017-12-011-7/+7
| | | | | | | | | | | | | | | | | | | | Use efi_uintn_t instead of unsigned long. EFI_GRAPHICS_OUTPUT_BLT_OPERATION is an enum. If we don't define an enum we have to pass it as u32. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: argument of efi_search_obj should be constHeinrich Schuchardt2017-12-011-1/+1
| | | | | | | | | | | | | | | | The argument of efi_search_obj is not changed so it should be marked as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: make efi_create_handle non-staticHeinrich Schuchardt2017-12-011-1/+7
| | | | | | | | | | | | | | Export function efi_create_handle. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
| * efi_loader: efi_dp_match should have const argumentsHeinrich Schuchardt2017-12-011-1/+2
| | | | | | | | | | | | | | | | efi_dp_match does not change its arguments. So they should be marked as const. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>