xref: /freebsd/sys/dev/syscons/syscons.h (revision 41b9077ef675c307fd1112bcea26aa3aeba1bb91)
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		kbd_opened;
195 	u_char		scr_opened;
196 };
197 
198 typedef struct sc_softc {
199 	int		unit;			/* unit # */
200 	int		config;			/* configuration flags */
201 #define SC_VESAMODE	(1 << 7)
202 #define SC_AUTODETECT_KBD (1 << 8)
203 #define SC_KERNEL_CONSOLE (1 << 9)
204 
205 	int		flags;			/* status flags */
206 #define SC_VISUAL_BELL	(1 << 0)
207 #define SC_QUIET_BELL	(1 << 1)
208 #if 0 /* not used anymore */
209 #define SC_BLINK_CURSOR	(1 << 2)
210 #define SC_CHAR_CURSOR	(1 << 3)
211 #endif
212 #define SC_MOUSE_ENABLED (1 << 4)
213 #define	SC_SCRN_IDLE	(1 << 5)
214 #define	SC_SCRN_BLANKED	(1 << 6)
215 #define	SC_SAVER_FAILED	(1 << 7)
216 #define	SC_SCRN_VTYLOCK	(1 << 8)
217 
218 #define	SC_INIT_DONE	(1 << 16)
219 #define	SC_SPLASH_SCRN	(1 << 17)
220 
221 	int		keyboard;		/* -1 if unavailable */
222 	struct keyboard	*kbd;
223 
224 	int		adapter;
225 	struct video_adapter *adp;
226 	int		initial_mode;		/* initial video mode */
227 
228 	int		first_vty;
229 	int		vtys;
230 	struct tty **dev;
231 	struct scr_stat	*cur_scp;
232 	struct scr_stat	*new_scp;
233 	struct scr_stat	*old_scp;
234 	int     	delayed_next_scr;
235 
236 	char        	font_loading_in_progress;
237 	char        	switch_in_progress;
238 	char        	write_in_progress;
239 	char        	blink_in_progress;
240 	int		grab_level;
241 	/* 2 is just enough for kdb to grab for stepping normal grabbing: */
242 	struct sc_cnstate grab_state[2];
243 	int		kbd_open_level;
244 	struct mtx	video_mtx;
245 
246 	long		scrn_time_stamp;
247 
248 	struct cursor_attr dflt_curs_attr;
249 	struct cursor_attr curs_attr;
250 
251 	u_char      	scr_map[256];
252 	u_char      	scr_rmap[256];
253 
254 #ifdef _SC_MD_SOFTC_DECLARED_
255 	sc_md_softc_t	md;			/* machine dependent vars */
256 #endif
257 
258 #ifndef SC_NO_PALETTE_LOADING
259 	u_char		palette[256 * 3];
260 #ifdef SC_PIXEL_MODE
261 	u_char		palette2[256 * 3];
262 #endif
263 #endif
264 
265 #ifndef SC_NO_FONT_LOADING
266 	int     	fonts_loaded;
267 #define FONT_8		2
268 #define FONT_14		4
269 #define FONT_16		8
270 #define FONT_22		8
271 	u_char		*font_8;
272 	u_char		*font_14;
273 	u_char		*font_16;
274 	u_char		*font_22;
275 #endif
276 
277 	u_char		cursor_char;
278 	u_char		mouse_char;
279 
280 #ifdef KDB
281 	int		sc_altbrk;
282 #endif
283 	struct callout	ctimeout;
284 	struct callout	cblink;
285 } sc_softc_t;
286 
287 /* virtual screen */
288 typedef struct scr_stat {
289 	int		index;			/* index of this vty */
290 	struct sc_softc *sc;			/* pointer to softc */
291 	struct sc_rndr_sw *rndr;		/* renderer */
292 #ifndef __sparc64__
293 	sc_vtb_t	scr;
294 #endif
295 	sc_vtb_t	vtb;
296 
297 	int 		xpos;			/* current X position */
298 	int 		ypos;			/* current Y position */
299 	int 		xsize;			/* X text size */
300 	int 		ysize;			/* Y text size */
301 	int 		xpixel;			/* X graphics size */
302 	int 		ypixel;			/* Y graphics size */
303 	int		xoff;			/* X offset in pixel mode */
304 	int		yoff;			/* Y offset in pixel mode */
305 
306 	u_char		*font;			/* current font */
307 	int		font_size;		/* fontsize in Y direction */
308 	int		font_width;		/* fontsize in X direction */
309 
310 	int		start;			/* modified area start */
311 	int		end;			/* modified area end */
312 
313 	struct sc_term_sw *tsw;
314 	void		*ts;
315 
316 	int	 	status;			/* status (bitfield) */
317 	int		kbd_mode;		/* keyboard I/O mode */
318 
319 	int		cursor_pos;		/* cursor buffer position */
320 	int		cursor_oldpos;		/* cursor old buffer position */
321 	u_short		cursor_saveunder_char;	/* saved char under cursor */
322 	u_short		cursor_saveunder_attr;	/* saved attr under cursor */
323 	struct cursor_attr dflt_curs_attr;
324 	struct cursor_attr curr_curs_attr;
325 	struct cursor_attr curs_attr;
326 
327 	int		mouse_pos;		/* mouse buffer position */
328 	int		mouse_oldpos;		/* mouse old buffer position */
329 	short		mouse_xpos;		/* mouse x coordinate */
330 	short		mouse_ypos;		/* mouse y coordinate */
331 	short		mouse_oldxpos;		/* mouse previous x coordinate */
332 	short		mouse_oldypos;		/* mouse previous y coordinate */
333 	short		mouse_buttons;		/* mouse buttons */
334 	int		mouse_cut_start;	/* mouse cut start pos */
335 	int		mouse_cut_end;		/* mouse cut end pos */
336 	int		mouse_level;		/* xterm mouse protocol */
337 	struct proc 	*mouse_proc;		/* proc* of controlling proc */
338 	pid_t 		mouse_pid;		/* pid of controlling proc */
339 	int		mouse_signal;		/* signal # to report with */
340 
341 	u_short		bell_duration;
342 	u_short		bell_pitch;
343 
344 	u_char		border;			/* border color */
345 	int	 	mode;			/* mode */
346 	pid_t 		pid;			/* pid of controlling proc */
347 	struct proc 	*proc;			/* proc* of controlling proc */
348 	struct vt_mode 	smode;			/* switch mode */
349 
350 	sc_vtb_t	*history;		/* circular history buffer */
351 	int		history_pos;		/* position shown on screen */
352 	int		history_size;		/* size of history buffer */
353 
354 	int		splash_save_mode;	/* saved mode for splash screen */
355 	int		splash_save_status;	/* saved status for splash screen */
356 #ifdef _SCR_MD_STAT_DECLARED_
357 	scr_md_stat_t	md;			/* machine dependent vars */
358 #endif
359 } scr_stat;
360 
361 /* TTY softc. */
362 typedef struct sc_ttysoftc {
363 	int		st_index;
364 	scr_stat	*st_stat;
365 } sc_ttysoftc;
366 
367 #ifndef SC_NORM_ATTR
368 #define SC_NORM_ATTR		(FG_LIGHTGREY | BG_BLACK)
369 #endif
370 #ifndef SC_NORM_REV_ATTR
371 #define SC_NORM_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
372 #endif
373 #ifndef SC_KERNEL_CONS_ATTR
374 #define SC_KERNEL_CONS_ATTR	(FG_WHITE | BG_BLACK)
375 #endif
376 #ifndef SC_KERNEL_CONS_REV_ATTR
377 #define SC_KERNEL_CONS_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
378 #endif
379 
380 /* terminal emulator */
381 
382 #ifndef SC_DFLT_TERM
383 #define SC_DFLT_TERM	"*"			/* any */
384 #endif
385 
386 typedef int	sc_term_init_t(scr_stat *scp, void **tcp, int code);
387 #define SC_TE_COLD_INIT	0
388 #define SC_TE_WARM_INIT	1
389 typedef int	sc_term_term_t(scr_stat *scp, void **tcp);
390 typedef void	sc_term_puts_t(scr_stat *scp, u_char *buf, int len, int kernel);
391 typedef int	sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
392 				caddr_t data, struct thread *td);
393 typedef int	sc_term_reset_t(scr_stat *scp, int code);
394 #define SC_TE_HARD_RESET 0
395 #define SC_TE_SOFT_RESET 1
396 typedef void	sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
397 typedef void	sc_term_clear_t(scr_stat *scp);
398 typedef void	sc_term_notify_t(scr_stat *scp, int event);
399 #define SC_TE_NOTIFY_VTSWITCH_IN	0
400 #define SC_TE_NOTIFY_VTSWITCH_OUT	1
401 typedef int	sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
402 typedef const char *sc_term_fkeystr_t(scr_stat *scp, int c);
403 
404 typedef struct sc_term_sw {
405 	LIST_ENTRY(sc_term_sw)	link;
406 	char 			*te_name;	/* name of the emulator */
407 	char 			*te_desc;	/* description */
408 	char 			*te_renderer;	/* matching renderer */
409 	size_t			te_size;	/* size of internal buffer */
410 	int			te_refcount;	/* reference counter */
411 	sc_term_init_t		*te_init;
412 	sc_term_term_t		*te_term;
413 	sc_term_puts_t		*te_puts;
414 	sc_term_ioctl_t		*te_ioctl;
415 	sc_term_reset_t		*te_reset;
416 	sc_term_default_attr_t	*te_default_attr;
417 	sc_term_clear_t		*te_clear;
418 	sc_term_notify_t	*te_notify;
419 	sc_term_input_t		*te_input;
420 	sc_term_fkeystr_t	*te_fkeystr;
421 } sc_term_sw_t;
422 
423 #define SCTERM_MODULE(name, sw)					\
424 	DATA_SET(scterm_set, sw);				\
425 	static int						\
426 	scterm_##name##_event(module_t mod, int type, void *data) \
427 	{							\
428 		switch (type) {					\
429 		case MOD_LOAD:					\
430 			return sc_term_add(&sw);		\
431 		case MOD_UNLOAD:				\
432 			if (sw.te_refcount > 0)			\
433 				return EBUSY;			\
434 			return sc_term_remove(&sw);		\
435 		default:					\
436 			return EOPNOTSUPP;			\
437 			break;					\
438 		}						\
439 		return 0;					\
440 	}							\
441 	static moduledata_t scterm_##name##_mod = {		\
442 		"scterm-" #name,				\
443 		scterm_##name##_event,				\
444 		NULL,						\
445 	};							\
446 	DECLARE_MODULE(scterm_##name, scterm_##name##_mod,	\
447 		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
448 
449 /* renderer function table */
450 typedef void	vr_init_t(scr_stat *scp);
451 typedef void	vr_clear_t(scr_stat *scp, int c, int attr);
452 typedef void	vr_draw_border_t(scr_stat *scp, int color);
453 typedef void	vr_draw_t(scr_stat *scp, int from, int count, int flip);
454 typedef void	vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
455 typedef void	vr_draw_cursor_t(scr_stat *scp, int at, int blink,
456 				 int on, int flip);
457 typedef void	vr_blink_cursor_t(scr_stat *scp, int at, int flip);
458 typedef void	vr_set_mouse_t(scr_stat *scp);
459 typedef void	vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
460 
461 typedef struct sc_rndr_sw {
462 	vr_init_t		*init;
463 	vr_clear_t		*clear;
464 	vr_draw_border_t	*draw_border;
465 	vr_draw_t		*draw;
466 	vr_set_cursor_t		*set_cursor;
467 	vr_draw_cursor_t	*draw_cursor;
468 	vr_blink_cursor_t	*blink_cursor;
469 	vr_set_mouse_t		*set_mouse;
470 	vr_draw_mouse_t		*draw_mouse;
471 } sc_rndr_sw_t;
472 
473 typedef struct sc_renderer {
474 	char			*name;
475 	int			mode;
476 	sc_rndr_sw_t		*rndrsw;
477 	LIST_ENTRY(sc_renderer)	link;
478 } sc_renderer_t;
479 
480 #define RENDERER(name, mode, sw, set)				\
481 	static struct sc_renderer scrndr_##name##_##mode = {	\
482 		#name, mode, &sw				\
483 	};							\
484 	DATA_SET(scrndr_set, scrndr_##name##_##mode);		\
485 	DATA_SET(set, scrndr_##name##_##mode)
486 
487 #define RENDERER_MODULE(name, set)				\
488 	SET_DECLARE(set, sc_renderer_t);			\
489 	static int						\
490 	scrndr_##name##_event(module_t mod, int type, void *data) \
491 	{							\
492 		sc_renderer_t **list;				\
493 		int error = 0;					\
494 		switch (type) {					\
495 		case MOD_LOAD:					\
496 			SET_FOREACH(list, set) {		\
497 				error = sc_render_add(*list);	\
498 				if (error)			\
499 					break;			\
500 			}					\
501 			break;					\
502 		case MOD_UNLOAD:				\
503 			SET_FOREACH(list, set) {		\
504 				error = sc_render_remove(*list);\
505 				if (error)			\
506 					break;			\
507 			}					\
508 			break;					\
509 		default:					\
510 			return EOPNOTSUPP;			\
511 			break;					\
512 		}						\
513 		return error;					\
514 	}							\
515 	static moduledata_t scrndr_##name##_mod = {		\
516 		"scrndr-" #name,				\
517 		scrndr_##name##_event,				\
518 		NULL,						\
519 	};							\
520 	DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod, 	\
521 		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
522 
523 typedef struct {
524 	int		cursor_start;
525 	int		cursor_end;
526 	int		shift_state;
527 	int		bell_pitch;
528 } bios_values_t;
529 
530 /* other macros */
531 #define ISTEXTSC(scp)	(!((scp)->status 				\
532 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
533 #define ISGRAPHSC(scp)	(((scp)->status 				\
534 			  & (UNKNOWN_MODE | GRAPHICS_MODE)))
535 #define ISPIXELSC(scp)	(((scp)->status 				\
536 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
537 			  == PIXEL_MODE)
538 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
539 
540 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
541 #define ISFONTAVAIL(af)	((af) & V_ADP_FONT)
542 #define ISPALAVAIL(af)	((af) & V_ADP_PALETTE)
543 
544 #define ISSIGVALID(sig)	((sig) > 0 && (sig) < NSIG)
545 
546 #define SC_VIDEO_LOCKINIT(sc)						\
547 		mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,	\
548 		    MTX_SPIN | MTX_RECURSE);
549 #define SC_VIDEO_LOCK(sc)						\
550 		do {							\
551 			if (!kdb_active)				\
552 				mtx_lock_spin(&(sc)->video_mtx);	\
553 		} while(0)
554 #define SC_VIDEO_UNLOCK(sc)						\
555 		do {							\
556 			if (!kdb_active)				\
557 				mtx_unlock_spin(&(sc)->video_mtx);	\
558 		} while(0)
559 
560 /* syscons.c */
561 extern int 	(*sc_user_ioctl)(struct tty *tp, u_long cmd, caddr_t data,
562 				 struct thread *td);
563 
564 int		sc_probe_unit(int unit, int flags);
565 int		sc_attach_unit(int unit, int flags);
566 
567 int		set_mode(scr_stat *scp);
568 
569 void		sc_set_border(scr_stat *scp, int color);
570 void		sc_load_font(scr_stat *scp, int page, int size, int width,
571 			     u_char *font, int base, int count);
572 void		sc_save_font(scr_stat *scp, int page, int size, int width,
573 			     u_char *font, int base, int count);
574 void		sc_show_font(scr_stat *scp, int page);
575 
576 void		sc_touch_scrn_saver(void);
577 void		sc_draw_cursor_image(scr_stat *scp);
578 void		sc_remove_cursor_image(scr_stat *scp);
579 void		sc_set_cursor_image(scr_stat *scp);
580 void		sc_change_cursor_shape(scr_stat *scp, int flags,
581 				       int base, int height);
582 int		sc_clean_up(scr_stat *scp);
583 int		sc_switch_scr(sc_softc_t *sc, u_int next_scr);
584 void		sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
585 int		sc_init_emulator(scr_stat *scp, char *name);
586 void		sc_paste(scr_stat *scp, const u_char *p, int count);
587 void		sc_respond(scr_stat *scp, const u_char *p,
588 			   int count, int wakeup);
589 void		sc_bell(scr_stat *scp, int pitch, int duration);
590 
591 /* schistory.c */
592 #ifndef SC_NO_HISTORY
593 int		sc_alloc_history_buffer(scr_stat *scp, int lines,
594 					int prev_ysize, int wait);
595 void		sc_free_history_buffer(scr_stat *scp, int prev_ysize);
596 void		sc_hist_save(scr_stat *scp);
597 #define		sc_hist_save_one_line(scp, from)	\
598 		sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
599 int		sc_hist_restore(scr_stat *scp);
600 void		sc_hist_home(scr_stat *scp);
601 void		sc_hist_end(scr_stat *scp);
602 int		sc_hist_up_line(scr_stat *scp);
603 int		sc_hist_down_line(scr_stat *scp);
604 int		sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
605 			      struct thread *td);
606 #endif /* SC_NO_HISTORY */
607 
608 /* scmouse.c */
609 #ifndef SC_NO_CUTPASTE
610 void		sc_alloc_cut_buffer(scr_stat *scp, int wait);
611 void		sc_draw_mouse_image(scr_stat *scp);
612 void		sc_remove_mouse_image(scr_stat *scp);
613 int		sc_inside_cutmark(scr_stat *scp, int pos);
614 void		sc_remove_cutmarking(scr_stat *scp);
615 void		sc_remove_all_cutmarkings(sc_softc_t *scp);
616 void		sc_remove_all_mouse(sc_softc_t *scp);
617 void		sc_mouse_paste(scr_stat *scp);
618 #else
619 #define		sc_draw_mouse_image(scp)
620 #define		sc_remove_mouse_image(scp)
621 #define		sc_inside_cutmark(scp, pos)	FALSE
622 #define		sc_remove_cutmarking(scp)
623 #define		sc_remove_all_cutmarkings(scp)
624 #define		sc_remove_all_mouse(scp)
625 #define		sc_mouse_paste(scp)
626 #endif /* SC_NO_CUTPASTE */
627 #ifndef SC_NO_SYSMOUSE
628 void		sc_mouse_move(scr_stat *scp, int x, int y);
629 int		sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
630 			       struct thread *td);
631 #endif /* SC_NO_SYSMOUSE */
632 
633 /* scvidctl.c */
634 int		sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
635 				 int xsize, int ysize, int fontsize,
636 				 int font_width);
637 int		sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
638 int		sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize,
639 				  int ysize, int fontsize, int font_width);
640 int		sc_support_pixel_mode(void *arg);
641 int		sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data,
642 			     struct thread *td);
643 
644 int		sc_render_add(sc_renderer_t *rndr);
645 int		sc_render_remove(sc_renderer_t *rndr);
646 sc_rndr_sw_t	*sc_render_match(scr_stat *scp, char *name, int mode);
647 
648 /* scvtb.c */
649 void		sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows,
650 			    void *buffer, int wait);
651 void		sc_vtb_destroy(sc_vtb_t *vtb);
652 size_t		sc_vtb_size(int cols, int rows);
653 void		sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
654 
655 int		sc_vtb_getc(sc_vtb_t *vtb, int at);
656 int		sc_vtb_geta(sc_vtb_t *vtb, int at);
657 void		sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
658 vm_offset_t	sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a);
659 vm_offset_t	sc_vtb_pointer(sc_vtb_t *vtb, int at);
660 int		sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
661 
662 #define		sc_vtb_tail(vtb)	((vtb)->vtb_tail)
663 #define		sc_vtb_rows(vtb)	((vtb)->vtb_rows)
664 #define		sc_vtb_cols(vtb)	((vtb)->vtb_cols)
665 
666 void		sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
667 			    int count);
668 void		sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
669 			      int count);
670 void		sc_vtb_seek(sc_vtb_t *vtb, int pos);
671 void		sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
672 void		sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
673 void		sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
674 void		sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
675 
676 /* sysmouse.c */
677 int		sysmouse_event(mouse_info_t *info);
678 
679 /* scterm.c */
680 void		sc_move_cursor(scr_stat *scp, int x, int y);
681 void		sc_clear_screen(scr_stat *scp);
682 int		sc_term_add(sc_term_sw_t *sw);
683 int		sc_term_remove(sc_term_sw_t *sw);
684 sc_term_sw_t	*sc_term_match(char *name);
685 sc_term_sw_t	*sc_term_match_by_number(int index);
686 
687 /* machine dependent functions */
688 int		sc_max_unit(void);
689 sc_softc_t	*sc_get_softc(int unit, int flags);
690 sc_softc_t	*sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
691 int		sc_get_cons_priority(int *unit, int *flags);
692 void		sc_get_bios_values(bios_values_t *values);
693 int		sc_tone(int herz);
694 
695 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */
696