Skip to content

Commit 994784b

Browse files
lyakhlgirdwood
authored andcommitted
rimage: count modules and files
When building libraries we know how many input files we use, but we also need to count how many modules each file contains. Add respective calculations. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent f23b778 commit 994784b

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

tools/rimage/src/include/rimage/module.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ struct module_sections_info {
7676
struct module {
7777
struct elf_file elf;
7878

79+
unsigned short first_module_idx;
80+
unsigned short n_modules;
81+
7982
/* Array of valid sections */
8083
struct module_section *sections;
8184

tools/rimage/src/include/rimage/rimage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct fw_image_manifest_module {
104104
struct sof_man_mod_config *mod_cfg;
105105
uint32_t mod_man_count;
106106
struct sof_man_module *mod_man;
107+
unsigned int output_mod_cfg_count;
107108
};
108109

109110
/*

tools/rimage/src/manifest.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,11 @@ static int man_module_create_reloc(struct image *image, struct manifest_module *
520520
return err;
521521
}
522522

523+
/*
524+
* number of manifests in .module, one module can contain several manifests
525+
* e.g. when a module defines multiple Module Adapter interfaces like
526+
* volume for PEAKVOL and GAIN, mixin_mixout for MIXIN and MIXOUT etc.
527+
*/
523528
unsigned int n_mod = section.header.data.size / sizeof(*sof_mod);
524529

525530
if (!n_mod || n_mod * sizeof(*sof_mod) != section.header.data.size) {
@@ -548,6 +553,9 @@ static int man_module_create_reloc(struct image *image, struct manifest_module *
548553
man_module_fill_reloc(module, *man_module);
549554
}
550555

556+
module->file.n_modules = n_mod;
557+
modules->output_mod_cfg_count += n_mod;
558+
551559
elf_section_free(&section);
552560

553561
module_print_zones(&module->file);
@@ -651,6 +659,7 @@ static int man_create_modules(struct image *image, struct sof_man_fw_desc *desc,
651659
}
652660

653661
image->image_end = 0;
662+
unsigned int n_mod = 0;
654663

655664
for (man_module = (struct sof_man_module *)((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(i - offset));
656665
i < image->num_modules;
@@ -663,7 +672,9 @@ static int man_create_modules(struct image *image, struct sof_man_fw_desc *desc,
663672
module->foffset = image->image_end;
664673

665674
if (image->reloc) {
675+
module->file.first_module_idx = n_mod;
666676
err = man_module_create_reloc(image, module, &man_module);
677+
n_mod += module->file.n_modules;
667678
} else {
668679
/* Some platforms don't have modules configuration in toml file */
669680
if (image->adsp->modules) {

0 commit comments

Comments
 (0)