xref: /OK3568_Linux_fs/external/rkwifibt/drivers/infineon/include/hnd_cons.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Console support for RTE - for host use only.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (C) 1999-2017, Broadcom Corporation
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
9*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
10*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
11*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12*4882a593Smuzhiyun  * following added to such license:
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
15*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
16*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
17*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
18*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
19*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
20*4882a593Smuzhiyun  * modifications of the software.
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  *      Notwithstanding the above, under no circumstances may you combine this
23*4882a593Smuzhiyun  * software in any way with any other Broadcom software provided under a license
24*4882a593Smuzhiyun  * other than the GPL, without Broadcom's express prior written consent.
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Open:>>
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  * $Id: hnd_cons.h 624181 2016-03-10 18:58:22Z $
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun #ifndef	_hnd_cons_h_
32*4882a593Smuzhiyun #define	_hnd_cons_h_
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #include <typedefs.h>
35*4882a593Smuzhiyun #include <siutils.h>
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #define CBUF_LEN	(128)
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #ifndef LOG_BUF_LEN
40*4882a593Smuzhiyun #if defined(BCM_BIG_LOG)
41*4882a593Smuzhiyun #define LOG_BUF_LEN	(16 * 1024)
42*4882a593Smuzhiyun #elif defined(BCMQT)
43*4882a593Smuzhiyun #define LOG_BUF_LEN	(16 * 1024)
44*4882a593Smuzhiyun #else
45*4882a593Smuzhiyun #define LOG_BUF_LEN	1024
46*4882a593Smuzhiyun #endif // endif
47*4882a593Smuzhiyun #endif /* LOG_BUF_LEN */
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #ifdef BOOTLOADER_CONSOLE_OUTPUT
50*4882a593Smuzhiyun #undef RWL_MAX_DATA_LEN
51*4882a593Smuzhiyun #undef CBUF_LEN
52*4882a593Smuzhiyun #undef LOG_BUF_LEN
53*4882a593Smuzhiyun #define RWL_MAX_DATA_LEN (4 * 1024 + 8)
54*4882a593Smuzhiyun #define CBUF_LEN	(RWL_MAX_DATA_LEN + 64)
55*4882a593Smuzhiyun #define LOG_BUF_LEN (16 * 1024)
56*4882a593Smuzhiyun #endif // endif
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun typedef struct {
59*4882a593Smuzhiyun 	uint32		buf;		/* Can't be pointer on (64-bit) hosts */
60*4882a593Smuzhiyun 	uint		buf_size;
61*4882a593Smuzhiyun 	uint		idx;
62*4882a593Smuzhiyun 	uint		out_idx;	/* output index */
63*4882a593Smuzhiyun } hnd_log_t;
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun typedef struct {
66*4882a593Smuzhiyun 	/* Virtual UART
67*4882a593Smuzhiyun 	 *   When there is no UART (e.g. Quickturn), the host should write a complete
68*4882a593Smuzhiyun 	 *   input line directly into cbuf and then write the length into vcons_in.
69*4882a593Smuzhiyun 	 *   This may also be used when there is a real UART (at risk of conflicting with
70*4882a593Smuzhiyun 	 *   the real UART).  vcons_out is currently unused.
71*4882a593Smuzhiyun 	 */
72*4882a593Smuzhiyun 	volatile uint	vcons_in;
73*4882a593Smuzhiyun 	volatile uint	vcons_out;
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun 	/* Output (logging) buffer
76*4882a593Smuzhiyun 	 *   Console output is written to a ring buffer log_buf at index log_idx.
77*4882a593Smuzhiyun 	 *   The host may read the output when it sees log_idx advance.
78*4882a593Smuzhiyun 	 *   Output will be lost if the output wraps around faster than the host polls.
79*4882a593Smuzhiyun 	 */
80*4882a593Smuzhiyun 	hnd_log_t	log;
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun 	/* Console input line buffer
83*4882a593Smuzhiyun 	 *   Characters are read one at a time into cbuf until <CR> is received, then
84*4882a593Smuzhiyun 	 *   the buffer is processed as a command line.  Also used for virtual UART.
85*4882a593Smuzhiyun 	 */
86*4882a593Smuzhiyun 	uint		cbuf_idx;
87*4882a593Smuzhiyun 	char		cbuf[CBUF_LEN];
88*4882a593Smuzhiyun } hnd_cons_t;
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun #endif /* _hnd_cons_h_ */
91