Commit d2458baa authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: SOF: ipc3-loader: Implement firmware parsing and loading

Add the IPC3 dependent implementation of validating the firmware image,
parsing the ext manifest and to load modules via memcpy.

The code introduced by this commit is the IPC dependent code from the
loader.c, which is going to be removed later.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220425221129.124615-3-ranjani.sridharan@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 61bafd1c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\
control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\ control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\
ipc3-topology.o ipc3.o ipc3-control.o ipc3-pcm.o ipc3-topology.o ipc3-control.o ipc3.o ipc3-pcm.o ipc3-loader.o
ifneq ($(CONFIG_SND_SOC_SOF_CLIENT),) ifneq ($(CONFIG_SND_SOC_SOF_CLIENT),)
snd-sof-objs += sof-client.o snd-sof-objs += sof-client.o
endif endif
......
This diff is collapsed.
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* Copyright(c) 2021 Intel Corporation. All rights reserved.
*/
#ifndef __SOUND_SOC_SOF_IPC3_PRIV_H
#define __SOUND_SOC_SOF_IPC3_PRIV_H
#include "sof-priv.h"
/* IPC3 specific ops */
extern const struct sof_ipc_fw_loader_ops ipc3_loader_ops;
/* helpers for fw_ready and ext_manifest parsing */
int sof_ipc3_get_ext_windows(struct snd_sof_dev *sdev,
const struct sof_ipc_ext_data_hdr *ext_hdr);
int sof_ipc3_get_cc_info(struct snd_sof_dev *sdev,
const struct sof_ipc_ext_data_hdr *ext_hdr);
int sof_ipc3_validate_fw_version(struct snd_sof_dev *sdev);
#endif
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <sound/sof/control.h> #include <sound/sof/control.h>
#include "sof-priv.h" #include "sof-priv.h"
#include "sof-audio.h" #include "sof-audio.h"
#include "ipc3-priv.h"
#include "ipc3-ops.h" #include "ipc3-ops.h"
#include "ops.h" #include "ops.h"
...@@ -475,8 +476,8 @@ static int sof_ipc3_set_get_data(struct snd_sof_dev *sdev, void *data, size_t da ...@@ -475,8 +476,8 @@ static int sof_ipc3_set_get_data(struct snd_sof_dev *sdev, void *data, size_t da
return ret; return ret;
} }
static int sof_ipc3_get_ext_windows(struct snd_sof_dev *sdev, int sof_ipc3_get_ext_windows(struct snd_sof_dev *sdev,
const struct sof_ipc_ext_data_hdr *ext_hdr) const struct sof_ipc_ext_data_hdr *ext_hdr)
{ {
const struct sof_ipc_window *w = const struct sof_ipc_window *w =
container_of(ext_hdr, struct sof_ipc_window, ext_hdr); container_of(ext_hdr, struct sof_ipc_window, ext_hdr);
...@@ -500,8 +501,8 @@ static int sof_ipc3_get_ext_windows(struct snd_sof_dev *sdev, ...@@ -500,8 +501,8 @@ static int sof_ipc3_get_ext_windows(struct snd_sof_dev *sdev,
return 0; return 0;
} }
static int sof_ipc3_get_cc_info(struct snd_sof_dev *sdev, int sof_ipc3_get_cc_info(struct snd_sof_dev *sdev,
const struct sof_ipc_ext_data_hdr *ext_hdr) const struct sof_ipc_ext_data_hdr *ext_hdr)
{ {
int ret; int ret;
...@@ -735,6 +736,56 @@ static int ipc3_init_reply_data_buffer(struct snd_sof_dev *sdev) ...@@ -735,6 +736,56 @@ static int ipc3_init_reply_data_buffer(struct snd_sof_dev *sdev)
return 0; return 0;
} }
int sof_ipc3_validate_fw_version(struct snd_sof_dev *sdev)
{
struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
struct sof_ipc_fw_version *v = &ready->version;
dev_info(sdev->dev,
"Firmware info: version %d:%d:%d-%s\n", v->major, v->minor,
v->micro, v->tag);
dev_info(sdev->dev,
"Firmware: ABI %d:%d:%d Kernel ABI %d:%d:%d\n",
SOF_ABI_VERSION_MAJOR(v->abi_version),
SOF_ABI_VERSION_MINOR(v->abi_version),
SOF_ABI_VERSION_PATCH(v->abi_version),
SOF_ABI_MAJOR, SOF_ABI_MINOR, SOF_ABI_PATCH);
if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, v->abi_version)) {
dev_err(sdev->dev, "incompatible FW ABI version\n");
return -EINVAL;
}
if (SOF_ABI_VERSION_MINOR(v->abi_version) > SOF_ABI_MINOR) {
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS)) {
dev_warn(sdev->dev, "FW ABI is more recent than kernel\n");
} else {
dev_err(sdev->dev, "FW ABI is more recent than kernel\n");
return -EINVAL;
}
}
if (ready->flags & SOF_IPC_INFO_BUILD) {
dev_info(sdev->dev,
"Firmware debug build %d on %s-%s - options:\n"
" GDB: %s\n"
" lock debug: %s\n"
" lock vdebug: %s\n",
v->build, v->date, v->time,
(ready->flags & SOF_IPC_INFO_GDB) ?
"enabled" : "disabled",
(ready->flags & SOF_IPC_INFO_LOCKS) ?
"enabled" : "disabled",
(ready->flags & SOF_IPC_INFO_LOCKSV) ?
"enabled" : "disabled");
}
/* copy the fw_version into debugfs at first boot */
memcpy(&sdev->fw_version, v, sizeof(*v));
return 0;
}
static int ipc3_fw_ready(struct snd_sof_dev *sdev, u32 cmd) static int ipc3_fw_ready(struct snd_sof_dev *sdev, u32 cmd)
{ {
struct sof_ipc_fw_ready *fw_ready = &sdev->fw_ready; struct sof_ipc_fw_ready *fw_ready = &sdev->fw_ready;
...@@ -767,7 +818,7 @@ static int ipc3_fw_ready(struct snd_sof_dev *sdev, u32 cmd) ...@@ -767,7 +818,7 @@ static int ipc3_fw_ready(struct snd_sof_dev *sdev, u32 cmd)
} }
/* make sure ABI version is compatible */ /* make sure ABI version is compatible */
ret = snd_sof_ipc_valid(sdev); ret = sof_ipc3_validate_fw_version(sdev);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1019,6 +1070,7 @@ const struct sof_ipc_ops ipc3_ops = { ...@@ -1019,6 +1070,7 @@ const struct sof_ipc_ops ipc3_ops = {
.tplg = &ipc3_tplg_ops, .tplg = &ipc3_tplg_ops,
.pm = &ipc3_pm_ops, .pm = &ipc3_pm_ops,
.pcm = &ipc3_pcm_ops, .pcm = &ipc3_pcm_ops,
.fw_loader = &ipc3_loader_ops,
.tx_msg = sof_ipc3_tx_msg, .tx_msg = sof_ipc3_tx_msg,
.rx_msg = sof_ipc3_rx_msg, .rx_msg = sof_ipc3_rx_msg,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment