Commit e86c0e8c authored by Marek Vasut's avatar Marek Vasut

mxssb: Support multiple sections

So far, we only support one section, but once we have proper parser
we will be able to support multiple sections. Prepare for this by
implementing the section generation in the image tree correctly.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent e8a655df
...@@ -661,34 +661,60 @@ err: ...@@ -661,34 +661,60 @@ err:
static int sb_parse_sections(struct sb_image_ctx *ictx) static int sb_parse_sections(struct sb_image_ctx *ictx)
{ {
/* This function is a stub, we support only one section so far. */ /* This function is a stub, we support only one section so far. */
struct sb_section_ctx *sctx; struct sb_cmd_ctx *cctx, *c_head;
struct sb_section_ctx *sctx, *head = NULL, *prev = NULL;
struct sb_sections_header *shdr; struct sb_sections_header *shdr;
int ret; int ret;
int sects = 1;
sctx = calloc(1, sizeof(*sctx)); while (sects--) {
if (!sctx)
return -ENOMEM;
ret = sb_parse_cmds(sctx); sctx = calloc(1, sizeof(*sctx));
if (ret) if (!sctx)
goto fail; goto fail;
shdr = &sctx->payload; if (!head)
/* FIXME -- bootable by default. */ head = sctx;
sctx->boot = 1;
/* FIXME -- the section ID should be configurable */ ret = sb_parse_cmds(sctx);
shdr->section_number = ictx->section_count++; if (ret)
/* FIXME -- use this instead of sctx->size */ goto fail;
shdr->section_size = sctx->size / SB_BLOCK_SIZE;
shdr->section_flags = sctx->boot ? SB_SECTION_FLAG_BOOTABLE : 0; shdr = &sctx->payload;
/* FIXME -- bootable by default. */
sctx->boot = 1;
/* FIXME -- the section ID should be configurable */
shdr->section_number = ictx->section_count++;
shdr->section_size = sctx->size / SB_BLOCK_SIZE;
shdr->section_flags = sctx->boot ? SB_SECTION_FLAG_BOOTABLE : 0;
if (prev)
prev->sect = sctx;
prev = sctx;
}
ictx->sect = sctx; ictx->sect = head;
return 0; return 0;
fail: fail:
free(sctx); while (head) {
sctx = head;
c_head = head->cmd;
while (c_head) {
cctx = c_head;
c_head = c_head->cmd;
if (cctx->data)
free(cctx->data);
free(cctx);
}
head = head->sect;
free(sctx);
}
return ret; return 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