pm.c revision 1.1.16.2 1 1.1.16.2 ad /* $NetBSD: pm.c,v 1.1.16.2 2002/03/16 10:38:12 ad Exp $ */
2 1.1.16.1 ad
3 1.1.16.1 ad /*-
4 1.1.16.1 ad * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.1.16.1 ad * All rights reserved.
6 1.1.16.1 ad *
7 1.1.16.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.16.1 ad * by Andrew Doran.
9 1.1.16.1 ad *
10 1.1.16.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1.16.1 ad * modification, are permitted provided that the following conditions
12 1.1.16.1 ad * are met:
13 1.1.16.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1.16.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1.16.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.16.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1.16.1 ad * documentation and/or other materials provided with the distribution.
18 1.1.16.1 ad * 3. All advertising materials mentioning features or use of this software
19 1.1.16.1 ad * must display the following acknowledgement:
20 1.1.16.1 ad * This product includes software developed by the NetBSD
21 1.1.16.1 ad * Foundation, Inc. and its contributors.
22 1.1.16.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.16.1 ad * contributors may be used to endorse or promote products derived
24 1.1.16.1 ad * from this software without specific prior written permission.
25 1.1.16.1 ad *
26 1.1.16.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.16.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.16.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.16.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.16.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.16.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.16.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.16.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.16.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.16.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.16.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1.16.1 ad */
38 1.1.16.1 ad
39 1.1.16.1 ad /*
40 1.1.16.1 ad * Copyright (c) 1998, 1999 Tohru Nishimura. All rights reserved.
41 1.1.16.1 ad *
42 1.1.16.1 ad * Redistribution and use in source and binary forms, with or without
43 1.1.16.1 ad * modification, are permitted provided that the following conditions
44 1.1.16.1 ad * are met:
45 1.1.16.1 ad * 1. Redistributions of source code must retain the above copyright
46 1.1.16.1 ad * notice, this list of conditions and the following disclaimer.
47 1.1.16.1 ad * 2. Redistributions in binary form must reproduce the above copyright
48 1.1.16.1 ad * notice, this list of conditions and the following disclaimer in the
49 1.1.16.1 ad * documentation and/or other materials provided with the distribution.
50 1.1.16.1 ad * 3. All advertising materials mentioning features or use of this software
51 1.1.16.1 ad * must display the following acknowledgement:
52 1.1.16.1 ad * This product includes software developed by Tohru Nishimura
53 1.1.16.1 ad * for the NetBSD Project.
54 1.1.16.1 ad * 4. The name of the author may not be used to endorse or promote products
55 1.1.16.1 ad * derived from this software without specific prior written permission
56 1.1.16.1 ad *
57 1.1.16.1 ad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58 1.1.16.1 ad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 1.1.16.1 ad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 1.1.16.1 ad * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61 1.1.16.1 ad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 1.1.16.1 ad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 1.1.16.1 ad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 1.1.16.1 ad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 1.1.16.1 ad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 1.1.16.1 ad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 1.1.16.1 ad */
68 1.1.16.1 ad
69 1.1.16.1 ad #include <sys/cdefs.h>
70 1.1.16.2 ad __KERNEL_RCSID(0, "$NetBSD: pm.c,v 1.1.16.2 2002/03/16 10:38:12 ad Exp $");
71 1.1.16.1 ad
72 1.1.16.1 ad #include <sys/param.h>
73 1.1.16.1 ad #include <sys/systm.h>
74 1.1.16.1 ad #include <sys/kernel.h>
75 1.1.16.1 ad #include <sys/device.h>
76 1.1.16.1 ad #include <sys/malloc.h>
77 1.1.16.1 ad #include <sys/buf.h>
78 1.1.16.1 ad #include <sys/ioctl.h>
79 1.1.16.1 ad
80 1.1.16.1 ad #include <machine/bus.h>
81 1.1.16.1 ad #include <machine/intr.h>
82 1.1.16.1 ad
83 1.1.16.1 ad #include <dev/wscons/wsconsio.h>
84 1.1.16.1 ad #include <dev/wscons/wsdisplayvar.h>
85 1.1.16.1 ad #include <dev/rasops/rasops.h>
86 1.1.16.1 ad #include <dev/wsfont/wsfont.h>
87 1.1.16.1 ad
88 1.1.16.1 ad #include <pmax/pmax/kn01.h>
89 1.1.16.1 ad
90 1.1.16.1 ad #include <pmax/ibus/ibusvar.h>
91 1.1.16.1 ad #include <pmax/ibus/pmreg.h>
92 1.1.16.1 ad
93 1.1.16.1 ad #include <uvm/uvm_extern.h>
94 1.1.16.1 ad
95 1.1.16.1 ad struct hwcmap256 {
96 1.1.16.1 ad u_int8_t r[256];
97 1.1.16.1 ad u_int8_t g[256];
98 1.1.16.1 ad u_int8_t b[256];
99 1.1.16.1 ad };
100 1.1.16.1 ad
101 1.1.16.1 ad struct hwcursor64 {
102 1.1.16.1 ad struct wsdisplay_curpos cc_pos;
103 1.1.16.1 ad struct wsdisplay_curpos cc_hot;
104 1.1.16.1 ad struct wsdisplay_curpos cc_size;
105 1.1.16.1 ad #define CURSOR_MAX_SIZE 16
106 1.1.16.1 ad u_int8_t cc_color[6];
107 1.1.16.1 ad u_short cc_image[16 + 16];
108 1.1.16.1 ad };
109 1.1.16.1 ad
110 1.1.16.1 ad struct pm_softc {
111 1.1.16.1 ad struct device sc_dev;
112 1.1.16.1 ad size_t sc_cmap_size;
113 1.1.16.1 ad size_t sc_fb_size;
114 1.1.16.1 ad int sc_type;
115 1.1.16.1 ad int sc_blanked;
116 1.1.16.1 ad int sc_curenb;
117 1.1.16.1 ad int sc_changed;
118 1.1.16.1 ad int sc_nscreens;
119 1.1.16.1 ad struct hwcursor64 sc_cursor;
120 1.1.16.1 ad struct hwcmap256 sc_cmap;
121 1.1.16.1 ad };
122 1.1.16.1 ad #define WSDISPLAY_CMAP_DOLUT 0x20
123 1.1.16.1 ad
124 1.1.16.1 ad int pmmatch(struct device *, struct cfdata *, void *);
125 1.1.16.1 ad void pmattach(struct device *, struct device *, void *);
126 1.1.16.1 ad int pm_ioctl(void *, u_long, caddr_t, int, struct proc *);
127 1.1.16.1 ad paddr_t pm_mmap(void *, off_t, int);
128 1.1.16.1 ad int pm_alloc_screen(void *, const struct wsscreen_descr *,
129 1.1.16.1 ad void **, int *, int *, long *);
130 1.1.16.1 ad void pm_free_screen(void *, void *);
131 1.1.16.1 ad int pm_show_screen(void *, void *, int,
132 1.1.16.1 ad void (*) (void *, int, int), void *);
133 1.1.16.2 ad void pm_cursor_off(void);
134 1.1.16.1 ad void pm_cursor_on(struct pm_softc *);
135 1.1.16.2 ad int pm_cnattach(void);
136 1.1.16.2 ad void pm_common_init(void);
137 1.1.16.1 ad int pm_flush(struct pm_softc *);
138 1.1.16.1 ad int pm_get_cmap(struct pm_softc *, struct wsdisplay_cmap *);
139 1.1.16.1 ad int pm_set_cmap(struct pm_softc *, struct wsdisplay_cmap *);
140 1.1.16.1 ad int pm_set_cursor(struct pm_softc *, struct wsdisplay_cursor *);
141 1.1.16.1 ad int pm_get_cursor(struct pm_softc *, struct wsdisplay_cursor *);
142 1.1.16.1 ad void pm_set_curpos(struct pm_softc *, struct wsdisplay_curpos *);
143 1.1.16.1 ad void pm_init_cmap(struct pm_softc *);
144 1.1.16.1 ad
145 1.1.16.1 ad const struct cfattach pm_ca = {
146 1.1.16.1 ad sizeof(struct pm_softc), pmmatch, pmattach,
147 1.1.16.1 ad };
148 1.1.16.1 ad
149 1.1.16.1 ad struct rasops_info pm_ri;
150 1.1.16.1 ad
151 1.1.16.1 ad struct wsscreen_descr pm_stdscreen = {
152 1.1.16.1 ad "std", 0, 0,
153 1.1.16.1 ad 0, /* textops */
154 1.1.16.1 ad 0, 0,
155 1.1.16.1 ad WSSCREEN_REVERSE
156 1.1.16.1 ad };
157 1.1.16.1 ad
158 1.1.16.1 ad const struct wsscreen_descr *_pm_scrlist[] = {
159 1.1.16.1 ad &pm_stdscreen,
160 1.1.16.1 ad };
161 1.1.16.1 ad
162 1.1.16.1 ad const struct wsscreen_list pm_screenlist = {
163 1.1.16.1 ad sizeof(_pm_scrlist) / sizeof(struct wsscreen_descr *), _pm_scrlist
164 1.1.16.1 ad };
165 1.1.16.1 ad
166 1.1.16.1 ad const struct wsdisplay_accessops pm_accessops = {
167 1.1.16.1 ad pm_ioctl,
168 1.1.16.1 ad pm_mmap,
169 1.1.16.1 ad pm_alloc_screen,
170 1.1.16.1 ad pm_free_screen,
171 1.1.16.1 ad pm_show_screen,
172 1.1.16.1 ad 0 /* load_font */
173 1.1.16.1 ad };
174 1.1.16.1 ad
175 1.1.16.1 ad u_int pm_creg;
176 1.1.16.1 ad
177 1.1.16.1 ad int
178 1.1.16.1 ad pmmatch(struct device *parent, struct cfdata *match, void *aux)
179 1.1.16.1 ad {
180 1.1.16.1 ad struct ibus_attach_args *ia;
181 1.1.16.1 ad caddr_t pmaddr;
182 1.1.16.1 ad
183 1.1.16.1 ad ia = aux;
184 1.1.16.1 ad pmaddr = (caddr_t)ia->ia_addr;
185 1.1.16.1 ad
186 1.1.16.1 ad if (strcmp(ia->ia_name, "pm") != 0)
187 1.1.16.1 ad return (0);
188 1.1.16.1 ad
189 1.1.16.1 ad if (badaddr(pmaddr, 4))
190 1.1.16.1 ad return (0);
191 1.1.16.1 ad
192 1.1.16.1 ad return (1);
193 1.1.16.1 ad }
194 1.1.16.1 ad
195 1.1.16.1 ad void
196 1.1.16.1 ad pmattach(struct device *parent, struct device *self, void *aux)
197 1.1.16.1 ad {
198 1.1.16.1 ad struct pm_softc *sc;
199 1.1.16.1 ad struct rasops_info *ri;
200 1.1.16.1 ad struct wsemuldisplaydev_attach_args waa;
201 1.1.16.1 ad int console;
202 1.1.16.1 ad
203 1.1.16.1 ad sc = (struct pm_softc *)self;
204 1.1.16.1 ad ri = &pm_ri;
205 1.1.16.1 ad console = (ri->ri_bits != NULL);
206 1.1.16.1 ad
207 1.1.16.1 ad if (console)
208 1.1.16.1 ad sc->sc_nscreens = 1;
209 1.1.16.1 ad else
210 1.1.16.2 ad pm_common_init();
211 1.1.16.1 ad
212 1.1.16.1 ad printf(": %dx%d, %dbpp\n", ri->ri_width, ri->ri_height, ri->ri_depth);
213 1.1.16.1 ad
214 1.1.16.1 ad pm_init_cmap(sc);
215 1.1.16.1 ad
216 1.1.16.1 ad sc->sc_blanked = 0;
217 1.1.16.1 ad sc->sc_curenb = 0;
218 1.1.16.1 ad
219 1.1.16.1 ad waa.console = console;
220 1.1.16.1 ad waa.scrdata = &pm_screenlist;
221 1.1.16.1 ad waa.accessops = &pm_accessops;
222 1.1.16.1 ad waa.accesscookie = sc;
223 1.1.16.1 ad
224 1.1.16.1 ad config_found(self, &waa, wsemuldisplaydevprint);
225 1.1.16.1 ad }
226 1.1.16.1 ad
227 1.1.16.1 ad void
228 1.1.16.1 ad pm_init_cmap(struct pm_softc *sc)
229 1.1.16.1 ad {
230 1.1.16.1 ad struct hwcmap256 *cm;
231 1.1.16.1 ad struct rasops_info *ri;
232 1.1.16.1 ad const u_int8_t *p;
233 1.1.16.1 ad int index;
234 1.1.16.1 ad
235 1.1.16.1 ad cm = &sc->sc_cmap;
236 1.1.16.1 ad ri = &pm_ri;
237 1.1.16.1 ad
238 1.1.16.1 ad if (ri->ri_depth == 8) {
239 1.1.16.1 ad p = rasops_cmap;
240 1.1.16.1 ad for (index = 0; index < 256; index++, p += 3) {
241 1.1.16.1 ad cm->r[index] = p[0];
242 1.1.16.1 ad cm->g[index] = p[1];
243 1.1.16.1 ad cm->b[index] = p[2];
244 1.1.16.1 ad }
245 1.1.16.1 ad
246 1.1.16.1 ad sc->sc_type = WSDISPLAY_TYPE_PM_COLOR;
247 1.1.16.1 ad sc->sc_cmap_size = 256;
248 1.1.16.1 ad sc->sc_fb_size = 0x100000;
249 1.1.16.1 ad } else {
250 1.1.16.2 ad cm->r[0] = 0x00;
251 1.1.16.2 ad cm->g[0] = 0x00;
252 1.1.16.2 ad cm->b[0] = 0x00;
253 1.1.16.2 ad
254 1.1.16.2 ad cm->r[1] = 0x00;
255 1.1.16.2 ad cm->g[1] = 0xff;
256 1.1.16.2 ad cm->b[1] = 0x00;
257 1.1.16.1 ad
258 1.1.16.1 ad sc->sc_type = WSDISPLAY_TYPE_PM_MONO;
259 1.1.16.1 ad sc->sc_cmap_size = 2;
260 1.1.16.2 ad sc->sc_fb_size = 0x40000;
261 1.1.16.1 ad }
262 1.1.16.1 ad }
263 1.1.16.1 ad
264 1.1.16.1 ad void
265 1.1.16.2 ad pm_common_init(void)
266 1.1.16.1 ad {
267 1.1.16.2 ad struct rasops_info *ri;
268 1.1.16.2 ad int cookie, bior, i;
269 1.1.16.1 ad PCCRegs *pcc;
270 1.1.16.1 ad VDACRegs *vdac;
271 1.1.16.1 ad u_int16_t kn01csr;
272 1.1.16.1 ad
273 1.1.16.1 ad kn01csr = *(volatile u_int16_t *)MIPS_PHYS_TO_KSEG1(KN01_SYS_CSR);
274 1.1.16.2 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
275 1.1.16.2 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
276 1.1.16.2 ad ri = &pm_ri;
277 1.1.16.1 ad
278 1.1.16.1 ad ri->ri_flg = RI_CENTER;
279 1.1.16.1 ad ri->ri_depth = ((kn01csr & KN01_CSR_MONO) != 0 ? 1 : 8);
280 1.1.16.1 ad ri->ri_width = 1024;
281 1.1.16.1 ad ri->ri_height = 864;
282 1.1.16.1 ad ri->ri_stride = (ri->ri_depth == 8 ? 1024 : 2048 / 8);
283 1.1.16.1 ad ri->ri_bits = (void *)MIPS_PHYS_TO_KSEG1(KN01_PHYS_FBUF_START);
284 1.1.16.1 ad
285 1.1.16.1 ad /*
286 1.1.16.1 ad * Clear the screen.
287 1.1.16.1 ad */
288 1.1.16.1 ad #if 0
289 1.1.16.1 ad memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
290 1.1.16.1 ad #endif
291 1.1.16.1 ad
292 1.1.16.1 ad /*
293 1.1.16.1 ad * Get a font to use.
294 1.1.16.1 ad */
295 1.1.16.1 ad bior = (ri->ri_depth == 8 ? WSDISPLAY_FONTORDER_L2R :
296 1.1.16.1 ad WSDISPLAY_FONTORDER_R2L);
297 1.1.16.1 ad
298 1.1.16.1 ad wsfont_init();
299 1.1.16.1 ad cookie = wsfont_find(NULL, 8, 0, 0, bior, WSDISPLAY_FONTORDER_L2R);
300 1.1.16.1 ad if (cookie <= 0)
301 1.1.16.1 ad cookie = wsfont_find(NULL, 0, 0, 0, bior,
302 1.1.16.1 ad WSDISPLAY_FONTORDER_L2R);
303 1.1.16.1 ad if (cookie <= 0) {
304 1.1.16.1 ad printf("pm: font table is empty\n");
305 1.1.16.1 ad return;
306 1.1.16.1 ad }
307 1.1.16.1 ad
308 1.1.16.1 ad if (wsfont_lock(cookie, &ri->ri_font)) {
309 1.1.16.1 ad printf("pm: couldn't lock font\n");
310 1.1.16.1 ad return;
311 1.1.16.1 ad }
312 1.1.16.1 ad ri->ri_wsfcookie = cookie;
313 1.1.16.1 ad
314 1.1.16.1 ad /*
315 1.1.16.1 ad * Set up the raster operations set.
316 1.1.16.1 ad */
317 1.1.16.1 ad rasops_init(ri, 34, 80);
318 1.1.16.1 ad
319 1.1.16.1 ad pm_stdscreen.nrows = ri->ri_rows;
320 1.1.16.1 ad pm_stdscreen.ncols = ri->ri_cols;
321 1.1.16.1 ad pm_stdscreen.textops = &ri->ri_ops;
322 1.1.16.1 ad pm_stdscreen.capabilities = ri->ri_caps;
323 1.1.16.1 ad
324 1.1.16.1 ad /*
325 1.1.16.1 ad * Initalize the VDAC.
326 1.1.16.1 ad */
327 1.1.16.2 ad *(u_int8_t *)MIPS_PHYS_TO_KSEG1(KN01_PHYS_COLMASK_START) = 0xff;
328 1.1.16.2 ad wbflush();
329 1.1.16.2 ad
330 1.1.16.1 ad vdac->overWA = 0x04; wbflush();
331 1.1.16.1 ad vdac->over = 0x00; wbflush();
332 1.1.16.1 ad vdac->over = 0x00; wbflush();
333 1.1.16.1 ad vdac->over = 0x00; wbflush();
334 1.1.16.1 ad vdac->overWA = 0x08; wbflush();
335 1.1.16.1 ad vdac->over = 0x00; wbflush();
336 1.1.16.1 ad vdac->over = 0x00; wbflush();
337 1.1.16.1 ad vdac->over = 0x7f; wbflush();
338 1.1.16.1 ad vdac->overWA = 0x0c; wbflush();
339 1.1.16.1 ad vdac->over = 0xff; wbflush();
340 1.1.16.1 ad vdac->over = 0xff; wbflush();
341 1.1.16.1 ad vdac->over = 0xff; wbflush();
342 1.1.16.1 ad
343 1.1.16.1 ad /*
344 1.1.16.1 ad * Set in the initial colormap.
345 1.1.16.1 ad */
346 1.1.16.1 ad if (ri->ri_depth == 8) {
347 1.1.16.1 ad vdac->mapWA = 0;
348 1.1.16.1 ad wbflush();
349 1.1.16.1 ad
350 1.1.16.1 ad for (i = 0; i < 256 * 3; i += 3) {
351 1.1.16.1 ad vdac->map = rasops_cmap[i];
352 1.1.16.1 ad wbflush();
353 1.1.16.1 ad vdac->map = rasops_cmap[i + 1];
354 1.1.16.1 ad wbflush();
355 1.1.16.1 ad vdac->map = rasops_cmap[i + 2];
356 1.1.16.1 ad wbflush();
357 1.1.16.1 ad }
358 1.1.16.1 ad } else {
359 1.1.16.1 ad vdac->mapWA = 0;
360 1.1.16.1 ad wbflush();
361 1.1.16.1 ad
362 1.1.16.2 ad for (i = 0; i < 256; i++) {
363 1.1.16.2 ad vdac->map = 0x00;
364 1.1.16.1 ad wbflush();
365 1.1.16.2 ad vdac->map = (i < 128 ? 0x00 : 0xff);
366 1.1.16.1 ad wbflush();
367 1.1.16.2 ad vdac->map = 0x00;
368 1.1.16.1 ad wbflush();
369 1.1.16.1 ad }
370 1.1.16.1 ad }
371 1.1.16.2 ad
372 1.1.16.1 ad /*
373 1.1.16.1 ad * Turn off the hardware cursor sprite for rcons text mode.
374 1.1.16.1 ad */
375 1.1.16.2 ad pcc->cmdr = PCC_FOPB | PCC_VBHI;
376 1.1.16.1 ad wbflush();
377 1.1.16.2 ad pm_creg = 0;
378 1.1.16.2 ad pm_cursor_off();
379 1.1.16.1 ad }
380 1.1.16.1 ad
381 1.1.16.1 ad void
382 1.1.16.2 ad pm_cursor_off(void)
383 1.1.16.1 ad {
384 1.1.16.1 ad PCCRegs *pcc;
385 1.1.16.1 ad VDACRegs *vdac;
386 1.1.16.1 ad int i;
387 1.1.16.1 ad
388 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
389 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
390 1.1.16.1 ad pcc->cmdr = (pm_creg &= ~(PCC_ENPA | PCC_ENPB));
391 1.1.16.1 ad wbflush();
392 1.1.16.1 ad
393 1.1.16.1 ad vdac->overWA = 0x0c;
394 1.1.16.1 ad wbflush();
395 1.1.16.1 ad
396 1.1.16.1 ad for (i = 0; i < 3; i++) {
397 1.1.16.1 ad vdac->over = 0;
398 1.1.16.1 ad wbflush();
399 1.1.16.1 ad }
400 1.1.16.1 ad }
401 1.1.16.1 ad
402 1.1.16.1 ad void
403 1.1.16.1 ad pm_cursor_on(struct pm_softc *sc)
404 1.1.16.1 ad {
405 1.1.16.1 ad PCCRegs *pcc;
406 1.1.16.1 ad
407 1.1.16.1 ad if (sc->sc_curenb) {
408 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
409 1.1.16.1 ad pcc->cmdr = (pm_creg |= (PCC_ENPA | PCC_ENPB));
410 1.1.16.1 ad wbflush();
411 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CURSOR_DOCMAP;
412 1.1.16.1 ad }
413 1.1.16.1 ad }
414 1.1.16.1 ad
415 1.1.16.1 ad int
416 1.1.16.1 ad pm_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
417 1.1.16.1 ad {
418 1.1.16.1 ad struct pm_softc *sc;
419 1.1.16.1 ad struct rasops_info *ri;
420 1.1.16.1 ad int turnoff, rv;
421 1.1.16.1 ad PCCRegs *pcc;
422 1.1.16.1 ad
423 1.1.16.1 ad sc = v;
424 1.1.16.1 ad ri = &pm_ri;
425 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
426 1.1.16.1 ad
427 1.1.16.1 ad switch (cmd) {
428 1.1.16.1 ad case WSDISPLAYIO_GTYPE:
429 1.1.16.1 ad *(u_int *)data = sc->sc_type;
430 1.1.16.1 ad rv = 0;
431 1.1.16.1 ad break;
432 1.1.16.1 ad
433 1.1.16.1 ad case WSDISPLAYIO_SMODE:
434 1.1.16.1 ad if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) {
435 1.1.16.2 ad pm_cursor_off();
436 1.1.16.1 ad pm_init_cmap(sc);
437 1.1.16.1 ad memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
438 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
439 1.1.16.1 ad }
440 1.1.16.1 ad rv = 0;
441 1.1.16.1 ad break;
442 1.1.16.1 ad
443 1.1.16.1 ad case WSDISPLAYIO_GINFO:
444 1.1.16.1 ad #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
445 1.1.16.1 ad wsd_fbip->height = ri->ri_height;
446 1.1.16.1 ad wsd_fbip->width = ri->ri_width;
447 1.1.16.1 ad wsd_fbip->depth = ri->ri_depth;
448 1.1.16.1 ad wsd_fbip->cmsize = sc->sc_cmap_size;
449 1.1.16.1 ad #undef fbt
450 1.1.16.1 ad rv = 0;
451 1.1.16.1 ad break;
452 1.1.16.1 ad
453 1.1.16.1 ad case WSDISPLAYIO_GETCMAP:
454 1.1.16.1 ad rv = pm_get_cmap(sc, (struct wsdisplay_cmap *)data);
455 1.1.16.1 ad break;
456 1.1.16.1 ad
457 1.1.16.1 ad case WSDISPLAYIO_PUTCMAP:
458 1.1.16.1 ad rv = pm_set_cmap(sc, (struct wsdisplay_cmap *)data);
459 1.1.16.1 ad break;
460 1.1.16.1 ad
461 1.1.16.1 ad case WSDISPLAYIO_SVIDEO:
462 1.1.16.1 ad turnoff = *(int *)data == WSDISPLAYIO_VIDEO_OFF;
463 1.1.16.1 ad if ((sc->sc_blanked == 0) ^ turnoff) {
464 1.1.16.1 ad sc->sc_blanked = turnoff;
465 1.1.16.1 ad if (turnoff == 1) {
466 1.1.16.1 ad pcc->cmdr =
467 1.1.16.1 ad (pm_creg &= ~(PCC_FOPA | PCC_FOPB));
468 1.1.16.1 ad pm_cursor_on(sc);
469 1.1.16.1 ad } else {
470 1.1.16.1 ad pcc->cmdr =
471 1.1.16.1 ad (pm_creg |= (PCC_FOPA | PCC_FOPB));
472 1.1.16.2 ad pm_cursor_off();
473 1.1.16.1 ad }
474 1.1.16.1 ad }
475 1.1.16.1 ad rv = 0;
476 1.1.16.1 ad break;
477 1.1.16.1 ad
478 1.1.16.1 ad case WSDISPLAYIO_GVIDEO:
479 1.1.16.1 ad *(u_int *)data = sc->sc_blanked ?
480 1.1.16.1 ad WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
481 1.1.16.1 ad rv = 0;
482 1.1.16.1 ad break;
483 1.1.16.1 ad
484 1.1.16.1 ad case WSDISPLAYIO_GCURPOS:
485 1.1.16.1 ad *(struct wsdisplay_curpos *)data = sc->sc_cursor.cc_pos;
486 1.1.16.1 ad rv = 0;
487 1.1.16.1 ad break;
488 1.1.16.1 ad
489 1.1.16.1 ad case WSDISPLAYIO_SCURPOS:
490 1.1.16.1 ad pm_set_curpos(sc, (struct wsdisplay_curpos *)data);
491 1.1.16.1 ad rv = 0;
492 1.1.16.1 ad break;
493 1.1.16.1 ad
494 1.1.16.1 ad case WSDISPLAYIO_GCURMAX:
495 1.1.16.1 ad ((struct wsdisplay_curpos *)data)->x =
496 1.1.16.1 ad ((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_SIZE;
497 1.1.16.1 ad rv = 0;
498 1.1.16.1 ad break;
499 1.1.16.1 ad
500 1.1.16.1 ad case WSDISPLAYIO_GCURSOR:
501 1.1.16.1 ad rv = pm_get_cursor(sc, (struct wsdisplay_cursor *)data);
502 1.1.16.1 ad break;
503 1.1.16.1 ad
504 1.1.16.1 ad case WSDISPLAYIO_SCURSOR:
505 1.1.16.1 ad rv = pm_set_cursor(sc, (struct wsdisplay_cursor *)data);
506 1.1.16.1 ad break;
507 1.1.16.1 ad
508 1.1.16.1 ad default:
509 1.1.16.1 ad rv = ENOTTY;
510 1.1.16.1 ad break;
511 1.1.16.1 ad }
512 1.1.16.1 ad
513 1.1.16.1 ad pm_flush(sc);
514 1.1.16.1 ad return (rv);
515 1.1.16.1 ad }
516 1.1.16.1 ad
517 1.1.16.1 ad paddr_t
518 1.1.16.1 ad pm_mmap(void *v, off_t offset, int prot)
519 1.1.16.1 ad {
520 1.1.16.1 ad struct pm_softc *sc;
521 1.1.16.1 ad
522 1.1.16.1 ad sc = v;
523 1.1.16.1 ad
524 1.1.16.1 ad if (offset >= sc->sc_fb_size || offset < 0)
525 1.1.16.1 ad return (-1);
526 1.1.16.1 ad
527 1.1.16.1 ad return (mips_btop((caddr_t)pm_ri.ri_bits + offset));
528 1.1.16.1 ad }
529 1.1.16.1 ad
530 1.1.16.1 ad int
531 1.1.16.1 ad pm_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
532 1.1.16.1 ad int *curxp, int *curyp, long *attrp)
533 1.1.16.1 ad {
534 1.1.16.1 ad struct pm_softc *sc;
535 1.1.16.1 ad struct rasops_info *ri;
536 1.1.16.1 ad long defattr;
537 1.1.16.1 ad
538 1.1.16.1 ad sc = v;
539 1.1.16.1 ad ri = &pm_ri;
540 1.1.16.1 ad
541 1.1.16.1 ad if (sc->sc_nscreens > 0)
542 1.1.16.1 ad return (ENOMEM);
543 1.1.16.1 ad
544 1.1.16.1 ad *cookiep = ri; /* one and only for now */
545 1.1.16.1 ad *curxp = 0;
546 1.1.16.1 ad *curyp = 0;
547 1.1.16.1 ad (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
548 1.1.16.1 ad *attrp = defattr;
549 1.1.16.1 ad sc->sc_nscreens++;
550 1.1.16.1 ad return (0);
551 1.1.16.1 ad }
552 1.1.16.1 ad
553 1.1.16.1 ad void
554 1.1.16.1 ad pm_free_screen(void *v, void *cookie)
555 1.1.16.1 ad {
556 1.1.16.1 ad
557 1.1.16.1 ad panic("pm_free_screen: console");
558 1.1.16.1 ad }
559 1.1.16.1 ad
560 1.1.16.1 ad int
561 1.1.16.1 ad pm_show_screen(void *v, void *cookie, int waitok,
562 1.1.16.1 ad void (*cb)(void *, int, int), void *cbarg)
563 1.1.16.1 ad {
564 1.1.16.1 ad
565 1.1.16.1 ad return (0);
566 1.1.16.1 ad }
567 1.1.16.1 ad
568 1.1.16.1 ad /* EXPORT */ int
569 1.1.16.1 ad pm_cnattach(void)
570 1.1.16.1 ad {
571 1.1.16.1 ad struct rasops_info *ri;
572 1.1.16.1 ad long defattr;
573 1.1.16.1 ad
574 1.1.16.2 ad ri = &pm_ri;
575 1.1.16.2 ad
576 1.1.16.1 ad printf("pm_cnattach: 0\n");
577 1.1.16.1 ad
578 1.1.16.2 ad pm_common_init();
579 1.1.16.1 ad
580 1.1.16.1 ad printf("pm_cnattach: 1\n");
581 1.1.16.1 ad
582 1.1.16.1 ad (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
583 1.1.16.1 ad
584 1.1.16.1 ad printf("pm_cnattach: 2\n");
585 1.1.16.1 ad
586 1.1.16.1 ad wsdisplay_cnattach(&pm_stdscreen, ri, 0, 0, defattr);
587 1.1.16.1 ad
588 1.1.16.1 ad printf("pm_cnattach: 3\n");
589 1.1.16.1 ad
590 1.1.16.2 ad return (1);
591 1.1.16.1 ad }
592 1.1.16.1 ad
593 1.1.16.1 ad int
594 1.1.16.1 ad pm_flush(struct pm_softc *sc)
595 1.1.16.1 ad {
596 1.1.16.1 ad VDACRegs *vdac;
597 1.1.16.1 ad PCCRegs *pcc;
598 1.1.16.1 ad u_int8_t *cp;
599 1.1.16.1 ad int v, i, x, y;
600 1.1.16.1 ad u_short *p, *pe;
601 1.1.16.1 ad struct hwcmap256 *cm;
602 1.1.16.1 ad struct rasops_info *ri;
603 1.1.16.1 ad
604 1.1.16.1 ad if (sc->sc_changed == 0)
605 1.1.16.1 ad return (1);
606 1.1.16.1 ad
607 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
608 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
609 1.1.16.1 ad ri = &pm_ri;
610 1.1.16.1 ad
611 1.1.16.1 ad if ((sc->sc_changed & WSDISPLAY_CURSOR_DOCUR) != 0) {
612 1.1.16.1 ad if (sc->sc_curenb)
613 1.1.16.1 ad pm_cursor_on(sc);
614 1.1.16.1 ad else
615 1.1.16.2 ad pm_cursor_off();
616 1.1.16.1 ad }
617 1.1.16.1 ad
618 1.1.16.1 ad /*
619 1.1.16.1 ad * sc_changed may be modified by pm_cursor_on().
620 1.1.16.1 ad */
621 1.1.16.1 ad v = sc->sc_changed;
622 1.1.16.1 ad
623 1.1.16.1 ad if ((v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) != 0) {
624 1.1.16.1 ad x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
625 1.1.16.1 ad y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
626 1.1.16.1 ad pcc->xpos = x + PCC_X_OFFSET;
627 1.1.16.1 ad pcc->ypos = y + PCC_Y_OFFSET;
628 1.1.16.1 ad wbflush();
629 1.1.16.1 ad }
630 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
631 1.1.16.1 ad cp = sc->sc_cursor.cc_color;
632 1.1.16.1 ad
633 1.1.16.1 ad vdac->overWA = 0x04;
634 1.1.16.1 ad wbflush();
635 1.1.16.1 ad for (i = 0; i < 6; i += 2) {
636 1.1.16.1 ad vdac->over = cp[i];
637 1.1.16.1 ad wbflush();
638 1.1.16.1 ad }
639 1.1.16.1 ad
640 1.1.16.1 ad vdac->overWA = 0x08;
641 1.1.16.1 ad wbflush();
642 1.1.16.1 ad vdac->over = 0x00;
643 1.1.16.1 ad wbflush();
644 1.1.16.1 ad vdac->over = 0x00;
645 1.1.16.1 ad wbflush();
646 1.1.16.1 ad vdac->over = 0x7f;
647 1.1.16.1 ad wbflush();
648 1.1.16.1 ad
649 1.1.16.1 ad vdac->overWA = 0x0c;
650 1.1.16.1 ad wbflush();
651 1.1.16.1 ad for (i = 1; i < 6; i += 2) {
652 1.1.16.1 ad vdac->over = cp[i];
653 1.1.16.1 ad wbflush();
654 1.1.16.1 ad }
655 1.1.16.1 ad }
656 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
657 1.1.16.1 ad pcc->cmdr = (pm_creg | PCC_LODSA);
658 1.1.16.1 ad wbflush();
659 1.1.16.1 ad
660 1.1.16.1 ad p = sc->sc_cursor.cc_image;
661 1.1.16.1 ad pe = p + 32;
662 1.1.16.1 ad while (p < pe) {
663 1.1.16.1 ad pcc->memory = *p++;
664 1.1.16.1 ad wbflush();
665 1.1.16.1 ad }
666 1.1.16.1 ad
667 1.1.16.1 ad pcc->cmdr = (pm_creg &= ~PCC_LODSA);
668 1.1.16.1 ad wbflush();
669 1.1.16.1 ad }
670 1.1.16.1 ad
671 1.1.16.1 ad if ((v & WSDISPLAY_CMAP_DOLUT) != 0) {
672 1.1.16.1 ad cm = &sc->sc_cmap;
673 1.1.16.1 ad
674 1.1.16.1 ad vdac->mapWA = 0;
675 1.1.16.1 ad wbflush();
676 1.1.16.1 ad
677 1.1.16.2 ad if (sc->sc_cmap_size == 2) {
678 1.1.16.2 ad for (i = 0; i < 128; i++) {
679 1.1.16.2 ad vdac->map = cm->r[0];
680 1.1.16.2 ad wbflush();
681 1.1.16.2 ad vdac->map = cm->g[0];
682 1.1.16.2 ad wbflush();
683 1.1.16.2 ad vdac->map = cm->b[0];
684 1.1.16.2 ad wbflush();
685 1.1.16.2 ad }
686 1.1.16.2 ad for (; i < 256; i++) {
687 1.1.16.2 ad vdac->map = cm->r[1];
688 1.1.16.2 ad wbflush();
689 1.1.16.2 ad vdac->map = cm->g[1];
690 1.1.16.2 ad wbflush();
691 1.1.16.2 ad vdac->map = cm->b[1];
692 1.1.16.2 ad wbflush();
693 1.1.16.2 ad }
694 1.1.16.2 ad } else {
695 1.1.16.2 ad for (i = 0; i < sc->sc_cmap_size; i++) {
696 1.1.16.2 ad vdac->map = cm->r[i];
697 1.1.16.2 ad wbflush();
698 1.1.16.2 ad vdac->map = cm->g[i];
699 1.1.16.2 ad wbflush();
700 1.1.16.2 ad vdac->map = cm->b[i];
701 1.1.16.2 ad wbflush();
702 1.1.16.2 ad }
703 1.1.16.1 ad }
704 1.1.16.1 ad }
705 1.1.16.1 ad
706 1.1.16.1 ad sc->sc_changed = 0;
707 1.1.16.1 ad return (1);
708 1.1.16.1 ad }
709 1.1.16.1 ad
710 1.1.16.1 ad int
711 1.1.16.1 ad pm_get_cmap(struct pm_softc *sc, struct wsdisplay_cmap *p)
712 1.1.16.1 ad {
713 1.1.16.1 ad u_int index, count;
714 1.1.16.1 ad
715 1.1.16.1 ad index = p->index;
716 1.1.16.1 ad count = p->count;
717 1.1.16.1 ad
718 1.1.16.1 ad if (index >= sc->sc_cmap_size || (index + count) > sc->sc_cmap_size)
719 1.1.16.1 ad return (EINVAL);
720 1.1.16.1 ad
721 1.1.16.1 ad if (!uvm_useracc(p->red, count, B_WRITE) ||
722 1.1.16.1 ad !uvm_useracc(p->green, count, B_WRITE) ||
723 1.1.16.1 ad !uvm_useracc(p->blue, count, B_WRITE))
724 1.1.16.1 ad return (EFAULT);
725 1.1.16.1 ad
726 1.1.16.1 ad copyout(&sc->sc_cmap.r[index], p->red, count);
727 1.1.16.1 ad copyout(&sc->sc_cmap.g[index], p->green, count);
728 1.1.16.1 ad copyout(&sc->sc_cmap.b[index], p->blue, count);
729 1.1.16.1 ad
730 1.1.16.1 ad return (0);
731 1.1.16.1 ad }
732 1.1.16.1 ad
733 1.1.16.1 ad int
734 1.1.16.1 ad pm_set_cmap(struct pm_softc *sc, struct wsdisplay_cmap *p)
735 1.1.16.1 ad {
736 1.1.16.1 ad u_int index, count;
737 1.1.16.1 ad
738 1.1.16.1 ad index = p->index;
739 1.1.16.1 ad count = p->count;
740 1.1.16.1 ad
741 1.1.16.1 ad if (index >= sc->sc_cmap_size || (index + count) > sc->sc_cmap_size)
742 1.1.16.1 ad return (EINVAL);
743 1.1.16.1 ad
744 1.1.16.1 ad if (!uvm_useracc(p->red, count, B_READ) ||
745 1.1.16.1 ad !uvm_useracc(p->green, count, B_READ) ||
746 1.1.16.1 ad !uvm_useracc(p->blue, count, B_READ))
747 1.1.16.1 ad return (EFAULT);
748 1.1.16.1 ad
749 1.1.16.1 ad copyin(p->red, &sc->sc_cmap.r[index], count);
750 1.1.16.1 ad copyin(p->green, &sc->sc_cmap.g[index], count);
751 1.1.16.1 ad copyin(p->blue, &sc->sc_cmap.b[index], count);
752 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
753 1.1.16.1 ad return (0);
754 1.1.16.1 ad }
755 1.1.16.1 ad
756 1.1.16.1 ad int
757 1.1.16.1 ad pm_set_cursor(struct pm_softc *sc, struct wsdisplay_cursor *p)
758 1.1.16.1 ad {
759 1.1.16.1 ad #define cc (&sc->sc_cursor)
760 1.1.16.1 ad u_int v, index, count;
761 1.1.16.1 ad
762 1.1.16.1 ad v = p->which;
763 1.1.16.1 ad
764 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
765 1.1.16.1 ad index = p->cmap.index;
766 1.1.16.1 ad count = p->cmap.count;
767 1.1.16.1 ad if (index >= 2 || (index + count) > 2)
768 1.1.16.1 ad return (EINVAL);
769 1.1.16.1 ad if (!uvm_useracc(p->cmap.red, count, B_READ) ||
770 1.1.16.1 ad !uvm_useracc(p->cmap.green, count, B_READ) ||
771 1.1.16.1 ad !uvm_useracc(p->cmap.blue, count, B_READ))
772 1.1.16.1 ad return (EFAULT);
773 1.1.16.1 ad }
774 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
775 1.1.16.1 ad if (p->size.x > CURSOR_MAX_SIZE ||
776 1.1.16.1 ad p->size.y > CURSOR_MAX_SIZE ||
777 1.1.16.1 ad p->size.x < 9)
778 1.1.16.1 ad return (EINVAL);
779 1.1.16.1 ad if (!uvm_useracc(p->image, p->size.y * 2, B_READ) ||
780 1.1.16.1 ad !uvm_useracc(p->mask, p->size.y * 2, B_READ))
781 1.1.16.1 ad return (EFAULT);
782 1.1.16.1 ad }
783 1.1.16.1 ad
784 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCUR) != 0)
785 1.1.16.1 ad sc->sc_curenb = p->enable;
786 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOPOS) != 0)
787 1.1.16.1 ad pm_set_curpos(sc, &p->pos);
788 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOHOT) != 0)
789 1.1.16.1 ad cc->cc_hot = p->hot;
790 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
791 1.1.16.1 ad copyin(p->cmap.red, &cc->cc_color[index], count);
792 1.1.16.1 ad copyin(p->cmap.green, &cc->cc_color[index + 2], count);
793 1.1.16.1 ad copyin(p->cmap.blue, &cc->cc_color[index + 4], count);
794 1.1.16.1 ad }
795 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
796 1.1.16.1 ad cc->cc_size = p->size;
797 1.1.16.1 ad memset(cc->cc_image, 0, sizeof(cc->cc_image));
798 1.1.16.1 ad copyin(p->image, cc->cc_image, p->size.y * 2);
799 1.1.16.1 ad copyin(p->mask, cc->cc_image+CURSOR_MAX_SIZE, p->size.y * 2);
800 1.1.16.1 ad }
801 1.1.16.1 ad sc->sc_changed |= v;
802 1.1.16.1 ad
803 1.1.16.1 ad return (0);
804 1.1.16.1 ad #undef cc
805 1.1.16.1 ad }
806 1.1.16.1 ad
807 1.1.16.1 ad int
808 1.1.16.1 ad pm_get_cursor(struct pm_softc *sc, struct wsdisplay_cursor *p)
809 1.1.16.1 ad {
810 1.1.16.1 ad
811 1.1.16.1 ad return (ENOTTY); /* XXX */
812 1.1.16.1 ad }
813 1.1.16.1 ad
814 1.1.16.1 ad void
815 1.1.16.1 ad pm_set_curpos(struct pm_softc *sc, struct wsdisplay_curpos *curpos)
816 1.1.16.1 ad {
817 1.1.16.1 ad struct rasops_info *ri;
818 1.1.16.1 ad int x, y;
819 1.1.16.1 ad
820 1.1.16.1 ad ri = &pm_ri;
821 1.1.16.1 ad x = curpos->x;
822 1.1.16.1 ad y = curpos->y;
823 1.1.16.1 ad
824 1.1.16.1 ad if (y < 0)
825 1.1.16.1 ad y = 0;
826 1.1.16.1 ad else if (y > ri->ri_height)
827 1.1.16.1 ad y = ri->ri_height;
828 1.1.16.1 ad if (x < 0)
829 1.1.16.1 ad x = 0;
830 1.1.16.1 ad else if (x > ri->ri_width)
831 1.1.16.1 ad x = ri->ri_width;
832 1.1.16.1 ad sc->sc_cursor.cc_pos.x = x;
833 1.1.16.1 ad sc->sc_cursor.cc_pos.y = y;
834 1.1.16.1 ad }
835