Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions rimage/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ static int elf_read_sections(struct image *image, struct module *module)
fprintf(stdout, " BSS module metadata section at index %d\n",
man_section_idx);

/* find log entries section */
module->logs_index = elf_find_section(image, module,
".static_log_entries");
/* find log entries and fw ready sections */
module->logs_index = elf_find_section(image, module,
".static_log_entries");
fprintf(stdout, " static log entries section at index %d\n",
module->logs_index);
module->fw_ready_index = elf_find_section(image, module,
".fw_ready");
fprintf(stdout, " fw ready section at index %d\n",
module->fw_ready_index);

/* parse each section */
for (i = 0; i < hdr->e_shnum; i++) {
Expand Down Expand Up @@ -352,7 +356,8 @@ static void elf_module_limits(struct image *image, struct module *module)
section = &module->section[i];

/* module bss can sometimes be missed */
if (i != module->bss_index && i != module->logs_index) {
if (i != module->bss_index && i != module->logs_index &&
i != module->fw_ready_index) {

/* only check valid sections */
if (!(section->sh_flags & valid))
Expand Down
5 changes: 5 additions & 0 deletions rimage/file_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
#ifndef __INCLUDE_UAPI_SOF_FW_H__
#define __INCLUDE_UAPI_SOF_FW_H__

/* Skip inclusion of <sof/io.h> which causes errors */
#define __INCLUDE_IO__
#include <uapi/ipc.h>

#define SND_SOF_FW_SIG_SIZE 4
#define SND_SOF_FW_ABI 1
#define SND_SOF_FW_SIG "Reef"
Expand Down Expand Up @@ -125,5 +129,6 @@ struct snd_sof_logs_header {
uint32_t base_address; /* address of log entries section */
uint32_t data_length; /* amount of bytes following this header */
uint32_t data_offset; /* offset to first entry in this file */
struct sof_ipc_fw_version version;
};
#endif
38 changes: 36 additions & 2 deletions rimage/file_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,37 @@ int write_logs_dictionary(struct image *image)
for (i = 0; i < image->num_modules; i++) {
struct module *module = &image->module[i];

/* extract fw_version from fw_ready message located
* in .fw_ready section
*/
if (module->fw_ready_index > 0) {
Elf32_Shdr *section =
&module->section[module->fw_ready_index];

buffer = calloc(1, sizeof(struct sof_ipc_fw_ready));
if (!buffer)
return -ENOMEM;

fseek(module->fd, section->sh_offset, SEEK_SET);
size_t count = fread(buffer, 1,
sizeof(struct sof_ipc_fw_ready), module->fd);

if (count != sizeof(struct sof_ipc_fw_ready)) {
fprintf(stderr,
"error: can't read ready section %d\n",
-errno);
ret = -errno;
goto out;
}

memcpy(&header.version,
&((struct sof_ipc_fw_ready *)buffer)->version,
sizeof(header.version));

free(buffer);
buffer = NULL;
}

if (module->logs_index > 0) {
Elf32_Shdr *section = &module->section[module->logs_index];

Expand All @@ -374,7 +405,8 @@ int write_logs_dictionary(struct image *image)
size_t count = fread(buffer, 1, section->sh_size,
module->fd);
if (count != section->sh_size) {
fprintf(stderr, "error: can't read section %d\n",
fprintf(stderr,
"error: can't read logs section %d\n",
-errno);
ret = -errno;
goto out;
Expand All @@ -388,8 +420,10 @@ int write_logs_dictionary(struct image *image)
goto out;
}

fprintf(stdout, "logs dictionary: size %d\n\n",
fprintf(stdout, "logs dictionary: size %u\n",
header.data_length + header.data_offset);
fprintf(stdout, "including fw version of size: %lu\n\n",
sizeof(header.version));
}
}
out:
Expand Down
1 change: 1 addition & 0 deletions rimage/rimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct module {
int fw_size;
int bss_index;
int logs_index;
int fw_ready_index;

/* sizes do not include any gaps */
int bss_size;
Expand Down
4 changes: 4 additions & 0 deletions src/platform/apollolake/apollolake.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -567,4 +567,8 @@ SECTIONS
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}
6 changes: 5 additions & 1 deletion src/platform/baytrail/baytrail.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -513,5 +513,9 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr
}

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}
3 changes: 2 additions & 1 deletion src/platform/baytrail/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
#include <string.h>
#include <version.h>

static const struct sof_ipc_fw_ready ready = {
static const struct sof_ipc_fw_ready ready
__attribute__((section(".fw_ready"))) = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just move to end of definition (like Linux) and we are good to merge.

Copy link
Member Author

@akloniex akloniex Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly in line with kernel examples:
e.g.: in macro expansion from include/linux/kernel.h:
#define ftrace_vprintk(fmt, vargs) \ do { \ if (__builtin_constant_p(fmt)) { \ static const char *trace_printk_fmt __used \ __attribute__((section("__trace_printk_fmt"))) = \ __builtin_constant_p(fmt) ? fmt : NULL; \ \ __ftrace_vbprintk(_THIS_IP_, trace_printk_fmt, vargs); \ } else \ __ftrace_vprintk(_THIS_IP_, fmt, vargs); \ } while (0)

It is a variable attribute, and cannot be placed after assignment operator, otherwise it will not compile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, it seems we can do this where we define but not declare...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that it is defined and declared in the same statement.
I could split it into 2 separate statements if you'd like, but it seems redundant to me.

.hdr = {
.cmd = SOF_IPC_FW_READY,
.size = sizeof(struct sof_ipc_fw_ready),
Expand Down
5 changes: 5 additions & 0 deletions src/platform/cannonlake/cannonlake.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -556,4 +556,9 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}
6 changes: 5 additions & 1 deletion src/platform/haswell/broadwell.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -513,5 +513,9 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr
}

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}
6 changes: 5 additions & 1 deletion src/platform/haswell/haswell.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -513,5 +513,9 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr
}

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}
3 changes: 2 additions & 1 deletion src/platform/haswell/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
#include <string.h>
#include <version.h>

static const struct sof_ipc_fw_ready ready = {
static const struct sof_ipc_fw_ready ready
__attribute__((section(".fw_ready"))) = {
.hdr = {
.cmd = SOF_IPC_FW_READY,
.size = sizeof(struct sof_ipc_fw_ready),
Expand Down
5 changes: 5 additions & 0 deletions src/platform/icelake/icelake.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -556,4 +556,9 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}
3 changes: 2 additions & 1 deletion src/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
#include <string.h>
#include <version.h>

static const struct sof_ipc_fw_ready ready = {
static const struct sof_ipc_fw_ready ready
__attribute__((section(".fw_ready"))) = {
.hdr = {
.cmd = SOF_IPC_FW_READY,
.size = sizeof(struct sof_ipc_fw_ready),
Expand Down
5 changes: 5 additions & 0 deletions src/platform/suecreek/suecreek.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,9 @@ SECTIONS
{
*(*.static_log*)
} > static_log_entries_seg :static_log_entries_phdr

.fw_ready : ALIGN(4)
{
KEEP (*(.fw_ready))
} >sof_data :sof_data_phdr
}