
From: Simon Glass <sjg@chromium.org> In some cases we don't have a particular address to read into so would like one reserved. Adjust this function to support that. For now, sysbot_read_file() fails if the address is not provided. This will be resolved in a later patch. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootmeth_extlinux.c | 9 +++------ boot/bootmeth_pxe.c | 11 ++++------- boot/pxe_utils.c | 7 ++----- boot/vbe_abrec_os.c | 11 ++++------- cmd/pxe.c | 7 +++++-- cmd/sysboot.c | 11 ++++++----- include/pxe_utils.h | 8 +++++--- 7 files changed, 29 insertions(+), 35 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index cc086cdef0c..5a4fefbd868 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -36,19 +36,16 @@ static int extlinux_get_state_desc(struct udevice *dev, char *buf, int maxsize) } static int extlinux_getfile(struct pxe_context *ctx, const char *file_path, - char *file_addr, enum bootflow_img_t type, + ulong *addrp, ulong align, enum bootflow_img_t type, ulong *sizep) { struct extlinux_info *info = ctx->userdata; - ulong addr; int ret; - addr = simple_strtoul(file_addr, NULL, 16); - /* Allow up to 1GB */ *sizep = 1 << 30; - ret = bootmeth_read_file(info->dev, info->bflow, file_path, &addr, 0, - type, sizep); + ret = bootmeth_read_file(info->dev, info->bflow, file_path, addrp, + align, type, sizep); if (ret) return log_msg_ret("read", ret); diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 1025c5acb6c..3c558266a14 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -23,19 +23,16 @@ #include <pxe_utils.h> static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, - char *file_addr, enum bootflow_img_t type, - ulong *sizep) + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *sizep) { struct extlinux_info *info = ctx->userdata; - ulong addr; int ret; - addr = simple_strtoul(file_addr, NULL, 16); - /* Allow up to 1GB */ *sizep = 1 << 30; - ret = bootmeth_read_file(info->dev, info->bflow, file_path, &addr, 0, - type, sizep); + ret = bootmeth_read_file(info->dev, info->bflow, file_path, addrp, + align, type, sizep); if (ret) return log_msg_ret("read", ret); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 99d8cfbe496..da4e25128c0 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -94,7 +94,7 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len) * * @ctx: PXE context * @file_path: File path to read (relative to the PXE file) - * @file_addr: Address to load file to + * @addr: Address to load file to * @filesizep: If not NULL, returns the file size in bytes * Returns 1 for success, or < 0 on error */ @@ -104,7 +104,6 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path, { size_t path_len; char relfile[MAX_TFTP_PATH_LEN + 1]; - char addr_buf[18]; ulong size; int ret; @@ -125,9 +124,7 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path, printf("Retrieving file: %s\n", relfile); - sprintf(addr_buf, "%lx", file_addr); - - ret = ctx->getfile(ctx, relfile, addr_buf, type, &size); + ret = ctx->getfile(ctx, relfile, &file_addr, 0, type, &size); if (ret < 0) return log_msg_ret("get", ret); if (filesizep) diff --git a/boot/vbe_abrec_os.c b/boot/vbe_abrec_os.c index ed4e4ab3dff..ea23c61f69c 100644 --- a/boot/vbe_abrec_os.c +++ b/boot/vbe_abrec_os.c @@ -43,19 +43,16 @@ static enum vbe_pick_t find_pick(const char *name) } static int vbe_abrec_getfile(struct pxe_context *ctx, const char *file_path, - char *file_addr, enum bootflow_img_t type, - ulong *sizep) + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *sizep) { struct extlinux_info *info = ctx->userdata; - ulong addr; int ret; - addr = simple_strtoul(file_addr, NULL, 16); - /* Allow up to 1GB */ *sizep = 1 << 30; - ret = bootmeth_read_file(info->dev, info->bflow, file_path, &addr, 0, - type, sizep); + ret = bootmeth_read_file(info->dev, info->bflow, file_path, addrp, + align, type, sizep); if (ret) return log_msg_ret("read", ret); diff --git a/cmd/pxe.c b/cmd/pxe.c index b5f2ff7cb6b..9f40f13c201 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -26,13 +26,16 @@ const char *pxe_default_paths[] = { }; static int do_get_tftp(struct pxe_context *ctx, const char *file_path, - char *file_addr, enum bootflow_img_t type, ulong *sizep) + ulong *addrp, ulong align, enum bootflow_img_t type, + ulong *sizep) { int ret; if (IS_ENABLED(CONFIG_NET_LWIP)) return -ENOTSUPP; - ret = netboot_run(TFTPGET, hextoul(file_addr, NULL), file_path, 0, + if (!*addrp) + return -ENOTSUPP; + ret = netboot_run(TFTPGET, *addrp, file_path, 0, ctx->use_ipv6); if (ret) return log_msg_ret("tfp", ret); diff --git a/cmd/sysboot.c b/cmd/sysboot.c index 1dad64c9ac5..e6f89c999cc 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -23,19 +23,20 @@ struct sysboot_info { }; static int sysboot_read_file(struct pxe_context *ctx, const char *file_path, - char *file_addr, enum bootflow_img_t type, - ulong *sizep) + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *sizep) { struct sysboot_info *info = ctx->userdata; loff_t len_read; - ulong addr; int ret; - addr = simple_strtoul(file_addr, NULL, 16); + if (!*addrp) + return -ENOTSUPP; + ret = fs_set_blk_dev(info->ifname, info->dev_part_str, info->fstype); if (ret) return ret; - ret = fs_legacy_read(file_path, addr, 0, 0, &len_read); + ret = fs_legacy_read(file_path, *addrp, 0, 0, &len_read); if (ret) return ret; *sizep = len_read; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 58301a78b03..663b631a969 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -97,13 +97,15 @@ struct pxe_context; * * @ctx: PXE context * @file_path: Full path to filename to read - * @file_addr: String containing the to which to read the file + * @addrp: On entry, address to load file or 0 to reserve an address with lmb; + * on exit, address to which the file was loaded + * @align: Reservation alignment, if using lmb * @type: File type * @fileszeip: Returns file size */ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, - char *file_addr, enum bootflow_img_t type, - ulong *filesizep); + ulong *addrp, ulong align, + enum bootflow_img_t type, ulong *filesizep); /** * struct pxe_context - context information for PXE parsing -- 2.43.0