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