xref: /onnv-gate/usr/src/uts/common/sys/tem_impl.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
30*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifndef	_SYS_TEM_IMPL_H
33*0Sstevel@tonic-gate #define	_SYS_TEM_IMPL_H
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #ifdef __cplusplus
38*0Sstevel@tonic-gate extern "C" {
39*0Sstevel@tonic-gate #endif
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #include <sys/sunldi.h>
42*0Sstevel@tonic-gate #include <sys/visual_io.h>
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate /*
45*0Sstevel@tonic-gate  * definitions for ANSI x3.64 terminal control language parser
46*0Sstevel@tonic-gate  */
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate #define	TEM_MAXPARAMS	5	/* maximum number of ANSI paramters */
49*0Sstevel@tonic-gate #define	TEM_MAXTAB	40	/* maximum number of tab stops */
50*0Sstevel@tonic-gate #define	TEM_MAXFKEY	30	/* max length of function key with <ESC>Q */
51*0Sstevel@tonic-gate #define	MAX_TEM		2	/* max number of loadable terminal emulators */
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate #define	TEM_SCROLL_UP		0
54*0Sstevel@tonic-gate #define	TEM_SCROLL_DOWN		1
55*0Sstevel@tonic-gate #define	TEM_SHIFT_LEFT		0
56*0Sstevel@tonic-gate #define	TEM_SHIFT_RIGHT		1
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate #define	TEM_ATTR_NORMAL		0x0000
59*0Sstevel@tonic-gate #define	TEM_ATTR_REVERSE	0x0001
60*0Sstevel@tonic-gate #define	TEM_ATTR_BOLD		0x0002
61*0Sstevel@tonic-gate #define	TEM_ATTR_BLINK		0x0004
62*0Sstevel@tonic-gate #define	TEM_ATTR_TRANSPARENT	0x0008
63*0Sstevel@tonic-gate #define	TEM_ATTR_SCREEN_REVERSE	0x0010
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate #define	ANSI_COLOR_BLACK	0
66*0Sstevel@tonic-gate #define	ANSI_COLOR_WHITE	7
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate #define	TEM_TEXT_WHITE		0
69*0Sstevel@tonic-gate #define	TEM_TEXT_BLACK		1
70*0Sstevel@tonic-gate #define	TEM_TEXT_BLACK24_RED	0x00
71*0Sstevel@tonic-gate #define	TEM_TEXT_BLACK24_GREEN	0x00
72*0Sstevel@tonic-gate #define	TEM_TEXT_BLACK24_BLUE	0x00
73*0Sstevel@tonic-gate #define	TEM_TEXT_WHITE24_RED	0xff
74*0Sstevel@tonic-gate #define	TEM_TEXT_WHITE24_GREEN	0xff
75*0Sstevel@tonic-gate #define	TEM_TEXT_WHITE24_BLUE	0xff
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate #define	A_STATE_START			0
78*0Sstevel@tonic-gate #define	A_STATE_ESC			1
79*0Sstevel@tonic-gate #define	A_STATE_ESC_Q			2
80*0Sstevel@tonic-gate #define	A_STATE_ESC_Q_DELM		3
81*0Sstevel@tonic-gate #define	A_STATE_ESC_Q_DELM_CTRL		4
82*0Sstevel@tonic-gate #define	A_STATE_ESC_C			5
83*0Sstevel@tonic-gate #define	A_STATE_CSI			6
84*0Sstevel@tonic-gate #define	A_STATE_CSI_QMARK		7
85*0Sstevel@tonic-gate #define	A_STATE_CSI_EQUAL		8
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate /*
88*0Sstevel@tonic-gate  * Default number of rows and columns
89*0Sstevel@tonic-gate  */
90*0Sstevel@tonic-gate #define	TEM_DEFAULT_ROWS	34
91*0Sstevel@tonic-gate #define	TEM_DEFAULT_COLS	80
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #define	BUF_LEN		160 /* Two lines of data can be processed at a time */
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate typedef uint8_t text_color_t;
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate struct tem_pix_pos {
98*0Sstevel@tonic-gate 	screen_pos_t	x;
99*0Sstevel@tonic-gate 	screen_pos_t	y;
100*0Sstevel@tonic-gate };
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate struct tem_char_pos {
103*0Sstevel@tonic-gate 	screen_pos_t	col;
104*0Sstevel@tonic-gate 	screen_pos_t	row;
105*0Sstevel@tonic-gate };
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate struct tem_size {
108*0Sstevel@tonic-gate 	screen_size_t	width;
109*0Sstevel@tonic-gate 	screen_size_t	height;
110*0Sstevel@tonic-gate };
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate struct terminal_emulator;	/* Forward declare */
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate enum called_from { CALLED_FROM_NORMAL, CALLED_FROM_STANDALONE };
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate struct in_func_ptrs {
117*0Sstevel@tonic-gate 	void (*f_display)(struct terminal_emulator *, unsigned char *, int,
118*0Sstevel@tonic-gate 	    screen_pos_t, screen_pos_t, unsigned char, unsigned char,
119*0Sstevel@tonic-gate 	    cred_t *, enum called_from);
120*0Sstevel@tonic-gate 	void (*f_copy)(struct terminal_emulator *,
121*0Sstevel@tonic-gate 	    screen_pos_t, screen_pos_t, screen_pos_t, screen_pos_t,
122*0Sstevel@tonic-gate 	    screen_pos_t, screen_pos_t, cred_t *, enum called_from);
123*0Sstevel@tonic-gate 	void (*f_cursor)(struct terminal_emulator *, short, cred_t *,
124*0Sstevel@tonic-gate 	    enum called_from);
125*0Sstevel@tonic-gate 	void (*f_bit2pix)(struct terminal_emulator *, unsigned char,
126*0Sstevel@tonic-gate 	    unsigned char, unsigned char);
127*0Sstevel@tonic-gate 	void (*f_cls)(struct terminal_emulator *, int,
128*0Sstevel@tonic-gate 	    screen_pos_t, screen_pos_t, cred_t *, enum called_from);
129*0Sstevel@tonic-gate };
130*0Sstevel@tonic-gate 
131*0Sstevel@tonic-gate /*
132*0Sstevel@tonic-gate  * State structure for terminal emulator
133*0Sstevel@tonic-gate  */
134*0Sstevel@tonic-gate struct terminal_emulator {		/* state for tem x3.64 emulator */
135*0Sstevel@tonic-gate 	ldi_handle_t		hdl; /* Framework handle for layered on dev */
136*0Sstevel@tonic-gate 	screen_size_t		linebytes; /* Layered on bytes per scan line */
137*0Sstevel@tonic-gate 	int			display_mode; /* What mode we are in */
138*0Sstevel@tonic-gate 	dev_info_t		*dip; /* Our dip */
139*0Sstevel@tonic-gate 	kmutex_t		lock;
140*0Sstevel@tonic-gate 	boolean_t		standalone_writes_ok;
141*0Sstevel@tonic-gate 	struct vis_polledio	*fb_polledio;
142*0Sstevel@tonic-gate 	unsigned short	a_flags;	/* flags for this x3.64 terminal */
143*0Sstevel@tonic-gate 	int	a_state;	/* state in output esc seq processing */
144*0Sstevel@tonic-gate 	boolean_t	a_gotparam;	/* does output esc seq have a param */
145*0Sstevel@tonic-gate 	int	a_curparam;	/* current param # of output esc seq */
146*0Sstevel@tonic-gate 	int	a_paramval;	/* value of current param */
147*0Sstevel@tonic-gate 	int	a_params[TEM_MAXPARAMS];  /* parameters of output esc seq */
148*0Sstevel@tonic-gate 	char	a_fkey[TEM_MAXFKEY];	/* work space for function key */
149*0Sstevel@tonic-gate 	screen_pos_t	a_tabs[TEM_MAXTAB];	/* tab stops */
150*0Sstevel@tonic-gate 	int	a_ntabs;		/* number of tabs used */
151*0Sstevel@tonic-gate 	int	a_nscroll;		/* number of lines to scroll */
152*0Sstevel@tonic-gate 	struct tem_char_pos a_s_cursor;	/* start cursor position */
153*0Sstevel@tonic-gate 	struct tem_char_pos a_c_cursor;	/* current cursor position */
154*0Sstevel@tonic-gate 	struct tem_char_pos a_r_cursor;	/* remembered cursor position */
155*0Sstevel@tonic-gate 	struct tem_size a_c_dimension;	/* window dimensions in characters */
156*0Sstevel@tonic-gate 	struct tem_size a_p_dimension;	/* screen dimensions in pixels */
157*0Sstevel@tonic-gate 	struct tem_size default_dims;	/* target dims in characters */
158*0Sstevel@tonic-gate 	struct tem_pix_pos a_p_offset;	/* pix offset to center the display */
159*0Sstevel@tonic-gate 	unsigned char	*a_outbuf;	/* place to keep incomplete lines */
160*0Sstevel@tonic-gate 	unsigned char	*a_blank_line;	/* a blank line for scrolling */
161*0Sstevel@tonic-gate 	int	a_outindex;	/* index into a_outbuf */
162*0Sstevel@tonic-gate 	struct in_func_ptrs	in_fp;	/* internal output functions */
163*0Sstevel@tonic-gate 	struct font	a_font;	/* font table */
164*0Sstevel@tonic-gate 	int	a_pdepth;	/* pixel depth */
165*0Sstevel@tonic-gate 	int	a_initialized;	/* initialization flag */
166*0Sstevel@tonic-gate 	void   *a_pix_data;	/* pointer to tmp bitmap area */
167*0Sstevel@tonic-gate 	int	a_pix_data_size; /* size of bitmap data areas */
168*0Sstevel@tonic-gate 	text_color_t fg_color;
169*0Sstevel@tonic-gate 	text_color_t bg_color;
170*0Sstevel@tonic-gate };
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate #ifdef __cplusplus
173*0Sstevel@tonic-gate }
174*0Sstevel@tonic-gate #endif
175*0Sstevel@tonic-gate 
176*0Sstevel@tonic-gate #endif /* _SYS_TEM_IMPL_H */
177