• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Beken Corporation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _shell_drv_h_
17 #define _shell_drv_h_
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <common/bk_typedef.h>
24 
25 typedef  enum
26 {
27 	bFALSE = 0,
28 	bTRUE  = !bFALSE,
29 } bool_t;
30 
31 typedef enum
32 {
33 	SHELL_IO_CTRL_GET_STATUS = 0,
34 	SHELL_IO_CTRL_RX_RESET,
35 	SHELL_IO_CTRL_TX_RESET,
36 	SHELL_IO_CTRL_FLUSH,
37 	SHELL_IO_CTRL_SET_UART_PORT,
38 	SHELL_IO_CTRL_GET_RX_STATUS,
39 } shell_ctrl_cmd_t;
40 
41 enum
42 {
43 	SHELL_DEV_UART = 0,
44 	SHELL_DEV_MAILBOX,
45 };
46 
47 struct _shell_dev_drv;
48 
49 typedef struct
50 {
51 	struct _shell_dev_drv  *dev_drv;
52 	u8      dev_type;
53 	void  * dev_ext;
54 } shell_dev_t;
55 
56 typedef void  (* tx_complete_t)(u8 *pbuf, u16 Tag);
57 typedef void  (* rx_indicate_t)(void);
58 
59 typedef struct _shell_dev_drv
60 {
61 	bool_t   (*init)(shell_dev_t * shell_dev);
62 	bool_t   (*open)(shell_dev_t * shell_dev, tx_complete_t tx_callback, rx_indicate_t rx_callback);
63 	u16      (*write_async)(shell_dev_t * shell_dev, u8 * pBuf, u16 BufLen, u16 Tag);
64 	u16      (*read)(shell_dev_t * shell_dev, u8 * pBuf, u16 BufLen);
65 	u16      (*write_sync)(shell_dev_t * shell_dev, u8 * pBuf, u16 BufLen);
66 	u16      (*write_echo)(shell_dev_t * shell_dev, u8 * pBuf, u16 BufLen);
67 	bool_t   (*io_ctrl)(shell_dev_t * shell_dev, u8 cmd, void * param);
68 	bool_t   (*close)(shell_dev_t * shell_dev);
69 } shell_dev_drv_t;
70 
71 extern shell_dev_t		shell_uart;
72 extern shell_dev_t		shell_dev_mb;
73 extern shell_dev_t		shell_uart3;
74 
75 
76 #ifdef CONFIG_DUAL_CORE
77 
78 #include "mailbox_channel.h"
79 
80 struct _shell_ipc_drv;
81 
82 typedef struct
83 {
84 	struct _shell_ipc_drv  *dev_drv;
85 	u8      dev_type;
86 	void  * dev_ext;
87 } shell_dev_ipc_t;
88 
89 typedef int  (* shell_ipc_rx_t)(u16 cmd, void *data_buf, u16 dataLen);
90 
91 typedef struct _shell_ipc_drv
92 {
93 	bool_t   (*init)(shell_dev_ipc_t * dev_ipc);
94 	bool_t   (*open)(shell_dev_ipc_t * dev_ipc, shell_ipc_rx_t rx_callback);
95 	u16      (*read)(shell_dev_ipc_t * dev_ipc, u8 * pBuf, u16 BufLen);
96 	u16      (*write_sync)(shell_dev_ipc_t * dev_ipc, u8 * pBuf, u16 BufLen);
97 	bool_t   (*io_ctrl)(shell_dev_ipc_t * dev_ipc, u8 cmd, void * param);
98 	bool_t   (*close)(shell_dev_ipc_t * dev_ipc);
99 } shell_ipc_drv_t;
100 
101 typedef union
102 {
103 	struct
104 	{
105 		mb_chnl_hdr_t	hdr;
106 		u8			  * buf;
107 		u16				len;
108 		u16				tag;
109 	};
110 	mb_chnl_cmd_t	cmd_buf;
111 } log_cmd_t;
112 
113 typedef union
114 {
115 	struct
116 	{
117 		mb_chnl_hdr_t	hdr;
118 		u8    * 		buf;
119 		u16     		len;
120 	};
121 	mb_chnl_cmd_t	cmd_buf;
122 } user_cmd_t;
123 
124 enum
125 {
126 	MB_CMD_LOG_OUT = 1,
127 	MB_CMD_LOG_OUT_OK,
128 	MB_CMD_USER_INPUT,
129 	MB_CMD_ASSERT_OUT,
130 } ;
131 
132 extern shell_dev_ipc_t		shell_dev_ipc;
133 
134 #endif /* CONFIG_DUAL_CORE */
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif /* _shell_drv_h_ */
141 
142