boot: Support booti format in bootm
At present the booti format is handled separately, in its own command.
Provide a way to boot uncompressed booti images within the bootm code,
so that eventually we can boot these images without CONFIG_CMDLINE
Update bootm_init() to attach the images for all formats which use them.
Add some debugging while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/boot/bootm.c b/boot/bootm.c
index c719a50..272623c 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -227,6 +227,12 @@
break;
}
#endif
+ case IMAGE_FORMAT_BOOTI:
+ if (IS_ENABLED(CONFIG_CMD_BOOTI)) {
+ *os_data = img_addr;
+ break;
+ }
+ fallthrough;
default:
bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE);
return -EPROTOTYPE;
@@ -286,6 +292,24 @@
return ret;
}
+static int found_booti_os(enum image_comp_t comp)
+{
+ images.os.load = images.os.image_start;
+ images.os.type = IH_TYPE_KERNEL;
+ images.os.os = IH_OS_LINUX;
+ images.os.comp = comp;
+ if (IS_ENABLED(CONFIG_RISCV_SMODE))
+ images.os.arch = IH_ARCH_RISCV;
+ else if (IS_ENABLED(CONFIG_ARM64))
+ images.os.arch = IH_ARCH_ARM64;
+
+ log_debug("load %lx start %lx len %lx ep %lx os %x comp %x\n",
+ images.os.load, images.os.image_start, images.os.image_len,
+ images.ep, images.os.os, images.os.comp);
+
+ return 0;
+}
+
/**
* bootm_find_os(): Find the OS to boot
*
@@ -390,6 +414,14 @@
}
break;
#endif
+ case IMAGE_FORMAT_BOOTI:
+ if (IS_ENABLED(CONFIG_CMD_BOOTI)) {
+ if (found_booti_os(IH_COMP_NONE))
+ return 1;
+ ep_found = true;
+ break;
+ }
+ fallthrough;
default:
puts("ERROR: unknown image format type!\n");
return 1;
@@ -541,6 +573,7 @@
static int bootm_find_other(ulong img_addr, const char *conf_ramdisk,
const char *conf_fdt)
{
+ log_debug("find_other type %x os %x\n", images.os.type, images.os.os);
if ((images.os.type == IH_TYPE_KERNEL ||
images.os.type == IH_TYPE_KERNEL_NOLOAD ||
images.os.type == IH_TYPE_MULTI) &&
@@ -629,6 +662,8 @@
debug("Allocated %lx bytes at %lx for kernel (size %lx) decompression\n",
req_size, load, image_len);
}
+ log_debug("load_os load %lx image_start %lx image_len %lx\n", load,
+ image_start, image_len);
load_buf = map_sysmem(load, 0);
image_buf = map_sysmem(os.image_start, image_len);
@@ -1110,6 +1145,10 @@
states |= BOOTM_STATE_RAMDISK;
states |= extra_states;
+ log_debug("cmd '%s' states %x addr_img '%s' conf_ramdisk '%s' conf_fdt '%s' images %p\n",
+ cmd, states, bmi->addr_img, bmi->conf_ramdisk, bmi->conf_fdt,
+ bmi->images);
+
return bootm_run_states(bmi, states);
}
@@ -1166,7 +1205,8 @@
{
memset(bmi, '\0', sizeof(struct bootm_info));
bmi->boot_progress = true;
- if (IS_ENABLED(CONFIG_CMD_BOOTM))
+ if (IS_ENABLED(CONFIG_CMD_BOOTM) || IS_ENABLED(CONFIG_CMD_BOOTZ) ||
+ IS_ENABLED(CONFIG_CMD_BOOTI) || IS_ENABLED(CONFIG_PXE_UTILS))
bmi->images = &images;
}
diff --git a/include/image.h b/include/image.h
index f8f2c88..5b9bd6a 100644
--- a/include/image.h
+++ b/include/image.h
@@ -244,7 +244,7 @@
* New IDs *MUST* be appended at the end of the list and *NEVER*
* inserted for backward compatibility.
*/
-enum {
+enum image_comp_t {
IH_COMP_NONE = 0, /* No Compression Used */
IH_COMP_GZIP, /* gzip Compression Used */
IH_COMP_BZIP2, /* bzip2 Compression Used */