xref: /illumos-gate/usr/src/uts/common/sys/kbio.h (revision c0423dd8)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5551573c4Srz  * Common Development and Distribution License (the "License").
6551573c4Srz  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
228ffc942dSrz  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_KBIO_H
277c478bd9Sstevel@tonic-gate #define	_SYS_KBIO_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * Keyboard related ioctls
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * See sys/kbd.h for TR_NONE (don't translate) and TR_ASCII
397c478bd9Sstevel@tonic-gate  * (translate to ASCII) TR_EVENT (translate to virtual input
407c478bd9Sstevel@tonic-gate  * device codes)
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate #define	KIOC		('k'<<8)
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * For x86, these numbers conflict with KD "Xenix" ioctl numbers, so each
487c478bd9Sstevel@tonic-gate  * conflicting command has been offset by 30.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #define	KIOCTRANS	(KIOC|30)	/* set keyboard translation */
517c478bd9Sstevel@tonic-gate #define	KIOCGTRANS	(KIOC|35)	/* get keyboard translation */
52*c0423dd8SToomas Soome #define	KIOCTRANSABLE	(KIOC|36)	/* set keyboard translatability */
537c478bd9Sstevel@tonic-gate #define	KIOCGTRANSABLE	(KIOC|37)	/* get keyboard translatability */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #else	/* __i386 || __i386_COMPAT */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #define	KIOCTRANS	(KIOC|0)	/* set keyboard translation */
587c478bd9Sstevel@tonic-gate #define	KIOCGTRANS	(KIOC|5)	/* get keyboard translation */
59*c0423dd8SToomas Soome #define	KIOCTRANSABLE	(KIOC|6)	/* set keyboard translatability */
607c478bd9Sstevel@tonic-gate #define	KIOCGTRANSABLE	(KIOC|7)	/* get keyboard translatability */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #endif	/* __i386 || __i386_COMPAT */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	TR_CANNOT	0	/* Cannot translate keyboard using tables */
667c478bd9Sstevel@tonic-gate #define	TR_CAN		1	/* Can translate keyboard using tables */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * Old-style keymap entry, for backwards compatibility only.
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate struct	kiockey {
727c478bd9Sstevel@tonic-gate 	int	kio_tablemask;	/* Translation table (one of: 0, CAPSMASK, */
737c478bd9Sstevel@tonic-gate 				/* SHIFTMASK, CTRLMASK, UPMASK, */
747c478bd9Sstevel@tonic-gate 				/* ALTGRAPHMASK, NUMLOCKMASK) */
757c478bd9Sstevel@tonic-gate #define	KIOCABORT1	-1	/* Special "mask": abort1 keystation */
767c478bd9Sstevel@tonic-gate #define	KIOCABORT2	-2	/* Special "mask": abort2 keystation */
777c478bd9Sstevel@tonic-gate #define	KIOCABORT1A	-3	/* Special "mask": alt abort1 keystation */
787c478bd9Sstevel@tonic-gate 	uchar_t	kio_station;	/* Physical keyboard key station (0-127) */
797c478bd9Sstevel@tonic-gate 	uchar_t	kio_entry;	/* Translation table station's entry */
807c478bd9Sstevel@tonic-gate 	char	kio_string[10];	/* Value for STRING entries (null terminated) */
817c478bd9Sstevel@tonic-gate };
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * Set kio_tablemask table's kio_station to kio_entry.
857c478bd9Sstevel@tonic-gate  * Copy kio_string to string table if kio_entry is between STRING and
867c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
897c478bd9Sstevel@tonic-gate #define	KIOCSETKEY	(KIOC|31)	/* avoid conflict with "SETFKEY" */
907c478bd9Sstevel@tonic-gate #else
917c478bd9Sstevel@tonic-gate #define	KIOCSETKEY	(KIOC|1)
927c478bd9Sstevel@tonic-gate #endif
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Get kio_tablemask table's kio_station to kio_entry.
967c478bd9Sstevel@tonic-gate  * Get kio_string from string table if kio_entry is between STRING and
977c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
987c478bd9Sstevel@tonic-gate  */
997c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
1007c478bd9Sstevel@tonic-gate #define	KIOCGETKEY	(KIOC|32)	/* avoid conflict with "GIO_SCRNMAP" */
1017c478bd9Sstevel@tonic-gate #else
1027c478bd9Sstevel@tonic-gate #define	KIOCGETKEY	(KIOC|2)
1037c478bd9Sstevel@tonic-gate #endif
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * Send the keyboard device a control command.  sys/kbd.h contains
1077c478bd9Sstevel@tonic-gate  * the constants that define the commands.  Normal values are:
1087c478bd9Sstevel@tonic-gate  * KBD_CMD_BELL, KBD_CMD_NOBELL, KBD_CMD_CLICK, KBD_CMD_NOCLICK.
1097c478bd9Sstevel@tonic-gate  * Inappropriate commands for particular keyboard types are ignored.
1107c478bd9Sstevel@tonic-gate  *
1117c478bd9Sstevel@tonic-gate  * Since there is no reliable way to get the state of the bell or click
1127c478bd9Sstevel@tonic-gate  * or LED (because we can't query the kdb, and also one could do writes
1137c478bd9Sstevel@tonic-gate  * to the appropriate serial driver--thus going around this ioctl)
1147c478bd9Sstevel@tonic-gate  * we don't provide an equivalent state querying ioctl.
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate #define	KIOCCMD		(KIOC|8)
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /*
1197c478bd9Sstevel@tonic-gate  * Get keyboard type.  Return values are one of KB_* from sys/kbd.h,
1207c478bd9Sstevel@tonic-gate  * e.g., KB_KLUNK, KB_VT100, KB_SUN2, KB_SUN3, KB_SUN4, KB_ASCII.
1217c478bd9Sstevel@tonic-gate  * -1 means that the type is not known.
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate #define	KIOCTYPE	(KIOC|9)	/* get keyboard type */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /*
1267c478bd9Sstevel@tonic-gate  * Set flag indicating whether keystrokes get routed to /dev/console.
1277c478bd9Sstevel@tonic-gate  */
1287c478bd9Sstevel@tonic-gate #define	KIOCSDIRECT	(KIOC|10)
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * Get flag indicating whether keystrokes get routed to /dev/console.
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
1347c478bd9Sstevel@tonic-gate #define	KIOCGDIRECT	(KIOC|41)	/* avoid conflict with "GIO_STRMAP" */
1357c478bd9Sstevel@tonic-gate #else
1367c478bd9Sstevel@tonic-gate #define	KIOCGDIRECT	(KIOC|11)
1377c478bd9Sstevel@tonic-gate #endif
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * New-style key map entry.
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate struct kiockeymap {
1437c478bd9Sstevel@tonic-gate 	int	kio_tablemask;	/* Translation table (one of: 0, CAPSMASK, */
1447c478bd9Sstevel@tonic-gate 				/*  SHIFTMASK, CTRLMASK, UPMASK, */
1457c478bd9Sstevel@tonic-gate 				/*  ALTGRAPHMASK) */
1467c478bd9Sstevel@tonic-gate 	uchar_t	kio_station;	/* Physical keyboard key station (0-127) */
147adc2b73dSToomas Soome 	unsigned kio_entry;	/* Translation table station's entry */
1487c478bd9Sstevel@tonic-gate 	char	kio_string[10];	/* Value for STRING entries (null terminated) */
1497c478bd9Sstevel@tonic-gate };
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * Set kio_tablemask table's kio_station to kio_entry.
1537c478bd9Sstevel@tonic-gate  * Copy kio_string to string table if kio_entry is between STRING and
1547c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
1577c478bd9Sstevel@tonic-gate #define	KIOCSKEY	(KIOC|42)	/* avoid conflict with "PIO_STRMAP" */
1587c478bd9Sstevel@tonic-gate #else
1597c478bd9Sstevel@tonic-gate #define	KIOCSKEY	(KIOC|12)
1607c478bd9Sstevel@tonic-gate #endif
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * Get kio_tablemask table's kio_station to kio_entry.
1647c478bd9Sstevel@tonic-gate  * Get kio_string from string table if kio_entry is between STRING and
1657c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate #define	KIOCGKEY	(KIOC|13)
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * Set and get LED state.
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate #define	KIOCSLED	(KIOC|14)
1737c478bd9Sstevel@tonic-gate #define	KIOCGLED	(KIOC|15)
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate /*
1767c478bd9Sstevel@tonic-gate  * Set and get compatibility mode.
1777c478bd9Sstevel@tonic-gate  */
1787c478bd9Sstevel@tonic-gate #define	KIOCSCOMPAT	(KIOC|16)
1797c478bd9Sstevel@tonic-gate #define	KIOCGCOMPAT	(KIOC|17)
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate /*
1827c478bd9Sstevel@tonic-gate  * Set and get keyboard layout.
1837c478bd9Sstevel@tonic-gate  */
1847c478bd9Sstevel@tonic-gate #define	KIOCSLAYOUT	(KIOC|19)
1857c478bd9Sstevel@tonic-gate #define	KIOCLAYOUT	(KIOC|20)
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate  * KIOCSKABORTEN:
1897c478bd9Sstevel@tonic-gate  *
1907c478bd9Sstevel@tonic-gate  * Enable/Disable/Alternate Keyboard abort effect (Stop/A, Break or other seq).
1917c478bd9Sstevel@tonic-gate  * The argument is a pointer to an integer.  If the integer is zero,
1927c478bd9Sstevel@tonic-gate  * keyboard abort is disabled, one will enable keyboard abort (hardware BREAK
1937c478bd9Sstevel@tonic-gate  * signal), two will revert to the Alternative Break Sequence.  NB: This ioctl
1947c478bd9Sstevel@tonic-gate  * requires root credentials and applies to serial input devices and keyboards.
1957c478bd9Sstevel@tonic-gate  * When the Alternative Break Sequence is enabled it applies to serial input
1967c478bd9Sstevel@tonic-gate  * devices ONLY.
1977c478bd9Sstevel@tonic-gate  */
1987c478bd9Sstevel@tonic-gate #define	KIOCSKABORTEN	(KIOC|21)
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate #define	KIOCABORTDISABLE	0	/* Disable Aborts  */
2017c478bd9Sstevel@tonic-gate #define	KIOCABORTENABLE		1	/* Enable BREAK Signal Aborts  */
2027c478bd9Sstevel@tonic-gate #define	KIOCABORTALTERNATE	2	/* Enable Alternative Aborts   */
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  * Get/Set Keyboard autorepeat delay/rate.
2067c478bd9Sstevel@tonic-gate  * Use millisecond as unit used by the user-level application
2077c478bd9Sstevel@tonic-gate  */
2087c478bd9Sstevel@tonic-gate #define	KIOCGRPTDELAY	(KIOC|22)
2097c478bd9Sstevel@tonic-gate #define	KIOCSRPTDELAY	(KIOC|23)
2107c478bd9Sstevel@tonic-gate #define	KIOCGRPTRATE	(KIOC|24)
2117c478bd9Sstevel@tonic-gate #define	KIOCSRPTRATE	(KIOC|25)
2127c478bd9Sstevel@tonic-gate 
2138ffc942dSrz /* Set keyboard and console beeper frequencies */
2148ffc942dSrz #define	KIOCSETFREQ	(KIOC|26)
2158ffc942dSrz 
2168ffc942dSrz /* Beeper type for struct freq_request */
2178ffc942dSrz enum fr_beep_type {CONSOLE_BEEP = 1, KBD_BEEP = 2};
2188ffc942dSrz 
2198ffc942dSrz /* Frequency request structure */
2208ffc942dSrz struct freq_request {
2218ffc942dSrz 	enum fr_beep_type type;	/* Beeper type */
2228ffc942dSrz 	int16_t	freq;		/* Frequency */
2238ffc942dSrz };
2248ffc942dSrz 
225c35aa225Smarx #define	KIOCMKTONE	(KIOC|27)
226c35aa225Smarx 
227c35aa225Smarx /*
228c35aa225Smarx  * For historical reasons, the frequency argument to KIOCMKTONE is
229c35aa225Smarx  * in i8254 clock cycles.
230c35aa225Smarx  */
231c35aa225Smarx 
232c35aa225Smarx #define	PIT_HZ		1193182		/* 8254's cycles per second */
233c35aa225Smarx 
234c35aa225Smarx #define	KDMKTONE	KIOCMKTONE
235c35aa225Smarx 
2367c478bd9Sstevel@tonic-gate /* Used to control the AutoRepeat Min-delay and Min-Rate */
237551573c4Srz #define	KIOCRPTDELAY_MIN	(100)
2384470e687Syx #define	KIOCRPTRATE_MIN		(1)
2397c478bd9Sstevel@tonic-gate 
240*c0423dd8SToomas Soome /*
241*c0423dd8SToomas Soome  * Get/Set Keyboard autorepeat count.
242*c0423dd8SToomas Soome  */
243*c0423dd8SToomas Soome #define	KIOCGRPTCOUNT	(KIOC|28)
244*c0423dd8SToomas Soome #define	KIOCSRPTCOUNT	(KIOC|29)
245*c0423dd8SToomas Soome 
2467c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2477c478bd9Sstevel@tonic-gate }
2487c478bd9Sstevel@tonic-gate #endif
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate #endif	/* _SYS_KBIO_H */
251