162306a36Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
462306a36Sopenharmony_ci * redistributing this file, you may do so under either license.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright(c) 2020 Intel Corporation. All rights reserved.
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/*
1062306a36Sopenharmony_ci * Extended manifest is a place to store metadata about firmware, known during
1162306a36Sopenharmony_ci * compilation time - for example firmware version or used compiler.
1262306a36Sopenharmony_ci * Given information are read on host side before firmware startup.
1362306a36Sopenharmony_ci * This part of output binary is not signed.
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#ifndef __SOF_FIRMWARE_EXT_MANIFEST_H__
1762306a36Sopenharmony_ci#define __SOF_FIRMWARE_EXT_MANIFEST_H__
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#include <linux/bits.h>
2062306a36Sopenharmony_ci#include <linux/compiler.h>
2162306a36Sopenharmony_ci#include <linux/types.h>
2262306a36Sopenharmony_ci#include <sound/sof/info.h>
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* In ASCII `XMan` */
2562306a36Sopenharmony_ci#define SOF_EXT_MAN_MAGIC_NUMBER	0x6e614d58
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* Build u32 number in format MMmmmppp */
2862306a36Sopenharmony_ci#define SOF_EXT_MAN_BUILD_VERSION(MAJOR, MINOR, PATH) ((uint32_t)( \
2962306a36Sopenharmony_ci	((MAJOR) << 24) | \
3062306a36Sopenharmony_ci	((MINOR) << 12) | \
3162306a36Sopenharmony_ci	(PATH)))
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* check extended manifest version consistency */
3462306a36Sopenharmony_ci#define SOF_EXT_MAN_VERSION_INCOMPATIBLE(host_ver, cli_ver) ( \
3562306a36Sopenharmony_ci	((host_ver) & GENMASK(31, 24)) != \
3662306a36Sopenharmony_ci	((cli_ver) & GENMASK(31, 24)))
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* used extended manifest header version */
3962306a36Sopenharmony_ci#define SOF_EXT_MAN_VERSION		SOF_EXT_MAN_BUILD_VERSION(1, 0, 0)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/* extended manifest header, deleting any field breaks backward compatibility */
4262306a36Sopenharmony_cistruct sof_ext_man_header {
4362306a36Sopenharmony_ci	uint32_t magic;		/*< identification number, */
4462306a36Sopenharmony_ci				/*< EXT_MAN_MAGIC_NUMBER */
4562306a36Sopenharmony_ci	uint32_t full_size;	/*< [bytes] full size of ext_man, */
4662306a36Sopenharmony_ci				/*< (header + content + padding) */
4762306a36Sopenharmony_ci	uint32_t header_size;	/*< [bytes] makes header extensionable, */
4862306a36Sopenharmony_ci				/*< after append new field to ext_man header */
4962306a36Sopenharmony_ci				/*< then backward compatible won't be lost */
5062306a36Sopenharmony_ci	uint32_t header_version; /*< value of EXT_MAN_VERSION */
5162306a36Sopenharmony_ci				/*< not related with following content */
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci	/* just after this header should be list of ext_man_elem_* elements */
5462306a36Sopenharmony_ci} __packed;
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* Now define extended manifest elements */
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* Extended manifest elements types */
5962306a36Sopenharmony_cienum sof_ext_man_elem_type {
6062306a36Sopenharmony_ci	SOF_EXT_MAN_ELEM_FW_VERSION		= 0,
6162306a36Sopenharmony_ci	SOF_EXT_MAN_ELEM_WINDOW			= 1,
6262306a36Sopenharmony_ci	SOF_EXT_MAN_ELEM_CC_VERSION		= 2,
6362306a36Sopenharmony_ci	SOF_EXT_MAN_ELEM_DBG_ABI		= 4,
6462306a36Sopenharmony_ci	SOF_EXT_MAN_ELEM_CONFIG_DATA		= 5, /**< ABI3.17 */
6562306a36Sopenharmony_ci	SOF_EXT_MAN_ELEM_PLATFORM_CONFIG_DATA   = 6,
6662306a36Sopenharmony_ci};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/* extended manifest element header */
6962306a36Sopenharmony_cistruct sof_ext_man_elem_header {
7062306a36Sopenharmony_ci	uint32_t type;		/*< SOF_EXT_MAN_ELEM_ */
7162306a36Sopenharmony_ci	uint32_t size;		/*< in bytes, including header size */
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci	/* just after this header should be type dependent content */
7462306a36Sopenharmony_ci} __packed;
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* FW version */
7762306a36Sopenharmony_cistruct sof_ext_man_fw_version {
7862306a36Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
7962306a36Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
8062306a36Sopenharmony_ci	struct sof_ipc_fw_version version;
8162306a36Sopenharmony_ci	uint32_t flags;
8262306a36Sopenharmony_ci} __packed;
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* extended data memory windows for IPC, trace and debug */
8562306a36Sopenharmony_cistruct sof_ext_man_window {
8662306a36Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
8762306a36Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
8862306a36Sopenharmony_ci	struct sof_ipc_window ipc_window;
8962306a36Sopenharmony_ci} __packed;
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci/* Used C compiler description */
9262306a36Sopenharmony_cistruct sof_ext_man_cc_version {
9362306a36Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
9462306a36Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
9562306a36Sopenharmony_ci	struct sof_ipc_cc_version cc_version;
9662306a36Sopenharmony_ci} __packed;
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_cistruct ext_man_dbg_abi {
9962306a36Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
10062306a36Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
10162306a36Sopenharmony_ci	struct sof_ipc_user_abi_version dbg_abi;
10262306a36Sopenharmony_ci} __packed;
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/* EXT_MAN_ELEM_CONFIG_DATA elements identificators, ABI3.17 */
10562306a36Sopenharmony_cienum config_elem_type {
10662306a36Sopenharmony_ci	SOF_EXT_MAN_CONFIG_EMPTY		= 0,
10762306a36Sopenharmony_ci	SOF_EXT_MAN_CONFIG_IPC_MSG_SIZE		= 1,
10862306a36Sopenharmony_ci	SOF_EXT_MAN_CONFIG_MEMORY_USAGE_SCAN	= 2, /**< ABI 3.18 */
10962306a36Sopenharmony_ci};
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_cistruct sof_config_elem {
11262306a36Sopenharmony_ci	uint32_t token;
11362306a36Sopenharmony_ci	uint32_t value;
11462306a36Sopenharmony_ci} __packed;
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci/* firmware configuration information */
11762306a36Sopenharmony_cistruct sof_ext_man_config_data {
11862306a36Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci	struct sof_config_elem elems[];
12162306a36Sopenharmony_ci} __packed;
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */
124