xref: /freebsd/sys/dev/syscons/syscons.h (revision 63d1fd5970ec814904aa0f4580b10a0d302d08b2)
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$
32  */
33 
34 #ifndef _DEV_SYSCONS_SYSCONS_H_
35 #define	_DEV_SYSCONS_SYSCONS_H_
36 
37 #include <sys/kdb.h>		/* XXX */
38 #include <sys/_lock.h>
39 #include <sys/_mutex.h>
40 
41 /* machine-dependent part of the header */
42 
43 #ifdef PC98
44 #include <pc98/cbus/sc_machdep.h>
45 #elif defined(__i386__)
46 /* nothing for the moment */
47 #endif
48 
49 /* default values for configuration options */
50 
51 #ifndef MAXCONS
52 #define MAXCONS		16
53 #endif
54 
55 #ifdef SC_NO_SYSMOUSE
56 #undef SC_NO_CUTPASTE
57 #define SC_NO_CUTPASTE	1
58 #endif
59 
60 #ifdef SC_NO_MODE_CHANGE
61 #undef SC_PIXEL_MODE
62 #endif
63 
64 /* Always load font data if the pixel (raster text) mode is to be used. */
65 #ifdef SC_PIXEL_MODE
66 #undef SC_NO_FONT_LOADING
67 #endif
68 
69 /*
70  * If font data is not available, the `arrow'-shaped mouse cursor cannot
71  * be drawn.  Use the alternative drawing method.
72  */
73 #ifdef SC_NO_FONT_LOADING
74 #undef SC_ALT_MOUSE_IMAGE
75 #define SC_ALT_MOUSE_IMAGE 1
76 #endif
77 
78 #ifndef SC_CURSOR_CHAR
79 #define SC_CURSOR_CHAR	(0x07)
80 #endif
81 
82 #ifndef SC_MOUSE_CHAR
83 #define SC_MOUSE_CHAR	(0xd0)
84 #endif
85 
86 #if SC_MOUSE_CHAR <= SC_CURSOR_CHAR && SC_CURSOR_CHAR < (SC_MOUSE_CHAR + 4)
87 #undef SC_CURSOR_CHAR
88 #define SC_CURSOR_CHAR	(SC_MOUSE_CHAR + 4)
89 #endif
90 
91 #ifndef SC_DEBUG_LEVEL
92 #define SC_DEBUG_LEVEL	0
93 #endif
94 
95 #define DPRINTF(l, p)	if (SC_DEBUG_LEVEL >= (l)) printf p
96 
97 #ifndef __sparc64__
98 #define SC_DRIVER_NAME	"sc"
99 #else
100 /*
101  * Use a different driver name on sparc64 so it does not get confused
102  * with the system controller devices which are also termed 'sc' in OFW.
103  */
104 #define SC_DRIVER_NAME	"syscons"
105 #endif
106 #define SC_VTY(dev)	(((sc_ttysoftc *)tty_softc(tp))->st_index)
107 #define SC_DEV(sc, vty)	((sc)->dev[(vty) - (sc)->first_vty])
108 #define SC_STAT(tp)	(*((scr_stat **)&((sc_ttysoftc *)tty_softc(tp))->st_stat))
109 
110 /* printable chars */
111 #ifndef PRINTABLE
112 #define PRINTABLE(ch)	((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
113 			 || (ch) < 0x07)
114 #endif
115 
116 /* macros for "intelligent" screen update */
117 #define mark_for_update(scp, x)	{\
118 			  	    if ((x) < scp->start) scp->start = (x);\
119 				    else if ((x) > scp->end) scp->end = (x);\
120 				}
121 #define mark_all(scp)		{\
122 				    scp->start = 0;\
123 				    scp->end = scp->xsize * scp->ysize - 1;\
124 				}
125 
126 /* vty status flags (scp->status) */
127 #define UNKNOWN_MODE	0x00010		/* unknown video mode */
128 #define SWITCH_WAIT_REL	0x00080		/* waiting for vty release */
129 #define SWITCH_WAIT_ACQ	0x00100		/* waiting for vty ack */
130 #define BUFFER_SAVED	0x00200		/* vty buffer is saved */
131 #define CURSOR_ENABLED 	0x00400		/* text cursor is enabled */
132 #define MOUSE_MOVED	0x01000		/* mouse cursor has moved */
133 #define MOUSE_CUTTING	0x02000		/* mouse cursor is cutting text */
134 #define MOUSE_VISIBLE	0x04000		/* mouse cursor is showing */
135 #define GRAPHICS_MODE	0x08000		/* vty is in a graphics mode */
136 #define PIXEL_MODE	0x10000		/* vty is in a raster text mode */
137 #define SAVER_RUNNING	0x20000		/* screen saver is running */
138 #define VR_CURSOR_BLINK	0x40000		/* blinking text cursor */
139 #define VR_CURSOR_ON	0x80000		/* text cursor is on */
140 #define MOUSE_HIDDEN	0x100000	/* mouse cursor is temporarily hidden */
141 
142 /* misc defines */
143 #define FALSE		0
144 #define TRUE		1
145 
146 /*
147    The following #defines are hard-coded for a maximum text
148    resolution corresponding to a maximum framebuffer
149    resolution of 1920x1200 with an 8x8 font...
150 */
151 #define	COL		240
152 #define	ROW		150
153 
154 #define PCBURST		128
155 
156 #ifndef BELL_DURATION
157 #define BELL_DURATION	((5 * hz + 99) / 100)
158 #define BELL_PITCH	800
159 #endif
160 
161 /* virtual terminal buffer */
162 typedef struct sc_vtb {
163 	int		vtb_flags;
164 #define VTB_VALID	(1 << 0)
165 #define VTB_ALLOCED	(1 << 1)
166 	int		vtb_type;
167 #define VTB_INVALID	0
168 #define VTB_MEMORY	1
169 #define VTB_FRAMEBUFFER	2
170 #define VTB_RINGBUFFER	3
171 	int		vtb_cols;
172 	int		vtb_rows;
173 	int		vtb_size;
174 	vm_offset_t	vtb_buffer;
175 	int		vtb_tail;	/* valid for VTB_RINGBUFFER only */
176 } sc_vtb_t;
177 
178 /* text cursor attributes */
179 struct cursor_attr {
180 	int		flags;
181 	int		base;
182 	int		height;
183 };
184 
185 /* softc */
186 
187 struct keyboard;
188 struct video_adapter;
189 struct scr_stat;
190 struct tty;
191 
192 struct sc_cnstate {
193 	u_char		kbd_locked;
194 	u_char		kdb_locked;
195 	u_char		mtx_locked;
196 	u_char		kbd_opened;
197 	u_char		scr_opened;
198 };
199 
200 typedef struct sc_softc {
201 	int		unit;			/* unit # */
202 	int		config;			/* configuration flags */
203 #define SC_VESAMODE	(1 << 7)
204 #define SC_AUTODETECT_KBD (1 << 8)
205 #define SC_KERNEL_CONSOLE (1 << 9)
206 
207 	int		flags;			/* status flags */
208 #define SC_VISUAL_BELL	(1 << 0)
209 #define SC_QUIET_BELL	(1 << 1)
210 #if 0 /* not used anymore */
211 #define SC_BLINK_CURSOR	(1 << 2)
212 #define SC_CHAR_CURSOR	(1 << 3)
213 #endif
214 #define SC_MOUSE_ENABLED (1 << 4)
215 #define	SC_SCRN_IDLE	(1 << 5)
216 #define	SC_SCRN_BLANKED	(1 << 6)
217 #define	SC_SAVER_FAILED	(1 << 7)
218 #define	SC_SCRN_VTYLOCK	(1 << 8)
219 
220 #define	SC_INIT_DONE	(1 << 16)
221 #define	SC_SPLASH_SCRN	(1 << 17)
222 
223 	int		keyboard;		/* -1 if unavailable */
224 	struct keyboard	*kbd;
225 
226 	int		adapter;
227 	struct video_adapter *adp;
228 	int		initial_mode;		/* initial video mode */
229 
230 	int		first_vty;
231 	int		vtys;
232 	struct tty **dev;
233 	struct scr_stat	*cur_scp;
234 	struct scr_stat	*new_scp;
235 	struct scr_stat	*old_scp;
236 	int     	delayed_next_scr;
237 
238 	char        	font_loading_in_progress;
239 	char        	switch_in_progress;
240 	char        	write_in_progress;
241 	char        	blink_in_progress;
242 	int		grab_level;
243 	/* 2 is just enough for kdb to grab for stepping normal grabbing: */
244 	struct sc_cnstate grab_state[2];
245 	int		kbd_open_level;
246 	struct mtx	video_mtx;
247 
248 	long		scrn_time_stamp;
249 
250 	struct cursor_attr dflt_curs_attr;
251 	struct cursor_attr curs_attr;
252 
253 	u_char      	scr_map[256];
254 	u_char      	scr_rmap[256];
255 
256 #ifdef _SC_MD_SOFTC_DECLARED_
257 	sc_md_softc_t	md;			/* machine dependent vars */
258 #endif
259 
260 #ifndef SC_NO_PALETTE_LOADING
261 	u_char		palette[256 * 3];
262 #ifdef SC_PIXEL_MODE
263 	u_char		palette2[256 * 3];
264 #endif
265 #endif
266 
267 #ifndef SC_NO_FONT_LOADING
268 	int     	fonts_loaded;
269 #define FONT_8		2
270 #define FONT_14		4
271 #define FONT_16		8
272 #define FONT_22		8
273 	u_char		*font_8;
274 	u_char		*font_14;
275 	u_char		*font_16;
276 	u_char		*font_22;
277 #endif
278 
279 	u_char		cursor_char;
280 	u_char		mouse_char;
281 
282 #ifdef KDB
283 	int		sc_altbrk;
284 #endif
285 	struct callout	ctimeout;
286 	struct callout	cblink;
287 } sc_softc_t;
288 
289 /* virtual screen */
290 typedef struct scr_stat {
291 	int		index;			/* index of this vty */
292 	struct sc_softc *sc;			/* pointer to softc */
293 	struct sc_rndr_sw *rndr;		/* renderer */
294 #ifndef __sparc64__
295 	sc_vtb_t	scr;
296 #endif
297 	sc_vtb_t	vtb;
298 
299 	int 		xpos;			/* current X position */
300 	int 		ypos;			/* current Y position */
301 	int 		xsize;			/* X text size */
302 	int 		ysize;			/* Y text size */
303 	int 		xpixel;			/* X graphics size */
304 	int 		ypixel;			/* Y graphics size */
305 	int		xoff;			/* X offset in pixel mode */
306 	int		yoff;			/* Y offset in pixel mode */
307 
308 	u_char		*font;			/* current font */
309 	int		font_size;		/* fontsize in Y direction */
310 	int		font_width;		/* fontsize in X direction */
311 
312 	int		start;			/* modified area start */
313 	int		end;			/* modified area end */
314 
315 	struct sc_term_sw *tsw;
316 	void		*ts;
317 
318 	int	 	status;			/* status (bitfield) */
319 	int		kbd_mode;		/* keyboard I/O mode */
320 
321 	int		cursor_pos;		/* cursor buffer position */
322 	int		cursor_oldpos;		/* cursor old buffer position */
323 	u_short		cursor_saveunder_char;	/* saved char under cursor */
324 	u_short		cursor_saveunder_attr;	/* saved attr under cursor */
325 	struct cursor_attr dflt_curs_attr;
326 	struct cursor_attr curr_curs_attr;
327 	struct cursor_attr curs_attr;
328 
329 	int		mouse_pos;		/* mouse buffer position */
330 	int		mouse_oldpos;		/* mouse old buffer position */
331 	short		mouse_xpos;		/* mouse x coordinate */
332 	short		mouse_ypos;		/* mouse y coordinate */
333 	short		mouse_oldxpos;		/* mouse previous x coordinate */
334 	short		mouse_oldypos;		/* mouse previous y coordinate */
335 	short		mouse_buttons;		/* mouse buttons */
336 	int		mouse_cut_start;	/* mouse cut start pos */
337 	int		mouse_cut_end;		/* mouse cut end pos */
338 	int		mouse_level;		/* xterm mouse protocol */
339 	struct proc 	*mouse_proc;		/* proc* of controlling proc */
340 	pid_t 		mouse_pid;		/* pid of controlling proc */
341 	int		mouse_signal;		/* signal # to report with */
342 
343 	u_short		bell_duration;
344 	u_short		bell_pitch;
345 
346 	u_char		border;			/* border color */
347 	int	 	mode;			/* mode */
348 	pid_t 		pid;			/* pid of controlling proc */
349 	struct proc 	*proc;			/* proc* of controlling proc */
350 	struct vt_mode 	smode;			/* switch mode */
351 
352 	sc_vtb_t	*history;		/* circular history buffer */
353 	int		history_pos;		/* position shown on screen */
354 	int		history_size;		/* size of history buffer */
355 
356 	int		splash_save_mode;	/* saved mode for splash screen */
357 	int		splash_save_status;	/* saved status for splash screen */
358 #ifdef _SCR_MD_STAT_DECLARED_
359 	scr_md_stat_t	md;			/* machine dependent vars */
360 #endif
361 } scr_stat;
362 
363 /* TTY softc. */
364 typedef struct sc_ttysoftc {
365 	int		st_index;
366 	scr_stat	*st_stat;
367 } sc_ttysoftc;
368 
369 #ifndef SC_NORM_ATTR
370 #define SC_NORM_ATTR		(FG_LIGHTGREY | BG_BLACK)
371 #endif
372 #ifndef SC_NORM_REV_ATTR
373 #define SC_NORM_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
374 #endif
375 #ifndef SC_KERNEL_CONS_ATTR
376 #define SC_KERNEL_CONS_ATTR	(FG_WHITE | BG_BLACK)
377 #endif
378 #ifndef SC_KERNEL_CONS_REV_ATTR
379 #define SC_KERNEL_CONS_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
380 #endif
381 
382 /* terminal emulator */
383 
384 #ifndef SC_DFLT_TERM
385 #define SC_DFLT_TERM	"*"			/* any */
386 #endif
387 
388 typedef int	sc_term_init_t(scr_stat *scp, void **tcp, int code);
389 #define SC_TE_COLD_INIT	0
390 #define SC_TE_WARM_INIT	1
391 typedef int	sc_term_term_t(scr_stat *scp, void **tcp);
392 typedef void	sc_term_puts_t(scr_stat *scp, u_char *buf, int len, int kernel);
393 typedef int	sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
394 				caddr_t data, struct thread *td);
395 typedef int	sc_term_reset_t(scr_stat *scp, int code);
396 #define SC_TE_HARD_RESET 0
397 #define SC_TE_SOFT_RESET 1
398 typedef void	sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
399 typedef void	sc_term_clear_t(scr_stat *scp);
400 typedef void	sc_term_notify_t(scr_stat *scp, int event);
401 #define SC_TE_NOTIFY_VTSWITCH_IN	0
402 #define SC_TE_NOTIFY_VTSWITCH_OUT	1
403 typedef int	sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
404 typedef const char *sc_term_fkeystr_t(scr_stat *scp, int c);
405 
406 typedef struct sc_term_sw {
407 	LIST_ENTRY(sc_term_sw)	link;
408 	char 			*te_name;	/* name of the emulator */
409 	char 			*te_desc;	/* description */
410 	char 			*te_renderer;	/* matching renderer */
411 	size_t			te_size;	/* size of internal buffer */
412 	int			te_refcount;	/* reference counter */
413 	sc_term_init_t		*te_init;
414 	sc_term_term_t		*te_term;
415 	sc_term_puts_t		*te_puts;
416 	sc_term_ioctl_t		*te_ioctl;
417 	sc_term_reset_t		*te_reset;
418 	sc_term_default_attr_t	*te_default_attr;
419 	sc_term_clear_t		*te_clear;
420 	sc_term_notify_t	*te_notify;
421 	sc_term_input_t		*te_input;
422 	sc_term_fkeystr_t	*te_fkeystr;
423 } sc_term_sw_t;
424 
425 #define SCTERM_MODULE(name, sw)					\
426 	DATA_SET(scterm_set, sw);				\
427 	static int						\
428 	scterm_##name##_event(module_t mod, int type, void *data) \
429 	{							\
430 		switch (type) {					\
431 		case MOD_LOAD:					\
432 			return sc_term_add(&sw);		\
433 		case MOD_UNLOAD:				\
434 			if (sw.te_refcount > 0)			\
435 				return EBUSY;			\
436 			return sc_term_remove(&sw);		\
437 		default:					\
438 			return EOPNOTSUPP;			\
439 			break;					\
440 		}						\
441 		return 0;					\
442 	}							\
443 	static moduledata_t scterm_##name##_mod = {		\
444 		"scterm-" #name,				\
445 		scterm_##name##_event,				\
446 		NULL,						\
447 	};							\
448 	DECLARE_MODULE(scterm_##name, scterm_##name##_mod,	\
449 		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
450 
451 /* renderer function table */
452 typedef void	vr_init_t(scr_stat *scp);
453 typedef void	vr_clear_t(scr_stat *scp, int c, int attr);
454 typedef void	vr_draw_border_t(scr_stat *scp, int color);
455 typedef void	vr_draw_t(scr_stat *scp, int from, int count, int flip);
456 typedef void	vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
457 typedef void	vr_draw_cursor_t(scr_stat *scp, int at, int blink,
458 				 int on, int flip);
459 typedef void	vr_blink_cursor_t(scr_stat *scp, int at, int flip);
460 typedef void	vr_set_mouse_t(scr_stat *scp);
461 typedef void	vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
462 
463 typedef struct sc_rndr_sw {
464 	vr_init_t		*init;
465 	vr_clear_t		*clear;
466 	vr_draw_border_t	*draw_border;
467 	vr_draw_t		*draw;
468 	vr_set_cursor_t		*set_cursor;
469 	vr_draw_cursor_t	*draw_cursor;
470 	vr_blink_cursor_t	*blink_cursor;
471 	vr_set_mouse_t		*set_mouse;
472 	vr_draw_mouse_t		*draw_mouse;
473 } sc_rndr_sw_t;
474 
475 typedef struct sc_renderer {
476 	char			*name;
477 	int			mode;
478 	sc_rndr_sw_t		*rndrsw;
479 	LIST_ENTRY(sc_renderer)	link;
480 } sc_renderer_t;
481 
482 #define RENDERER(name, mode, sw, set)				\
483 	static struct sc_renderer scrndr_##name##_##mode = {	\
484 		#name, mode, &sw				\
485 	};							\
486 	DATA_SET(scrndr_set, scrndr_##name##_##mode);		\
487 	DATA_SET(set, scrndr_##name##_##mode)
488 
489 #define RENDERER_MODULE(name, set)				\
490 	SET_DECLARE(set, sc_renderer_t);			\
491 	static int						\
492 	scrndr_##name##_event(module_t mod, int type, void *data) \
493 	{							\
494 		sc_renderer_t **list;				\
495 		int error = 0;					\
496 		switch (type) {					\
497 		case MOD_LOAD:					\
498 			SET_FOREACH(list, set) {		\
499 				error = sc_render_add(*list);	\
500 				if (error)			\
501 					break;			\
502 			}					\
503 			break;					\
504 		case MOD_UNLOAD:				\
505 			SET_FOREACH(list, set) {		\
506 				error = sc_render_remove(*list);\
507 				if (error)			\
508 					break;			\
509 			}					\
510 			break;					\
511 		default:					\
512 			return EOPNOTSUPP;			\
513 			break;					\
514 		}						\
515 		return error;					\
516 	}							\
517 	static moduledata_t scrndr_##name##_mod = {		\
518 		"scrndr-" #name,				\
519 		scrndr_##name##_event,				\
520 		NULL,						\
521 	};							\
522 	DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod, 	\
523 		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
524 
525 typedef struct {
526 	int		cursor_start;
527 	int		cursor_end;
528 	int		shift_state;
529 	int		bell_pitch;
530 } bios_values_t;
531 
532 /* other macros */
533 #define ISTEXTSC(scp)	(!((scp)->status 				\
534 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
535 #define ISGRAPHSC(scp)	(((scp)->status 				\
536 			  & (UNKNOWN_MODE | GRAPHICS_MODE)))
537 #define ISPIXELSC(scp)	(((scp)->status 				\
538 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
539 			  == PIXEL_MODE)
540 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
541 
542 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
543 #define ISFONTAVAIL(af)	((af) & V_ADP_FONT)
544 #define ISPALAVAIL(af)	((af) & V_ADP_PALETTE)
545 
546 #define ISSIGVALID(sig)	((sig) > 0 && (sig) < NSIG)
547 
548 #define SC_VIDEO_LOCKINIT(sc)						\
549 		mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,	\
550 		    MTX_SPIN | MTX_RECURSE);
551 #define SC_VIDEO_LOCK(sc)						\
552 		do {							\
553 			if (!kdb_active)				\
554 				mtx_lock_spin(&(sc)->video_mtx);	\
555 		} while(0)
556 #define SC_VIDEO_UNLOCK(sc)						\
557 		do {							\
558 			if (!kdb_active)				\
559 				mtx_unlock_spin(&(sc)->video_mtx);	\
560 		} while(0)
561 
562 /* syscons.c */
563 extern int 	(*sc_user_ioctl)(struct tty *tp, u_long cmd, caddr_t data,
564 				 struct thread *td);
565 
566 int		sc_probe_unit(int unit, int flags);
567 int		sc_attach_unit(int unit, int flags);
568 
569 int		set_mode(scr_stat *scp);
570 
571 void		sc_set_border(scr_stat *scp, int color);
572 void		sc_load_font(scr_stat *scp, int page, int size, int width,
573 			     u_char *font, int base, int count);
574 void		sc_save_font(scr_stat *scp, int page, int size, int width,
575 			     u_char *font, int base, int count);
576 void		sc_show_font(scr_stat *scp, int page);
577 
578 void		sc_touch_scrn_saver(void);
579 void		sc_draw_cursor_image(scr_stat *scp);
580 void		sc_remove_cursor_image(scr_stat *scp);
581 void		sc_set_cursor_image(scr_stat *scp);
582 void		sc_change_cursor_shape(scr_stat *scp, int flags,
583 				       int base, int height);
584 int		sc_clean_up(scr_stat *scp);
585 int		sc_switch_scr(sc_softc_t *sc, u_int next_scr);
586 void		sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
587 int		sc_init_emulator(scr_stat *scp, char *name);
588 void		sc_paste(scr_stat *scp, const u_char *p, int count);
589 void		sc_respond(scr_stat *scp, const u_char *p,
590 			   int count, int wakeup);
591 void		sc_bell(scr_stat *scp, int pitch, int duration);
592 
593 /* schistory.c */
594 #ifndef SC_NO_HISTORY
595 int		sc_alloc_history_buffer(scr_stat *scp, int lines,
596 					int prev_ysize, int wait);
597 void		sc_free_history_buffer(scr_stat *scp, int prev_ysize);
598 void		sc_hist_save(scr_stat *scp);
599 #define		sc_hist_save_one_line(scp, from)	\
600 		sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
601 int		sc_hist_restore(scr_stat *scp);
602 void		sc_hist_home(scr_stat *scp);
603 void		sc_hist_end(scr_stat *scp);
604 int		sc_hist_up_line(scr_stat *scp);
605 int		sc_hist_down_line(scr_stat *scp);
606 int		sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
607 			      struct thread *td);
608 #endif /* SC_NO_HISTORY */
609 
610 /* scmouse.c */
611 #ifndef SC_NO_CUTPASTE
612 void		sc_alloc_cut_buffer(scr_stat *scp, int wait);
613 void		sc_draw_mouse_image(scr_stat *scp);
614 void		sc_remove_mouse_image(scr_stat *scp);
615 int		sc_inside_cutmark(scr_stat *scp, int pos);
616 void		sc_remove_cutmarking(scr_stat *scp);
617 void		sc_remove_all_cutmarkings(sc_softc_t *scp);
618 void		sc_remove_all_mouse(sc_softc_t *scp);
619 void		sc_mouse_paste(scr_stat *scp);
620 #else
621 #define		sc_draw_mouse_image(scp)
622 #define		sc_remove_mouse_image(scp)
623 #define		sc_inside_cutmark(scp, pos)	FALSE
624 #define		sc_remove_cutmarking(scp)
625 #define		sc_remove_all_cutmarkings(scp)
626 #define		sc_remove_all_mouse(scp)
627 #define		sc_mouse_paste(scp)
628 #endif /* SC_NO_CUTPASTE */
629 #ifndef SC_NO_SYSMOUSE
630 void		sc_mouse_move(scr_stat *scp, int x, int y);
631 int		sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
632 			       struct thread *td);
633 #endif /* SC_NO_SYSMOUSE */
634 
635 /* scvidctl.c */
636 int		sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
637 				 int xsize, int ysize, int fontsize,
638 				 int font_width);
639 int		sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
640 int		sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize,
641 				  int ysize, int fontsize, int font_width);
642 int		sc_support_pixel_mode(void *arg);
643 int		sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data,
644 			     struct thread *td);
645 
646 int		sc_render_add(sc_renderer_t *rndr);
647 int		sc_render_remove(sc_renderer_t *rndr);
648 sc_rndr_sw_t	*sc_render_match(scr_stat *scp, char *name, int mode);
649 
650 /* scvtb.c */
651 void		sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows,
652 			    void *buffer, int wait);
653 void		sc_vtb_destroy(sc_vtb_t *vtb);
654 size_t		sc_vtb_size(int cols, int rows);
655 void		sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
656 
657 int		sc_vtb_getc(sc_vtb_t *vtb, int at);
658 int		sc_vtb_geta(sc_vtb_t *vtb, int at);
659 void		sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
660 vm_offset_t	sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a);
661 vm_offset_t	sc_vtb_pointer(sc_vtb_t *vtb, int at);
662 int		sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
663 
664 #define		sc_vtb_tail(vtb)	((vtb)->vtb_tail)
665 #define		sc_vtb_rows(vtb)	((vtb)->vtb_rows)
666 #define		sc_vtb_cols(vtb)	((vtb)->vtb_cols)
667 
668 void		sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
669 			    int count);
670 void		sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
671 			      int count);
672 void		sc_vtb_seek(sc_vtb_t *vtb, int pos);
673 void		sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
674 void		sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
675 void		sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
676 void		sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
677 
678 /* sysmouse.c */
679 int		sysmouse_event(mouse_info_t *info);
680 
681 /* scterm.c */
682 void		sc_move_cursor(scr_stat *scp, int x, int y);
683 void		sc_clear_screen(scr_stat *scp);
684 int		sc_term_add(sc_term_sw_t *sw);
685 int		sc_term_remove(sc_term_sw_t *sw);
686 sc_term_sw_t	*sc_term_match(char *name);
687 sc_term_sw_t	*sc_term_match_by_number(int index);
688 
689 /* machine dependent functions */
690 int		sc_max_unit(void);
691 sc_softc_t	*sc_get_softc(int unit, int flags);
692 sc_softc_t	*sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
693 int		sc_get_cons_priority(int *unit, int *flags);
694 void		sc_get_bios_values(bios_values_t *values);
695 int		sc_tone(int herz);
696 
697 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */
698