
From: Simon Glass <sjg@chromium.org> Several of the strings in this struct would be better off as addresses, now that they are passed around a fair bit. Start by converting initrd_addr_str to ulong Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/pxe_utils.c | 45 +++++++++++++++++++++------------------------ include/pxe_utils.h | 9 ++++----- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index c8532fad020..ada66d1ba7d 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -537,16 +537,15 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label, * @ctx: PXE context * @label: Label to process * @kernel_addr: String containing kernel address (cannot be NULL) - * @initrd_addr_str: String containing initrd address (NULL if none) - * @initrd_filesize: String containing initrd size (only used if - * @initrd_addr_str) - * @initrd_str: initrd string to process (only used if @initrd_addr_str) + * @initrd_addr: String containing initrd address (0 if none) + * @initrd_filesize: String containing initrd size (only used if @initrd_addr) + * @initrd_str: initrd string to process (only used if @initrd_addr) * @conf_fdt: string containing the FDT address * Return: does not return on success, or returns 0 if the boot command * returned, or -ve error value on error */ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, - char *kernel_addr, char *initrd_addr_str, + char *kernel_addr, ulong initrd_addr, char *initrd_filesize, char *initrd_str, const char *conf_fdt) { @@ -562,10 +561,9 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label, bmi.addr_img = kernel_addr; bootm_x86_set(&bmi, bzimage_addr, hextoul(kernel_addr, NULL)); - if (initrd_addr_str) { + if (initrd_addr) { bmi.conf_ramdisk = initrd_str; - bootm_x86_set(&bmi, initrd_addr, - hextoul(initrd_addr_str, NULL)); + bootm_x86_set(&bmi, initrd_addr, initrd_addr); bootm_x86_set(&bmi, initrd_size, hextoul(initrd_filesize, NULL)); } @@ -651,7 +649,7 @@ static int generate_localboot(struct pxe_label *label) static int label_boot(struct pxe_context *ctx, struct pxe_label *label) { char *kernel_addr = NULL; - char *initrd_addr_str = NULL; + ulong initrd_addr = 0; char initrd_filesize[10]; char initrd_str[28] = ""; char mac_str[29] = ""; @@ -713,23 +711,22 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) /* For FIT, the label can be identical to kernel one */ if (label->initrd && !strcmp(label->kernel_label, label->initrd)) { - initrd_addr_str = kernel_addr; + initrd_addr = hextoul(kernel_addr, NULL); } else if (label->initrd) { ulong size; int ret; ret = get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", (enum bootflow_img_t)IH_TYPE_RAMDISK, - &addr, &size); + &initrd_addr, &size); if (ret < 0) { printf("Skipping %s for failure retrieving initrd\n", label->name); goto cleanup; } strcpy(initrd_filesize, simple_xtoa(size)); - initrd_addr_str = env_get("ramdisk_addr_r"); - size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx", - initrd_addr_str, size); + size = snprintf(initrd_str, sizeof(initrd_str), "%lx:%lx", + initrd_addr, size); if (size >= sizeof(initrd_str)) goto cleanup; } @@ -806,8 +803,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ctx->no_boot) { ctx->label = label; ctx->kernel_addr = strdup(kernel_addr); - if (initrd_addr_str) { - ctx->initrd_addr_str = strdup(initrd_addr_str); + if (initrd_addr) { + ctx->initrd_addr = initrd_addr; ctx->initrd_filesize = strdup(initrd_filesize); ctx->initrd_str = strdup(initrd_str); } @@ -815,22 +812,22 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) log_debug("Saving label '%s':\n", label->name); log_debug("- kernel_addr '%s' conf_fdt '%s'\n", ctx->kernel_addr, ctx->conf_fdt); - if (initrd_addr_str) { - log_debug("- initrd addr '%s' filesize '%s' str '%s'\n", - ctx->initrd_addr_str, ctx->initrd_filesize, + if (initrd_addr) { + log_debug("- initrd addr %lx filesize '%s' str '%s'\n", + ctx->initrd_addr, ctx->initrd_filesize, ctx->initrd_str); } if (!ctx->kernel_addr || (conf_fdt && !ctx->conf_fdt) || - (initrd_addr_str && (!ctx->initrd_addr_str || - !ctx->initrd_filesize || !ctx->initrd_str))) { + (initrd_addr && + (!ctx->initrd_filesize || !ctx->initrd_str))) { printf("malloc fail (saving label)\n"); return 1; } return 0; } - label_run_boot(ctx, label, kernel_addr, initrd_addr_str, - initrd_filesize, initrd_str, conf_fdt); + label_run_boot(ctx, label, kernel_addr, initrd_addr, initrd_filesize, + initrd_str, conf_fdt); /* ignore the error value since we are going to fail anyway */ cleanup: @@ -1128,7 +1125,7 @@ int pxe_do_boot(struct pxe_context *ctx) return log_msg_ret("pxb", -ENOENT); ret = label_run_boot(ctx, ctx->label, ctx->kernel_addr, - ctx->initrd_addr_str, ctx->initrd_filesize, + ctx->initrd_addr, ctx->initrd_filesize, ctx->initrd_str, ctx->conf_fdt); if (ret) return log_msg_ret("lrb", ret); diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 663b631a969..448108a3886 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -126,10 +126,9 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * The following are only used when probing for a label * @label: Label to process * @kernel_addr: String containing kernel address (cannot be NULL) - * @initrd_addr_str: String containing initaddr address (NULL if none) - * @initrd_filesize: String containing initrd size (only used if - * @initrd_addr_str) - * @initrd_str: initrd string to process (only used if @initrd_addr_str) + * @initrd_addr: initaddr address (0 if none) + * @initrd_filesize: String containing initrd size (only used if @initrd_addr) + * @initrd_str: initrd string to process (only used if @initrd_addr) * @conf_fdt: string containing the FDT address * @restart: true to use BOOTM_STATE_RESTART instead of BOOTM_STATE_START (only * supported with FIT / bootm) @@ -160,7 +159,7 @@ struct pxe_context { /* information on the selected label to boot */ struct pxe_label *label; char *kernel_addr; - char *initrd_addr_str; + ulong initrd_addr; char *initrd_filesize; char *initrd_str; char *conf_fdt; -- 2.43.0