xref: /illumos-gate/usr/src/uts/common/sys/consdev.h (revision dbad7380)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5fea9cb91Slq150181  * Common Development and Distribution License (the "License").
6fea9cb91Slq150181  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21fea9cb91Slq150181 
227c478bd9Sstevel@tonic-gate /*
23361ed64aSJames Anderson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_CONSDEV_H
287c478bd9Sstevel@tonic-gate #define	_SYS_CONSDEV_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
317c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
37fea9cb91Slq150181 
387c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB)
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  * Paths to console devices
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate #define	CONSKBD_PATH	"/pseudo/conskbd@0:conskbd"
447c478bd9Sstevel@tonic-gate #define	CONSMS_PATH	"/pseudo/consms@0:mouse"
457c478bd9Sstevel@tonic-gate #define	WC_PATH		"/pseudo/wc@0:wscons"
467c478bd9Sstevel@tonic-gate #define	IWSCN_PATH	"/pseudo/iwscn@0:iwscn"
477c478bd9Sstevel@tonic-gate #define	CVC_PATH	"/pseudo/cvc@0:cvc"
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Console redirection.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate extern dev_t	rconsdev;	/* real (underlying) console */
537c478bd9Sstevel@tonic-gate extern struct vnode *rconsvp;	/* pointer to vnode for that device */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
56361ed64aSJames Anderson  * Virtual Serial Console redirection.
57361ed64aSJames Anderson  */
58361ed64aSJames Anderson extern struct vnode *vsconsvp;	/* pointer to vnode for virtual console */
59361ed64aSJames Anderson 
60361ed64aSJames Anderson /*
617c478bd9Sstevel@tonic-gate  * Mouse, keyboard, and frame buffer configuration information.
627c478bd9Sstevel@tonic-gate  *
637c478bd9Sstevel@tonic-gate  * XXX:	Assumes a single mouse/keyboard/frame buffer triple.
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate extern dev_t	mousedev;	/* default mouse device */
667c478bd9Sstevel@tonic-gate extern dev_t	kbddev;		/* default (actual) keyboard device */
677c478bd9Sstevel@tonic-gate extern dev_t	stdindev;	/* default standard input device */
687c478bd9Sstevel@tonic-gate extern dev_t	fbdev;		/* default framebuffer device */
697c478bd9Sstevel@tonic-gate extern struct vnode *fbvp;	/* pointer to vnode for that device */
707c478bd9Sstevel@tonic-gate extern dev_info_t *fbdip;	/* pointer to dev_info for fbdev (optional) */
71*dbad7380SToomas Soome extern dev_t	diagdev;	/* default diag device (optional) */
727c478bd9Sstevel@tonic-gate 
73fea9cb91Slq150181 extern int	consmode;	/* CONS_FW or CONS_KFB */
74fea9cb91Slq150181 extern int	cons_tem_disable;
75fea9cb91Slq150181 #define	CONS_FW		0
76fea9cb91Slq150181 #define	CONS_KFB	1
77fea9cb91Slq150181 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * Workstation console redirection.
807c478bd9Sstevel@tonic-gate  *
817c478bd9Sstevel@tonic-gate  * The workstation console device is the multiplexor that hooks keyboard and
827c478bd9Sstevel@tonic-gate  * frame buffer together into a single tty-like device.  Access to it is
837c478bd9Sstevel@tonic-gate  * through the redirecting driver, so that frame buffer output can be
847c478bd9Sstevel@tonic-gate  * redirected to other devices.  wsconsvp names the redirecting access point,
857c478bd9Sstevel@tonic-gate  * and rwsconsvp names the workstation console itself.
867c478bd9Sstevel@tonic-gate  *
877c478bd9Sstevel@tonic-gate  * XXX:	Assumes a single workstation console.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate extern struct vnode *wsconsvp;	/* vnode for redirecting ws cons access */
907c478bd9Sstevel@tonic-gate extern struct vnode *rwsconsvp;	/* vnode for underlying workstation console */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Generic console ioctls.
947c478bd9Sstevel@tonic-gate  *
957c478bd9Sstevel@tonic-gate  * On systems without OBP, all potential console devices should implement these.
967c478bd9Sstevel@tonic-gate  *
977c478bd9Sstevel@tonic-gate  * On systems with OBP, all potential console devices should implement
987c478bd9Sstevel@tonic-gate  * the ABORTENABLE ioctls.  All potential console devices that cannot share
997c478bd9Sstevel@tonic-gate  * their hardware with OBP should implement the POLLEDIO ioctls.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate #define	_CONSIOC	(('C'<<24)|('O'<<16)|('N'<<8))
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  * Get the structure of function pointers to be used for polled I/O
1057c478bd9Sstevel@tonic-gate  *
1067c478bd9Sstevel@tonic-gate  *	struct cons_polledio *polledio;
1077c478bd9Sstevel@tonic-gate  *	struct strioctl str;
1087c478bd9Sstevel@tonic-gate  *
1097c478bd9Sstevel@tonic-gate  *	str.ic_cmd = CONS_OPENPOLLEDIO;
1107c478bd9Sstevel@tonic-gate  *	str.ic_timout = INFTIM;
1117c478bd9Sstevel@tonic-gate  *	str.ic_len = sizeof (polledio);
1127c478bd9Sstevel@tonic-gate  *	str.ic_dp = (char *)&polledio;
1137c478bd9Sstevel@tonic-gate  *	ioctl(fd, I_STR, &str);
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate #define	CONSOPENPOLLEDIO	(_CONSIOC|0)
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /*
1187c478bd9Sstevel@tonic-gate  * Get the current state of abort enable
1197c478bd9Sstevel@tonic-gate  * enable = ioctl(fd, CONSGETABORTENABLE, 0)
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate #define	CONSGETABORTENABLE	(_CONSIOC|1)
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate  * Set the current state of abort enable
1257c478bd9Sstevel@tonic-gate  * ioctl(fd, CONSSETABORTENABLE, boolean_t)
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate #define	CONSSETABORTENABLE	(_CONSIOC|2)
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * Undo anything that was done with CONSOPENPOLLEDIO
1317c478bd9Sstevel@tonic-gate  * ioctl(fd, CONSCLOSEPOLLEDIO, 0)
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #define	CONSCLOSEPOLLEDIO	(_CONSIOC|3)
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * Set the type simulated by hardwares
1377c478bd9Sstevel@tonic-gate  * ioctl(fd, CONSSETKBDTYPE, kbdtype)
1387c478bd9Sstevel@tonic-gate  * kbdtype:
1397c478bd9Sstevel@tonic-gate  *	KB_PC or KB_USB
1407c478bd9Sstevel@tonic-gate  */
1417c478bd9Sstevel@tonic-gate #define	CONSSETKBDTYPE		(_CONSIOC|4)
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate #define	CONSPOLLEDIO_V0		0
1447c478bd9Sstevel@tonic-gate #define	CONSPOLLEDIO_V1		1
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate typedef int kbtrans_key_t;
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 };
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * Opaque state structure for driver state.  Each driver has its own
1537c478bd9Sstevel@tonic-gate  * implementation (with different names!), and casts to/from this.
1547c478bd9Sstevel@tonic-gate  * This allows better type-checking than "void *", helping to ensure
1557c478bd9Sstevel@tonic-gate  * that the structure passed in is the structure used in the callback.
1567c478bd9Sstevel@tonic-gate  */
157281f0747Slt200341 typedef struct __cons_polledio_arg	*cons_polledio_arg_t;
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /*
1607c478bd9Sstevel@tonic-gate  * This is the structure that is used to handle polled I/O.  It is filled
1617c478bd9Sstevel@tonic-gate  * in by a lower driver, passed up, and eventually registered with the
1627c478bd9Sstevel@tonic-gate  * debugger that needs to do polled I/O.
1637c478bd9Sstevel@tonic-gate  */
1647c478bd9Sstevel@tonic-gate typedef struct cons_polledio {
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate 	/*
1677c478bd9Sstevel@tonic-gate 	 * version of this structure
1687c478bd9Sstevel@tonic-gate 	 */
1697c478bd9Sstevel@tonic-gate 	unsigned	cons_polledio_version;
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 	/*
1727c478bd9Sstevel@tonic-gate 	 * Argument that is passed to the following routines.
1737c478bd9Sstevel@tonic-gate 	 */
174281f0747Slt200341 	cons_polledio_arg_t	cons_polledio_argument;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate 	/*
1777c478bd9Sstevel@tonic-gate 	 * Pointer to the routine and its argument that handles putting
1787c478bd9Sstevel@tonic-gate 	 * characters out to the polled device.
1797c478bd9Sstevel@tonic-gate 	 */
180281f0747Slt200341 	void		(*cons_polledio_putchar)(cons_polledio_arg_t,
1817c478bd9Sstevel@tonic-gate 				uchar_t);
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate 	/*
1847c478bd9Sstevel@tonic-gate 	 * Pointer to the routine and its argument that handles getting
1857c478bd9Sstevel@tonic-gate 	 * characters from the polled device.  This routine is blocking.
1867c478bd9Sstevel@tonic-gate 	 */
187281f0747Slt200341 	int		(*cons_polledio_getchar)(cons_polledio_arg_t);
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate 	/*
1907c478bd9Sstevel@tonic-gate 	 * Pointer to the routine and its argument that checks to see
1917c478bd9Sstevel@tonic-gate 	 * if a character is pending input.  This routine is non-blocking.
1927c478bd9Sstevel@tonic-gate 	 */
193281f0747Slt200341 	boolean_t	(*cons_polledio_ischar)(cons_polledio_arg_t);
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate 	/*
1967c478bd9Sstevel@tonic-gate 	 * Initialize the polled subsystem.  This routine is called once
1977c478bd9Sstevel@tonic-gate 	 * per mode change from non-polled to polled mode.
1987c478bd9Sstevel@tonic-gate 	 */
199281f0747Slt200341 	void		(*cons_polledio_enter)(cons_polledio_arg_t);
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate 	/*
2027c478bd9Sstevel@tonic-gate 	 * Restore the non-polled subsystem.  This routine is called once
2037c478bd9Sstevel@tonic-gate 	 * per mode change from non-polled to polled mode.
2047c478bd9Sstevel@tonic-gate 	 */
205281f0747Slt200341 	void		(*cons_polledio_exit)(cons_polledio_arg_t);
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate 	/* Routine to set the LED's in polled mode */
209281f0747Slt200341 	void	(*cons_polledio_setled)(cons_polledio_arg_t, int);
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate 	/* Routine to indicate that a scande is available in polled mode */
2127c478bd9Sstevel@tonic-gate 	boolean_t	(*cons_polledio_keycheck)(
213281f0747Slt200341 			    cons_polledio_arg_t,
2147c478bd9Sstevel@tonic-gate 			    kbtrans_key_t *, enum keystate *);
2157c478bd9Sstevel@tonic-gate } cons_polledio_t;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate extern cons_polledio_t *cons_polledio;
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate /*
2207c478bd9Sstevel@tonic-gate  * Workstation Console
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate #define	_WCIOC		(('W'<<24)|('C'<<16))
2237c478bd9Sstevel@tonic-gate #define	WC_OPEN_FB	(_WCIOC | 0)
2247c478bd9Sstevel@tonic-gate #define	WC_CLOSE_FB	(_WCIOC | 1)
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate #endif	/* _KERNEL || _KMDB */
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate #endif
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate #endif	/* _SYS_CONSDEV_H */
233