mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-11-04 05:50:17 +00:00 
			
		
		
		
	pxe: Add a userdata field to the context
Allow the caller to provide some info which is passed back to the readfile() method. 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>
This commit is contained in:
		
							parent
							
								
									b1ead6b908
								
							
						
					
					
						commit
						4ad5d51edb
					
				@ -121,7 +121,7 @@ do_pxe_get(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 | 
			
		||||
	struct pxe_context ctx;
 | 
			
		||||
	int err, i = 0;
 | 
			
		||||
 | 
			
		||||
	pxe_setup_ctx(&ctx, cmdtp, do_get_tftp);
 | 
			
		||||
	pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL);
 | 
			
		||||
 | 
			
		||||
	if (argc != 1)
 | 
			
		||||
		return CMD_RET_USAGE;
 | 
			
		||||
@ -175,7 +175,7 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 | 
			
		||||
	char *pxefile_addr_str;
 | 
			
		||||
	struct pxe_context ctx;
 | 
			
		||||
 | 
			
		||||
	pxe_setup_ctx(&ctx, cmdtp, do_get_tftp);
 | 
			
		||||
	pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL);
 | 
			
		||||
 | 
			
		||||
	if (argc == 1) {
 | 
			
		||||
		pxefile_addr_str = from_env("pxefile_addr_r");
 | 
			
		||||
 | 
			
		||||
@ -1451,8 +1451,9 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
 | 
			
		||||
		   pxe_getfile_func getfile)
 | 
			
		||||
		   pxe_getfile_func getfile, void *userdata)
 | 
			
		||||
{
 | 
			
		||||
	ctx->cmdtp = cmdtp;
 | 
			
		||||
	ctx->getfile = getfile;
 | 
			
		||||
	ctx->userdata = userdata;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -86,6 +86,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
 | 
			
		||||
 *
 | 
			
		||||
 * @cmdtp: Pointer to command table to use when calling other commands
 | 
			
		||||
 * @getfile: Function called by PXE to read a file
 | 
			
		||||
 * @userdata: Data the caller requires for @getfile
 | 
			
		||||
 */
 | 
			
		||||
struct pxe_context {
 | 
			
		||||
	struct cmd_tbl *cmdtp;
 | 
			
		||||
@ -99,6 +100,8 @@ struct pxe_context {
 | 
			
		||||
	 * Return 0 if OK, -ve on error
 | 
			
		||||
	 */
 | 
			
		||||
	pxe_getfile_func getfile;
 | 
			
		||||
 | 
			
		||||
	void *userdata;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -192,8 +195,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
 | 
			
		||||
 * @userdata: Data the caller requires for @getfile - stored in ctx->userdata
 | 
			
		||||
 */
 | 
			
		||||
void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
 | 
			
		||||
		   pxe_getfile_func getfile);
 | 
			
		||||
		   pxe_getfile_func getfile, void *userdata);
 | 
			
		||||
 | 
			
		||||
#endif /* __PXE_UTILS_H */
 | 
			
		||||
 | 
			
		||||
@ -91,7 +91,7 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc,
 | 
			
		||||
		env_set("bootfile", filename);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pxe_setup_ctx(&ctx, cmdtp, NULL);
 | 
			
		||||
	pxe_setup_ctx(&ctx, cmdtp, NULL, NULL);
 | 
			
		||||
	if (strstr(argv[3], "ext2")) {
 | 
			
		||||
		ctx.getfile = do_get_ext2;
 | 
			
		||||
	} else if (strstr(argv[3], "fat")) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user