xref: /titanic_41/usr/src/uts/common/sys/kbio.h (revision 2278144afd2005b3eabcfd9bc412fe5ceb78749d)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_KBIO_H
27 #define	_SYS_KBIO_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS4.0 1.23 */
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Keyboard related ioctls
37  */
38 
39 /*
40  * See sys/kbd.h for TR_NONE (don't translate) and TR_ASCII
41  * (translate to ASCII) TR_EVENT (translate to virtual input
42  * device codes)
43  */
44 #define	KIOC		('k'<<8)
45 
46 #if defined(__i386) || defined(__i386_COMPAT)
47 
48 /*
49  * For x86, these numbers conflict with KD "Xenix" ioctl numbers, so each
50  * conflicting command has been offset by 30.
51  */
52 #define	KIOCTRANS	(KIOC|30)	/* set keyboard translation */
53 #define	KIOCGTRANS	(KIOC|35)	/* get keyboard translation */
54 #define	KIOCTRANSABLE	(KIOC|36) 	/* set keyboard translatability */
55 #define	KIOCGTRANSABLE	(KIOC|37)	/* get keyboard translatability */
56 
57 #else	/* __i386 || __i386_COMPAT */
58 
59 #define	KIOCTRANS	(KIOC|0)	/* set keyboard translation */
60 #define	KIOCGTRANS	(KIOC|5)	/* get keyboard translation */
61 #define	KIOCTRANSABLE	(KIOC|6) 	/* set keyboard translatability */
62 #define	KIOCGTRANSABLE	(KIOC|7)	/* get keyboard translatability */
63 
64 #endif	/* __i386 || __i386_COMPAT */
65 
66 
67 #define	TR_CANNOT	0	/* Cannot translate keyboard using tables */
68 #define	TR_CAN		1	/* Can translate keyboard using tables */
69 
70 /*
71  * Old-style keymap entry, for backwards compatibility only.
72  */
73 struct	kiockey {
74 	int	kio_tablemask;	/* Translation table (one of: 0, CAPSMASK, */
75 				/* SHIFTMASK, CTRLMASK, UPMASK, */
76 				/* ALTGRAPHMASK, NUMLOCKMASK) */
77 #define	KIOCABORT1	-1	/* Special "mask": abort1 keystation */
78 #define	KIOCABORT2	-2	/* Special "mask": abort2 keystation */
79 #define	KIOCABORT1A	-3	/* Special "mask": alt abort1 keystation */
80 	uchar_t	kio_station;	/* Physical keyboard key station (0-127) */
81 	uchar_t	kio_entry;	/* Translation table station's entry */
82 	char	kio_string[10];	/* Value for STRING entries (null terminated) */
83 };
84 
85 /*
86  * Set kio_tablemask table's kio_station to kio_entry.
87  * Copy kio_string to string table if kio_entry is between STRING and
88  * STRING+15.  EINVAL is possible if there are invalid arguments.
89  */
90 #if defined(__i386) || defined(__i386_COMPAT)
91 #define	KIOCSETKEY	(KIOC|31)	/* avoid conflict with "SETFKEY" */
92 #else
93 #define	KIOCSETKEY	(KIOC|1)
94 #endif
95 
96 /*
97  * Get kio_tablemask table's kio_station to kio_entry.
98  * Get kio_string from string table if kio_entry is between STRING and
99  * STRING+15.  EINVAL is possible if there are invalid arguments.
100  */
101 #if defined(__i386) || defined(__i386_COMPAT)
102 #define	KIOCGETKEY	(KIOC|32)	/* avoid conflict with "GIO_SCRNMAP" */
103 #else
104 #define	KIOCGETKEY	(KIOC|2)
105 #endif
106 
107 /*
108  * Send the keyboard device a control command.  sys/kbd.h contains
109  * the constants that define the commands.  Normal values are:
110  * KBD_CMD_BELL, KBD_CMD_NOBELL, KBD_CMD_CLICK, KBD_CMD_NOCLICK.
111  * Inappropriate commands for particular keyboard types are ignored.
112  *
113  * Since there is no reliable way to get the state of the bell or click
114  * or LED (because we can't query the kdb, and also one could do writes
115  * to the appropriate serial driver--thus going around this ioctl)
116  * we don't provide an equivalent state querying ioctl.
117  */
118 #define	KIOCCMD		(KIOC|8)
119 
120 /*
121  * Get keyboard type.  Return values are one of KB_* from sys/kbd.h,
122  * e.g., KB_KLUNK, KB_VT100, KB_SUN2, KB_SUN3, KB_SUN4, KB_ASCII.
123  * -1 means that the type is not known.
124  */
125 #define	KIOCTYPE	(KIOC|9)	/* get keyboard type */
126 
127 /*
128  * Set flag indicating whether keystrokes get routed to /dev/console.
129  */
130 #define	KIOCSDIRECT	(KIOC|10)
131 
132 /*
133  * Get flag indicating whether keystrokes get routed to /dev/console.
134  */
135 #if defined(__i386) || defined(__i386_COMPAT)
136 #define	KIOCGDIRECT	(KIOC|41)	/* avoid conflict with "GIO_STRMAP" */
137 #else
138 #define	KIOCGDIRECT	(KIOC|11)
139 #endif
140 
141 /*
142  * New-style key map entry.
143  */
144 struct kiockeymap {
145 	int	kio_tablemask;	/* Translation table (one of: 0, CAPSMASK, */
146 				/*  SHIFTMASK, CTRLMASK, UPMASK, */
147 				/*  ALTGRAPHMASK) */
148 	uchar_t	kio_station;	/* Physical keyboard key station (0-127) */
149 	ushort_t kio_entry;	/* Translation table station's entry */
150 	char	kio_string[10];	/* Value for STRING entries (null terminated) */
151 };
152 
153 /*
154  * Set kio_tablemask table's kio_station to kio_entry.
155  * Copy kio_string to string table if kio_entry is between STRING and
156  * STRING+15.  EINVAL is possible if there are invalid arguments.
157  */
158 #if defined(__i386) || defined(__i386_COMPAT)
159 #define	KIOCSKEY	(KIOC|42)	/* avoid conflict with "PIO_STRMAP" */
160 #else
161 #define	KIOCSKEY	(KIOC|12)
162 #endif
163 
164 /*
165  * Get kio_tablemask table's kio_station to kio_entry.
166  * Get kio_string from string table if kio_entry is between STRING and
167  * STRING+15.  EINVAL is possible if there are invalid arguments.
168  */
169 #define	KIOCGKEY	(KIOC|13)
170 
171 /*
172  * Set and get LED state.
173  */
174 #define	KIOCSLED	(KIOC|14)
175 #define	KIOCGLED	(KIOC|15)
176 
177 /*
178  * Set and get compatibility mode.
179  */
180 #define	KIOCSCOMPAT	(KIOC|16)
181 #define	KIOCGCOMPAT	(KIOC|17)
182 
183 /*
184  * Set and get keyboard layout.
185  */
186 #define	KIOCSLAYOUT	(KIOC|19)
187 #define	KIOCLAYOUT	(KIOC|20)
188 
189 /*
190  * KIOCSKABORTEN:
191  *
192  * Enable/Disable/Alternate Keyboard abort effect (Stop/A, Break or other seq).
193  * The argument is a pointer to an integer.  If the integer is zero,
194  * keyboard abort is disabled, one will enable keyboard abort (hardware BREAK
195  * signal), two will revert to the Alternative Break Sequence.  NB: This ioctl
196  * requires root credentials and applies to serial input devices and keyboards.
197  * When the Alternative Break Sequence is enabled it applies to serial input
198  * devices ONLY.
199  */
200 #define	KIOCSKABORTEN	(KIOC|21)
201 
202 #define	KIOCABORTDISABLE	0	/* Disable Aborts  */
203 #define	KIOCABORTENABLE		1	/* Enable BREAK Signal Aborts  */
204 #define	KIOCABORTALTERNATE	2	/* Enable Alternative Aborts   */
205 
206 /*
207  * Get/Set Keyboard autorepeat delay/rate.
208  * Use millisecond as unit used by the user-level application
209  */
210 #define	KIOCGRPTDELAY	(KIOC|22)
211 #define	KIOCSRPTDELAY	(KIOC|23)
212 #define	KIOCGRPTRATE	(KIOC|24)
213 #define	KIOCSRPTRATE	(KIOC|25)
214 
215 /* Used to control the AutoRepeat Min-delay and Min-Rate */
216 #define	KIOCRPTDELAY_MIN	(100)
217 #define	KIOCRPTRATE_MIN		(30)
218 
219 #ifdef	__cplusplus
220 }
221 #endif
222 
223 #endif	/* _SYS_KBIO_H */
224