"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

boot: Update extlinux pxe_getfile_func() to include type

Add a file-type parameter to this function and update all users. Add a
proper comment to the function which we are here.

This will allow tracking of the file types loaded by the extlinux
bootmeth.

Signed-off-by: Simon Glass <sjg@chromium.org>

authored by

Simon Glass and committed by
Tom Rini
3ed218e2 ea7f88f3

+42 -16
+3 -2
boot/bootmeth_extlinux.c
··· 68 68 } 69 69 70 70 static int extlinux_getfile(struct pxe_context *ctx, const char *file_path, 71 - char *file_addr, ulong *sizep) 71 + char *file_addr, enum bootflow_img_t type, 72 + ulong *sizep) 72 73 { 73 74 struct extlinux_info *info = ctx->userdata; 74 75 ulong addr; ··· 79 80 /* Allow up to 1GB */ 80 81 *sizep = 1 << 30; 81 82 ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, 82 - (enum bootflow_img_t)IH_TYPE_INVALID, sizep); 83 + type, sizep); 83 84 if (ret) 84 85 return log_msg_ret("read", ret); 85 86
+3 -2
boot/bootmeth_pxe.c
··· 23 23 #include <pxe_utils.h> 24 24 25 25 static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, 26 - char *file_addr, ulong *sizep) 26 + char *file_addr, enum bootflow_img_t type, 27 + ulong *sizep) 27 28 { 28 29 struct extlinux_info *info = ctx->userdata; 29 30 ulong addr; ··· 34 35 /* Allow up to 1GB */ 35 36 *sizep = 1 << 30; 36 37 ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, 37 - IH_TYPE_INVALID, sizep); 38 + type, sizep); 38 39 if (ret) 39 40 return log_msg_ret("read", ret); 40 41
+18 -8
boot/pxe_utils.c
··· 6 6 7 7 #define LOG_CATEGORY LOGC_BOOT 8 8 9 + #include <bootflow.h> 9 10 #include <command.h> 10 11 #include <dm.h> 11 12 #include <env.h> ··· 97 98 * Returns 1 for success, or < 0 on error 98 99 */ 99 100 static int get_relfile(struct pxe_context *ctx, const char *file_path, 100 - unsigned long file_addr, ulong *filesizep) 101 + unsigned long file_addr, enum bootflow_img_t type, 102 + ulong *filesizep) 101 103 { 102 104 size_t path_len; 103 105 char relfile[MAX_TFTP_PATH_LEN + 1]; ··· 124 126 125 127 sprintf(addr_buf, "%lx", file_addr); 126 128 127 - ret = ctx->getfile(ctx, relfile, addr_buf, &size); 129 + ret = ctx->getfile(ctx, relfile, addr_buf, type, &size); 128 130 if (ret < 0) 129 131 return log_msg_ret("get", ret); 130 132 if (filesizep) ··· 140 142 int err; 141 143 char *buf; 142 144 143 - err = get_relfile(ctx, file_path, file_addr, &size); 145 + err = get_relfile(ctx, file_path, file_addr, BFI_EXTLINUX_CFG, 146 + &size); 144 147 if (err < 0) 145 148 return err; 146 149 ··· 189 192 * @file_path: File path to read (relative to the PXE file) 190 193 * @envaddr_name: Name of environment variable which contains the address to 191 194 * load to 195 + * @type: File type 192 196 * @filesizep: Returns the file size in bytes 193 197 * Returns 1 on success, -ENOENT if @envaddr_name does not exist as an 194 198 * environment variable, -EINVAL if its format is not valid hex, or other 195 199 * value < 0 on other error 196 200 */ 197 201 static int get_relfile_envaddr(struct pxe_context *ctx, const char *file_path, 198 - const char *envaddr_name, ulong *filesizep) 202 + const char *envaddr_name, 203 + enum bootflow_img_t type, ulong *filesizep) 199 204 { 200 205 unsigned long file_addr; 201 206 char *envaddr; ··· 207 212 if (strict_strtoul(envaddr, 16, &file_addr) < 0) 208 213 return -EINVAL; 209 214 210 - return get_relfile(ctx, file_path, file_addr, filesizep); 215 + return get_relfile(ctx, file_path, file_addr, type, filesizep); 211 216 } 212 217 213 218 /** ··· 395 400 396 401 /* Load overlay file */ 397 402 err = get_relfile_envaddr(ctx, overlayfile, "fdtoverlay_addr_r", 403 + (enum bootflow_img_t)IH_TYPE_FLATDT, 398 404 NULL); 399 405 if (err < 0) { 400 406 printf("Failed loading overlay %s\n", overlayfile); ··· 480 486 } 481 487 482 488 if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", 483 - NULL) < 0) { 489 + (enum bootflow_img_t)IH_TYPE_KERNEL, NULL) 490 + < 0) { 484 491 printf("Skipping %s for failure retrieving kernel\n", 485 492 label->name); 486 493 return 1; ··· 506 513 } else if (label->initrd) { 507 514 ulong size; 508 515 if (get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", 516 + (enum bootflow_img_t)IH_TYPE_RAMDISK, 509 517 &size) < 0) { 510 518 printf("Skipping %s for failure retrieving initrd\n", 511 519 label->name); ··· 651 659 652 660 if (fdtfile) { 653 661 int err = get_relfile_envaddr(ctx, fdtfile, 654 - "fdt_addr_r", NULL); 662 + "fdt_addr_r", 663 + (enum bootflow_img_t)IH_TYPE_FLATDT, NULL); 655 664 656 665 free(fdtfilefree); 657 666 if (err < 0) { ··· 1538 1547 if (IS_ENABLED(CONFIG_CMD_BMP)) { 1539 1548 /* display BMP if available */ 1540 1549 if (cfg->bmp) { 1541 - if (get_relfile(ctx, cfg->bmp, image_load_addr, NULL)) { 1550 + if (get_relfile(ctx, cfg->bmp, image_load_addr, 1551 + BFI_LOGO, NULL)) { 1542 1552 #if defined(CONFIG_VIDEO) 1543 1553 struct udevice *dev; 1544 1554
+1 -1
cmd/pxe.c
··· 27 27 }; 28 28 29 29 static int do_get_tftp(struct pxe_context *ctx, const char *file_path, 30 - char *file_addr, ulong *sizep) 30 + char *file_addr, enum bootflow_img_t type, ulong *sizep) 31 31 { 32 32 char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; 33 33 int ret;
+4 -2
cmd/sysboot.c
··· 23 23 }; 24 24 25 25 static int sysboot_read_file(struct pxe_context *ctx, const char *file_path, 26 - char *file_addr, ulong *sizep) 26 + char *file_addr, enum bootflow_img_t type, 27 + ulong *sizep) 27 28 { 28 29 struct sysboot_info *info = ctx->userdata; 29 30 loff_t len_read; ··· 110 111 return CMD_RET_FAILURE; 111 112 } 112 113 113 - if (get_pxe_file(&ctx, filename, pxefile_addr_r) < 0) { 114 + if (get_pxe_file(&ctx, filename, pxefile_addr_r) 115 + < 0) { 114 116 printf("Error reading config file\n"); 115 117 pxe_destroy_ctx(&ctx); 116 118 return 1;
+13 -1
include/pxe_utils.h
··· 3 3 #ifndef __PXE_UTILS_H 4 4 #define __PXE_UTILS_H 5 5 6 + #include <bootflow.h> 6 7 #include <linux/list.h> 7 8 8 9 /* ··· 82 83 }; 83 84 84 85 struct pxe_context; 86 + 87 + /** 88 + * Read a file 89 + * 90 + * @ctx: PXE context 91 + * @file_path: Full path to filename to read 92 + * @file_addr: String containing the to which to read the file 93 + * @type: File type 94 + * @fileszeip: Returns file size 95 + */ 85 96 typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, 86 - char *file_addr, ulong *filesizep); 97 + char *file_addr, enum bootflow_img_t type, 98 + ulong *filesizep); 87 99 88 100 /** 89 101 * struct pxe_context - context information for PXE parsing