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