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