vt.h revision 265391
156167Sru/*- 2100518Sru * Copyright (c) 2009, 2013 The FreeBSD Foundation 3100518Sru * All rights reserved. 442688Smarkm * 593144Sru * This software was developed by Ed Schouten under sponsorship from the 693144Sru * FreeBSD Foundation. 793144Sru * 842688Smarkm * Portions of this software were developed by Oleksandr Rybalko 942688Smarkm * under sponsorship from the FreeBSD Foundation. 10100518Sru * 1193144Sru * Redistribution and use in source and binary forms, with or without 1293144Sru * modification, are permitted provided that the following conditions 1393144Sru * are met: 1493144Sru * 1. Redistributions of source code must retain the above copyright 1593144Sru * notice, this list of conditions and the following disclaimer. 1693144Sru * 2. Redistributions in binary form must reproduce the above copyright 17100518Sru * notice, this list of conditions and the following disclaimer in the 1893144Sru * documentation and/or other materials provided with the distribution. 1993144Sru * 20100518Sru * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2142688Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2242688Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23100518Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24100518Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2542688Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2642688Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27100518Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2893144Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2942688Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30100518Sru * SUCH DAMAGE. 3193144Sru * 3242688Smarkm * $FreeBSD: head/sys/dev/vt/vt.h 265391 2014-05-05 21:29:56Z ray $ 3393144Sru */ 3493144Sru 3593144Sru#ifndef _DEV_VT_VT_H_ 3656167Sru#define _DEV_VT_VT_H_ 37114479Sru 38114479Sru#include <sys/param.h> 39114479Sru#include <sys/_lock.h> 40114479Sru#include <sys/_mutex.h> 4193144Sru#include <sys/callout.h> 4293144Sru#include <sys/condvar.h> 4342688Smarkm#include <sys/conf.h> 4493144Sru#include <sys/consio.h> 4593144Sru#include <sys/kbio.h> 4642688Smarkm#include <sys/mouse.h> 4793144Sru#include <sys/terminal.h> 4893144Sru#include <sys/sysctl.h> 4942688Smarkm 5093144Sru#include "opt_syscons.h" 5193144Sru#include "opt_splash.h" 5242688Smarkm 53100518Sru#ifdef DEV_SC 5493144Sru#error "Build with both syscons and vt is not supported. Please enable only \ 5542688Smarkmone 'device sc' or 'device vt'" 56100518Sru#endif 5793144Sru 5842688Smarkm#ifndef VT_MAXWINDOWS 59100518Sru#ifdef MAXCONS 60114479Sru#define VT_MAXWINDOWS MAXCONS 6142688Smarkm#else 62100518Sru#define VT_MAXWINDOWS 12 6393144Sru#endif 6442688Smarkm#endif 65100518Sru 6693144Sru#ifndef VT_ALT_TO_ESC_HACK 6742688Smarkm#define VT_ALT_TO_ESC_HACK 1 68100518Sru#endif 69114479Sru 7042688Smarkm#define VT_CONSWINDOW 0 71100518Sru 7293144Sru#if defined(SC_TWOBUTTON_MOUSE) || defined(VT_TWOBUTTON_MOUSE) 7356167Sru#define VT_MOUSE_PASTEBUTTON MOUSE_BUTTON3DOWN /* right button */ 74100518Sru#define VT_MOUSE_EXTENDBUTTON MOUSE_BUTTON2DOWN /* not really used */ 7593144Sru#else 7642688Smarkm#define VT_MOUSE_PASTEBUTTON MOUSE_BUTTON2DOWN /* middle button */ 77100518Sru#define VT_MOUSE_EXTENDBUTTON MOUSE_BUTTON3DOWN /* right button */ 7893144Sru#endif /* defined(SC_TWOBUTTON_MOUSE) || defined(VT_TWOBUTTON_MOUSE) */ 7942688Smarkm 80100518Sru#define SC_DRIVER_NAME "vt" 8193144Sru#define DPRINTF(_l, ...) if (vt_debug > (_l)) printf( __VA_ARGS__ ) 8242688Smarkm#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) 8393144Sru 8442688Smarkm#define VT_SYSCTL_INT(_name, _default, _descr) \ 8542688Smarkmstatic int vt_##_name = _default; \ 86114479SruSYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RW, &vt_##_name, _default,\ 87114479Sru _descr); \ 88114479SruTUNABLE_INT("kern.vt." #_name, &vt_##_name); 89100518Sru 9093144Srustruct vt_driver; 9142688Smarkm 9293144Sruvoid vt_allocate(struct vt_driver *, void *); 9393144Sruvoid vt_resume(void); 9442688Smarkmvoid vt_suspend(void); 95114479Sru 9693144Srutypedef unsigned int vt_axis_t; 9742688Smarkm 98114479Sru/* 99114479Sru * List of locks 100114479Sru * (d) locked by vd_lock 101114479Sru * (b) locked by vb_lock 102100518Sru * (G) locked by Giant 10393144Sru * (u) unlocked, locked by higher levels 10442688Smarkm * (c) const until freeing 10593144Sru * (?) yet to be determined 10693144Sru */ 10742688Smarkm 10893144Sru/* 10993144Sru * Per-device datastructure. 11042688Smarkm */ 111100518Sru 11293144Srustruct vt_device { 11342688Smarkm struct vt_window *vd_windows[VT_MAXWINDOWS]; /* (c) Windows. */ 114100518Sru struct vt_window *vd_curwindow; /* (d) Current window. */ 11593144Sru struct vt_window *vd_savedwindow;/* (?) Saved for suspend. */ 11642688Smarkm struct vt_window *vd_markedwin; /* (?) Copy/paste buf owner. */ 117100518Sru const struct vt_driver *vd_driver; /* (c) Graphics driver. */ 11893144Sru void *vd_softc; /* (u) Driver data. */ 11942688Smarkm uint16_t vd_mx; /* (?) Mouse X. */ 120100518Sru uint16_t vd_my; /* (?) Mouse Y. */ 121114479Sru vt_axis_t vd_mdirtyx; /* (?) Screen width. */ 12293144Sru vt_axis_t vd_mdirtyy; /* (?) Screen height. */ 123100518Sru uint32_t vd_mstate; /* (?) Mouse state. */ 12442688Smarkm term_pos_t vd_offset; /* (?) Pixel offset. */ 12542688Smarkm vt_axis_t vd_width; /* (?) Screen width. */ 126100518Sru vt_axis_t vd_height; /* (?) Screen height. */ 12742688Smarkm struct mtx vd_lock; /* Per-device lock. */ 12842688Smarkm struct cv vd_winswitch; /* (d) Window switch notify. */ 129100518Sru struct callout vd_timer; /* (d) Display timer. */ 13093144Sru int vd_flags; /* (d) Device flags. */ 13193144Sru#define VDF_TEXTMODE 0x01 /* Do text mode rendering. */ 132100518Sru#define VDF_SPLASH 0x02 /* Splash screen active. */ 13393144Sru#define VDF_ASYNC 0x04 /* vt_timer() running. */ 13493144Sru#define VDF_INVALID 0x08 /* Entire screen should be re-rendered. */ 135100518Sru#define VDF_DEAD 0x10 /* Early probing found nothing. */ 13642688Smarkm#define VDF_INITIALIZED 0x20 /* vtterm_cnprobe already done. */ 13742688Smarkm#define VDF_MOUSECURSOR 0x40 /* Mouse cursor visible. */ 138114479Sru#define VDF_QUIET_BELL 0x80 /* Disable bell. */ 139114479Sru int vd_keyboard; /* (G) Keyboard index. */ 140114479Sru unsigned int vd_kbstate; /* (?) Device unit. */ 141100518Sru unsigned int vd_unit; /* (c) Device unit. */ 14293144Sru}; 14393144Sru 144100518Sru/* 14542688Smarkm * Per-window terminal screen buffer. 14642688Smarkm * 147100518Sru * Because redrawing is performed asynchronously, the buffer keeps track 14893144Sru * of a rectangle that needs to be redrawn (vb_dirtyrect). Because this 14993144Sru * approach seemed to cause suboptimal performance (when the top left 150100518Sru * and the bottom right of the screen are modified), it also uses a set 15193144Sru * of bitmasks to keep track of the rows and columns (mod 64) that have 15293144Sru * been modified. 153100518Sru */ 15442688Smarkm 15542688Smarkmstruct vt_bufmask { 156100518Sru uint64_t vbm_row, vbm_col; 15793144Sru#define VBM_DIRTY UINT64_MAX 15893144Sru}; 159100518Sru 16042688Smarkmstruct vt_buf { 16142688Smarkm struct mtx vb_lock; /* Buffer lock. */ 162100518Sru term_pos_t vb_scr_size; /* (b) Screen dimensions. */ 16342688Smarkm int vb_flags; /* (b) Flags. */ 16442688Smarkm#define VBF_CURSOR 0x1 /* Cursor visible. */ 165100518Sru#define VBF_STATIC 0x2 /* Buffer is statically allocated. */ 16642688Smarkm#define VBF_MTX_INIT 0x4 /* Mutex initialized. */ 16742688Smarkm#define VBF_SCROLL 0x8 /* scroll locked mode. */ 168114479Sru#define VBF_HISTORY_FULL 0x10 /* All rows filled. */ 169114479Sru int vb_history_size; 170114479Sru#define VBF_DEFAULT_HISTORY_SIZE 500 171100518Sru int vb_roffset; /* (b) History rows offset. */ 17242688Smarkm int vb_curroffset; /* (b) Saved rows offset. */ 17342688Smarkm term_pos_t vb_cursor; /* (u) Cursor position. */ 174100518Sru term_pos_t vb_mark_start; /* (b) Copy region start. */ 17542688Smarkm term_pos_t vb_mark_end; /* (b) Copy region end. */ 17642688Smarkm int vb_mark_last; /* Last mouse event. */ 177100518Sru term_rect_t vb_dirtyrect; /* (b) Dirty rectangle. */ 17893144Sru struct vt_bufmask vb_dirtymask; /* (b) Dirty bitmasks. */ 17993144Sru term_char_t *vb_buffer; /* (u) Data buffer. */ 180100518Sru term_char_t **vb_rows; /* (u) Array of rows */ 181114479Sru}; 18293144Sru 183114479Sruvoid vtbuf_copy(struct vt_buf *, const term_rect_t *, const term_pos_t *); 184114479Sruvoid vtbuf_fill_locked(struct vt_buf *, const term_rect_t *, term_char_t); 185114479Sruvoid vtbuf_init_early(struct vt_buf *); 186114479Sruvoid vtbuf_init(struct vt_buf *, const term_pos_t *); 187100518Sruvoid vtbuf_grow(struct vt_buf *, const term_pos_t *, int); 18893144Sruvoid vtbuf_putchar(struct vt_buf *, const term_pos_t *, term_char_t); 18993144Sruvoid vtbuf_cursor_position(struct vt_buf *, const term_pos_t *); 190100518Sruvoid vtbuf_scroll_mode(struct vt_buf *vb, int yes); 191114479Sruvoid vtbuf_undirty(struct vt_buf *, term_rect_t *, struct vt_bufmask *); 19242688Smarkmvoid vtbuf_sethistory_size(struct vt_buf *, int); 193100518Sruint vtbuf_iscursor(struct vt_buf *vb, int row, int col); 19442688Smarkmvoid vtbuf_cursor_visibility(struct vt_buf *, int); 19542688Smarkm#ifndef SC_NO_CUTPASTE 196100518Sruvoid vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row); 19742688Smarkmint vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row); 19842688Smarkmint vtbuf_get_marked_len(struct vt_buf *vb); 199100518Sruvoid vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz); 200100518Sru#endif 20193144Sru 20293144Sru#define VTB_MARK_NONE 0 203100518Sru#define VTB_MARK_END 1 20442688Smarkm#define VTB_MARK_START 2 20542688Smarkm#define VTB_MARK_WORD 3 206100518Sru#define VTB_MARK_ROW 4 20742688Smarkm#define VTB_MARK_EXTEND 5 20842688Smarkm#define VTB_MARK_MOVE 6 209100518Sru 21093144Sru#define VTBUF_SLCK_ENABLE(vb) vtbuf_scroll_mode((vb), 1) 21156167Sru#define VTBUF_SLCK_DISABLE(vb) vtbuf_scroll_mode((vb), 0) 212100518Sru 21393144Sru#define VTBUF_MAX_HEIGHT(vb) \ 21442688Smarkm ((vb)->vb_history_size) 215100518Sru#define VTBUF_GET_ROW(vb, r) \ 21693144Sru ((vb)->vb_rows[((vb)->vb_roffset + (r)) % VTBUF_MAX_HEIGHT(vb)]) 21742688Smarkm#define VTBUF_GET_FIELD(vb, r, c) \ 218100518Sru ((vb)->vb_rows[((vb)->vb_roffset + (r)) % VTBUF_MAX_HEIGHT(vb)][(c)]) 21993144Sru#define VTBUF_FIELD(vb, r, c) \ 22042688Smarkm ((vb)->vb_rows[((vb)->vb_curroffset + (r)) % VTBUF_MAX_HEIGHT(vb)][(c)]) 221100518Sru#define VTBUF_ISCURSOR(vb, r, c) \ 22242688Smarkm vtbuf_iscursor((vb), (r), (c)) 22342688Smarkm#define VTBUF_DIRTYROW(mask, row) \ 224100518Sru ((mask)->vbm_row & ((uint64_t)1 << ((row) % 64))) 22542688Smarkm#define VTBUF_DIRTYCOL(mask, col) \ 22642688Smarkm ((mask)->vbm_col & ((uint64_t)1 << ((col) % 64))) 227100518Sru#define VTBUF_SPACE_CHAR (' ' | TC_WHITE << 26 | TC_BLACK << 29) 22842688Smarkm 22942688Smarkm#define VHS_SET 0 230100518Sru#define VHS_CUR 1 23142688Smarkm#define VHS_END 2 23242688Smarkmint vthistory_seek(struct vt_buf *, int offset, int whence); 233100518Sruvoid vthistory_addlines(struct vt_buf *vb, int offset); 23493144Sruvoid vthistory_getpos(const struct vt_buf *, unsigned int *offset); 23593144Sru 236114479Sru/* 237114479Sru * Per-window datastructure. 238114479Sru */ 239100518Sru 24042688Smarkmstruct vt_window { 24142688Smarkm struct vt_device *vw_device; /* (c) Device. */ 242100518Sru struct terminal *vw_terminal; /* (c) Terminal. */ 24342688Smarkm struct vt_buf vw_buf; /* (u) Screen buffer. */ 24442688Smarkm struct vt_font *vw_font; /* (d) Graphical font. */ 245100518Sru unsigned int vw_number; /* (c) Window number. */ 24693144Sru int vw_kbdmode; /* (?) Keyboard mode. */ 24793144Sru char *vw_kbdsq; /* Escape sequence queue*/ 248100518Sru unsigned int vw_flags; /* (d) Per-window flags. */ 24942688Smarkm int vw_mouse_level;/* Mouse op mode. */ 25042688Smarkm#define VWF_BUSY 0x1 /* Busy reconfiguring device. */ 251100518Sru#define VWF_OPENED 0x2 /* TTY in use. */ 25242688Smarkm#define VWF_SCROLL 0x4 /* Keys influence scrollback. */ 25342688Smarkm#define VWF_CONSOLE 0x8 /* Kernel message console window. */ 254100518Sru#define VWF_VTYLOCK 0x10 /* Prevent window switch. */ 25593144Sru#define VWF_MOUSE_HIDE 0x20 /* Disable mouse events processing. */ 25693144Sru#define VWF_SWWAIT_REL 0x10000 /* Program wait for VT acquire is done. */ 257100518Sru#define VWF_SWWAIT_ACQ 0x20000 /* Program wait for VT release is done. */ 25842688Smarkm pid_t vw_pid; /* Terminal holding process */ 25942688Smarkm struct proc *vw_proc; 260100518Sru struct vt_mode vw_smode; /* switch mode */ 26193144Sru struct callout vw_proc_dead_timer; 26242688Smarkm struct vt_window *vw_switch_to; 263114479Sru}; 264114479Sru 265114479Sru#define VT_AUTO 0 /* switching is automatic */ 266100518Sru#define VT_PROCESS 1 /* switching controlled by prog */ 26742688Smarkm#define VT_KERNEL 255 /* switching controlled in kernel */ 26842688Smarkm 269114479Sru#define IS_VT_PROC_MODE(vw) ((vw)->vw_smode.mode == VT_PROCESS) 270114479Sru 271114479Sru/* 272100518Sru * Per-device driver routines. 27393144Sru * 27442688Smarkm * vd_bitbltchr is used when the driver operates in graphics mode, while 275100518Sru * vd_putchar is used when the driver operates in text mode 27693144Sru * (VDF_TEXTMODE). 27742688Smarkm */ 278100518Sru 27993144Srutypedef int vd_init_t(struct vt_device *vd); 28093144Srutypedef int vd_probe_t(struct vt_device *vd); 281100518Srutypedef void vd_postswitch_t(struct vt_device *vd); 28293144Srutypedef void vd_blank_t(struct vt_device *vd, term_color_t color); 28393144Srutypedef void vd_bitbltchr_t(struct vt_device *vd, const uint8_t *src, 284116532Sru const uint8_t *mask, int bpl, vt_axis_t top, vt_axis_t left, 285116532Sru unsigned int width, unsigned int height, term_color_t fg, term_color_t bg); 286116532Srutypedef void vd_maskbitbltchr_t(struct vt_device *vd, const uint8_t *src, 287114479Sru const uint8_t *mask, int bpl, vt_axis_t top, vt_axis_t left, 288114479Sru unsigned int width, unsigned int height, term_color_t fg, term_color_t bg); 289114479Srutypedef void vd_putchar_t(struct vt_device *vd, term_char_t, 29093144Sru vt_axis_t top, vt_axis_t left, term_color_t fg, term_color_t bg); 29193144Srutypedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *); 29293144Srutypedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int, 293114479Sru vm_memattr_t *); 294114479Srutypedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int, 295114479Sru term_color_t); 29656167Srutypedef void vd_setpixel_t(struct vt_device *, int, int, term_color_t); 29756167Sru 29842688Smarkmstruct vt_driver { 299100518Sru char vd_name[16]; 300100518Sru /* Console attachment. */ 301100518Sru vd_probe_t *vd_probe; 302100518Sru vd_init_t *vd_init; 303100518Sru 304100518Sru /* Drawing. */ 305100518Sru vd_blank_t *vd_blank; 306116532Sru vd_bitbltchr_t *vd_bitbltchr; 307100518Sru vd_maskbitbltchr_t *vd_maskbitbltchr; 308100518Sru vd_drawrect_t *vd_drawrect; 309100518Sru vd_setpixel_t *vd_setpixel; 310100518Sru 311100518Sru /* Framebuffer ioctls, if present. */ 312116532Sru vd_fb_ioctl_t *vd_fb_ioctl; 313100518Sru 314114479Sru /* Framebuffer mmap, if present. */ 315114479Sru vd_fb_mmap_t *vd_fb_mmap; 316114479Sru 31793144Sru /* Text mode operation. */ 31893144Sru vd_putchar_t *vd_putchar; 31993144Sru 32093144Sru /* Update display setting on vt switch. */ 32193144Sru vd_postswitch_t *vd_postswitch; 32293144Sru 32393144Sru /* Priority to know which one can override */ 32493144Sru int vd_priority; 32593144Sru#define VD_PRIORITY_DUMB 10 32693144Sru#define VD_PRIORITY_GENERIC 100 32793144Sru#define VD_PRIORITY_SPECIFIC 1000 328100518Sru}; 32993144Sru 33093144Sru/* 331100518Sru * Console device madness. 33293144Sru * 33393144Sru * Utility macro to make early vt(4) instances work. 334100518Sru */ 33593144Sru 33693144Sruextern const struct terminal_class vt_termclass; 33756167Sruvoid vt_upgrade(struct vt_device *vd); 338116532Sru 33942688Smarkm#define PIXEL_WIDTH(w) ((w) / 8) 340100518Sru#define PIXEL_HEIGHT(h) ((h) / 16) 34193144Sru 34256167Sru#ifndef VT_FB_DEFAULT_WIDTH 343100518Sru#define VT_FB_DEFAULT_WIDTH 2048 344100518Sru#endif 34593144Sru#ifndef VT_FB_DEFAULT_HEIGHT 34656167Sru#define VT_FB_DEFAULT_HEIGHT 1200 347100518Sru#endif 34893144Sru 34956167Sru#define VT_CONSDEV_DECLARE(driver, width, height, softc) \ 35093144Srustatic struct terminal driver ## _consterm; \ 35193144Srustatic struct vt_window driver ## _conswindow; \ 35256167Srustatic struct vt_device driver ## _consdev = { \ 35393144Sru .vd_driver = &driver, \ 35493144Sru .vd_softc = (softc), \ 35593144Sru .vd_flags = VDF_INVALID, \ 35656167Sru .vd_windows = { [VT_CONSWINDOW] = &driver ## _conswindow, }, \ 357114479Sru .vd_curwindow = &driver ## _conswindow, \ 358114479Sru .vd_markedwin = NULL, \ 359114479Sru .vd_kbstate = 0, \ 36093144Sru}; \ 36193144Srustatic term_char_t driver ## _constextbuf[(width) * \ 36256167Sru (VBF_DEFAULT_HISTORY_SIZE)]; \ 36393144Srustatic term_char_t *driver ## _constextbufrows[ \ 36493144Sru VBF_DEFAULT_HISTORY_SIZE]; \ 365114479Srustatic struct vt_window driver ## _conswindow = { \ 366114479Sru .vw_number = VT_CONSWINDOW, \ 367114479Sru .vw_flags = VWF_CONSOLE, \ 368114479Sru .vw_buf = { \ 369 .vb_buffer = driver ## _constextbuf, \ 370 .vb_rows = driver ## _constextbufrows, \ 371 .vb_history_size = VBF_DEFAULT_HISTORY_SIZE, \ 372 .vb_curroffset = 0, \ 373 .vb_roffset = 0, \ 374 .vb_flags = VBF_STATIC, \ 375 .vb_mark_start = { \ 376 .tp_row = 0, \ 377 .tp_col = 0, \ 378 }, \ 379 .vb_mark_end = { \ 380 .tp_row = 0, \ 381 .tp_col = 0, \ 382 }, \ 383 .vb_scr_size = { \ 384 .tp_row = height, \ 385 .tp_col = width, \ 386 }, \ 387 }, \ 388 .vw_device = &driver ## _consdev, \ 389 .vw_terminal = &driver ## _consterm, \ 390 .vw_kbdmode = K_XLATE, \ 391}; \ 392TERMINAL_DECLARE_EARLY(driver ## _consterm, vt_termclass, \ 393 &driver ## _conswindow); \ 394SYSINIT(vt_early_cons, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_ANY, \ 395 vt_upgrade, &driver ## _consdev) 396 397/* 398 * Fonts. 399 * 400 * Remapping tables are used to map Unicode points to glyphs. They need 401 * to be sorted, because vtfont_lookup() performs a binary search. Each 402 * font has two remapping tables, for normal and bold. When a character 403 * is not present in bold, it uses a normal glyph. When no glyph is 404 * available, it uses glyph 0, which is normally equal to U+FFFD. 405 */ 406 407struct vt_font_map { 408 uint32_t vfm_src; 409 uint16_t vfm_dst; 410 uint16_t vfm_len; 411}; 412 413struct vt_font { 414 struct vt_font_map *vf_map[VFNT_MAPS]; 415 uint8_t *vf_bytes; 416 unsigned int vf_height, vf_width; 417 unsigned int vf_map_count[VFNT_MAPS]; 418 unsigned int vf_refcount; 419}; 420 421#ifndef SC_NO_CUTPASTE 422struct mouse_cursor { 423 uint8_t map[64 * 64 / 8]; 424 uint8_t mask[64 * 64 / 8]; 425 uint8_t w; 426 uint8_t h; 427}; 428#endif 429 430const uint8_t *vtfont_lookup(const struct vt_font *vf, term_char_t c); 431struct vt_font *vtfont_ref(struct vt_font *vf); 432void vtfont_unref(struct vt_font *vf); 433int vtfont_load(vfnt_t *f, struct vt_font **ret); 434 435/* Sysmouse. */ 436void sysmouse_process_event(mouse_info_t *mi); 437#ifndef SC_NO_CUTPASTE 438void vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel); 439void vt_mouse_state(int show); 440#endif 441#define VT_MOUSE_SHOW 1 442#define VT_MOUSE_HIDE 0 443 444#endif /* !_DEV_VT_VT_H_ */ 445 446