wsdisplayvar.h revision 1.31
1/* $OpenBSD: wsdisplayvar.h,v 1.31 2017/07/19 14:34:10 kettenis Exp $ */
2/* $NetBSD: wsdisplayvar.h,v 1.30 2005/02/04 02:10:49 perry Exp $ */
3
4/*
5 * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *      This product includes software developed by Christopher G. Demetriou
18 *	for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 *    derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * Default to white on black except on Sun hardware, where we default
36 * to black on white to match the firmware console.
37 */
38#ifndef WS_DEFAULT_FG
39#if defined(__sparc64__)
40#define WS_DEFAULT_FG WSCOL_BLACK
41#else
42#define WS_DEFAULT_FG WSCOL_WHITE
43#endif
44#endif
45#ifndef WS_DEFAULT_BG
46#if defined(__sparc64__)
47#define WS_DEFAULT_BG WSCOL_WHITE
48#else
49#define WS_DEFAULT_BG WSCOL_BLACK
50#endif
51#endif
52
53struct device;
54
55/*
56 * WSDISPLAY interfaces
57 */
58
59#define WSDISPLAY_MAXSCREEN	12
60
61/*
62 * Emulation functions, for displays that can support glass-tty terminal
63 * emulations.  These are character oriented, with row and column
64 * numbers starting at zero in the upper left hand corner of the
65 * screen.
66 *
67 * These are used only when emulating a terminal.  Therefore, displays
68 * drivers which cannot emulate terminals do not have to provide them.
69 *
70 * There is a "void *" cookie provided by the display driver associated
71 * with these functions, which is passed to them when they are invoked.
72 */
73struct wsdisplay_emulops {
74	int	(*cursor)(void *c, int on, int row, int col);
75	int	(*mapchar)(void *, int, unsigned int *);
76	int	(*putchar)(void *c, int row, int col, u_int uc, long attr);
77	int	(*copycols)(void *c, int row, int srccol, int dstcol,
78		    int ncols);
79	int	(*erasecols)(void *c, int row, int startcol, int ncols, long);
80	int	(*copyrows)(void *c, int srcrow, int dstrow, int nrows);
81	int	(*eraserows)(void *c, int row, int nrows, long attr);
82	int	(*alloc_attr)(void *c, int fg, int bg, int flags, long *attrp);
83	void	(*unpack_attr)(void *c, long attr, int *fg, int *bg, int *ul);
84/* fg / bg values. Made identical to ANSI terminal color codes. */
85#define WSCOL_BLACK	0
86#define WSCOL_RED	1
87#define WSCOL_GREEN	2
88#define WSCOL_BROWN	3
89#define WSCOL_BLUE	4
90#define WSCOL_MAGENTA	5
91#define WSCOL_CYAN	6
92#define WSCOL_WHITE	7
93/* flag values: */
94#define WSATTR_REVERSE	1
95#define WSATTR_HILIT	2
96#define WSATTR_BLINK	4
97#define WSATTR_UNDERLINE 8
98#define WSATTR_WSCOLORS 16
99	/* XXX need a free_attr() ??? */
100};
101
102#define	WSSCREEN_NAME_SIZE	16
103
104struct wsscreen_descr {
105	char name[WSSCREEN_NAME_SIZE];
106	int ncols, nrows;
107	const struct wsdisplay_emulops *textops;
108	int fontwidth, fontheight;
109	int capabilities;
110#define WSSCREEN_WSCOLORS	1	/* minimal color capability */
111#define WSSCREEN_REVERSE	2	/* can display reversed */
112#define WSSCREEN_HILIT		4	/* can highlight (however) */
113#define WSSCREEN_BLINK		8	/* can blink */
114#define WSSCREEN_UNDERLINE	16	/* can underline */
115};
116
117/*
118 * Character cell description (for emulation mode).
119 */
120struct wsdisplay_charcell {
121	u_int	uc;
122	long	attr;
123};
124
125struct wsdisplay_font;
126/*
127 * Display access functions, invoked by user-land programs which require
128 * direct device access, such as X11.
129 *
130 * There is a "void *" cookie provided by the display driver associated
131 * with these functions, which is passed to them when they are invoked.
132 */
133struct wsdisplay_accessops {
134	int	(*ioctl)(void *v, u_long cmd, caddr_t data, int flag,
135		    struct proc *p);
136	paddr_t	(*mmap)(void *v, off_t off, int prot);
137	int	(*alloc_screen)(void *, const struct wsscreen_descr *,
138				     void **, int *, int *, long *);
139	void	(*free_screen)(void *, void *);
140	int	(*show_screen)(void *, void *, int,
141			       void (*) (void *, int, int), void *);
142	int	(*load_font)(void *, void *, struct wsdisplay_font *);
143	int	(*list_font)(void *, struct wsdisplay_font *);
144	void	(*scrollback)(void *, void *, int);
145	int	(*getchar)(void *, int, int, struct wsdisplay_charcell *);
146	void	(*burn_screen)(void *, u_int, u_int);
147	void	(*pollc)(void *, int);
148	void	(*enter_ddb)(void *, void *);
149};
150
151/* passed to wscons by the video driver to tell about its capabilities */
152struct wsscreen_list {
153	int nscreens;
154	const struct wsscreen_descr **screens;
155};
156
157/*
158 * Attachment information provided by wsemuldisplaydev devices when attaching
159 * wsdisplay units.
160 */
161struct wsemuldisplaydev_attach_args {
162	int	console;				/* is it console? */
163	const struct wsscreen_list *scrdata;		/* screen cfg info */
164	const struct wsdisplay_accessops *accessops;	/* access ops */
165	void	*accesscookie;				/* access cookie */
166	u_int	defaultscreens;				/* screens to create */
167};
168
169#define	WSEMULDISPLAYDEVCF_CONSOLE	0
170#define	wsemuldisplaydevcf_console	cf_loc[WSEMULDISPLAYDEVCF_CONSOLE]	/* spec'd as console? */
171#define	WSEMULDISPLAYDEVCF_CONSOLE_UNK	-1
172#define	WSDISPLAYDEVCF_MUX		0
173#define	wsdisplaydevcf_mux		cf_loc[WSDISPLAYDEVCF_MUX]
174#define	WSEMULDISPLAYDEVCF_MUX		1
175#define	wsemuldisplaydevcf_mux		cf_loc[WSEMULDISPLAYDEVCF_MUX]
176
177struct wscons_syncops {
178	int (*detach)(void *, int, void (*)(void *, int, int), void *);
179	int (*attach)(void *, int, void (*)(void *, int, int), void *);
180	int (*check)(void *);
181	void (*destroy)(void *);
182};
183
184/*
185 * Autoconfiguration helper functions.
186 */
187void	wsdisplay_cnattach(const struct wsscreen_descr *, void *,
188				int, int, long);
189int	wsemuldisplaydevprint(void *, const char *);
190int	wsemuldisplaydevsubmatch(struct device *, void *, void *);
191
192/*
193 * Console interface.
194 */
195void	wsdisplay_cnputc(dev_t dev, int i);
196
197/*
198 * for use by compatibility code
199 */
200struct wsdisplay_softc;
201struct wsscreen;
202int wsscreen_attach_sync(struct wsscreen *,
203			      const struct wscons_syncops *, void *);
204int wsscreen_detach_sync(struct wsscreen *);
205int wsscreen_lookup_sync(struct wsscreen *,
206			      const struct wscons_syncops *, void **);
207
208int wsdisplay_maxscreenidx(struct wsdisplay_softc *);
209int wsdisplay_screenstate(struct wsdisplay_softc *, int);
210int wsdisplay_getactivescreen(struct wsdisplay_softc *);
211int wsscreen_switchwait(struct wsdisplay_softc *, int);
212
213int wsdisplay_internal_ioctl(struct wsdisplay_softc *sc,
214				  struct wsscreen *,
215				  u_long cmd, caddr_t data,
216				  int flag, struct proc *p);
217
218int wsdisplay_usl_ioctl1(struct wsdisplay_softc *,
219			     u_long, caddr_t, int, struct proc *);
220
221int wsdisplay_usl_ioctl2(struct wsdisplay_softc *, struct wsscreen *,
222			     u_long, caddr_t, int, struct proc *);
223
224int wsdisplay_cfg_ioctl(struct wsdisplay_softc *sc,
225			     u_long cmd, caddr_t data,
226			     int flag, struct proc *p);
227
228/*
229 * for general use
230 */
231#define WSDISPLAY_NULLSCREEN	-1
232void wsdisplay_switchtoconsole(void);
233void wsdisplay_enter_ddb(void);
234void wsdisplay_suspend(void);
235void wsdisplay_resume(void);
236const struct wsscreen_descr *
237    wsdisplay_screentype_pick(const struct wsscreen_list *, const char *);
238
239/*
240 * for use by wskbd
241 */
242void wsdisplay_burn(void *v, u_int flags);
243void wsscrollback(void *v, int op);
244
245#define WSDISPLAY_SCROLL_BACKWARD	0
246#define WSDISPLAY_SCROLL_FORWARD	1
247#define WSDISPLAY_SCROLL_RESET		2
248
249/*
250 * screen burner
251 */
252#define	WSDISPLAY_DEFBURNOUT	0	/* disabled */
253#define	WSDISPLAY_DEFBURNIN	250	/* ms */
254
255