1 /*
2  * Copyright (c) 2024 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef SHELL_ADSP_MEMORY_WINDOW_H__
8 #define SHELL_ADSP_MEMORY_WINDOW_H__
9 
10 #include <zephyr/kernel.h>
11 #include <zephyr/shell/shell.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 extern const struct shell_transport_api shell_adsp_memory_window_transport_api;
18 
19 struct sys_winstream;
20 
21 /** Memwindow based shell transport. */
22 struct shell_adsp_memory_window {
23 	/** Handler function registered by shell. */
24 	shell_transport_handler_t shell_handler;
25 
26 	struct k_timer timer;
27 
28 	/** Context registered by shell. */
29 	void *shell_context;
30 
31 	/** Receive winstream object */
32 	struct sys_winstream *ws_rx;
33 
34 	/** Transmit winstream object */
35 	struct sys_winstream *ws_tx;
36 
37 	/** Last read sequence number */
38 	uint32_t read_seqno;
39 };
40 
41 #define SHELL_ADSP_MEMORY_WINDOW_DEFINE(_name)				\
42 	static struct shell_adsp_memory_window _name##_shell_adsp_memory_window;\
43 	struct shell_transport _name = {					\
44 		.api = &shell_adsp_memory_window_transport_api,		\
45 		.ctx = &_name##_shell_adsp_memory_window,	\
46 	}
47 
48 /**
49  * @brief This function provides pointer to shell ADSP memory window backend instance.
50  *
51  * Function returns pointer to the shell ADSP memory window instance. This instance can be
52  * next used with shell_execute_cmd function in order to test commands behavior.
53  *
54  * @returns Pointer to the shell instance.
55  */
56 const struct shell *shell_backend_adsp_memory_window_get_ptr(void);
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif /* SHELL_ADSP_MEMORY_WINDOW_H__ */
63