1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1991-1996 S��ren Schmidt 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer 12 * in this position and unchanged. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef _SYS_CONSIO_H_ 32#define _SYS_CONSIO_H_ 33 34#ifndef _KERNEL 35#include <sys/types.h> 36#endif 37#include <sys/ioccom.h> 38#include <sys/font.h> 39 40/* 41 * Console ioctl commands. Some commands are named as KDXXXX, GIO_XXX, and 42 * PIO_XXX, rather than CONS_XXX, for historical and compatibility reasons. 43 * Some other CONS_XXX commands are works as wrapper around frame buffer 44 * ioctl commands FBIO_XXX. Do not try to change all these commands, 45 * otherwise we shall have compatibility problems. 46 */ 47 48/* get/set video mode */ 49#define KD_TEXT 0 /* set text mode restore fonts */ 50#define KD_TEXT0 0 /* ditto */ 51#define KD_GRAPHICS 1 /* set graphics mode */ 52#define KD_TEXT1 2 /* set text mode !restore fonts */ 53#define KD_PIXEL 3 /* set pixel mode */ 54#define KDGETMODE _IOR('K', 9, int) 55#define KDSETMODE _IOWINT('K', 10) 56 57/* set border color */ 58#define KDSBORDER _IOWINT('K', 13) 59 60/* set up raster(pixel) text mode */ 61struct _scr_size { 62 int scr_size[3]; 63}; 64typedef struct _scr_size scr_size_t; 65 66#define KDRASTER _IOW('K', 100, scr_size_t) 67 68/* get/set screen char map */ 69struct _scrmap { 70 char scrmap[256]; 71}; 72typedef struct _scrmap scrmap_t; 73 74#define GIO_SCRNMAP _IOR('k', 2, scrmap_t) 75#define PIO_SCRNMAP _IOW('k', 3, scrmap_t) 76 77/* get the current text attribute */ 78#define GIO_ATTR _IOR('a', 0, int) 79 80/* get the current text color */ 81#define GIO_COLOR _IOR('c', 0, int) 82 83/* get the adapter type (equivalent to FBIO_ADPTYPE) */ 84#define CONS_CURRENT _IOR('c', 1, int) 85 86/* get the current video mode (equivalent to FBIO_GETMODE) */ 87#define CONS_GET _IOR('c', 2, int) 88 89/* not supported? */ 90#define CONS_IO _IO('c', 3) 91 92/* set blank time interval */ 93#define CONS_BLANKTIME _IOW('c', 4, int) 94 95/* set/get the screen saver (these ioctls are current noop) */ 96struct ssaver { 97#define MAXSSAVER 16 98 char name[MAXSSAVER]; 99 int num; 100 long time; 101}; 102typedef struct ssaver ssaver_t; 103 104#define CONS_SSAVER _IOW('c', 5, ssaver_t) 105#define CONS_GSAVER _IOWR('c', 6, ssaver_t) 106 107/* 108 * Set the text cursor type. 109 * 110 * This is an old interface extended to support the CONS_HIDDEN_CURSOR bit. 111 * New code should use CONS_CURSORSHAPE. CONS_CURSOR_ATTRS gives the 3 112 * bits supported by the (extended) old interface. The old interface is 113 * especially unusable for hiding the cursor (even with its extension) 114 * since it changes the cursor on all vtys. 115 */ 116#define CONS_CURSORTYPE _IOW('c', 7, int) 117 118/* set the bell type to audible or visual */ 119#define CONS_VISUAL_BELL (1 << 0) 120#define CONS_QUIET_BELL (1 << 1) 121#define CONS_BELLTYPE _IOW('c', 8, int) 122 123/* set the history (scroll back) buffer size (in lines) */ 124#define CONS_HISTORY _IOW('c', 9, int) 125 126/* clear the history (scroll back) buffer */ 127#define CONS_CLRHIST _IO('c', 10) 128 129/* mouse cursor ioctl */ 130struct mouse_data { 131 int x; 132 int y; 133 int z; 134 int buttons; 135}; 136typedef struct mouse_data mouse_data_t; 137 138struct mouse_mode { 139 int mode; 140 int signal; 141}; 142typedef struct mouse_mode mouse_mode_t; 143 144struct mouse_event { 145 int id; /* one based */ 146 int value; 147}; 148typedef struct mouse_event mouse_event_t; 149 150struct mouse_info { 151 int operation; 152#define MOUSE_SHOW 0x01 153#define MOUSE_HIDE 0x02 154#define MOUSE_MOVEABS 0x03 155#define MOUSE_MOVEREL 0x04 156#define MOUSE_GETINFO 0x05 157#define MOUSE_MODE 0x06 158#define MOUSE_ACTION 0x07 159#define MOUSE_MOTION_EVENT 0x08 160#define MOUSE_BUTTON_EVENT 0x09 161#define MOUSE_MOUSECHAR 0x0a 162 union { 163 mouse_data_t data; 164 mouse_mode_t mode; 165 mouse_event_t event; 166 int mouse_char; 167 } u; 168}; 169typedef struct mouse_info mouse_info_t; 170 171#define CONS_MOUSECTL _IOWR('c', 10, mouse_info_t) 172 173/* see if the vty has been idle */ 174#define CONS_IDLE _IOR('c', 11, int) 175 176/* set the screen saver mode */ 177#define CONS_NO_SAVER (-1) 178#define CONS_LKM_SAVER 0 179#define CONS_USR_SAVER 1 180#define CONS_SAVERMODE _IOW('c', 12, int) 181 182/* start the screen saver */ 183#define CONS_SAVERSTART _IOW('c', 13, int) 184 185/* set the text cursor shape (see also CONS_CURSORTYPE above) */ 186#define CONS_BLINK_CURSOR (1 << 0) 187#define CONS_CHAR_CURSOR (1 << 1) 188#define CONS_HIDDEN_CURSOR (1 << 2) 189#define CONS_CURSOR_ATTRS (CONS_BLINK_CURSOR | CONS_CHAR_CURSOR | \ 190 CONS_HIDDEN_CURSOR) 191#define CONS_CHARCURSOR_COLORS (1 << 26) 192#define CONS_MOUSECURSOR_COLORS (1 << 27) 193#define CONS_DEFAULT_CURSOR (1 << 28) 194#define CONS_SHAPEONLY_CURSOR (1 << 29) 195#define CONS_RESET_CURSOR (1 << 30) 196#define CONS_LOCAL_CURSOR (1U << 31) 197struct cshape { 198 /* shape[0]: flags, shape[1]: base, shape[2]: height */ 199 int shape[3]; 200}; 201#define CONS_GETCURSORSHAPE _IOWR('c', 14, struct cshape) 202#define CONS_SETCURSORSHAPE _IOW('c', 15, struct cshape) 203 204/* set/get font data */ 205struct fnt8 { 206 char fnt8x8[8*256]; 207}; 208typedef struct fnt8 fnt8_t; 209 210struct fnt14 { 211 char fnt8x14[14*256]; 212}; 213typedef struct fnt14 fnt14_t; 214 215struct fnt16 { 216 char fnt8x16[16*256]; 217}; 218typedef struct fnt16 fnt16_t; 219 220struct vfnt { 221 vfnt_map_t *map[VFNT_MAPS]; 222 uint8_t *glyphs; 223 unsigned int map_count[VFNT_MAPS]; 224 unsigned int glyph_count; 225 unsigned int width; 226 unsigned int height; 227}; 228typedef struct vfnt vfnt_t; 229 230#define PIO_FONT8x8 _IOW('c', 64, fnt8_t) 231#define GIO_FONT8x8 _IOR('c', 65, fnt8_t) 232#define PIO_FONT8x14 _IOW('c', 66, fnt14_t) 233#define GIO_FONT8x14 _IOR('c', 67, fnt14_t) 234#define PIO_FONT8x16 _IOW('c', 68, fnt16_t) 235#define GIO_FONT8x16 _IOR('c', 69, fnt16_t) 236#define PIO_VFONT _IOW('c', 70, vfnt_t) 237#define GIO_VFONT _IOR('c', 71, vfnt_t) 238#define PIO_VFONT_DEFAULT _IO('c', 72) 239 240/* get video mode information */ 241struct colors { 242 char fore; 243 char back; 244}; 245 246struct vid_info { 247 short size; 248 short m_num; 249 u_short font_size; 250 u_short mv_row, mv_col; 251 u_short mv_rsz, mv_csz; 252 u_short mv_hsz; 253 struct colors mv_norm, 254 mv_rev, 255 mv_grfc; 256 u_char mv_ovscan; 257 u_char mk_keylock; 258}; 259typedef struct vid_info vid_info_t; 260 261#define CONS_GETINFO _IOWR('c', 73, vid_info_t) 262 263/* get version */ 264#define CONS_GETVERS _IOR('c', 74, int) 265 266/* get the video adapter index (equivalent to FBIO_ADAPTER) */ 267#define CONS_CURRENTADP _IOR('c', 100, int) 268 269/* get the video adapter information (equivalent to FBIO_ADPINFO) */ 270#define CONS_ADPINFO _IOWR('c', 101, video_adapter_info_t) 271 272/* get the video mode information (equivalent to FBIO_MODEINFO) */ 273#define CONS_MODEINFO _IOWR('c', 102, video_info_t) 274 275/* find a video mode (equivalent to FBIO_FINDMODE) */ 276#define CONS_FINDMODE _IOWR('c', 103, video_info_t) 277 278/* set the frame buffer window origin (equivalent to FBIO_SETWINORG) */ 279#define CONS_SETWINORG _IOWINT('c', 104) 280 281/* use the specified keyboard */ 282#define CONS_SETKBD _IOWINT('c', 110) 283 284/* release the current keyboard */ 285#define CONS_RELKBD _IO('c', 111) 286 287struct scrshot { 288 int x; 289 int y; 290 int xsize; 291 int ysize; 292 u_int16_t* buf; 293}; 294typedef struct scrshot scrshot_t; 295 296/* Snapshot the current video buffer */ 297#define CONS_SCRSHOT _IOWR('c', 105, scrshot_t) 298 299/* get/set the current terminal emulator info. */ 300#define TI_NAME_LEN 32 301#define TI_DESC_LEN 64 302 303struct term_info { 304 int ti_index; 305 int ti_flags; 306 u_char ti_name[TI_NAME_LEN]; 307 u_char ti_desc[TI_DESC_LEN]; 308}; 309typedef struct term_info term_info_t; 310 311#define CONS_GETTERM _IOWR('c', 112, term_info_t) 312#define CONS_SETTERM _IOW('c', 113, term_info_t) 313 314/* 315 * Vty switching ioctl commands. 316 */ 317 318/* get the next available vty */ 319#define VT_OPENQRY _IOR('v', 1, int) 320 321/* set/get vty switching mode */ 322#ifndef _VT_MODE_DECLARED 323#define _VT_MODE_DECLARED 324struct vt_mode { 325 char mode; 326#define VT_AUTO 0 /* switching is automatic */ 327#define VT_PROCESS 1 /* switching controlled by prog */ 328#define VT_KERNEL 255 /* switching controlled in kernel */ 329 char waitv; /* not implemented yet SOS */ 330 short relsig; 331 short acqsig; 332 short frsig; /* not implemented yet SOS */ 333}; 334typedef struct vt_mode vtmode_t; 335#endif /* !_VT_MODE_DECLARED */ 336 337#define VT_SETMODE _IOW('v', 2, vtmode_t) 338#define VT_GETMODE _IOR('v', 3, vtmode_t) 339 340/* acknowledge release or acquisition of a vty */ 341#define VT_FALSE 0 342#define VT_TRUE 1 343#define VT_ACKACQ 2 344#define VT_RELDISP _IOWINT('v', 4) 345 346/* activate the specified vty */ 347#define VT_ACTIVATE _IOWINT('v', 5) 348 349/* wait until the specified vty is activate */ 350#define VT_WAITACTIVE _IOWINT('v', 6) 351 352/* get the currently active vty */ 353#define VT_GETACTIVE _IOR('v', 7, int) 354 355/* get the index of the vty */ 356#define VT_GETINDEX _IOR('v', 8, int) 357 358/* prevent switching vtys */ 359#define VT_LOCKSWITCH _IOW('v', 9, int) 360 361/* 362 * Video mode switching ioctl. See sys/fbio.h for mode numbers. 363 */ 364 365#define SW_B40x25 _IO('S', M_B40x25) 366#define SW_C40x25 _IO('S', M_C40x25) 367#define SW_B80x25 _IO('S', M_B80x25) 368#define SW_C80x25 _IO('S', M_C80x25) 369#define SW_BG320 _IO('S', M_BG320) 370#define SW_CG320 _IO('S', M_CG320) 371#define SW_BG640 _IO('S', M_BG640) 372#define SW_EGAMONO80x25 _IO('S', M_EGAMONO80x25) 373#define SW_CG320_D _IO('S', M_CG320_D) 374#define SW_CG640_E _IO('S', M_CG640_E) 375#define SW_EGAMONOAPA _IO('S', M_EGAMONOAPA) 376#define SW_CG640x350 _IO('S', M_CG640x350) 377#define SW_ENH_MONOAPA2 _IO('S', M_ENHMONOAPA2) 378#define SW_ENH_CG640 _IO('S', M_ENH_CG640) 379#define SW_ENH_B40x25 _IO('S', M_ENH_B40x25) 380#define SW_ENH_C40x25 _IO('S', M_ENH_C40x25) 381#define SW_ENH_B80x25 _IO('S', M_ENH_B80x25) 382#define SW_ENH_C80x25 _IO('S', M_ENH_C80x25) 383#define SW_ENH_B80x43 _IO('S', M_ENH_B80x43) 384#define SW_ENH_C80x43 _IO('S', M_ENH_C80x43) 385#define SW_MCAMODE _IO('S', M_MCA_MODE) 386#define SW_VGA_C40x25 _IO('S', M_VGA_C40x25) 387#define SW_VGA_C80x25 _IO('S', M_VGA_C80x25) 388#define SW_VGA_C80x30 _IO('S', M_VGA_C80x30) 389#define SW_VGA_C80x50 _IO('S', M_VGA_C80x50) 390#define SW_VGA_C80x60 _IO('S', M_VGA_C80x60) 391#define SW_VGA_M80x25 _IO('S', M_VGA_M80x25) 392#define SW_VGA_M80x30 _IO('S', M_VGA_M80x30) 393#define SW_VGA_M80x50 _IO('S', M_VGA_M80x50) 394#define SW_VGA_M80x60 _IO('S', M_VGA_M80x60) 395#define SW_VGA11 _IO('S', M_VGA11) 396#define SW_BG640x480 _IO('S', M_VGA11) 397#define SW_VGA12 _IO('S', M_VGA12) 398#define SW_CG640x480 _IO('S', M_VGA12) 399#define SW_VGA13 _IO('S', M_VGA13) 400#define SW_VGA_CG320 _IO('S', M_VGA13) 401#define SW_VGA_CG640 _IO('S', M_VGA_CG640) 402#define SW_VGA_MODEX _IO('S', M_VGA_MODEX) 403 404#define SW_VGA_C90x25 _IO('S', M_VGA_C90x25) 405#define SW_VGA_M90x25 _IO('S', M_VGA_M90x25) 406#define SW_VGA_C90x30 _IO('S', M_VGA_C90x30) 407#define SW_VGA_M90x30 _IO('S', M_VGA_M90x30) 408#define SW_VGA_C90x43 _IO('S', M_VGA_C90x43) 409#define SW_VGA_M90x43 _IO('S', M_VGA_M90x43) 410#define SW_VGA_C90x50 _IO('S', M_VGA_C90x50) 411#define SW_VGA_M90x50 _IO('S', M_VGA_M90x50) 412#define SW_VGA_C90x60 _IO('S', M_VGA_C90x60) 413#define SW_VGA_M90x60 _IO('S', M_VGA_M90x60) 414 415#define SW_TEXT_80x25 _IO('S', M_TEXT_80x25) 416#define SW_TEXT_80x30 _IO('S', M_TEXT_80x30) 417#define SW_TEXT_80x43 _IO('S', M_TEXT_80x43) 418#define SW_TEXT_80x50 _IO('S', M_TEXT_80x50) 419#define SW_TEXT_80x60 _IO('S', M_TEXT_80x60) 420#define SW_TEXT_132x25 _IO('S', M_TEXT_132x25) 421#define SW_TEXT_132x30 _IO('S', M_TEXT_132x30) 422#define SW_TEXT_132x43 _IO('S', M_TEXT_132x43) 423#define SW_TEXT_132x50 _IO('S', M_TEXT_132x50) 424#define SW_TEXT_132x60 _IO('S', M_TEXT_132x60) 425 426#define SW_VESA_CG640x400 _IO('V', M_VESA_CG640x400 - M_VESA_BASE) 427#define SW_VESA_CG640x480 _IO('V', M_VESA_CG640x480 - M_VESA_BASE) 428#define SW_VESA_800x600 _IO('V', M_VESA_800x600 - M_VESA_BASE) 429#define SW_VESA_CG800x600 _IO('V', M_VESA_CG800x600 - M_VESA_BASE) 430#define SW_VESA_1024x768 _IO('V', M_VESA_1024x768 - M_VESA_BASE) 431#define SW_VESA_CG1024x768 _IO('V', M_VESA_CG1024x768 - M_VESA_BASE) 432#define SW_VESA_1280x1024 _IO('V', M_VESA_1280x1024 - M_VESA_BASE) 433#define SW_VESA_CG1280x1024 _IO('V', M_VESA_CG1280x1024 - M_VESA_BASE) 434#define SW_VESA_C80x60 _IO('V', M_VESA_C80x60 - M_VESA_BASE) 435#define SW_VESA_C132x25 _IO('V', M_VESA_C132x25 - M_VESA_BASE) 436#define SW_VESA_C132x43 _IO('V', M_VESA_C132x43 - M_VESA_BASE) 437#define SW_VESA_C132x50 _IO('V', M_VESA_C132x50 - M_VESA_BASE) 438#define SW_VESA_C132x60 _IO('V', M_VESA_C132x60 - M_VESA_BASE) 439#define SW_VESA_32K_320 _IO('V', M_VESA_32K_320 - M_VESA_BASE) 440#define SW_VESA_64K_320 _IO('V', M_VESA_64K_320 - M_VESA_BASE) 441#define SW_VESA_FULL_320 _IO('V', M_VESA_FULL_320 - M_VESA_BASE) 442#define SW_VESA_32K_640 _IO('V', M_VESA_32K_640 - M_VESA_BASE) 443#define SW_VESA_64K_640 _IO('V', M_VESA_64K_640 - M_VESA_BASE) 444#define SW_VESA_FULL_640 _IO('V', M_VESA_FULL_640 - M_VESA_BASE) 445#define SW_VESA_32K_800 _IO('V', M_VESA_32K_800 - M_VESA_BASE) 446#define SW_VESA_64K_800 _IO('V', M_VESA_64K_800 - M_VESA_BASE) 447#define SW_VESA_FULL_800 _IO('V', M_VESA_FULL_800 - M_VESA_BASE) 448#define SW_VESA_32K_1024 _IO('V', M_VESA_32K_1024 - M_VESA_BASE) 449#define SW_VESA_64K_1024 _IO('V', M_VESA_64K_1024 - M_VESA_BASE) 450#define SW_VESA_FULL_1024 _IO('V', M_VESA_FULL_1024 - M_VESA_BASE) 451#define SW_VESA_32K_1280 _IO('V', M_VESA_32K_1280 - M_VESA_BASE) 452#define SW_VESA_64K_1280 _IO('V', M_VESA_64K_1280 - M_VESA_BASE) 453#define SW_VESA_FULL_1280 _IO('V', M_VESA_FULL_1280 - M_VESA_BASE) 454 455#endif /* !_SYS_CONSIO_H_ */ 456