1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2021 Intel Corporation. All rights reserved.
4  */
5 
6 /*
7  * This file contains structures that are exact copies of an existing ABI used
8  * by IOT middleware. They are Intel specific and will be used by one middleware.
9  *
10  * Some of the structures may contain programming implementations that makes them
11  * unsuitable for generic use and general usage.
12  *
13  * This code is mostly copied "as-is" from existing C++ interface files hence the use of
14  * different style in places. The intention is to keep the interface as close as possible to
15  * original so it's easier to track changes with IPC host code.
16  */
17 
18 /**
19  * \file include/ipc4/header.h
20  * \brief IPC4 global definitions.
21  * NOTE: This ABI uses bit fields and is non portable.
22  */
23 
24 #ifndef __SOF_IPC4_HEADER_H__
25 #define __SOF_IPC4_HEADER_H__
26 
27 #include <stdint.h>
28 
29 #define ipc_from_hdr(x) ((struct ipc4_message_request *)x)
30 
31 /**< Message target, value of msg_tgt field. */
32 enum ipc4_message_target {
33 	/**< Global FW message */
34 	SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG = 0,
35 	/**< Module message */
36 	SOF_IPC4_MESSAGE_TARGET_MODULE_MSG = 1
37 };
38 
39 /**< Message direction, value of rsp field. */
40 enum ipc4_message_direction {
41 	/**< Request, Notification */
42 	SOF_IPC4_MESSAGE_DIR_MSG_REQUEST = 0,
43 	/**< Reply */
44 	SOF_IPC4_MESSAGE_DIR_MSG_REPLY = 1,
45 };
46 
47 /*
48  * Global IPC4 message types - must fit into 5 bits.
49  */
50 enum ipc4_message_type {
51 	/**< Boot Config. */
52 	SOF_IPC4_GLB_BOOT_CONFIG = 0,
53 	/**< ROM Control (directed to ROM). */
54 	SOF_IPC4_GLB_ROM_CONTROL = 1,
55 	/**< Execute IPC gateway command */
56 	SOF_IPC4_GLB_IPCGATEWAY_CMD = 2,
57 
58 	/* GAP HERE- DO NOT USE - size 10 (3 .. 12)  */
59 
60 	/**< Execute performance measurements command. */
61 	SOF_IPC4_GLB_PERF_MEASUREMENTS_CMD = 13,
62 	/**< DMA Chain command. */
63 	SOF_IPC4_GLB_CHAIN_DMA = 14,
64 	/**< Load multiple modules */
65 	SOF_IPC4_GLB_LOAD_MULTIPLE_MODULES = 15,
66 	/**< Unload multiple modules */
67 	SOF_IPC4_GLB_UNLOAD_MULTIPLE_MODULES = 16,
68 	/**< Create pipeline */
69 	SOF_IPC4_GLB_CREATE_PIPELINE = 17,
70 	/**< Delete pipeline */
71 	SOF_IPC4_GLB_DELETE_PIPELINE = 18,
72 	/**< Set pipeline state */
73 	SOF_IPC4_GLB_SET_PIPELINE_STATE = 19,
74 	/**< Get pipeline state */
75 	SOF_IPC4_GLB_GET_PIPELINE_STATE = 20,
76 	/**< Get pipeline context size */
77 	SOF_IPC4_GLB_GET_PIPELINE_CONTEXT_SIZE = 21,
78 	/**< Save pipeline */
79 	SOF_IPC4_GLB_SAVE_PIPELINE = 22,
80 	/**< Restore pipeline */
81 	SOF_IPC4_GLB_RESTORE_PIPELINE = 23,
82 	/**< Loads library */
83 	SOF_IPC4_GLB_LOAD_LIBRARY = 24,
84 	/**< Internal FW message */
85 	SOF_IPC4_GLB_INTERNAL_MESSAGE = 26,
86 	/**< Notification (FW to SW driver) */
87 	SOF_IPC4_GLB_NOTIFICATION = 27,
88 	/* GAP HERE- DO NOT USE - size 3 (28 .. 30)  */
89 
90 	/**< Maximum message number */
91 	SOF_IPC4_GLB_MAX_IXC_MESSAGE_TYPE = 31
92 };
93 
94 /**
95  * \brief Generic message header. IPC MAJOR 4 version.
96  * All IPC4 messages use this header as abstraction
97  * to platform specific calls.
98  */
99 struct ipc_cmd_hdr {
100 	uint32_t pri;
101 	uint32_t ext;
102 };
103 
104 /**
105  * \brief IPC MAJOR 4 message header. All IPC4 messages use this header.
106  * When msg_tgt is SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG then type is
107  * enum ipc4_message_type.
108  */
109 struct ipc4_message_request {
110 	union  {
111 		uint32_t dat;
112 
113 		struct {
114 			uint32_t rsvd0 : 24;
115 
116 			/**< One of Global::Type */
117 			uint32_t type : 5;
118 
119 			/**< Msg::MSG_REQUEST */
120 			uint32_t rsp : 1;
121 
122 			/**< Msg::FW_GEN_MSG */
123 			uint32_t msg_tgt : 1;
124 
125 			uint32_t _reserved_0 : 1;
126 		} r;
127 	} primary;
128 	union  {
129 		uint32_t dat;
130 		struct {
131 			uint32_t ext_data : 30;
132 			uint32_t _reserved_0 : 2;
133 		} r;
134 	} extension;
135 } __attribute__((packed, aligned(4)));
136 
137 struct ipc4_message_reply {
138 	union {
139 		uint32_t dat;
140 
141 		struct {
142 			/**< Processing status, one of IxcStatus values */
143 			uint32_t status	: 24;
144 
145 			/**< Type, symmetric to Msg */
146 			uint32_t type : 5;
147 
148 			/**< MSG_REPLY */
149 			uint32_t rsp : 1;
150 
151 			/**< same as request, one of FW_GEN_MSG, MODULE_MSG */
152 			uint32_t msg_tgt : 1;
153 
154 			/**< Reserved field (HW ctrl bits) */
155 			uint32_t _reserved_0 : 1;
156 		} r;
157 	} primary;
158 
159 	union {
160 		uint32_t dat;
161 
162 		struct {
163 			/**< Reserved field */
164 			uint32_t rsvd1 : 30;
165 
166 			/**< Reserved field (HW ctrl bits) */
167 			uint32_t _reserved_2 : 2;
168 		} r;
169 	} extension;
170 } __attribute((packed, aligned(4)));
171 
172 #endif
173