xref: /illumos-gate/usr/src/uts/sun4u/serengeti/sys/sgcn.h (revision 03831d35)
1*03831d35Sstevel /*
2*03831d35Sstevel  * CDDL HEADER START
3*03831d35Sstevel  *
4*03831d35Sstevel  * The contents of this file are subject to the terms of the
5*03831d35Sstevel  * Common Development and Distribution License (the "License").
6*03831d35Sstevel  * You may not use this file except in compliance with the License.
7*03831d35Sstevel  *
8*03831d35Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*03831d35Sstevel  * or http://www.opensolaris.org/os/licensing.
10*03831d35Sstevel  * See the License for the specific language governing permissions
11*03831d35Sstevel  * and limitations under the License.
12*03831d35Sstevel  *
13*03831d35Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*03831d35Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*03831d35Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*03831d35Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*03831d35Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*03831d35Sstevel  *
19*03831d35Sstevel  * CDDL HEADER END
20*03831d35Sstevel  */
21*03831d35Sstevel 
22*03831d35Sstevel /*
23*03831d35Sstevel  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*03831d35Sstevel  * Use is subject to license terms.
25*03831d35Sstevel  */
26*03831d35Sstevel 
27*03831d35Sstevel #ifndef	_SGCN_H
28*03831d35Sstevel #define	_SGCN_H
29*03831d35Sstevel 
30*03831d35Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*03831d35Sstevel 
32*03831d35Sstevel #ifdef __cplusplus
33*03831d35Sstevel extern "C" {
34*03831d35Sstevel #endif
35*03831d35Sstevel 
36*03831d35Sstevel /*
37*03831d35Sstevel  * Console driver
38*03831d35Sstevel  *
39*03831d35Sstevel  * There is no hardware serial port is provided. A standalone
40*03831d35Sstevel  * co-processor SC acts as console device. The communication
41*03831d35Sstevel  * between SC and a domain is via SRAM on the choosen I/O board.
42*03831d35Sstevel  *
43*03831d35Sstevel  * This driver manipulates SRAM from domain Solaris side.
44*03831d35Sstevel  */
45*03831d35Sstevel 
46*03831d35Sstevel /*
47*03831d35Sstevel  * Logically there are two sets of interfaces defined here.
48*03831d35Sstevel  * The first part describes IOSRAM structures and will be
49*03831d35Sstevel  * exposed to all relevant clients, like SC, OBP.
50*03831d35Sstevel  * The second part defines internal driver data structure
51*03831d35Sstevel  * used by sgcn dirver.
52*03831d35Sstevel  */
53*03831d35Sstevel 
54*03831d35Sstevel #include <sys/types.h>
55*03831d35Sstevel #include <sys/stream.h>
56*03831d35Sstevel #include <sys/tty.h>
57*03831d35Sstevel #include <sys/ddi.h>
58*03831d35Sstevel #include <sys/sunddi.h>
59*03831d35Sstevel 
60*03831d35Sstevel /*
61*03831d35Sstevel  * IOSRAM structure
62*03831d35Sstevel  *
63*03831d35Sstevel  * Solaris and OBP use separate console buffers. But they share
64*03831d35Sstevel  * the same console buffer structure.
65*03831d35Sstevel  *
66*03831d35Sstevel  *              +---------------+ <- console buffer base address (BASE)
67*03831d35Sstevel  *              |   header      |
68*03831d35Sstevel  *              +---------------+ <- cnsram_in_begin + BASE
69*03831d35Sstevel  *              |   input       |
70*03831d35Sstevel  *              |   buffer      | <- cnsram_in_rdptr + BASE
71*03831d35Sstevel  *              |               | <- cnsram_in_wrptr + BASE
72*03831d35Sstevel  *              |               |
73*03831d35Sstevel  *              +---------------+ <- cnsram_in_end + BASE
74*03831d35Sstevel  *              |///////////////|
75*03831d35Sstevel  *              |///////////////| <- reserved for future expansion
76*03831d35Sstevel  *              |///////////////|
77*03831d35Sstevel  *              +---------------+ <- cnsram_out_begin + BASE
78*03831d35Sstevel  *              |   output      |
79*03831d35Sstevel  *              |   buffer      | <- cnsram_out_rdptr + BASE
80*03831d35Sstevel  *              |               | <- cnsram_out_wrptr + BASE
81*03831d35Sstevel  *              +---------------+ <- cnsram_out_end + BASE
82*03831d35Sstevel  *              |///////////////|
83*03831d35Sstevel  *              |///////////////| <- reserved for future expansion
84*03831d35Sstevel  *              |///////////////|
85*03831d35Sstevel  *              +---------------+ <- cnsram_size + BASE
86*03831d35Sstevel  */
87*03831d35Sstevel 
88*03831d35Sstevel /*
89*03831d35Sstevel  * Console IOSRAM header structure
90*03831d35Sstevel  * The header size is fixed, despite of 32-bit or 64-bit Solaris
91*03831d35Sstevel  */
92*03831d35Sstevel typedef struct {
93*03831d35Sstevel 	int32_t cnsram_magic;		/* magic number, CNSRAM_MAGIC	*/
94*03831d35Sstevel 	int32_t cnsram_version;		/* verison number		*/
95*03831d35Sstevel 	int32_t cnsram_size;		/* console buffer size		*/
96*03831d35Sstevel 
97*03831d35Sstevel 	/*
98*03831d35Sstevel 	 * the followings are all relative to beginning of console buffer
99*03831d35Sstevel 	 */
100*03831d35Sstevel 	int32_t cnsram_in_begin;
101*03831d35Sstevel 	int32_t cnsram_in_end;
102*03831d35Sstevel 	int32_t cnsram_in_rdptr;
103*03831d35Sstevel 	int32_t cnsram_in_wrptr;
104*03831d35Sstevel 
105*03831d35Sstevel 	int32_t cnsram_out_begin;
106*03831d35Sstevel 	int32_t cnsram_out_end;
107*03831d35Sstevel 	int32_t cnsram_out_rdptr;
108*03831d35Sstevel 	int32_t cnsram_out_wrptr;
109*03831d35Sstevel } cnsram_header;
110*03831d35Sstevel 
111*03831d35Sstevel #define	CNSRAM_MAGIC		0x434F4E00		/* "CON" */
112*03831d35Sstevel #define	CNSRAM_VERSION_1	1
113*03831d35Sstevel 
114*03831d35Sstevel /*
115*03831d35Sstevel  * sgcn driver's soft state structure
116*03831d35Sstevel  */
117*03831d35Sstevel typedef struct sgcn {
118*03831d35Sstevel 	/* mutexes */
119*03831d35Sstevel 	kmutex_t sgcn_lock;		/* protects sgcn_t (soft state)	*/
120*03831d35Sstevel 
121*03831d35Sstevel 	/* these are required by sbbc driver */
122*03831d35Sstevel 	kmutex_t sgcn_sbbc_in_lock;	/* input data lock 		*/
123*03831d35Sstevel 	kmutex_t sgcn_sbbc_outspace_lock; /* output data lock 		*/
124*03831d35Sstevel 	kmutex_t sgcn_sbbc_brk_lock;	/* break sequence lock 		*/
125*03831d35Sstevel 	uint_t sgcn_sbbc_in_state;	/* input data state		*/
126*03831d35Sstevel 	uint_t sgcn_sbbc_outspace_state; /* output data state		*/
127*03831d35Sstevel 	uint_t sgcn_sbbc_brk_state;	/* break sequence state		*/
128*03831d35Sstevel 
129*03831d35Sstevel 	/* stream queues */
130*03831d35Sstevel 	queue_t *sgcn_writeq;		/* stream write queue		*/
131*03831d35Sstevel 	queue_t	*sgcn_readq;		/* stream read queue		*/
132*03831d35Sstevel 
133*03831d35Sstevel 	/* pre-allocated console input buffer */
134*03831d35Sstevel 	char *sgcn_inbuf;		/* console input buffer		*/
135*03831d35Sstevel 	uint_t sgcn_inbuf_size;		/* buffer size			*/
136*03831d35Sstevel 
137*03831d35Sstevel 	/* dev info */
138*03831d35Sstevel 	dev_info_t	*sgcn_dip;	/* dev_info			*/
139*03831d35Sstevel 
140*03831d35Sstevel 	/* for handling IOCTL messages */
141*03831d35Sstevel 	bufcall_id_t	sgcn_wbufcid;	/* for console ioctl	*/
142*03831d35Sstevel 	tty_common_t	sgcn_tty;	/* for console ioctl	*/
143*03831d35Sstevel 
144*03831d35Sstevel 	/* for console output timeout */
145*03831d35Sstevel 	time_t sgcn_sc_active;		/* last time (sec) SC was active */
146*03831d35Sstevel 
147*03831d35Sstevel } sgcn_t;
148*03831d35Sstevel 
149*03831d35Sstevel /* Constants used by promif routines */
150*03831d35Sstevel #define	SGCN_CLNT_STR	"CON_CLNT"
151*03831d35Sstevel #define	SGCN_OBP_STR	"CON_OBP"
152*03831d35Sstevel 
153*03831d35Sstevel /* alternate break sequence */
154*03831d35Sstevel extern void (*abort_seq_handler)();
155*03831d35Sstevel 
156*03831d35Sstevel extern struct mod_ops mod_driverops;
157*03831d35Sstevel 
158*03831d35Sstevel #ifdef __cplusplus
159*03831d35Sstevel }
160*03831d35Sstevel #endif
161*03831d35Sstevel 
162*03831d35Sstevel #endif	/* _SGCN_H */
163