Home | History | Annotate | Download | only in kbtrans
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 /*
     23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #ifndef _KBTRANS_STREAMS_H
     28 #define	_KBTRANS_STREAMS_H
     29 
     30 #ifdef __cplusplus
     31 extern "C" {
     32 #endif
     33 
     34 #include <sys/stream.h>
     35 
     36 #define	KBTRANS_POLLED_BUF_SIZE	30
     37 
     38 /* definitions for various state machines */
     39 #define	KBTRANS_STREAMS_OPEN	0x00000001 /* keyboard is open for business */
     40 
     41 #define	NO_HARD_RESET	0	/* resets only state struct */
     42 #define	HARD_RESET	1	/* resets keyboard and state structure */
     43 
     44 /*
     45  * structure to keep track of currently pressed keys when in
     46  * TR_UNTRANS_EVENT mode
     47  */
     48 typedef struct  key_event {
     49 	uchar_t  key_station;   /* Physical key station associated with event */
     50 	Firm_event event;	/* Event that sent out on down */
     51 } Key_event;
     52 
     53 
     54 /* state structure for kbtrans_streams */
     55 struct  kbtrans {
     56 	struct kbtrans_lower	kbtrans_lower;	/* actual translation state */
     57 
     58 	/* Read and write queues */
     59 	queue_t 	*kbtrans_streams_readq;
     60 	queue_t 	*kbtrans_streams_writeq;
     61 
     62 	/* Pending "ioctl" awaiting buffer */
     63 	mblk_t  	*kbtrans_streams_iocpending;
     64 
     65 	/* Number of times the keyboard overflowed input */
     66 	int		kbtrans_overflow_cnt;
     67 
     68 	/* random flags */
     69 	int		kbtrans_streams_flags;
     70 
     71 	/* id from qbufcall on allocb failure */
     72 	bufcall_id_t	kbtrans_streams_bufcallid;
     73 
     74 	timeout_id_t	kbtrans_streams_rptid; /* timeout id for repeat */
     75 
     76 	int	kbtrans_streams_iocerror;	/* error return from "ioctl" */
     77 	int	kbtrans_streams_translate_mode;	/* Translate keycodes? */
     78 	int	kbtrans_streams_translatable;  	/* Keyboard is translatable? */
     79 
     80 	/* Vuid_id_addrs for various events */
     81 	struct {
     82 	    short	ascii;
     83 	    short	top;
     84 	    short	vkey;
     85 	}	kbtrans_streams_vuid_addr;
     86 
     87 	/*
     88 	 * Table of key stations currently down that have
     89 	 * have firm events that need to be matched with up transitions
     90 	 * when translation mode is TR_*EVENT
     91 	 */
     92 	struct  key_event *kbtrans_streams_downs;
     93 
     94 	/* Number of down entries */
     95 	int	kbtrans_streams_num_downs_entries; /* entries in downs */
     96 
     97 	/* Bytes allocated for downs */
     98 	uint_t  kbtrans_streams_downs_bytes;
     99 
    100 	/* Abort state */
    101 	enum {
    102 		ABORT_NORMAL,
    103 		ABORT_ABORT1_RECEIVED,
    104 		NEW_ABORT_ABORT1_RECEIVED	/* for new abort key */
    105 	}		kbtrans_streams_abort_state;
    106 
    107 	/* Indicated whether or not abort may be honored */
    108 	boolean_t	kbtrans_streams_abortable;
    109 
    110 	/*
    111 	 * During an abort sequence, says which key started the sequence.
    112 	 * This is used to support both L1+A and F1+A.
    113 	 */
    114 	kbtrans_key_t	kbtrans_streams_abort1_key;
    115 
    116 	/* It is used to support new abort sequence Shift+Pause */
    117 	kbtrans_key_t	kbtrans_streams_new_abort1_key;
    118 
    119 	/* Functions to be called based on the translation type */
    120 	struct keyboard_callback *kbtrans_streams_callback;
    121 
    122 	/* Private structure for the keyboard specific module/driver */
    123 	struct kbtrans_hardware *kbtrans_streams_hw;
    124 
    125 	/* Callbacks into the keyboard specific module/driver */
    126 	struct kbtrans_callbacks *kbtrans_streams_hw_callbacks;
    127 
    128 	/* Keyboard type */
    129 	int	kbtrans_streams_id;
    130 
    131 	/* Buffers to hold characters during the polled mode */
    132 	char	*kbtrans_polled_pending_chars;
    133 	char	kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1];
    134 
    135 	/* vt switch key sequence state */
    136 	enum {
    137 		VT_SWITCH_KEY_NONE = 0,
    138 		VT_SWITCH_KEY_ALT,	/* left Alt key is pressed */
    139 		VT_SWITCH_KEY_ALTGR	/* right Alt key is pressed */
    140 	}		vt_switch_keystate;
    141 
    142 	kcondvar_t progressbar_key_abort_cv;
    143 	kmutex_t progressbar_key_abort_lock;
    144 	int progressbar_key_abort_flag;
    145 	kt_did_t progressbar_key_abort_t_did;
    146 };
    147 
    148 #ifdef __cplusplus
    149 }
    150 #endif
    151 
    152 #endif /* _KBTRANS_STREAMS_H */
    153