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