syscons.h revision 29121
1181834Sroberto/*-
2181834Sroberto * Copyright (c) 1995-1997 S�ren Schmidt
3181834Sroberto * All rights reserved.
4181834Sroberto *
5181834Sroberto * Redistribution and use in source and binary forms, with or without
6181834Sroberto * modification, are permitted provided that the following conditions
7181834Sroberto * are met:
8181834Sroberto * 1. Redistributions of source code must retain the above copyright
9181834Sroberto *    notice, this list of conditions and the following disclaimer
10181834Sroberto *    in this position and unchanged.
11181834Sroberto * 2. Redistributions in binary form must reproduce the above copyright
12181834Sroberto *    notice, this list of conditions and the following disclaimer in the
13181834Sroberto *    documentation and/or other materials provided with the distribution.
14181834Sroberto * 3. The name of the author may not be used to endorse or promote products
15181834Sroberto *    derived from this software without specific prior written permission
16181834Sroberto *
17181834Sroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18181834Sroberto * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19181834Sroberto * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20181834Sroberto * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21181834Sroberto * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22181834Sroberto * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23181834Sroberto * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24181834Sroberto * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25181834Sroberto * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26181834Sroberto * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27181834Sroberto *
28181834Sroberto *	$Id: syscons.h,v 1.32 1997/08/25 23:21:55 bde Exp $
29181834Sroberto */
30181834Sroberto
31181834Sroberto#ifndef _I386_ISA_SYSCONS_H_
32181834Sroberto#define	_I386_ISA_SYSCONS_H_
33181834Sroberto
34181834Sroberto/* vm things */
35181834Sroberto#define	ISMAPPED(pa, width) \
36181834Sroberto	(((pa) <= (u_long)0x1000 - (width)) \
37181834Sroberto	 || ((pa) >= 0xa0000 && (pa) <= 0x100000 - (width)))
38181834Sroberto#define	pa_to_va(pa)	(KERNBASE + (pa))	/* works if ISMAPPED(pa...) */
39181834Sroberto
40181834Sroberto/* printable chars */
41181834Sroberto#define PRINTABLE(ch)	((ch) > 0x1b || ((ch) > 0x0d && (ch) < 0x1b) \
42181834Sroberto			 || (ch) < 0x07)
43181834Sroberto
44181834Sroberto/* macros for "intelligent" screen update */
45181834Sroberto#define mark_for_update(scp, x)	{\
46181834Sroberto			  	    if ((x) < scp->start) scp->start = (x);\
47181834Sroberto				    else if ((x) > scp->end) scp->end = (x);\
48181834Sroberto				}
49181834Sroberto#define mark_all(scp)		{\
50181834Sroberto				    scp->start = 0;\
51181834Sroberto				    scp->end = scp->xsize * scp->ysize;\
52181834Sroberto				}
53181834Sroberto
54181834Sroberto/* status flags */
55181834Sroberto#define LOCK_KEY_MASK	0x0000F
56181834Sroberto#define LED_MASK	0x00007
57181834Sroberto#define UNKNOWN_MODE	0x00010
58181834Sroberto#define KBD_RAW_MODE	0x00020
59181834Sroberto#define SWITCH_WAIT_REL	0x00040
60181834Sroberto#define SWITCH_WAIT_ACQ	0x00080
61181834Sroberto#define BUFFER_SAVED	0x00100
62181834Sroberto#define CURSOR_ENABLED 	0x00200
63181834Sroberto#define MOUSE_ENABLED	0x00400
64181834Sroberto#define MOUSE_MOVED	0x00800
65181834Sroberto#define MOUSE_CUTTING	0x01000
66181834Sroberto#define MOUSE_VISIBLE	0x02000
67181834Sroberto
68181834Sroberto/* configuration flags */
69181834Sroberto#define VISUAL_BELL	0x00001
70181834Sroberto#define BLINK_CURSOR	0x00002
71181834Sroberto#define CHAR_CURSOR	0x00004
72181834Sroberto#define DETECT_KBD	0x00008
73181834Sroberto#define XT_KEYBD	0x00010
74181834Sroberto#define KBD_NORESET	0x00020
75181834Sroberto
76181834Sroberto/* attribute flags */
77181834Sroberto#define NORMAL_ATTR             0x00
78181834Sroberto#define BLINK_ATTR              0x01
79181834Sroberto#define BOLD_ATTR               0x02
80181834Sroberto#define UNDERLINE_ATTR          0x04
81181834Sroberto#define REVERSE_ATTR            0x08
82181834Sroberto#define FOREGROUND_CHANGED      0x10
83181834Sroberto#define BACKGROUND_CHANGED      0x20
84181834Sroberto
85181834Sroberto/* video hardware memory addresses */
86181834Sroberto#define VIDEOMEM	0x000A0000
87181834Sroberto
88181834Sroberto/* misc defines */
89181834Sroberto#define FALSE		0
90181834Sroberto#define TRUE		1
91181834Sroberto#define MAX_ESC_PAR 	5
92181834Sroberto#define	LOAD		1
93181834Sroberto#define SAVE		0
94181834Sroberto#define	COL		80
95181834Sroberto#define	ROW		25
96181834Sroberto#define BELL_DURATION	5
97181834Sroberto#define BELL_PITCH	800
98181834Sroberto#define CONSOLE_BUFSIZE 1024
99181834Sroberto#define PCBURST		128
100181834Sroberto#define FONT_NONE	1
101181834Sroberto#define FONT_8		2
102181834Sroberto#define FONT_14		4
103181834Sroberto#define FONT_16		8
104181834Sroberto#if !defined(SC_HISTORY_SIZE)
105181834Sroberto#define SC_HISTORY_SIZE	(ROW * 4)
106181834Sroberto#endif /* SC_HISTORY_SIZE */
107181834Sroberto#define HISTORY_SIZE	(COL * (SC_HISTORY_SIZE))
108181834Sroberto
109181834Sroberto/* defines related to hardware addresses */
110181834Sroberto#define	MONO_BASE	0x3B4			/* crt controller base mono */
111181834Sroberto#define	COLOR_BASE	0x3D4			/* crt controller base color */
112181834Sroberto#define MISC		0x3C2			/* misc output register */
113181834Sroberto#define ATC		IO_VGA+0x00		/* attribute controller */
114181834Sroberto#define TSIDX		IO_VGA+0x04		/* timing sequencer idx */
115181834Sroberto#define TSREG		IO_VGA+0x05		/* timing sequencer data */
116181834Sroberto#define PIXMASK		IO_VGA+0x06		/* pixel write mask */
117181834Sroberto#define PALRADR		IO_VGA+0x07		/* palette read address */
118181834Sroberto#define PALWADR		IO_VGA+0x08		/* palette write address */
119181834Sroberto#define PALDATA		IO_VGA+0x09		/* palette data register */
120181834Sroberto#define GDCIDX		IO_VGA+0x0E		/* graph data controller idx */
121181834Sroberto#define GDCREG		IO_VGA+0x0F		/* graph data controller data */
122181834Sroberto
123181834Sroberto/* special characters */
124181834Sroberto#define cntlc		0x03
125181834Sroberto#define cntld		0x04
126181834Sroberto#define bs		0x08
127181834Sroberto#define lf		0x0a
128181834Sroberto#define cr		0x0d
129181834Sroberto#define del		0x7f
130181834Sroberto
131181834Sroberto#define DEAD_CHAR 	0x07			/* char used for cursor */
132181834Sroberto
133181834Srobertotypedef struct term_stat {
134181834Sroberto	int 		esc;			/* processing escape sequence */
135181834Sroberto	int 		num_param;		/* # of parameters to ESC */
136181834Sroberto	int	 	last_param;		/* last parameter # */
137181834Sroberto	int 		param[MAX_ESC_PAR];	/* contains ESC parameters */
138181834Sroberto	int             cur_attr;               /* current hardware attr word */
139181834Sroberto	int             attr_mask;              /* current logical attr mask */
140181834Sroberto	int             cur_color;              /* current hardware color */
141181834Sroberto	int             std_color;              /* normal hardware color */
142181834Sroberto	int             rev_color;              /* reverse hardware color */
143181834Sroberto} term_stat;
144181834Sroberto
145181834Srobertotypedef struct scr_stat {
146181834Sroberto	u_short 	*scr_buf;		/* buffer when off screen */
147181834Sroberto	int 		xpos;			/* current X position */
148181834Sroberto	int 		ypos;			/* current Y position */
149181834Sroberto	int             saved_xpos;             /* saved X position */
150181834Sroberto	int             saved_ypos;             /* saved Y position */
151181834Sroberto	int 		xsize;			/* X text size */
152181834Sroberto	int 		ysize;			/* Y text size */
153181834Sroberto	int 		xpixel;			/* X graphics size */
154181834Sroberto	int 		ypixel;			/* Y graphics size */
155181834Sroberto	int		font_size;		/* fontsize in Y direction */
156181834Sroberto	int		start;			/* modified area start */
157181834Sroberto	int		end;			/* modified area end */
158181834Sroberto	term_stat 	term;			/* terminal emulation stuff */
159181834Sroberto	int	 	status;			/* status (bitfield) */
160181834Sroberto	u_short 	*cursor_pos;		/* cursor buffer position */
161181834Sroberto	u_short 	*cursor_oldpos;		/* cursor old buffer position */
162181834Sroberto	u_short		cursor_saveunder;	/* saved chars under cursor */
163181834Sroberto	char		cursor_start;		/* cursor start line # */
164181834Sroberto	char		cursor_end;		/* cursor end line # */
165181834Sroberto	u_short		*mouse_pos;		/* mouse buffer position */
166181834Sroberto	u_short		*mouse_oldpos;		/* mouse old buffer position */
167181834Sroberto	short		mouse_xpos;		/* mouse x coordinate */
168181834Sroberto	short		mouse_ypos;		/* mouse y coordinate */
169181834Sroberto	short		mouse_buttons;		/* mouse buttons */
170181834Sroberto	u_char		mouse_cursor[128];	/* mouse cursor bitmap store */
171181834Sroberto	u_short		*mouse_cut_start;	/* mouse cut start pos */
172181834Sroberto	u_short		*mouse_cut_end;		/* mouse cut end pos */
173181834Sroberto	struct proc 	*mouse_proc;		/* proc* of controlling proc */
174181834Sroberto	pid_t 		mouse_pid;		/* pid of controlling proc */
175181834Sroberto	int		mouse_signal;		/* signal # to report with */
176181834Sroberto	u_short		bell_duration;
177181834Sroberto	u_short		bell_pitch;
178181834Sroberto	u_char		border;			/* border color */
179181834Sroberto	u_char	 	mode;			/* mode */
180181834Sroberto	pid_t 		pid;			/* pid of controlling proc */
181181834Sroberto	struct proc 	*proc;			/* proc* of controlling proc */
182181834Sroberto	struct vt_mode 	smode;			/* switch mode */
183181834Sroberto	u_short		*history;		/* circular history buffer */
184181834Sroberto	u_short		*history_head;		/* current head position */
185181834Sroberto	u_short		*history_pos;		/* position shown on screen */
186181834Sroberto	u_short		*history_save;		/* save area index */
187181834Sroberto	int		history_size;		/* size of history buffer */
188181834Sroberto	struct apmhook  r_hook;			/* reconfiguration support */
189181834Sroberto} scr_stat;
190181834Sroberto
191181834Srobertotypedef struct default_attr {
192181834Sroberto	int             std_color;              /* normal hardware color */
193181834Sroberto	int             rev_color;              /* reverse hardware color */
194181834Sroberto} default_attr;
195181834Sroberto
196181834Sroberto/* misc prototypes used by different syscons related LKM's */
197181834Srobertovoid set_border(u_char color);
198181834Srobertovoid set_mode(scr_stat *scp);
199181834Srobertovoid copy_font(int operation, int font_type, char* font_image);
200181834Srobertovoid load_palette(char *palette);
201181834Srobertoint add_scrn_saver(void (*this)(int));
202181834Srobertoint remove_scrn_saver(void (*this)(int));
203181834Sroberto
204181834Sroberto#endif /* !_I386_ISA_SYSCONS_H_ */
205181834Sroberto