xref: /freebsd/sys/dev/syscons/syscons.h (revision 4bc52338)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1995-1998 Søren Schmidt
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The DragonFly Project
8  * by Sascha Wildner <saw@online.de>
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer,
15  *    without modification, immediately at the beginning of the file.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * $FreeBSD$
34  */
35 
36 #ifndef _DEV_SYSCONS_SYSCONS_H_
37 #define	_DEV_SYSCONS_SYSCONS_H_
38 
39 #include <sys/kdb.h>		/* XXX */
40 #include <sys/_lock.h>
41 #include <sys/_mutex.h>
42 
43 /* default values for configuration options */
44 
45 #ifndef MAXCONS
46 #define MAXCONS		16
47 #endif
48 
49 #ifdef SC_NO_SYSMOUSE
50 #undef SC_NO_CUTPASTE
51 #define SC_NO_CUTPASTE	1
52 #endif
53 
54 #ifdef SC_NO_MODE_CHANGE
55 #undef SC_PIXEL_MODE
56 #endif
57 
58 /* Always load font data if the pixel (raster text) mode is to be used. */
59 #ifdef SC_PIXEL_MODE
60 #undef SC_NO_FONT_LOADING
61 #endif
62 
63 /*
64  * If font data is not available, the `arrow'-shaped mouse cursor cannot
65  * be drawn.  Use the alternative drawing method.
66  */
67 #ifdef SC_NO_FONT_LOADING
68 #undef SC_ALT_MOUSE_IMAGE
69 #define SC_ALT_MOUSE_IMAGE 1
70 #endif
71 
72 #ifndef SC_CURSOR_CHAR
73 #define SC_CURSOR_CHAR	7
74 #endif
75 
76 #ifndef SC_MOUSE_CHAR
77 #define SC_MOUSE_CHAR	8
78 #endif
79 
80 #if SC_MOUSE_CHAR <= SC_CURSOR_CHAR && SC_CURSOR_CHAR < (SC_MOUSE_CHAR + 4)
81 #undef SC_CURSOR_CHAR
82 #define SC_CURSOR_CHAR	(SC_MOUSE_CHAR + 4)
83 #endif
84 
85 #ifndef SC_DEBUG_LEVEL
86 #define SC_DEBUG_LEVEL	0
87 #endif
88 
89 #define DPRINTF(l, p)	if (SC_DEBUG_LEVEL >= (l)) printf p
90 
91 #ifndef __sparc64__
92 #define SC_DRIVER_NAME	"sc"
93 #else
94 /*
95  * Use a different driver name on sparc64 so it does not get confused
96  * with the system controller devices which are also termed 'sc' in OFW.
97  */
98 #define SC_DRIVER_NAME	"syscons"
99 #endif
100 #define SC_VTY(dev)	(((sc_ttysoftc *)tty_softc(tp))->st_index)
101 #define SC_DEV(sc, vty)	((sc)->dev[(vty) - (sc)->first_vty])
102 #define SC_STAT(tp)	(*((scr_stat **)&((sc_ttysoftc *)tty_softc(tp))->st_stat))
103 
104 /* printable chars */
105 #ifndef PRINTABLE
106 #define PRINTABLE(ch)	((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
107 			 || (ch) < 0x07)
108 #endif
109 
110 /* macros for "intelligent" screen update */
111 #define mark_for_update(scp, x)	{\
112 			  	    if ((x) < scp->start) scp->start = (x);\
113 				    else if ((x) > scp->end) scp->end = (x);\
114 				}
115 #define mark_all(scp)		{\
116 				    scp->start = 0;\
117 				    scp->end = scp->xsize * scp->ysize - 1;\
118 				}
119 
120 /* vty status flags (scp->status) */
121 #define UNKNOWN_MODE	0x00010		/* unknown video mode */
122 #define SWITCH_WAIT_REL	0x00080		/* waiting for vty release */
123 #define SWITCH_WAIT_ACQ	0x00100		/* waiting for vty ack */
124 #define BUFFER_SAVED	0x00200		/* vty buffer is saved */
125 #define CURSOR_ENABLED 	0x00400		/* text cursor is enabled */
126 #define MOUSE_MOVED	0x01000		/* mouse cursor has moved */
127 #define MOUSE_CUTTING	0x02000		/* mouse cursor is cutting text */
128 #define MOUSE_VISIBLE	0x04000		/* mouse cursor is showing */
129 #define GRAPHICS_MODE	0x08000		/* vty is in a graphics mode */
130 #define PIXEL_MODE	0x10000		/* vty is in a raster text mode */
131 #define SAVER_RUNNING	0x20000		/* screen saver is running */
132 #define VR_CURSOR_BLINK	0x40000		/* blinking text cursor */
133 #define VR_CURSOR_ON	0x80000		/* text cursor is on */
134 #define MOUSE_HIDDEN	0x100000	/* mouse cursor is temporarily hidden */
135 
136 /* misc defines */
137 #define FALSE		0
138 #define TRUE		1
139 
140 /*
141    The following #defines are hard-coded for a maximum text
142    resolution corresponding to a maximum framebuffer
143    resolution of 1920x1200 with an 8x8 font...
144 */
145 #define	COL		240
146 #define	ROW		150
147 
148 #define PCBURST		128
149 
150 #ifndef BELL_DURATION
151 #define BELL_DURATION	((5 * hz + 99) / 100)
152 #define BELL_PITCH	800
153 #endif
154 
155 /* virtual terminal buffer */
156 typedef struct sc_vtb {
157 	int		vtb_flags;
158 #define VTB_VALID	(1 << 0)
159 #define VTB_ALLOCED	(1 << 1)
160 	int		vtb_type;
161 #define VTB_INVALID	0
162 #define VTB_MEMORY	1
163 #define VTB_FRAMEBUFFER	2
164 #define VTB_RINGBUFFER	3
165 	int		vtb_cols;
166 	int		vtb_rows;
167 	int		vtb_size;
168 	vm_offset_t	vtb_buffer;
169 	int		vtb_tail;	/* valid for VTB_RINGBUFFER only */
170 } sc_vtb_t;
171 
172 /* text and some mouse cursor attributes */
173 struct cursor_attr {
174 	u_char		flags;
175 	u_char		base;
176 	u_char		height;
177 	u_char		bg[3];
178 	u_char		mouse_ba;
179 	u_char		mouse_ia;
180 };
181 
182 /* softc */
183 
184 struct keyboard;
185 struct video_adapter;
186 struct scr_stat;
187 struct tty;
188 
189 struct sc_cnstate {
190 	u_char		kbd_locked;
191 	u_char		kdb_locked;
192 	u_char		mtx_locked;
193 	u_char		kbd_opened;
194 	u_char		scr_opened;
195 };
196 
197 typedef struct sc_softc {
198 	int		unit;			/* unit # */
199 	int		config;			/* configuration flags */
200 #define SC_VESAMODE	(1 << 7)
201 #define SC_AUTODETECT_KBD (1 << 8)
202 #define SC_KERNEL_CONSOLE (1 << 9)
203 
204 	int		flags;			/* status flags */
205 #define SC_VISUAL_BELL	(1 << 0)
206 #define SC_QUIET_BELL	(1 << 1)
207 #if 0 /* not used anymore */
208 #define SC_BLINK_CURSOR	(1 << 2)
209 #define SC_CHAR_CURSOR	(1 << 3)
210 #endif
211 #define SC_MOUSE_ENABLED (1 << 4)
212 #define	SC_SCRN_IDLE	(1 << 5)
213 #define	SC_SCRN_BLANKED	(1 << 6)
214 #define	SC_SAVER_FAILED	(1 << 7)
215 #define	SC_SCRN_VTYLOCK	(1 << 8)
216 
217 #define	SC_INIT_DONE	(1 << 16)
218 #define	SC_SPLASH_SCRN	(1 << 17)
219 
220 	int		keyboard;		/* -1 if unavailable */
221 	struct keyboard	*kbd;
222 
223 	int		adapter;
224 	struct video_adapter *adp;
225 	int		initial_mode;		/* initial video mode */
226 
227 	int		first_vty;
228 	int		vtys;
229 	struct tty **dev;
230 	struct scr_stat	*cur_scp;
231 	struct scr_stat	*new_scp;
232 	struct scr_stat	*old_scp;
233 	int     	delayed_next_scr;
234 
235 	char        	font_loading_in_progress;
236 	char        	switch_in_progress;
237 	char        	write_in_progress;
238 	char        	blink_in_progress;
239 	int		grab_level;
240 	/* 2 is just enough for kdb to grab for stepping normal grabbing: */
241 	struct sc_cnstate grab_state[2];
242 	int		kbd_open_level;
243 	struct mtx	video_mtx;
244 
245 	long		scrn_time_stamp;
246 
247 	struct cursor_attr dflt_curs_attr;
248 	struct cursor_attr curs_attr;
249 
250 	u_char      	scr_map[256];
251 	u_char      	scr_rmap[256];
252 
253 #ifdef _SC_MD_SOFTC_DECLARED_
254 	sc_md_softc_t	md;			/* machine dependent vars */
255 #endif
256 
257 #ifndef SC_NO_PALETTE_LOADING
258 	u_char		palette[256 * 3];
259 #ifdef SC_PIXEL_MODE
260 	u_char		palette2[256 * 3];
261 #endif
262 #endif
263 
264 #ifndef SC_NO_FONT_LOADING
265 	int     	fonts_loaded;
266 #define FONT_8		2
267 #define FONT_14		4
268 #define FONT_16		8
269 #define FONT_22		8
270 	u_char		*font_8;
271 	u_char		*font_14;
272 	u_char		*font_16;
273 	u_char		*font_22;
274 #endif
275 
276 	u_char		cursor_char;
277 	u_char		mouse_char;
278 
279 #ifdef KDB
280 	int		sc_altbrk;
281 #endif
282 	struct callout	ctimeout;
283 	struct callout	cblink;
284 } sc_softc_t;
285 
286 /* virtual screen */
287 typedef struct scr_stat {
288 	int		index;			/* index of this vty */
289 	struct sc_softc *sc;			/* pointer to softc */
290 	struct sc_rndr_sw *rndr;		/* renderer */
291 #ifndef __sparc64__
292 	sc_vtb_t	scr;
293 #endif
294 	sc_vtb_t	vtb;
295 
296 	int 		xpos;			/* current X position */
297 	int 		ypos;			/* current Y position */
298 	int 		xsize;			/* X text size */
299 	int 		ysize;			/* Y text size */
300 	int 		xpixel;			/* X graphics size */
301 	int 		ypixel;			/* Y graphics size */
302 	int		xoff;			/* X offset in pixel mode */
303 	int		yoff;			/* Y offset in pixel mode */
304 
305 	u_char		*font;			/* current font */
306 	int		font_size;		/* fontsize in Y direction */
307 	int		font_width;		/* fontsize in X direction */
308 
309 	int		start;			/* modified area start */
310 	int		end;			/* modified area end */
311 
312 	struct sc_term_sw *tsw;
313 	void		*ts;
314 
315 	int	 	status;			/* status (bitfield) */
316 	int		kbd_mode;		/* keyboard I/O mode */
317 
318 	int		cursor_pos;		/* cursor buffer position */
319 	int		cursor_oldpos;		/* cursor old buffer position */
320 	struct cursor_attr dflt_curs_attr;
321 	struct cursor_attr base_curs_attr;
322 	struct cursor_attr curs_attr;
323 
324 	int		mouse_pos;		/* mouse buffer position */
325 	int		mouse_oldpos;		/* mouse old buffer position */
326 	short		mouse_xpos;		/* mouse x coordinate */
327 	short		mouse_ypos;		/* mouse y coordinate */
328 	short		mouse_oldxpos;		/* mouse previous x coordinate */
329 	short		mouse_oldypos;		/* mouse previous y coordinate */
330 	short		mouse_buttons;		/* mouse buttons */
331 	int		mouse_cut_start;	/* mouse cut start pos */
332 	int		mouse_cut_end;		/* mouse cut end pos */
333 	int		mouse_level;		/* xterm mouse protocol */
334 	struct proc 	*mouse_proc;		/* proc* of controlling proc */
335 	pid_t 		mouse_pid;		/* pid of controlling proc */
336 	int		mouse_signal;		/* signal # to report with */
337 	const void	*mouse_data;		/* renderer (pixmap) data */
338 
339 	u_short		bell_duration;
340 	u_short		bell_pitch;
341 
342 	u_char		border;			/* border color */
343 	int	 	mode;			/* mode */
344 	pid_t 		pid;			/* pid of controlling proc */
345 	struct proc 	*proc;			/* proc* of controlling proc */
346 	struct vt_mode 	smode;			/* switch mode */
347 
348 	sc_vtb_t	*history;		/* circular history buffer */
349 	int		history_pos;		/* position shown on screen */
350 	int		history_size;		/* size of history buffer */
351 
352 	int		splash_save_mode;	/* saved mode for splash screen */
353 	int		splash_save_status;	/* saved status for splash screen */
354 #ifdef _SCR_MD_STAT_DECLARED_
355 	scr_md_stat_t	md;			/* machine dependent vars */
356 #endif
357 } scr_stat;
358 
359 /* TTY softc. */
360 typedef struct sc_ttysoftc {
361 	int		st_index;
362 	scr_stat	*st_stat;
363 } sc_ttysoftc;
364 
365 #ifndef SC_NORM_ATTR
366 #define SC_NORM_ATTR		(FG_LIGHTGREY | BG_BLACK)
367 #endif
368 #ifndef SC_NORM_REV_ATTR
369 #define SC_NORM_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
370 #endif
371 #ifndef SC_KERNEL_CONS_ATTR
372 #define SC_KERNEL_CONS_ATTR	(FG_WHITE | BG_BLACK)
373 #endif
374 #ifndef SC_KERNEL_CONS_REV_ATTR
375 #define SC_KERNEL_CONS_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
376 #endif
377 
378 /* terminal emulator */
379 
380 #ifndef SC_DFLT_TERM
381 #define SC_DFLT_TERM	"scteken"
382 #endif
383 
384 typedef int	sc_term_init_t(scr_stat *scp, void **tcp, int code);
385 #define SC_TE_COLD_INIT	0
386 #define SC_TE_WARM_INIT	1
387 typedef int	sc_term_term_t(scr_stat *scp, void **tcp);
388 typedef void	sc_term_puts_t(scr_stat *scp, u_char *buf, int len);
389 typedef int	sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
390 				caddr_t data, struct thread *td);
391 typedef int	sc_term_reset_t(scr_stat *scp, int code);
392 #define SC_TE_HARD_RESET 0
393 #define SC_TE_SOFT_RESET 1
394 typedef void	sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
395 typedef void	sc_term_clear_t(scr_stat *scp);
396 typedef void	sc_term_notify_t(scr_stat *scp, int event);
397 #define SC_TE_NOTIFY_VTSWITCH_IN	0
398 #define SC_TE_NOTIFY_VTSWITCH_OUT	1
399 typedef int	sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
400 typedef const char *sc_term_fkeystr_t(scr_stat *scp, int c);
401 typedef void sc_term_sync_t(scr_stat *scp);
402 
403 typedef struct sc_term_sw {
404 	LIST_ENTRY(sc_term_sw)	link;
405 	char 			*te_name;	/* name of the emulator */
406 	char 			*te_desc;	/* description */
407 	char 			*te_renderer;	/* matching renderer */
408 	size_t			te_size;	/* size of internal buffer */
409 	int			te_refcount;	/* reference counter */
410 	sc_term_init_t		*te_init;
411 	sc_term_term_t		*te_term;
412 	sc_term_puts_t		*te_puts;
413 	sc_term_ioctl_t		*te_ioctl;
414 	sc_term_reset_t		*te_reset;
415 	sc_term_default_attr_t	*te_default_attr;
416 	sc_term_clear_t		*te_clear;
417 	sc_term_notify_t	*te_notify;
418 	sc_term_input_t		*te_input;
419 	sc_term_fkeystr_t	*te_fkeystr;
420 	sc_term_sync_t		*te_sync;
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		shift_state;
525 	int		bell_pitch;
526 } bios_values_t;
527 
528 /* other macros */
529 #define ISTEXTSC(scp)	(!((scp)->status 				\
530 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
531 #define ISGRAPHSC(scp)	(((scp)->status 				\
532 			  & (UNKNOWN_MODE | GRAPHICS_MODE)))
533 #define ISPIXELSC(scp)	(((scp)->status 				\
534 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
535 			  == PIXEL_MODE)
536 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
537 
538 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
539 #define ISFONTAVAIL(af)	((af) & V_ADP_FONT)
540 #define ISPALAVAIL(af)	((af) & V_ADP_PALETTE)
541 
542 #define ISSIGVALID(sig)	((sig) > 0 && (sig) < NSIG)
543 
544 #define SC_VIDEO_LOCKINIT(sc)						\
545 		mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,	\
546 		    MTX_SPIN | MTX_RECURSE);
547 #define SC_VIDEO_LOCK(sc)						\
548 		do {							\
549 			if (!kdb_active)				\
550 				mtx_lock_spin(&(sc)->video_mtx);	\
551 		} while(0)
552 #define SC_VIDEO_UNLOCK(sc)						\
553 		do {							\
554 			if (!kdb_active)				\
555 				mtx_unlock_spin(&(sc)->video_mtx);	\
556 		} while(0)
557 
558 /* syscons.c */
559 extern int 	(*sc_user_ioctl)(struct tty *tp, u_long cmd, caddr_t data,
560 				 struct thread *td);
561 
562 int		sc_probe_unit(int unit, int flags);
563 int		sc_attach_unit(int unit, int flags);
564 
565 int		set_mode(scr_stat *scp);
566 
567 void		sc_set_border(scr_stat *scp, int color);
568 void		sc_load_font(scr_stat *scp, int page, int size, int width,
569 			     u_char *font, int base, int count);
570 void		sc_save_font(scr_stat *scp, int page, int size, int width,
571 			     u_char *font, int base, int count);
572 void		sc_show_font(scr_stat *scp, int page);
573 
574 void		sc_touch_scrn_saver(void);
575 void		sc_draw_cursor_image(scr_stat *scp);
576 void		sc_remove_cursor_image(scr_stat *scp);
577 void		sc_set_cursor_image(scr_stat *scp);
578 void		sc_change_cursor_shape(scr_stat *scp, int flags,
579 				       int base, int height);
580 int		sc_clean_up(scr_stat *scp);
581 int		sc_switch_scr(sc_softc_t *sc, u_int next_scr);
582 void		sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
583 int		sc_init_emulator(scr_stat *scp, char *name);
584 void		sc_paste(scr_stat *scp, const u_char *p, int count);
585 void		sc_respond(scr_stat *scp, const u_char *p,
586 			   int count, int wakeup);
587 void		sc_bell(scr_stat *scp, int pitch, int duration);
588 
589 /* schistory.c */
590 #ifndef SC_NO_HISTORY
591 int		sc_alloc_history_buffer(scr_stat *scp, int lines,
592 					int prev_ysize, int wait);
593 void		sc_free_history_buffer(scr_stat *scp, int prev_ysize);
594 void		sc_hist_save(scr_stat *scp);
595 #define		sc_hist_save_one_line(scp, from)	\
596 		sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
597 int		sc_hist_restore(scr_stat *scp);
598 void		sc_hist_home(scr_stat *scp);
599 void		sc_hist_end(scr_stat *scp);
600 int		sc_hist_up_line(scr_stat *scp);
601 int		sc_hist_down_line(scr_stat *scp);
602 int		sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
603 			      struct thread *td);
604 #endif /* SC_NO_HISTORY */
605 
606 /* scmouse.c */
607 #ifndef SC_NO_CUTPASTE
608 void		sc_alloc_cut_buffer(scr_stat *scp, int wait);
609 void		sc_draw_mouse_image(scr_stat *scp);
610 void		sc_remove_mouse_image(scr_stat *scp);
611 int		sc_inside_cutmark(scr_stat *scp, int pos);
612 void		sc_remove_cutmarking(scr_stat *scp);
613 void		sc_remove_all_cutmarkings(sc_softc_t *scp);
614 void		sc_remove_all_mouse(sc_softc_t *scp);
615 void		sc_mouse_paste(scr_stat *scp);
616 #else
617 #define		sc_draw_mouse_image(scp)
618 #define		sc_remove_mouse_image(scp)
619 #define		sc_inside_cutmark(scp, pos)	FALSE
620 #define		sc_remove_cutmarking(scp)
621 #define		sc_remove_all_cutmarkings(scp)
622 #define		sc_remove_all_mouse(scp)
623 #define		sc_mouse_paste(scp)
624 #endif /* SC_NO_CUTPASTE */
625 #ifndef SC_NO_SYSMOUSE
626 void		sc_mouse_move(scr_stat *scp, int x, int y);
627 int		sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
628 			       struct thread *td);
629 #endif /* SC_NO_SYSMOUSE */
630 
631 /* scvidctl.c */
632 int		sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
633 				 int xsize, int ysize, int fontsize,
634 				 int font_width);
635 int		sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
636 int		sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize,
637 				  int ysize, int fontsize, int font_width);
638 int		sc_support_pixel_mode(void *arg);
639 int		sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data,
640 			     struct thread *td);
641 
642 int		sc_render_add(sc_renderer_t *rndr);
643 int		sc_render_remove(sc_renderer_t *rndr);
644 sc_rndr_sw_t	*sc_render_match(scr_stat *scp, char *name, int mode);
645 
646 /* scvtb.c */
647 void		sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows,
648 			    void *buffer, int wait);
649 void		sc_vtb_destroy(sc_vtb_t *vtb);
650 size_t		sc_vtb_size(int cols, int rows);
651 void		sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
652 
653 int		sc_vtb_getc(sc_vtb_t *vtb, int at);
654 int		sc_vtb_geta(sc_vtb_t *vtb, int at);
655 void		sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
656 vm_offset_t	sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a);
657 vm_offset_t	sc_vtb_pointer(sc_vtb_t *vtb, int at);
658 int		sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
659 
660 #define		sc_vtb_tail(vtb)	((vtb)->vtb_tail)
661 #define		sc_vtb_rows(vtb)	((vtb)->vtb_rows)
662 #define		sc_vtb_cols(vtb)	((vtb)->vtb_cols)
663 
664 void		sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
665 			    int count);
666 void		sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
667 			      int count);
668 void		sc_vtb_seek(sc_vtb_t *vtb, int pos);
669 void		sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
670 void		sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
671 void		sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
672 void		sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
673 
674 /* sysmouse.c */
675 int		sysmouse_event(mouse_info_t *info);
676 
677 /* scterm.c */
678 void		sc_move_cursor(scr_stat *scp, int x, int y);
679 void		sc_clear_screen(scr_stat *scp);
680 int		sc_term_add(sc_term_sw_t *sw);
681 int		sc_term_remove(sc_term_sw_t *sw);
682 sc_term_sw_t	*sc_term_match(char *name);
683 sc_term_sw_t	*sc_term_match_by_number(int index);
684 
685 /* machine dependent functions */
686 int		sc_max_unit(void);
687 sc_softc_t	*sc_get_softc(int unit, int flags);
688 sc_softc_t	*sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
689 int		sc_get_cons_priority(int *unit, int *flags);
690 void		sc_get_bios_values(bios_values_t *values);
691 int		sc_tone(int herz);
692 
693 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */
694