xref: /onnv-gate/usr/src/uts/common/sys/consdev.h (revision 1762:b91aae9ab33e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51253Slq150181  * Common Development and Distribution License (the "License").
61253Slq150181  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211253Slq150181 
220Sstevel@tonic-gate /*
231253Slq150181  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SYS_CONSDEV_H
280Sstevel@tonic-gate #define	_SYS_CONSDEV_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/isa_defs.h>
330Sstevel@tonic-gate #include <sys/dditypes.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
391253Slq150181 
400Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB)
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * Paths to console devices
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate #define	CONSKBD_PATH	"/pseudo/conskbd@0:conskbd"
460Sstevel@tonic-gate #define	CONSMS_PATH	"/pseudo/consms@0:mouse"
470Sstevel@tonic-gate #define	WC_PATH		"/pseudo/wc@0:wscons"
480Sstevel@tonic-gate #define	IWSCN_PATH	"/pseudo/iwscn@0:iwscn"
490Sstevel@tonic-gate #define	CVC_PATH	"/pseudo/cvc@0:cvc"
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * Console redirection.
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate extern dev_t	rconsdev;	/* real (underlying) console */
550Sstevel@tonic-gate extern struct vnode *rconsvp;	/* pointer to vnode for that device */
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /*
580Sstevel@tonic-gate  * Mouse, keyboard, and frame buffer configuration information.
590Sstevel@tonic-gate  *
600Sstevel@tonic-gate  * XXX:	Assumes a single mouse/keyboard/frame buffer triple.
610Sstevel@tonic-gate  */
620Sstevel@tonic-gate extern dev_t	mousedev;	/* default mouse device */
630Sstevel@tonic-gate extern dev_t	kbddev;		/* default (actual) keyboard device */
640Sstevel@tonic-gate extern dev_t	stdindev;	/* default standard input device */
650Sstevel@tonic-gate extern dev_t	fbdev;		/* default framebuffer device */
660Sstevel@tonic-gate extern struct vnode *fbvp;	/* pointer to vnode for that device */
670Sstevel@tonic-gate extern dev_info_t *fbdip;	/* pointer to dev_info for fbdev (optional) */
680Sstevel@tonic-gate 
691253Slq150181 extern int	consmode;	/* CONS_FW or CONS_KFB */
701253Slq150181 extern int	cons_tem_disable;
711253Slq150181 #define	CONS_FW		0
721253Slq150181 #define	CONS_KFB	1
731253Slq150181 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * Workstation console redirection.
760Sstevel@tonic-gate  *
770Sstevel@tonic-gate  * The workstation console device is the multiplexor that hooks keyboard and
780Sstevel@tonic-gate  * frame buffer together into a single tty-like device.  Access to it is
790Sstevel@tonic-gate  * through the redirecting driver, so that frame buffer output can be
800Sstevel@tonic-gate  * redirected to other devices.  wsconsvp names the redirecting access point,
810Sstevel@tonic-gate  * and rwsconsvp names the workstation console itself.
820Sstevel@tonic-gate  *
830Sstevel@tonic-gate  * XXX:	Assumes a single workstation console.
840Sstevel@tonic-gate  */
850Sstevel@tonic-gate extern struct vnode *wsconsvp;	/* vnode for redirecting ws cons access */
860Sstevel@tonic-gate extern struct vnode *rwsconsvp;	/* vnode for underlying workstation console */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate extern int cn_conf;
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * Generic console ioctls.
920Sstevel@tonic-gate  *
930Sstevel@tonic-gate  * On systems without OBP, all potential console devices should implement these.
940Sstevel@tonic-gate  *
950Sstevel@tonic-gate  * On systems with OBP, all potential console devices should implement
960Sstevel@tonic-gate  * the ABORTENABLE ioctls.  All potential console devices that cannot share
970Sstevel@tonic-gate  * their hardware with OBP should implement the POLLEDIO ioctls.
980Sstevel@tonic-gate  */
990Sstevel@tonic-gate #define	_CONSIOC	(('C'<<24)|('O'<<16)|('N'<<8))
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate  * Get the structure of function pointers to be used for polled I/O
1030Sstevel@tonic-gate  *
1040Sstevel@tonic-gate  *	struct cons_polledio *polledio;
1050Sstevel@tonic-gate  *	struct strioctl str;
1060Sstevel@tonic-gate  *
1070Sstevel@tonic-gate  *	str.ic_cmd = CONS_OPENPOLLEDIO;
1080Sstevel@tonic-gate  *	str.ic_timout = INFTIM;
1090Sstevel@tonic-gate  *	str.ic_len = sizeof (polledio);
1100Sstevel@tonic-gate  *	str.ic_dp = (char *)&polledio;
1110Sstevel@tonic-gate  *	ioctl(fd, I_STR, &str);
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate #define	CONSOPENPOLLEDIO	(_CONSIOC|0)
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate /*
1160Sstevel@tonic-gate  * Get the current state of abort enable
1170Sstevel@tonic-gate  * enable = ioctl(fd, CONSGETABORTENABLE, 0)
1180Sstevel@tonic-gate  */
1190Sstevel@tonic-gate #define	CONSGETABORTENABLE	(_CONSIOC|1)
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate /*
1220Sstevel@tonic-gate  * Set the current state of abort enable
1230Sstevel@tonic-gate  * ioctl(fd, CONSSETABORTENABLE, boolean_t)
1240Sstevel@tonic-gate  */
1250Sstevel@tonic-gate #define	CONSSETABORTENABLE	(_CONSIOC|2)
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate /*
1280Sstevel@tonic-gate  * Undo anything that was done with CONSOPENPOLLEDIO
1290Sstevel@tonic-gate  * ioctl(fd, CONSCLOSEPOLLEDIO, 0)
1300Sstevel@tonic-gate  */
1310Sstevel@tonic-gate #define	CONSCLOSEPOLLEDIO	(_CONSIOC|3)
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * Set the type simulated by hardwares
1350Sstevel@tonic-gate  * ioctl(fd, CONSSETKBDTYPE, kbdtype)
1360Sstevel@tonic-gate  * kbdtype:
1370Sstevel@tonic-gate  * 	KB_PC or KB_USB
1380Sstevel@tonic-gate  */
1390Sstevel@tonic-gate #define	CONSSETKBDTYPE		(_CONSIOC|4)
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate #define	CONSPOLLEDIO_V0		0
1420Sstevel@tonic-gate #define	CONSPOLLEDIO_V1		1
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate typedef int kbtrans_key_t;
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 };
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate /*
1500Sstevel@tonic-gate  * Opaque state structure for driver state.  Each driver has its own
1510Sstevel@tonic-gate  * implementation (with different names!), and casts to/from this.
1520Sstevel@tonic-gate  * This allows better type-checking than "void *", helping to ensure
1530Sstevel@tonic-gate  * that the structure passed in is the structure used in the callback.
1540Sstevel@tonic-gate  */
155*1762Slt200341 typedef struct __cons_polledio_arg	*cons_polledio_arg_t;
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * This is the structure that is used to handle polled I/O.  It is filled
1590Sstevel@tonic-gate  * in by a lower driver, passed up, and eventually registered with the
1600Sstevel@tonic-gate  * debugger that needs to do polled I/O.
1610Sstevel@tonic-gate  */
1620Sstevel@tonic-gate typedef struct cons_polledio {
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 	/*
1650Sstevel@tonic-gate 	 * version of this structure
1660Sstevel@tonic-gate 	 */
1670Sstevel@tonic-gate 	unsigned	cons_polledio_version;
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate 	/*
1700Sstevel@tonic-gate 	 * Argument that is passed to the following routines.
1710Sstevel@tonic-gate 	 */
172*1762Slt200341 	cons_polledio_arg_t	cons_polledio_argument;
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate 	/*
1750Sstevel@tonic-gate 	 * Pointer to the routine and its argument that handles putting
1760Sstevel@tonic-gate 	 * characters out to the polled device.
1770Sstevel@tonic-gate 	 */
178*1762Slt200341 	void		(*cons_polledio_putchar)(cons_polledio_arg_t,
1790Sstevel@tonic-gate 				uchar_t);
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate 	/*
1820Sstevel@tonic-gate 	 * Pointer to the routine and its argument that handles getting
1830Sstevel@tonic-gate 	 * characters from the polled device.  This routine is blocking.
1840Sstevel@tonic-gate 	 */
185*1762Slt200341 	int		(*cons_polledio_getchar)(cons_polledio_arg_t);
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate 	/*
1880Sstevel@tonic-gate 	 * Pointer to the routine and its argument that checks to see
1890Sstevel@tonic-gate 	 * if a character is pending input.  This routine is non-blocking.
1900Sstevel@tonic-gate 	 */
191*1762Slt200341 	boolean_t	(*cons_polledio_ischar)(cons_polledio_arg_t);
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate 	/*
1940Sstevel@tonic-gate 	 * Initialize the polled subsystem.  This routine is called once
1950Sstevel@tonic-gate 	 * per mode change from non-polled to polled mode.
1960Sstevel@tonic-gate 	 */
197*1762Slt200341 	void		(*cons_polledio_enter)(cons_polledio_arg_t);
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate 	/*
2000Sstevel@tonic-gate 	 * Restore the non-polled subsystem.  This routine is called once
2010Sstevel@tonic-gate 	 * per mode change from non-polled to polled mode.
2020Sstevel@tonic-gate 	 */
203*1762Slt200341 	void		(*cons_polledio_exit)(cons_polledio_arg_t);
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate 	/* Routine to set the LED's in polled mode */
207*1762Slt200341 	void	(*cons_polledio_setled)(cons_polledio_arg_t, int);
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate 	/* Routine to indicate that a scande is available in polled mode */
2100Sstevel@tonic-gate 	boolean_t	(*cons_polledio_keycheck)(
211*1762Slt200341 			    cons_polledio_arg_t,
2120Sstevel@tonic-gate 			    kbtrans_key_t *, enum keystate *);
2130Sstevel@tonic-gate } cons_polledio_t;
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate extern cons_polledio_t *cons_polledio;
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate /*
2180Sstevel@tonic-gate  * Workstation Console
2190Sstevel@tonic-gate  */
2200Sstevel@tonic-gate #define	_WCIOC		(('W'<<24)|('C'<<16))
2210Sstevel@tonic-gate #define	WC_OPEN_FB	(_WCIOC | 0)
2220Sstevel@tonic-gate #define	WC_CLOSE_FB	(_WCIOC | 1)
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate #endif	/* _KERNEL || _KMDB */
2250Sstevel@tonic-gate 
2260Sstevel@tonic-gate #ifdef	__cplusplus
2270Sstevel@tonic-gate }
2280Sstevel@tonic-gate #endif
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate #endif	/* _SYS_CONSDEV_H */
231