summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/visual_io.h
blob: c894bb48bcb9b0b820360745009a7b5b0b9b81a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SYS_VISUAL_IO_H
#define	_SYS_VISUAL_IO_H

#ifdef __cplusplus
extern "C" {
#endif

#define	VIOC	('V' << 8)
#define	VIOCF	('F' << 8)


/*
 * Device Identification
 *
 * VIS_GETIDENTIFIER returns an identifier string to uniquely identify
 * a device type used in the Solaris VISUAL environment.  The identifier
 * must be unique.  We suggest the convention:
 *
 *	<companysymbol><devicetype>
 *
 * for example: SUNWcg6
 */

#define	VIS_MAXNAMELEN 128

struct vis_identifier {
	char name[VIS_MAXNAMELEN];	/* <companysymbol><devicename>	*/
};

#define	VIS_GETIDENTIFIER	(VIOC | 0)



/*
 * Hardware Cursor Control
 *
 * Devices with hardware cursors may implement these ioctls in their
 * kernel device drivers.
 */


struct vis_cursorpos {
	short x;		/* cursor x coordinate	*/
	short y;		/* cursor y coordinate	*/
};

struct vis_cursorcmap {
	int		version;	/* version			*/
	int		reserved;
	unsigned char	*red;		/* red color map elements	*/
	unsigned char	*green;		/* green color map elements	*/
	unsigned char	*blue;		/* blue color map elements	*/
};


/*
 * These ioctls fetch and set various cursor attributes, using the
 * vis_cursor struct.
 */

#define	VIS_SETCURSOR	(VIOCF|24)
#define	VIS_GETCURSOR	(VIOCF|25)

struct vis_cursor {
	short			set;		/* what to set		*/
	short			enable;		/* cursor on/off	*/
	struct vis_cursorpos	pos;		/* cursor position	*/
	struct vis_cursorpos	hot;		/* cursor hot spot	*/
	struct vis_cursorcmap	cmap;		/* color map info	*/
	struct vis_cursorpos	size;		/* cursor bit map size	*/
	char			*image;		/* cursor image bits	*/
	char			*mask;		/* cursor mask bits	*/
};

#define	VIS_CURSOR_SETCURSOR	0x01		/* set cursor		*/
#define	VIS_CURSOR_SETPOSITION	0x02		/* set cursor position	*/
#define	VIS_CURSOR_SETHOTSPOT	0x04		/* set cursor hot spot	*/
#define	VIS_CURSOR_SETCOLORMAP	0x08		/* set cursor colormap	*/
#define	VIS_CURSOR_SETSHAPE	0x10		/* set cursor shape	*/

#define	VIS_CURSOR_SETALL	(VIS_CURSOR_SETCURSOR | \
    VIS_CURSOR_SETPOSITION	| \
    VIS_CURSOR_SETHOTSPOT	| \
    VIS_CURSOR_SETCOLORMAP	| \
    VIS_CURSOR_SETSHAPE)


/*
 * These ioctls fetch and move the current cursor position, using the
 * vis_cursorposition struct.
 */

#define	VIS_MOVECURSOR		(VIOCF|26)
#define	VIS_GETCURSORPOS	(VIOCF|27)

/*
 * VIS_SETCMAP:
 * VIS_GETCMAP:
 * Set/Get the indicated color map entries.  The index states the first
 * color to be update and count specifies the number of entries to be
 * updated from index.  red, green, and blue are arrays of color
 * values.  The length of the arrays is count.
 */
#define	VIS_GETCMAP	(VIOC|9)
#define	VIS_PUTCMAP	(VIOC|10)
struct vis_cmap {
	int		index; /* Index into colormap to start updating */
	int		count; /* Number of entries to update */
	unsigned char	*red; /* List of red values */
	unsigned char	*green; /* List of green values */
	unsigned char	*blue; /* List of blue values */
};


#if defined(_KERNEL) || defined(_STANDALONE)
/*
 * The following ioctls are used for communication between the layered
 * device and the framebuffer.  The layered driver calls the framebuffer
 * with these ioctls.
 *
 * On machines that don't have a prom, kmdb uses the kernel to display
 * characters.  The kernel in turn will use the routines returned by
 * VIS_DEVINIT to ask the framebuffer driver to display the data.  The
 * framebuffer driver CANNOT use any DDI services to display this data.  It
 * must just dump the data to the framebuffer.  In particular, the mutex and
 * copy routines do not work.
 *
 * On machines without a prom, the framebuffer driver must implement all
 * of these ioctls to be a console.  On machines with a prom, the
 * framebuffer driver can set vis_devinit.polledio to NULL.
 */
typedef short screen_pos_t;
typedef short screen_size_t;

/*
 * Union of pixel depths
 */
typedef union {
	unsigned char mono;		/* one-bit */
	unsigned char four;		/* four bit */
	unsigned char eight;		/* eight bit */
	unsigned char sixteen[2];	/* 16 bit */
	unsigned char twentyfour[3];	/* 24 bit */
	unsigned char thirtytwo[4];	/* 32 bit */
} color_t;

/*
 * VIS_DEVINIT:
 * Initialize the framebuffer as a console device.  The terminal emulator
 * will provide the following structure to the device driver to be filled in.
 * The driver is expected to fill it in.
 *
 * ioctl(fd, VIS_DEVINIT, struct vis_devinit *)
 */
#define	VIS_DEVINIT	(VIOC|1)
#define	VIS_CONS_REV		5 /* Console IO interface version */
/* Modes */
#define	VIS_TEXT		0 /* Use text mode when displaying data */
#define	VIS_PIXEL		1 /* Use pixel mode when displaying data */

