From: Peng Fan
Add plugin support for imximage.
Define CONFIG_USE_PLUGIN to enable using plugin.
Signed-off-by: Peng Fan
Cc: Stefano Babic
Cc: Eric Nelson
Cc: Ye Li
---
tools/imximage.c | 260 ---
tools/imximage.h | 10 ++-
2 files changed, 218 insertions(+), 52 deletions(-)
diff --git a/tools/imximage.c b/tools/imximage.c
index 092d550..88233ac 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -27,6 +27,9 @@ static table_entry_t imximage_cmds[] = {
{CMD_CHECK_BITS_CLR,"CHECK_BITS_CLR", "Reg Check bits clr", },
{CMD_CSF, "CSF", "Command Sequence File", },
{CMD_IMAGE_VERSION, "IMAGE_VERSION","image version", },
+#ifdef CONFIG_USE_PLUGIN
+ {CMD_PLUGIN,"PLUGIN", "file plugin_addr", },
+#endif
{-1,"", "", },
};
@@ -80,6 +83,8 @@ static uint32_t imximage_ivt_offset = UNDEFINED;
static uint32_t imximage_csf_size = UNDEFINED;
/* Initial Load Region Size */
static uint32_t imximage_init_loadsize;
+static uint32_t imximage_iram_free_start;
+static uint32_t imximage_plugin_size;
static set_dcd_val_t set_dcd_val;
static set_dcd_param_t set_dcd_param;
@@ -118,7 +123,11 @@ static uint32_t detect_imximage_version(struct imx_header
*imx_hdr)
/* Try to detect V2 */
if ((fhdr_v2->header.tag == IVT_HEADER_TAG) &&
- (hdr_v2->dcd_table.header.tag == DCD_HEADER_TAG))
+ (hdr_v2->data.dcd_table.header.tag == DCD_HEADER_TAG))
+ return IMXIMAGE_V2;
+
+ if ((fhdr_v2->header.tag == IVT_HEADER_TAG) &&
+ hdr_v2->boot_data.plugin)
return IMXIMAGE_V2;
return IMXIMAGE_VER_INVALID;
@@ -165,7 +174,7 @@ static struct dcd_v2_cmd *gd_last_cmd;
static void set_dcd_param_v2(struct imx_header *imxhdr, uint32_t dcd_len,
int32_t cmd)
{
- dcd_v2_t *dcd_v2 = >header.hdr_v2.dcd_table;
+ dcd_v2_t *dcd_v2 = >header.hdr_v2.data.dcd_table;
struct dcd_v2_cmd *d = gd_last_cmd;
struct dcd_v2_cmd *d2;
int len;
@@ -261,21 +270,23 @@ static void set_dcd_rst_v1(struct imx_header *imxhdr,
uint32_t dcd_len,
static void set_dcd_rst_v2(struct imx_header *imxhdr, uint32_t dcd_len,
char *name, int lineno)
{
- dcd_v2_t *dcd_v2 = >header.hdr_v2.dcd_table;
- struct dcd_v2_cmd *d = gd_last_cmd;
- int len;
-
- if (!d)
- d = _v2->dcd_cmd;
- len = be16_to_cpu(d->write_dcd_command.length);
- if (len > 4)
- d = (struct dcd_v2_cmd *)(((char *)d) + len);
-
- len = (char *)d - (char *)_v2->header;
-
- dcd_v2->header.tag = DCD_HEADER_TAG;
- dcd_v2->header.length = cpu_to_be16(len);
- dcd_v2->header.version = DCD_VERSION;
+ if (!imxhdr->header.hdr_v2.boot_data.plugin) {
+ dcd_v2_t *dcd_v2 = >header.hdr_v2.data.dcd_table;
+ struct dcd_v2_cmd *d = gd_last_cmd;
+ int len;
+
+ if (!d)
+ d = _v2->dcd_cmd;
+ len = be16_to_cpu(d->write_dcd_command.length);
+ if (len > 4)
+ d = (struct dcd_v2_cmd *)(((char *)d) + len);
+
+ len = (char *)d - (char *)_v2->header;
+
+ dcd_v2->header.tag = DCD_HEADER_TAG;
+ dcd_v2->header.length = cpu_to_be16(len);
+ dcd_v2->header.version = DCD_VERSION;
+ }
}
static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len,
@@ -317,24 +328,93 @@ static void set_imx_hdr_v2(struct imx_header *imxhdr,
uint32_t dcd_len,
fhdr_v2->header.length = cpu_to_be16(sizeof(flash_header_v2_t));
fhdr_v2->header.version = IVT_VERSION; /* 0x40 */
- fhdr_v2->entry = entry_point;
- fhdr_v2->reserved1 = fhdr_v2->reserved2 = 0;
- hdr_base = entry_point - imximage_init_loadsize +
- flash_offset;
- fhdr_v2->self = hdr_base;
- if (dcd_len > 0)
- fhdr_v2->dcd_ptr = hdr_base
- + offsetof(imx_header_v2_t, dcd_table);
- else
+ if (!hdr_v2->boot_data.plugin) {
+ fhdr_v2->entry = entry_point;
+ fhdr_v2->reserved1 = 0;
+ fhdr_v2->reserved1 = 0;
+ hdr_base = entry_point - imximage_init_loadsize +
+ flash_offset;
+ fhdr_v2->self = hdr_base;
+ if (dcd_len > 0)
+ fhdr_v2->dcd_ptr = hdr_base +
+ offsetof(imx_header_v2_t, data);
+ else
+ fhdr_v2->dcd_ptr = 0;
+ fhdr_v2->boot_data_ptr = hdr_base
+ + offsetof(imx_header_v2_t, boot_data);
+