diff options
author | Simon Glass | 2021-10-14 12:48:08 -0600 |
---|---|---|
committer | Tom Rini | 2021-11-11 19:02:36 -0500 |
commit | 4d79e884adf6842beb94566bf5249c07a84a5b51 (patch) | |
tree | 7eb943b038db3795e57cec8536553dbc959197e1 /include | |
parent | 4a255ea3b65e7793eea97a90ad00dc2b59889683 (diff) |
pxe: Return the file size from the getfile() function
It is pretty strange that the pxe code uses the 'filesize' environment
variable find the size of a file it has just read.
Partly this is because it uses the command-line interpreter to parse its
request to load the file.
As a first step towards unwinding this, return it directly from the
getfile() function. This makes the code a bit longer, for now, but will be
cleaned up in future patches.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/pxe_utils.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 8b50f2e6861..194a5ed8cc7 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -77,7 +77,7 @@ struct pxe_menu { struct pxe_context; typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, - char *file_addr); + char *file_addr, ulong *filesizep); /** * struct pxe_context - context information for PXE parsing @@ -88,6 +88,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, * @allow_abs_path: true to allow absolute paths * @bootdir: Directory that files are loaded from ("" if no directory). This is * allocated + * @pxe_file_size: Size of the PXE file */ struct pxe_context { struct cmd_tbl *cmdtp; @@ -98,6 +99,7 @@ struct pxe_context { * @file_path: Path to the file * @file_addr: String containing the hex address to put the file in * memory + * @filesizep: Returns the file size in bytes * Return 0 if OK, -ve on error */ pxe_getfile_func getfile; @@ -105,6 +107,7 @@ struct pxe_context { void *userdata; bool allow_abs_path; char *bootdir; + ulong pxe_file_size; }; /** @@ -225,4 +228,12 @@ void pxe_destroy_ctx(struct pxe_context *ctx); */ int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt); +/** + * pxe_get_file_size() - Read the value of the 'filesize' environment variable + * + * @sizep: Place to put the value + * @return 0 if OK, -ENOENT if no such variable, -EINVAL if format is invalid + */ +int pxe_get_file_size(ulong *sizep); + #endif /* __PXE_UTILS_H */ |