From b1ead6b9087f1f96cb117d72e3e5cf0d5fb708f5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 14 Oct 2021 12:47:57 -0600 Subject: pxe: Move do_getfile() into the context Rather than having a global variable, pass the function as part of the context. Signed-off-by: Simon Glass Reviewed-by: Artem Lapkin Tested-by: Artem Lapkin Reviewed-by: Ramon Fried --- cmd/pxe_utils.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'cmd/pxe_utils.h') diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h index cd0d337176..ca2696f48b 100644 --- a/cmd/pxe_utils.h +++ b/cmd/pxe_utils.h @@ -77,16 +77,28 @@ struct pxe_menu { extern bool is_pxe; -extern int (*do_getfile)(struct cmd_tbl *cmdtp, const char *file_path, - char *file_addr); +struct pxe_context; +typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path, + char *file_addr); /** * struct pxe_context - context information for PXE parsing * * @cmdtp: Pointer to command table to use when calling other commands + * @getfile: Function called by PXE to read a file */ struct pxe_context { struct cmd_tbl *cmdtp; + /** + * getfile() - read a file + * + * @ctx: PXE context + * @file_path: Path to the file + * @file_addr: String containing the hex address to put the file in + * memory + * Return 0 if OK, -ve on error + */ + pxe_getfile_func getfile; }; /** @@ -179,7 +191,9 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); * * @ctx: Context to set up * @cmdtp: Command table entry which started this action + * @getfile: Function to call to read a file */ -void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp); +void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, + pxe_getfile_func getfile); #endif /* __PXE_UTILS_H */ -- cgit v1.2.3