Virtio_Balloon implementation for DragonFly
[dragonfly.git] / sys / sys / kbio.h
1 /*-
2  * $FreeBSD: src/sys/sys/kbio.h,v 1.5.2.1 2000/10/29 16:59:32 dwmalone Exp $
3  */
4
5 #ifndef _SYS_KBIO_H_
6 #define _SYS_KBIO_H_
7
8 #ifndef _SYS_TYPES_H_
9 #include <sys/types.h>
10 #endif
11 #ifndef _SYS_IOCCOM_H_
12 #include <sys/ioccom.h>
13 #endif
14
15 /* get/set keyboard I/O mode */
16 #define K_RAW           0               /* keyboard returns scancodes   */
17 #define K_XLATE         1               /* keyboard returns ascii       */
18 #define K_CODE          2               /* keyboard returns keycodes    */
19 #define KDGKBMODE       _IOR('K', 6, int)
20 #define KDSKBMODE       _IO('K', 7 /*, int */)
21
22 /* make tone */
23 #define KDMKTONE        _IO('K', 8 /*, int */)
24
25 /* see console.h for the definitions of the following ioctls */
26 #if 0 /* notdef */
27 #define KDGETMODE       _IOR('K', 9, int)
28 #define KDSETMODE       _IO('K', 10 /*, int */)
29 #define KDSBORDER       _IO('K', 13 /*, int */)
30 #endif
31
32 /* get/set keyboard lock state */
33 #define CLKED           1               /* Caps locked                  */
34 #define NLKED           2               /* Num locked                   */
35 #define SLKED           4               /* Scroll locked                */
36 #define ALKED           8               /* AltGr locked                 */
37 #define LOCK_MASK       (CLKED | NLKED | SLKED | ALKED)
38 #define KDGKBSTATE      _IOR('K', 19, int)
39 #define KDSKBSTATE      _IO('K', 20 /*, int */)
40
41 /* enable/disable I/O access */
42 #define KDENABIO        _IO('K', 60)
43 #define KDDISABIO       _IO('K', 61)
44
45 /* make sound */
46 #define KIOCSOUND       _IO('K', 63 /*, int */)
47
48 /* get keyboard model */
49 #define KB_OTHER        0               /* keyboard not known           */
50 #define KB_84           1               /* 'old' 84 key AT-keyboard     */
51 #define KB_101          2               /* MF-101 or MF-102 keyboard    */
52 #define KDGKBTYPE       _IOR('K', 64, int)
53
54 /* get/set keyboard LED state */
55 #define LED_CAP         1               /* Caps lock LED                */
56 #define LED_NUM         2               /* Num lock LED                 */
57 #define LED_SCR         4               /* Scroll lock LED              */
58 #define LED_MASK        (LED_CAP | LED_NUM | LED_SCR)
59 #define KDGETLED        _IOR('K', 65, int)
60 #define KDSETLED        _IO('K', 66 /*, int */)
61
62 #if 0 /* deprecated ioctl */
63 /* set keyboard repeat rate (obsolete, use KDSETREPEAT below) */
64 #define KDSETRAD        _IO('K', 67 /*, int */)
65 #endif
66
67 /* see console.h for the definition of the following ioctl */
68 #if 0 /* notdef */
69 #define KDRASTER        _IOW('K', 100, scr_size_t)
70 #endif
71
72 /* get keyboard information */
73 struct keyboard_info {
74         int             kb_index;       /* kbdio index#                 */
75         char            kb_name[16];    /* driver name                  */
76         int             kb_unit;        /* unit#                        */
77         int             kb_type;        /* KB_84, KB_101, KB_OTHER,...  */
78         int             kb_config;      /* device configuration flags   */
79         int             kb_flags;       /* internal flags               */
80 };
81 typedef struct keyboard_info keyboard_info_t;
82 #define KBADDKBD        _IOW('K', 68, keyboard_info_t)  /* add keyboard */
83 #define KBRELKBD        _IOW('K', 69, keyboard_info_t)  /* release keyboard */
84 #define KDGKBINFO       _IOR('K', 101, keyboard_info_t)
85
86 /* set/get keyboard repeat rate (new interface) */
87 struct keyboard_repeat {
88         int             kb_repeat[2];
89 };
90 typedef struct keyboard_repeat keyboard_repeat_t;
91 #define KDSETREPEAT     _IOW('K', 102, keyboard_repeat_t)
92 #define KDGETREPEAT     _IOR('K', 103, keyboard_repeat_t)
93
94 /* get/set key map/accent map/function key strings */
95
96 #define NUM_KEYS        256             /* number of keys in table      */
97 #define NUM_STATES      8               /* states per key               */
98 #define ALTGR_OFFSET    128             /* offset for altlock keys      */
99
100 #define NUM_DEADKEYS    15              /* number of accent keys        */
101 #define NUM_ACCENTCHARS 52              /* max number of accent chars   */
102
103 #define NUM_FKEYS       96              /* max number of function keys  */
104 #define MAXFK           16              /* max length of a function key str */
105
106 #ifndef _KEYMAP_DECLARED
107 #define _KEYMAP_DECLARED
108
109 struct keyent_t {
110         u_char          map[NUM_STATES];
111         u_char          spcl;
112         u_char          flgs;
113 #define FLAG_LOCK_O     0
114 #define FLAG_LOCK_C     1
115 #define FLAG_LOCK_N     2
116 };
117
118 struct keymap {
119         u_short         n_keys;
120         struct keyent_t key[NUM_KEYS];
121 };
122 typedef struct keymap keymap_t;
123
124 #ifdef _KERNEL
125 struct okeyent_t {
126         u_char          map[NUM_STATES];
127         u_char          spcl;
128         u_char          flgs;
129 };
130
131 struct okeymap {
132         u_short         n_keys;
133         struct okeyent_t key[NUM_KEYS];
134 };
135 typedef struct okeymap okeymap_t;
136 #endif /* _KERNEL */
137
138 #endif /* !_KEYMAP_DECLARED */
139
140 /* defines for "special" keys (spcl bit set in keymap) */
141 #define NOP             0x00            /* nothing (dead key)           */
142 #define LSH             0x02            /* left shift key               */
143 #define RSH             0x03            /* right shift key              */
144 #define CLK             0x04            /* caps lock key                */
145 #define NLK             0x05            /* num lock key                 */
146 #define SLK             0x06            /* scroll lock key              */
147 #define LALT            0x07            /* left alt key                 */
148 #define BTAB            0x08            /* backwards tab                */
149 #define LCTR            0x09            /* left control key             */
150 #define NEXT            0x0a            /* switch to next screen        */
151 #define F_SCR           0x0b            /* switch to first screen       */
152 #define L_SCR           0x1a            /* switch to last screen        */
153 #define F_FN            0x1b            /* first function key           */
154 #define L_FN            0x7a            /* last function key            */
155 /*                      0x7b-0x7f          reserved do not use !        */
156 #define RCTR            0x80            /* right control key            */
157 #define RALT            0x81            /* right alt (altgr) key        */
158 #define ALK             0x82            /* alt lock key                 */
159 #define ASH             0x83            /* alt shift key                */
160 #define META            0x84            /* meta key                     */
161 #define RBT             0x85            /* boot machine                 */
162 #define DBG             0x86            /* call debugger                */
163 #define SUSP            0x87            /* suspend power                */
164 #define SPSC            0x88            /* toggle splash/text screen    */
165
166 #define F_ACC           DGRA            /* first accent key             */
167 #define DGRA            0x89            /* grave                        */
168 #define DACU            0x8a            /* acute                        */
169 #define DCIR            0x8b            /* circumflex                   */
170 #define DTIL            0x8c            /* tilde                        */
171 #define DMAC            0x8d            /* macron                       */
172 #define DBRE            0x8e            /* breve                        */
173 #define DDOT            0x8f            /* dot                          */
174 #define DUML            0x90            /* umlaut/diaresis              */
175 #define DDIA            0x90            /* diaresis                     */
176 #define DSLA            0x91            /* slash                        */
177 #define DRIN            0x92            /* ring                         */
178 #define DCED            0x93            /* cedilla                      */
179 #define DAPO            0x94            /* apostrophe                   */
180 #define DDAC            0x95            /* double acute                 */
181 #define DOGO            0x96            /* ogonek                       */
182 #define DCAR            0x97            /* caron                        */
183 #define L_ACC           DCAR            /* last accent key              */
184
185 #define STBY            0x98            /* Go into standby mode         */
186 #define PREV            0x99            /* switch to previous screen    */
187 #define PNC             0x9a            /* force system panic */
188 #define LSHA            0x9b            /* left shift key / alt lock    */
189 #define RSHA            0x9c            /* right shift key / alt lock   */
190 #define LCTRA           0x9d            /* left ctrl key / alt lock     */
191 #define RCTRA           0x9e            /* right ctrl key / alt lock    */
192 #define LALTA           0x9f            /* left alt key / alt lock      */
193 #define RALTA           0xa0            /* right alt key / alt lock     */
194 #define HALT            0xa1            /* halt machine */
195 #define PDWN            0xa2            /* halt machine and power down */
196 #define PASTE           0xa3            /* paste from cut-paste buffer */
197
198 #define F(x)            ((x)+F_FN-1)
199 #define S(x)            ((x)+F_SCR-1)
200 #define ACC(x)          ((x)+F_ACC)
201
202 struct acc_t {
203         u_char          accchar;
204         u_char          map[NUM_ACCENTCHARS][2];
205 };
206
207 struct accentmap {
208         u_short         n_accs;
209         struct acc_t    acc[NUM_DEADKEYS];
210 };
211 typedef struct accentmap accentmap_t;
212
213 struct keyarg {
214         u_short         keynum;
215         struct keyent_t key;
216 };
217 typedef struct keyarg keyarg_t;
218
219 struct fkeytab {
220         u_char          str[MAXFK];
221         u_char          len;
222 };
223 typedef struct fkeytab fkeytab_t;
224
225 struct fkeyarg {
226         u_short         keynum;
227         char            keydef[MAXFK];
228         char            flen;
229 };
230 typedef struct fkeyarg  fkeyarg_t;
231
232 #define GETFKEY         _IOWR('k', 0, fkeyarg_t)
233 #define SETFKEY         _IOWR('k', 1, fkeyarg_t)
234 #if 0 /* see console.h */
235 #define GIO_SCRNMAP     _IOR('k', 2, scrmap_t)
236 #define PIO_SCRNMAP     _IOW('k', 3, scrmap_t)
237 #endif
238 #define GIO_KEYMAP      _IOR('k', 6, keymap_t)
239 #define PIO_KEYMAP      _IOW('k', 7, keymap_t)
240 #ifdef _KERNEL
241 #define OGIO_KEYMAP     _IOR('k', 6, okeymap_t)
242 #define OPIO_KEYMAP     _IOW('k', 7, okeymap_t)
243 #endif /* _KERNEL */
244 #define GIO_DEADKEYMAP  _IOR('k', 8, accentmap_t)
245 #define PIO_DEADKEYMAP  _IOW('k', 9, accentmap_t)
246 #define GIO_KEYMAPENT   _IOWR('k', 10, keyarg_t)
247 #define PIO_KEYMAPENT   _IOW('k', 11, keyarg_t)
248
249 /* flags set to the return value in the KD_XLATE mode */
250
251 #define NOKEY           0x100           /* no key pressed marker        */
252 #define FKEY            0x200           /* function key marker          */
253 #define MKEY            0x400           /* meta key marker (prepend ESC)*/
254 #define BKEY            0x800           /* backtab (ESC [ Z)            */
255
256 #define SPCLKEY         0x8000          /* special key                  */
257 #define RELKEY          0x4000          /* key released                 */
258 #define ERRKEY          0x2000          /* error                        */
259
260 #define KEYCHAR(c)      ((c) & 0x00ff)
261 #define KEYFLAGS(c)     ((c) & ~0x00ff)
262
263 #endif /* !_SYS_KBIO_H_ */