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