diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2018-10-17 16:32:03 +0900 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-12-02 21:59:36 +0100 |
commit | f1589ffb33a798ddb9391dcbab0ddaea2643c2c8 (patch) | |
tree | 211b185143c326d8a6ad74e1dcb6847accb4f2a1 /lib | |
parent | b0c78d8ffc9fe8b0388353d72e9f2b9e9c6107c6 (diff) | |
download | u-boot-f1589ffb33a798ddb9391dcbab0ddaea2643c2c8.zip u-boot-f1589ffb33a798ddb9391dcbab0ddaea2643c2c8.tar.gz u-boot-f1589ffb33a798ddb9391dcbab0ddaea2643c2c8.tar.bz2 |
efi_loader: add efi_dp_from_name()
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_loader/efi_device_path.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 2b5d067..adb9938 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -941,3 +941,50 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path, *file_path = fp; return EFI_SUCCESS; } + +efi_status_t efi_dp_from_name(const char *dev, const char *devnr, + const char *path, + struct efi_device_path **device, + struct efi_device_path **file) +{ + int is_net; + struct blk_desc *desc = NULL; + disk_partition_t fs_partition; + int part = 0; + char filename[32] = { 0 }; /* dp->str is u16[32] long */ + char *s; + + if (!device || (path && !file)) + return EFI_INVALID_PARAMETER; + + is_net = !strcmp(dev, "Net"); + if (!is_net) { + part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition, + 1); + if (part < 0) + return EFI_INVALID_PARAMETER; + + *device = efi_dp_from_part(desc, part); + } else { +#ifdef CONFIG_NET + *device = efi_dp_from_eth(); +#endif + } + + if (!path) + return EFI_SUCCESS; + + if (!is_net) { + /* Add leading / to fs paths, because they're absolute */ + snprintf(filename, sizeof(filename), "/%s", path); + } else { + snprintf(filename, sizeof(filename), "%s", path); + } + /* DOS style file path: */ + s = filename; + while ((s = strchr(s, '/'))) + *s++ = '\\'; + *file = efi_dp_from_file(NULL, 0, filename); + + return EFI_SUCCESS; +} |