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