xref: /onnv-gate/usr/src/uts/common/sys/visual_io.h (revision 1253:0df630a41817)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1253Slq150181  * Common Development and Distribution License (the "License").
6*1253Slq150181  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1253Slq150181 
220Sstevel@tonic-gate /*
23*1253Slq150181  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _SYS_VISUAL_IO_H
280Sstevel@tonic-gate #define	_SYS_VISUAL_IO_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef __cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #define	VIOC	('V' << 8)
370Sstevel@tonic-gate #define	VIOCF	('F' << 8)
380Sstevel@tonic-gate 
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * Device Identification
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * VIS_GETIDENTIFIER returns an identifier string to uniquely identify
440Sstevel@tonic-gate  * a device type used in the Solaris VISUAL environment.  The identifier
450Sstevel@tonic-gate  * must be unique.  We suggest the convention:
460Sstevel@tonic-gate  *
470Sstevel@tonic-gate  *	<companysymbol><devicetype>
480Sstevel@tonic-gate  *
490Sstevel@tonic-gate  * for example: SUNWcg6
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #define	VIS_MAXNAMELEN 128
530Sstevel@tonic-gate 
540Sstevel@tonic-gate struct vis_identifier {
550Sstevel@tonic-gate 	char name[VIS_MAXNAMELEN];	/* <companysymbol><devicename>	*/
560Sstevel@tonic-gate };
570Sstevel@tonic-gate 
580Sstevel@tonic-gate #define	VIS_GETIDENTIFIER	(VIOC | 0)
590Sstevel@tonic-gate 
600Sstevel@tonic-gate 
610Sstevel@tonic-gate 
620Sstevel@tonic-gate /*
630Sstevel@tonic-gate  * Hardware Cursor Control
640Sstevel@tonic-gate  *
650Sstevel@tonic-gate  * Devices with hardware cursors may implement these ioctls in their
660Sstevel@tonic-gate  * kernel device drivers.
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 
700Sstevel@tonic-gate struct vis_cursorpos {
710Sstevel@tonic-gate 	short x;		/* cursor x coordinate	*/
720Sstevel@tonic-gate 	short y;		/* cursor y coordinate	*/
730Sstevel@tonic-gate };
740Sstevel@tonic-gate 
750Sstevel@tonic-gate struct vis_cursorcmap {
760Sstevel@tonic-gate 	int		version;	/* version			*/
770Sstevel@tonic-gate 	int		reserved;
780Sstevel@tonic-gate 	unsigned char	*red;		/* red color map elements	*/
790Sstevel@tonic-gate 	unsigned char	*green;		/* green color map elements	*/
800Sstevel@tonic-gate 	unsigned char	*blue;		/* blue color map elements	*/
810Sstevel@tonic-gate };
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /*
850Sstevel@tonic-gate  * These ioctls fetch and set various cursor attributes, using the
860Sstevel@tonic-gate  * vis_cursor struct.
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate #define	VIS_SETCURSOR	(VIOCF|24)
900Sstevel@tonic-gate #define	VIS_GETCURSOR	(VIOCF|25)
910Sstevel@tonic-gate 
920Sstevel@tonic-gate struct vis_cursor {
930Sstevel@tonic-gate 	short			set;		/* what to set		*/
940Sstevel@tonic-gate 	short			enable;		/* cursor on/off	*/
950Sstevel@tonic-gate 	struct vis_cursorpos	pos;		/* cursor position	*/
960Sstevel@tonic-gate 	struct vis_cursorpos	hot;		/* cursor hot spot	*/
970Sstevel@tonic-gate 	struct vis_cursorcmap	cmap;		/* color map info	*/
980Sstevel@tonic-gate 	struct vis_cursorpos	size;		/* cursor bit map size	*/
990Sstevel@tonic-gate 	char			*image;		/* cursor image bits	*/
1000Sstevel@tonic-gate 	char			*mask;		/* cursor mask bits	*/
1010Sstevel@tonic-gate };
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #define	VIS_CURSOR_SETCURSOR	0x01		/* set cursor		*/
1040Sstevel@tonic-gate #define	VIS_CURSOR_SETPOSITION	0x02		/* set cursor position	*/
1050Sstevel@tonic-gate #define	VIS_CURSOR_SETHOTSPOT	0x04		/* set cursor hot spot	*/
1060Sstevel@tonic-gate #define	VIS_CURSOR_SETCOLORMAP	0x08		/* set cursor colormap	*/
1070Sstevel@tonic-gate #define	VIS_CURSOR_SETSHAPE	0x10		/* set cursor shape	*/
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate #define	VIS_CURSOR_SETALL	(VIS_CURSOR_SETCURSOR | \
1100Sstevel@tonic-gate     VIS_CURSOR_SETPOSITION	| \
1110Sstevel@tonic-gate     VIS_CURSOR_SETHOTSPOT	| \
1120Sstevel@tonic-gate     VIS_CURSOR_SETCOLORMAP	| \
1130Sstevel@tonic-gate     VIS_CURSOR_SETSHAPE)
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate /*
1170Sstevel@tonic-gate  * These ioctls fetch and move the current cursor position, using the
1180Sstevel@tonic-gate  * vis_cursorposition struct.
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate #define	VIS_MOVECURSOR		(VIOCF|26)
1220Sstevel@tonic-gate #define	VIS_GETCURSORPOS	(VIOCF|27)
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * VIS_SETCMAP:
1260Sstevel@tonic-gate  * VIS_GETCMAP:
1270Sstevel@tonic-gate  * Set/Get the indicated color map entries.  The index states the first
1280Sstevel@tonic-gate  * color to be update and count specifies the number of entries to be
1290Sstevel@tonic-gate  * updated from index.  red, green, and blue are arrays of color
1300Sstevel@tonic-gate  * values.  The length of the arrays is count.
1310Sstevel@tonic-gate  */
1320Sstevel@tonic-gate #define	VIS_GETCMAP	(VIOC|9)
1330Sstevel@tonic-gate #define	VIS_PUTCMAP	(VIOC|10)
134*1253Slq150181 struct vis_cmap {
1350Sstevel@tonic-gate 	int		index; /* Index into colormap to start updating */
1360Sstevel@tonic-gate 	int		count; /* Number of entries to update */
1370Sstevel@tonic-gate 	unsigned char	*red; /* List of red values */
1380Sstevel@tonic-gate 	unsigned char	*green; /* List of green values */
1390Sstevel@tonic-gate 	unsigned char	*blue; /* List of blue values */
1400Sstevel@tonic-gate };
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate #ifdef _KERNEL
1440Sstevel@tonic-gate /*
1450Sstevel@tonic-gate  * The following ioctls are used for communication between the layered
1460Sstevel@tonic-gate  * device and the framebuffer.  The layered driver calls the framebuffer
1470Sstevel@tonic-gate  * with these ioctls.
1480Sstevel@tonic-gate  *
1490Sstevel@tonic-gate  * On machines that don't have a prom, kmdb uses the kernel to display
1500Sstevel@tonic-gate  * characters.  The kernel in turn will use the routines returned by
1510Sstevel@tonic-gate  * VIS_DEVINIT to ask the framebuffer driver to display the data.  The
1520Sstevel@tonic-gate  * framebuffer driver CANNOT use any DDI services to display this data.  It
1530Sstevel@tonic-gate  * must just dump the data to the framebuffer.  In particular, the mutex and
1540Sstevel@tonic-gate  * copy routines do not work.
1550Sstevel@tonic-gate  *
1560Sstevel@tonic-gate  * On machines without a prom, the framebuffer driver must implement all
1570Sstevel@tonic-gate  * of these ioctls to be a console.  On machines with a prom, the
1580Sstevel@tonic-gate  * framebuffer driver can set vis_devinit.polledio to NULL.
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate typedef short screen_pos_t;
1610Sstevel@tonic-gate typedef short screen_size_t;
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /*
1640Sstevel@tonic-gate  * Union of pixel depths
1650Sstevel@tonic-gate  */
1660Sstevel@tonic-gate typedef union {
1670Sstevel@tonic-gate 	unsigned char  mono;   /* one-bit */
1680Sstevel@tonic-gate 	unsigned char  four;   /* four bit */
1690Sstevel@tonic-gate 	unsigned char  eight;  /* eight bit */
1700Sstevel@tonic-gate 	unsigned char  twentyfour[3];  /* 24 bit */
1710Sstevel@tonic-gate } color_t;
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate /*
1740Sstevel@tonic-gate  * VIS_DEVINIT:
1750Sstevel@tonic-gate  * Initialize the framebuffer as a console device.  The terminal emulator
1760Sstevel@tonic-gate  * will provide the following structure to the device driver to be filled in.
1770Sstevel@tonic-gate  * The driver is expected to fill it in.
1780Sstevel@tonic-gate  *
1790Sstevel@tonic-gate  * ioctl(fd, VIS_DEVINIT, struct vis_devinit *)
1800Sstevel@tonic-gate  */
1810Sstevel@tonic-gate #define	VIS_DEVINIT	(VIOC|1)
182*1253Slq150181 #define	VIS_CONS_REV		3 /* Console IO interface version */
1830Sstevel@tonic-gate /* Modes */
1840Sstevel@tonic-gate #define	VIS_TEXT		0 /* Use text mode when displaying data */
1850Sstevel@tonic-gate #define	VIS_PIXEL		1 /* Use pixel mode when displaying data */
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate /*
1880Sstevel@tonic-gate  * VIS_DEVFINI:
1890Sstevel@tonic-gate  * Tells the framebuffer that it is no longer being used as a console.
1900Sstevel@tonic-gate  *
1910Sstevel@tonic-gate  * ioctl(fd, VIS_DEVFINI, unused)
1920Sstevel@tonic-gate  */
1930Sstevel@tonic-gate #define	VIS_DEVFINI	(VIOC|2)
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate /*
1960Sstevel@tonic-gate  * VIS_CONSCURSOR:
1970Sstevel@tonic-gate  * Display/Hide cursor on the screen.  The layered driver uses this ioctl to
1980Sstevel@tonic-gate  * display, hide, and move the cursor on the console.  The framebuffer driver
1990Sstevel@tonic-gate  * is expected to draw a cursor at position (col,row) of size width x height.
2000Sstevel@tonic-gate  *
2010Sstevel@tonic-gate  * ioctl(fd, VIS_CONSCURSOR, struct vis_conscursor *)
2020Sstevel@tonic-gate  */
2030Sstevel@tonic-gate #define	VIS_CONSCURSOR		(VIOC|3)
2040Sstevel@tonic-gate /* Cursor action - Either display or hide cursor */
2050Sstevel@tonic-gate #define	VIS_HIDE_CURSOR		0
2060Sstevel@tonic-gate #define	VIS_DISPLAY_CURSOR	1
2070Sstevel@tonic-gate #define	VIS_GET_CURSOR		2
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate /*
2100Sstevel@tonic-gate  * VIS_CONSDISPLAY:
2110Sstevel@tonic-gate  * Display data on the framebuffer.  The data will be in the form specified
2120Sstevel@tonic-gate  * by the driver during console initialization (see VIS_CONSDEVINIT above).
2130Sstevel@tonic-gate  * The driver is expected to display the data at location (row,col).  Width
2140Sstevel@tonic-gate  * and height specify the size of the data.
2150Sstevel@tonic-gate  *
2160Sstevel@tonic-gate  * ioctl(fd, VIS_CONSDISPLAY, struct vis_consdisplay *)
2170Sstevel@tonic-gate  */
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate #define	VIS_CONSDISPLAY		(VIOC|5)
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate /*
2220Sstevel@tonic-gate  * VIS_CONSCOPY:
2230Sstevel@tonic-gate  * Move data on the framebuffer.  Used to scroll the screen by the terminal
2240Sstevel@tonic-gate  * emulator or to move data by applications.  The driver must copy the data
2250Sstevel@tonic-gate  * specified by the rectangle (s_col,s_row),(e_col,e_row) to the location
2260Sstevel@tonic-gate  * which starts at (t_col,t_row), handling overlapping copies correctly.
2270Sstevel@tonic-gate  *
2280Sstevel@tonic-gate  * ioctl(fd, VIS_CONSCOPY, struct vis_conscopy *)
2290Sstevel@tonic-gate  */
2300Sstevel@tonic-gate #define	VIS_CONSCOPY		(VIOC|7)
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate struct vis_consdisplay {
2330Sstevel@tonic-gate 	screen_pos_t	row; /* Row to display data at */
2340Sstevel@tonic-gate 	screen_pos_t	col; /* Col to display data at */
2350Sstevel@tonic-gate 	screen_size_t	width; /* Width of data */
2360Sstevel@tonic-gate 	screen_size_t	height; /* Height of data */
2370Sstevel@tonic-gate 	unsigned char	*data; /* Data to display */
2380Sstevel@tonic-gate 	unsigned char	fg_color; /* Foreground color */
2390Sstevel@tonic-gate 	unsigned char	bg_color; /* Background color */
2400Sstevel@tonic-gate };
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate struct vis_conscopy {
2430Sstevel@tonic-gate 	screen_pos_t	s_row; /* Starting row */
2440Sstevel@tonic-gate 	screen_pos_t	s_col; /* Starting col */
2450Sstevel@tonic-gate 	screen_pos_t	e_row; /* Ending row */
2460Sstevel@tonic-gate 	screen_pos_t	e_col; /* Ending col */
2470Sstevel@tonic-gate 	screen_pos_t	t_row; /* Row to move to */
2480Sstevel@tonic-gate 	screen_pos_t	t_col; /* Col to move to */
2490Sstevel@tonic-gate };
2500Sstevel@tonic-gate 
2510Sstevel@tonic-gate struct vis_conscursor {
2520Sstevel@tonic-gate 	screen_pos_t	row; /* Row to display cursor at */
2530Sstevel@tonic-gate 	screen_pos_t	col; /* Col to display cursor at */
2540Sstevel@tonic-gate 	screen_size_t	width; /* Width of cursor */
2550Sstevel@tonic-gate 	screen_size_t	height; /* Height of cursor */
2560Sstevel@tonic-gate 	color_t		fg_color; /* Foreground color */
2570Sstevel@tonic-gate 	color_t		bg_color; /* Background color */
2580Sstevel@tonic-gate 	short		action; /* Hide or show cursor */
2590Sstevel@tonic-gate };
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate /*
2620Sstevel@tonic-gate  * Each software-console-capable frame buffer driver defines its own
2630Sstevel@tonic-gate  * instance of this (with its own name!) and casts to/from this at the
264*1253Slq150181  * interface with the terminal emulator.  These yield somewhat better
2650Sstevel@tonic-gate  * type checking than "void *".
2660Sstevel@tonic-gate  */
2670Sstevel@tonic-gate struct vis_polledio_arg;
268*1253Slq150181 struct vis_modechg_arg;
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate /*
2710Sstevel@tonic-gate  * Each software-console-capable frame buffer driver supplies these routines
2720Sstevel@tonic-gate  * for I/O from "polled" contexts - kmdb, OBP, etc.  No system services are
2730Sstevel@tonic-gate  * available.
2740Sstevel@tonic-gate  */
2750Sstevel@tonic-gate struct vis_polledio {
2760Sstevel@tonic-gate 	struct vis_polledio_arg	*arg;
277*1253Slq150181 	void	(*display)(struct vis_polledio_arg *, struct vis_consdisplay *);
2780Sstevel@tonic-gate 	void	(*copy)(struct vis_polledio_arg *, struct vis_conscopy *);
2790Sstevel@tonic-gate 	void	(*cursor)(struct vis_polledio_arg *, struct vis_conscursor *);
2800Sstevel@tonic-gate };
2810Sstevel@tonic-gate 
282*1253Slq150181 struct vis_devinit; /* forward decl. for typedef */
283*1253Slq150181 
284*1253Slq150181 typedef void (*vis_modechg_cb_t)(struct vis_modechg_arg *,
285*1253Slq150181     struct vis_devinit *);
286*1253Slq150181 
2870Sstevel@tonic-gate struct vis_devinit {
288*1253Slq150181 	/*
289*1253Slq150181 	 * This set of fields are used as parameters passed from the
290*1253Slq150181 	 * layered framebuffer driver to the terminal emulator.
291*1253Slq150181 	 */
2920Sstevel@tonic-gate 	int		version;	/* Console IO interface version */
2930Sstevel@tonic-gate 	screen_size_t	width;		/* Width of the device */
2940Sstevel@tonic-gate 	screen_size_t	height;		/* Height of the device */
2950Sstevel@tonic-gate 	screen_size_t	linebytes;	/* Bytes per scan line */
2960Sstevel@tonic-gate 	int		depth;		/* Device depth */
2970Sstevel@tonic-gate 	short		mode;		/* Mode to use when displaying data */
298*1253Slq150181 	struct vis_polledio *polledio;	/* Polled output routines */
299*1253Slq150181 
300*1253Slq150181 	/*
301*1253Slq150181 	 * The following fields are used as parameters passed from the
302*1253Slq150181 	 * terminal emulator to the underlying framebuffer driver.
303*1253Slq150181 	 */
304*1253Slq150181 	vis_modechg_cb_t modechg_cb;	/* Video mode change callback */
305*1253Slq150181 	struct vis_modechg_arg *modechg_arg; /* Mode change cb arg */
3060Sstevel@tonic-gate };
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate #endif	/* _KERNEL */
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate #ifdef __cplusplus
3110Sstevel@tonic-gate }
3120Sstevel@tonic-gate #endif
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate #endif	/* !_SYS_VISUAL_IO_H */
315