summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/cbfstool/bpdt_formats/bpdt_1_6.c18
-rw-r--r--util/cbfstool/bpdt_formats/bpdt_1_7.c22
-rw-r--r--util/cbfstool/cse_serger.c32
-rw-r--r--util/cbfstool/cse_serger.h15
4 files changed, 49 insertions, 38 deletions
diff --git a/util/cbfstool/bpdt_formats/bpdt_1_6.c b/util/cbfstool/bpdt_formats/bpdt_1_6.c
index eaa2902670..b894936543 100644
--- a/util/cbfstool/bpdt_formats/bpdt_1_6.c
+++ b/util/cbfstool/bpdt_formats/bpdt_1_6.c
@@ -142,21 +142,21 @@ static void inc_bpdt_entry_count(bpdt_hdr_ptr ptr)
h->descriptor_count++;
}
-static cse_layout_ptr create_cse_layout(const struct cse_layout_regions *r)
+static cse_layout_ptr create_cse_layout(const struct region *r)
{
struct cse_layout *l = malloc(sizeof(*l));
if (!l)
return NULL;
- l->data_offset = r->data_partition.offset;
- l->data_size = r->data_partition.size;
- l->bp1_offset = r->bp1.offset;
- l->bp1_size = r->bp1.size;
- l->bp2_offset = r->bp2.offset;
- l->bp2_size = r->bp2.size;
- l->bp3_offset = r->bp3.offset;
- l->bp3_size = r->bp3.size;
+ l->data_offset = r[DP].offset;
+ l->data_size = r[DP].size;
+ l->bp1_offset = r[BP1].offset;
+ l->bp1_size = r[BP1].size;
+ l->bp2_offset = r[BP2].offset;
+ l->bp2_size = r[BP2].size;
+ l->bp3_offset = r[BP3].offset;
+ l->bp3_size = r[BP3].size;
l->checksum = 0; /* unused */
return 0;
diff --git a/util/cbfstool/bpdt_formats/bpdt_1_7.c b/util/cbfstool/bpdt_formats/bpdt_1_7.c
index 53294242ca..9badc82c11 100644
--- a/util/cbfstool/bpdt_formats/bpdt_1_7.c
+++ b/util/cbfstool/bpdt_formats/bpdt_1_7.c
@@ -185,7 +185,7 @@ static uint32_t calculate_layout_checksum(struct cse_layout *l)
return calc_checksum;
}
-static cse_layout_ptr create_cse_layout(const struct cse_layout_regions *r)
+static cse_layout_ptr create_cse_layout(const struct region *r)
{
struct cse_layout *l = calloc(1, sizeof(*l));
@@ -196,16 +196,16 @@ static cse_layout_ptr create_cse_layout(const struct cse_layout_regions *r)
l->size = sizeof(struct cse_layout) - sizeof(l->rom_bypass);
l->redundancy = 0;
l->checksum = 0;
- l->data_offset = r->data_partition.offset;
- l->data_size = r->data_partition.size;
- l->bp1_offset = r->bp1.offset;
- l->bp1_size = r->bp1.size;
- l->bp2_offset = r->bp2.offset;
- l->bp2_size = r->bp2.size;
- l->bp3_offset = r->bp3.offset;
- l->bp3_size = r->bp3.size;
- l->bp4_offset = r->bp4.offset;
- l->bp4_size = r->bp4.size;
+ l->data_offset = r[DP].offset;
+ l->data_size = r[DP].size;
+ l->bp1_offset = r[BP1].offset;
+ l->bp1_size = r[BP1].size;
+ l->bp2_offset = r[BP2].offset;
+ l->bp2_size = r[BP2].size;
+ l->bp3_offset = r[BP3].offset;
+ l->bp3_size = r[BP3].size;
+ l->bp4_offset = r[BP4].offset;
+ l->bp4_size = r[BP4].size;
l->bp5_offset = 0;
l->bp5_size = 0;
l->temp_base_addr = 0;
diff --git a/util/cbfstool/cse_serger.c b/util/cbfstool/cse_serger.c
index c8bd1040e3..13afeab273 100644
--- a/util/cbfstool/cse_serger.c
+++ b/util/cbfstool/cse_serger.c
@@ -21,7 +21,7 @@ static struct params {
const char *image_name;
const char *version_str;
const char *input_file;
- struct cse_layout_regions layout_regions;
+ struct region layout_regions[BP_TOTAL];
} params;
static const struct {
@@ -640,14 +640,14 @@ static int allocate_buffer(struct buffer *buff, struct buffer *wbuff, const char
return 0;
}
-static int cmd_create_layout(void)
+static int fill_layout_buffer(struct buffer *buff)
{
- struct buffer buff, wbuff;
+ struct buffer wbuff;
- if (allocate_buffer(&buff, &wbuff, "CSE layout"))
+ if (allocate_buffer(buff, &wbuff, "CSE layout"))
return -1;
- ifwi.cse_layout = ifwi.bpdt_ops->create_layout(&params.layout_regions);
+ ifwi.cse_layout = ifwi.bpdt_ops->create_layout(&params.layout_regions[0]);
if (!ifwi.cse_layout) {
ERROR("Failed to create layout!\n");
return -1;
@@ -658,6 +658,16 @@ static int cmd_create_layout(void)
return -1;
}
+ return 0;
+}
+
+static int cmd_create_layout(void)
+{
+ struct buffer buff;
+
+ if (fill_layout_buffer(&buff))
+ return -1;
+
buffer_write_file(&buff, params.image_name);
return 0;
}
@@ -815,7 +825,7 @@ static void usage(const char *name)
"COMMANDs:\n"
" print [-s][-n NAME][-t TYPE]\n"
" dump [-o DIR][-n NAME]\n"
- " create-layout --dp <offset:size> --bp1 <offset:size> --bp2 <offset:size> -v VERSION\n"
+ " create-layout --dp <offset:size> --bp* <offset:size> -v VERSION\n"
" print-layout -v VERSION\n"
" create-bpdt -v VERSION\n"
" add [-n NAME][-t TYPE][-f INPUT_FILE]\n"
@@ -896,19 +906,19 @@ int main(int argc, char **argv)
params.partition_type = atoi(optarg);
break;
case LONGOPT_BP1:
- parse_region(&params.layout_regions.bp1, optarg);
+ parse_region(&params.layout_regions[BP1], optarg);
break;
case LONGOPT_BP2:
- parse_region(&params.layout_regions.bp2, optarg);
+ parse_region(&params.layout_regions[BP2], optarg);
break;
case LONGOPT_BP3:
- parse_region(&params.layout_regions.bp3, optarg);
+ parse_region(&params.layout_regions[BP3], optarg);
break;
case LONGOPT_BP4:
- parse_region(&params.layout_regions.bp4, optarg);
+ parse_region(&params.layout_regions[BP4], optarg);
break;
case LONGOPT_DATA:
- parse_region(&params.layout_regions.data_partition, optarg);
+ parse_region(&params.layout_regions[DP], optarg);
break;
case 'h':
case '?':
diff --git a/util/cbfstool/cse_serger.h b/util/cbfstool/cse_serger.h
index 8727f59422..e1f351abf5 100644
--- a/util/cbfstool/cse_serger.h
+++ b/util/cbfstool/cse_serger.h
@@ -27,12 +27,13 @@ enum subpart_entry_version {
SUBPART_ENTRY_VERSION_1 = 1,
};
-struct cse_layout_regions {
- struct region data_partition;
- struct region bp1;
- struct region bp2;
- struct region bp3;
- struct region bp4;
+enum {
+ DP,
+ BP1,
+ BP2,
+ BP3,
+ BP4,
+ BP_TOTAL,
};
typedef void *cse_layout_ptr;
@@ -56,7 +57,7 @@ struct bpdt_ops {
size_t (*get_entry_count)(const bpdt_hdr_ptr ptr);
void (*inc_entry_count)(bpdt_hdr_ptr ptr);
- cse_layout_ptr (*create_layout)(const struct cse_layout_regions *regions);
+ cse_layout_ptr (*create_layout)(const struct region *regions);
void (*print_layout)(const cse_layout_ptr ptr);
cse_layout_ptr (*read_layout)(struct buffer *buff);
int (*write_layout)(struct buffer *buff, const cse_layout_ptr ptr);