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
98 changes: 71 additions & 27 deletions rimage/file_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// Copyright(c) 2015 Intel Corporation. All rights reserved.

#include <kernel/abi.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
Expand Down Expand Up @@ -72,6 +73,73 @@ static int get_mem_zone_type(struct image *image, Elf32_Shdr *section)
return SOF_FW_BLK_TYPE_INVALID;
}

static int fw_version_copy(struct snd_sof_logs_header *header,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like the separating out of this function can be its own patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it were just refactor, then yea. But here you'd have 1 diff to have it changed in another.

const struct module *module)
{
Elf32_Shdr *section = NULL;
struct sof_ipc_ext_data_hdr *ext_hdr = NULL;
void *buffer = NULL;

if (module->fw_ready_index <= 0)
return 0;

section = &module->section[module->fw_ready_index];

buffer = calloc(1, section->size);
if (!buffer)
return -ENOMEM;

fseek(module->fd, section->off, SEEK_SET);
size_t count = fread(buffer, 1,
section->size, module->fd);

if (count != section->size) {
fprintf(stderr, "error: can't read ready section %d\n", -errno);
free(buffer);
return -errno;
}

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

/* fw_ready structure contains main (primarily kernel)
* ABI version.
*/

fprintf(stdout, "fw abi main version: %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(header->version.abi_version),
SOF_ABI_VERSION_MINOR(header->version.abi_version),
SOF_ABI_VERSION_PATCH(header->version.abi_version));

/* let's find dbg abi version, which the log client
* is interested in and override the kernel's one.
*
* skip the base fw-ready record and begin from the first extension.
*/
ext_hdr = buffer + ((struct sof_ipc_fw_ready *)buffer)->hdr.size;
while ((uintptr_t)ext_hdr < (uintptr_t)buffer + section->size) {
if (ext_hdr->type == SOF_IPC_EXT_USER_ABI_INFO) {
header->version.abi_version =
((struct sof_ipc_user_abi_version *)
ext_hdr)->abi_dbg_version;
break;
}
//move to the next entry
ext_hdr = (struct sof_ipc_ext_data_hdr *)
((uint8_t *)ext_hdr + ext_hdr->hdr.size);
}

fprintf(stdout, "fw abi dbg version: %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(header->version.abi_version),
SOF_ABI_VERSION_MINOR(header->version.abi_version),
SOF_ABI_VERSION_PATCH(header->version.abi_version));

free(buffer);

return 0;
}

static int block_idx;

