syscons.h revision 56329
169800Stomsoft/*-
269800Stomsoft * Copyright (c) 1995-1998 S�ren Schmidt
369800Stomsoft * All rights reserved.
469800Stomsoft *
569800Stomsoft * Redistribution and use in source and binary forms, with or without
669800Stomsoft * modification, are permitted provided that the following conditions
769800Stomsoft * are met:
869800Stomsoft * 1. Redistributions of source code must retain the above copyright
969800Stomsoft *    notice, this list of conditions and the following disclaimer,
1069800Stomsoft *    without modification, immediately at the beginning of the file.
1169800Stomsoft * 2. Redistributions in binary form must reproduce the above copyright
1269800Stomsoft *    notice, this list of conditions and the following disclaimer in the
1369800Stomsoft *    documentation and/or other materials provided with the distribution.
1474815Sru * 3. The name of the author may not be used to endorse or promote products
1569800Stomsoft *    derived from this software without specific prior written permission.
1669800Stomsoft *
1769800Stomsoft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1869800Stomsoft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1969800Stomsoft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2069800Stomsoft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2169800Stomsoft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/syscons/syscons.h 56329 2000-01-20 13:23:03Z yokota $
29 */
30
31#ifndef _DEV_SYSCONS_SYSCONS_H_
32#define	_DEV_SYSCONS_SYSCONS_H_
33
34/* machine-dependent part of the header */
35
36#ifdef PC98
37#include <pc98/pc98/sc_machdep.h>
38#elif defined(__i386__)
39/* nothing for the moment */
40#elif defined(__alpha__)
41/* nothing for the moment */
42#endif
43
44/* default values for configuration options */
45
46#ifndef MAXCONS
47#define MAXCONS		16
48#endif
49
50#ifdef SC_NO_SYSMOUSE
51#undef SC_NO_CUTPASTE
52#define SC_NO_CUTPASTE	1
53#endif
54
55#ifdef SC_NO_MODE_CHANGE
56#undef SC_PIXEL_MODE
57#endif
58
59#ifndef SC_MOUSE_CHAR
60#define SC_MOUSE_CHAR	(0xd0)
61#endif
62
63#ifndef SC_DEBUG_LEVEL
64#define SC_DEBUG_LEVEL	0
65#endif
66
67#define DPRINTF(l, p)	if (SC_DEBUG_LEVEL >= (l)) printf p
68
69#define SC_DRIVER_NAME	"sc"
70#define SC_VTY(dev)	minor(dev)
71#define SC_DEV(sc, vty)	((sc)->dev[(vty) - (sc)->first_vty])
72#define SC_STAT(dev)	((scr_stat *)(dev)->si_drv1)
73
74/* printable chars */
75#ifndef PRINTABLE
76#define PRINTABLE(ch)	((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
77			 || (ch) < 0x07)
78#endif
79
80/* macros for "intelligent" screen update */
81#define mark_for_update(scp, x)	{\
82			  	    if ((x) < scp->start) scp->start = (x);\
83				    else if ((x) > scp->end) scp->end = (x);\
84				}
85#define mark_all(scp)		{\
86				    scp->start = 0;\
87				    scp->end = scp->xsize * scp->ysize - 1;\
88				}
89
90/* vty status flags (scp->status) */
91#define UNKNOWN_MODE	0x00010
92#define SWITCH_WAIT_REL	0x00080
93#define SWITCH_WAIT_ACQ	0x00100
94#define BUFFER_SAVED	0x00200
95#define CURSOR_ENABLED 	0x00400
96#define MOUSE_MOVED	0x01000
97#define MOUSE_CUTTING	0x02000
98#define MOUSE_VISIBLE	0x04000
99#define GRAPHICS_MODE	0x08000
100#define PIXEL_MODE	0x10000
101#define SAVER_RUNNING	0x20000
102#define VR_CURSOR_BLINK	0x40000
103#define VR_CURSOR_ON	0x80000
104
105/* misc defines */
106#define FALSE		0
107#define TRUE		1
108#define	COL		80
109#define	ROW		25
110#define PCBURST		128
111
112#ifndef BELL_DURATION
113#define BELL_DURATION	5
114#define BELL_PITCH	800
115#endif
116
117/* virtual terminal buffer */
118typedef struct sc_vtb {
119	int		vtb_flags;
120#define VTB_VALID	(1 << 0)
121	int		vtb_type;
122#define VTB_INVALID	0
123#define VTB_MEMORY	1
124#define VTB_FRAMEBUFFER	2
125#define VTB_RINGBUFFER	3
126	int		vtb_cols;
127	int		vtb_rows;
128	int		vtb_size;
129	vm_offset_t	vtb_buffer;
130	int		vtb_tail;	/* valid for VTB_RINGBUFFER only */
131} sc_vtb_t;
132
133/* softc */
134
135struct keyboard;
136struct video_adapter;
137struct scr_stat;
138struct tty;
139
140typedef struct sc_softc {
141	int		unit;			/* unit # */
142	int		config;			/* configuration flags */
143#define SC_VESA800X600	(1 << 7)
144#define SC_AUTODETECT_KBD (1 << 8)
145#define SC_KERNEL_CONSOLE (1 << 9)
146
147	int		flags;			/* status flags */
148#define SC_VISUAL_BELL	(1 << 0)
149#define SC_QUIET_BELL	(1 << 1)
150#define SC_BLINK_CURSOR	(1 << 2)
151#define SC_CHAR_CURSOR	(1 << 3)
152#define SC_MOUSE_ENABLED (1 << 4)
153#define	SC_SCRN_IDLE	(1 << 5)
154#define	SC_SCRN_BLANKED	(1 << 6)
155#define	SC_SAVER_FAILED	(1 << 7)
156
157#define	SC_INIT_DONE	(1 << 16)
158#define	SC_SPLASH_SCRN	(1 << 17)
159
160	int		keyboard;		/* -1 if unavailable */
161	struct keyboard	*kbd;
162
163	int		adapter;
164	struct video_adapter *adp;
165	int		initial_mode;		/* initial video mode */
166
167	int		first_vty;
168	int		vtys;
169	dev_t		*dev;
170	struct scr_stat	*cur_scp;
171	struct scr_stat	*new_scp;
172	struct scr_stat	*old_scp;
173	int     	delayed_next_scr;
174
175	char        	font_loading_in_progress;
176	char        	switch_in_progress;
177	char        	videoio_in_progress;
178	char        	write_in_progress;
179	char        	blink_in_progress;
180
181	long		scrn_time_stamp;
182
183	char		cursor_base;
184	char		cursor_height;
185
186	u_char      	scr_map[256];
187	u_char      	scr_rmap[256];
188
189#ifdef _SC_MD_SOFTC_DECLARED_
190	sc_md_softc_t	md;			/* machine dependent vars */
191#endif
192
193#ifndef SC_NO_PALETTE_LOADING
194	u_char        	palette[256*3];
195#endif
196
197#ifndef SC_NO_FONT_LOADING
198	int     	fonts_loaded;
199#define FONT_8		2
200#define FONT_14		4
201#define FONT_16		8
202	u_char		*font_8;
203	u_char		*font_14;
204	u_char		*font_16;
205#endif
206
207	u_char		mouse_char;
208
209} sc_softc_t;
210
211/* virtual screen */
212typedef struct scr_stat {
213	int		index;			/* index of this vty */
214	struct sc_softc *sc;			/* pointer to softc */
215	struct sc_rndr_sw *rndr;		/* renderer */
216	sc_vtb_t	scr;
217	sc_vtb_t	vtb;
218
219	int 		xpos;			/* current X position */
220	int 		ypos;			/* current Y position */
221	int 		xsize;			/* X text size */
222	int 		ysize;			/* Y text size */
223	int 		xpixel;			/* X graphics size */
224	int 		ypixel;			/* Y graphics size */
225	int		xoff;			/* X offset in pixel mode */
226	int		yoff;			/* Y offset in pixel mode */
227
228	u_char		*font;			/* current font */
229	int		font_size;		/* fontsize in Y direction */
230
231	int		start;			/* modified area start */
232	int		end;			/* modified area end */
233
234	struct sc_term_sw *tsw;
235	void		*ts;
236
237	int	 	status;			/* status (bitfield) */
238	int		kbd_mode;		/* keyboard I/O mode */
239
240	int		cursor_pos;		/* cursor buffer position */
241	int		cursor_oldpos;		/* cursor old buffer position */
242	u_short		cursor_saveunder_char;	/* saved char under cursor */
243	u_short		cursor_saveunder_attr;	/* saved attr under cursor */
244	char		cursor_base;		/* cursor base line # */
245	char		cursor_height;		/* cursor height */
246
247	int		mouse_pos;		/* mouse buffer position */
248	int		mouse_oldpos;		/* mouse old buffer position */
249	short		mouse_xpos;		/* mouse x coordinate */
250	short		mouse_ypos;		/* mouse y coordinate */
251	short		mouse_buttons;		/* mouse buttons */
252	int		mouse_cut_start;	/* mouse cut start pos */
253	int		mouse_cut_end;		/* mouse cut end pos */
254	struct proc 	*mouse_proc;		/* proc* of controlling proc */
255	pid_t 		mouse_pid;		/* pid of controlling proc */
256	int		mouse_signal;		/* signal # to report with */
257
258	u_short		bell_duration;
259	u_short		bell_pitch;
260
261	u_char		border;			/* border color */
262	int	 	mode;			/* mode */
263	pid_t 		pid;			/* pid of controlling proc */
264	struct proc 	*proc;			/* proc* of controlling proc */
265	struct vt_mode 	smode;			/* switch mode */
266
267	sc_vtb_t	*history;		/* circular history buffer */
268	int		history_pos;		/* position shown on screen */
269	int		history_size;		/* size of history buffer */
270
271	int		splash_save_mode;	/* saved mode for splash screen */
272	int		splash_save_status;	/* saved status for splash screen */
273#ifdef _SCR_MD_STAT_DECLARED_
274	scr_md_stat_t	md;			/* machine dependent vars */
275#endif
276} scr_stat;
277
278#ifndef SC_NORM_ATTR
279#define SC_NORM_ATTR		(FG_LIGHTGREY | BG_BLACK)
280#endif
281#ifndef SC_NORM_REV_ATTR
282#define SC_NORM_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
283#endif
284#ifndef SC_KERNEL_CONS_ATTR
285#define SC_KERNEL_CONS_ATTR	(FG_WHITE | BG_BLACK)
286#endif
287#ifndef SC_KERNEL_CONS_REV_ATTR
288#define SC_KERNEL_CONS_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
289#endif
290
291/* terminal emulator */
292
293#ifndef SC_DFLT_TERM
294#define SC_DFLT_TERM	"*"			/* any */
295#endif
296
297typedef int	sc_term_init_t(scr_stat *scp, void **tcp, int code);
298#define SC_TE_COLD_INIT	0
299#define SC_TE_WARM_INIT	1
300typedef int	sc_term_term_t(scr_stat *scp, void **tcp);
301typedef void	sc_term_puts_t(scr_stat *scp, u_char *buf, int len);
302typedef int	sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
303				caddr_t data, int flag, struct proc *p);
304typedef int	sc_term_reset_t(scr_stat *scp, int code);
305#define SC_TE_HARD_RESET 0
306#define SC_TE_SOFT_RESET 1
307typedef void	sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
308typedef void	sc_term_clear_t(scr_stat *scp);
309typedef void	sc_term_notify_t(scr_stat *scp, int event);
310#define SC_TE_NOTIFY_VTSWITCH_IN	0
311#define SC_TE_NOTIFY_VTSWITCH_OUT	1
312typedef int	sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
313
314typedef struct sc_term_sw {
315	LIST_ENTRY(sc_term_sw)	link;
316	char 			*te_name;	/* name of the emulator */
317	char 			*te_desc;	/* description */
318	char 			*te_renderer;	/* matching renderer */
319	size_t			te_size;	/* size of internal buffer */
320	int			te_refcount;	/* reference counter */
321	sc_term_init_t		*te_init;
322	sc_term_term_t		*te_term;
323	sc_term_puts_t		*te_puts;
324	sc_term_ioctl_t		*te_ioctl;
325	sc_term_reset_t		*te_reset;
326	sc_term_default_attr_t	*te_default_attr;
327	sc_term_clear_t		*te_clear;
328	sc_term_notify_t	*te_notify;
329	sc_term_input_t		*te_input;
330} sc_term_sw_t;
331
332extern struct linker_set scterm_set;
333
334#define SCTERM_MODULE(name, sw)					\
335	DATA_SET(scterm_set, sw);				\
336	static int						\
337	scterm_##name##_event(module_t mod, int type, void *data) \
338	{							\
339		switch (type) {					\
340		case MOD_LOAD:					\
341			return sc_term_add(&sw);		\
342		case MOD_UNLOAD:				\
343			if (sw.te_refcount > 0)			\
344				return EBUSY;			\
345			return sc_term_remove(&sw);		\
346		default:					\
347			break;					\
348		}						\
349		return 0;					\
350	}							\
351	static moduledata_t scterm_##name##_mod = {		\
352		"scterm-" #name,				\
353		scterm_##name##_event,				\
354		NULL,						\
355	};							\
356	DECLARE_MODULE(scterm_##name, scterm_##name##_mod,	\
357		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
358
359/* renderer function table */
360typedef void	vr_clear_t(scr_stat *scp, int c, int attr);
361typedef void	vr_draw_border_t(scr_stat *scp, int color);
362typedef void	vr_draw_t(scr_stat *scp, int from, int count, int flip);
363typedef void	vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
364typedef void	vr_draw_cursor_t(scr_stat *scp, int at, int blink,
365				 int on, int flip);
366typedef void	vr_blink_cursor_t(scr_stat *scp, int at, int flip);
367typedef void	vr_set_mouse_t(scr_stat *scp);
368typedef void	vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
369
370typedef struct sc_rndr_sw {
371	vr_clear_t		*clear;
372	vr_draw_border_t	*draw_border;
373	vr_draw_t		*draw;
374	vr_set_cursor_t		*set_cursor;
375	vr_draw_cursor_t	*draw_cursor;
376	vr_blink_cursor_t	*blink_cursor;
377	vr_set_mouse_t		*set_mouse;
378	vr_draw_mouse_t		*draw_mouse;
379} sc_rndr_sw_t;
380
381typedef struct sc_renderer {
382	char			*name;
383	int			mode;
384	sc_rndr_sw_t		*rndrsw;
385	LIST_ENTRY(sc_renderer)	link;
386} sc_renderer_t;
387
388extern struct linker_set scrndr_set;
389
390#define RENDERER(name, mode, sw, set)				\
391	static struct sc_renderer scrndr_##name##_##mode## = {	\
392		#name, mode, &sw				\
393	};							\
394	DATA_SET(scrndr_set, scrndr_##name##_##mode##);		\
395	DATA_SET(set, scrndr_##name##_##mode##)
396
397#define RENDERER_MODULE(name, set)				\
398	static int						\
399	scrndr_##name##_event(module_t mod, int type, void *data) \
400	{							\
401		sc_renderer_t **list;				\
402		sc_renderer_t *p;				\
403		int error = 0;					\
404		switch (type) {					\
405		case MOD_LOAD:					\
406			list = (sc_renderer_t **)set.ls_items;	\
407			while ((p = *list++) != NULL) {		\
408				error = sc_render_add(p);	\
409				if (error)			\
410					break;			\
411			}					\
412			break;					\
413		case MOD_UNLOAD:				\
414			list = (sc_renderer_t **)set.ls_items;	\
415			while ((p = *list++) != NULL) {		\
416				error = sc_render_remove(p);	\
417				if (error)			\
418					break;			\
419			}					\
420			break;					\
421		default:					\
422			break;					\
423		}						\
424		return error;					\
425	}							\
426	static moduledata_t scrndr_##name##_mod = {		\
427		"scrndr-" #name,				\
428		scrndr_##name##_event,				\
429		NULL,						\
430	};							\
431	DECLARE_MODULE(scrndr_##name##, scrndr_##name##_mod, 	\
432		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
433
434typedef struct {
435	int		cursor_start;
436	int		cursor_end;
437	int		shift_state;
438	int		bell_pitch;
439} bios_values_t;
440
441/* other macros */
442#define ISTEXTSC(scp)	(!((scp)->status 				\
443			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
444#define ISGRAPHSC(scp)	(((scp)->status 				\
445			  & (UNKNOWN_MODE | GRAPHICS_MODE)))
446#define ISPIXELSC(scp)	(((scp)->status 				\
447			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
448			  == PIXEL_MODE)
449#define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
450
451#ifndef ISMOUSEAVAIL
452#ifdef SC_ALT_MOUSE_IMAGE
453#define ISMOUSEAVAIL(af) (1)
454#else
455#define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
456#endif /* SC_ALT_MOUSE_IMAGE */
457#define ISFONTAVAIL(af)	((af) & V_ADP_FONT)
458#define ISPALAVAIL(af)	((af) & V_ADP_PALETTE)
459#endif /* ISMOUSEAVAIL */
460
461#define ISSIGVALID(sig)	((sig) > 0 && (sig) < NSIG)
462
463#define kbd_read_char(kbd, wait)					\
464		(*kbdsw[(kbd)->kb_index]->read_char)((kbd), (wait))
465#define kbd_check_char(kbd)						\
466		(*kbdsw[(kbd)->kb_index]->check_char)((kbd))
467#define kbd_enable(kbd)							\
468		(*kbdsw[(kbd)->kb_index]->enable)((kbd))
469#define kbd_disable(kbd)						\
470		(*kbdsw[(kbd)->kb_index]->disable)((kbd))
471#define kbd_lock(kbd, lockf)						\
472		(*kbdsw[(kbd)->kb_index]->lock)((kbd), (lockf))
473#define kbd_ioctl(kbd, cmd, arg)					\
474	    (((kbd) == NULL) ?						\
475		ENODEV : (*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (arg)))
476#define kbd_clear_state(kbd)						\
477		(*kbdsw[(kbd)->kb_index]->clear_state)((kbd))
478#define kbd_get_fkeystr(kbd, fkey, len)					\
479		(*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len))
480#define kbd_poll(kbd, on)						\
481		(*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
482
483/* syscons.c */
484extern int 	(*sc_user_ioctl)(dev_t dev, u_long cmd, caddr_t data,
485				 int flag, struct proc *p);
486
487int		sc_probe_unit(int unit, int flags);
488int		sc_attach_unit(int unit, int flags);
489int		sc_resume_unit(int unit);
490
491int		set_mode(scr_stat *scp);
492
493void		sc_set_border(scr_stat *scp, int color);
494void		sc_load_font(scr_stat *scp, int page, int size, u_char *font,
495			     int base, int count);
496void		sc_save_font(scr_stat *scp, int page, int size, u_char *font,
497			     int base, int count);
498void		sc_show_font(scr_stat *scp, int page);
499
500void		sc_touch_scrn_saver(void);
501void		sc_puts(scr_stat *scp, u_char *buf, int len);
502void		sc_draw_cursor_image(scr_stat *scp);
503void		sc_remove_cursor_image(scr_stat *scp);
504void		sc_set_cursor_image(scr_stat *scp);
505int		sc_clean_up(scr_stat *scp);
506int		sc_switch_scr(sc_softc_t *sc, u_int next_scr);
507void		sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
508int		sc_init_emulator(scr_stat *scp, char *name);
509void		sc_paste(scr_stat *scp, u_char *p, int count);
510void		sc_bell(scr_stat *scp, int pitch, int duration);
511
512/* schistory.c */
513#ifndef SC_NO_HISTORY
514int		sc_alloc_history_buffer(scr_stat *scp, int lines,
515					int prev_ysize, int wait);
516void		sc_free_history_buffer(scr_stat *scp, int prev_ysize);
517void		sc_hist_save(scr_stat *scp);
518#define		sc_hist_save_one_line(scp, from)	\
519		sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
520int		sc_hist_restore(scr_stat *scp);
521void		sc_hist_home(scr_stat *scp);
522void		sc_hist_end(scr_stat *scp);
523int		sc_hist_up_line(scr_stat *scp);
524int		sc_hist_down_line(scr_stat *scp);
525int		sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
526			      int flag, struct proc *p);
527#endif /* SC_NO_HISTORY */
528
529/* scmouse.c */
530#ifndef SC_NO_CUTPASTE
531void		sc_alloc_cut_buffer(scr_stat *scp, int wait);
532void		sc_draw_mouse_image(scr_stat *scp);
533void		sc_remove_mouse_image(scr_stat *scp);
534int		sc_inside_cutmark(scr_stat *scp, int pos);
535void		sc_remove_cutmarking(scr_stat *scp);
536void		sc_remove_all_cutmarkings(sc_softc_t *scp);
537void		sc_remove_all_mouse(sc_softc_t *scp);
538#else
539#define		sc_inside_cutmark(scp, pos)	FALSE
540#define		sc_remove_cutmarking(scp)
541#endif /* SC_NO_CUTPASTE */
542#ifndef SC_NO_SYSMOUSE
543void		sc_mouse_move(scr_stat *scp, int x, int y);
544int		sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
545			       int flag, struct proc *p);
546#endif /* SC_NO_SYSMOUSE */
547
548/* scvidctl.c */
549int		sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
550				 int xsize, int ysize, int fontsize);
551int		sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
552int		sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
553				  int xsize, int ysize, int fontsize);
554int		sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
555			     struct proc *p);
556
557int		sc_render_add(sc_renderer_t *rndr);
558int		sc_render_remove(sc_renderer_t *rndr);
559sc_rndr_sw_t	*sc_render_match(scr_stat *scp, char *name, int mode);
560
561/* scvtb.c */
562void		sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows,
563			    void *buffer, int wait);
564void		sc_vtb_destroy(sc_vtb_t *vtb);
565size_t		sc_vtb_size(int cols, int rows);
566void		sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
567
568int		sc_vtb_getc(sc_vtb_t *vtb, int at);
569int		sc_vtb_geta(sc_vtb_t *vtb, int at);
570void		sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
571vm_offset_t	sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a);
572vm_offset_t	sc_vtb_pointer(sc_vtb_t *vtb, int at);
573int		sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
574
575#define		sc_vtb_tail(vtb)	((vtb)->vtb_tail)
576#define		sc_vtb_rows(vtb)	((vtb)->vtb_rows)
577#define		sc_vtb_cols(vtb)	((vtb)->vtb_cols)
578
579void		sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
580			    int count);
581void		sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
582			      int count);
583void		sc_vtb_seek(sc_vtb_t *vtb, int pos);
584void		sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
585void		sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
586void		sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
587void		sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
588
589/* sysmouse.c */
590int		sysmouse_event(mouse_info_t *info);
591
592/* scterm.c */
593void		sc_move_cursor(scr_stat *scp, int x, int y);
594void		sc_clear_screen(scr_stat *scp);
595int		sc_term_add(sc_term_sw_t *sw);
596int		sc_term_remove(sc_term_sw_t *sw);
597sc_term_sw_t	*sc_term_match(char *name);
598sc_term_sw_t	*sc_term_match_by_number(int index);
599
600/* machine dependent functions */
601int		sc_max_unit(void);
602sc_softc_t	*sc_get_softc(int unit, int flags);
603sc_softc_t	*sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
604int		sc_get_cons_priority(int *unit, int *flags);
605void		sc_get_bios_values(bios_values_t *values);
606int		sc_tone(int herz);
607
608#endif /* !_DEV_SYSCONS_SYSCONS_H_ */
609