xref: /titanic_44/usr/src/uts/common/io/kbtrans/kbtrans_streams.h (revision e1c679fa4b0ab8c4bcaa6263974ca0c46e5b027f)
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _KBTRANS_STREAMS_H
27 #define	_KBTRANS_STREAMS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/stream.h>
36 
37 #define	KBTRANS_POLLED_BUF_SIZE	30
38 
39 /* definitions for various state machines */
40 #define	KBTRANS_STREAMS_OPEN	0x00000001 /* keyboard is open for business */
41 
42 #define	NO_HARD_RESET	0	/* resets only state struct */
43 #define	HARD_RESET	1	/* resets keyboard and state structure */
44 
45 /*
46  * structure to keep track of currently pressed keys when in
47  * TR_UNTRANS_EVENT mode
48  */
49 typedef struct  key_event {
50 	uchar_t  key_station;   /* Physical key station associated with event */
51 	Firm_event event;	/* Event that sent out on down */
52 } Key_event;
53 
54 
55 /* state structure for kbtrans_streams */
56 struct  kbtrans {
57 	struct kbtrans_lower	kbtrans_lower;	/* actual translation state */
58 
59 	/* Read and write queues */
60 	queue_t 	*kbtrans_streams_readq;
61 	queue_t 	*kbtrans_streams_writeq;
62 
63 	/* Pending "ioctl" awaiting buffer */
64 	mblk_t  	*kbtrans_streams_iocpending;
65 
66 	/* Number of times the keyboard overflowed input */
67 	int		kbtrans_overflow_cnt;
68 
69 	/* random flags */
70 	int		kbtrans_streams_flags;
71 
72 	/* id from qbufcall on allocb failure */
73 	bufcall_id_t	kbtrans_streams_bufcallid;
74 
75 	timeout_id_t	kbtrans_streams_rptid; /* timeout id for repeat */
76 
77 	int	kbtrans_streams_iocerror;	/* error return from "ioctl" */
78 	int	kbtrans_streams_translate_mode;	/* Translate keycodes? */
79 	int	kbtrans_streams_translatable;  	/* Keyboard is translatable? */
80 
81 	/* Vuid_id_addrs for various events */
82 	struct {
83 	    short	ascii;
84 	    short	top;
85 	    short	vkey;
86 	}	kbtrans_streams_vuid_addr;
87 
88 	/*
89 	 * Table of key stations currently down that have
90 	 * have firm events that need to be matched with up transitions
91 	 * when translation mode is TR_*EVENT
92 	 */
93 	struct  key_event *kbtrans_streams_downs;
94 
95 	/* Number of down entries */
96 	int	kbtrans_streams_num_downs_entries; /* entries in downs */
97 
98 	/* Bytes allocated for downs */
99 	uint_t  kbtrans_streams_downs_bytes;
100 
101 	/* Abort state */
102 	enum {
103 		ABORT_NORMAL,
104 		ABORT_ABORT1_RECEIVED,
105 		NEW_ABORT_ABORT1_RECEIVED	/* for new abort key */
106 	}		kbtrans_streams_abort_state;
107 
108 	/* Indicated whether or not abort may be honored */
109 	boolean_t	kbtrans_streams_abortable;
110 
111 	/*
112 	 * During an abort sequence, says which key started the sequence.
113 	 * This is used to support both L1+A and F1+A.
114 	 */
115 	kbtrans_key_t	kbtrans_streams_abort1_key;
116 
117 	/* It is used to support new abort sequence Shift+Pause */
118 	kbtrans_key_t	kbtrans_streams_new_abort1_key;
119 
120 	/* Functions to be called based on the translation type */
121 	struct keyboard_callback *kbtrans_streams_callback;
122 
123 	/* Private structure for the keyboard specific module/driver */
124 	struct kbtrans_hardware *kbtrans_streams_hw;
125 
126 	/* Callbacks into the keyboard specific module/driver */
127 	struct kbtrans_callbacks *kbtrans_streams_hw_callbacks;
128 
129 	/* Keyboard type */
130 	int	kbtrans_streams_id;
131 
132 	/* Buffers to hold characters during the polled mode */
133 	char	*kbtrans_polled_pending_chars;
134 	char	kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1];
135 };
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif /* _KBTRANS_STREAMS_H */
142