xref: /titanic_51/usr/src/uts/common/sys/consdev.h (revision 361ed64a5abddd9ed26f47e25824bbce82557ab4)
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 /*
23*361ed64aSJames 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 /*
56*361ed64aSJames Anderson  * Virtual Serial Console redirection.
57*361ed64aSJames Anderson  */
58*361ed64aSJames Anderson extern struct vnode *vsconsvp;	/* pointer to vnode for virtual console */
59*361ed64aSJames Anderson 
60*361ed64aSJames 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) */
717c478bd9Sstevel@tonic-gate 
72fea9cb91Slq150181 extern int	consmode;	/* CONS_FW or CONS_KFB */
73fea9cb91Slq150181 extern int	cons_tem_disable;
74fea9cb91Slq150181 #define	CONS_FW		0
75fea9cb91Slq150181 #define	CONS_KFB	1
76fea9cb91Slq150181 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * Workstation console redirection.
797c478bd9Sstevel@tonic-gate  *
807c478bd9Sstevel@tonic-gate  * The workstation console device is the multiplexor that hooks keyboard and
817c478bd9Sstevel@tonic-gate  * frame buffer together into a single tty-like device.  Access to it is
827c478bd9Sstevel@tonic-gate  * through the redirecting driver, so that frame buffer output can be
837c478bd9Sstevel@tonic-gate  * redirected to other devices.  wsconsvp names the redirecting access point,
847c478bd9Sstevel@tonic-gate  * and rwsconsvp names the workstation console itself.
857c478bd9Sstevel@tonic-gate  *
867c478bd9Sstevel@tonic-gate  * XXX:	Assumes a single workstation console.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate extern struct vnode *wsconsvp;	/* vnode for redirecting ws cons access */
897c478bd9Sstevel@tonic-gate extern struct vnode *rwsconsvp;	/* vnode for underlying workstation console */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  * Generic console ioctls.
937c478bd9Sstevel@tonic-gate  *
947c478bd9Sstevel@tonic-gate  * On systems without OBP, all potential console devices should implement these.
957c478bd9Sstevel@tonic-gate  *
967c478bd9Sstevel@tonic-gate  * On systems with OBP, all potential console devices should implement
977c478bd9Sstevel@tonic-gate  * the ABORTENABLE ioctls.  All potential console devices that cannot share
987c478bd9Sstevel@tonic-gate  * their hardware with OBP should implement the POLLEDIO ioctls.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate #define	_CONSIOC	(('C'<<24)|('O'<<16)|('N'<<8))
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Get the structure of function pointers to be used for polled I/O
1047c478bd9Sstevel@tonic-gate  *
1057c478bd9Sstevel@tonic-gate  *	struct cons_polledio *polledio;
1067c478bd9Sstevel@tonic-gate  *	struct strioctl str;
1077c478bd9Sstevel@tonic-gate  *
1087c478bd9Sstevel@tonic-gate  *	str.ic_cmd = CONS_OPENPOLLEDIO;
1097c478bd9Sstevel@tonic-gate  *	str.ic_timout = INFTIM;
1107c478bd9Sstevel@tonic-gate  *	str.ic_len = sizeof (polledio);
1117c478bd9Sstevel@tonic-gate  *	str.ic_dp = (char *)&polledio;
1127c478bd9Sstevel@tonic-gate  *	ioctl(fd, I_STR, &str);
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate #define	CONSOPENPOLLEDIO	(_CONSIOC|0)
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * Get the current state of abort enable
1187c478bd9Sstevel@tonic-gate  * enable = ioctl(fd, CONSGETABORTENABLE, 0)
1197c478bd9Sstevel@tonic-gate  */
1207c478bd9Sstevel@tonic-gate #define	CONSGETABORTENABLE	(_CONSIOC|1)
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * Set the current state of abort enable
1247c478bd9Sstevel@tonic-gate  * ioctl(fd, CONSSETABORTENABLE, boolean_t)
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate #define	CONSSETABORTENABLE	(_CONSIOC|2)
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  * Undo anything that was done with CONSOPENPOLLEDIO
1307c478bd9Sstevel@tonic-gate  * ioctl(fd, CONSCLOSEPOLLEDIO, 0)
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate #define	CONSCLOSEPOLLEDIO	(_CONSIOC|3)
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  * Set the type simulated by hardwares
1367c478bd9Sstevel@tonic-gate  * ioctl(fd, CONSSETKBDTYPE, kbdtype)
1377c478bd9Sstevel@tonic-gate  * kbdtype:
1387c478bd9Sstevel@tonic-gate  * 	KB_PC or KB_USB
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate #define	CONSSETKBDTYPE		(_CONSIOC|4)
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #define	CONSPOLLEDIO_V0		0
1437c478bd9Sstevel@tonic-gate #define	CONSPOLLEDIO_V1		1
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate typedef int kbtrans_key_t;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 };
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  * Opaque state structure for driver state.  Each driver has its own
1527c478bd9Sstevel@tonic-gate  * implementation (with different names!), and casts to/from this.
1537c478bd9Sstevel@tonic-gate  * This allows better type-checking than "void *", helping to ensure
1547c478bd9Sstevel@tonic-gate  * that the structure passed in is the structure used in the callback.
1557c478bd9Sstevel@tonic-gate  */
156281f0747Slt200341 typedef struct __cons_polledio_arg	*cons_polledio_arg_t;
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate  * This is the structure that is used to handle polled I/O.  It is filled
1607c478bd9Sstevel@tonic-gate  * in by a lower driver, passed up, and eventually registered with the
1617c478bd9Sstevel@tonic-gate  * debugger that needs to do polled I/O.
1627c478bd9Sstevel@tonic-gate  */
1637c478bd9Sstevel@tonic-gate typedef struct cons_polledio {
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 	/*
1667c478bd9Sstevel@tonic-gate 	 * version of this structure
1677c478bd9Sstevel@tonic-gate 	 */
1687c478bd9Sstevel@tonic-gate 	unsigned	cons_polledio_version;
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate 	/*
1717c478bd9Sstevel@tonic-gate 	 * Argument that is passed to the following routines.
1727c478bd9Sstevel@tonic-gate 	 */
173281f0747Slt200341 	cons_polledio_arg_t	cons_polledio_argument;
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	/*
1767c478bd9Sstevel@tonic-gate 	 * Pointer to the routine and its argument that handles putting
1777c478bd9Sstevel@tonic-gate 	 * characters out to the polled device.
1787c478bd9Sstevel@tonic-gate 	 */
179281f0747Slt200341 	void		(*cons_polledio_putchar)(cons_polledio_arg_t,
1807c478bd9Sstevel@tonic-gate 				uchar_t);
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate 	/*
1837c478bd9Sstevel@tonic-gate 	 * Pointer to the routine and its argument that handles getting
1847c478bd9Sstevel@tonic-gate 	 * characters from the polled device.  This routine is blocking.
1857c478bd9Sstevel@tonic-gate 	 */
186281f0747Slt200341 	int		(*cons_polledio_getchar)(cons_polledio_arg_t);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 	/*
1897c478bd9Sstevel@tonic-gate 	 * Pointer to the routine and its argument that checks to see
1907c478bd9Sstevel@tonic-gate 	 * if a character is pending input.  This routine is non-blocking.
1917c478bd9Sstevel@tonic-gate 	 */
192281f0747Slt200341 	boolean_t	(*cons_polledio_ischar)(cons_polledio_arg_t);
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate 	/*
1957c478bd9Sstevel@tonic-gate 	 * Initialize the polled subsystem.  This routine is called once
1967c478bd9Sstevel@tonic-gate 	 * per mode change from non-polled to polled mode.
1977c478bd9Sstevel@tonic-gate 	 */
198281f0747Slt200341 	void		(*cons_polledio_enter)(cons_polledio_arg_t);
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 	/*
2017c478bd9Sstevel@tonic-gate 	 * Restore the non-polled subsystem.  This routine is called once
2027c478bd9Sstevel@tonic-gate 	 * per mode change from non-polled to polled mode.
2037c478bd9Sstevel@tonic-gate 	 */
204281f0747Slt200341 	void		(*cons_polledio_exit)(cons_polledio_arg_t);
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	/* Routine to set the LED's in polled mode */
208281f0747Slt200341 	void	(*cons_polledio_setled)(cons_polledio_arg_t, int);
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	/* Routine to indicate that a scande is available in polled mode */
2117c478bd9Sstevel@tonic-gate 	boolean_t	(*cons_polledio_keycheck)(
212281f0747Slt200341 			    cons_polledio_arg_t,
2137c478bd9Sstevel@tonic-gate 			    kbtrans_key_t *, enum keystate *);
2147c478bd9Sstevel@tonic-gate } cons_polledio_t;
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate extern cons_polledio_t *cons_polledio;
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate /*
2197c478bd9Sstevel@tonic-gate  * Workstation Console
2207c478bd9Sstevel@tonic-gate  */
2217c478bd9Sstevel@tonic-gate #define	_WCIOC		(('W'<<24)|('C'<<16))
2227c478bd9Sstevel@tonic-gate #define	WC_OPEN_FB	(_WCIOC | 0)
2237c478bd9Sstevel@tonic-gate #define	WC_CLOSE_FB	(_WCIOC | 1)
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate #endif	/* _KERNEL || _KMDB */
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2287c478bd9Sstevel@tonic-gate }
2297c478bd9Sstevel@tonic-gate #endif
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #endif	/* _SYS_CONSDEV_H */
232