Commit 36dc1432 authored by Marek Vasut's avatar Marek Vasut
Browse files

mxssb: Move sb_tag_to_command in mxssb.c



Move the function lower in mxssb.c so there is no longer need for
forward declaration of sb_load_file().
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent 03e58070
......@@ -345,68 +345,6 @@ static uint8_t sb_command_checksum(struct sb_command *inst)
return csum;
}
static int sb_load_file(struct sb_cmd_ctx *cctx, struct sb_source_entry *src);
static int sb_tag_to_command(struct sb_source_entry *src,
struct sb_cmd_ctx *cctx)
{
struct sb_command *cmd = &cctx->payload;
int ret;
cmd->header.checksum = 0x5a;
cmd->header.tag = src->tag;
cmd->header.flags = src->flags;
switch (src->tag) {
case ROM_NOP_CMD: /* UNSUPPORTED */
goto unsupp;
case ROM_TAG_CMD:
/* TAG instruction is filled later */
break;
case ROM_LOAD_CMD:
/* Load the file */
if (!strcmp(src->filename, "ivt:spl")) {
cctx->ivt = 1;
cctx->data = (uint8_t *)&sb_spl_ivt;
cctx->length = sizeof(sb_spl_ivt);
} else if (!strcmp(src->filename, "ivt:u-boot")) {
cctx->ivt = 1;
cctx->data = (uint8_t *)&sb_uboot_ivt;
cctx->length = sizeof(sb_uboot_ivt);
} else {
ret = sb_load_file(cctx, src);
if (ret)
return ret;
}
if (cctx->length & (SB_BLOCK_SIZE - 1))
fprintf(stderr, "WARN: Unaligned payload!\n");
/* Fill LOAD instruction. */
cmd->load.address = src->address;
cmd->load.count = cctx->length;
cmd->load.crc32 = crc32(cctx->data, cctx->length);
break;
case ROM_FILL_CMD: /* UNSUPPORTED */
goto unsupp;
case ROM_JUMP_CMD: /* UNSUPPORTED */
goto unsupp;
case ROM_CALL_CMD:
cmd->call.address = src->address;
/* FIXME ... make this configurable */
cmd->jump.argument = 0x00000000;
break;
case ROM_MODE_CMD: /* UNSUPPORTED */
goto unsupp;
}
return 0;
unsupp:
return -ENOTSUP;
}
static void sb_encrypt_tag(struct sb_image_ctx *ictx,
struct sb_command *cmd,
uint8_t result[sizeof(struct sb_command)])
......@@ -628,6 +566,66 @@ err_open:
return -EINVAL;
}
static int sb_tag_to_command(struct sb_source_entry *src,
struct sb_cmd_ctx *cctx)
{
struct sb_command *cmd = &cctx->payload;
int ret;
cmd->header.checksum = 0x5a;
cmd->header.tag = src->tag;
cmd->header.flags = src->flags;
switch (src->tag) {
case ROM_NOP_CMD: /* UNSUPPORTED */
goto unsupp;
case ROM_TAG_CMD:
/* TAG instruction is filled later */
break;
case ROM_LOAD_CMD:
/* Load the file */
if (!strcmp(src->filename, "ivt:spl")) {
cctx->ivt = 1;
cctx->data = (uint8_t *)&sb_spl_ivt;
cctx->length = sizeof(sb_spl_ivt);
} else if (!strcmp(src->filename, "ivt:u-boot")) {
cctx->ivt = 1;
cctx->data = (uint8_t *)&sb_uboot_ivt;
cctx->length = sizeof(sb_uboot_ivt);
} else {
ret = sb_load_file(cctx, src);
if (ret)
return ret;
}
if (cctx->length & (SB_BLOCK_SIZE - 1))
fprintf(stderr, "WARN: Unaligned payload!\n");
/* Fill LOAD instruction. */
cmd->load.address = src->address;
cmd->load.count = cctx->length;
cmd->load.crc32 = crc32(cctx->data, cctx->length);
break;
case ROM_FILL_CMD: /* UNSUPPORTED */
goto unsupp;
case ROM_JUMP_CMD: /* UNSUPPORTED */
goto unsupp;
case ROM_CALL_CMD:
cmd->call.address = src->address;
/* FIXME ... make this configurable */
cmd->call.argument = 0x00000000;
break;
case ROM_MODE_CMD: /* UNSUPPORTED */
goto unsupp;
}
return 0;
unsupp:
return -ENOTSUP;
}
static int sb_parse_cmds(struct sb_section_ctx *sctx)
{
struct sb_cmd_ctx *cctx, *prev = NULL, *head = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment