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