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