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