/*
 * VIS_DEVFINI:
 * Tells the framebuffer that it is no longer being used as a console.
 *
 * ioctl(fd, VIS_DEVFINI, unused)
 */
#define	VIS_DEVFINI	(VIOC|2)

/*
 * VIS_CONSCURSOR:
 * Display/Hide cursor on the screen.  The layered driver uses this ioctl to
 * display, hide, and move the cursor on the console.  The framebuffer driver
 * is expected to draw a cursor at position (col,row) of size width x height.
 *
 * ioctl(fd, VIS_CONSCURSOR, struct vis_conscursor *)
 */
#define	VIS_CONSCURSOR		(VIOC|3)
/* Cursor action - Either display or hide cursor */
#define	VIS_HIDE_CURSOR		0
#define	VIS_DISPLAY_CURSOR	1
#define	VIS_GET_CURSOR		2

/*
 * VIS_CONSDISPLAY:
 * Display data on the framebuffer.  The data will be in the form specified
 * by the driver during console initialization (see VIS_CONSDEVINIT above).
 * The driver is expected to display the data at location (row,col).  Width
 * and height specify the size of the data.
 *
 * ioctl(fd, VIS_CONSDISPLAY, struct vis_consdisplay *)
 */

#define	VIS_CONSDISPLAY		(VIOC|5)

/*
 * VIS_CONSCOPY:
 * Move data on the framebuffer.  Used to scroll the screen by the terminal
 * emulator or to move data by applications.  The driver must copy the data
 * specified by the rectangle (s_col,s_row),(e_col,e_row) to the location
 * which starts at (t_col,t_row), handling overlapping copies correctly.
 *
 * ioctl(fd, VIS_CONSCOPY, struct vis_conscopy *)
 */
#define	VIS_CONSCOPY		(VIOC|7)

/*
 * VIS_CONSCLEAR:
 * Clear the screen using provided color. Used on VIS_PIXEL mode.
 *
 * ioctl(fd, VIS_CONSCLEAR, struct vis_consclear *)
 */
#define	VIS_CONSCLEAR		(VIOC|8)

struct vis_consclear {
	color_t	bg_color; /* Background color */
};

struct vis_consdisplay {
	screen_pos_t	row; /* Row to display data at */
	screen_pos_t	col; /* Col to display data at */
	screen_size_t	width; /* Width of data */
	screen_size_t	height; /* Height of data */
	unsigned char	*data; /* Data to display */
	color_t		fg_color; /* Foreground color */
	color_t		bg_color; /* Background color */
};

struct vis_conscopy {
	screen_pos_t	s_row; /* Starting row */
	screen_pos_t	s_col; /* Starting col */
	screen_pos_t	e_row; /* Ending row */
	screen_pos_t	e_col; /* Ending col */
	screen_pos_t	t_row; /* Row to move to */
	screen_pos_t	t_col; /* Col to move to */
};

struct vis_conscursor {
	screen_pos_t	row; /* Row to display cursor at */
	screen_pos_t	col; /* Col to display cursor at */
	screen_size_t	width; /* Width of cursor */
	screen_size_t	height; /* Height of cursor */
	color_t		fg_color; /* Foreground color */
	color_t		bg_color; /* Background color */
	short		action; /* Hide or show cursor */
};

/*
 * Each software-console-capable frame buffer driver defines its own
 * instance of this (with its own name!) and casts to/from this at the
 * interface with the terminal emulator.  These yield somewhat better
 * type checking than "void *".
 */
struct vis_polledio_arg;
struct vis_modechg_arg;

/*
 * Each software-console-capable frame buffer driver supplies these routines
 * for I/O from "polled" contexts - kmdb, OBP, etc.  No system services are
 * available.
 */
struct vis_polledio {
	struct vis_polledio_arg	*arg;
	void	(*display)(struct vis_polledio_arg *, struct vis_consdisplay *);
	void	(*copy)(struct vis_polledio_arg *, struct vis_conscopy *);
	void	(*cursor)(struct vis_polledio_arg *, struct vis_conscursor *);
};

struct vis_devinit; /* forward decl. for typedef */

typedef void (*vis_modechg_cb_t)(struct vis_modechg_arg *,
    struct vis_devinit *);

typedef uint32_t (*color_map_fn_t)(uint8_t color);

struct vis_devinit {
	/*
	 * This set of fields are used as parameters passed from the
	 * layered framebuffer driver to the terminal emulator.
	 */
	int		version;	/* Console IO interface version */
	screen_size_t	width;		/* Width of the device */
	screen_size_t	height;		/* Height of the device */
	screen_size_t	linebytes;	/* Bytes per scan line */
	int		depth;		/* Device depth */
	color_map_fn_t	color_map;	/* Color map tem -> fb */
	short		mode;		/* Mode to use when displaying data */
	struct vis_polledio *polledio;	/* Polled output routines */

	/*
	 * The following fields are used as parameters passed from the
	 * terminal emulator to the underlying framebuffer driver.
	 */
	vis_modechg_cb_t modechg_cb;	/* Video mode change callback */
	struct vis_modechg_arg *modechg_arg; /* Mode change cb arg */
};

struct visual_ops {
	const struct vis_identifier *ident;
	int (*kdsetmode)(int);
	int (*devinit)(struct vis_devinit *);
	void (*cons_copy)(struct vis_conscopy *);
	void (*cons_display)(struct vis_consdisplay *);
	void (*cons_cursor)(struct vis_conscursor *);
	int (*cons_clear)(struct vis_consclear *);
	int (*cons_put_cmap)(struct vis_cmap *);
};

#endif	/* _KERNEL || _STANDALONE */

#ifdef __cplusplus
}
#endif

#endif	/* !_SYS_VISUAL_IO_H */