summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/kbtrans/kbtrans_streams.h
blob: 36303529d37dd53ac353d6e44a8363e7cc081671 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _KBTRANS_STREAMS_H
#define	_KBTRANS_STREAMS_H

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/stream.h>

#define	KBTRANS_POLLED_BUF_SIZE	30

/* definitions for various state machines */
#define	KBTRANS_STREAMS_OPEN	0x00000001 /* keyboard is open for business */

#define	NO_HARD_RESET	0	/* resets only state struct */
#define	HARD_RESET	1	/* resets keyboard and state structure */

/*
 * structure to keep track of currently pressed keys when in
 * TR_UNTRANS_EVENT mode
 */
typedef struct  key_event {
	uchar_t  key_station;   /* Physical key station associated with event */
	Firm_event event;	/* Event that sent out on down */
} Key_event;


/* state structure for kbtrans_streams */
struct  kbtrans {
	struct kbtrans_lower	kbtrans_lower;	/* actual translation state */

	/* Read and write queues */
	queue_t 	*kbtrans_streams_readq;
	queue_t 	*kbtrans_streams_writeq;

	/* Pending "ioctl" awaiting buffer */
	mblk_t  	*kbtrans_streams_iocpending;

	/* Number of times the keyboard overflowed input */
	int		kbtrans_overflow_cnt;

	/* random flags */
	int		kbtrans_streams_flags;

	/* id from qbufcall on allocb failure */
	bufcall_id_t	kbtrans_streams_bufcallid;

	timeout_id_t	kbtrans_streams_rptid; /* timeout id for repeat */

	int	kbtrans_streams_iocerror;	/* error return from "ioctl" */
	int	kbtrans_streams_translate_mode;	/* Translate keycodes? */
	int	kbtrans_streams_translatable;  	/* Keyboard is translatable? */

	/* Vuid_id_addrs for various events */
	struct {
	    short	ascii;
	    short	top;
	    short	vkey;
	}	kbtrans_streams_vuid_addr;

	/*
	 * Table of key stations currently down that have
	 * have firm events that need to be matched with up transitions
	 * when translation mode is TR_*EVENT
	 */
	struct  key_event *kbtrans_streams_downs;

	/* Number of down entries */
	int	kbtrans_streams_num_downs_entries; /* entries in downs */

	/* Bytes allocated for downs */
	uint_t  kbtrans_streams_downs_bytes;

	/* Abort state */
	enum {
		ABORT_NORMAL,
		ABORT_ABORT1_RECEIVED,
		NEW_ABORT_ABORT1_RECEIVED	/* for new abort key */
	}		kbtrans_streams_abort_state;

	/* Indicated whether or not abort may be honored */
	boolean_t	kbtrans_streams_abortable;

	/*
	 * During an abort sequence, says which key started the sequence.
	 * This is used to support both L1+A and F1+A.
	 */
	kbtrans_key_t	kbtrans_streams_abort1_key;

	/* It is used to support new abort sequence Shift+Pause */
	kbtrans_key_t	kbtrans_streams_new_abort1_key;

	/* Functions to be called based on the translation type */
	struct keyboard_callback *kbtrans_streams_callback;

	/* Private structure for the keyboard specific module/driver */
	struct kbtrans_hardware *kbtrans_streams_hw;

	/* Callbacks into the keyboard specific module/driver */
	struct kbtrans_callbacks *kbtrans_streams_hw_callbacks;

	/* Keyboard type */
	int	kbtrans_streams_id;

	/* Buffers to hold characters during the polled mode */
	char	*kbtrans_polled_pending_chars;
	char	kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1];

	/* vt switch key sequence state */
	enum {
		VT_SWITCH_KEY_NONE = 0,
		VT_SWITCH_KEY_ALT,	/* left Alt key is pressed */
		VT_SWITCH_KEY_ALTGR	/* right Alt key is pressed */
	}		vt_switch_keystate;

	kcondvar_t progressbar_key_abort_cv;
	kmutex_t progressbar_key_abort_lock;
	int progressbar_key_abort_flag;
	kt_did_t progressbar_key_abort_t_did;
};

#ifdef __cplusplus
}
#endif

#endif /* _KBTRANS_STREAMS_H */