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