xref: /onnv-gate/usr/src/uts/common/io/kbtrans/kbtrans_streams.h (revision 9022:4eecb577dc66)
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
53505Sqz150045  * Common Development and Distribution License (the "License").
63505Sqz150045  * 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  */
217688SAaron.Zang@Sun.COM 
220Sstevel@tonic-gate /*
238974SJan.Setje-Eilers@Sun.COM  * Copyright 2009 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 _KBTRANS_STREAMS_H
280Sstevel@tonic-gate #define	_KBTRANS_STREAMS_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef __cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #include <sys/stream.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #define	KBTRANS_POLLED_BUF_SIZE	30
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /* definitions for various state machines */
390Sstevel@tonic-gate #define	KBTRANS_STREAMS_OPEN	0x00000001 /* keyboard is open for business */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	NO_HARD_RESET	0	/* resets only state struct */
420Sstevel@tonic-gate #define	HARD_RESET	1	/* resets keyboard and state structure */
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * structure to keep track of currently pressed keys when in
460Sstevel@tonic-gate  * TR_UNTRANS_EVENT mode
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate typedef struct  key_event {
490Sstevel@tonic-gate 	uchar_t  key_station;   /* Physical key station associated with event */
500Sstevel@tonic-gate 	Firm_event event;	/* Event that sent out on down */
510Sstevel@tonic-gate } Key_event;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /* state structure for kbtrans_streams */
550Sstevel@tonic-gate struct  kbtrans {
560Sstevel@tonic-gate 	struct kbtrans_lower	kbtrans_lower;	/* actual translation state */
570Sstevel@tonic-gate 
580Sstevel@tonic-gate 	/* Read and write queues */
590Sstevel@tonic-gate 	queue_t 	*kbtrans_streams_readq;
600Sstevel@tonic-gate 	queue_t 	*kbtrans_streams_writeq;
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	/* Pending "ioctl" awaiting buffer */
630Sstevel@tonic-gate 	mblk_t  	*kbtrans_streams_iocpending;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate 	/* Number of times the keyboard overflowed input */
660Sstevel@tonic-gate 	int		kbtrans_overflow_cnt;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	/* random flags */
690Sstevel@tonic-gate 	int		kbtrans_streams_flags;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	/* id from qbufcall on allocb failure */
720Sstevel@tonic-gate 	bufcall_id_t	kbtrans_streams_bufcallid;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate 	timeout_id_t	kbtrans_streams_rptid; /* timeout id for repeat */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate 	int	kbtrans_streams_iocerror;	/* error return from "ioctl" */
770Sstevel@tonic-gate 	int	kbtrans_streams_translate_mode;	/* Translate keycodes? */
780Sstevel@tonic-gate 	int	kbtrans_streams_translatable;  	/* Keyboard is translatable? */
790Sstevel@tonic-gate 
800Sstevel@tonic-gate 	/* Vuid_id_addrs for various events */
810Sstevel@tonic-gate 	struct {
820Sstevel@tonic-gate 	    short	ascii;
830Sstevel@tonic-gate 	    short	top;
840Sstevel@tonic-gate 	    short	vkey;
850Sstevel@tonic-gate 	}	kbtrans_streams_vuid_addr;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	/*
880Sstevel@tonic-gate 	 * Table of key stations currently down that have
890Sstevel@tonic-gate 	 * have firm events that need to be matched with up transitions
900Sstevel@tonic-gate 	 * when translation mode is TR_*EVENT
910Sstevel@tonic-gate 	 */
920Sstevel@tonic-gate 	struct  key_event *kbtrans_streams_downs;
930Sstevel@tonic-gate 
940Sstevel@tonic-gate 	/* Number of down entries */
950Sstevel@tonic-gate 	int	kbtrans_streams_num_downs_entries; /* entries in downs */
960Sstevel@tonic-gate 
970Sstevel@tonic-gate 	/* Bytes allocated for downs */
980Sstevel@tonic-gate 	uint_t  kbtrans_streams_downs_bytes;
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate 	/* Abort state */
1010Sstevel@tonic-gate 	enum {
1020Sstevel@tonic-gate 		ABORT_NORMAL,
1033505Sqz150045 		ABORT_ABORT1_RECEIVED,
1043505Sqz150045 		NEW_ABORT_ABORT1_RECEIVED	/* for new abort key */
1050Sstevel@tonic-gate 	}		kbtrans_streams_abort_state;
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	/* Indicated whether or not abort may be honored */
1080Sstevel@tonic-gate 	boolean_t	kbtrans_streams_abortable;
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate 	/*
1110Sstevel@tonic-gate 	 * During an abort sequence, says which key started the sequence.
1120Sstevel@tonic-gate 	 * This is used to support both L1+A and F1+A.
1130Sstevel@tonic-gate 	 */
1140Sstevel@tonic-gate 	kbtrans_key_t	kbtrans_streams_abort1_key;
1150Sstevel@tonic-gate 
1163505Sqz150045 	/* It is used to support new abort sequence Shift+Pause */
1173505Sqz150045 	kbtrans_key_t	kbtrans_streams_new_abort1_key;
1183505Sqz150045 
1190Sstevel@tonic-gate 	/* Functions to be called based on the translation type */
1200Sstevel@tonic-gate 	struct keyboard_callback *kbtrans_streams_callback;
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate 	/* Private structure for the keyboard specific module/driver */
1230Sstevel@tonic-gate 	struct kbtrans_hardware *kbtrans_streams_hw;
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate 	/* Callbacks into the keyboard specific module/driver */
1260Sstevel@tonic-gate 	struct kbtrans_callbacks *kbtrans_streams_hw_callbacks;
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate 	/* Keyboard type */
1290Sstevel@tonic-gate 	int	kbtrans_streams_id;
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 	/* Buffers to hold characters during the polled mode */
1320Sstevel@tonic-gate 	char	*kbtrans_polled_pending_chars;
1330Sstevel@tonic-gate 	char	kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1];
1347688SAaron.Zang@Sun.COM 
1357688SAaron.Zang@Sun.COM 	/* vt switch key sequence state */
1367688SAaron.Zang@Sun.COM 	enum {
1377688SAaron.Zang@Sun.COM 		VT_SWITCH_KEY_NONE = 0,
1387688SAaron.Zang@Sun.COM 		VT_SWITCH_KEY_ALT,	/* left Alt key is pressed */
1397688SAaron.Zang@Sun.COM 		VT_SWITCH_KEY_ALTGR	/* right Alt key is pressed */
1407688SAaron.Zang@Sun.COM 	}		vt_switch_keystate;
1418974SJan.Setje-Eilers@Sun.COM 
1428974SJan.Setje-Eilers@Sun.COM 	kcondvar_t progressbar_key_abort_cv;
1438974SJan.Setje-Eilers@Sun.COM 	kmutex_t progressbar_key_abort_lock;
1448974SJan.Setje-Eilers@Sun.COM 	int progressbar_key_abort_flag;
145*9022SJan.Setje-Eilers@Sun.COM 	kt_did_t progressbar_key_abort_t_did;
1460Sstevel@tonic-gate };
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate #ifdef __cplusplus
1490Sstevel@tonic-gate }
1500Sstevel@tonic-gate #endif
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate #endif /* _KBTRANS_STREAMS_H */
153