Repository navigation
Expand file tree
/
Copy pathmsg.h
More file actions
157 lines (139 loc) · 4.38 KB
/
Copy pathmsg.h
File metadata and controls
157 lines (139 loc) · 4.38 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
*/
#ifndef __SOF_IPC_MSG_H__
#define __SOF_IPC_MSG_H__
#include <sof/audio/buffer.h>
#include <sof/audio/component.h>
#include <sof/audio/pipeline.h>
#include <rtos/alloc.h>
#include <sof/list.h>
#include <rtos/task.h>
#include <rtos/sof.h>
#include <rtos/spinlock.h>
#include <sof/trace/trace.h>
#include <sof/ipc/common.h>
#include <ipc/trace.h>
#include <stdbool.h>
#include <stdint.h>
struct dai_config;
struct dma;
struct dma_sg_elem_array;
struct k_heap;
struct ipc_msg {
uint32_t header; /* specific to platform */
uint32_t extension; /* extension specific to platform */
uint32_t tx_size; /* payload size in bytes */
void *tx_data; /* pointer to payload data, must be in a non-cached memory */
struct list_item list;
void (*callback)(struct ipc_msg *msg); /* Function called after sending the message */
};
/**
* \brief Initialize a new IPC message using a specific heap.
* @param heap Heap to allocate from (NULL = default kernel heap)
* @param header Message header metadata
* @param extension Message header extension metadata
* @param size Message data size in bytes.
* @return New IPC message.
*/
struct ipc_msg *ipc_msg_w_ext_init(struct k_heap *heap, uint32_t header,
uint32_t extension, uint32_t size);
/**
* \brief Initialize a new IPC message using a specific heap.
* @param heap Heap to allocate from (NULL = default kernel heap)
* @param header Message header metadata
* @param size Message data size in bytes.
* @return New IPC message.
*/
static inline struct ipc_msg *ipc_msg_init(struct k_heap *heap,
uint32_t header, uint32_t size)
{
return ipc_msg_w_ext_init(heap, header, 0, size);
}
/**
* \brief Remove an IPC message from the send queue.
*
* Acquires the IPC lock and removes the message from its list.
* Safe to call from userspace.
*
* @param msg The IPC message to remove from the queue.
*/
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
__syscall void ipc_msg_list_remove(struct ipc_msg *msg);
#include <zephyr/syscalls/msg.h>
#else
void z_impl_ipc_msg_list_remove(struct ipc_msg *msg);
#define ipc_msg_list_remove z_impl_ipc_msg_list_remove
#endif
/**
* \brief Frees IPC message header and data.
* @param msg The IPC message to be freed.
*/
static inline void ipc_msg_free(struct ipc_msg *msg)
{
if (!msg)
return;
ipc_msg_list_remove(msg);
rfree(msg->tx_data);
rfree(msg);
}
/**
* \brief Sends the next message in the IPC message queue.
*/
void ipc_send_queued_msg(void);
/**
* \brief Queues an IPC message for transmission.
* @param msg The IPC message.
* @param data The message data.
* @param high_priority True if a high priority message.
*/
#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
__syscall void ipc_msg_send(struct ipc_msg *msg, void *data,
bool high_priority);
#include <zephyr/syscalls/msg.h>
#else
void z_impl_ipc_msg_send(struct ipc_msg *msg, void *data,
bool high_priority);
#define ipc_msg_send z_impl_ipc_msg_send
#endif
#ifdef CONFIG_USERSPACE
struct k_mem_domain;
/**
* \brief Drop queued messages sent by user threads of a memory domain.
*
* Messages sent by user threads are queued as kernel copies, found by the
* address of the user message and the memory domain of the sender. Call
* this before a memory domain is reused, so that a message still queued
* from its previous threads is not taken as theirs. Kernel context only.
*
* @param domain The memory domain.
*/
void ipc_user_msg_purge(struct k_mem_domain *domain);
#endif
/**
* \brief Send an IPC message directly for emergency.
* @param msg The IPC message to be freed.
* @param data The message data.
*/
void ipc_msg_send_direct(struct ipc_msg *msg, void *data);
/**
* \brief Build stream position IPC message.
* @param[in,out] posn Stream position message
* @param[in] type Stream message type
* @param[in] id Stream ID.
*/
void ipc_build_stream_posn(struct sof_ipc_stream_posn *posn, uint32_t type,
uint32_t id);
/**
* \brief Build component event IPC message.
* @param[in,out] event Component event message
* @param[in] type Component event type
* @param[in] id Component ID.
*/
void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type,
uint32_t id);
#endif