xref: /illumos-gate/usr/src/uts/common/sys/consdev.h (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_CONSDEV_H
28 #define	_SYS_CONSDEV_H
29 
30 #include <sys/isa_defs.h>
31 #include <sys/dditypes.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 
38 #if defined(_KERNEL) || defined(_KMDB)
39 
40 /*
41  * Paths to console devices
42  */
43 #define	CONSKBD_PATH	"/pseudo/conskbd@0:conskbd"
44 #define	CONSMS_PATH	"/pseudo/consms@0:mouse"
45 #define	WC_PATH		"/pseudo/wc@0:wscons"
46 #define	IWSCN_PATH	"/pseudo/iwscn@0:iwscn"
47 #define	CVC_PATH	"/pseudo/cvc@0:cvc"
48 
49 /*
50  * Console redirection.
51  */
52 extern dev_t	rconsdev;	/* real (underlying) console */
53 extern struct vnode *rconsvp;	/* pointer to vnode for that device */
54 
55 /*
56  * Virtual Serial Console redirection.
57  */
58 extern struct vnode *vsconsvp;	/* pointer to vnode for virtual console */
59 
60 /*
61  * Mouse, keyboard, and frame buffer configuration information.
62  *
63  * XXX:	Assumes a single mouse/keyboard/frame buffer triple.
64  */
65 extern dev_t	mousedev;	/* default mouse device */
66 extern dev_t	kbddev;		/* default (actual) keyboard device */
67 extern dev_t	stdindev;	/* default standard input device */
68 extern dev_t	fbdev;		/* default framebuffer device */
69 extern struct vnode *fbvp;	/* pointer to vnode for that device */
70 extern dev_info_t *fbdip;	/* pointer to dev_info for fbdev (optional) */
71 extern dev_t	diagdev;	/* default diag device (optional) */
72 
73 extern int	consmode;	/* CONS_FW or CONS_KFB */
74 extern int	cons_tem_disable;
75 #define	CONS_FW		0
76 #define	CONS_KFB	1
77 
78 /*
79  * Workstation console redirection.
80  *
81  * The workstation console device is the multiplexor that hooks keyboard and
82  * frame buffer together into a single tty-like device.  Access to it is
83  * through the redirecting driver, so that frame buffer output can be
84  * redirected to other devices.  wsconsvp names the redirecting access point,
85  * and rwsconsvp names the workstation console itself.
86  *
87  * XXX:	Assumes a single workstation console.
88  */
89 extern struct vnode *wsconsvp;	/* vnode for redirecting ws cons access */
90 extern struct vnode *rwsconsvp;	/* vnode for underlying workstation console */
91 
92 /*
93  * Generic console ioctls.
94  *
95  * On systems without OBP, all potential console devices should implement these.
96  *
97  * On systems with OBP, all potential console devices should implement
98  * the ABORTENABLE ioctls.  All potential console devices that cannot share
99  * their hardware with OBP should implement the POLLEDIO ioctls.
100  */
101 #define	_CONSIOC	(('C'<<24)|('O'<<16)|('N'<<8))
102 
103 /*
104  * Get the structure of function pointers to be used for polled I/O
105  *
106  *	struct cons_polledio *polledio;
107  *	struct strioctl str;
108  *
109  *	str.ic_cmd = CONS_OPENPOLLEDIO;
110  *	str.ic_timout = INFTIM;
111  *	str.ic_len = sizeof (polledio);
112  *	str.ic_dp = (char *)&polledio;
113  *	ioctl(fd, I_STR, &str);
114  */
115 #define	CONSOPENPOLLEDIO	(_CONSIOC|0)
116 
117 /*
118  * Get the current state of abort enable
119  * enable = ioctl(fd, CONSGETABORTENABLE, 0)
120  */
121 #define	CONSGETABORTENABLE	(_CONSIOC|1)
122 
123 /*
124  * Set the current state of abort enable
125  * ioctl(fd, CONSSETABORTENABLE, boolean_t)
126  */
127 #define	CONSSETABORTENABLE	(_CONSIOC|2)
128 
129 /*
130  * Undo anything that was done with CONSOPENPOLLEDIO
131  * ioctl(fd, CONSCLOSEPOLLEDIO, 0)
132  */
133 #define	CONSCLOSEPOLLEDIO	(_CONSIOC|3)
134 
135 /*
136  * Set the type simulated by hardwares
137  * ioctl(fd, CONSSETKBDTYPE, kbdtype)
138  * kbdtype:
139  *	KB_PC or KB_USB
140  */
141 #define	CONSSETKBDTYPE		(_CONSIOC|4)
142 
143 #define	CONSPOLLEDIO_V0		0
144 #define	CONSPOLLEDIO_V1		1
145 
146 typedef int kbtrans_key_t;
147 
148 enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 };
149 
150 
151 /*
152  * Opaque state structure for driver state.  Each driver has its own
153  * implementation (with different names!), and casts to/from this.
154  * This allows better type-checking than "void *", helping to ensure
155  * that the structure passed in is the structure used in the callback.
156  */
157 typedef struct __cons_polledio_arg	*cons_polledio_arg_t;
158 
159 /*
160  * This is the structure that is used to handle polled I/O.  It is filled
161  * in by a lower driver, passed up, and eventually registered with the
162  * debugger that needs to do polled I/O.
163  */
164 typedef struct cons_polledio {
165 
166 	/*
167 	 * version of this structure
168 	 */
169 	unsigned	cons_polledio_version;
170 
171 	/*
172 	 * Argument that is passed to the following routines.
173 	 */
174 	cons_polledio_arg_t	cons_polledio_argument;
175 
176 	/*
177 	 * Pointer to the routine and its argument that handles putting
178 	 * characters out to the polled device.
179 	 */
180 	void		(*cons_polledio_putchar)(cons_polledio_arg_t,
181 				uchar_t);
182 
183 	/*
184 	 * Pointer to the routine and its argument that handles getting
185 	 * characters from the polled device.  This routine is blocking.
186 	 */
187 	int		(*cons_polledio_getchar)(cons_polledio_arg_t);
188 
189 	/*
190 	 * Pointer to the routine and its argument that checks to see
191 	 * if a character is pending input.  This routine is non-blocking.
192 	 */
193 	boolean_t	(*cons_polledio_ischar)(cons_polledio_arg_t);
194 
195 	/*
196 	 * Initialize the polled subsystem.  This routine is called once
197 	 * per mode change from non-polled to polled mode.
198 	 */
199 	void		(*cons_polledio_enter)(cons_polledio_arg_t);
200 
201 	/*
202 	 * Restore the non-polled subsystem.  This routine is called once
203 	 * per mode change from non-polled to polled mode.
204 	 */
205 	void		(*cons_polledio_exit)(cons_polledio_arg_t);
206 
207 
208 	/* Routine to set the LED's in polled mode */
209 	void	(*cons_polledio_setled)(cons_polledio_arg_t, int);
210 
211 	/* Routine to indicate that a scande is available in polled mode */
212 	boolean_t	(*cons_polledio_keycheck)(
213 			    cons_polledio_arg_t,
214 			    kbtrans_key_t *, enum keystate *);
215 } cons_polledio_t;
216 
217 extern cons_polledio_t *cons_polledio;
218 
219 /*
220  * Workstation Console
221  */
222 #define	_WCIOC		(('W'<<24)|('C'<<16))
223 #define	WC_OPEN_FB	(_WCIOC | 0)
224 #define	WC_CLOSE_FB	(_WCIOC | 1)
225 
226 #endif	/* _KERNEL || _KMDB */
227 
228 #ifdef	__cplusplus
229 }
230 #endif
231 
232 #endif	/* _SYS_CONSDEV_H */
233