Upgrade vi(1). 1/2
[dragonfly.git] / sys / sys / consio.h
1 /*-
2  * Copyright (c) 1991-1996 Søren Schmidt
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer
10  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/sys/consio.h,v 1.5.2.7 2002/09/15 22:30:46 dd Exp $
29  */
30
31 #ifndef _SYS_CONSIO_H_
32 #define _SYS_CONSIO_H_
33
34 #ifndef _SYS_TYPES_H_
35 #include <sys/types.h>
36 #endif
37 #ifndef _SYS_IOCCOM_H_
38 #include <sys/ioccom.h>
39 #endif
40
41 /*
42  * Console ioctl commands.  Some commands are named as KDXXXX, GIO_XXX, and
43  * PIO_XXX, rather than CONS_XXX, for historical and compatibility reasons.
44  * Some other CONS_XXX commands are works as wrapper around frame buffer 
45  * ioctl commands FBIO_XXX.  Do not try to change all these commands, 
46  * otherwise we shall have compatibility problems.
47  */
48
49 /* get/set video mode */
50 #define KD_TEXT         0               /* set text mode restore fonts  */
51 #define KD_TEXT0        0               /* ditto                        */
52 #define KD_GRAPHICS     1               /* set graphics mode            */
53 #define KD_TEXT1        2               /* set text mode !restore fonts */
54 #define KD_PIXEL        3               /* set pixel mode               */
55 #define KDGETMODE       _IOR('K', 9, int)
56 #define KDSETMODE       _IO('K', 10 /*, int */)
57
58 /* set border color */
59 #define KDSBORDER       _IO('K', 13 /*, int */)
60
61 /* set up raster(pixel) text mode */
62 struct _scr_size {
63         int             scr_size[3];
64 };
65 typedef struct _scr_size        scr_size_t;
66
67 #define KDRASTER        _IOW('K', 100, scr_size_t)
68
69 /* get/set screen char map */
70 struct _scrmap {
71         char            scrmap[256];
72 };
73 typedef struct _scrmap  scrmap_t;
74
75 #define GIO_SCRNMAP     _IOR('k', 2, scrmap_t)
76 #define PIO_SCRNMAP     _IOW('k', 3, scrmap_t)
77
78 /* get the current text attribute */
79 #define GIO_ATTR        _IOR('a', 0, int)
80
81 /* get the current text color */
82 #define GIO_COLOR       _IOR('c', 0, int)
83
84 /* get the adapter type (equivalent to FBIO_ADPTYPE) */
85 #define CONS_CURRENT    _IOR('c', 1, int)
86
87 /* get the current video mode (equivalent to FBIO_GETMODE) */
88 #define CONS_GET        _IOR('c', 2, int)
89
90 /* set the current video mode (equivalent to FBIO_SETMODE) */
91 #define CONS_SET        _IOW('c', 3, int)
92
93 /* set blank time interval */
94 #define CONS_BLANKTIME  _IOW('c', 4, int)
95
96 /* set the text cursor shape */
97 #define CONS_BLINK_CURSOR (1 << 0)
98 #define CONS_CHAR_CURSOR (1 << 1)
99 #define CONS_CURSORTYPE _IOW('c', 7, int)
100
101 /* set the bell type to audible or visual */
102 #define CONS_VISUAL_BELL (1 << 0)
103 #define CONS_QUIET_BELL (1 << 1)
104 #define CONS_BELLTYPE   _IOW('c', 8, int)
105
106 /* set the history (scroll back) buffer size (in lines) */
107 #define CONS_HISTORY    _IOW('c', 9, int)
108
109 /* clear the history (scroll back) buffer */
110 #define CONS_CLRHIST    _IO('c', 10)
111
112 /* mouse cursor ioctl */
113 struct mouse_data {
114         int             x;
115         int             y;
116         int             z;
117         int             buttons;
118 };
119 typedef struct mouse_data mouse_data_t;
120
121 struct mouse_mode {
122         int             mode;
123         int             signal;
124 };
125 typedef struct mouse_mode mouse_mode_t;
126
127 struct mouse_event {
128         int             id;                     /* one based */
129         int             value;
130 };
131 typedef struct mouse_event mouse_event_t;
132
133 struct mouse_info {
134         int             operation;
135 #define MOUSE_SHOW      0x01
136 #define MOUSE_HIDE      0x02
137 #define MOUSE_MOVEABS   0x03
138 #define MOUSE_MOVEREL   0x04
139 #define MOUSE_GETINFO   0x05
140 #define MOUSE_MODE      0x06
141 #define MOUSE_ACTION    0x07
142 #define MOUSE_MOTION_EVENT      0x08
143 #define MOUSE_BUTTON_EVENT      0x09
144 #define MOUSE_MOUSECHAR 0x0a
145         union {
146                 mouse_data_t    data;
147                 mouse_mode_t    mode;
148                 mouse_event_t   event;
149                 int             mouse_char;
150         }               u;
151 };
152 typedef struct mouse_info mouse_info_t;
153
154 #define CONS_MOUSECTL   _IOWR('c', 10, mouse_info_t)
155
156 /* see if the vty has been idle */
157 #define CONS_IDLE       _IOR('c', 11, int)
158
159 /* set the screen saver mode */
160 #define CONS_NO_SAVER   (-1)
161 #define CONS_LKM_SAVER  0
162 #define CONS_USR_SAVER  1
163 #define CONS_SAVERMODE  _IOW('c', 12, int)
164
165 /* start the screen saver */
166 #define CONS_SAVERSTART _IOW('c', 13, int)
167
168 /* set/get font data */
169 struct fnt8 {
170         char            fnt8x8[8*256];
171 };
172 typedef struct fnt8     fnt8_t;
173
174 struct fnt14 {
175         char            fnt8x14[14*256];
176 };
177 typedef struct fnt14    fnt14_t;
178
179 struct fnt16 {
180         char            fnt8x16[16*256];
181 };
182 typedef struct fnt16    fnt16_t;
183
184 #define PIO_FONT8x8     _IOW('c', 64, fnt8_t)
185 #define GIO_FONT8x8     _IOR('c', 65, fnt8_t)
186 #define PIO_FONT8x14    _IOW('c', 66, fnt14_t)
187 #define GIO_FONT8x14    _IOR('c', 67, fnt14_t)
188 #define PIO_FONT8x16    _IOW('c', 68, fnt16_t)
189 #define GIO_FONT8x16    _IOR('c', 69, fnt16_t)
190
191 /* get video mode information */
192 struct colors   {
193         char            fore;
194         char            back;
195 };
196
197 struct vid_info {
198         short           size;
199         short           m_num;
200         u_short         font_size;
201         u_short         mv_row, mv_col;
202         u_short         mv_rsz, mv_csz;
203         struct colors   mv_norm,
204                         mv_rev,
205                         mv_grfc;
206         u_char          mv_ovscan;
207         u_char          mk_keylock;
208 };
209 typedef struct vid_info vid_info_t;
210
211 #define CONS_GETINFO    _IOWR('c', 73, vid_info_t)
212
213 /* get version */
214 #define CONS_GETVERS    _IOR('c', 74, int)
215
216 /* get the video adapter index (equivalent to FBIO_ADAPTER) */
217 #define CONS_CURRENTADP _IOR('c', 100, int)
218
219 /* get the video adapter information (equivalent to FBIO_ADPINFO) */
220 #define CONS_ADPINFO    _IOWR('c', 101, video_adapter_info_t)
221
222 /* get the video mode information (equivalent to FBIO_MODEINFO) */
223 #define CONS_MODEINFO   _IOWR('c', 102, video_info_t)
224
225 /* find a video mode (equivalent to FBIO_FINDMODE) */
226 #define CONS_FINDMODE   _IOWR('c', 103, video_info_t)
227
228 /* set the frame buffer window origin (equivalent to FBIO_SETWINORG) */
229 #define CONS_SETWINORG  _IO('c', 104 /*, u_int */) 
230
231 /* use the specified keyboard */
232 #define CONS_SETKBD     _IO('c', 110 /*, int */)
233
234 /* release the current keyboard */
235 #define CONS_RELKBD     _IO('c', 111)
236
237 /* Snapshot the current video buffer */
238 #define CONS_SCRSHOT    _IOWR('c', 105, scrshot_t)
239
240 struct scrshot {
241         int             xsize;
242         int             ysize;
243         u_int16_t*      buf;
244 };
245 typedef struct scrshot scrshot_t;
246
247 /* get/set the current terminal emulator info. */
248 #define TI_NAME_LEN     32
249 #define TI_DESC_LEN     64
250
251 struct term_info {
252         int             ti_index;
253         int             ti_flags;
254         u_char          ti_name[TI_NAME_LEN];
255         u_char          ti_desc[TI_DESC_LEN];
256 };
257 typedef struct term_info term_info_t;
258
259 #define CONS_GETTERM    _IOWR('c', 112, term_info_t)
260 #define CONS_SETTERM    _IOW('c', 113, term_info_t)
261
262 /*
263  * Vty switching ioctl commands.
264  */
265
266 /* get the next available vty */
267 #define VT_OPENQRY      _IOR('v', 1, int)
268
269 /* set/get vty switching mode */
270 #ifndef _VT_MODE_DECLARED
271 #define _VT_MODE_DECLARED
272 struct vt_mode {
273         char            mode;
274 #define VT_AUTO         0               /* switching is automatic       */
275 #define VT_PROCESS      1               /* switching controlled by prog */
276 #define VT_KERNEL       255             /* switching controlled in kernel */
277         char            waitv;          /* not implemented yet  SOS     */
278         short           relsig;
279         short           acqsig;
280         short           frsig;          /* not implemented yet  SOS     */
281 };
282 typedef struct vt_mode vtmode_t;
283 #endif /* !_VT_MODE_DECLARED */
284
285 #define VT_SETMODE      _IOW('v', 2, vtmode_t)
286 #define VT_GETMODE      _IOR('v', 3, vtmode_t)
287
288 /* acknowledge release or acquisition of a vty */
289 #define VT_FALSE        0
290 #define VT_TRUE         1
291 #define VT_ACKACQ       2
292 #define VT_RELDISP      _IO('v', 4 /*, int */)
293
294 /* activate the specified vty */
295 #define VT_ACTIVATE     _IO('v', 5 /*, int */)
296
297 /* wait until the specified vty is activate */
298 #define VT_WAITACTIVE   _IO('v', 6 /*, int */)
299
300 /* get the currently active vty */
301 #define VT_GETACTIVE    _IOR('v', 7, int)
302
303 /* get the index of the vty */
304 #define VT_GETINDEX     _IOR('v', 8, int)
305
306 /* prevent switching vtys */
307 #define VT_LOCKSWITCH   _IOW('v', 9, int)
308
309 #ifdef _KERNEL
310
311 extern int break_to_debugger;
312 extern int alt_break_to_debugger;
313
314 #endif
315
316 #endif /* !_SYS_CONSIO_H_ */