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