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
5e4603304Sqz  * Common Development and Distribution License (the "License").
6e4603304Sqz  * 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  */
21aecfc01dSrui zang - Sun Microsystems - Beijing China 
227c478bd9Sstevel@tonic-gate /*
233bce8c8cSJan Setje-Eilers  * 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 _KBTRANS_STREAMS_H
287c478bd9Sstevel@tonic-gate #define	_KBTRANS_STREAMS_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef __cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/stream.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #define	KBTRANS_POLLED_BUF_SIZE	30
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /* definitions for various state machines */
397c478bd9Sstevel@tonic-gate #define	KBTRANS_STREAMS_OPEN	0x00000001 /* keyboard is open for business */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	NO_HARD_RESET	0	/* resets only state struct */
427c478bd9Sstevel@tonic-gate #define	HARD_RESET	1	/* resets keyboard and state structure */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * structure to keep track of currently pressed keys when in
467c478bd9Sstevel@tonic-gate  * TR_UNTRANS_EVENT mode
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate typedef struct  key_event {
497c478bd9Sstevel@tonic-gate 	uchar_t  key_station;   /* Physical key station associated with event */
507c478bd9Sstevel@tonic-gate 	Firm_event event;	/* Event that sent out on down */
517c478bd9Sstevel@tonic-gate } Key_event;
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /* state structure for kbtrans_streams */
557c478bd9Sstevel@tonic-gate struct  kbtrans {
567c478bd9Sstevel@tonic-gate 	struct kbtrans_lower	kbtrans_lower;	/* actual translation state */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 	/* Read and write queues */
59*5d420dfbSToomas Soome 	queue_t		*kbtrans_streams_readq;
60*5d420dfbSToomas Soome 	queue_t		*kbtrans_streams_writeq;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	/* Pending "ioctl" awaiting buffer */
63*5d420dfbSToomas Soome 	mblk_t		*kbtrans_streams_iocpending;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 	/* Number of times the keyboard overflowed input */
667c478bd9Sstevel@tonic-gate 	int		kbtrans_overflow_cnt;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	/* random flags */
697c478bd9Sstevel@tonic-gate 	int		kbtrans_streams_flags;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 	/* id from qbufcall on allocb failure */
727c478bd9Sstevel@tonic-gate 	bufcall_id_t	kbtrans_streams_bufcallid;
737c478bd9Sstevel@tonic-gate 
74*5d420dfbSToomas Soome 	unsigned	kbtrans_streams_count;
757c478bd9Sstevel@tonic-gate 	timeout_id_t	kbtrans_streams_rptid; /* timeout id for repeat */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 	int	kbtrans_streams_iocerror;	/* error return from "ioctl" */
787c478bd9Sstevel@tonic-gate 	int	kbtrans_streams_translate_mode;	/* Translate keycodes? */
79*5d420dfbSToomas Soome 	int	kbtrans_streams_translatable;	/* Keyboard is translatable? */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	/* Vuid_id_addrs for various events */
827c478bd9Sstevel@tonic-gate 	struct {
837c478bd9Sstevel@tonic-gate 	    short	ascii;
847c478bd9Sstevel@tonic-gate 	    short	top;
857c478bd9Sstevel@tonic-gate 	    short	vkey;
867c478bd9Sstevel@tonic-gate 	}	kbtrans_streams_vuid_addr;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate 	/*
897c478bd9Sstevel@tonic-gate 	 * Table of key stations currently down that have
907c478bd9Sstevel@tonic-gate 	 * have firm events that need to be matched with up transitions
917c478bd9Sstevel@tonic-gate 	 * when translation mode is TR_*EVENT
927c478bd9Sstevel@tonic-gate 	 */
937c478bd9Sstevel@tonic-gate 	struct  key_event *kbtrans_streams_downs;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	/* Number of down entries */
967c478bd9Sstevel@tonic-gate 	int	kbtrans_streams_num_downs_entries; /* entries in downs */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 	/* Bytes allocated for downs */
997c478bd9Sstevel@tonic-gate 	uint_t  kbtrans_streams_downs_bytes;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 	/* Abort state */
1027c478bd9Sstevel@tonic-gate 	enum {
1037c478bd9Sstevel@tonic-gate 		ABORT_NORMAL,
104e4603304Sqz 		ABORT_ABORT1_RECEIVED,
105e4603304Sqz 		NEW_ABORT_ABORT1_RECEIVED	/* for new abort key */
1067c478bd9Sstevel@tonic-gate 	}		kbtrans_streams_abort_state;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate 	/* Indicated whether or not abort may be honored */
1097c478bd9Sstevel@tonic-gate 	boolean_t	kbtrans_streams_abortable;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 	/*
1127c478bd9Sstevel@tonic-gate 	 * During an abort sequence, says which key started the sequence.
1137c478bd9Sstevel@tonic-gate 	 * This is used to support both L1+A and F1+A.
1147c478bd9Sstevel@tonic-gate 	 */
1157c478bd9Sstevel@tonic-gate 	kbtrans_key_t	kbtrans_streams_abort1_key;
1167c478bd9Sstevel@tonic-gate 
117e4603304Sqz 	/* It is used to support new abort sequence Shift+Pause */
118e4603304Sqz 	kbtrans_key_t	kbtrans_streams_new_abort1_key;
119e4603304Sqz 
1207c478bd9Sstevel@tonic-gate 	/* Functions to be called based on the translation type */
1217c478bd9Sstevel@tonic-gate 	struct keyboard_callback *kbtrans_streams_callback;
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate 	/* Private structure for the keyboard specific module/driver */
1247c478bd9Sstevel@tonic-gate 	struct kbtrans_hardware *kbtrans_streams_hw;
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 	/* Callbacks into the keyboard specific module/driver */
1277c478bd9Sstevel@tonic-gate 	struct kbtrans_callbacks *kbtrans_streams_hw_callbacks;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 	/* Keyboard type */
1307c478bd9Sstevel@tonic-gate 	int	kbtrans_streams_id;
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	/* Buffers to hold characters during the polled mode */
1337c478bd9Sstevel@tonic-gate 	char	*kbtrans_polled_pending_chars;
1347c478bd9Sstevel@tonic-gate 	char	kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1];
135aecfc01dSrui zang - Sun Microsystems - Beijing China 
136aecfc01dSrui zang - Sun Microsystems - Beijing China 	/* vt switch key sequence state */
137aecfc01dSrui zang - Sun Microsystems - Beijing China 	enum {
138aecfc01dSrui zang - Sun Microsystems - Beijing China 		VT_SWITCH_KEY_NONE = 0,
139aecfc01dSrui zang - Sun Microsystems - Beijing China 		VT_SWITCH_KEY_ALT,	/* left Alt key is pressed */
140aecfc01dSrui zang - Sun Microsystems - Beijing China 		VT_SWITCH_KEY_ALTGR	/* right Alt key is pressed */
141aecfc01dSrui zang - Sun Microsystems - Beijing China 	}		vt_switch_keystate;
1423bce8c8cSJan Setje-Eilers 
1433bce8c8cSJan Setje-Eilers 	kcondvar_t progressbar_key_abort_cv;
1443bce8c8cSJan Setje-Eilers 	kmutex_t progressbar_key_abort_lock;
1453bce8c8cSJan Setje-Eilers 	int progressbar_key_abort_flag;
1466087c6ddSJan Setje-Eilers 	kt_did_t progressbar_key_abort_t_did;
1477c478bd9Sstevel@tonic-gate };
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1507c478bd9Sstevel@tonic-gate }
1517c478bd9Sstevel@tonic-gate #endif
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #endif /* _KBTRANS_STREAMS_H */
154