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