summaryrefslogtreecommitdiffstats
path: root/include/sound/sof/ext_manifest.h
blob: fc0231d04a941ce08e721ce6d41a5301476c2896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) 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) 2020 Intel Corporation
 */

/*
 * Extended manifest is a place to store metadata about firmware, known during
 * compilation time - for example firmware version or used compiler.
 * Given information are read on host side before firmware startup.
 * This part of output binary is not signed.
 */

#ifndef __SOF_FIRMWARE_EXT_MANIFEST_H__
#define __SOF_FIRMWARE_EXT_MANIFEST_H__

#include <linux/bits.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <sound/sof/info.h>

/* In ASCII `XMan` */
#define SOF_EXT_MAN_MAGIC_NUMBER	0x6e614d58

/* Build u32 number in format MMmmmppp */
#define SOF_EXT_MAN_BUILD_VERSION(MAJOR, MINOR, PATH) ((uint32_t)( \
	((MAJOR) << 24) | \
	((MINOR) << 12) | \
	(PATH)))

/* check extended manifest version consistency */
#define SOF_EXT_MAN_VERSION_INCOMPATIBLE(host_ver, cli_ver) ( \
	((host_ver) & GENMASK(31, 24)) != \
	((cli_ver) & GENMASK(31, 24)))

/* used extended manifest header version */
#define SOF_EXT_MAN_VERSION		SOF_EXT_MAN_BUILD_VERSION(1, 0, 0)

/* extended manifest header, deleting any field breaks backward compatibility */
struct sof_ext_man_header {
	uint32_t magic;		/*< identification number, */
				/*< EXT_MAN_MAGIC_NUMBER */
	uint32_t full_size;	/*< [bytes] full size of ext_man, */
				/*< (header + content + padding) */
	uint32_t header_size;	/*< [bytes] makes header extensionable, */
				/*< after append new field to ext_man header */
				/*< then backward compatible won't be lost */
	uint32_t header_version; /*< value of EXT_MAN_VERSION */
				/*< not related with following content */

	/* just after this header should be list of ext_man_elem_* elements */
} __packed;

/* Now define extended manifest elements */

/* Extended manifest elements types */
enum sof_ext_man_elem_type {
	SOF_EXT_MAN_ELEM_FW_VERSION		= 0,
	SOF_EXT_MAN_ELEM_WINDOW			= 1,
	SOF_EXT_MAN_ELEM_CC_VERSION		= 2,
	SOF_EXT_MAN_ELEM_DBG_ABI		= 4,
	SOF_EXT_MAN_ELEM_CONFIG_DATA		= 5, /**< ABI3.17 */
	SOF_EXT_MAN_ELEM_PLATFORM_CONFIG_DATA   = 6,
};

/* extended manifest element header */
struct sof_ext_man_elem_header {
	uint32_t type;		/*< SOF_EXT_MAN_ELEM_ */
	uint32_t size;		/*< in bytes, including header size */

	/* just after this header should be type dependent content */
} __packed;

/* FW version */
struct sof_ext_man_fw_version {
	struct sof_ext_man_elem_header hdr;
	/* use sof_ipc struct because of code re-use */
	struct sof_ipc_fw_version version;
	uint32_t flags;
} __packed;

/* extended data memory windows for IPC, trace and debug */
struct sof_ext_man_window {
	struct sof_ext_man_elem_header hdr;
	/* use sof_ipc struct because of code re-use */
	struct sof_ipc_window ipc_window;
} __packed;

/* Used C compiler description */
struct sof_ext_man_cc_version {
	struct sof_ext_man_elem_header hdr;
	/* use sof_ipc struct because of code re-use */
	struct sof_ipc_cc_version cc_version;
} __packed;

struct ext_man_dbg_abi {
	struct sof_ext_man_elem_header hdr;
	/* use sof_ipc struct because of code re-use */
	struct sof_ipc_user_abi_version dbg_abi;
} __packed;

/* EXT_MAN_ELEM_CONFIG_DATA elements identificators, ABI3.17 */
enum config_elem_type {
	SOF_EXT_MAN_CONFIG_EMPTY		= 0,
	SOF_EXT_MAN_CONFIG_IPC_MSG_SIZE		= 1,
	SOF_EXT_MAN_CONFIG_MEMORY_USAGE_SCAN	= 2, /**< ABI 3.18 */
};

struct sof_config_elem {
	uint32_t token;
	uint32_t value;
} __packed;

/* firmware configuration information */
struct sof_ext_man_config_data {
	struct sof_ext_man_elem_header hdr;

	struct sof_config_elem elems[];
} __packed;

#endif /* __SOF_FIRMWARE_EXT_MANIFEST_H__ */