summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_device_path.c
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: use EfiBootServicesData for device pathHeinrich Schuchardt2021-08-171-1/+1
| | | | | | | dp_alloc() was using a constant from the wrong enum resulting in creating device paths in EfiReservedMemory. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: set partition GUID in device path for SIG_TYPE_GUIDAlfonso Sánchez-Beato2021-07-181-2/+8
| | | | | | | | | | | Previously, the GPT device GUID was being used instead of the partition, which was incorrect. Signed-off-by: Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com> Let EFI_LOADER select CONFIG_PARTITION_UUIDS. Use log_warning() instead of printf() for warning. Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: path length in efi_dp_from_name()Heinrich Schuchardt2021-05-251-2/+7
| | | | | | | | | | Before this patch efi_dp_from_name() only accommodated a maximum file path length of 31 characters. This leads to boot failures due to file name truncation. Allow arbitrary path lengths. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Add device path related functions for initrd via Boot####Ilias Apalodimas2021-03-251-5/+105
| | | | | | | | | | | | | | | On the following patches we allow for an initrd path to be stored in Boot#### variables. Specifically we encode in the FIlePathList[] of the EFI_LOAD_OPTIONS for each Boot#### variable. The FilePathList[] array looks like this: kernel - 0xff - VenMedia(initrd GUID) - initrd1 - 0x01 initrd2 - 0xff So let's add the relevant functions to concatenate and retrieve a device path based on a Vendor GUID. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reformat function descriptions. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Uart device pathHeinrich Schuchardt2021-03-251-9/+32
| | | | | | | | | | 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>
* dm: Use access methods for dev/uclass private dataSimon Glass2021-01-051-1/+1
| | | | | | | | | | | Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
* dm: Avoid accessing seq directlySimon Glass2020-12-181-2/+2
| | | | | | | | | | At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead. The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass2020-12-131-7/+7
| | | | | | | | | | We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: efi_dp_check_length()Heinrich Schuchardt2020-08-241-0/+33
| | | | | | | | | | We need to check that device paths provided via UEFI variables are not malformed. Provide function efi_dp_check_length() to check if a device path has an end node within a given number of bytes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: device path for SATA devicesHeinrich Schuchardt2020-05-211-0/+21
| | | | | | | | | | | | | | | | | | 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>
* efi_loader: device path for virtio block devicesHeinrich Schuchardt2020-05-211-0/+30
| | | | | | | | | | | The UEFI specification does not define a device sub-type for virtio. Let's use a vendor hardware node here. This avoids creation of two handles with the same device path indicating our root node. Reported-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* common: Drop log.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* part: Drop disk_partition_t typedefSimon Glass2020-05-181-2/+2
| | | | | | | We should not be using typedefs and these make it harder to use forward declarations (to reduce header file inclusions). Drop the typedef. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop net.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | | | | | | Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: remove redundant assignment in dp_fill()Heinrich Schuchardt2020-05-071-1/+1
| | | | | | The value of dp is overwritten without being used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: remove unused function efi_dp_from_dev()Heinrich Schuchardt2019-11-191-16/+2
| | | | | | Function efi_dp_from_dev() is not used anywhere. Remove it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix efi_dp_from_name()Heinrich Schuchardt2019-11-121-3/+12
| | | | | | | | | | | Correctly check the return value of efi_dp_from_file(). If we can determine device path for the file, should not depend on the device path for the device being requested. Provide a function description for efi_dp_from_name(). Reported-by: Coverity CID 273159, CID 273158 Fixes: 08c51fff30cc ("efi_loader: device_path: check against file path length") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: device_path: check against file path lengthAKASHI Takahiro2019-10-171-2/+9
| | | | | | | | device_path strcuture has 2 bytes of "length" field, and so file path length should not exceed this limit, 65535. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi: device path for nvmePatrick Wildt2019-10-061-0/+20
| | | | | | | | | | | 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: device_path: support Sandbox's "host" devicesAKASHI Takahiro2019-09-201-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sandbox's "host" devices are currently described as UCLASS_ROOT udevice with DEV_IF_HOST block device. As the current implementation of efi_device_path doesn't support such a type, any "host" device on sandbox cannot be seen as a distinct object. For example, => host bind 0 /foo/disk.img => efi devices Scanning disk host0... Found 1 disks Device Device Path ================ ==================== 0000000015c19970 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) 0000000015c19d70 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) => efi dh Handle Protocols ================ ==================== 0000000015c19970 Device Path, Device Path To Text, Device Path Utilities, Unicode Collation 2, HII String, HII Database, HII Config Routing 0000000015c19ba0 Driver Binding 0000000015c19c10 Simple Text Output 0000000015c19c80 Simple Text Input, Simple Text Input Ex 0000000015c19d70 Block IO, Device Path, Simple File System As you can see here, efi_root (0x0000000015c19970) and host0 device (0x0000000015c19d70) have the same representation of device path. This is not only inconvenient, but also confusing since two different efi objects are associated with the same device path and efi_dp_find_obj() will possibly return a wrong result. Solution: Each "host" device should be given an additional device path node of "vendor device path" to make it distinguishable. 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: correctly render CD-ROM device path nodesHeinrich Schuchardt2019-09-051-1/+1
| | | | | | | | | | 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: efi_dp_from_file() expect UTF-8 pathHeinrich Schuchardt2019-07-161-9/+31
| | | | | | Properly convert UTF-8 file names to UTF-16. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: check length in CreateDeviceNode()Heinrich Schuchardt2019-04-231-0/+3
| | | | | | | When creating a device path node ensure that the size of the allocated memory at lest matches the size of the node header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: efi_setup_loaded_image() handle missing file nameAKASHI Takahiro2019-04-231-3/+4
| | | | | | | | | | | | | | | | | | This is a preparatory patch. efi_dp_split_file_path() is used to create device_path and file_path from file_path for efi_setup_loaded_image(). In a special case, however, of HARDWARE_DEVICE/MEMORY, it doesn't work expectedly since this path doesn't contain any FILE_PATH sub-type. This patch makes a workaround. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Adjust the logic such that for all paths that do no end on a media file path we return NULL as file_path. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: add protection for block_devPatrick Delaunay2019-04-121-1/+1
| | | | | | | | | | | | | Check the value of block_dev before to use this pointer. This patch solves problem for the command "load" when ubifs is previously mounted: in this case the function blk_get_device_part_str("ubi 0") don't return error but return block_dev = NULL and then data abort. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: remove stray #define LOG_CATEGORY LOGL_ERRHeinrich Schuchardt2019-04-121-2/+0
| | | | | | | The statement '#define LOG_CATEGORY LOGL_ERR' makes not sense. LOGL_ERR is not a LOG_CATEGORY. Remove the statement. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* 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: efi_dp_split_file_path() error handlingHeinrich Schuchardt2019-02-161-4/+12
| | | | | | | | | | | If the path passed to efi_dp_split_file_path() does not contain a reference to a file it returns EFI_OUT_OF_RESOURCES. This does not properly indicate the kind of the problem that occurred. Return EFI_INVALID_PARAMETER instead. Update function description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: allow device == NULL in efi_dp_from_name()AKASHI Takahiro2018-12-031-4/+7
| | | | | | | | | This is a preparatory patch for use in efi_serialize_load_option() as a load option's file_path should have both a device path and a file path. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix typos in efi_device_path.cHeinrich Schuchardt2018-12-021-11/+12
| | | | | | | Fix some typos in comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: add efi_dp_from_name()AKASHI Takahiro2018-12-021-0/+47
| | | | | | | | Factor out efi_set_bootdev() and extract efi_dp_from_name(). This function will be used to set a boot device in efishell command. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: eliminate handle memberHeinrich Schuchardt2018-12-021-1/+1
| | | | | | | | A pointer to a struct efi_object is a handle. We do not need any handle member in this structure. Let's eliminate it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: efi_dp_get_next_instance() superfluous statementHeinrich Schuchardt2018-10-161-1/+0
| | | | | | | Remove a superfluous statement in efi_dp_get_next_instance(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: create root nodeHeinrich Schuchardt2018-09-231-4/+0
| | | | | | | | | | 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>
* Remove <inttypes.h> includes and PRI* usages in printf() entirelyMasahiro Yamada2018-09-101-1/+0
| | | | | | | | | | | | | | | | In int-ll64.h, we always use the following typedefs: typedef unsigned int u32; typedef unsigned long uintptr_t; typedef unsigned long long u64; This does not need to match to the compiler's <inttypes.h>. Do not include it. The use of PRI* makes the code super-ugly. You can simply use "l" for printing uintptr_t, "ll" for u64, and no modifier for u32. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: complete EFI_DEVICE_PATH_UTILITIES_PROTOCOLHeinrich Schuchardt2018-04-231-0/+64
| | | | | | | | The missing services of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL are implemented. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correcty determine total device path lengthHeinrich Schuchardt2018-04-231-9/+25
| | | | | | | | | | | | | Device paths may consist of multiple instances. Up to now we have only considered the size of the first instance. For the services of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL in most cases the total length of the device path is relevant. So let's rename efi_dp_size() to efi_dp_instance_size() and create a new function efi_dp_size() that calculates the total device path length. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: correctly determine length of empty device pathHeinrich Schuchardt2018-04-231-0/+2
| | | | | | | | | | | efi_dp_size() is meant to return the device path length without the end node. The length of a device path containing only an end node was incorrectly reported as 4. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: fix AppendDevicePathHeinrich Schuchardt2018-04-231-3/+6
| | | | | | | | | | | | The logic of the AppendDevicePath service of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL is incorrectly implemented: * if both paths are NULL an end node has to be returned * if both paths are not NULL the end node of the second device path has to be kept Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: implement CreateDeviceNodeHeinrich Schuchardt2018-04-231-0/+15
| | | | | | | Implement the CreateDeviceNode service of the device path utility protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* Revert "Kconfig: cmd: Make networking command dependent on NET"Joe Hershberger2018-04-131-1/+1
| | | | | | | | | This reverts the parts of commit 3b3ea2c56ec4bc5588281fd103c744e608f8b25c where it changed the EFI dependency on NET. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Duncan Hare <dh@synoia.com>
* efi_loader: initialize device path on allocPatrick Wildt2018-04-041-0/+1
| | | | | | | | | | | Since the backing memory for a new device path can contain stale data we have to make sure that we zero the buffer. Otherwise some code paths that don't set all fields in a structure backed by this device path might contain unwanted stale data. Signed-off-by: Patrick Wildt <patrick@blueri.se> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: Fix network DP with DM_ETHAlexander Graf2018-04-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_DM_ETH is set, we assemble the device path properly with a full device hierarchy. Our helper function dp_fill() even put the MAC node itself in it for us. However, for non-DM compatibility we also have code in that added the MAC node manually. That code now runs on top of the existing MAC node: Handle 0x3db2f6b0 /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ] /USBClass(0,0,9,0,0)/USBClass(424,9514,9,0,2)/MacAddr(b8:27:eb:e1:81:47,1) /MacAddr(b8:27:eb:e1:81:47,57)/EndEntire We obviously don't need the additional node and in fact, grub chokes on it and fails to match the DP against the ethernet device node. So this patch moves the additional MAC node into the non-DM code path: Handle 0x3db3fde0 /HardwareVendor(e61d73b9-a384-4acc-aeab-82e828f3628b)[0: ] /USBClass(0,0,9,0,0)/USBClass(424,9514,9,0,2)/MacAddr(b8:27:eb:e1:81:47,1) /EndEntire While at it, we also mark the non-DM MAC node as ethernet. Fixes: b66c60dde9d ("efi_loader: add device-path utils") Signed-off-by: Alexander Graf <agraf@suse.de>
* Kconfig: cmd: Make networking command dependent on NETMichal Simek2018-02-271-1/+1
| | | | | | | | Enable networking command only when NET is enabled. And remove selecting NET for CMD_NET Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Tom Rini <trini@konsulko.com>
* efi_loader: allow creation of more device part nodesHeinrich Schuchardt2018-01-221-5/+49
| | | | | | | | | | | Create device path nodes for UCLASS_ETH udevices. Create device path nodes of block device children of UCLASS_MMC udevices. Consistently use debug for unsupported nodes. Set the log level to error. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> [agraf: Fix build failure by adding #ifdef CONFIG_DM_ETH] Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: provide function to get last node of a device pathHeinrich Schuchardt2018-01-221-0/+20
| | | | | | | | | | | On a block device and its partitions the same protocols can be installed. To tell the apart we can use the type of the last node of the device path which is not the end node. The patch provides a utility function to find this last node. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: provide a function to create a partition nodeHeinrich Schuchardt2018-01-221-36/+70
| | | | | | | | Provide new function efi_dp_part_node() to create a device node for a partition. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
* efi_loader: return NULL from device path functionsHeinrich Schuchardt2018-01-221-6/+36
| | | | | | | | | | | | | | For the construction of device paths we need to call the AllocatePool service. We should not ignore if it fails due to an out of memory situation. This patch changes the device path functions to return NULL if the memory allocation fails. Additional patches will be needed to fix the callers. 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/+64
| | | | | | | | | 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>