Commit f2d11fed authored by Marek Vasut's avatar Marek Vasut
Browse files

mxssb: Wrap target_cpu into SB image context



The CPU model should be part of the image context, make it so.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent a289a072
...@@ -78,7 +78,6 @@ struct sb_image_ctx { ...@@ -78,7 +78,6 @@ struct sb_image_ctx {
struct sb_boot_image_header payload; struct sb_boot_image_header payload;
}; };
static int target_cpu = -1;
static int verbose_boot = 0; static int verbose_boot = 0;
#define SB_IVT_LOAD_ADDR 0x8000 #define SB_IVT_LOAD_ADDR 0x8000
...@@ -610,11 +609,11 @@ unsupp: ...@@ -610,11 +609,11 @@ unsupp:
return -ENOTSUP; return -ENOTSUP;
} }
static int sb_parse_cmds(struct sb_section_ctx *sctx) static int sb_parse_cmds(struct sb_section_ctx *sctx, struct sb_image_ctx *ictx)
{ {
struct sb_cmd_ctx *cctx, *prev = NULL, *head = NULL; struct sb_cmd_ctx *cctx, *prev = NULL, *head = NULL;
struct sb_source_entry *src = sb_get_boot_list(target_cpu); struct sb_source_entry *src = sb_get_boot_list(ictx->target_cpu);
unsigned int insts = sb_get_boot_list_size(target_cpu); unsigned int insts = sb_get_boot_list_size(ictx->target_cpu);
uint32_t len = 0; uint32_t len = 0;
int ret; int ret;
...@@ -673,7 +672,7 @@ static int sb_parse_sections(struct sb_image_ctx *ictx) ...@@ -673,7 +672,7 @@ static int sb_parse_sections(struct sb_image_ctx *ictx)
if (!head) if (!head)
head = sctx; head = sctx;
ret = sb_parse_cmds(sctx); ret = sb_parse_cmds(sctx, ictx);
if (ret) if (ret)
goto fail; goto fail;
...@@ -911,10 +910,11 @@ static void sb_free_image(struct sb_image_ctx *ictx) ...@@ -911,10 +910,11 @@ static void sb_free_image(struct sb_image_ctx *ictx)
} }
} }
static int sb_load_binary(const char *filename, const unsigned int spl) static int sb_load_binary(struct sb_image_ctx *ictx,
const char *filename, const unsigned int spl)
{ {
const int slot = sb_get_boot_list_payload_slot(target_cpu, spl); const int slot = sb_get_boot_list_payload_slot(ictx->target_cpu, spl);
struct sb_source_entry *lst = sb_get_boot_list(target_cpu); struct sb_source_entry *lst = sb_get_boot_list(ictx->target_cpu);
lst[slot].filename = (char *)filename; lst[slot].filename = (char *)filename;
...@@ -933,15 +933,15 @@ static void print_help(const char *pn) ...@@ -933,15 +933,15 @@ static void print_help(const char *pn)
" -h .......... print help\n", pn); " -h .......... print help\n", pn);
} }
static int set_cpu(const char *pn, const char *cpu) static int set_cpu(struct sb_image_ctx *ictx, const char *pn, const char *cpu)
{ {
if (!strcmp("mx23", cpu)) { if (!strcmp("mx23", cpu)) {
target_cpu = CPU_MX23; ictx->target_cpu = CPU_MX23;
return 0; return 0;
} }
if (!strcmp("mx28", cpu)) { if (!strcmp("mx28", cpu)) {
target_cpu = CPU_MX28; ictx->target_cpu = CPU_MX28;
return 0; return 0;
} }
...@@ -960,11 +960,12 @@ int main(int argc, char **argv) ...@@ -960,11 +960,12 @@ int main(int argc, char **argv)
struct sb_image_ctx ctx; struct sb_image_ctx ctx;
memset(&ctx, 0, sizeof(ctx)); memset(&ctx, 0, sizeof(ctx));
ctx.target_cpu = -1;
while ((opt = getopt(argc, argv, "c:s:u:o:vh")) != -1) { while ((opt = getopt(argc, argv, "c:s:u:o:vh")) != -1) {
switch (opt) { switch (opt) {
case 'c': case 'c':
ret = set_cpu(argv[0], optarg); ret = set_cpu(&ctx, argv[0], optarg);
if (ret) if (ret)
return ret; return ret;
break; break;
...@@ -1002,8 +1003,8 @@ int main(int argc, char **argv) ...@@ -1002,8 +1003,8 @@ int main(int argc, char **argv)
return -1; return -1;
} }
sb_load_binary(spl_filename, 1); sb_load_binary(&ctx, spl_filename, 1);
sb_load_binary(uboot_filename, 0); sb_load_binary(&ctx, uboot_filename, 0);
ret = sb_parse_image(&ctx); ret = sb_parse_image(&ctx);
if (ret) if (ret)
......
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