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