mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
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>
This commit is contained in:
parent
4a255ea3b6
commit
4d79e884ad
4 changed files with 79 additions and 32 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue