xref: /titanic_41/usr/src/uts/sun4v/sys/qcn.h (revision 66f9d5cb3cc0652e2d9d1366fb950efbe4ca2f24)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_QCN_H
28 #define	_QCN_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * sun4v Console driver
38  */
39 
40 #include <sys/types.h>
41 #include <sys/stream.h>
42 #include <sys/tty.h>
43 #include <sys/ddi.h>
44 #include <sys/sunddi.h>
45 
46 #define	RINGBITS	8		/* # of bits in ring ptrs */
47 #define	RINGSIZE	(1<<RINGBITS)	/* size of ring */
48 #define	RINGMASK	(RINGSIZE-1)
49 
50 #define	RING_INIT(qsp)	((qsp)->qcn_rput = (qsp)->qcn_rget = 0)
51 #define	RING_CNT(qsp)	(((qsp)->qcn_rput - (qsp)->qcn_rget) & RINGMASK)
52 #define	RING_POK(qsp, n) ((int)RING_CNT(qsp) < (int)(RINGSIZE-(n)))
53 #define	RING_PUT(qsp, c) \
54 	((qsp)->qcn_ring[(qsp)->qcn_rput++ & RINGMASK] =  (uchar_t)(c))
55 #define	RING_GET(qsp)	((qsp)->qcn_ring[(qsp)->qcn_rget++ & RINGMASK])
56 
57 /*
58  * qcn driver's soft state structure
59  */
60 typedef struct qcn {
61 	/* mutexes */
62 	kmutex_t qcn_hi_lock;		/* protects qcn_t (soft state)	*/
63 	kmutex_t qcn_softlock;	/* protects input handler	*/
64 	kmutex_t qcn_lock;	/* protects output queue	*/
65 
66 	/* stream queues */
67 	queue_t *qcn_writeq;		/* stream write queue		*/
68 	queue_t	*qcn_readq;		/* stream read queue		*/
69 
70 	/* dev info */
71 	dev_info_t	*qcn_dip;	/* dev_info			*/
72 
73 	/* for handling IOCTL messages */
74 	bufcall_id_t	qcn_wbufcid;	/* for console ioctl	*/
75 	tty_common_t	qcn_tty;	/* for console ioctl	*/
76 
77 	/* for console output timeout */
78 	time_t qcn_sc_active;		/* last time (sec) SC was active */
79 	uint_t	qcn_polling;
80 	uchar_t	qcn_rget;
81 	uchar_t	qcn_rput;
82 	int	qcn_soft_pend;
83 	ddi_softint_handle_t qcn_softint_hdl;
84 	ushort_t	qcn_ring[RINGSIZE];
85 	ushort_t	qcn_hangup;
86 	ddi_intr_handle_t *qcn_htable;	/* For array of interrupts */
87 	int	qcn_intr_type;	/* What type of interrupt */
88 	int	qcn_intr_cnt;	/* # of intrs count returned */
89 	size_t	qcn_intr_size;	/* Size of intr array */
90 	uint_t	qcn_intr_pri;	/* Interrupt priority   */
91 	ddi_iblock_cookie_t qcn_soft_pri;
92 	uint_t	qcn_rbuf_overflow;
93 } qcn_t;
94 
95 /* Constants used by promif routines */
96 #define	QCN_CLNT_STR	"CON_CLNT"
97 #define	QCN_OBP_STR	"CON_OBP"
98 
99 /* alternate break sequence */
100 extern void (*abort_seq_handler)();
101 
102 extern struct mod_ops mod_driverops;
103 
104 #define	QCN_TXINT_ENABLE	0x1
105 #define	QCN_RXINT_ENABLE	0x2
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif	/* _QCN_H */
112