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