[Sound-open-firmware] [PATCH] rimage: manifest: Move text offset into non immutable ROM structure.

Liam Girdwood liam.r.girdwood at linux.intel.com
Mon Mar 19 09:57:12 CET 2018


text_offset was added to an immutable ROM structure that would break
some tools and cause instability. Fix this by creating a new structure
for rimage manifest data that can be modified without breaking the ROM
ABI.

Signed-off-by: Liam Girdwood <liam.r.girdwood at linux.intel.com>
---
 rimage/manifest.c                     | 18 +++++++++---------
 src/include/uapi/manifest.h           | 27 +++++++++++++++++----------
 src/platform/apollolake/base_module.c | 20 +++++++++++---------
 src/platform/cannonlake/base_module.c | 20 +++++++++++---------
 src/platform/cannonlake/boot_module.c | 20 +++++++++++---------
 5 files changed, 59 insertions(+), 46 deletions(-)

diff --git a/rimage/manifest.c b/rimage/manifest.c
index 337f82a4..243c194f 100644
--- a/rimage/manifest.c
+++ b/rimage/manifest.c
@@ -194,7 +194,7 @@ static int man_get_module_manifest(struct image *image, struct module *module,
 {
 	Elf32_Shdr *section;
 	struct sof_man_segment_desc *segment;
-	struct sof_man_module sof_mod;
+	struct sof_man_module_manifest sof_mod;
 	size_t count;
 	int ret, man_section_idx;
 
@@ -224,14 +224,14 @@ static int man_get_module_manifest(struct image *image, struct module *module,
 
 	/* configure man_module with sofmod data */
 	memcpy(man_module->struct_id, "$AME", 4);
-	man_module->entry_point = sof_mod.entry_point;
-	memcpy(man_module->name, sof_mod.name, SOF_MAN_MOD_NAME_LEN);
-	memcpy(man_module->uuid, sof_mod.uuid, 16);
-	man_module->affinity_mask = sof_mod.affinity_mask;
-	man_module->type.auto_start = sof_mod.type.auto_start;
-	man_module->type.domain_dp = sof_mod.type.domain_dp;
-	man_module->type.domain_ll = sof_mod.type.domain_ll;
-	man_module->type.load_type = sof_mod.type.load_type;
+	man_module->entry_point = sof_mod.module.entry_point;
+	memcpy(man_module->name, sof_mod.module.name, SOF_MAN_MOD_NAME_LEN);
+	memcpy(man_module->uuid, sof_mod.module.uuid, 16);
+	man_module->affinity_mask = sof_mod.module.affinity_mask;
+	man_module->type.auto_start = sof_mod.module.type.auto_start;
+	man_module->type.domain_dp = sof_mod.module.type.domain_dp;
+	man_module->type.domain_ll = sof_mod.module.type.domain_ll;
+	man_module->type.load_type = sof_mod.module.type.load_type;
 
 	/* read out text_fixup_size from memory mapping */
 	module->text_fixup_size = sof_mod.text_size;
diff --git a/src/include/uapi/manifest.h b/src/include/uapi/manifest.h
index e83725bd..f53a6628 100644
--- a/src/include/uapi/manifest.h
+++ b/src/include/uapi/manifest.h
@@ -75,7 +75,7 @@ union sof_man_segment_flags {
 } __attribute__((packed));
 
 /*
- * Module segment descriptor.
+ * Module segment descriptor. Used by ROM - Immutable.
  */
 struct sof_man_segment_desc {
 	union sof_man_segment_flags flags;
@@ -93,7 +93,7 @@ struct sof_man_segment_desc {
 #define SOF_MAN_MOD_ID			{'$', 'A', 'M', 'E'}
 
 /*
- * Each module has an entry in the FW header.
+ * Each module has an entry in the FW header. Used by ROM - Immutable.
  */
 struct sof_man_module {
 	uint8_t struct_id[SOF_MAN_MOD_ID_LEN];	/* SOF_MAN_MOD_ID */
@@ -102,7 +102,6 @@ struct sof_man_module {
 	struct sof_man_module_type type;
 	uint8_t hash[SOF_MAN_MOD_SHA256_LEN];
 	uint32_t entry_point;
-	uint32_t text_size;
 	uint16_t cfg_offset;
 	uint16_t cfg_count;
 	uint32_t affinity_mask;
@@ -112,7 +111,7 @@ struct sof_man_module {
 } __attribute__((packed));
 
 /*
- * Each module has a configuration in the FW header.
+ * Each module has a configuration in the FW header. Used by ROM - Immutable.
  */
 struct sof_man_mod_config {
 	uint32_t par[4];	/* module parameters */
@@ -138,9 +137,9 @@ struct sof_man_mod_config {
 
 /*
  * The firmware has a standard header that is checked by the ROM on firmware
- * loading.
- * preload_page_count is used by DMA code loader and is entire image size on
- * CNL. i.e. CNL: total size of the binary’s .text and .rodata
+ * loading. preload_page_count is used by DMA code loader and is entire
+ * image size on CNL. i.e. CNL: total size of the binary’s .text and .rodata
+ * Used by ROM - Immutable.
  */
 struct sof_man_fw_header {
 	uint8_t header_id[4];
@@ -163,7 +162,7 @@ struct sof_man_fw_header {
 
 /*
  * Firmware manifest descriptor. This can contain N modules and N module
- * configs.
+ * configs. Used by ROM - Immutable.
  */
 struct sof_man_fw_desc {
 	struct sof_man_fw_header header;
@@ -181,7 +180,7 @@ struct sof_man_fw_desc {
 } __attribute__((packed));
 
 /*
- * Component Descriptor
+ * Component Descriptor. Used by ROM - Immutable.
  */
 struct sof_man_component_desc {
 	uint32_t reserved[2];	/* all 0 */
@@ -194,7 +193,7 @@ struct sof_man_component_desc {
 
 
 /*
- * Audio DSP extended metadata.
+ * Audio DSP extended metadata. Used by ROM - Immutable.
  */
 struct sof_man_adsp_meta_file_ext {
 	uint32_t ext_type;	/* always 17 for ADSP extension */
@@ -204,6 +203,14 @@ struct sof_man_adsp_meta_file_ext {
 	struct sof_man_component_desc comp_desc[1];
 } __attribute__((packed));
 
+/*
+ * Module Manifest for rimage module metadata. Not used by ROM.
+ */
+struct sof_man_module_manifest {
+	struct sof_man_module module;
+	uint32_t text_size;
+};
+
 /* utility to get module pointer from position */
 static inline struct sof_man_module *sof_man_get_module(
 	struct sof_man_fw_desc *desc, int index)
diff --git a/src/platform/apollolake/base_module.c b/src/platform/apollolake/base_module.c
index 56633c5b..141d7ba8 100644
--- a/src/platform/apollolake/base_module.c
+++ b/src/platform/apollolake/base_module.c
@@ -36,16 +36,18 @@
  * the SOF executable image but is inserted by object copy as a ELF section
  * for parsing by rimage (to genrate the manifest).
  */
-struct sof_man_module apl_manifest = {
-	.name	= "BASEFW",
-	.uuid	= {0x2e, 0x9e, 0x86, 0xfc, 0xf8, 0x45, 0x45, 0x40,
-		0xa4, 0x16, 0x89, 0x88, 0x0a, 0xe3, 0x20, 0xa9},
-	.entry_point = REEF_TEXT_START,
-	.type = {
-			.load_type = SOF_MAN_MOD_TYPE_MODULE,
-			.domain_ll = 1,
+struct sof_man_module_manifest apl_manifest = {
+	.module = {
+		.name	= "BASEFW",
+		.uuid	= {0x2e, 0x9e, 0x86, 0xfc, 0xf8, 0x45, 0x45, 0x40,
+			0xa4, 0x16, 0x89, 0x88, 0x0a, 0xe3, 0x20, 0xa9},
+		.entry_point = REEF_TEXT_START,
+		.type = {
+				.load_type = SOF_MAN_MOD_TYPE_MODULE,
+				.domain_ll = 1,
+		},
+		.affinity_mask = 3,
 	},
-	.affinity_mask = 3,
 	.text_size = REEF_TEXT_SIZE + L2_VECTOR_SIZE,
 };
 
diff --git a/src/platform/cannonlake/base_module.c b/src/platform/cannonlake/base_module.c
index dd5d7199..ac1f8737 100644
--- a/src/platform/cannonlake/base_module.c
+++ b/src/platform/cannonlake/base_module.c
@@ -36,16 +36,18 @@
  * the SOF executable image but is inserted by object copy as a ELF section
  * for parsing by rimage (to genrate the manifest).
  */
-struct sof_man_module cnl_manifest = {
-	.name	= "BASEFW",
-	.uuid	= {0x32, 0x8c, 0x39, 0x0e, 0xde, 0x5a, 0x4b, 0xba,
-			0x93, 0xb1, 0xc5, 0x04, 0x32, 0x28, 0x0e, 0xe4},
-	.entry_point = REEF_TEXT_START,
-	.type = {
-			.load_type = SOF_MAN_MOD_TYPE_MODULE,
-			.domain_ll = 1,
+struct sof_man_module_manifest cnl_manifest = {
+	.module = {
+		.name	= "BASEFW",
+		.uuid	= {0x32, 0x8c, 0x39, 0x0e, 0xde, 0x5a, 0x4b, 0xba,
+				0x93, 0xb1, 0xc5, 0x04, 0x32, 0x28, 0x0e, 0xe4},
+		.entry_point = REEF_TEXT_START,
+		.type = {
+				.load_type = SOF_MAN_MOD_TYPE_MODULE,
+				.domain_ll = 1,
+		},
+		.affinity_mask = 3,
 	},
-	.affinity_mask = 3,
 };
 
 /* not used, but stops linker complaining */
diff --git a/src/platform/cannonlake/boot_module.c b/src/platform/cannonlake/boot_module.c
index 7d965f5d..48374933 100644
--- a/src/platform/cannonlake/boot_module.c
+++ b/src/platform/cannonlake/boot_module.c
@@ -36,16 +36,18 @@
  * the SOF executable image but is inserted by object copy as a ELF section
  * for parsing by rimage (to genrate the manifest).
  */
-struct sof_man_module cnl_bootldr_manifest = {
-	.name	= "BRNGUP",
-	.uuid	= {0xf3, 0xe4, 0x79, 0x2b, 0x75, 0x46, 0x49, 0xf6,
-			0x89, 0xdf, 0x3b, 0xc1, 0x94, 0xa9, 0x1a, 0xeb},
-	.entry_point = IMR_BOOT_LDR_TEXT_ENTRY_BASE,
-	.type = {
-			.load_type = SOF_MAN_MOD_TYPE_MODULE,
-			.domain_ll = 1,
+struct sof_man_module_manifest cnl_bootldr_manifest = {
+	.module = {
+		.name	= "BRNGUP",
+		.uuid	= {0xf3, 0xe4, 0x79, 0x2b, 0x75, 0x46, 0x49, 0xf6,
+				0x89, 0xdf, 0x3b, 0xc1, 0x94, 0xa9, 0x1a, 0xeb},
+		.entry_point = IMR_BOOT_LDR_TEXT_ENTRY_BASE,
+		.type = {
+				.load_type = SOF_MAN_MOD_TYPE_MODULE,
+				.domain_ll = 1,
+		},
+		.affinity_mask = 3,
 	},
-	.affinity_mask = 3,
 };
 
 /* not used, but stops linker complaining */
-- 
2.14.1



More information about the Sound-open-firmware mailing list