1/*
2 * Console support for hndrte.
3 *
4 * Copyright (C) 1999-2013, Broadcom Corporation
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $Id: hndrte_cons.h 383834 2013-02-07 23:21:51Z $
19 */
20#ifndef	_HNDRTE_CONS_H
21#define	_HNDRTE_CONS_H
22
23#include <typedefs.h>
24
25#define CBUF_LEN	(128)
26
27#define LOG_BUF_LEN	1024
28
29typedef struct {
30	uint32		buf;		/* Can't be pointer on (64-bit) hosts */
31	uint		buf_size;
32	uint		idx;
33	char		*_buf_compat;	/* redundant pointer for backward compat. */
34} hndrte_log_t;
35
36typedef struct {
37	/* Virtual UART
38	 *   When there is no UART (e.g. Quickturn), the host should write a complete
39	 *   input line directly into cbuf and then write the length into vcons_in.
40	 *   This may also be used when there is a real UART (at risk of conflicting with
41	 *   the real UART).  vcons_out is currently unused.
42	 */
43	volatile uint	vcons_in;
44	volatile uint	vcons_out;
45
46	/* Output (logging) buffer
47	 *   Console output is written to a ring buffer log_buf at index log_idx.
48	 *   The host may read the output when it sees log_idx advance.
49	 *   Output will be lost if the output wraps around faster than the host polls.
50	 */
51	hndrte_log_t	log;
52
53	/* Console input line buffer
54	 *   Characters are read one at a time into cbuf until <CR> is received, then
55	 *   the buffer is processed as a command line.  Also used for virtual UART.
56	 */
57	uint		cbuf_idx;
58	char		cbuf[CBUF_LEN];
59} hndrte_cons_t;
60
61hndrte_cons_t *hndrte_get_active_cons_state(void);
62
63#endif /* _HNDRTE_CONS_H */
64