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