static int write_block(struct image *image, struct module *module,
Expand Down Expand Up @@ -389,33 +457,9 @@ int write_logs_dictionary(struct image *image)
/* 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->off, 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;
}
ret = fw_version_copy(&header, module);
if (ret < 0)
goto out;

if (module->logs_index > 0) {
Elf32_Shdr *section =
Expand Down
8 changes: 8 additions & 0 deletions src/include/ipc/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum sof_ipc_ext_data {
SOF_IPC_EXT_WINDOW,
SOF_IPC_EXT_CC_INFO,
SOF_IPC_EXT_PROBE_INFO,
SOF_IPC_EXT_USER_ABI_INFO,
};

/* FW version - SOF_IPC_GLB_VERSION */
Expand Down Expand Up @@ -151,4 +152,11 @@ struct sof_ipc_probe_support {
uint32_t reserved[2];
} __attribute__((packed));

/* extended data: user abi version(s) */
struct sof_ipc_user_abi_version {
struct sof_ipc_ext_data_hdr ext_hdr;

uint32_t abi_dbg_version;
} __attribute__((packed));

#endif /* __IPC_INFO_H__ */
2 changes: 1 addition & 1 deletion src/include/kernel/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/** \brief SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 13
#define SOF_ABI_MINOR 14
#define SOF_ABI_PATCH 0

/** \brief SOF ABI version number. Format within 32bit word is MMmmmppp */
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/fw-ready-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@

extern const struct sof_ipc_cc_version cc_version;
extern const struct sof_ipc_probe_support probe_support;
extern const struct sof_ipc_user_abi_version user_abi_version;

#endif /* __IPC_FW_READY_METADATA_H__ */
29 changes: 29 additions & 0 deletions src/include/user/abi_dbg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Marcin Maka <marcin.maka@linux.intel.com>
*/

/**
* \file include/user/abi_dbg.h
* \brief ABI definitions for debug interfaces accessed by user space apps.
* \author Marcin Maka <marcin.maka@linux.intel.com>
*
* Follows the rules documented in include/user/abi.h.
*/

#include <kernel/abi.h>

#ifndef __USER_ABI_DBG_H__
#define __USER_ABI_DBG_H__

#define SOF_ABI_DBG_MAJOR 3
#define SOF_ABI_DBG_MINOR 14
#define SOF_ABI_DBG_PATCH 0
Comment on lines +21 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

Is 'debug abi' the best name for this? We have folders that are named by-abi-user (kernelspace or userspace), but ABI version symbols are named by-feature (generic vs debug).

Copy link
Contributor

Choose a reason for hiding this comment

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

Nvm, I see it's going to be more granular for user, versions are in sof_ipc_user_abi_version


#define SOF_ABI_DBG_VERSION SOF_ABI_VER(SOF_ABI_DBG_MAJOR, \
SOF_ABI_DBG_MINOR, \
SOF_ABI_DBG_PATCH)

#endif /* __USER_ABI_DBG_H__ */
3 changes: 2 additions & 1 deletion src/ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ set_property(TARGET data_structs APPEND

add_local_sources(data_structs
cc_version.c
probe_support.c)
probe_support.c
user_abi_version.c)

target_link_libraries(data_structs sof_options)
target_link_libraries(sof_static_libraries INTERFACE data_structs)
18 changes: 18 additions & 0 deletions src/ipc/user_abi_version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Marcin Maka <marcin.maka@linux.intel.com>

#include <ipc/info.h>
#include <user/abi_dbg.h>

const struct sof_ipc_user_abi_version user_abi_version
__attribute__((section(".fw_ready_metadata"))) = {
.ext_hdr = {
.hdr.cmd = SOF_IPC_FW_READY,
.hdr.size = sizeof(struct sof_ipc_user_abi_version),
.type = SOF_IPC_EXT_USER_ABI_INFO,
},
.abi_dbg_version = SOF_ABI_DBG_VERSION,
};
4 changes: 4 additions & 0 deletions src/platform/baytrail/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ int platform_boot_complete(uint32_t boot_message)

mailbox_dspbox_write(mb_offset, &probe_support,
probe_support.ext_hdr.hdr.size);
mb_offset = mb_offset + probe_support.ext_hdr.hdr.size;

mailbox_dspbox_write(mb_offset, &user_abi_version,
user_abi_version.ext_hdr.hdr.size);

/* now interrupt host to tell it we are done booting */
shim_write(SHIM_IPCDL, SOF_IPC_FW_READY | outbox);
Expand Down
4 changes: 4 additions & 0 deletions src/platform/haswell/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ int platform_boot_complete(uint32_t boot_message)

mailbox_dspbox_write(mb_offset, &probe_support,
probe_support.ext_hdr.hdr.size);
mb_offset = mb_offset + probe_support.ext_hdr.hdr.size;

mailbox_dspbox_write(mb_offset, &user_abi_version,
user_abi_version.ext_hdr.hdr.size);

/* now interrupt host to tell it we are done booting */
shim_write(SHIM_IPCD, outbox | SHIM_IPCD_BUSY);
Expand Down
4 changes: 4 additions & 0 deletions src/platform/imx8/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ int platform_boot_complete(uint32_t boot_message)

mailbox_dspbox_write(mb_offset, &probe_support,
probe_support.ext_hdr.hdr.size);
mb_offset = mb_offset + probe_support.ext_hdr.hdr.size;

