Skip to content

Commit ba8534b

Browse files
lyakhlgirdwood
authored andcommitted
Fix bitmap according to the IMR type
When the IMR type is set to 4, the default bitmap field #4 must be 0x10. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent f3eef3c commit ba8534b

4 files changed

Lines changed: 47 additions & 33 deletions

File tree

src/adsp_config.c

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,10 @@ static void dump_signed_pkg(const struct signed_pkg_info_ext *signed_pkg)
974974
}
975975

976976
static int parse_signed_pkg(const toml_table_t *toml, struct parse_ctx *pctx,
977-
struct signed_pkg_info_ext *out, bool verbose)
977+
struct image *image, bool verbose)
978978
{
979+
struct adsp *adsp = image->adsp;
980+
struct signed_pkg_info_ext *out = &adsp->man_v1_8->signed_pkg;
979981
struct signed_pkg_info_module *mod;
980982
toml_array_t *bitmap_array;
981983
toml_array_t *module_array;
@@ -1022,8 +1024,8 @@ static int parse_signed_pkg(const toml_table_t *toml, struct parse_ctx *pctx,
10221024
/* bitmap array */
10231025
bitmap_array = toml_array_in(signed_pkg, "bitmap");
10241026
if (!bitmap_array) {
1025-
/* default value */
1026-
out->bitmap[4] = 8;
1027+
/* default value, depending on the IMR type */
1028+
out->bitmap[4] = image->imr_type == 4 ? 0x10 : 0x8;
10271029
} else {
10281030
++ctx.array_cnt;
10291031
if (toml_array_kind(bitmap_array) != 'v' || toml_array_type(bitmap_array) != 'i' ||
@@ -1130,8 +1132,10 @@ static void dump_signed_pkg_v2_5(const struct signed_pkg_info_ext_v2_5 *signed_p
11301132
}
11311133

11321134
static int parse_signed_pkg_v2_5(const toml_table_t *toml, struct parse_ctx *pctx,
1133-
struct signed_pkg_info_ext_v2_5 *out, bool verbose)
1135+
struct image *image, bool verbose)
11341136
{
1137+
struct adsp *adsp = image->adsp;
1138+
struct signed_pkg_info_ext_v2_5 *out = &adsp->man_v2_5->signed_pkg;
11351139
struct signed_pkg_info_module_v2_5 *mod;
11361140
toml_array_t *bitmap_array;
11371141
toml_array_t *module_array;
@@ -1178,8 +1182,8 @@ static int parse_signed_pkg_v2_5(const toml_table_t *toml, struct parse_ctx *pct
11781182
/* bitmap array */
11791183
bitmap_array = toml_array_in(signed_pkg, "bitmap");
11801184
if (!bitmap_array) {
1181-
/* default value - some use 0x10*/
1182-
out->bitmap[4] = 0x8;
1185+
/* default value, depending on the IMR type */
1186+
out->bitmap[4] = image->imr_type == 4 ? 0x10 : 0x8;
11831187
} else {
11841188
++ctx.array_cnt;
11851189
if (toml_array_kind(bitmap_array) != 'v' || toml_array_type(bitmap_array) != 'i' ||
@@ -1281,8 +1285,10 @@ static void dump_signed_pkg_ace_v1_5(const struct signed_pkg_info_ext_ace_v1_5 *
12811285
}
12821286

12831287
static int parse_signed_pkg_ace_v1_5(const toml_table_t *toml, struct parse_ctx *pctx,
1284-
struct signed_pkg_info_ext_ace_v1_5 *out, bool verbose)
1288+
struct image *image, bool verbose)
12851289
{
1290+
struct adsp *adsp = image->adsp;
1291+
struct signed_pkg_info_ext_ace_v1_5 *out = &adsp->man_ace_v1_5->signed_pkg;
12861292
struct signed_pkg_info_module_ace_v1_5 *mod;
12871293
toml_array_t *module_array;
12881294
toml_table_t *signed_pkg;
@@ -2240,9 +2246,10 @@ static int parse_module(const toml_table_t *toml, struct parse_ctx *pctx,
22402246
return 0;
22412247
}
22422248

2243-
static int parse_adsp_config_v1_0(const toml_table_t *toml, struct adsp *out,
2244-
bool verbose)
2249+
static int parse_adsp_config_v1_0(const toml_table_t *toml, struct image *image)
22452250
{
2251+
struct adsp *out = image->adsp;
2252+
bool verbose = image->verbose;
22462253
struct parse_ctx ctx;
22472254
int ret;
22482255

@@ -2267,9 +2274,10 @@ static int parse_adsp_config_v1_0(const toml_table_t *toml, struct adsp *out,
22672274
return 0;
22682275
}
22692276

2270-
static int parse_adsp_config_v1_5(const toml_table_t *toml, struct adsp *out,
2271-
bool verbose)
2277+
static int parse_adsp_config_v1_5(const toml_table_t *toml, struct image *image)
22722278
{
2279+
struct adsp *out = image->adsp;
2280+
bool verbose = image->verbose;
22732281
struct parse_ctx ctx;
22742282
int ret;
22752283

@@ -2333,9 +2341,10 @@ static int parse_adsp_config_v1_5(const toml_table_t *toml, struct adsp *out,
23332341
return 0;
23342342
}
23352343

2336-
static int parse_adsp_config_v1_8(const toml_table_t *toml, struct adsp *out,
2337-
bool verbose)
2344+
static int parse_adsp_config_v1_8(const toml_table_t *toml, struct image *image)
23382345
{
2346+
struct adsp *out = image->adsp;
2347+
bool verbose = image->verbose;
23392348
struct parse_ctx ctx;
23402349
int ret;
23412350

@@ -2370,7 +2379,7 @@ static int parse_adsp_config_v1_8(const toml_table_t *toml, struct adsp *out,
23702379
if (ret < 0)
23712380
return err_key_parse("css", NULL);
23722381

2373-
ret = parse_signed_pkg(toml, &ctx, &out->man_v1_8->signed_pkg, verbose);
2382+
ret = parse_signed_pkg(toml, &ctx, image, verbose);
23742383
if (ret < 0)
23752384
return err_key_parse("signed_pkg", NULL);
23762385

@@ -2394,9 +2403,10 @@ static int parse_adsp_config_v1_8(const toml_table_t *toml, struct adsp *out,
23942403
return 0;
23952404
}
23962405

2397-
static int parse_adsp_config_v2_5(const toml_table_t *toml, struct adsp *out,
2398-
bool verbose)
2406+
static int parse_adsp_config_v2_5(const toml_table_t *toml, struct image *image)
23992407
{
2408+
struct adsp *out = image->adsp;
2409+
bool verbose = image->verbose;
24002410
struct parse_ctx ctx;
24012411
int ret;
24022412

@@ -2431,7 +2441,7 @@ static int parse_adsp_config_v2_5(const toml_table_t *toml, struct adsp *out,
24312441
if (ret < 0)
24322442
return err_key_parse("css", NULL);
24332443

2434-
ret = parse_signed_pkg_v2_5(toml, &ctx, &out->man_v2_5->signed_pkg, verbose);
2444+
ret = parse_signed_pkg_v2_5(toml, &ctx, image, verbose);
24352445
if (ret < 0)
24362446
return err_key_parse("signed_pkg", NULL);
24372447

@@ -2459,9 +2469,10 @@ static int parse_adsp_config_v2_5(const toml_table_t *toml, struct adsp *out,
24592469
return 0;
24602470
}
24612471

2462-
static int parse_adsp_config_ace_v1_5(const toml_table_t *toml, struct adsp *out,
2463-
bool verbose)
2472+
static int parse_adsp_config_ace_v1_5(const toml_table_t *toml, struct image *image)
24642473
{
2474+
struct adsp *out = image->adsp;
2475+
bool verbose = image->verbose;
24652476
struct parse_ctx ctx;
24662477
int ret;
24672478

@@ -2495,7 +2506,7 @@ static int parse_adsp_config_ace_v1_5(const toml_table_t *toml, struct adsp *out
24952506
if (ret < 0)
24962507
return err_key_parse("css", NULL);
24972508

2498-
ret = parse_signed_pkg_ace_v1_5(toml, &ctx, &out->man_ace_v1_5->signed_pkg, verbose);
2509+
ret = parse_signed_pkg_ace_v1_5(toml, &ctx, image, verbose);
24992510
if (ret < 0)
25002511
return err_key_parse("signed_pkg", NULL);
25012512

@@ -2556,7 +2567,7 @@ static int parse_version(toml_table_t *toml, int64_t version[2])
25562567
struct config_parser {
25572568
int major;
25582569
int minor;
2559-
int (*parse)(const toml_table_t *toml, struct adsp *out, bool verbose);
2570+
int (*parse)(const toml_table_t *toml, struct image *image);
25602571
};
25612572

25622573
static const struct config_parser *find_config_parser(int64_t version[2])
@@ -2580,7 +2591,7 @@ static const struct config_parser *find_config_parser(int64_t version[2])
25802591
return NULL;
25812592
}
25822593

2583-
static int adsp_parse_config_fd(FILE *fd, struct adsp *out, bool verbose)
2594+
static int adsp_parse_config_fd(FILE *fd, struct image *image)
25842595
{
25852596
const struct config_parser *parser;
25862597
int64_t manifest_version[2];
@@ -2607,22 +2618,22 @@ static int adsp_parse_config_fd(FILE *fd, struct adsp *out, bool verbose)
26072618
}
26082619

26092620
/* run dedicated parser */
2610-
ret = parser->parse(toml, out, verbose);
2621+
ret = parser->parse(toml, image);
26112622
error:
26122623
toml_free(toml);
26132624
return ret;
26142625
}
26152626

26162627
/* public function, fully handle parsing process */
2617-
int adsp_parse_config(const char *file, struct adsp *out, bool verbose)
2628+
int adsp_parse_config(const char *file, struct image *image)
26182629
{
26192630
FILE *fd;
26202631
int ret;
26212632

26222633
fd = fopen(file, "r");
26232634
if (!fd)
26242635
return log_err(-EIO, "error: can't open '%s' file\n", file);
2625-
ret = adsp_parse_config_fd(fd, out, verbose);
2636+
ret = adsp_parse_config_fd(fd, image);
26262637
fclose(fd);
26272638
return ret;
26282639
}

src/include/rimage/adsp_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
#include <rimage/rimage.h>
66
#include <stdbool.h>
77

8-
int adsp_parse_config(const char *file, struct adsp *out, bool verbose);
8+
int adsp_parse_config(const char *file, struct image *image);
99
void adsp_free(struct adsp *adsp);

src/include/rimage/rimage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct image {
7777
FILE *out_fd;
7878
void *pos;
7979

80-
const struct adsp *adsp;
80+
struct adsp *adsp;
8181
int abi;
8282
int verbose;
8383
int reloc; /* ELF data is relocatable */
@@ -111,6 +111,8 @@ struct image {
111111
uint16_t fw_ver_minor;
112112
uint16_t fw_ver_micro;
113113
uint16_t fw_ver_build;
114+
115+
uint32_t imr_type;
114116
};
115117

116118
struct mem_zone {

src/rimage.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ int main(int argc, char *argv[])
4040
struct adsp *heap_adsp;
4141
const char *adsp_config = NULL;
4242
int opt, ret, i, first_non_opt;
43-
int imr_type = MAN_DEFAULT_IMR_TYPE;
4443
int use_ext_man = 0;
4544
unsigned int pv_bit = 0;
4645
bool imr_type_override = false;
4746

4847
memset(&image, 0, sizeof(image));
4948

49+
image.imr_type = MAN_DEFAULT_IMR_TYPE;
50+
5051
while ((opt = getopt(argc, argv, "ho:va:s:k:ri:f:b:ec:y:q:p")) != -1) {
5152
switch (opt) {
5253
case 'o':
@@ -68,7 +69,7 @@ int main(int argc, char *argv[])
6869
image.reloc = 1;
6970
break;
7071
case 'i':
71-
imr_type = atoi(optarg);
72+
image.imr_type = atoi(optarg);
7273
imr_type_override = true;
7374
break;
7475
case 'f':
@@ -155,7 +156,7 @@ int main(int argc, char *argv[])
155156
}
156157
image.adsp = heap_adsp;
157158
memset(heap_adsp, 0, sizeof(*heap_adsp));
158-
ret = adsp_parse_config(adsp_config, heap_adsp, image.verbose);
159+
ret = adsp_parse_config(adsp_config, &image);
159160
if (ret < 0)
160161
goto out;
161162

@@ -173,19 +174,19 @@ int main(int argc, char *argv[])
173174
/* set IMR Type and the PV bit in found machine definition */
174175
if (image.adsp->man_v1_8) {
175176
if (imr_type_override)
176-
image.adsp->man_v1_8->adsp_file_ext.imr_type = imr_type;
177+
image.adsp->man_v1_8->adsp_file_ext.imr_type = image.imr_type;
177178
image.adsp->man_v1_8->css.reserved0 = pv_bit;
178179
}
179180

180181
if (image.adsp->man_v2_5) {
181182
if (imr_type_override)
182-
image.adsp->man_v2_5->adsp_file_ext.imr_type = imr_type;
183+
image.adsp->man_v2_5->adsp_file_ext.imr_type = image.imr_type;
183184
image.adsp->man_v2_5->css.reserved0 = pv_bit;
184185
}
185186

186187
if (image.adsp->man_ace_v1_5) {
187188
if (imr_type_override)
188-
image.adsp->man_ace_v1_5->adsp_file_ext.imr_type = imr_type;
189+
image.adsp->man_ace_v1_5->adsp_file_ext.imr_type = image.imr_type;
189190
image.adsp->man_ace_v1_5->css.reserved0 = pv_bit;
190191
}
191192

0 commit comments

Comments
 (0)