"Das U-Boot" Source Tree
0
fork

Configure Feed

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

bootmeth: Update the read_file() method to include a type

We want to record the type of each file which is loaded. Add an new
parameter for this, to the read_file() method. Update all users.

Make bootmeth_common_read_file() store information about the image that
is read.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

authored by

Simon Glass and committed by
Tom Rini
aa0ba7fb d4c60aa9

+37 -20
+8 -3
boot/bootmeth-uclass.c
··· 84 84 } 85 85 86 86 int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow, 87 - const char *file_path, ulong addr, ulong *sizep) 87 + const char *file_path, ulong addr, 88 + enum bootflow_img_t type, ulong *sizep) 88 89 { 89 90 const struct bootmeth_ops *ops = bootmeth_get_ops(dev); 90 91 91 92 if (!ops->read_file) 92 93 return -ENOSYS; 93 94 94 - return ops->read_file(dev, bflow, file_path, addr, sizep); 95 + return ops->read_file(dev, bflow, file_path, addr, type, sizep); 95 96 } 96 97 97 98 int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow) ··· 394 395 } 395 396 396 397 int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, 397 - const char *file_path, ulong addr, ulong *sizep) 398 + const char *file_path, ulong addr, 399 + enum bootflow_img_t type, ulong *sizep) 398 400 { 399 401 struct blk_desc *desc = NULL; 400 402 loff_t len_read; ··· 422 424 if (ret) 423 425 return ret; 424 426 *sizep = len_read; 427 + 428 + if (!bootflow_img_add(bflow, bflow->fname, type, addr, size)) 429 + return log_msg_ret("bci", -ENOMEM); 425 430 426 431 return 0; 427 432 }
+2 -1
boot/bootmeth_android.c
··· 298 298 } 299 299 300 300 static int android_read_file(struct udevice *dev, struct bootflow *bflow, 301 - const char *file_path, ulong addr, ulong *sizep) 301 + const char *file_path, ulong addr, 302 + enum bootflow_img_t type, ulong *sizep) 302 303 { 303 304 /* 304 305 * Reading individual files is not supported since we only
+2 -1
boot/bootmeth_cros.c
··· 400 400 } 401 401 402 402 static int cros_read_file(struct udevice *dev, struct bootflow *bflow, 403 - const char *file_path, ulong addr, ulong *sizep) 403 + const char *file_path, ulong addr, 404 + enum bootflow_img_t type, ulong *sizep) 404 405 { 405 406 return -ENOSYS; 406 407 }
+3 -2
boot/bootmeth_efi.c
··· 97 97 98 98 size = SZ_1G; 99 99 ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname, 100 - addr, &size); 100 + addr, BFI_EFI, &size); 101 101 if (ret) 102 102 return log_msg_ret("rdf", ret); 103 103 bflow->buf = map_sysmem(addr, bflow->size); ··· 172 172 /* Limit FDT files to 4MB */ 173 173 size = SZ_4M; 174 174 ret = bootmeth_common_read_file(dev, bflow, fname, 175 - fdt_addr, &size); 175 + fdt_addr, (enum bootflow_img_t)IH_TYPE_FLATDT, 176 + &size); 176 177 } 177 178 } 178 179
+2 -1
boot/bootmeth_efi_mgr.c
··· 74 74 } 75 75 76 76 static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow, 77 - const char *file_path, ulong addr, ulong *sizep) 77 + const char *file_path, ulong addr, 78 + enum bootflow_img_t type, ulong *sizep) 78 79 { 79 80 /* Files are loaded by the 'bootefi bootmgr' command */ 80 81
+1 -1
boot/bootmeth_extlinux.c
··· 79 79 /* Allow up to 1GB */ 80 80 *sizep = 1 << 30; 81 81 ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, 82 - sizep); 82 + (enum bootflow_img_t)IH_TYPE_INVALID, sizep); 83 83 if (ret) 84 84 return log_msg_ret("read", ret); 85 85
+3 -3
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, ulong *sizep) 27 27 { 28 28 struct extlinux_info *info = ctx->userdata; 29 29 ulong addr; ··· 34 34 /* Allow up to 1GB */ 35 35 *sizep = 1 << 30; 36 36 ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, 37 - sizep); 37 + IH_TYPE_INVALID, sizep); 38 38 if (ret) 39 39 return log_msg_ret("read", ret); 40 40 ··· 113 113 114 114 static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, 115 115 const char *file_path, ulong addr, 116 - ulong *sizep) 116 + enum bootflow_img_t type, ulong *sizep) 117 117 { 118 118 char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; 119 119 struct pxe_context *ctx = dev_get_priv(dev);
+2 -1
boot/bootmeth_qfw.c
··· 52 52 } 53 53 54 54 static int qfw_read_file(struct udevice *dev, struct bootflow *bflow, 55 - const char *file_path, ulong addr, ulong *sizep) 55 + const char *file_path, ulong addr, 56 + enum bootflow_img_t type, ulong *sizep) 56 57 { 57 58 return -ENOSYS; 58 59 }
+2 -1
boot/bootmeth_sandbox.c
··· 27 27 } 28 28 29 29 static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow, 30 - const char *file_path, ulong addr, ulong *sizep) 30 + const char *file_path, ulong addr, 31 + enum bootflow_img_t type, ulong *sizep) 31 32 { 32 33 return -ENOSYS; 33 34 }
+3 -2
boot/vbe_simple.c
··· 160 160 } 161 161 162 162 static int vbe_simple_read_file(struct udevice *dev, struct bootflow *bflow, 163 - const char *file_path, ulong addr, ulong *sizep) 163 + const char *file_path, ulong addr, 164 + enum bootflow_img_t type, ulong *sizep) 164 165 { 165 166 int ret; 166 167 167 168 if (vbe_phase() == VBE_PHASE_OS) { 168 169 ret = bootmeth_common_read_file(dev, bflow, file_path, addr, 169 - sizep); 170 + type, sizep); 170 171 if (ret) 171 172 return log_msg_ret("os", ret); 172 173 }
+9 -4
include/bootmeth.h
··· 8 8 #define __bootmeth_h 9 9 10 10 #include <bootflow.h> 11 - #include <image.h> 12 11 #include <linux/bitops.h> 13 12 14 13 struct blk_desc; ··· 117 116 * @bflow: Bootflow providing info on where to read from 118 117 * @file_path: Path to file (may be absolute or relative) 119 118 * @addr: Address to load file 119 + * @type: File type (IH_TYPE_...) 120 120 * @sizep: On entry provides the maximum permitted size; on exit 121 121 * returns the size of the file 122 122 * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other 123 123 * -ve value if something else goes wrong 124 124 */ 125 125 int (*read_file)(struct udevice *dev, struct bootflow *bflow, 126 - const char *file_path, ulong addr, ulong *sizep); 126 + const char *file_path, ulong addr, 127 + enum bootflow_img_t type, ulong *sizep); 127 128 #if CONFIG_IS_ENABLED(BOOTSTD_FULL) 128 129 /** 129 130 * readall() - read all files for a bootflow ··· 245 246 * @bflow: Bootflow providing info on where to read from 246 247 * @file_path: Path to file (may be absolute or relative) 247 248 * @addr: Address to load file 249 + * @type: File type (IH_TYPE_...) 248 250 * @sizep: On entry provides the maximum permitted size; on exit 249 251 * returns the size of the file 250 252 * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other 251 253 * -ve value if something else goes wrong 252 254 */ 253 255 int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow, 254 - const char *file_path, ulong addr, ulong *sizep); 256 + const char *file_path, ulong addr, 257 + enum bootflow_img_t type, ulong *sizep); 255 258 256 259 /** 257 260 * bootmeth_read_all() - read all bootflow files ··· 397 400 * @bflow: Bootflow information 398 401 * @file_path: Path to file 399 402 * @addr: Address to load file to 403 + * @type: File type (IH_TYPE_...) 400 404 * @sizep: On entry, the maximum file size to accept, on exit the actual file 401 405 * size read 402 406 */ 403 407 int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, 404 - const char *file_path, ulong addr, ulong *sizep); 408 + const char *file_path, ulong addr, 409 + enum bootflow_img_t type, ulong *sizep); 405 410 406 411 /** 407 412 * bootmeth_get_bootflow() - Get a bootflow from a global bootmeth