18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright(c) 2020 Intel Corporation. All rights reserved.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/*
108c2ecf20Sopenharmony_ci * Extended manifest is a place to store metadata about firmware, known during
118c2ecf20Sopenharmony_ci * compilation time - for example firmware version or used compiler.
128c2ecf20Sopenharmony_ci * Given information are read on host side before firmware startup.
138c2ecf20Sopenharmony_ci * This part of output binary is not signed.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifndef __SOF_FIRMWARE_EXT_MANIFEST_H__
178c2ecf20Sopenharmony_ci#define __SOF_FIRMWARE_EXT_MANIFEST_H__
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <linux/bits.h>
208c2ecf20Sopenharmony_ci#include <linux/compiler.h>
218c2ecf20Sopenharmony_ci#include <linux/types.h>
228c2ecf20Sopenharmony_ci#include <sound/sof/info.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* In ASCII `XMan` */
258c2ecf20Sopenharmony_ci#define SOF_EXT_MAN_MAGIC_NUMBER	0x6e614d58
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* Build u32 number in format MMmmmppp */
288c2ecf20Sopenharmony_ci#define SOF_EXT_MAN_BUILD_VERSION(MAJOR, MINOR, PATH) ((uint32_t)( \
298c2ecf20Sopenharmony_ci	((MAJOR) << 24) | \
308c2ecf20Sopenharmony_ci	((MINOR) << 12) | \
318c2ecf20Sopenharmony_ci	(PATH)))
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* check extended manifest version consistency */
348c2ecf20Sopenharmony_ci#define SOF_EXT_MAN_VERSION_INCOMPATIBLE(host_ver, cli_ver) ( \
358c2ecf20Sopenharmony_ci	((host_ver) & GENMASK(31, 24)) != \
368c2ecf20Sopenharmony_ci	((cli_ver) & GENMASK(31, 24)))
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* used extended manifest header version */
398c2ecf20Sopenharmony_ci#define SOF_EXT_MAN_VERSION		SOF_EXT_MAN_BUILD_VERSION(1, 0, 0)
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* extended manifest header, deleting any field breaks backward compatibility */
428c2ecf20Sopenharmony_cistruct sof_ext_man_header {
438c2ecf20Sopenharmony_ci	uint32_t magic;		/*< identification number, */
448c2ecf20Sopenharmony_ci				/*< EXT_MAN_MAGIC_NUMBER */
458c2ecf20Sopenharmony_ci	uint32_t full_size;	/*< [bytes] full size of ext_man, */
468c2ecf20Sopenharmony_ci				/*< (header + content + padding) */
478c2ecf20Sopenharmony_ci	uint32_t header_size;	/*< [bytes] makes header extensionable, */
488c2ecf20Sopenharmony_ci				/*< after append new field to ext_man header */
498c2ecf20Sopenharmony_ci				/*< then backward compatible won't be lost */
508c2ecf20Sopenharmony_ci	uint32_t header_version; /*< value of EXT_MAN_VERSION */
518c2ecf20Sopenharmony_ci				/*< not related with following content */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	/* just after this header should be list of ext_man_elem_* elements */
548c2ecf20Sopenharmony_ci} __packed;
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Now define extended manifest elements */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* Extended manifest elements types */
598c2ecf20Sopenharmony_cienum sof_ext_man_elem_type {
608c2ecf20Sopenharmony_ci	SOF_EXT_MAN_ELEM_FW_VERSION		= 0,
618c2ecf20Sopenharmony_ci	SOF_EXT_MAN_ELEM_WINDOW			= SOF_IPC_EXT_WINDOW,
628c2ecf20Sopenharmony_ci	SOF_EXT_MAN_ELEM_CC_VERSION		= SOF_IPC_EXT_CC_INFO,
638c2ecf20Sopenharmony_ci	SOF_EXT_MAN_ELEM_DBG_ABI		= SOF_IPC_EXT_USER_ABI_INFO,
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* extended manifest element header */
678c2ecf20Sopenharmony_cistruct sof_ext_man_elem_header {
688c2ecf20Sopenharmony_ci	uint32_t type;		/*< SOF_EXT_MAN_ELEM_ */
698c2ecf20Sopenharmony_ci	uint32_t size;		/*< in bytes, including header size */
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	/* just after this header should be type dependent content */
728c2ecf20Sopenharmony_ci} __packed;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/* FW version */
758c2ecf20Sopenharmony_cistruct sof_ext_man_fw_version {
768c2ecf20Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
778c2ecf20Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
788c2ecf20Sopenharmony_ci	struct sof_ipc_fw_version version;
798c2ecf20Sopenharmony_ci	uint32_t flags;
808c2ecf20Sopenharmony_ci} __packed;
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci/* extended data memory windows for IPC, trace and debug */
838c2ecf20Sopenharmony_cistruct sof_ext_man_window {
848c2ecf20Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
858c2ecf20Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
868c2ecf20Sopenharmony_ci	struct sof_ipc_window ipc_window;
878c2ecf20Sopenharmony_ci} __packed;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* Used C compiler description */
908c2ecf20Sopenharmony_cistruct sof_ext_man_cc_version {
918c2ecf20Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
928c2ecf20Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
938c2ecf20Sopenharmony_ci	struct sof_ipc_cc_version cc_version;
948c2ecf20Sopenharmony_ci} __packed;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistruct ext_man_dbg_abi {
978c2ecf20Sopenharmony_ci	struct sof_ext_man_elem_header hdr;
988c2ecf20Sopenharmony_ci	/* use sof_ipc struct because of code re-use */
998c2ecf20Sopenharmony_ci	struct sof_ipc_user_abi_version dbg_abi;
1008c2ecf20Sopenharmony_ci} __packed;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */
103