xref: /dflybsd-src/sys/dev/misc/syscons/syscons.h (revision 02d0b1ce2a4f5e91f8a38d977e6239e4483d4d48)
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: src/sys/dev/syscons/syscons.h,v 1.60.2.6 2002/09/15 22:30:45 dd Exp $
32  */
33 
34 #ifndef _DEV_SYSCONS_SYSCONS_H_
35 #define	_DEV_SYSCONS_SYSCONS_H_
36 
37 #include <sys/malloc.h>
38 
39 MALLOC_DECLARE(M_SYSCONS);
40 
41 /* default values for configuration options */
42 
43 #ifndef MAXCONS
44 #define MAXCONS		16	/* power of 2 */
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)) kprintf p
88 
89 #define SC_DRIVER_NAME	"sc"
90 #define SC_VTY(dev)	minor(dev)
91 #define SC_DEV(sc, vty)	((sc)->dev ? (sc)->dev[(vty) - (sc)->first_vty] : NULL)
92 #define SC_STAT(dev)	((scr_stat *)(dev)->si_drv1)
93 
94 /* printable chars */
95 #ifndef PRINTABLE
96 #define PRINTABLE(ch)	((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
97 			 || (ch) < 0x07)
98 #endif
99 
100 /* macros for "intelligent" screen update */
101 #define mark_for_update(scp, x)	{\
102 			  	    if ((x) < scp->start) scp->start = (x);\
103 				    else if ((x) > scp->end) scp->end = (x);\
104 				}
105 #define mark_all(scp)		{\
106 				    scp->start = 0;\
107 				    scp->end = scp->xsize * scp->ysize - 1;\
108 				}
109 
110 /* macro for calculating the drawing position in video memory */
111 #ifdef SC_PIXEL_MODE
112 #define	VIDEO_MEMORY_POS(scp, pos, x) 					\
113 	((scp)->sc->adp->va_window +					\
114 	 (x) * (scp)->xoff +						\
115 	 (scp)->yoff * (scp)->font_size * (scp)->sc->adp->va_line_width +\
116 	 (x) * ((pos) % (scp)->xsize) +					\
117 	 (scp)->font_size * (scp)->sc->adp->va_line_width * (pos / (scp)->xsize))
118 #endif
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 #define	COL		80
140 #define	ROW		25
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 	uint16_t	*vtb_buffer;
162 	int		vtb_tail;	/* valid for VTB_RINGBUFFER only */
163 } sc_vtb_t;
164 
165 /* softc */
166 
167 struct keyboard;
168 struct video_adapter;
169 struct scr_stat;
170 struct tty;
171 struct dev_ioctl_args;
172 
173 typedef struct sc_softc {
174 	int		unit;			/* unit # */
175 	int		config;			/* configuration flags */
176 #define SC_VESA800X600	(1 << 7)
177 #define SC_AUTODETECT_KBD (1 << 8)
178 #define SC_KERNEL_CONSOLE (1 << 9)
179 
180 	int		flags;			/* status flags */
181 #define SC_VISUAL_BELL	(1 << 0)
182 #define SC_QUIET_BELL	(1 << 1)
183 #define SC_BLINK_CURSOR	(1 << 2)
184 #define SC_CHAR_CURSOR	(1 << 3)
185 #define SC_MOUSE_ENABLED (1 << 4)
186 #define	SC_SCRN_IDLE	(1 << 5)
187 #define	SC_SCRN_BLANKED	(1 << 6)
188 #define	SC_SAVER_FAILED	(1 << 7)
189 #define	SC_SCRN_VTYLOCK	(1 << 8)
190 
191 #define	SC_INIT_DONE	(1 << 16)
192 #define	SC_SPLASH_SCRN	(1 << 17)
193 
194 	int		keyboard;		/* -1 if unavailable */
195 	struct keyboard	*kbd;
196 
197 	int		adapter;
198 	struct video_adapter *adp;
199 	int		initial_mode;		/* initial video mode */
200 
201 	struct fb_info	*fbi;
202 
203 	int		first_vty;
204 	int		vtys;
205 	cdev_t		*dev;
206 	struct scr_stat	*console_scp;
207 	struct scr_stat	*cur_scp;
208 	struct scr_stat	*new_scp;
209 	struct scr_stat	*old_scp;
210 	int     	delayed_next_scr;
211 
212 	char        	font_loading_in_progress;
213 	char        	switch_in_progress;
214 	char        	videoio_in_progress;
215 	char        	write_in_progress;
216 	char        	blink_in_progress;
217 
218 	long		scrn_time_stamp;
219 	struct callout	scrn_timer_ch;
220 
221 	char		cursor_base;
222 	char		cursor_height;
223 
224 	u_char      	scr_map[256];
225 	u_char      	scr_rmap[256];
226 
227 #ifdef _SC_MD_SOFTC_DECLARED_
228 	sc_md_softc_t	md;			/* machine dependent vars */
229 #endif
230 
231 #ifndef SC_NO_PALETTE_LOADING
232 	u_char        	palette[256*3];
233 #endif
234 
235 #ifndef SC_NO_FONT_LOADING
236 	int     	fonts_loaded;
237 #define FONT_8		2
238 #define FONT_14		4
239 #define FONT_16		8
240 	u_char		*font_8;
241 	u_char		*font_14;
242 	u_char		*font_16;
243 #endif
244 
245 	u_char		cursor_char;
246 	u_char		mouse_char;
247 
248 } sc_softc_t;
249 
250 /* virtual screen */
251 typedef struct scr_stat {
252 	int		index;			/* index of this vty */
253 	struct sc_softc *sc;			/* pointer to softc */
254 	struct sc_rndr_sw *rndr;		/* renderer */
255 	sc_vtb_t	scr;
256 	sc_vtb_t	vtb;
257 	struct fb_info	*fbi;
258 
259 	int 		xpos;			/* current X position */
260 	int 		ypos;			/* current Y position */
261 	int 		xsize;			/* X text size */
262 	int 		ysize;			/* Y text size */
263 	int 		xpixel;			/* X graphics size */
264 	int 		ypixel;			/* Y graphics size */
265 	int		xpad;			/* for fbi->stride % 8 != 0 */
266 	int		xoff;			/* X offset in pixel mode */
267 	int		yoff;			/* Y offset in pixel mode */
268 
269 	u_char		*font;			/* current font */
270 	int		font_size;		/* fontsize in Y direction */
271 
272 	int		start;			/* modified area start */
273 	int		end;			/* modified area end */
274 
275 	struct sc_term_sw *tsw;
276 	void		*ts;
277 
278 	int	 	status;			/* status (bitfield) */
279 	int		kbd_mode;		/* keyboard I/O mode */
280 
281 	int		cursor_pos;		/* cursor buffer position */
282 	int		cursor_oldpos;		/* cursor old buffer position */
283 	u_short		cursor_saveunder_char;	/* saved char under cursor */
284 	u_short		cursor_saveunder_attr;	/* saved attr under cursor */
285 	char		cursor_base;		/* cursor base line # */
286 	char		cursor_height;		/* cursor height */
287 
288 	int		mouse_pos;		/* mouse buffer position */
289 	int		mouse_oldpos;		/* mouse old buffer position */
290 	short		mouse_xpos;		/* mouse x coordinate */
291 	short		mouse_ypos;		/* mouse y coordinate */
292 	short		mouse_oldxpos;		/* mouse previous x coordinate */
293 	short		mouse_oldypos;		/* mouse previous y coordinate */
294 	short		mouse_buttons;		/* mouse buttons */
295 	int		mouse_cut_start;	/* mouse cut start pos */
296 	int		mouse_cut_end;		/* mouse cut end pos */
297 	struct proc 	*mouse_proc;		/* proc* of controlling proc */
298 	pid_t 		mouse_pid;		/* pid of controlling proc */
299 	int		mouse_signal;		/* signal # to report with */
300 
301 	u_short		bell_duration;
302 	u_short		bell_pitch;
303 
304 	struct callout	blink_screen_ch;
305 
306 	uint32_t	ega_palette[16];	/* ega palette */
307 	u_char		border;			/* border color */
308 	int	 	mode;			/* mode */
309 	int		model;			/* memory model */
310 	pid_t 		pid;			/* pid of controlling proc */
311 	struct proc 	*proc;			/* proc* of controlling proc */
312 	struct vt_mode 	smode;			/* switch mode */
313 
314 	sc_vtb_t	*history;		/* circular history buffer */
315 	int		history_pos;		/* position shown on screen */
316 	int		history_size;		/* size of history buffer */
317 
318 	int		splash_save_mode;	/* saved mode for splash screen */
319 	int		splash_save_status;	/* saved status for splash screen */
320 #ifdef _SCR_MD_STAT_DECLARED_
321 	scr_md_stat_t	md;			/* machine dependent vars */
322 #endif
323 } scr_stat;
324 
325 #ifndef SC_NORM_ATTR
326 #define SC_NORM_ATTR		(FG_LIGHTGREY | BG_BLACK)
327 #endif
328 #ifndef SC_NORM_REV_ATTR
329 #define SC_NORM_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
330 #endif
331 #ifndef SC_KERNEL_CONS_ATTR
332 #define SC_KERNEL_CONS_ATTR	(FG_WHITE | BG_BLACK)
333 #endif
334 #ifndef SC_KERNEL_CONS_REV_ATTR
335 #define SC_KERNEL_CONS_REV_ATTR	(FG_BLACK | BG_LIGHTGREY)
336 #endif
337 
338 /* terminal emulator */
339 
340 #ifndef SC_DFLT_TERM
341 #define SC_DFLT_TERM	"*"			/* any */
342 #endif
343 
344 typedef int	sc_term_init_t(scr_stat *scp, void **tcp, int code);
345 #define SC_TE_COLD_INIT	0
346 #define SC_TE_WARM_INIT	1
347 typedef int	sc_term_term_t(scr_stat *scp, void **tcp);
348 typedef void	sc_term_puts_t(scr_stat *scp, u_char *buf, int len);
349 typedef int	sc_term_ioctl_t(scr_stat *scp, struct tty *tp, u_long cmd,
350 				caddr_t data, int flag);
351 typedef int	sc_term_reset_t(scr_stat *scp, int code);
352 #define SC_TE_HARD_RESET 0
353 #define SC_TE_SOFT_RESET 1
354 typedef void	sc_term_default_attr_t(scr_stat *scp, int norm, int rev);
355 typedef void	sc_term_clear_t(scr_stat *scp);
356 typedef void	sc_term_notify_t(scr_stat *scp, int event);
357 #define SC_TE_NOTIFY_VTSWITCH_IN	0
358 #define SC_TE_NOTIFY_VTSWITCH_OUT	1
359 typedef int	sc_term_input_t(scr_stat *scp, int c, struct tty *tp);
360 
361 typedef struct sc_term_sw {
362 	LIST_ENTRY(sc_term_sw)	link;
363 	char 			*te_name;	/* name of the emulator */
364 	char 			*te_desc;	/* description */
365 	char 			*te_renderer;	/* matching renderer */
366 	size_t			te_size;	/* size of internal buffer */
367 	int			te_refcount;	/* reference counter */
368 	sc_term_init_t		*te_init;
369 	sc_term_term_t		*te_term;
370 	sc_term_puts_t		*te_puts;
371 	sc_term_ioctl_t		*te_ioctl;
372 	sc_term_reset_t		*te_reset;
373 	sc_term_default_attr_t	*te_default_attr;
374 	sc_term_clear_t		*te_clear;
375 	sc_term_notify_t	*te_notify;
376 	sc_term_input_t		*te_input;
377 } sc_term_sw_t;
378 
379 extern struct linker_set scterm_set;
380 
381 #define SCTERM_MODULE(name, sw)					\
382 	DATA_SET(scterm_set, sw);				\
383 	static int						\
384 	scterm_##name##_event(module_t mod, int type, void *data) \
385 	{							\
386 		switch (type) {					\
387 		case MOD_LOAD:					\
388 			return sc_term_add(&sw);		\
389 		case MOD_UNLOAD:				\
390 			if (sw.te_refcount > 0)			\
391 				return EBUSY;			\
392 			return sc_term_remove(&sw);		\
393 		default:					\
394 			break;					\
395 		}						\
396 		return 0;					\
397 	}							\
398 	static moduledata_t scterm_##name##_mod = {		\
399 		"scterm-" #name,				\
400 		scterm_##name##_event,				\
401 		NULL,						\
402 	};							\
403 	DECLARE_MODULE(scterm_##name, scterm_##name##_mod,	\
404 		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
405 
406 /* renderer function table */
407 typedef void	vr_draw_border_t(scr_stat *scp, int color);
408 typedef void	vr_draw_t(scr_stat *scp, int from, int count, int flip);
409 typedef void	vr_set_cursor_t(scr_stat *scp, int base, int height, int blink);
410 typedef void	vr_draw_cursor_t(scr_stat *scp, int at, int blink,
411 				 int on, int flip);
412 typedef void	vr_blink_cursor_t(scr_stat *scp, int at, int flip);
413 typedef void	vr_set_mouse_t(scr_stat *scp);
414 typedef void	vr_draw_mouse_t(scr_stat *scp, int x, int y, int on);
415 
416 typedef struct sc_rndr_sw {
417 	vr_draw_border_t	*draw_border;
418 	vr_draw_t		*draw;
419 	vr_set_cursor_t		*set_cursor;
420 	vr_draw_cursor_t	*draw_cursor;
421 	vr_blink_cursor_t	*blink_cursor;
422 	vr_draw_mouse_t		*draw_mouse;
423 } sc_rndr_sw_t;
424 
425 typedef struct sc_renderer {
426 	char			*name;
427 	int			model;
428 	sc_rndr_sw_t		*rndrsw;
429 	LIST_ENTRY(sc_renderer)	link;
430 } sc_renderer_t;
431 
432 extern struct linker_set scrndr_set;
433 
434 #define RENDERER(name, model, sw, set)				\
435 	static struct sc_renderer scrndr_##name##_##model = {	\
436 		#name, model, &sw				\
437 	};							\
438 	DATA_SET(scrndr_set, scrndr_##name##_##model);		\
439 	DATA_SET(set, scrndr_##name##_##model)
440 
441 #define RENDERER_MODULE(name, set)				\
442 	SET_DECLARE(set, sc_renderer_t);			\
443 	static int						\
444 	scrndr_##name##_event(module_t mod, int type, void *data) \
445 	{							\
446 		sc_renderer_t **list;				\
447 		int error = 0;					\
448 		switch (type) {					\
449 		case MOD_LOAD:					\
450 			SET_FOREACH(list, set) {		\
451 				error = sc_render_add(*list);	\
452 				if (error)			\
453 					break;			\
454 			}					\
455 			break;					\
456 		case MOD_UNLOAD:				\
457 			SET_FOREACH(list, set) {		\
458 				error = sc_render_remove(*list);	\
459 				if (error)			\
460 					break;			\
461 			}					\
462 			break;					\
463 		default:					\
464 			break;					\
465 		}						\
466 		return error;					\
467 	}							\
468 	static moduledata_t scrndr_##name##_mod = {		\
469 		"scrndr-" #name,				\
470 		scrndr_##name##_event,				\
471 		NULL,						\
472 	};							\
473 	DECLARE_MODULE(scrndr_##name, scrndr_##name##_mod, 	\
474 		       SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
475 
476 typedef struct {
477 	int		cursor_start;
478 	int		cursor_end;
479 	int		shift_state;
480 	int		bell_pitch;
481 } bios_values_t;
482 
483 /* other macros */
484 #define ISTEXTSC(scp)	(!((scp)->status 				\
485 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE)))
486 #define ISGRAPHSC(scp)	(((scp)->status 				\
487 			  & (UNKNOWN_MODE | GRAPHICS_MODE)))
488 #define ISPIXELSC(scp)	(((scp)->status 				\
489 			  & (UNKNOWN_MODE | GRAPHICS_MODE | PIXEL_MODE))\
490 			  == PIXEL_MODE)
491 #define ISUNKNOWNSC(scp) ((scp)->status & UNKNOWN_MODE)
492 
493 #define ISMOUSEAVAIL(af) ((af) & V_ADP_FONT)
494 #define ISFONTAVAIL(af)	((af) & V_ADP_FONT)
495 #define ISPALAVAIL(af)	((af) & V_ADP_PALETTE)
496 
497 #define ISSIGVALID(sig)	((sig) > 0 && (sig) < NSIG)
498 
499 /* syscons.c */
500 int		sc_probe_unit(int unit, int flags);
501 int		sc_attach_unit(int unit, int flags);
502 
503 int		set_mode(scr_stat *scp);
504 void		refresh_ega_palette(scr_stat *scp);
505 
506 void		sc_set_border(scr_stat *scp, int color);
507 void		sc_load_font(scr_stat *scp, int page, int size, u_char *font,
508 			     int base, int count);
509 void		sc_save_font(scr_stat *scp, int page, int size, u_char *font,
510 			     int base, int count);
511 void		sc_show_font(scr_stat *scp, int page);
512 
513 void		sc_touch_scrn_saver(void);
514 void		sc_draw_cursor_image(scr_stat *scp);
515 void		sc_remove_cursor_image(scr_stat *scp);
516 void		sc_set_cursor_image(scr_stat *scp);
517 int		sc_clean_up(scr_stat *scp);
518 int		sc_switch_scr(sc_softc_t *sc, u_int next_scr);
519 void		sc_alloc_scr_buffer(scr_stat *scp, int wait, int discard);
520 int		sc_init_emulator(scr_stat *scp, char *name);
521 void		sc_paste(scr_stat *scp, u_char *p, int count);
522 void		sc_bell(scr_stat *scp, int pitch, int duration);
523 
524 /* schistory.c */
525 #ifndef SC_NO_HISTORY
526 int		sc_alloc_history_buffer(scr_stat *scp, int lines,
527 					int prev_ysize, int wait);
528 void		sc_free_history_buffer(scr_stat *scp, int prev_ysize);
529 void		sc_hist_save(scr_stat *scp);
530 #define		sc_hist_save_one_line(scp, from)	\
531 		sc_vtb_append(&(scp)->vtb, (from), (scp)->history, (scp)->xsize)
532 int		sc_hist_restore(scr_stat *scp);
533 void		sc_hist_home(scr_stat *scp);
534 void		sc_hist_end(scr_stat *scp);
535 int		sc_hist_up_line(scr_stat *scp);
536 int		sc_hist_down_line(scr_stat *scp);
537 int		sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data,
538 			      int flag);
539 #endif /* SC_NO_HISTORY */
540 
541 /* scmouse.c */
542 #ifndef SC_NO_CUTPASTE
543 void		sc_alloc_cut_buffer(scr_stat *scp, int wait);
544 void		sc_draw_mouse_image(scr_stat *scp);
545 void		sc_remove_mouse_image(scr_stat *scp);
546 int		sc_inside_cutmark(scr_stat *scp, int pos);
547 void		sc_remove_cutmarking(scr_stat *scp);
548 void		sc_remove_all_cutmarkings(sc_softc_t *scp);
549 void		sc_remove_all_mouse(sc_softc_t *scp);
550 #else
551 #define		sc_draw_mouse_image(scp)
552 #define		sc_remove_mouse_image(scp)
553 #define		sc_inside_cutmark(scp, pos)	FALSE
554 #define		sc_remove_cutmarking(scp)
555 #define		sc_remove_all_cutmarkings(scp)
556 #define		sc_remove_all_mouse(scp)
557 #endif /* SC_NO_CUTPASTE */
558 #ifndef SC_NO_SYSMOUSE
559 void		sc_mouse_move(scr_stat *scp, int x, int y);
560 int		sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data,
561 			       int flag);
562 #endif /* SC_NO_SYSMOUSE */
563 
564 /* scvidctl.c */
565 int		sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode,
566 				 int xsize, int ysize, int fontsize);
567 int		sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode);
568 int		sc_set_pixel_mode(scr_stat *scp, struct tty *tp,
569 				  int xsize, int ysize, int fontsize);
570 int		sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data,
571 				  int flag);
572 
573 int		sc_render_add(sc_renderer_t *rndr);
574 int		sc_render_remove(sc_renderer_t *rndr);
575 sc_rndr_sw_t	*sc_render_match(scr_stat *scp, char *name, int model);
576 void		sc_update_render(scr_stat *scp);
577 
578 /* scvtb.c */
579 void		sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows,
580 			    void *buffer, int wait);
581 void		sc_vtb_destroy(sc_vtb_t *vtb);
582 size_t		sc_vtb_size(int cols, int rows);
583 void		sc_vtb_clear(sc_vtb_t *vtb, int c, int attr);
584 
585 int		sc_vtb_getc(sc_vtb_t *vtb, int at);
586 int		sc_vtb_geta(sc_vtb_t *vtb, int at);
587 void		sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a);
588 uint16_t	*sc_vtb_putchar(sc_vtb_t *vtb, uint16_t *p, int c, int a);
589 int		sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset);
590 
591 #define		sc_vtb_tail(vtb)	((vtb)->vtb_tail)
592 #define		sc_vtb_rows(vtb)	((vtb)->vtb_rows)
593 #define		sc_vtb_cols(vtb)	((vtb)->vtb_cols)
594 
595 void		sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to,
596 			    int count);
597 void		sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2,
598 			      int count);
599 void		sc_vtb_seek(sc_vtb_t *vtb, int pos);
600 void		sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr);
601 void		sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count);
602 void		sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr);
603 void		sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr);
604 
605 /* sysmouse.c */
606 int		sysmouse_event(mouse_info_t *info);
607 
608 /* scterm.c */
609 void		sc_move_cursor(scr_stat *scp, int x, int y);
610 void		sc_clear_screen(scr_stat *scp);
611 int		sc_term_add(sc_term_sw_t *sw);
612 int		sc_term_remove(sc_term_sw_t *sw);
613 sc_term_sw_t	*sc_term_match(char *name);
614 sc_term_sw_t	*sc_term_match_by_number(int index);
615 
616 /* machine dependent functions */
617 int		sc_max_unit(void);
618 sc_softc_t	*sc_get_softc(int unit, int flags);
619 sc_softc_t	*sc_find_softc(struct video_adapter *adp, struct keyboard *kbd);
620 int		sc_get_cons_priority(int *unit, int *flags);
621 void		sc_get_bios_values(bios_values_t *values);
622 int		sc_tone(int hertz);
623 
624 #endif /* !_DEV_SYSCONS_SYSCONS_H_ */
625