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