summaryrefslogtreecommitdiff
path: root/include/pxe_utils.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-10-14 21:48:04 +0300
committerTom Rini <trini@konsulko.com>2021-11-12 03:02:28 +0300
commit12df842ee324a7e188a643bfee6fe08f28127b26 (patch)
treecb34fdc5fbc3f5941141fcc3a8e830369aa35e60 /include/pxe_utils.h
parent9e62e7ca543ea94a46f30053262f67202e2435f4 (diff)
downloadu-boot-12df842ee324a7e188a643bfee6fe08f28127b26.tar.xz
pxe: Clean up the use of bootfile
The 'bootfile' environment variable is read in the bowels of pxe_util to provide a directory to which all loaded files are relative. This is not obvious from the API to PXE and it is strange to make the caller set an environment variable rather than pass this as a parameter. The code is also convoluted, which this feature implemented by get_bootfile_path(). Update the API to improve this. Unfortunately this means that pxe_setup_ctx() can fail, so add error checking. 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/pxe_utils.h')
-rw-r--r--include/pxe_utils.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/pxe_utils.h b/include/pxe_utils.h
index 0cae0dabec..543d0245c8 100644
--- a/include/pxe_utils.h
+++ b/include/pxe_utils.h
@@ -86,6 +86,8 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
* @getfile: Function called by PXE to read a file
* @userdata: Data the caller requires for @getfile
* @allow_abs_path: true to allow absolute paths
+ * @bootdir: Directory that files are loaded from ("" if no directory). This is
+ * allocated
*/
struct pxe_context {
struct cmd_tbl *cmdtp;
@@ -102,6 +104,7 @@ struct pxe_context {
void *userdata;
bool allow_abs_path;
+ char *bootdir;
};
/**
@@ -197,10 +200,20 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len);
* @getfile: Function to call to read a file
* @userdata: Data the caller requires for @getfile - stored in ctx->userdata
* @allow_abs_path: true to allow absolute paths
+ * @bootfile: Bootfile whose directory loaded files are relative to, NULL if
+ * none
+ * @return 0 if OK, -ENOMEM if out of memory
*/
-void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
- pxe_getfile_func getfile, void *userdata,
- bool allow_abs_path);
+int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
+ pxe_getfile_func getfile, void *userdata,
+ bool allow_abs_path, const char *bootfile);
+
+/**
+ * pxe_destroy_ctx() - Destroy a PXE context
+ *
+ * @ctx: Context to destroy
+ */
+void pxe_destroy_ctx(struct pxe_context *ctx);
/**
* pxe_process() - Process a PXE file through to boot