mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
boot: extension: Move overlay apply custom logic to command level
The extension_overlay_cmd environment variable approach is specific to the U-Boot extension_board command, while other boot flows (pxe_utils, bootstd) handle overlay loading differently. Move the extension_overlay_cmd execution out of the core extension framework to the command level. This decouples the framework from command-specific behavior and prepares for future extension support in other boot flows. Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Tom Rini
parent
2d12958ee7
commit
f9b139342c
@@ -59,92 +59,34 @@ int extension_scan(void)
|
||||
return ops->scan(dev, extension_list);
|
||||
}
|
||||
|
||||
static int _extension_apply(const struct extension *extension)
|
||||
int extension_apply(struct fdt_header *working_fdt, ulong size)
|
||||
{
|
||||
ulong extrasize, overlay_addr;
|
||||
struct fdt_header *blob;
|
||||
char *overlay_cmd;
|
||||
ulong overlay_addr;
|
||||
int ret;
|
||||
|
||||
if (!working_fdt) {
|
||||
printf("No FDT memory address configured. Please configure\n"
|
||||
"the FDT address via \"fdt addr <address>\" command.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
overlay_cmd = env_get("extension_overlay_cmd");
|
||||
if (!overlay_cmd) {
|
||||
printf("Environment extension_overlay_cmd is missing\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
overlay_addr = env_get_hex("extension_overlay_addr", 0);
|
||||
if (!overlay_addr) {
|
||||
printf("Environment extension_overlay_addr is missing\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
env_set("extension_overlay_name", extension->overlay);
|
||||
ret = run_command(overlay_cmd, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
extrasize = env_get_hex("filesize", 0);
|
||||
if (!extrasize)
|
||||
return -EINVAL;
|
||||
|
||||
fdt_shrink_to_minimum(working_fdt, extrasize);
|
||||
fdt_shrink_to_minimum(working_fdt, size);
|
||||
|
||||
blob = map_sysmem(overlay_addr, 0);
|
||||
if (!fdt_valid(&blob)) {
|
||||
printf("Invalid overlay devicetree %s\n", extension->overlay);
|
||||
printf("Invalid overlay devicetree\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Apply method prints messages on error */
|
||||
ret = fdt_overlay_apply_verbose(working_fdt, blob);
|
||||
if (ret)
|
||||
printf("Failed to apply overlay %s\n", extension->overlay);
|
||||
printf("Failed to apply overlay\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int extension_apply(int extension_num)
|
||||
{
|
||||
struct alist *extension_list = extension_get_list();
|
||||
const struct extension *extension;
|
||||
|
||||
if (!extension_list)
|
||||
return -ENOENT;
|
||||
|
||||
extension = alist_get(extension_list, extension_num,
|
||||
struct extension);
|
||||
if (!extension) {
|
||||
printf("Wrong extension number\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return _extension_apply(extension);
|
||||
}
|
||||
|
||||
int extension_apply_all(void)
|
||||
{
|
||||
struct alist *extension_list = extension_get_list();
|
||||
const struct extension *extension;
|
||||
int ret;
|
||||
|
||||
if (!extension_list)
|
||||
return -ENOENT;
|
||||
|
||||
alist_for_each(extension, extension_list) {
|
||||
ret = _extension_apply(extension);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(extension) = {
|
||||
.name = "extension",
|
||||
.id = UCLASS_EXTENSION,
|
||||
|
||||
Reference in New Issue
Block a user