#ifndef USE_HOSTCC
#include <common.h>
#include <env.h>
+#include <display_options.h>
+#include <init.h>
#include <lmb.h>
#include <log.h>
#include <malloc.h>
#include <linux/errno.h>
#include <asm/io.h>
-#ifdef CONFIG_CMD_BDI
-extern int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
-#endif
-
DECLARE_GLOBAL_DATA_PTR;
/* Set this if we have less than 4 MB of malloc() space */
#else /* USE_HOSTCC */
#include "mkimage.h"
+#include <linux/kconfig.h>
#include <u-boot/md5.h>
#include <time.h>
#include <relocate.h>
#include <linux/lzo.h>
#include <linux/zstd.h>
-#include <linux/kconfig.h>
#include <lzma/LzmaTypes.h>
#include <lzma/LzmaDec.h>
#include <lzma/LzmaTools.h>
{ IH_OS_INVALID, "invalid", "Invalid OS", },
{ IH_OS_ARM_TRUSTED_FIRMWARE, "arm-trusted-firmware", "ARM Trusted Firmware" },
{ IH_OS_LINUX, "linux", "Linux", },
-#if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC)
- { IH_OS_LYNXOS, "lynxos", "LynxOS", },
-#endif
{ IH_OS_NETBSD, "netbsd", "NetBSD", },
{ IH_OS_OSE, "ose", "Enea OSE", },
{ IH_OS_PLAN9, "plan9", "Plan 9", },
{ IH_TYPE_MTKIMAGE, "mtk_image", "MediaTek BootROM loadable Image" },
{ IH_TYPE_COPRO, "copro", "Coprocessor Image"},
{ IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" },
+ { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot Image" },
+ { IH_TYPE_FDT_LEGACY, "fdt_legacy", "legacy Image with Flat Device Tree ", },
+ { IH_TYPE_RENESAS_SPKG, "spkgimage", "Renesas SPKG Image" },
+ { IH_TYPE_STARFIVE_SPL, "sfspl", "StarFive SPL Image" },
{ -1, "", "", },
};
{ -1, "", "", },
};
+static const table_entry_t uimage_phase[] = {
+ { IH_PHASE_NONE, "none", "any", },
+ { IH_PHASE_U_BOOT, "u-boot", "U-Boot phase", },
+ { IH_PHASE_SPL, "spl", "SPL Phase", },
+ { -1, "", "", },
+};
+
struct table_info {
const char *desc;
int count;
{ "compression", IH_COMP_COUNT, uimage_comp },
{ "operating system", IH_OS_COUNT, uimage_os },
{ "image type", IH_TYPE_COUNT, uimage_type },
+ { "phase", IH_PHASE_COUNT, uimage_phase },
};
/*****************************************************************************/
/* Legacy format routines */
/*****************************************************************************/
-int image_check_hcrc(const image_header_t *hdr)
+int image_check_hcrc(const struct legacy_img_hdr *hdr)
{
ulong hcrc;
ulong len = image_get_header_size();
- image_header_t header;
+ struct legacy_img_hdr header;
/* Copy header so we can blank CRC field for re-calculation */
memmove(&header, (char *)hdr, image_get_header_size());
return (hcrc == image_get_hcrc(hdr));
}
-int image_check_dcrc(const image_header_t *hdr)
+int image_check_dcrc(const struct legacy_img_hdr *hdr)
{
ulong data = image_get_data(hdr);
ulong len = image_get_data_size(hdr);
* returns:
* number of components
*/
-ulong image_multi_count(const image_header_t *hdr)
+ulong image_multi_count(const struct legacy_img_hdr *hdr)
{
ulong i, count = 0;
uint32_t *size;
* data address and size of the component, if idx is valid
* 0 in data and len, if idx is out of range
*/
-void image_multi_getimg(const image_header_t *hdr, ulong idx,
+void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
ulong *data, ulong *len)
{
int i;
}
}
-static void image_print_type(const image_header_t *hdr)
+static void image_print_type(const struct legacy_img_hdr *hdr)
{
const char __maybe_unused *os, *arch, *type, *comp;
*/
void image_print_contents(const void *ptr)
{
- const image_header_t *hdr = (const image_header_t *)ptr;
+ const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
const char __maybe_unused *p;
p = IMAGE_INDENT_STRING;
* @type: OS type (IH_OS_...)
* @comp_type: Compression type being used (IH_COMP_...)
* @is_xip: true if the load address matches the image start
+ * @load: Load address for printing
*/
-static void print_decomp_msg(int comp_type, int type, bool is_xip)
+static void print_decomp_msg(int comp_type, int type, bool is_xip,
+ ulong load)
{
const char *name = genimg_get_type_name(type);
+ /* Shows "Loading Kernel Image" for example */
if (comp_type == IH_COMP_NONE)
- printf(" %s %s\n", is_xip ? "XIP" : "Loading", name);
+ printf(" %s %s", is_xip ? "XIP" : "Loading", name);
else
- printf(" Uncompressing %s\n", name);
+ printf(" Uncompressing %s", name);
+
+ printf(" to %lx\n", load);
}
int image_decomp_type(const unsigned char *buf, ulong len)
int ret = -ENOSYS;
*load_end = load;
- print_decomp_msg(comp, type, load == image_start);
+ print_decomp_msg(comp, type, load == image_start, load);
/*
* Load the image to the right place, decompressing if needed. After
struct abuf in, out;
abuf_init_set(&in, image_buf, image_len);
- abuf_init_set(&in, load_buf, unc_len);
+ abuf_init_set(&out, load_buf, unc_len);
ret = zstd_decompress(&in, &out);
if (ret >= 0) {
image_len = ret;
* This will scan the translation table trying to find the entry that matches
* the given id.
*
- * @return long entry name if translation succeeds; error string on failure
+ * Return: long entry name if translation succeeds; error string on failure
*/
const char *genimg_get_cat_name(enum ih_category category, uint id)
{
entry = get_table_entry(table_info[category].table, id);
if (!entry)
return unknown_msg(category);
- return manual_reloc(entry->lname);
+ return entry->lname;
}
/**
* This will scan the translation table trying to find the entry that matches
* the given id.
*
- * @return short entry name if translation succeeds; error string on failure
+ * Return: short entry name if translation succeeds; error string on failure
*/
const char *genimg_get_cat_short_name(enum ih_category category, uint id)
{
entry = get_table_entry(table_info[category].table, id);
if (!entry)
return unknown_msg(category);
- return manual_reloc(entry->sname);
+ return entry->sname;
}
int genimg_get_cat_count(enum ih_category category)
* This will scan the translation table trying to find the entry that matches
* the given id.
*
- * @return true if category has entry id; false if not
+ * Return: true if category has entry id; false if not
*/
bool genimg_cat_has_id(enum ih_category category, uint id)
{
table = get_table_entry(table, id);
if (!table)
return msg;
- return manual_reloc(table->lname);
+ return table->lname;
}
const char *genimg_get_os_name(uint8_t os)
comp));
}
+const char *genimg_get_phase_name(enum image_phase_t phase)
+{
+ return get_table_entry_name(uimage_phase, "Unknown Phase", phase);
+}
+
static const char *genimg_get_short_name(const table_entry_t *table, int val)
{
table = get_table_entry(table, val);
if (!table)
return "unknown";
- return manual_reloc(table->sname);
+ return table->sname;
}
const char *genimg_get_type_short_name(uint8_t type)
const table_entry_t *t;
for (t = table; t->id >= 0; ++t) {
- if (t->sname && !strcasecmp(manual_reloc(t->sname), name))
+ if (t->sname && !strcasecmp(t->sname, name))
return t->id;
}
debug("Invalid %s Type: %s\n", table_name, name);
{
return (get_table_entry_id(uimage_comp, "Compression", name));
}
+
+int genimg_get_phase_id(const char *name)
+{
+ return get_table_entry_id(uimage_phase, "Phase", name);
+}