aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_device_path_to_text.c
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: Remove <common.h>Tom Rini2023-12-211-1/+0
| | | | | | | | | We largely do not need <common.h> in these files, so drop it. The only exception here is that efi_freestanding.c needs <linux/types.h> and had been getting that via <common.h>. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: simplify efi_str_to_u16()Heinrich Schuchardt2023-03-251-3/+2
| | | | | | | Use efi_alloc() to allocate memory. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* efi_loader: support for Ctrl() device path nodeHeinrich Schuchardt2023-03-251-0/+7
| | | | | | | | | * Add the definitions for Ctrl() device path nodes. * Implement Ctrl() nodes in the device path to text protocol. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: fix display of NVMe EUI-64Heinrich Schuchardt2022-09-031-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | UEFI specification 2.9A requires to display the EUI-64 "in hexadecimal format with byte 7 first (i.e., on the left) and byte 0 last". This is in contrast to what the NVMe specification wants. But it is what EDK II has been implementing. Here is an example with the patch applied: qemu-system-aarch64 -machine virt -cpu cortex-a72 -nographic \ -bios denx/u-boot.bin \ -device nvme,id=nvme1,serial=9ff81223 \ -device nvme-ns,bus=nvme1,drive=nvme1n0,eui64=0x123456789ABCDEF0 \ -drive file=arm64.img,if=none,format=raw,id=nvme1n0 => nvme scan => efidebug devices Device Path ==================== /VenHw(…)/NVMe(0x1,f0-de-bc-9a-78-56-34-12) Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: fix efi_convert_device_path_to_text()Heinrich Schuchardt2022-08-131-0/+1
| | | | | | | | | Ensure that the string we convert to UTF-16 is NUL terminated even if the device path only contains end nodes. Fixes: bd3d75bb0c58 ("efi_loader: multi part device paths to text") Addresses-Coverity: 350434 ("Uninitialized scalar variable") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: fix text output for Uart() DP nodesHeinrich Schuchardt2022-02-051-9/+19
| | | | | | | | | | | | | The UEFI specification concerning Uart() device path nodes has been clarified: Parity and stop bits can either both use keywords or both use numbers but numbers and keywords should not be mixed. Let's go for keywords as this is what EDK II does. For illegal values fall back to numbers. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: fix device path to text protocolHeinrich Schuchardt2022-02-051-4/+13
| | | | | | | | | | The printing of a file path node must properly handle: * odd length of the device path node * UTF-16 character only partially contained in device path node * buffer overflow due to very long file path Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* doc: replace @return by Return:Heinrich Schuchardt2022-01-191-4/+4
| | | | | | | | | | | | Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: use EfiBootServicesData for DP to textHeinrich Schuchardt2021-08-171-1/+1
| | | | | | | Memory allocated in the implementation of the EFI_DEVICE_PATH_TO_TEXT_PROTOCOL must be of type EfiBootServicesData. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: Uri() device path nodeHeinrich Schuchardt2021-08-141-0/+13
| | | | | | | iPXE used Uri() device path nodes. So we should support them in the device path to text protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Uart device path missing breakHeinrich Schuchardt2021-03-311-0/+2
| | | | | | | | | In the devicepath node to text conversion for Uart nodes a break statement is missing. Indicated by Coverity Scan CID 330038 Fixes: 62df6e9c9994 ("efi_loader: Uart device path") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Uart device pathHeinrich Schuchardt2021-03-191-0/+13
| | | | | | | | | | When uploading an EFI binary via the UART we need to assign a device path. * Provide devicepath node to text conversion for Uart() node. * Provide function to create Uart() device path. * Add UART support to efi_dp_from_name(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: limit output length for VenHw, VenMediaHeinrich Schuchardt2021-02-261-2/+4
| | | | | | | | | | | | | | VenHw and VenMedia device path nodes may carry vendor defined data of arbitrary length. When converting a device path node to text ensure that we do not overrun our internal buffer. In our implementation of EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() we could first determine the output length and then allocate buffers but that would nearly double the code size. Therefore keep the preallocated buffers and truncate excessive device paths instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: multi part device paths to textHeinrich Schuchardt2021-02-211-5/+12
| | | | | | | | | | | | Our current implementation of EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() truncates multi part device paths after the first part. We should convert all parts. Render device path instance ends as commas. This is not explicitly described in the UEFI spec but mimics what EDK II does. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: VenMedia device path nodeHeinrich Schuchardt2021-02-041-0/+15
| | | | | | | | | The Load File2 protocol exposes a device path with a VenMedia() node. Hence our implementation of the device path to text protocol should support this node. Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: device path for SATA devicesHeinrich Schuchardt2020-05-211-0/+10
| | | | | | | | | | | | | | | | | | Provide device path nodes for SATA devices. This avoids creation of two handles with the same device path indicating our root node. This is what the device paths for a SATA drive with four partitions could like: /VenHw(..)/Sata(0x0,0xffff,0x0) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(1,MBR,0x81ea591f,0x800,0x63ff830) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(2,MBR,0x81ea591f,0x6400800,0x9ff830) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(3,MBR,0x81ea591f,0x6e00800,0x16ef2ab0) /VenHw(..)/Sata(0x0,0xffff,0x0)/HD(4,MBR,0x81ea591f,0x1dcf3800,0x1dcedab0) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* common: Drop part.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi: device path for nvmePatrick Wildt2019-10-061-0/+15
| | | | | | | | | | | This allows our EFI API to create a device path node for NVMe devices. It adds the necessary device path struct, uses the nvme namespace accessor to retrieve the id and eui64, and also provides support for the device path text protocol. Signed-off-by: Patrick Wildt <patrick@blueri.se> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: eliminate inline function ascii2unicode()Heinrich Schuchardt2019-09-091-5/+5
| | | | | | | ascii2unicode() can only convert characters 0x00-0x7f from UTF-8 to UTF-16. Use utf8_utf16_strcpy() instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correctly render UsbClass DP nodes as textHeinrich Schuchardt2019-09-051-1/+1
| | | | | | Correct the text representation of UsbClass device path nodes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correctly render CD-ROM device path nodesHeinrich Schuchardt2019-09-051-1/+2
| | | | | | | | | | Correct the name of the partition size component in struct efi_device_path_cdrom_path. Render entry, start, and size when converting a CD-ROM device path node to text. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correctly render MAC address device path nodesHeinrich Schuchardt2019-09-051-8/+7
| | | | | | If the interface type is greater 1 render all 32 bytes of the MAC address. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: correct text conversion for vendor DPHeinrich Schuchardt2019-09-051-1/+10
| | | | | | | Vendor device paths may contain data. When converting vendor device paths to text this binary data has to be rendered. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: merge adjacent sprintf()Heinrich Schuchardt2019-05-191-3/+2
| | | | | | | In the implementation of the device path to text protocol join adjacent sprintf() statements. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: ACPI device node to textHeinrich Schuchardt2019-05-121-3/+3
| | | | | | | | | | | The device path to text protocol renders ACPI device nodes incorrectly. Use capital hexadecimal numbers as shown in the UEFI spec examples. Always output the optional UID. This matches what UEFI SCT expects and saves us an `if`. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix typosHeinrich Schuchardt2018-12-021-4/+4
| | | | | | | Fix typos in EFI subsystem comments. 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>
* SPDX: Convert a few files that were missed beforeTom Rini2018-05-101-2/+1
| | | | | | | | | | | As part of the main conversion a few files were missed. These files had additional whitespace after the '*' and before the SPDX tag and my previous regex was too strict. This time I did a grep for all SPDX tags and then filtered out anything that matched the correct styles. Fixes: 83d290c56fab ("SPDX: Convert all of our single license tags to Linux Kernel style") Reported-by: Heinrich Schuchardt <xypron.debian@gmx.de> Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: text output for device path end nodeHeinrich Schuchardt2018-01-221-0/+2
| | | | | | | | Without the patch a device path consisting only of an end node is displayed as '/UNKNOWN(007f,00ff)'. It should be displayed as '/'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: support device path for IDE and SCSI disksHeinrich Schuchardt2018-01-221-0/+14
| | | | | | | | | Correctly create the device path for IDE and SCSI disks. Support for SATA remains to be done in a future patch. 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: 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: 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: Add mem-mapped for fallbackRob Clark2017-10-121-0/+9
| | | | | | | | | | | | When we don't have a real device/image path, such as 'bootefi hello', construct a mem-mapped device-path. This fixes 'bootefi hello' after devicepath refactoring. Fixes: 95c5553ea2 ("efi_loader: refactor boot device and loaded_image handling") Signed-off-by: Rob Clark <robdclark@gmail.com> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: flesh out device-path to textRob Clark2017-09-201-63/+178
| | | | | | | | | | | It needs to handle more device-path node types, and also multiple levels of path hierarchy. To simplify this, initially construct utf8 string to a temporary buffer, and then allocate the real utf16 buffer that is returned. This should be mostly for debugging or at least not critical- path so an extra copy won't hurt, and is saner than the alternative. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: drop redundant efi_device_path_protocolRob Clark2017-09-201-5/+8
| | | | | | | This is really the same thing as the efi_device_path struct. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: add some missing breaksRob Clark2017-07-281-0/+2
| | | | | Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: implement ConvertDeviceNodeToTextxypron.glpk@gmx.de2017-07-241-30/+91
| | | | | | | | | | | | | | | | | Move the logic for converting a node to text from efi_convert_device_path_to_text to convert_device_node_to_text. Provide a wrapper function convert_device_node_to_text_ext. As we use only shallow device paths so we can call directly call efi_device_node_to_text from efi_device_path_to_text. Add output for MAC addresses. Add output for not yet supported types/subtypes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: implement EFI_DEVICE_PATH_TO_TEXT_PROTOCOLxypron.glpk@gmx.de2017-07-191-0/+67
ConvertPathToText is implemented for * type 4 - media device path * subtype 4 - file path This is the kind of device path we hand out for block devices. All other cases may be implemented later. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: fix whitespace] Signed-off-by: Alexander Graf <agraf@suse.de>