4040#include <rtos/string.h>
4141#include <sof/lib_manager.h>
4242
43+ #ifdef __ZEPHYR__
44+ #include <zephyr/kernel.h>
45+ #include <zephyr/internal/syscall_handler.h>
46+ #endif
47+
4348#include <errno.h>
4449#include <stdbool.h>
4550#include <stddef.h>
@@ -128,15 +133,31 @@ __cold static bool is_any_ppl_active(void)
128133 return false;
129134}
130135
131- void ipc_compound_pre_start (int msg_id )
136+ void z_impl_ipc_compound_pre_start (int msg_id )
132137{
133138 /* ipc thread will wait for all scheduled tasks to be complete
134139 * Use a reference count to check status of these tasks.
135140 */
136141 atomic_add (& msg_data .delayed_reply , 1 );
137142}
138143
139- void ipc_compound_post_start (uint32_t msg_id , int ret , bool delayed )
144+ #ifdef CONFIG_USERSPACE
145+ /**
146+ * \brief Userspace verification wrapper for ipc_compound_pre_start().
147+ *
148+ * Forwards the call to z_impl_ipc_compound_pre_start(). No pointer
149+ * validation is needed as only primitive types are passed.
150+ *
151+ * @param[in] msg_id IPC message ID.
152+ */
153+ void z_vrfy_ipc_compound_pre_start (int msg_id )
154+ {
155+ z_impl_ipc_compound_pre_start (msg_id );
156+ }
157+ #include <zephyr/syscalls/ipc_compound_pre_start_mrsh.c>
158+ #endif
159+
160+ void z_impl_ipc_compound_post_start (uint32_t msg_id , int ret , bool delayed )
140161{
141162 if (ret ) {
142163 ipc_cmd_err (& ipc_tr , "failed to process msg %d status %d" , msg_id , ret );
@@ -149,6 +170,24 @@ void ipc_compound_post_start(uint32_t msg_id, int ret, bool delayed)
149170 atomic_sub (& msg_data .delayed_reply , 1 );
150171}
151172
173+ #ifdef CONFIG_USERSPACE
174+ /**
175+ * \brief Userspace verification wrapper for ipc_compound_post_start().
176+ *
177+ * Forwards the call to z_impl_ipc_compound_post_start(). No pointer
178+ * validation is needed as only primitive types are passed.
179+ *
180+ * @param[in] msg_id IPC message ID.
181+ * @param[in] ret Return value of the IPC command.
182+ * @param[in] delayed True if the reply is delayed.
183+ */
184+ void z_vrfy_ipc_compound_post_start (uint32_t msg_id , int ret , bool delayed )
185+ {
186+ z_impl_ipc_compound_post_start (msg_id , ret , delayed );
187+ }
188+ #include <zephyr/syscalls/ipc_compound_post_start_mrsh.c>
189+ #endif
190+
152191void ipc_compound_msg_done (uint32_t msg_id , int error )
153192{
154193 if (!atomic_read (& msg_data .delayed_reply )) {
@@ -170,13 +209,13 @@ void ipc_compound_msg_done(uint32_t msg_id, int error)
170209 * be always IPC4_FAILURE. Therefore the compound messages handling is simplified. The pipeline
171210 * triggers will require an explicit scheduler call to get the components to desired state.
172211 */
173- int ipc_wait_for_compound_msg (void )
212+ int z_impl_ipc_wait_for_compound_msg (void )
174213{
175214 atomic_set (& msg_data .delayed_reply , 0 );
176215 return IPC4_SUCCESS ;
177216}
178217#else
179- int ipc_wait_for_compound_msg (void )
218+ int z_impl_ipc_wait_for_compound_msg (void )
180219{
181220 int try_count = 30 ;
182221
@@ -192,6 +231,22 @@ int ipc_wait_for_compound_msg(void)
192231
193232 return IPC4_SUCCESS ;
194233}
234+
235+ #ifdef CONFIG_USERSPACE
236+ /**
237+ * \brief Userspace verification wrapper for ipc_wait_for_compound_msg().
238+ *
239+ * Forwards the call to z_impl_ipc_wait_for_compound_msg(). No pointer
240+ * validation is needed as no pointers are passed.
241+ *
242+ * @return IPC4_SUCCESS on success, IPC4_FAILURE on timeout.
243+ */
244+ int z_vrfy_ipc_wait_for_compound_msg (void )
245+ {
246+ return z_impl_ipc_wait_for_compound_msg ();
247+ }
248+ #include <zephyr/syscalls/ipc_wait_for_compound_msg_mrsh.c>
249+ #endif
195250#endif
196251
197252#if CONFIG_LIBRARY_MANAGER
@@ -509,14 +564,23 @@ void ipc_send_buffer_status_notify(void)
509564}
510565#endif
511566
512- void ipc_msg_reply (struct sof_ipc_reply * reply )
567+ void z_impl_ipc_msg_reply (struct sof_ipc_reply * reply )
513568{
514569 struct ipc4_message_request in ;
515570
516571 in .primary .dat = msg_data .msg_in .pri ;
517572 ipc_compound_msg_done (in .primary .r .type , reply -> error );
518573}
519574
575+ #ifdef CONFIG_USERSPACE
576+ void z_vrfy_ipc_msg_reply (struct sof_ipc_reply * reply )
577+ {
578+ K_OOPS (K_SYSCALL_MEMORY_READ (reply , sizeof (* reply )));
579+ z_impl_ipc_msg_reply (reply );
580+ }
581+ #include <zephyr/syscalls/ipc_msg_reply_mrsh.c>
582+ #endif
583+
520584void ipc_cmd (struct ipc_cmd_hdr * _hdr )
521585{
522586 struct ipc4_message_request * in = ipc4_get_message_request ();
0 commit comments