xref: /titanic_41/usr/src/uts/common/sys/kbio.h (revision c35aa225b9ae500f1d14f0d39a94f1eb6cda333d)
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
5551573c4Srz201010  * Common Development and Distribution License (the "License").
6551573c4Srz201010  * 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 /*
228ffc942dSrz201010  * 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS4.0 1.23 */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Keyboard related ioctls
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * See sys/kbd.h for TR_NONE (don't translate) and TR_ASCII
417c478bd9Sstevel@tonic-gate  * (translate to ASCII) TR_EVENT (translate to virtual input
427c478bd9Sstevel@tonic-gate  * device codes)
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate #define	KIOC		('k'<<8)
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * For x86, these numbers conflict with KD "Xenix" ioctl numbers, so each
507c478bd9Sstevel@tonic-gate  * conflicting command has been offset by 30.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	KIOCTRANS	(KIOC|30)	/* set keyboard translation */
537c478bd9Sstevel@tonic-gate #define	KIOCGTRANS	(KIOC|35)	/* get keyboard translation */
547c478bd9Sstevel@tonic-gate #define	KIOCTRANSABLE	(KIOC|36) 	/* set keyboard translatability */
557c478bd9Sstevel@tonic-gate #define	KIOCGTRANSABLE	(KIOC|37)	/* get keyboard translatability */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #else	/* __i386 || __i386_COMPAT */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	KIOCTRANS	(KIOC|0)	/* set keyboard translation */
607c478bd9Sstevel@tonic-gate #define	KIOCGTRANS	(KIOC|5)	/* get keyboard translation */
617c478bd9Sstevel@tonic-gate #define	KIOCTRANSABLE	(KIOC|6) 	/* set keyboard translatability */
627c478bd9Sstevel@tonic-gate #define	KIOCGTRANSABLE	(KIOC|7)	/* get keyboard translatability */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #endif	/* __i386 || __i386_COMPAT */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	TR_CANNOT	0	/* Cannot translate keyboard using tables */
687c478bd9Sstevel@tonic-gate #define	TR_CAN		1	/* Can translate keyboard using tables */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Old-style keymap entry, for backwards compatibility only.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate struct	kiockey {
747c478bd9Sstevel@tonic-gate 	int	kio_tablemask;	/* Translation table (one of: 0, CAPSMASK, */
757c478bd9Sstevel@tonic-gate 				/* SHIFTMASK, CTRLMASK, UPMASK, */
767c478bd9Sstevel@tonic-gate 				/* ALTGRAPHMASK, NUMLOCKMASK) */
777c478bd9Sstevel@tonic-gate #define	KIOCABORT1	-1	/* Special "mask": abort1 keystation */
787c478bd9Sstevel@tonic-gate #define	KIOCABORT2	-2	/* Special "mask": abort2 keystation */
797c478bd9Sstevel@tonic-gate #define	KIOCABORT1A	-3	/* Special "mask": alt abort1 keystation */
807c478bd9Sstevel@tonic-gate 	uchar_t	kio_station;	/* Physical keyboard key station (0-127) */
817c478bd9Sstevel@tonic-gate 	uchar_t	kio_entry;	/* Translation table station's entry */
827c478bd9Sstevel@tonic-gate 	char	kio_string[10];	/* Value for STRING entries (null terminated) */
837c478bd9Sstevel@tonic-gate };
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * Set kio_tablemask table's kio_station to kio_entry.
877c478bd9Sstevel@tonic-gate  * Copy kio_string to string table if kio_entry is between STRING and
887c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
917c478bd9Sstevel@tonic-gate #define	KIOCSETKEY	(KIOC|31)	/* avoid conflict with "SETFKEY" */
927c478bd9Sstevel@tonic-gate #else
937c478bd9Sstevel@tonic-gate #define	KIOCSETKEY	(KIOC|1)
947c478bd9Sstevel@tonic-gate #endif
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /*
977c478bd9Sstevel@tonic-gate  * Get kio_tablemask table's kio_station to kio_entry.
987c478bd9Sstevel@tonic-gate  * Get kio_string from string table if kio_entry is between STRING and
997c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
1027c478bd9Sstevel@tonic-gate #define	KIOCGETKEY	(KIOC|32)	/* avoid conflict with "GIO_SCRNMAP" */
1037c478bd9Sstevel@tonic-gate #else
1047c478bd9Sstevel@tonic-gate #define	KIOCGETKEY	(KIOC|2)
1057c478bd9Sstevel@tonic-gate #endif
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * Send the keyboard device a control command.  sys/kbd.h contains
1097c478bd9Sstevel@tonic-gate  * the constants that define the commands.  Normal values are:
1107c478bd9Sstevel@tonic-gate  * KBD_CMD_BELL, KBD_CMD_NOBELL, KBD_CMD_CLICK, KBD_CMD_NOCLICK.
1117c478bd9Sstevel@tonic-gate  * Inappropriate commands for particular keyboard types are ignored.
1127c478bd9Sstevel@tonic-gate  *
1137c478bd9Sstevel@tonic-gate  * Since there is no reliable way to get the state of the bell or click
1147c478bd9Sstevel@tonic-gate  * or LED (because we can't query the kdb, and also one could do writes
1157c478bd9Sstevel@tonic-gate  * to the appropriate serial driver--thus going around this ioctl)
1167c478bd9Sstevel@tonic-gate  * we don't provide an equivalent state querying ioctl.
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define	KIOCCMD		(KIOC|8)
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate  * Get keyboard type.  Return values are one of KB_* from sys/kbd.h,
1227c478bd9Sstevel@tonic-gate  * e.g., KB_KLUNK, KB_VT100, KB_SUN2, KB_SUN3, KB_SUN4, KB_ASCII.
1237c478bd9Sstevel@tonic-gate  * -1 means that the type is not known.
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate #define	KIOCTYPE	(KIOC|9)	/* get keyboard type */
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * Set flag indicating whether keystrokes get routed to /dev/console.
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate #define	KIOCSDIRECT	(KIOC|10)
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  * Get flag indicating whether keystrokes get routed to /dev/console.
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
1367c478bd9Sstevel@tonic-gate #define	KIOCGDIRECT	(KIOC|41)	/* avoid conflict with "GIO_STRMAP" */
1377c478bd9Sstevel@tonic-gate #else
1387c478bd9Sstevel@tonic-gate #define	KIOCGDIRECT	(KIOC|11)
1397c478bd9Sstevel@tonic-gate #endif
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /*
1427c478bd9Sstevel@tonic-gate  * New-style key map entry.
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate struct kiockeymap {
1457c478bd9Sstevel@tonic-gate 	int	kio_tablemask;	/* Translation table (one of: 0, CAPSMASK, */
1467c478bd9Sstevel@tonic-gate 				/*  SHIFTMASK, CTRLMASK, UPMASK, */
1477c478bd9Sstevel@tonic-gate 				/*  ALTGRAPHMASK) */
1487c478bd9Sstevel@tonic-gate 	uchar_t	kio_station;	/* Physical keyboard key station (0-127) */
1497c478bd9Sstevel@tonic-gate 	ushort_t kio_entry;	/* Translation table station's entry */
1507c478bd9Sstevel@tonic-gate 	char	kio_string[10];	/* Value for STRING entries (null terminated) */
1517c478bd9Sstevel@tonic-gate };
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate  * Set kio_tablemask table's kio_station to kio_entry.
1557c478bd9Sstevel@tonic-gate  * Copy kio_string to string table if kio_entry is between STRING and
1567c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__i386_COMPAT)
1597c478bd9Sstevel@tonic-gate #define	KIOCSKEY	(KIOC|42)	/* avoid conflict with "PIO_STRMAP" */
1607c478bd9Sstevel@tonic-gate #else
1617c478bd9Sstevel@tonic-gate #define	KIOCSKEY	(KIOC|12)
1627c478bd9Sstevel@tonic-gate #endif
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * Get kio_tablemask table's kio_station to kio_entry.
1667c478bd9Sstevel@tonic-gate  * Get kio_string from string table if kio_entry is between STRING and
1677c478bd9Sstevel@tonic-gate  * STRING+15.  EINVAL is possible if there are invalid arguments.
1687c478bd9Sstevel@tonic-gate  */
1697c478bd9Sstevel@tonic-gate #define	KIOCGKEY	(KIOC|13)
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * Set and get LED state.
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate #define	KIOCSLED	(KIOC|14)
1757c478bd9Sstevel@tonic-gate #define	KIOCGLED	(KIOC|15)
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  * Set and get compatibility mode.
1797c478bd9Sstevel@tonic-gate  */
1807c478bd9Sstevel@tonic-gate #define	KIOCSCOMPAT	(KIOC|16)
1817c478bd9Sstevel@tonic-gate #define	KIOCGCOMPAT	(KIOC|17)
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * Set and get keyboard layout.
1857c478bd9Sstevel@tonic-gate  */
1867c478bd9Sstevel@tonic-gate #define	KIOCSLAYOUT	(KIOC|19)
1877c478bd9Sstevel@tonic-gate #define	KIOCLAYOUT	(KIOC|20)
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate /*
1907c478bd9Sstevel@tonic-gate  * KIOCSKABORTEN:
1917c478bd9Sstevel@tonic-gate  *
1927c478bd9Sstevel@tonic-gate  * Enable/Disable/Alternate Keyboard abort effect (Stop/A, Break or other seq).
1937c478bd9Sstevel@tonic-gate  * The argument is a pointer to an integer.  If the integer is zero,
1947c478bd9Sstevel@tonic-gate  * keyboard abort is disabled, one will enable keyboard abort (hardware BREAK
1957c478bd9Sstevel@tonic-gate  * signal), two will revert to the Alternative Break Sequence.  NB: This ioctl
1967c478bd9Sstevel@tonic-gate  * requires root credentials and applies to serial input devices and keyboards.
1977c478bd9Sstevel@tonic-gate  * When the Alternative Break Sequence is enabled it applies to serial input
1987c478bd9Sstevel@tonic-gate  * devices ONLY.
1997c478bd9Sstevel@tonic-gate  */
2007c478bd9Sstevel@tonic-gate #define	KIOCSKABORTEN	(KIOC|21)
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate #define	KIOCABORTDISABLE	0	/* Disable Aborts  */
2037c478bd9Sstevel@tonic-gate #define	KIOCABORTENABLE		1	/* Enable BREAK Signal Aborts  */
2047c478bd9Sstevel@tonic-gate #define	KIOCABORTALTERNATE	2	/* Enable Alternative Aborts   */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  * Get/Set Keyboard autorepeat delay/rate.
2087c478bd9Sstevel@tonic-gate  * Use millisecond as unit used by the user-level application
2097c478bd9Sstevel@tonic-gate  */
2107c478bd9Sstevel@tonic-gate #define	KIOCGRPTDELAY	(KIOC|22)
2117c478bd9Sstevel@tonic-gate #define	KIOCSRPTDELAY	(KIOC|23)
2127c478bd9Sstevel@tonic-gate #define	KIOCGRPTRATE	(KIOC|24)
2137c478bd9Sstevel@tonic-gate #define	KIOCSRPTRATE	(KIOC|25)
2147c478bd9Sstevel@tonic-gate 
2158ffc942dSrz201010 /* Set keyboard and console beeper frequencies */
2168ffc942dSrz201010 #define	KIOCSETFREQ	(KIOC|26)
2178ffc942dSrz201010 
2188ffc942dSrz201010 /* Beeper type for struct freq_request */
2198ffc942dSrz201010 enum fr_beep_type {CONSOLE_BEEP = 1, KBD_BEEP = 2};
2208ffc942dSrz201010 
2218ffc942dSrz201010 /* Frequency request structure */
2228ffc942dSrz201010 struct freq_request {
2238ffc942dSrz201010 	enum fr_beep_type type;	/* Beeper type */
2248ffc942dSrz201010 	int16_t	freq;		/* Frequency */
2258ffc942dSrz201010 };
2268ffc942dSrz201010 
227*c35aa225Smarx #define	KIOCMKTONE	(KIOC|27)
228*c35aa225Smarx 
229*c35aa225Smarx /*
230*c35aa225Smarx  * For historical reasons, the frequency argument to KIOCMKTONE is
231*c35aa225Smarx  * in i8254 clock cycles.
232*c35aa225Smarx  */
233*c35aa225Smarx 
234*c35aa225Smarx #define	PIT_HZ		1193182		/* 8254's cycles per second */
235*c35aa225Smarx 
236*c35aa225Smarx #define	KDMKTONE	KIOCMKTONE
237*c35aa225Smarx 
2387c478bd9Sstevel@tonic-gate /* Used to control the AutoRepeat Min-delay and Min-Rate */
239551573c4Srz201010 #define	KIOCRPTDELAY_MIN	(100)
2404470e687Syx209491 #define	KIOCRPTRATE_MIN		(1)
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2437c478bd9Sstevel@tonic-gate }
2447c478bd9Sstevel@tonic-gate #endif
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate #endif	/* _SYS_KBIO_H */
247