Skip to content

Commit 33dbbfb

Browse files
lyakhnashif
authored andcommitted
Xtensa: ADSP: bootloader: use proper struct field access
Replace byte-counting with proper structure field access. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent c2400a4 commit 33dbbfb

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

soc/xtensa/intel_adsp/common/bootloader/boot_loader.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ static void parse_module(struct sof_man_fw_header *hdr,
9999
switch (mod->segment[i].flags.r.type) {
100100
case SOF_MAN_SEGMENT_TEXT:
101101
case SOF_MAN_SEGMENT_DATA:
102-
bias = (mod->segment[i].file_offset -
103-
SOF_MAN_ELF_TEXT_OFFSET);
102+
bias = mod->segment[i].file_offset -
103+
SOF_MAN_ELF_TEXT_OFFSET;
104104

105105
/* copy from IMR to SRAM */
106106
bmemcpy((void *)mod->segment[i].v_base_addr,
107-
(void *)((int)hdr + bias),
107+
(uint8_t *)hdr + bias,
108108
mod->segment[i].flags.r.length *
109109
HOST_PAGE_SIZE);
110110
break;
@@ -140,8 +140,8 @@ static uint32_t get_fw_size_in_use(void)
140140

141141
/* Calculate fw size passed in BASEFW module in MANIFEST */
142142
for (i = MAN_SKIP_ENTRIES; i < hdr->num_module_entries; i++) {
143-
mod = (struct sof_man_module *)((char *)desc +
144-
SOF_MAN_MODULE_OFFSET(i));
143+
mod = desc->man_module + i;
144+
145145
if (strcmp((char *)mod->name, "BASEFW"))
146146
continue;
147147
for (i = 0; i < MANIFEST_SEGMENT_COUNT; i++) {
@@ -172,8 +172,8 @@ static void parse_manifest(void)
172172

173173
/* copy module to SRAM - skip bootloader module */
174174
for (i = MAN_SKIP_ENTRIES; i < hdr->num_module_entries; i++) {
175+
mod = desc->man_module + i;
175176

176-
mod = (void *)((uintptr_t)desc + SOF_MAN_MODULE_OFFSET(i));
177177
z_xtensa_cache_inv(mod, sizeof(*mod));
178178
parse_module(hdr, mod);
179179
}

soc/xtensa/intel_adsp/common/bootloader/manifest.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct sof_man_fw_desc {
156156
* struct sof_man_mod_config mod_config[];
157157
*/
158158

159+
struct sof_man_module man_module[];
159160
} __attribute__((packed));
160161

161162
/*
@@ -189,11 +190,4 @@ struct sof_man_module_manifest {
189190
uint32_t text_size;
190191
};
191192

192-
/*
193-
* Module offset in manifest.
194-
*/
195-
#define SOF_MAN_MODULE_OFFSET(index) \
196-
(sizeof(struct sof_man_fw_header) + \
197-
(index) * sizeof(struct sof_man_module))
198-
199193
#endif

0 commit comments

Comments
 (0)