@@ -140,27 +140,9 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow)
return 0;
}
-static int extlinux_boot(struct udevice *dev, struct bootflow *bflow)
+static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow)
{
- struct extlinux_plat *plat = dev_get_plat(dev);
- ulong addr;
- int ret;
-
- addr = map_to_sysmem(bflow->buf);
-
- plat->info.dev = dev;
- plat->info.bflow = bflow;
-
- ret = pxe_setup_ctx(&plat->ctx, extlinux_getfile, &plat->info, true,
- bflow->fname, false, plat->use_fallback, bflow);
- if (ret)
- return log_msg_ret("ctx", -EINVAL);
-
- ret = pxe_process(&plat->ctx, addr, false);
- if (ret)
- return log_msg_ret("bread", -EINVAL);
-
- return 0;
+ return extlinux_boot(dev, bflow, extlinux_getfile, true, bflow->fname);
}
static int extlinux_bootmeth_bind(struct udevice *dev)
@@ -178,7 +160,7 @@ static struct bootmeth_ops extlinux_bootmeth_ops = {
.check = extlinux_check,
.read_bootflow = extlinux_read_bootflow,
.read_file = bootmeth_common_read_file,
- .boot = extlinux_boot,
+ .boot = extlinux_local_boot,
.set_property = extlinux_set_property,
};
@@ -139,24 +139,8 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow)
{
- struct extlinux_plat *plat = dev_get_plat(dev);
- struct pxe_context *ctx = &plat->ctx;
- ulong addr;
- int ret;
-
- addr = map_to_sysmem(bflow->buf);
- plat->info.dev = dev;
- plat->info.bflow = bflow;
- ret = pxe_setup_ctx(ctx, extlinux_pxe_getfile, &plat->info, false,
- bflow->subdir, false, plat->use_fallback, bflow);
- if (ret)
- return log_msg_ret("ctx", -EINVAL);
-
- ret = pxe_process(ctx, addr, false);
- if (ret)
- return log_msg_ret("bread", -EINVAL);
-
- return 0;
+ return extlinux_boot(dev, bflow, extlinux_pxe_getfile, false,
+ bflow->subdir);
}
static int extlinux_bootmeth_pxe_bind(struct udevice *dev)
@@ -74,3 +74,28 @@ int extlinux_set_property(struct udevice *dev, const char *property,
return 0;
}
+
+int extlinux_boot(struct udevice *dev, struct bootflow *bflow,
+ pxe_getfile_func getfile, bool allow_abs_path,
+ const char *bootfile)
+{
+ struct extlinux_plat *plat = dev_get_plat(dev);
+ ulong addr;
+ int ret;
+
+ addr = map_to_sysmem(bflow->buf);
+
+ plat->info.dev = dev;
+ plat->info.bflow = bflow;
+
+ ret = pxe_setup_ctx(&plat->ctx, getfile, &plat->info, allow_abs_path,
+ bootfile, false, plat->use_fallback, bflow);
+ if (ret)
+ return log_msg_ret("ctx", -EINVAL);
+
+ ret = pxe_process(&plat->ctx, addr, false);
+ if (ret)
+ return log_msg_ret("bread", -EINVAL);
+
+ return 0;
+}
@@ -49,4 +49,19 @@ struct extlinux_plat {
int extlinux_set_property(struct udevice *dev, const char *property,
const char *value);
+/**
+ * extlinux_boot() - Boot a bootflow
+ *
+ * @dev: bootmeth device
+ * @bflow: Bootflow to boot
+ * @getfile: Function to use to read files
+ * @allow_abs_path: true to allow absolute paths
+ * @bootfile: Bootfile whose directory loaded files are relative to, NULL if
+ * none
+ * Return: 0 if OK, -ve error code on failure
+ */
+int extlinux_boot(struct udevice *dev, struct bootflow *bflow,
+ pxe_getfile_func getfile, bool allow_abs_path,
+ const char *bootfile);
+
#endif
The extlinux and PXE code for booting is almost the same. Move it into the common file so it is easier to keep it in sync. Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v3: - Pass through the bootfile since extlinux and PXE are different boot/bootmeth_extlinux.c | 24 +++--------------------- boot/bootmeth_pxe.c | 20 ++------------------ boot/ext_pxe_common.c | 25 +++++++++++++++++++++++++ include/extlinux.h | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 39 deletions(-)