diff options
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r-- | freebsd/sys/sys/consio.h | 468 | ||||
-rw-r--r-- | freebsd/sys/sys/fbio.h | 622 | ||||
-rw-r--r-- | freebsd/sys/sys/terminal.h | 240 |
3 files changed, 1330 insertions, 0 deletions
diff --git a/freebsd/sys/sys/consio.h b/freebsd/sys/sys/consio.h new file mode 100644 index 00000000..5dfedc4b --- /dev/null +++ b/freebsd/sys/sys/consio.h @@ -0,0 +1,468 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1991-1996 Søren Schmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_CONSIO_H_ +#define _SYS_CONSIO_H_ + +#ifndef _KERNEL +#include <sys/types.h> +#endif +#include <sys/ioccom.h> + +/* + * Console ioctl commands. Some commands are named as KDXXXX, GIO_XXX, and + * PIO_XXX, rather than CONS_XXX, for historical and compatibility reasons. + * Some other CONS_XXX commands are works as wrapper around frame buffer + * ioctl commands FBIO_XXX. Do not try to change all these commands, + * otherwise we shall have compatibility problems. + */ + +/* get/set video mode */ +#define KD_TEXT 0 /* set text mode restore fonts */ +#define KD_TEXT0 0 /* ditto */ +#define KD_GRAPHICS 1 /* set graphics mode */ +#define KD_TEXT1 2 /* set text mode !restore fonts */ +#define KD_PIXEL 3 /* set pixel mode */ +#define KDGETMODE _IOR('K', 9, int) +#define KDSETMODE _IOWINT('K', 10) + +/* set border color */ +#define KDSBORDER _IOWINT('K', 13) + +/* set up raster(pixel) text mode */ +struct _scr_size { + int scr_size[3]; +}; +typedef struct _scr_size scr_size_t; + +#define KDRASTER _IOW('K', 100, scr_size_t) + +/* get/set screen char map */ +struct _scrmap { + char scrmap[256]; +}; +typedef struct _scrmap scrmap_t; + +#define GIO_SCRNMAP _IOR('k', 2, scrmap_t) +#define PIO_SCRNMAP _IOW('k', 3, scrmap_t) + +/* get the current text attribute */ +#define GIO_ATTR _IOR('a', 0, int) + +/* get the current text color */ +#define GIO_COLOR _IOR('c', 0, int) + +/* get the adapter type (equivalent to FBIO_ADPTYPE) */ +#define CONS_CURRENT _IOR('c', 1, int) + +/* get the current video mode (equivalent to FBIO_GETMODE) */ +#define CONS_GET _IOR('c', 2, int) + +/* not supported? */ +#define CONS_IO _IO('c', 3) + +/* set blank time interval */ +#define CONS_BLANKTIME _IOW('c', 4, int) + +/* set/get the screen saver (these ioctls are current noop) */ +struct ssaver { +#define MAXSSAVER 16 + char name[MAXSSAVER]; + int num; + long time; +}; +typedef struct ssaver ssaver_t; + +#define CONS_SSAVER _IOW('c', 5, ssaver_t) +#define CONS_GSAVER _IOWR('c', 6, ssaver_t) + +/* + * Set the text cursor type. + * + * This is an old interface extended to support the CONS_HIDDEN_CURSOR bit. + * New code should use CONS_CURSORSHAPE. CONS_CURSOR_ATTRS gives the 3 + * bits supported by the (extended) old interface. The old interface is + * especially unusable for hiding the cursor (even with its extension) + * since it changes the cursor on all vtys. + */ +#define CONS_CURSORTYPE _IOW('c', 7, int) + +/* set the bell type to audible or visual */ +#define CONS_VISUAL_BELL (1 << 0) +#define CONS_QUIET_BELL (1 << 1) +#define CONS_BELLTYPE _IOW('c', 8, int) + +/* set the history (scroll back) buffer size (in lines) */ +#define CONS_HISTORY _IOW('c', 9, int) + +/* clear the history (scroll back) buffer */ +#define CONS_CLRHIST _IO('c', 10) + +/* mouse cursor ioctl */ +struct mouse_data { + int x; + int y; + int z; + int buttons; +}; +typedef struct mouse_data mouse_data_t; + +struct mouse_mode { + int mode; + int signal; +}; +typedef struct mouse_mode mouse_mode_t; + +struct mouse_event { + int id; /* one based */ + int value; +}; +typedef struct mouse_event mouse_event_t; + +struct mouse_info { + int operation; +#define MOUSE_SHOW 0x01 +#define MOUSE_HIDE 0x02 +#define MOUSE_MOVEABS 0x03 +#define MOUSE_MOVEREL 0x04 +#define MOUSE_GETINFO 0x05 +#define MOUSE_MODE 0x06 +#define MOUSE_ACTION 0x07 +#define MOUSE_MOTION_EVENT 0x08 +#define MOUSE_BUTTON_EVENT 0x09 +#define MOUSE_MOUSECHAR 0x0a + union { + mouse_data_t data; + mouse_mode_t mode; + mouse_event_t event; + int mouse_char; + } u; +}; +typedef struct mouse_info mouse_info_t; + +#define CONS_MOUSECTL _IOWR('c', 10, mouse_info_t) + +/* see if the vty has been idle */ +#define CONS_IDLE _IOR('c', 11, int) + +/* set the screen saver mode */ +#define CONS_NO_SAVER (-1) +#define CONS_LKM_SAVER 0 +#define CONS_USR_SAVER 1 +#define CONS_SAVERMODE _IOW('c', 12, int) + +/* start the screen saver */ +#define CONS_SAVERSTART _IOW('c', 13, int) + +/* set the text cursor shape (see also CONS_CURSORTYPE above) */ +#define CONS_BLINK_CURSOR (1 << 0) +#define CONS_CHAR_CURSOR (1 << 1) +#define CONS_HIDDEN_CURSOR (1 << 2) +#define CONS_CURSOR_ATTRS (CONS_BLINK_CURSOR | CONS_CHAR_CURSOR | \ + CONS_HIDDEN_CURSOR) +#define CONS_CHARCURSOR_COLORS (1 << 26) +#define CONS_MOUSECURSOR_COLORS (1 << 27) +#define CONS_DEFAULT_CURSOR (1 << 28) +#define CONS_SHAPEONLY_CURSOR (1 << 29) +#define CONS_RESET_CURSOR (1 << 30) +#define CONS_LOCAL_CURSOR (1U << 31) +struct cshape { + /* shape[0]: flags, shape[1]: base, shape[2]: height */ + int shape[3]; +}; +#define CONS_GETCURSORSHAPE _IOWR('c', 14, struct cshape) +#define CONS_SETCURSORSHAPE _IOW('c', 15, struct cshape) + +/* set/get font data */ +struct fnt8 { + char fnt8x8[8*256]; +}; +typedef struct fnt8 fnt8_t; + +struct fnt14 { + char fnt8x14[14*256]; +}; +typedef struct fnt14 fnt14_t; + +struct fnt16 { + char fnt8x16[16*256]; +}; +typedef struct fnt16 fnt16_t; + +struct vfnt_map { + uint32_t src; + uint16_t dst; + uint16_t len; +}; +typedef struct vfnt_map vfnt_map_t; + +#define VFNT_MAP_NORMAL 0 +#define VFNT_MAP_NORMAL_RIGHT 1 +#define VFNT_MAP_BOLD 2 +#define VFNT_MAP_BOLD_RIGHT 3 +#define VFNT_MAPS 4 +struct vfnt { + vfnt_map_t *map[VFNT_MAPS]; + uint8_t *glyphs; + unsigned int map_count[VFNT_MAPS]; + unsigned int glyph_count; + unsigned int width; + unsigned int height; +}; +typedef struct vfnt vfnt_t; + +#define PIO_FONT8x8 _IOW('c', 64, fnt8_t) +#define GIO_FONT8x8 _IOR('c', 65, fnt8_t) +#define PIO_FONT8x14 _IOW('c', 66, fnt14_t) +#define GIO_FONT8x14 _IOR('c', 67, fnt14_t) +#define PIO_FONT8x16 _IOW('c', 68, fnt16_t) +#define GIO_FONT8x16 _IOR('c', 69, fnt16_t) +#define PIO_VFONT _IOW('c', 70, vfnt_t) +#define GIO_VFONT _IOR('c', 71, vfnt_t) +#define PIO_VFONT_DEFAULT _IO('c', 72) + +/* get video mode information */ +struct colors { + char fore; + char back; +}; + +struct vid_info { + short size; + short m_num; + u_short font_size; + u_short mv_row, mv_col; + u_short mv_rsz, mv_csz; + u_short mv_hsz; + struct colors mv_norm, + mv_rev, + mv_grfc; + u_char mv_ovscan; + u_char mk_keylock; +}; +typedef struct vid_info vid_info_t; + +#define CONS_GETINFO _IOWR('c', 73, vid_info_t) + +/* get version */ +#define CONS_GETVERS _IOR('c', 74, int) + +/* get the video adapter index (equivalent to FBIO_ADAPTER) */ +#define CONS_CURRENTADP _IOR('c', 100, int) + +/* get the video adapter information (equivalent to FBIO_ADPINFO) */ +#define CONS_ADPINFO _IOWR('c', 101, video_adapter_info_t) + +/* get the video mode information (equivalent to FBIO_MODEINFO) */ +#define CONS_MODEINFO _IOWR('c', 102, video_info_t) + +/* find a video mode (equivalent to FBIO_FINDMODE) */ +#define CONS_FINDMODE _IOWR('c', 103, video_info_t) + +/* set the frame buffer window origin (equivalent to FBIO_SETWINORG) */ +#define CONS_SETWINORG _IOWINT('c', 104) + +/* use the specified keyboard */ +#define CONS_SETKBD _IOWINT('c', 110) + +/* release the current keyboard */ +#define CONS_RELKBD _IO('c', 111) + +struct scrshot { + int x; + int y; + int xsize; + int ysize; + u_int16_t* buf; +}; +typedef struct scrshot scrshot_t; + +/* Snapshot the current video buffer */ +#define CONS_SCRSHOT _IOWR('c', 105, scrshot_t) + +/* get/set the current terminal emulator info. */ +#define TI_NAME_LEN 32 +#define TI_DESC_LEN 64 + +struct term_info { + int ti_index; + int ti_flags; + u_char ti_name[TI_NAME_LEN]; + u_char ti_desc[TI_DESC_LEN]; +}; +typedef struct term_info term_info_t; + +#define CONS_GETTERM _IOWR('c', 112, term_info_t) +#define CONS_SETTERM _IOW('c', 113, term_info_t) + +/* + * Vty switching ioctl commands. + */ + +/* get the next available vty */ +#define VT_OPENQRY _IOR('v', 1, int) + +/* set/get vty switching mode */ +#ifndef _VT_MODE_DECLARED +#define _VT_MODE_DECLARED +struct vt_mode { + char mode; +#define VT_AUTO 0 /* switching is automatic */ +#define VT_PROCESS 1 /* switching controlled by prog */ +#define VT_KERNEL 255 /* switching controlled in kernel */ + char waitv; /* not implemented yet SOS */ + short relsig; + short acqsig; + short frsig; /* not implemented yet SOS */ +}; +typedef struct vt_mode vtmode_t; +#endif /* !_VT_MODE_DECLARED */ + +#define VT_SETMODE _IOW('v', 2, vtmode_t) +#define VT_GETMODE _IOR('v', 3, vtmode_t) + +/* acknowledge release or acquisition of a vty */ +#define VT_FALSE 0 +#define VT_TRUE 1 +#define VT_ACKACQ 2 +#define VT_RELDISP _IOWINT('v', 4) + +/* activate the specified vty */ +#define VT_ACTIVATE _IOWINT('v', 5) + +/* wait until the specified vty is activate */ +#define VT_WAITACTIVE _IOWINT('v', 6) + +/* get the currently active vty */ +#define VT_GETACTIVE _IOR('v', 7, int) + +/* get the index of the vty */ +#define VT_GETINDEX _IOR('v', 8, int) + +/* prevent switching vtys */ +#define VT_LOCKSWITCH _IOW('v', 9, int) + +/* + * Video mode switching ioctl. See sys/fbio.h for mode numbers. + */ + +#define SW_B40x25 _IO('S', M_B40x25) +#define SW_C40x25 _IO('S', M_C40x25) +#define SW_B80x25 _IO('S', M_B80x25) +#define SW_C80x25 _IO('S', M_C80x25) +#define SW_BG320 _IO('S', M_BG320) +#define SW_CG320 _IO('S', M_CG320) +#define SW_BG640 _IO('S', M_BG640) +#define SW_EGAMONO80x25 _IO('S', M_EGAMONO80x25) +#define SW_CG320_D _IO('S', M_CG320_D) +#define SW_CG640_E _IO('S', M_CG640_E) +#define SW_EGAMONOAPA _IO('S', M_EGAMONOAPA) +#define SW_CG640x350 _IO('S', M_CG640x350) +#define SW_ENH_MONOAPA2 _IO('S', M_ENHMONOAPA2) +#define SW_ENH_CG640 _IO('S', M_ENH_CG640) +#define SW_ENH_B40x25 _IO('S', M_ENH_B40x25) +#define SW_ENH_C40x25 _IO('S', M_ENH_C40x25) +#define SW_ENH_B80x25 _IO('S', M_ENH_B80x25) +#define SW_ENH_C80x25 _IO('S', M_ENH_C80x25) +#define SW_ENH_B80x43 _IO('S', M_ENH_B80x43) +#define SW_ENH_C80x43 _IO('S', M_ENH_C80x43) +#define SW_MCAMODE _IO('S', M_MCA_MODE) +#define SW_VGA_C40x25 _IO('S', M_VGA_C40x25) +#define SW_VGA_C80x25 _IO('S', M_VGA_C80x25) +#define SW_VGA_C80x30 _IO('S', M_VGA_C80x30) +#define SW_VGA_C80x50 _IO('S', M_VGA_C80x50) +#define SW_VGA_C80x60 _IO('S', M_VGA_C80x60) +#define SW_VGA_M80x25 _IO('S', M_VGA_M80x25) +#define SW_VGA_M80x30 _IO('S', M_VGA_M80x30) +#define SW_VGA_M80x50 _IO('S', M_VGA_M80x50) +#define SW_VGA_M80x60 _IO('S', M_VGA_M80x60) +#define SW_VGA11 _IO('S', M_VGA11) +#define SW_BG640x480 _IO('S', M_VGA11) +#define SW_VGA12 _IO('S', M_VGA12) +#define SW_CG640x480 _IO('S', M_VGA12) +#define SW_VGA13 _IO('S', M_VGA13) +#define SW_VGA_CG320 _IO('S', M_VGA13) +#define SW_VGA_CG640 _IO('S', M_VGA_CG640) +#define SW_VGA_MODEX _IO('S', M_VGA_MODEX) + +#define SW_VGA_C90x25 _IO('S', M_VGA_C90x25) +#define SW_VGA_M90x25 _IO('S', M_VGA_M90x25) +#define SW_VGA_C90x30 _IO('S', M_VGA_C90x30) +#define SW_VGA_M90x30 _IO('S', M_VGA_M90x30) +#define SW_VGA_C90x43 _IO('S', M_VGA_C90x43) +#define SW_VGA_M90x43 _IO('S', M_VGA_M90x43) +#define SW_VGA_C90x50 _IO('S', M_VGA_C90x50) +#define SW_VGA_M90x50 _IO('S', M_VGA_M90x50) +#define SW_VGA_C90x60 _IO('S', M_VGA_C90x60) +#define SW_VGA_M90x60 _IO('S', M_VGA_M90x60) + +#define SW_TEXT_80x25 _IO('S', M_TEXT_80x25) +#define SW_TEXT_80x30 _IO('S', M_TEXT_80x30) +#define SW_TEXT_80x43 _IO('S', M_TEXT_80x43) +#define SW_TEXT_80x50 _IO('S', M_TEXT_80x50) +#define SW_TEXT_80x60 _IO('S', M_TEXT_80x60) +#define SW_TEXT_132x25 _IO('S', M_TEXT_132x25) +#define SW_TEXT_132x30 _IO('S', M_TEXT_132x30) +#define SW_TEXT_132x43 _IO('S', M_TEXT_132x43) +#define SW_TEXT_132x50 _IO('S', M_TEXT_132x50) +#define SW_TEXT_132x60 _IO('S', M_TEXT_132x60) + +#define SW_VESA_CG640x400 _IO('V', M_VESA_CG640x400 - M_VESA_BASE) +#define SW_VESA_CG640x480 _IO('V', M_VESA_CG640x480 - M_VESA_BASE) +#define SW_VESA_800x600 _IO('V', M_VESA_800x600 - M_VESA_BASE) +#define SW_VESA_CG800x600 _IO('V', M_VESA_CG800x600 - M_VESA_BASE) +#define SW_VESA_1024x768 _IO('V', M_VESA_1024x768 - M_VESA_BASE) +#define SW_VESA_CG1024x768 _IO('V', M_VESA_CG1024x768 - M_VESA_BASE) +#define SW_VESA_1280x1024 _IO('V', M_VESA_1280x1024 - M_VESA_BASE) +#define SW_VESA_CG1280x1024 _IO('V', M_VESA_CG1280x1024 - M_VESA_BASE) +#define SW_VESA_C80x60 _IO('V', M_VESA_C80x60 - M_VESA_BASE) +#define SW_VESA_C132x25 _IO('V', M_VESA_C132x25 - M_VESA_BASE) +#define SW_VESA_C132x43 _IO('V', M_VESA_C132x43 - M_VESA_BASE) +#define SW_VESA_C132x50 _IO('V', M_VESA_C132x50 - M_VESA_BASE) +#define SW_VESA_C132x60 _IO('V', M_VESA_C132x60 - M_VESA_BASE) +#define SW_VESA_32K_320 _IO('V', M_VESA_32K_320 - M_VESA_BASE) +#define SW_VESA_64K_320 _IO('V', M_VESA_64K_320 - M_VESA_BASE) +#define SW_VESA_FULL_320 _IO('V', M_VESA_FULL_320 - M_VESA_BASE) +#define SW_VESA_32K_640 _IO('V', M_VESA_32K_640 - M_VESA_BASE) +#define SW_VESA_64K_640 _IO('V', M_VESA_64K_640 - M_VESA_BASE) +#define SW_VESA_FULL_640 _IO('V', M_VESA_FULL_640 - M_VESA_BASE) +#define SW_VESA_32K_800 _IO('V', M_VESA_32K_800 - M_VESA_BASE) +#define SW_VESA_64K_800 _IO('V', M_VESA_64K_800 - M_VESA_BASE) +#define SW_VESA_FULL_800 _IO('V', M_VESA_FULL_800 - M_VESA_BASE) +#define SW_VESA_32K_1024 _IO('V', M_VESA_32K_1024 - M_VESA_BASE) +#define SW_VESA_64K_1024 _IO('V', M_VESA_64K_1024 - M_VESA_BASE) +#define SW_VESA_FULL_1024 _IO('V', M_VESA_FULL_1024 - M_VESA_BASE) +#define SW_VESA_32K_1280 _IO('V', M_VESA_32K_1280 - M_VESA_BASE) +#define SW_VESA_64K_1280 _IO('V', M_VESA_64K_1280 - M_VESA_BASE) +#define SW_VESA_FULL_1280 _IO('V', M_VESA_FULL_1280 - M_VESA_BASE) + +#endif /* !_SYS_CONSIO_H_ */ diff --git a/freebsd/sys/sys/fbio.h b/freebsd/sys/sys/fbio.h new file mode 100644 index 00000000..4cc0cc6d --- /dev/null +++ b/freebsd/sys/sys/fbio.h @@ -0,0 +1,622 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software developed by the Computer Systems + * Engineering group at Lawrence Berkeley Laboratory under DARPA + * contract BG 91-66 and contributed to Berkeley. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fbio.h 8.2 (Berkeley) 10/30/93 + * + * $FreeBSD$ + */ + +#ifndef _SYS_FBIO_H_ +#define _SYS_FBIO_H_ + +#ifndef _KERNEL +#include <sys/types.h> +#else +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/eventhandler.h> +#endif +#include <sys/ioccom.h> + +/* + * Frame buffer ioctls (from Sprite, trimmed to essentials for X11). + */ + +/* + * Frame buffer type codes. + */ +#define FBTYPE_SUN1BW 0 /* multibus mono */ +#define FBTYPE_SUN1COLOR 1 /* multibus color */ +#define FBTYPE_SUN2BW 2 /* memory mono */ +#define FBTYPE_SUN2COLOR 3 /* color w/rasterop chips */ +#define FBTYPE_SUN2GP 4 /* GP1/GP2 */ +#define FBTYPE_SUN5COLOR 5 /* RoadRunner accelerator */ +#define FBTYPE_SUN3COLOR 6 /* memory color */ +#define FBTYPE_MEMCOLOR 7 /* memory 24-bit */ +#define FBTYPE_SUN4COLOR 8 /* memory color w/overlay */ + +#define FBTYPE_NOTSUN1 9 /* reserved for customer */ +#define FBTYPE_NOTSUN2 10 /* reserved for customer */ +#define FBTYPE_PCIMISC 11 /* (generic) PCI misc. disp. */ + +#define FBTYPE_SUNFAST_COLOR 12 /* accelerated 8bit */ +#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */ +#define FBTYPE_SUNFB_VIDEO 14 /* Simple video mixing */ +#define FBTYPE_RESERVED5 15 /* reserved, do not use */ +#define FBTYPE_RESERVED4 16 /* reserved, do not use */ +#define FBTYPE_SUNGP3 17 +#define FBTYPE_SUNGT 18 +#define FBTYPE_SUNLEO 19 /* zx Leo */ + +#define FBTYPE_MDA 20 +#define FBTYPE_HERCULES 21 +#define FBTYPE_CGA 22 +#define FBTYPE_EGA 23 +#define FBTYPE_VGA 24 +#define FBTYPE_TGA 26 +#define FBTYPE_TGA2 27 + +#define FBTYPE_MDICOLOR 28 /* cg14 */ +#define FBTYPE_TCXCOLOR 29 /* SUNW,tcx */ +#define FBTYPE_CREATOR 30 + +#define FBTYPE_LASTPLUSONE 31 /* max number of fbs (change as add) */ + +/* + * Frame buffer descriptor as returned by FBIOGTYPE. + */ +struct fbtype { + int fb_type; /* as defined above */ + int fb_height; /* in pixels */ + int fb_width; /* in pixels */ + int fb_depth; /* bits per pixel */ + int fb_cmsize; /* size of color map (entries) */ + int fb_size; /* total size in bytes */ +}; +#define FBIOGTYPE _IOR('F', 0, struct fbtype) + +#define FBTYPE_GET_STRIDE(_fb) ((_fb)->fb_size / (_fb)->fb_height) +#define FBTYPE_GET_BPP(_fb) ((_fb)->fb_bpp) +#define FBTYPE_GET_BYTESPP(_fb) ((_fb)->fb_bpp / 8) + +#ifdef _KERNEL + +struct fb_info; + +typedef int fb_enter_t(void *priv); +typedef int fb_leave_t(void *priv); +typedef int fb_setblankmode_t(void *priv, int mode); + +struct fb_info { + /* Raw copy of fbtype. Do not change. */ + int fb_type; /* as defined above */ + int fb_height; /* in pixels */ + int fb_width; /* in pixels */ + int fb_depth; /* bits to define color */ + int fb_cmsize; /* size of color map (entries) */ + int fb_size; /* total size in bytes */ + + struct cdev *fb_cdev; + + device_t fb_fbd_dev; /* "fbd" device. */ + device_t fb_video_dev; /* Video adapter. */ + + fb_enter_t *enter; + fb_leave_t *leave; + fb_setblankmode_t *setblankmode; + + uintptr_t fb_pbase; /* For FB mmap. */ + uintptr_t fb_vbase; /* if NULL, use fb_write/fb_read. */ + void *fb_priv; /* First argument for read/write. */ + const char *fb_name; + uint32_t fb_flags; +#define FB_FLAG_NOMMAP 1 /* mmap unsupported. */ +#define FB_FLAG_NOWRITE 2 /* disable writes for the time being */ +#define FB_FLAG_MEMATTR 4 /* override memattr for mmap */ + vm_memattr_t fb_memattr; + int fb_stride; + int fb_bpp; /* bits per pixel */ + uint32_t fb_cmap[16]; +}; + +int fbd_list(void); +int fbd_register(struct fb_info *); +int fbd_unregister(struct fb_info *); + +static inline int +register_framebuffer(struct fb_info *info) +{ + + EVENTHANDLER_INVOKE(register_framebuffer, info); + return (0); +} + +static inline int +unregister_framebuffer(struct fb_info *info) +{ + + EVENTHANDLER_INVOKE(unregister_framebuffer, info); + return (0); +} +#endif + +#ifdef notdef +/* + * General purpose structure for passing info in and out of frame buffers + * (used for gp1) -- unsupported. + */ +struct fbinfo { + int fb_physaddr; /* physical frame buffer address */ + int fb_hwwidth; /* fb board width */ + int fb_hwheight; /* fb board height */ + int fb_addrdelta; /* phys addr diff between boards */ + u_char *fb_ropaddr; /* fb virtual addr */ + int fb_unit; /* minor devnum of fb */ +}; +#define FBIOGINFO _IOR('F', 2, struct fbinfo) +#endif + +/* + * Color map I/O. + */ +struct fbcmap { + int index; /* first element (0 origin) */ + int count; /* number of elements */ + u_char *red; /* red color map elements */ + u_char *green; /* green color map elements */ + u_char *blue; /* blue color map elements */ +}; +#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap) +#define FBIOGETCMAP _IOW('F', 4, struct fbcmap) + +/* + * Set/get attributes. + */ +#define FB_ATTR_NDEVSPECIFIC 8 /* no. of device specific values */ +#define FB_ATTR_NEMUTYPES 4 /* no. of emulation types */ + +struct fbsattr { + int flags; /* flags; see below */ + int emu_type; /* emulation type (-1 if unused) */ + int dev_specific[FB_ATTR_NDEVSPECIFIC]; /* catchall */ +}; +#define FB_ATTR_AUTOINIT 1 /* emulation auto init flag */ +#define FB_ATTR_DEVSPECIFIC 2 /* dev. specific stuff valid flag */ + +struct fbgattr { + int real_type; /* real device type */ + int owner; /* PID of owner, 0 if myself */ + struct fbtype fbtype; /* fbtype info for real device */ + struct fbsattr sattr; /* see above */ + int emu_types[FB_ATTR_NEMUTYPES]; /* possible emulations */ + /* (-1 if unused) */ +}; +#define FBIOSATTR _IOW('F', 5, struct fbsattr) +#define FBIOGATTR _IOR('F', 6, struct fbgattr) + +/* + * Video control. + */ +#define FBVIDEO_OFF 0 +#define FBVIDEO_ON 1 + +#define FBIOSVIDEO _IOW('F', 7, int) +#define FBIOGVIDEO _IOR('F', 8, int) + +/* vertical retrace */ +#define FBIOVERTICAL _IO('F', 9) + +/* + * Hardware cursor control (for, e.g., CG6). A rather complex and icky + * interface that smells like VMS, but there it is.... + */ +struct fbcurpos { + short x; + short y; +}; + +struct fbcursor { + short set; /* flags; see below */ + short enable; /* nonzero => cursor on, 0 => cursor off */ + struct fbcurpos pos; /* position on display */ + struct fbcurpos hot; /* hot-spot within cursor */ + struct fbcmap cmap; /* cursor color map */ + struct fbcurpos size; /* number of valid bits in image & mask */ + caddr_t image; /* cursor image bits */ + caddr_t mask; /* cursor mask bits */ +}; +#define FB_CUR_SETCUR 0x01 /* set on/off (i.e., obey fbcursor.enable) */ +#define FB_CUR_SETPOS 0x02 /* set position */ +#define FB_CUR_SETHOT 0x04 /* set hot-spot */ +#define FB_CUR_SETCMAP 0x08 /* set cursor color map */ +#define FB_CUR_SETSHAPE 0x10 /* set size & bits */ +#define FB_CUR_SETALL (FB_CUR_SETCUR | FB_CUR_SETPOS | FB_CUR_SETHOT | \ + FB_CUR_SETCMAP | FB_CUR_SETSHAPE) + +/* controls for cursor attributes & shape (including position) */ +#define FBIOSCURSOR _IOW('F', 24, struct fbcursor) +#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor) + +/* controls for cursor position only */ +#define FBIOSCURPOS _IOW('F', 26, struct fbcurpos) +#define FBIOGCURPOS _IOW('F', 27, struct fbcurpos) + +/* get maximum cursor size */ +#define FBIOGCURMAX _IOR('F', 28, struct fbcurpos) + +/* + * Video board information + */ +struct brd_info { + u_short accessible_width; /* accessible bytes in scanline */ + u_short accessible_height; /* number of accessible scanlines */ + u_short line_bytes; /* number of bytes/scanline */ + u_short hdb_capable; /* can this thing hardware db? */ + u_short vmsize; /* video memory size */ + u_char boardrev; /* board revision # */ + u_char pad0; + u_long pad1; +}; +#define FBIOGXINFO _IOR('F', 39, struct brd_info) + +/* + * Monitor information + */ +struct mon_info { + u_long mon_type; /* bit array */ +#define MON_TYPE_STEREO 0x8 /* stereo display */ +#define MON_TYPE_0_OFFSET 0x4 /* black level 0 ire instead of 7.5 */ +#define MON_TYPE_OVERSCAN 0x2 /* overscan */ +#define MON_TYPE_GRAY 0x1 /* greyscale monitor */ + u_long pixfreq; /* pixel frequency in Hz */ + u_long hfreq; /* horizontal freq in Hz */ + u_long vfreq; /* vertical freq in Hz */ + u_long vsync; /* vertical sync in scanlines */ + u_long hsync; /* horizontal sync in pixels */ + /* these are in pixel units */ + u_short hfporch; /* horizontal front porch */ + u_short hbporch; /* horizontal back porch */ + u_short vfporch; /* vertical front porch */ + u_short vbporch; /* vertical back porch */ +}; +#define FBIOMONINFO _IOR('F', 40, struct mon_info) + +/* + * Color map I/O. + */ +struct fbcmap_i { + unsigned int flags; +#define FB_CMAP_BLOCK (1 << 0) /* wait for vertical refresh */ +#define FB_CMAP_KERNEL (1 << 1) /* called within kernel */ + int id; /* color map id */ + int index; /* first element (0 origin) */ + int count; /* number of elements */ + u_char *red; /* red color map elements */ + u_char *green; /* green color map elements */ + u_char *blue; /* blue color map elements */ +}; +#define FBIOPUTCMAPI _IOW('F', 41, struct fbcmap_i) +#define FBIOGETCMAPI _IOW('F', 42, struct fbcmap_i) + +/* The new style frame buffer ioctls. */ + +/* video mode information block */ +struct video_info { + int vi_mode; /* mode number, see below */ + int vi_flags; +#define V_INFO_COLOR (1 << 0) +#define V_INFO_GRAPHICS (1 << 1) +#define V_INFO_LINEAR (1 << 2) +#define V_INFO_VESA (1 << 3) +#define V_INFO_NONVGA (1 << 4) +#define V_INFO_CWIDTH9 (1 << 5) + int vi_width; + int vi_height; + int vi_cwidth; + int vi_cheight; + int vi_depth; + int vi_planes; + vm_offset_t vi_window; /* physical address */ + size_t vi_window_size; + size_t vi_window_gran; + vm_offset_t vi_buffer; /* physical address */ + size_t vi_buffer_size; + int vi_mem_model; +#define V_INFO_MM_OTHER (-1) +#define V_INFO_MM_TEXT 0 +#define V_INFO_MM_PLANAR 1 +#define V_INFO_MM_PACKED 2 +#define V_INFO_MM_DIRECT 3 +#define V_INFO_MM_CGA 100 +#define V_INFO_MM_HGC 101 +#define V_INFO_MM_VGAX 102 + /* for MM_PACKED and MM_DIRECT only */ + int vi_pixel_size; /* in bytes */ + /* for MM_DIRECT only */ + int vi_pixel_fields[4]; /* RGB and reserved fields */ + int vi_pixel_fsizes[4]; + /* reserved */ + u_char vi_reserved[64]; + vm_offset_t vi_registers; /* physical address */ + vm_offset_t vi_registers_size; +}; +typedef struct video_info video_info_t; + +/* adapter infromation block */ +struct video_adapter { + int va_index; + int va_type; +#define KD_OTHER 0 /* unknown */ +#define KD_MONO 1 /* monochrome adapter */ +#define KD_HERCULES 2 /* hercules adapter */ +#define KD_CGA 3 /* color graphics adapter */ +#define KD_EGA 4 /* enhanced graphics adapter */ +#define KD_VGA 5 /* video graphics adapter */ +#define KD_TGA 7 /* TGA */ +#define KD_TGA2 8 /* TGA2 */ + char *va_name; + int va_unit; + int va_minor; + int va_flags; +#define V_ADP_COLOR (1 << 0) +#define V_ADP_MODECHANGE (1 << 1) +#define V_ADP_STATESAVE (1 << 2) +#define V_ADP_STATELOAD (1 << 3) +#define V_ADP_FONT (1 << 4) +#define V_ADP_PALETTE (1 << 5) +#define V_ADP_BORDER (1 << 6) +#define V_ADP_VESA (1 << 7) +#define V_ADP_BOOTDISPLAY (1 << 8) +#define V_ADP_PROBED (1 << 16) +#define V_ADP_INITIALIZED (1 << 17) +#define V_ADP_REGISTERED (1 << 18) +#define V_ADP_ATTACHED (1 << 19) +#define V_ADP_DAC8 (1 << 20) +#define V_ADP_CWIDTH9 (1 << 21) + vm_offset_t va_io_base; + int va_io_size; + vm_offset_t va_crtc_addr; + vm_offset_t va_mem_base; + int va_mem_size; + vm_offset_t va_window; /* virtual address */ + size_t va_window_size; + size_t va_window_gran; + u_int va_window_orig; + vm_offset_t va_buffer; /* virtual address */ + size_t va_buffer_size; + int va_initial_mode; + int va_initial_bios_mode; + int va_mode; + struct video_info va_info; + int va_line_width; + struct { + int x; + int y; + } va_disp_start; + void *va_token; + int va_model; + int va_little_bitian; + int va_little_endian; + int va_buffer_alias; + vm_offset_t va_registers; /* virtual address */ + vm_offset_t va_registers_size; +}; +typedef struct video_adapter video_adapter_t; + +struct video_adapter_info { + int va_index; + int va_type; + char va_name[16]; + int va_unit; + int va_flags; + vm_offset_t va_io_base; + int va_io_size; + vm_offset_t va_crtc_addr; + vm_offset_t va_mem_base; + int va_mem_size; + vm_offset_t va_window; /* virtual address */ + size_t va_window_size; + size_t va_window_gran; + vm_offset_t va_unused0; + size_t va_buffer_size; + int va_initial_mode; + int va_initial_bios_mode; + int va_mode; + int va_line_width; + struct { + int x; + int y; + } va_disp_start; + u_int va_window_orig; + /* reserved */ + u_char va_reserved[64]; +}; +typedef struct video_adapter_info video_adapter_info_t; + +/* some useful video adapter index */ +#define V_ADP_PRIMARY 0 +#define V_ADP_SECONDARY 1 + +/* video mode numbers */ + +#define M_B40x25 0 /* black & white 40 columns */ +#define M_C40x25 1 /* color 40 columns */ +#define M_B80x25 2 /* black & white 80 columns */ +#define M_C80x25 3 /* color 80 columns */ +#define M_BG320 4 /* black & white graphics 320x200 */ +#define M_CG320 5 /* color graphics 320x200 */ +#define M_BG640 6 /* black & white graphics 640x200 hi-res */ +#define M_EGAMONO80x25 7 /* ega-mono 80x25 */ +#define M_CG320_D 13 /* ega mode D */ +#define M_CG640_E 14 /* ega mode E */ +#define M_EGAMONOAPA 15 /* ega mode F */ +#define M_CG640x350 16 /* ega mode 10 */ +#define M_ENHMONOAPA2 17 /* ega mode F with extended memory */ +#define M_ENH_CG640 18 /* ega mode 10* */ +#define M_ENH_B40x25 19 /* ega enhanced black & white 40 columns */ +#define M_ENH_C40x25 20 /* ega enhanced color 40 columns */ +#define M_ENH_B80x25 21 /* ega enhanced black & white 80 columns */ +#define M_ENH_C80x25 22 /* ega enhanced color 80 columns */ +#define M_VGA_C40x25 23 /* vga 8x16 font on color */ +#define M_VGA_C80x25 24 /* vga 8x16 font on color */ +#define M_VGA_M80x25 25 /* vga 8x16 font on mono */ + +#define M_VGA11 26 /* vga 640x480 2 colors */ +#define M_BG640x480 26 +#define M_VGA12 27 /* vga 640x480 16 colors */ +#define M_CG640x480 27 +#define M_VGA13 28 /* vga 320x200 256 colors */ +#define M_VGA_CG320 28 + +#define M_VGA_C80x50 30 /* vga 8x8 font on color */ +#define M_VGA_M80x50 31 /* vga 8x8 font on color */ +#define M_VGA_C80x30 32 /* vga 8x16 font on color */ +#define M_VGA_M80x30 33 /* vga 8x16 font on color */ +#define M_VGA_C80x60 34 /* vga 8x8 font on color */ +#define M_VGA_M80x60 35 /* vga 8x8 font on color */ +#define M_VGA_CG640 36 /* vga 640x400 256 color */ +#define M_VGA_MODEX 37 /* vga 320x240 256 color */ + +#define M_VGA_C90x25 40 /* vga 8x16 font on color */ +#define M_VGA_M90x25 41 /* vga 8x16 font on mono */ +#define M_VGA_C90x30 42 /* vga 8x16 font on color */ +#define M_VGA_M90x30 43 /* vga 8x16 font on mono */ +#define M_VGA_C90x43 44 /* vga 8x8 font on color */ +#define M_VGA_M90x43 45 /* vga 8x8 font on mono */ +#define M_VGA_C90x50 46 /* vga 8x8 font on color */ +#define M_VGA_M90x50 47 /* vga 8x8 font on mono */ +#define M_VGA_C90x60 48 /* vga 8x8 font on color */ +#define M_VGA_M90x60 49 /* vga 8x8 font on mono */ + +#define M_ENH_B80x43 0x70 /* ega black & white 80x43 */ +#define M_ENH_C80x43 0x71 /* ega color 80x43 */ + +#define M_HGC_P0 0xe0 /* hercules graphics - page 0 @ B0000 */ +#define M_HGC_P1 0xe1 /* hercules graphics - page 1 @ B8000 */ +#define M_MCA_MODE 0xff /* monochrome adapter mode */ + +#define M_TEXT_80x25 200 /* generic text modes */ +#define M_TEXT_80x30 201 +#define M_TEXT_80x43 202 +#define M_TEXT_80x50 203 +#define M_TEXT_80x60 204 +#define M_TEXT_132x25 205 +#define M_TEXT_132x30 206 +#define M_TEXT_132x43 207 +#define M_TEXT_132x50 208 +#define M_TEXT_132x60 209 + +#define M_VESA_BASE 0x100 /* VESA mode number base */ +#define M_VESA_CG640x400 0x100 /* 640x400, 256 color */ +#define M_VESA_CG640x480 0x101 /* 640x480, 256 color */ +#define M_VESA_800x600 0x102 /* 800x600, 16 color */ +#define M_VESA_CG800x600 0x103 /* 800x600, 256 color */ +#define M_VESA_1024x768 0x104 /* 1024x768, 16 color */ +#define M_VESA_CG1024x768 0x105 /* 1024x768, 256 color */ +#define M_VESA_1280x1024 0x106 /* 1280x1024, 16 color */ +#define M_VESA_CG1280x1024 0x107 /* 1280x1024, 256 color */ +#define M_VESA_C80x60 0x108 /* 8x8 font */ +#define M_VESA_C132x25 0x109 /* 8x16 font */ +#define M_VESA_C132x43 0x10a /* 8x14 font */ +#define M_VESA_C132x50 0x10b /* 8x8 font */ +#define M_VESA_C132x60 0x10c /* 8x8 font */ +#define M_VESA_32K_320 0x10d /* 320x200, 5:5:5 */ +#define M_VESA_64K_320 0x10e /* 320x200, 5:6:5 */ +#define M_VESA_FULL_320 0x10f /* 320x200, 8:8:8 */ +#define M_VESA_32K_640 0x110 /* 640x480, 5:5:5 */ +#define M_VESA_64K_640 0x111 /* 640x480, 5:6:5 */ +#define M_VESA_FULL_640 0x112 /* 640x480, 8:8:8 */ +#define M_VESA_32K_800 0x113 /* 800x600, 5:5:5 */ +#define M_VESA_64K_800 0x114 /* 800x600, 5:6:5 */ +#define M_VESA_FULL_800 0x115 /* 800x600, 8:8:8 */ +#define M_VESA_32K_1024 0x116 /* 1024x768, 5:5:5 */ +#define M_VESA_64K_1024 0x117 /* 1024x768, 5:6:5 */ +#define M_VESA_FULL_1024 0x118 /* 1024x768, 8:8:8 */ +#define M_VESA_32K_1280 0x119 /* 1280x1024, 5:5:5 */ +#define M_VESA_64K_1280 0x11a /* 1280x1024, 5:6:5 */ +#define M_VESA_FULL_1280 0x11b /* 1280x1024, 8:8:8 */ +#define M_VESA_MODE_MAX 0x1ff + +struct video_display_start { + int x; + int y; +}; +typedef struct video_display_start video_display_start_t; + +struct video_color_palette { + int index; /* first element (zero-based) */ + int count; /* number of elements */ + u_char *red; /* red */ + u_char *green; /* green */ + u_char *blue; /* blue */ + u_char *transparent; /* may be NULL */ +}; +typedef struct video_color_palette video_color_palette_t; + +/* adapter info. */ +#define FBIO_ADAPTER _IOR('F', 100, int) +#define FBIO_ADPTYPE _IOR('F', 101, int) +#define FBIO_ADPINFO _IOR('F', 102, struct video_adapter_info) + +/* video mode control */ +#define FBIO_MODEINFO _IOWR('F', 103, struct video_info) +#define FBIO_FINDMODE _IOWR('F', 104, struct video_info) +#define FBIO_GETMODE _IOR('F', 105, int) +#define FBIO_SETMODE _IOW('F', 106, int) + +/* get/set frame buffer window origin */ +#define FBIO_GETWINORG _IOR('F', 107, u_int) +#define FBIO_SETWINORG _IOW('F', 108, u_int) + +/* get/set display start address */ +#define FBIO_GETDISPSTART _IOR('F', 109, video_display_start_t) +#define FBIO_SETDISPSTART _IOW('F', 110, video_display_start_t) + +/* get/set scan line width */ +#define FBIO_GETLINEWIDTH _IOR('F', 111, u_int) +#define FBIO_SETLINEWIDTH _IOW('F', 112, u_int) + +/* color palette control */ +#define FBIO_GETPALETTE _IOW('F', 113, video_color_palette_t) +#define FBIO_SETPALETTE _IOW('F', 114, video_color_palette_t) + +/* blank display */ +#define V_DISPLAY_ON 0 +#define V_DISPLAY_BLANK 1 +#define V_DISPLAY_STAND_BY 2 +#define V_DISPLAY_SUSPEND 3 + +#define FBIO_BLANK _IOW('F', 115, int) + +#endif /* !_SYS_FBIO_H_ */ diff --git a/freebsd/sys/sys/terminal.h b/freebsd/sys/sys/terminal.h new file mode 100644 index 00000000..e3413a79 --- /dev/null +++ b/freebsd/sys/sys/terminal.h @@ -0,0 +1,240 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2009 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Ed Schouten under sponsorship from the + * FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_TERMINAL_H_ +#define _SYS_TERMINAL_H_ + +#include <sys/param.h> +#include <sys/_lock.h> +#include <sys/_mutex.h> +#include <sys/cons.h> +#include <sys/linker_set.h> +#include <sys/ttycom.h> + +#include <teken/teken.h> + +#include <rtems/bsd/local/opt_syscons.h> +#include <rtems/bsd/local/opt_teken.h> + +struct terminal; +struct thread; +struct tty; + +/* + * The terminal layer is an abstraction on top of the TTY layer and the + * console interface. It can be used by system console drivers to + * easily interact with the kernel console and TTYs. + * + * Terminals contain terminal emulators, which means console drivers + * don't need to implement their own terminal emulator. The terminal + * emulator deals with UTF-8 exclusively. This means that term_char_t, + * the data type used to store input/output characters will always + * contain Unicode codepoints. + * + * To save memory usage, the top bits of term_char_t will contain other + * attributes, like colors. Right now term_char_t is composed as + * follows: + * + * Bits Meaning + * 0-20: Character value + * 21-25: Bold, underline, blink, reverse, right part of CJK fullwidth character + * 26-28: Foreground color + * 29-31: Background color + */ + +typedef uint32_t term_char_t; +#define TCHAR_CHARACTER(c) ((c) & 0x1fffff) +#define TCHAR_FORMAT(c) (((c) >> 21) & 0x1f) +#define TCHAR_FGCOLOR(c) (((c) >> 26) & 0x7) +#define TCHAR_BGCOLOR(c) (((c) >> 29) & 0x7) + +typedef teken_attr_t term_attr_t; + +typedef teken_color_t term_color_t; +#define TCOLOR_FG(c) (((c) & 0x7) << 26) +#define TCOLOR_BG(c) (((c) & 0x7) << 29) +#define TCOLOR_LIGHT(c) ((c) | 0x8) +#define TCOLOR_DARK(c) ((c) & ~0x8) + +#define TFORMAT(c) (((c) & 0x1f) << 21) + +/* syscons(4) compatible color attributes for foreground text */ +#define FG_BLACK TCOLOR_FG(TC_BLACK) +#define FG_BLUE TCOLOR_FG(TC_BLUE) +#define FG_GREEN TCOLOR_FG(TC_GREEN) +#define FG_CYAN TCOLOR_FG(TC_CYAN) +#define FG_RED TCOLOR_FG(TC_RED) +#define FG_MAGENTA TCOLOR_FG(TC_MAGENTA) +#define FG_BROWN TCOLOR_FG(TC_BROWN) +#define FG_LIGHTGREY TCOLOR_FG(TC_WHITE) +#define FG_DARKGREY (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_BLACK)) +#define FG_LIGHTBLUE (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_BLUE)) +#define FG_LIGHTGREEN (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_GREEN)) +#define FG_LIGHTCYAN (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_CYAN)) +#define FG_LIGHTRED (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_RED)) +#define FG_LIGHTMAGENTA (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_MAGENTA)) +#define FG_YELLOW (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_BROWN)) +#define FG_WHITE (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_WHITE)) +#define FG_BLINK TFORMAT(TF_BLINK) + +/* syscons(4) compatible color attributes for text background */ +#define BG_BLACK TCOLOR_BG(TC_BLACK) +#define BG_BLUE TCOLOR_BG(TC_BLUE) +#define BG_GREEN TCOLOR_BG(TC_GREEN) +#define BG_CYAN TCOLOR_BG(TC_CYAN) +#define BG_RED TCOLOR_BG(TC_RED) +#define BG_MAGENTA TCOLOR_BG(TC_MAGENTA) +#define BG_BROWN TCOLOR_BG(TC_BROWN) +#define BG_LIGHTGREY TCOLOR_BG(TC_WHITE) +#define BG_DARKGREY (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_BLACK)) +#define BG_LIGHTBLUE (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_BLUE)) +#define BG_LIGHTGREEN (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_GREEN)) +#define BG_LIGHTCYAN (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_CYAN)) +#define BG_LIGHTRED (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_RED)) +#define BG_LIGHTMAGENTA (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_MAGENTA)) +#define BG_YELLOW (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_BROWN)) +#define BG_WHITE (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_WHITE)) + +#ifndef TERMINAL_NORM_ATTR +#ifdef SC_NORM_ATTR +#define TERMINAL_NORM_ATTR SC_NORM_ATTR +#else +#define TERMINAL_NORM_ATTR (FG_LIGHTGREY | BG_BLACK) +#endif +#endif + +#ifndef TERMINAL_KERN_ATTR +#ifdef SC_KERNEL_CONS_ATTR +#define TERMINAL_KERN_ATTR SC_KERNEL_CONS_ATTR +#else +#define TERMINAL_KERN_ATTR (FG_WHITE | BG_BLACK) +#endif +#endif + +typedef teken_pos_t term_pos_t; +typedef teken_rect_t term_rect_t; + +typedef void tc_cursor_t(struct terminal *tm, const term_pos_t *p); +typedef void tc_putchar_t(struct terminal *tm, const term_pos_t *p, + term_char_t c); +typedef void tc_fill_t(struct terminal *tm, const term_rect_t *r, + term_char_t c); +typedef void tc_copy_t(struct terminal *tm, const term_rect_t *r, + const term_pos_t *p); +typedef void tc_pre_input_t(struct terminal *tm); +typedef void tc_post_input_t(struct terminal *tm); +typedef void tc_param_t(struct terminal *tm, int cmd, unsigned int arg); +typedef void tc_done_t(struct terminal *tm); + +typedef void tc_cnprobe_t(struct terminal *tm, struct consdev *cd); +typedef int tc_cngetc_t(struct terminal *tm); + +typedef void tc_cngrab_t(struct terminal *tm); +typedef void tc_cnungrab_t(struct terminal *tm); + +typedef void tc_opened_t(struct terminal *tm, int opened); +typedef int tc_ioctl_t(struct terminal *tm, u_long cmd, caddr_t data, + struct thread *td); +typedef int tc_mmap_t(struct terminal *tm, vm_ooffset_t offset, + vm_paddr_t * paddr, int nprot, vm_memattr_t *memattr); +typedef void tc_bell_t(struct terminal *tm); + +struct terminal_class { + /* Terminal emulator. */ + tc_cursor_t *tc_cursor; + tc_putchar_t *tc_putchar; + tc_fill_t *tc_fill; + tc_copy_t *tc_copy; + tc_pre_input_t *tc_pre_input; + tc_post_input_t *tc_post_input; + tc_param_t *tc_param; + tc_done_t *tc_done; + + /* Low-level console interface. */ + tc_cnprobe_t *tc_cnprobe; + tc_cngetc_t *tc_cngetc; + + /* DDB & panic handling. */ + tc_cngrab_t *tc_cngrab; + tc_cnungrab_t *tc_cnungrab; + + /* Misc. */ + tc_opened_t *tc_opened; + tc_ioctl_t *tc_ioctl; + tc_mmap_t *tc_mmap; + tc_bell_t *tc_bell; +}; + +struct terminal { + const struct terminal_class *tm_class; + void *tm_softc; + struct mtx tm_mtx; + struct tty *tm_tty; + teken_t tm_emulator; + struct winsize tm_winsize; + unsigned int tm_flags; +#define TF_MUTE 0x1 /* Drop incoming data. */ +#define TF_BELL 0x2 /* Bell needs to be sent. */ +#define TF_CONS 0x4 /* Console device (needs spinlock). */ + struct consdev *consdev; +}; + +#ifdef _KERNEL + +struct terminal *terminal_alloc(const struct terminal_class *tc, void *softc); +void terminal_maketty(struct terminal *tm, const char *fmt, ...); +void terminal_set_cursor(struct terminal *tm, const term_pos_t *pos); +void terminal_set_winsize_blank(struct terminal *tm, + const struct winsize *size, int blank, const term_attr_t *attr); +void terminal_set_winsize(struct terminal *tm, const struct winsize *size); +void terminal_mute(struct terminal *tm, int yes); +void terminal_input_char(struct terminal *tm, term_char_t c); +void terminal_input_raw(struct terminal *tm, char c); +void terminal_input_special(struct terminal *tm, unsigned int k); + +void termcn_cnregister(struct terminal *tm); + +/* Kernel console helper interface. */ +extern const struct consdev_ops termcn_cnops; + +#define TERMINAL_DECLARE_EARLY(name, class, softc) \ + static struct terminal name = { \ + .tm_class = &class, \ + .tm_softc = softc, \ + .tm_flags = TF_CONS, \ + }; \ + CONSOLE_DEVICE(name ## _consdev, termcn_cnops, &name) + +#endif /* _KERNEL */ + +#endif /* !_SYS_TERMINAL_H_ */ |