vt.h revision 286867
1193323Sed/*-
2193323Sed * Copyright (c) 2009, 2013 The FreeBSD Foundation
3193323Sed * All rights reserved.
4193323Sed *
5193323Sed * This software was developed by Ed Schouten under sponsorship from the
6193323Sed * FreeBSD Foundation.
7193323Sed *
8193323Sed * Portions of this software were developed by Oleksandr Rybalko
9193323Sed * under sponsorship from the FreeBSD Foundation.
10193323Sed *
11193323Sed * Redistribution and use in source and binary forms, with or without
12193323Sed * modification, are permitted provided that the following conditions
13193323Sed * are met:
14193323Sed * 1. Redistributions of source code must retain the above copyright
15193323Sed *    notice, this list of conditions and the following disclaimer.
16193323Sed * 2. Redistributions in binary form must reproduce the above copyright
17193323Sed *    notice, this list of conditions and the following disclaimer in the
18193323Sed *    documentation and/or other materials provided with the distribution.
19193323Sed *
20193323Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21193323Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22193323Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23193323Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24193323Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25193323Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26193323Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27193323Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28193323Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29193323Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30193323Sed * SUCH DAMAGE.
31193323Sed *
32193323Sed * $FreeBSD: head/sys/dev/vt/vt.h 286867 2015-08-18 00:47:02Z marcel $
33193323Sed */
34193323Sed
35193323Sed#ifndef _DEV_VT_VT_H_
36193323Sed#define	_DEV_VT_VT_H_
37193323Sed
38193323Sed#include <sys/param.h>
39193323Sed#include <sys/_lock.h>
40193323Sed#include <sys/_mutex.h>
41193323Sed#include <sys/callout.h>
42193323Sed#include <sys/condvar.h>
43193323Sed#include <sys/conf.h>
44193323Sed#include <sys/consio.h>
45193323Sed#include <sys/kbio.h>
46193323Sed#include <sys/mouse.h>
47193323Sed#include <sys/terminal.h>
48193323Sed#include <sys/sysctl.h>
49193323Sed
50193323Sed#include "opt_syscons.h"
51193323Sed#include "opt_splash.h"
52193323Sed
53193323Sed#ifndef	VT_MAXWINDOWS
54193323Sed#ifdef	MAXCONS
55193323Sed#define	VT_MAXWINDOWS	MAXCONS
56193323Sed#else
57193323Sed#define	VT_MAXWINDOWS	12
58193323Sed#endif
59193323Sed#endif
60193323Sed
61193323Sed#ifndef VT_ALT_TO_ESC_HACK
62193323Sed#define	VT_ALT_TO_ESC_HACK	1
63193323Sed#endif
64193323Sed
65193323Sed#define	VT_CONSWINDOW	0
66193323Sed
67193323Sed#if defined(SC_TWOBUTTON_MOUSE) || defined(VT_TWOBUTTON_MOUSE)
68193323Sed#define VT_MOUSE_PASTEBUTTON	MOUSE_BUTTON3DOWN	/* right button */
69193323Sed#define VT_MOUSE_EXTENDBUTTON	MOUSE_BUTTON2DOWN	/* not really used */
70193323Sed#else
71193323Sed#define VT_MOUSE_PASTEBUTTON	MOUSE_BUTTON2DOWN	/* middle button */
72193323Sed#define VT_MOUSE_EXTENDBUTTON	MOUSE_BUTTON3DOWN	/* right button */
73193323Sed#endif /* defined(SC_TWOBUTTON_MOUSE) || defined(VT_TWOBUTTON_MOUSE) */
74193323Sed
75193323Sed#define	SC_DRIVER_NAME	"vt"
76193323Sed#ifdef VT_DEBUG
77193323Sed#define	DPRINTF(_l, ...)	if (vt_debug > (_l)) printf( __VA_ARGS__ )
78193323Sed#define VT_CONSOLECTL_DEBUG
79193323Sed#define VT_SYSMOUSE_DEBUG
80193323Sed#else
81193323Sed#define	DPRINTF(_l, ...)	do {} while (0)
82193323Sed#endif
83193323Sed#define	ISSIGVALID(sig)	((sig) > 0 && (sig) < NSIG)
84193323Sed
85193323Sed#define	VT_SYSCTL_INT(_name, _default, _descr)				\
86193323Sedint vt_##_name = (_default);						\
87193323SedSYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, 0, _descr)
88193323Sed
89193323Sedstruct vt_driver;
90193323Sed
91193323Sedvoid vt_allocate(const struct vt_driver *, void *);
92193323Sedvoid vt_deallocate(const struct vt_driver *, void *);
93193323Sed
94193323Sedtypedef unsigned int 	vt_axis_t;
95193323Sed
96193323Sed/*
97195098Sed * List of locks
98195098Sed * (d)	locked by vd_lock
99193323Sed * (b)	locked by vb_lock
100193323Sed * (G)	locked by Giant
101193323Sed * (u)	unlocked, locked by higher levels
102193323Sed * (c)	const until freeing
103193323Sed * (?)	yet to be determined
104193323Sed */
105193323Sed
106193323Sed/*
107193323Sed * Per-device datastructure.
108193323Sed */
109193323Sed
110193323Sed#ifndef SC_NO_CUTPASTE
111193323Sedstruct vt_mouse_cursor;
112193323Sed#endif
113193323Sed
114193323Sedstruct vt_pastebuf {
115193323Sed	term_char_t		*vpb_buf;	/* Copy-paste buffer. */
116193323Sed	unsigned int		 vpb_bufsz;	/* Buffer size. */
117193323Sed	unsigned int		 vpb_len;	/* Length of a last selection. */
118193323Sed};
119193323Sed
120193323Sedstruct vt_device {
121193323Sed	struct vt_window	*vd_windows[VT_MAXWINDOWS]; /* (c) Windows. */
122193323Sed	struct vt_window	*vd_curwindow;	/* (d) Current window. */
123193323Sed	struct vt_window	*vd_savedwindow;/* (?) Saved for suspend. */
124195098Sed	struct vt_pastebuf	 vd_pastebuf;	/* (?) Copy/paste buf. */
125195098Sed	const struct vt_driver	*vd_driver;	/* (c) Graphics driver. */
126195098Sed	void			*vd_softc;	/* (u) Driver data. */
127195098Sed	const struct vt_driver	*vd_prev_driver;/* (?) Previous driver. */
128195098Sed	void			*vd_prev_softc;	/* (?) Previous driver data. */
129195098Sed	device_t		 vd_video_dev;	/* (?) Video adapter. */
130193323Sed#ifndef SC_NO_CUTPASTE
131195098Sed	struct vt_mouse_cursor	*vd_mcursor;	/* (?) Cursor bitmap. */
132193323Sed	term_color_t		 vd_mcursor_fg;	/* (?) Cursor fg color. */
133193323Sed	term_color_t		 vd_mcursor_bg;	/* (?) Cursor bg color. */
134193323Sed	vt_axis_t		 vd_mx_drawn;	/* (?) Mouse X and Y      */
135193323Sed	vt_axis_t		 vd_my_drawn;	/*     as of last redraw. */
136193323Sed	int			 vd_mshown;	/* (?) Mouse shown during */
137193323Sed#endif						/*     last redrawn.      */
138193323Sed	uint16_t		 vd_mx;		/* (?) Current mouse X. */
139193323Sed	uint16_t		 vd_my;		/* (?) current mouse Y. */
140193323Sed	uint32_t		 vd_mstate;	/* (?) Mouse state. */
141195098Sed	vt_axis_t		 vd_width;	/* (?) Screen width. */
142193323Sed	vt_axis_t		 vd_height;	/* (?) Screen height. */
143193323Sed	size_t			 vd_transpose;	/* (?) Screen offset in FB */
144193323Sed	struct mtx		 vd_lock;	/* Per-device lock. */
145193323Sed	struct cv		 vd_winswitch;	/* (d) Window switch notify. */
146193323Sed	struct callout		 vd_timer;	/* (d) Display timer. */
147193323Sed	volatile unsigned int	 vd_timer_armed;/* (?) Display timer started.*/
148193323Sed	int			 vd_flags;	/* (d) Device flags. */
149193323Sed#define	VDF_TEXTMODE	0x01	/* Do text mode rendering. */
150193323Sed#define	VDF_SPLASH	0x02	/* Splash screen active. */
151193323Sed#define	VDF_ASYNC	0x04	/* vt_timer() running. */
152193323Sed#define	VDF_INVALID	0x08	/* Entire screen should be re-rendered. */
153193323Sed#define	VDF_DEAD	0x10	/* Early probing found nothing. */
154193323Sed#define	VDF_INITIALIZED	0x20	/* vtterm_cnprobe already done. */
155193323Sed#define	VDF_MOUSECURSOR	0x40	/* Mouse cursor visible. */
156193323Sed#define	VDF_QUIET_BELL	0x80	/* Disable bell. */
157193323Sed#define	VDF_DOWNGRADE	0x8000	/* The driver is being downgraded. */
158193323Sed	int			 vd_keyboard;	/* (G) Keyboard index. */
159193323Sed	unsigned int		 vd_kbstate;	/* (?) Device unit. */
160193323Sed	unsigned int		 vd_unit;	/* (c) Device unit. */
161193323Sed	int			 vd_altbrk;	/* (?) Alt break seq. state */
162193323Sed};
163193323Sed
164193323Sed#define	VD_PASTEBUF(vd)	((vd)->vd_pastebuf.vpb_buf)
165193323Sed#define	VD_PASTEBUFSZ(vd)	((vd)->vd_pastebuf.vpb_bufsz)
166193323Sed#define	VD_PASTEBUFLEN(vd)	((vd)->vd_pastebuf.vpb_len)
167193323Sed
168193323Sed#define	VT_LOCK(vd)	mtx_lock(&(vd)->vd_lock)
169193323Sed#define	VT_UNLOCK(vd)	mtx_unlock(&(vd)->vd_lock)
170193323Sed#define	VT_LOCK_ASSERT(vd, what)	mtx_assert(&(vd)->vd_lock, what)
171193323Sed
172193323Sedvoid vt_resume(struct vt_device *vd);
173193323Sedvoid vt_resume_flush_timer(struct vt_device *vd, int ms);
174193323Sedvoid vt_suspend(struct vt_device *vd);
175193323Sed
176193323Sed/*
177193323Sed * Per-window terminal screen buffer.
178193323Sed *
179193323Sed * Because redrawing is performed asynchronously, the buffer keeps track
180193323Sed * of a rectangle that needs to be redrawn (vb_dirtyrect).  Because this
181193323Sed * approach seemed to cause suboptimal performance (when the top left
182193323Sed * and the bottom right of the screen are modified), it also uses a set
183193323Sed * of bitmasks to keep track of the rows and columns (mod 64) that have
184193323Sed * been modified.
185193323Sed */
186193323Sed
187193323Sedstruct vt_buf {
188193323Sed	struct mtx		 vb_lock;	/* Buffer lock. */
189193323Sed	term_pos_t		 vb_scr_size;	/* (b) Screen dimensions. */
190193323Sed	int			 vb_flags;	/* (b) Flags. */
191193323Sed#define	VBF_CURSOR	0x1	/* Cursor visible. */
192193323Sed#define	VBF_STATIC	0x2	/* Buffer is statically allocated. */
193193323Sed#define	VBF_MTX_INIT	0x4	/* Mutex initialized. */
194193323Sed#define	VBF_SCROLL	0x8	/* scroll locked mode. */
195193323Sed#define	VBF_HISTORY_FULL 0x10	/* All rows filled. */
196193323Sed	unsigned int		 vb_history_size;
197193323Sed	int			 vb_roffset;	/* (b) History rows offset. */
198193323Sed	int			 vb_curroffset;	/* (b) Saved rows offset. */
199193323Sed	term_pos_t		 vb_cursor;	/* (u) Cursor position. */
200193323Sed	term_pos_t		 vb_mark_start;	/* (b) Copy region start. */
201193323Sed	term_pos_t		 vb_mark_end;	/* (b) Copy region end. */
202193323Sed	int			 vb_mark_last;	/* Last mouse event. */
203193323Sed	term_rect_t		 vb_dirtyrect;	/* (b) Dirty rectangle. */
204193323Sed	term_char_t		*vb_buffer;	/* (u) Data buffer. */
205193323Sed	term_char_t		**vb_rows;	/* (u) Array of rows */
206193323Sed};
207193323Sed
208193323Sed#ifdef SC_HISTORY_SIZE
209193323Sed#define	VBF_DEFAULT_HISTORY_SIZE	SC_HISTORY_SIZE
210193323Sed#else
211193323Sed#define	VBF_DEFAULT_HISTORY_SIZE	500
212193323Sed#endif
213193323Sed
214193323Sedvoid vtbuf_copy(struct vt_buf *, const term_rect_t *, const term_pos_t *);
215193323Sedvoid vtbuf_fill_locked(struct vt_buf *, const term_rect_t *, term_char_t);
216193323Sedvoid vtbuf_init_early(struct vt_buf *);
217193323Sedvoid vtbuf_init(struct vt_buf *, const term_pos_t *);
218193323Sedvoid vtbuf_grow(struct vt_buf *, const term_pos_t *, unsigned int);
219193323Sedvoid vtbuf_putchar(struct vt_buf *, const term_pos_t *, term_char_t);
220193323Sedvoid vtbuf_cursor_position(struct vt_buf *, const term_pos_t *);
221193323Sedvoid vtbuf_scroll_mode(struct vt_buf *vb, int yes);
222193323Sedvoid vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area);
223193323Sedvoid vtbuf_undirty(struct vt_buf *, term_rect_t *);
224193323Sedvoid vtbuf_sethistory_size(struct vt_buf *, int);
225193323Sedint vtbuf_iscursor(const struct vt_buf *vb, int row, int col);
226193323Sedvoid vtbuf_cursor_visibility(struct vt_buf *, int);
227193323Sed#ifndef SC_NO_CUTPASTE
228193323Sedint vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row);
229193323Sedint vtbuf_get_marked_len(struct vt_buf *vb);
230193323Sedvoid vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz);
231193323Sed#endif
232193323Sed
233193323Sed#define	VTB_MARK_NONE		0
234193323Sed#define	VTB_MARK_END		1
235193323Sed#define	VTB_MARK_START		2
236193323Sed#define	VTB_MARK_WORD		3
237193323Sed#define	VTB_MARK_ROW		4
238193323Sed#define	VTB_MARK_EXTEND		5
239193323Sed#define	VTB_MARK_MOVE		6
240193323Sed
241193323Sed#define	VTBUF_SLCK_ENABLE(vb)	vtbuf_scroll_mode((vb), 1)
242193323Sed#define	VTBUF_SLCK_DISABLE(vb)	vtbuf_scroll_mode((vb), 0)
243193323Sed
244193323Sed#define	VTBUF_MAX_HEIGHT(vb) \
245193323Sed	((vb)->vb_history_size)
246193323Sed#define	VTBUF_GET_ROW(vb, r) \
247193323Sed	((vb)->vb_rows[((vb)->vb_roffset + (r)) % VTBUF_MAX_HEIGHT(vb)])
248193323Sed#define	VTBUF_GET_FIELD(vb, r, c) \
249193323Sed	((vb)->vb_rows[((vb)->vb_roffset + (r)) % VTBUF_MAX_HEIGHT(vb)][(c)])
250193323Sed#define	VTBUF_FIELD(vb, r, c) \
251193323Sed	((vb)->vb_rows[((vb)->vb_curroffset + (r)) % VTBUF_MAX_HEIGHT(vb)][(c)])
252193323Sed#define	VTBUF_ISCURSOR(vb, r, c) \
253193323Sed	vtbuf_iscursor((vb), (r), (c))
254193323Sed#define	VTBUF_DIRTYROW(mask, row) \
255193323Sed	((mask)->vbm_row & ((uint64_t)1 << ((row) % 64)))
256193323Sed#define	VTBUF_DIRTYCOL(mask, col) \
257193323Sed	((mask)->vbm_col & ((uint64_t)1 << ((col) % 64)))
258193323Sed#define	VTBUF_SPACE_CHAR(attr)	(' ' | (attr))
259193323Sed
260193323Sed#define	VHS_SET	0
261193323Sed#define	VHS_CUR	1
262193323Sed#define	VHS_END	2
263193323Sedint vthistory_seek(struct vt_buf *, int offset, int whence);
264193323Sedvoid vthistory_addlines(struct vt_buf *vb, int offset);
265193323Sedvoid vthistory_getpos(const struct vt_buf *, unsigned int *offset);
266193323Sed
267193323Sed/*
268193323Sed * Per-window datastructure.
269193323Sed */
270193323Sed
271193323Sedstruct vt_window {
272195098Sed	struct vt_device	*vw_device;	/* (c) Device. */
273195098Sed	struct terminal		*vw_terminal;	/* (c) Terminal. */
274193323Sed	struct vt_buf		 vw_buf;	/* (u) Screen buffer. */
275193323Sed	struct vt_font		*vw_font;	/* (d) Graphical font. */
276193323Sed	term_rect_t		 vw_draw_area;	/* (?) Drawable area. */
277193323Sed	unsigned int		 vw_number;	/* (c) Window number. */
278193323Sed	int			 vw_kbdmode;	/* (?) Keyboard mode. */
279193323Sed	int			 vw_prev_kbdmode;/* (?) Previous mode. */
280193323Sed	int			 vw_kbdstate;	/* (?) Keyboard state. */
281193323Sed	int			 vw_grabbed;	/* (?) Grab count. */
282193323Sed	char			*vw_kbdsq;	/* Escape sequence queue*/
283193323Sed	unsigned int		 vw_flags;	/* (d) Per-window flags. */
284193323Sed	int			 vw_mouse_level;/* Mouse op mode. */
285193323Sed#define	VWF_BUSY	0x1	/* Busy reconfiguring device. */
286193323Sed#define	VWF_OPENED	0x2	/* TTY in use. */
287193323Sed#define	VWF_SCROLL	0x4	/* Keys influence scrollback. */
288193323Sed#define	VWF_CONSOLE	0x8	/* Kernel message console window. */
289193323Sed#define	VWF_VTYLOCK	0x10	/* Prevent window switch. */
290193323Sed#define	VWF_MOUSE_HIDE	0x20	/* Disable mouse events processing. */
291193323Sed#define	VWF_READY	0x40	/* Window fully initialized. */
292193323Sed#define	VWF_GRAPHICS	0x80	/* Window in graphics mode (KDSETMODE). */
293193323Sed#define	VWF_SWWAIT_REL	0x10000	/* Program wait for VT acquire is done. */
294#define	VWF_SWWAIT_ACQ	0x20000	/* Program wait for VT release is done. */
295	pid_t			 vw_pid;	/* Terminal holding process */
296	struct proc		*vw_proc;
297	struct vt_mode		 vw_smode;	/* switch mode */
298	struct callout		 vw_proc_dead_timer;
299	struct vt_window	*vw_switch_to;
300};
301
302#define	VT_AUTO		0		/* switching is automatic */
303#define	VT_PROCESS	1		/* switching controlled by prog */
304#define	VT_KERNEL	255		/* switching controlled in kernel */
305
306#define	IS_VT_PROC_MODE(vw)	((vw)->vw_smode.mode == VT_PROCESS)
307
308/*
309 * Per-device driver routines.
310 */
311
312typedef int vd_init_t(struct vt_device *vd);
313typedef int vd_probe_t(struct vt_device *vd);
314typedef void vd_fini_t(struct vt_device *vd, void *softc);
315typedef void vd_postswitch_t(struct vt_device *vd);
316typedef void vd_blank_t(struct vt_device *vd, term_color_t color);
317typedef void vd_bitblt_text_t(struct vt_device *vd, const struct vt_window *vw,
318    const term_rect_t *area);
319typedef void vd_bitblt_bmp_t(struct vt_device *vd, const struct vt_window *vw,
320    const uint8_t *pattern, const uint8_t *mask,
321    unsigned int width, unsigned int height,
322    unsigned int x, unsigned int y, term_color_t fg, term_color_t bg);
323typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *);
324typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int,
325    vm_memattr_t *);
326typedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int,
327    term_color_t);
328typedef void vd_setpixel_t(struct vt_device *, int, int, term_color_t);
329typedef void vd_suspend_t(struct vt_device *);
330typedef void vd_resume_t(struct vt_device *);
331
332struct vt_driver {
333	char		 vd_name[16];
334	/* Console attachment. */
335	vd_probe_t	*vd_probe;
336	vd_init_t	*vd_init;
337	vd_fini_t	*vd_fini;
338
339	/* Drawing. */
340	vd_blank_t	*vd_blank;
341	vd_drawrect_t	*vd_drawrect;
342	vd_setpixel_t	*vd_setpixel;
343	vd_bitblt_text_t *vd_bitblt_text;
344	vd_bitblt_bmp_t	*vd_bitblt_bmp;
345
346	/* Framebuffer ioctls, if present. */
347	vd_fb_ioctl_t	*vd_fb_ioctl;
348
349	/* Framebuffer mmap, if present. */
350	vd_fb_mmap_t	*vd_fb_mmap;
351
352	/* Update display setting on vt switch. */
353	vd_postswitch_t	*vd_postswitch;
354
355	/* Suspend/resume handlers. */
356	vd_suspend_t	*vd_suspend;
357	vd_resume_t	*vd_resume;
358
359	/* Priority to know which one can override */
360	int		vd_priority;
361#define	VD_PRIORITY_DUMB	10
362#define	VD_PRIORITY_GENERIC	100
363#define	VD_PRIORITY_SPECIFIC	1000
364};
365
366/*
367 * Console device madness.
368 *
369 * Utility macro to make early vt(4) instances work.
370 */
371
372extern struct terminal vt_consterm;
373extern const struct terminal_class vt_termclass;
374void vt_upgrade(struct vt_device *vd);
375
376#define	PIXEL_WIDTH(w)	((w) / 8)
377#define	PIXEL_HEIGHT(h)	((h) / 16)
378
379#ifndef VT_FB_DEFAULT_WIDTH
380#define	VT_FB_DEFAULT_WIDTH	2048
381#endif
382#ifndef VT_FB_DEFAULT_HEIGHT
383#define	VT_FB_DEFAULT_HEIGHT	1200
384#endif
385
386/* name argument is not used yet. */
387#define VT_DRIVER_DECLARE(name, drv) DATA_SET(vt_drv_set, drv)
388
389/*
390 * Fonts.
391 *
392 * Remapping tables are used to map Unicode points to glyphs.  They need
393 * to be sorted, because vtfont_lookup() performs a binary search.  Each
394 * font has two remapping tables, for normal and bold.  When a character
395 * is not present in bold, it uses a normal glyph.  When no glyph is
396 * available, it uses glyph 0, which is normally equal to U+FFFD.
397 */
398
399struct vt_font_map {
400	uint32_t		 vfm_src;
401	uint16_t		 vfm_dst;
402	uint16_t		 vfm_len;
403};
404
405struct vt_font {
406	struct vt_font_map	*vf_map[VFNT_MAPS];
407	uint8_t			*vf_bytes;
408	unsigned int		 vf_height, vf_width;
409	unsigned int		 vf_map_count[VFNT_MAPS];
410	unsigned int		 vf_refcount;
411};
412
413#ifndef SC_NO_CUTPASTE
414struct vt_mouse_cursor {
415	uint8_t map[64 * 64 / 8];
416	uint8_t mask[64 * 64 / 8];
417	uint8_t width;
418	uint8_t height;
419};
420#endif
421
422const uint8_t	*vtfont_lookup(const struct vt_font *vf, term_char_t c);
423struct vt_font	*vtfont_ref(struct vt_font *vf);
424void		 vtfont_unref(struct vt_font *vf);
425int		 vtfont_load(vfnt_t *f, struct vt_font **ret);
426
427/* Sysmouse. */
428void sysmouse_process_event(mouse_info_t *mi);
429#ifndef SC_NO_CUTPASTE
430void vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel);
431void vt_mouse_state(int show);
432#endif
433#define	VT_MOUSE_SHOW 1
434#define	VT_MOUSE_HIDE 0
435
436/* Utilities. */
437void	vt_compute_drawable_area(struct vt_window *);
438void	vt_determine_colors(term_char_t c, int cursor,
439	    term_color_t *fg, term_color_t *bg);
440int	vt_is_cursor_in_area(const struct vt_device *vd,
441	    const term_rect_t *area);
442void	vt_termsize(struct vt_device *, struct vt_font *, term_pos_t *);
443void	vt_winsize(struct vt_device *, struct vt_font *, struct winsize *);
444
445/* Logos-on-boot. */
446#define	VT_LOGOS_DRAW_BEASTIE		0
447#define	VT_LOGOS_DRAW_ALT_BEASTIE	1
448#define	VT_LOGOS_DRAW_ORB		2
449
450extern int vt_draw_logo_cpus;
451extern int vt_splash_cpu;
452extern int vt_splash_ncpu;
453extern int vt_splash_cpu_style;
454extern int vt_splash_cpu_duration;
455
456extern const unsigned int vt_logo_sprite_height;
457extern const unsigned int vt_logo_sprite_width;
458
459void vtterm_draw_cpu_logos(struct vt_device *);
460
461#endif /* !_DEV_VT_VT_H_ */
462
463