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