xref: /illumos-gate/usr/src/uts/common/sys/visual_io.h (revision 7c478bd9)
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 #ifndef _SYS_VISUAL_IO_H
28 #define	_SYS_VISUAL_IO_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	VIOC	('V' << 8)
37 #define	VIOCF	('F' << 8)
38 
39 
40 /*
41  * Device Identification
42  *
43  * VIS_GETIDENTIFIER returns an identifier string to uniquely identify
44  * a device type used in the Solaris VISUAL environment.  The identifier
45  * must be unique.  We suggest the convention:
46  *
47  *	<companysymbol><devicetype>
48  *
49  * for example: SUNWcg6
50  */
51 
52 #define	VIS_MAXNAMELEN 128
53 
54 struct vis_identifier {
55 	char name[VIS_MAXNAMELEN];	/* <companysymbol><devicename>	*/
56 };
57 
58 #define	VIS_GETIDENTIFIER	(VIOC | 0)
59 
60 
61 
62 /*
63  * Hardware Cursor Control
64  *
65  * Devices with hardware cursors may implement these ioctls in their
66  * kernel device drivers.
67  */
68 
69 
70 struct vis_cursorpos {
71 	short x;		/* cursor x coordinate	*/
72 	short y;		/* cursor y coordinate	*/
73 };
74 
75 struct vis_cursorcmap {
76 	int		version;	/* version			*/
77 	int		reserved;
78 	unsigned char	*red;		/* red color map elements	*/
79 	unsigned char	*green;		/* green color map elements	*/
80 	unsigned char	*blue;		/* blue color map elements	*/
81 };
82 
83 
84 /*
85  * These ioctls fetch and set various cursor attributes, using the
86  * vis_cursor struct.
87  */
88 
89 #define	VIS_SETCURSOR	(VIOCF|24)
90 #define	VIS_GETCURSOR	(VIOCF|25)
91 
92 struct vis_cursor {
93 	short			set;		/* what to set		*/
94 	short			enable;		/* cursor on/off	*/
95 	struct vis_cursorpos	pos;		/* cursor position	*/
96 	struct vis_cursorpos	hot;		/* cursor hot spot	*/
97 	struct vis_cursorcmap	cmap;		/* color map info	*/
98 	struct vis_cursorpos	size;		/* cursor bit map size	*/
99 	char			*image;		/* cursor image bits	*/
100 	char			*mask;		/* cursor mask bits	*/
101 };
102 
103 #define	VIS_CURSOR_SETCURSOR	0x01		/* set cursor		*/
104 #define	VIS_CURSOR_SETPOSITION	0x02		/* set cursor position	*/
105 #define	VIS_CURSOR_SETHOTSPOT	0x04		/* set cursor hot spot	*/
106 #define	VIS_CURSOR_SETCOLORMAP	0x08		/* set cursor colormap	*/
107 #define	VIS_CURSOR_SETSHAPE	0x10		/* set cursor shape	*/
108 
109 #define	VIS_CURSOR_SETALL	(VIS_CURSOR_SETCURSOR | \
110     VIS_CURSOR_SETPOSITION	| \
111     VIS_CURSOR_SETHOTSPOT	| \
112     VIS_CURSOR_SETCOLORMAP	| \
113     VIS_CURSOR_SETSHAPE)
114 
115 
116 /*
117  * These ioctls fetch and move the current cursor position, using the
118  * vis_cursorposition struct.
119  */
120 
121 #define	VIS_MOVECURSOR		(VIOCF|26)
122 #define	VIS_GETCURSORPOS	(VIOCF|27)
123 
124 /*
125  * VIS_SETCMAP:
126  * VIS_GETCMAP:
127  * Set/Get the indicated color map entries.  The index states the first
128  * color to be update and count specifies the number of entries to be
129  * updated from index.  red, green, and blue are arrays of color
130  * values.  The length of the arrays is count.
131  */
132 #define	VIS_GETCMAP	(VIOC|9)
133 #define	VIS_PUTCMAP	(VIOC|10)
134 struct viscmap {
135 	int		index; /* Index into colormap to start updating */
136 	int		count; /* Number of entries to update */
137 	unsigned char	*red; /* List of red values */
138 	unsigned char	*green; /* List of green values */
139 	unsigned char	*blue; /* List of blue values */
140 };
141 
142 
143 #ifdef _KERNEL
144 /*
145  * The following ioctls are used for communication between the layered
146  * device and the framebuffer.  The layered driver calls the framebuffer
147  * with these ioctls.
148  *
149  * On machines that don't have a prom, kmdb uses the kernel to display
150  * characters.  The kernel in turn will use the routines returned by
151  * VIS_DEVINIT to ask the framebuffer driver to display the data.  The
152  * framebuffer driver CANNOT use any DDI services to display this data.  It
153  * must just dump the data to the framebuffer.  In particular, the mutex and
154  * copy routines do not work.
155  *
156  * On machines without a prom, the framebuffer driver must implement all
157  * of these ioctls to be a console.  On machines with a prom, the
158  * framebuffer driver can set vis_devinit.polledio to NULL.
159  */
160 typedef short screen_pos_t;
161 typedef short screen_size_t;
162 
163 /*
164  * Union of pixel depths
165  */
166 typedef union {
167 	unsigned char  mono;   /* one-bit */
168 	unsigned char  four;   /* four bit */
169 	unsigned char  eight;  /* eight bit */
170 	unsigned char  twentyfour[3];  /* 24 bit */
171 } color_t;
172 
173 /*
174  * VIS_DEVINIT:
175  * Initialize the framebuffer as a console device.  The terminal emulator
176  * will provide the following structure to the device driver to be filled in.
177  * The driver is expected to fill it in.
178  *
179  * ioctl(fd, VIS_DEVINIT, struct vis_devinit *)
180  */
181 #define	VIS_DEVINIT	(VIOC|1)
182 #define	VIS_CONS_REV		2 /* Console IO interface version */
183 /* Modes */
184 #define	VIS_TEXT		0 /* Use text mode when displaying data */
185 #define	VIS_PIXEL		1 /* Use pixel mode when displaying data */
186 
187 /*
188  * VIS_DEVFINI:
189  * Tells the framebuffer that it is no longer being used as a console.
190  *
191  * ioctl(fd, VIS_DEVFINI, unused)
192  */
193 #define	VIS_DEVFINI	(VIOC|2)
194 
195 /*
196  * VIS_CONSCURSOR:
197  * Display/Hide cursor on the screen.  The layered driver uses this ioctl to
198  * display, hide, and move the cursor on the console.  The framebuffer driver
199  * is expected to draw a cursor at position (col,row) of size width x height.
200  *
201  * ioctl(fd, VIS_CONSCURSOR, struct vis_conscursor *)
202  */
203 #define	VIS_CONSCURSOR		(VIOC|3)
204 #define	VIS_CURSOR_VERSION	1
205 /* Cursor action - Either display or hide cursor */
206 #define	VIS_HIDE_CURSOR		0
207 #define	VIS_DISPLAY_CURSOR	1
208 #define	VIS_GET_CURSOR		2
209 
210 /*
211  * VIS_CONSDISPLAY:
212  * Display data on the framebuffer.  The data will be in the form specified
213  * by the driver during console initialization (see VIS_CONSDEVINIT above).
214  * The driver is expected to display the data at location (row,col).  Width
215  * and height specify the size of the data.
216  *
217  * ioctl(fd, VIS_CONSDISPLAY, struct vis_consdisplay *)
218  */
219 
220 #define	VIS_CONSDISPLAY		(VIOC|5)
221 /* Version */
222 #define	VIS_DISPLAY_VERSION		1
223 
224 /*
225  * VIS_CONSCOPY:
226  * Move data on the framebuffer.  Used to scroll the screen by the terminal
227  * emulator or to move data by applications.  The driver must copy the data
228  * specified by the rectangle (s_col,s_row),(e_col,e_row) to the location
229  * which starts at (t_col,t_row), handling overlapping copies correctly.
230  *
231  * ioctl(fd, VIS_CONSCOPY, struct vis_conscopy *)
232  */
233 #define	VIS_CONSCOPY		(VIOC|7)
234 /* Version */
235 #define	VIS_COPY_VERSION		2
236 
237 struct vis_consdisplay {
238 	int		version; /* Version of this structure */
239 	screen_pos_t	row; /* Row to display data at */
240 	screen_pos_t	col; /* Col to display data at */
241 	screen_size_t	width; /* Width of data */
242 	screen_size_t	height; /* Height of data */
243 	unsigned char	*data; /* Data to display */
244 	unsigned char	fg_color; /* Foreground color */
245 	unsigned char	bg_color; /* Background color */
246 };
247 
248 struct vis_conscopy {
249 	int		version; /* Version of this structure */
250 	screen_pos_t	s_row; /* Starting row */
251 	screen_pos_t	s_col; /* Starting col */
252 	screen_pos_t	e_row; /* Ending row */
253 	screen_pos_t	e_col; /* Ending col */
254 	screen_pos_t	t_row; /* Row to move to */
255 	screen_pos_t	t_col; /* Col to move to */
256 };
257 
258 struct vis_conscursor {
259 	int		version; /* Version of this structure */
260 	screen_pos_t	row; /* Row to display cursor at */
261 	screen_pos_t	col; /* Col to display cursor at */
262 	screen_size_t	width; /* Width of cursor */
263 	screen_size_t	height; /* Height of cursor */
264 	color_t		fg_color; /* Foreground color */
265 	color_t		bg_color; /* Background color */
266 	short		action; /* Hide or show cursor */
267 };
268 
269 /*
270  * Each software-console-capable frame buffer driver defines its own
271  * instance of this (with its own name!) and casts to/from this at the
272  * interface with the terminal emulator.  This yields somewhat better
273  * type checking than "void *".
274  */
275 struct vis_polledio_arg;
276 
277 /*
278  * Each software-console-capable frame buffer driver supplies these routines
279  * for I/O from "polled" contexts - kmdb, OBP, etc.  No system services are
280  * available.
281  */
282 struct vis_polledio {
283 	struct vis_polledio_arg	*arg;
284 	void	(*display)(struct vis_polledio_arg *,
285 			struct vis_consdisplay *);
286 	void	(*copy)(struct vis_polledio_arg *, struct vis_conscopy *);
287 	void	(*cursor)(struct vis_polledio_arg *, struct vis_conscursor *);
288 };
289 
290 struct vis_devinit {
291 	int		version;	/* Console IO interface version */
292 	screen_size_t	width;		/* Width of the device */
293 	screen_size_t	height;		/* Height of the device */
294 	screen_size_t	linebytes;	/* Bytes per scan line */
295 	int		depth;		/* Device depth */
296 	short		mode;		/* Mode to use when displaying data */
297 	struct vis_polledio *polledio; /* Polled output routines */
298 };
299 
300 #endif	/* _KERNEL */
301 
302 /*
303  * VIS_CONS_MODE_CHANGE
304  * Coordinates changes of the console frame buffer mode.
305  *
306  * The exact semantics of this request must be defined by a device-specific
307  * contract between the X server and the frame buffer driver.  Normally,
308  * this request notifies the terminal emulator and the frame buffer driver
309  * that the X server has changed the frame buffer mode, but the contract
310  * can specify that the responsibility is divided differently.  The contract
311  * must specify the allowable modes.
312  *
313  * ioctl(fd, VIS_CONS_MODE_CHANGE, device_specific)
314  */
315 #define	VIS_CONS_MODE_CHANGE	(VIOC|11)
316 
317 #ifdef __cplusplus
318 }
319 #endif
320 
321 #endif	/* !_SYS_VISUAL_IO_H */
322