xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/include/hnd_cons.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Console support for RTE - for host use only.
3  *
4  * Copyright (C) 2020, Broadcom.
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *
21  * <<Broadcom-WL-IPTag/Dual:>>
22  */
23 #ifndef	_hnd_cons_h_
24 #define	_hnd_cons_h_
25 
26 #include <typedefs.h>
27 
28 #if defined(RWL_DONGLE) || defined(UART_REFLECTOR)
29 /* For Dongle uart tranport max cmd len is 256 bytes + header length (16 bytes)
30  *  In case of ASD commands we are not sure about how much is the command size
31  *  To be on the safe side, input buf len CBUF_LEN is increased to max (512) bytes.
32  */
33 #define RWL_MAX_DATA_LEN 	(512 + 8)	/* allow some extra bytes for '/n' termination */
34 #define CBUF_LEN	(RWL_MAX_DATA_LEN + 64)  /* allow 64 bytes for header ("rwl...") */
35 #else
36 #define CBUF_LEN	(128)
37 #endif /* RWL_DONGLE || UART_REFLECTOR */
38 
39 #ifndef LOG_BUF_LEN
40 #if defined(BCMDBG) || defined (BCM_BIG_LOG)
41 #define LOG_BUF_LEN	(16 * 1024)
42 #elif defined(ATE_BUILD)
43 #define LOG_BUF_LEN	(2 * 1024)
44 #elif defined(BCMQT)
45 #define LOG_BUF_LEN	(16 * 1024)
46 #else
47 #define LOG_BUF_LEN	1024
48 #endif
49 #endif /* LOG_BUF_LEN */
50 
51 #ifdef BOOTLOADER_CONSOLE_OUTPUT
52 #undef RWL_MAX_DATA_LEN
53 #undef CBUF_LEN
54 #undef LOG_BUF_LEN
55 #define RWL_MAX_DATA_LEN (4 * 1024 + 8)
56 #define CBUF_LEN	(RWL_MAX_DATA_LEN + 64)
57 #define LOG_BUF_LEN (16 * 1024)
58 #endif
59 
60 typedef struct {
61 #ifdef BCMDONGLEHOST
62 	uint32		buf;		/* Can't be pointer on (64-bit) hosts */
63 #else
64 	/* Physical buffer address, read by host code to dump console. */
65 	char*		PHYS_ADDR_N(buf);
66 #endif
67 	uint		buf_size;
68 	uint		idx;
69 	uint		out_idx;	/* output index */
70 	uint		dump_idx;	/* read idx for wl dump */
71 } hnd_log_t;
72 
73 typedef struct {
74 	/* Virtual UART
75 	 *   When there is no UART (e.g. Quickturn), the host should write a complete
76 	 *   input line directly into cbuf and then write the length into vcons_in.
77 	 *   This may also be used when there is a real UART (at risk of conflicting with
78 	 *   the real UART).  vcons_out is currently unused.
79 	 */
80 	volatile uint	vcons_in;
81 	volatile uint	vcons_out;
82 
83 	/* Output (logging) buffer
84 	 *   Console output is written to a ring buffer log_buf at index log_idx.
85 	 *   The host may read the output when it sees log_idx advance.
86 	 *   Output will be lost if the output wraps around faster than the host polls.
87 	 */
88 	hnd_log_t	log;
89 
90 	/* Console input line buffer
91 	 *   Characters are read one at a time into cbuf until <CR> is received, then
92 	 *   the buffer is processed as a command line.  Also used for virtual UART.
93 	 */
94 	uint		cbuf_idx;
95 	char		cbuf[CBUF_LEN];
96 } hnd_cons_t;
97 
98 #endif /* _hnd_cons_h_ */
99