Skip to content

Commit 5c9e98f

Browse files
author
Jyri Sarha
committed
debug_stream: make debug_stream_slot_send_record() a syscall
Make debug_stream_slot_send_record() a Zephyr syscall. This allows user-space threads to send debug stream records directly. Rename the implementation to z_impl_debug_stream_slot_send_record() and add z_vrfy_debug_stream_slot_send_record() with K_SYSCALL_MEMORY_READ validation of the record buffer. Register the syscall header in CMakeLists.txt. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent f9ecbd2 commit 5c9e98f

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/debug/debug_stream/debug_stream_slot.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include <user/debug_stream_slot.h>
1313
#include <zephyr/kernel.h>
1414

15+
#ifdef CONFIG_USERSPACE
16+
#include <zephyr/internal/syscall_handler.h>
17+
#endif
18+
1519
LOG_MODULE_REGISTER(debug_stream_slot);
1620

1721
struct cpu_mutex {
@@ -66,7 +70,7 @@ debug_stream_get_circular_buffer(struct debug_stream_section_descriptor *desc, u
6670
return (struct debug_stream_circular_buf *) (((uint8_t *)hdr) + desc->offset);
6771
}
6872

69-
int debug_stream_slot_send_record(struct debug_stream_record *rec)
73+
int z_impl_debug_stream_slot_send_record(struct debug_stream_record *rec)
7074
{
7175
struct debug_stream_section_descriptor desc = { 0 };
7276
struct debug_stream_circular_buf *buf =
@@ -119,6 +123,16 @@ int debug_stream_slot_send_record(struct debug_stream_record *rec)
119123
return 0;
120124
}
121125

126+
#ifdef CONFIG_USERSPACE
127+
static inline int z_vrfy_debug_stream_slot_send_record(struct debug_stream_record *rec)
128+
{
129+
K_OOPS(K_SYSCALL_MEMORY_READ(rec, sizeof(*rec)));
130+
K_OOPS(K_SYSCALL_MEMORY_READ(rec, rec->size_words * sizeof(uint32_t)));
131+
return z_impl_debug_stream_slot_send_record(rec);
132+
}
133+
#include <zephyr/syscalls/debug_stream_slot_send_record_mrsh.c>
134+
#endif
135+
122136
static int debug_stream_slot_init(void)
123137
{
124138
struct debug_stream_slot_hdr *hdr = debug_stream_get_slot();

src/include/user/debug_stream_slot.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ struct debug_stream_record;
127127
* -ENODEV if debug stream slot is not configured
128128
* -ENOMEM if the record is too big
129129
*/
130-
int debug_stream_slot_send_record(struct debug_stream_record *rec);
130+
__syscall int debug_stream_slot_send_record(struct debug_stream_record *rec);
131+
132+
#include <zephyr/syscalls/debug_stream_slot.h>
131133

132134
#endif /* __SOC_DEBUG_WINDOW_SLOT_H__ */

zephyr/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ zephyr_syscall_header(${SOF_SRC_PATH}/include/sof/lib/fast-get.h)
623623
zephyr_syscall_header(include/rtos/alloc.h)
624624
zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_INTERFACE_ALLOC syscall/alloc.c)
625625

626+
zephyr_syscall_header(${SOF_SRC_PATH}/include/user/debug_stream_slot.h)
627+
626628
zephyr_library_link_libraries(SOF)
627629
target_link_libraries(SOF INTERFACE zephyr_interface)
628630

0 commit comments

Comments
 (0)