mailbox_dspbox_write(mb_offset, &user_abi_version,
user_abi_version.ext_hdr.hdr.size);

/* now interrupt host to tell it we are done booting */
imx_mu_xcr_rmw(IMX_MU_xCR_GIRn(1), 0);
Expand Down
4 changes: 4 additions & 0 deletions src/platform/imx8m/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ int platform_boot_complete(uint32_t boot_message)

mailbox_dspbox_write(mb_offset, &probe_support,
probe_support.ext_hdr.hdr.size);
mb_offset = mb_offset + probe_support.ext_hdr.hdr.size;

mailbox_dspbox_write(mb_offset, &user_abi_version,
user_abi_version.ext_hdr.hdr.size);

/* now interrupt host to tell it we are done booting */
imx_mu_xcr_rmw(IMX_MU_xCR_GIRn(1), 0);
Expand Down
4 changes: 4 additions & 0 deletions src/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ int platform_boot_complete(uint32_t boot_message)

mailbox_dspbox_write(mb_offset, &probe_support,
probe_support.ext_hdr.hdr.size);
mb_offset = mb_offset + probe_support.ext_hdr.hdr.size;

mailbox_dspbox_write(mb_offset, &user_abi_version,
user_abi_version.ext_hdr.hdr.size);

/* tell host we are ready */
#if CAVS_VERSION == CAVS_VERSION_1_5
Expand Down
22 changes: 12 additions & 10 deletions tools/logger/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <errno.h>
#include <unistd.h>
#include <math.h>
#include <kernel/abi.h>
#include <user/abi_dbg.h>
#include <user/trace.h>
#include "convert.h"

Expand Down Expand Up @@ -445,15 +445,16 @@ int convert(const struct convert_config *config) {
return -EINVAL;
}

/* logger and version_file abi verification */
if SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, ver.abi_version) {
/* logger and version_file abi dbg verification */
if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_DBG_VERSION,
ver.abi_version)) {
fprintf(stderr, "Error: abi version in %s file "
"does not coincide with abi version used "
"by logger.\n", config->version_file);
fprintf(stderr, "logger ABI Version is %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(SOF_ABI_VERSION),
SOF_ABI_VERSION_MINOR(SOF_ABI_VERSION),
SOF_ABI_VERSION_PATCH(SOF_ABI_VERSION));
SOF_ABI_VERSION_MAJOR(SOF_ABI_DBG_VERSION),
SOF_ABI_VERSION_MINOR(SOF_ABI_DBG_VERSION),
SOF_ABI_VERSION_PATCH(SOF_ABI_DBG_VERSION));
fprintf(stderr, "version_file ABI Version is %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(ver.abi_version),
SOF_ABI_VERSION_MINOR(ver.abi_version),
Expand All @@ -463,14 +464,15 @@ int convert(const struct convert_config *config) {
}

/* default logger and ldc_file abi verification */
if SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, snd.version.abi_version) {
if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_DBG_VERSION,
snd.version.abi_version)) {
fprintf(stderr, "Error: abi version in %s file "
"does not coincide with abi version used "
"by logger.\n", config->ldc_file);
fprintf(stderr, "logger ABI Version is %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(SOF_ABI_VERSION),
SOF_ABI_VERSION_MINOR(SOF_ABI_VERSION),
SOF_ABI_VERSION_PATCH(SOF_ABI_VERSION));
SOF_ABI_VERSION_MAJOR(SOF_ABI_DBG_VERSION),
SOF_ABI_VERSION_MINOR(SOF_ABI_DBG_VERSION),
SOF_ABI_VERSION_PATCH(SOF_ABI_DBG_VERSION));
fprintf(stderr, "ldc_file ABI Version is %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(snd.version.abi_version),
SOF_ABI_VERSION_MINOR(snd.version.abi_version),
Expand Down