pm.c revision 1.1.16.3 1 1.1.16.3 ad /* $NetBSD: pm.c,v 1.1.16.3 2002/03/25 19:26:20 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.3 ad __KERNEL_RCSID(0, "$NetBSD: pm.c,v 1.1.16.3 2002/03/25 19:26:20 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 memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
289 1.1.16.1 ad
290 1.1.16.1 ad /*
291 1.1.16.1 ad * Get a font to use.
292 1.1.16.1 ad */
293 1.1.16.1 ad bior = (ri->ri_depth == 8 ? WSDISPLAY_FONTORDER_L2R :
294 1.1.16.1 ad WSDISPLAY_FONTORDER_R2L);
295 1.1.16.1 ad
296 1.1.16.1 ad wsfont_init();
297 1.1.16.1 ad cookie = wsfont_find(NULL, 8, 0, 0, bior, WSDISPLAY_FONTORDER_L2R);
298 1.1.16.1 ad if (cookie <= 0)
299 1.1.16.1 ad cookie = wsfont_find(NULL, 0, 0, 0, bior,
300 1.1.16.1 ad WSDISPLAY_FONTORDER_L2R);
301 1.1.16.1 ad if (cookie <= 0) {
302 1.1.16.1 ad printf("pm: font table is empty\n");
303 1.1.16.1 ad return;
304 1.1.16.1 ad }
305 1.1.16.1 ad
306 1.1.16.1 ad if (wsfont_lock(cookie, &ri->ri_font)) {
307 1.1.16.1 ad printf("pm: couldn't lock font\n");
308 1.1.16.1 ad return;
309 1.1.16.1 ad }
310 1.1.16.1 ad ri->ri_wsfcookie = cookie;
311 1.1.16.1 ad
312 1.1.16.1 ad /*
313 1.1.16.1 ad * Set up the raster operations set.
314 1.1.16.1 ad */
315 1.1.16.3 ad rasops_init(ri, 1000, 1000);
316 1.1.16.1 ad
317 1.1.16.1 ad pm_stdscreen.nrows = ri->ri_rows;
318 1.1.16.1 ad pm_stdscreen.ncols = ri->ri_cols;
319 1.1.16.1 ad pm_stdscreen.textops = &ri->ri_ops;
320 1.1.16.1 ad pm_stdscreen.capabilities = ri->ri_caps;
321 1.1.16.1 ad
322 1.1.16.1 ad /*
323 1.1.16.1 ad * Initalize the VDAC.
324 1.1.16.1 ad */
325 1.1.16.2 ad *(u_int8_t *)MIPS_PHYS_TO_KSEG1(KN01_PHYS_COLMASK_START) = 0xff;
326 1.1.16.2 ad wbflush();
327 1.1.16.2 ad
328 1.1.16.1 ad vdac->overWA = 0x04; wbflush();
329 1.1.16.1 ad vdac->over = 0x00; wbflush();
330 1.1.16.1 ad vdac->over = 0x00; wbflush();
331 1.1.16.1 ad vdac->over = 0x00; wbflush();
332 1.1.16.1 ad vdac->overWA = 0x08; wbflush();
333 1.1.16.1 ad vdac->over = 0x00; wbflush();
334 1.1.16.1 ad vdac->over = 0x00; wbflush();
335 1.1.16.1 ad vdac->over = 0x7f; wbflush();
336 1.1.16.1 ad vdac->overWA = 0x0c; wbflush();
337 1.1.16.1 ad vdac->over = 0xff; wbflush();
338 1.1.16.1 ad vdac->over = 0xff; wbflush();
339 1.1.16.1 ad vdac->over = 0xff; wbflush();
340 1.1.16.1 ad
341 1.1.16.1 ad /*
342 1.1.16.1 ad * Set in the initial colormap.
343 1.1.16.1 ad */
344 1.1.16.1 ad if (ri->ri_depth == 8) {
345 1.1.16.1 ad vdac->mapWA = 0;
346 1.1.16.1 ad wbflush();
347 1.1.16.1 ad
348 1.1.16.1 ad for (i = 0; i < 256 * 3; i += 3) {
349 1.1.16.1 ad vdac->map = rasops_cmap[i];
350 1.1.16.1 ad wbflush();
351 1.1.16.1 ad vdac->map = rasops_cmap[i + 1];
352 1.1.16.1 ad wbflush();
353 1.1.16.1 ad vdac->map = rasops_cmap[i + 2];
354 1.1.16.1 ad wbflush();
355 1.1.16.1 ad }
356 1.1.16.1 ad } else {
357 1.1.16.1 ad vdac->mapWA = 0;
358 1.1.16.1 ad wbflush();
359 1.1.16.1 ad
360 1.1.16.2 ad for (i = 0; i < 256; i++) {
361 1.1.16.2 ad vdac->map = 0x00;
362 1.1.16.1 ad wbflush();
363 1.1.16.2 ad vdac->map = (i < 128 ? 0x00 : 0xff);
364 1.1.16.1 ad wbflush();
365 1.1.16.2 ad vdac->map = 0x00;
366 1.1.16.1 ad wbflush();
367 1.1.16.1 ad }
368 1.1.16.1 ad }
369 1.1.16.2 ad
370 1.1.16.1 ad /*
371 1.1.16.1 ad * Turn off the hardware cursor sprite for rcons text mode.
372 1.1.16.1 ad */
373 1.1.16.2 ad pcc->cmdr = PCC_FOPB | PCC_VBHI;
374 1.1.16.1 ad wbflush();
375 1.1.16.2 ad pm_creg = 0;
376 1.1.16.2 ad pm_cursor_off();
377 1.1.16.1 ad }
378 1.1.16.1 ad
379 1.1.16.1 ad void
380 1.1.16.2 ad pm_cursor_off(void)
381 1.1.16.1 ad {
382 1.1.16.1 ad PCCRegs *pcc;
383 1.1.16.1 ad VDACRegs *vdac;
384 1.1.16.1 ad int i;
385 1.1.16.1 ad
386 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
387 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
388 1.1.16.1 ad pcc->cmdr = (pm_creg &= ~(PCC_ENPA | PCC_ENPB));
389 1.1.16.1 ad wbflush();
390 1.1.16.1 ad
391 1.1.16.1 ad vdac->overWA = 0x0c;
392 1.1.16.1 ad wbflush();
393 1.1.16.1 ad
394 1.1.16.1 ad for (i = 0; i < 3; i++) {
395 1.1.16.1 ad vdac->over = 0;
396 1.1.16.1 ad wbflush();
397 1.1.16.1 ad }
398 1.1.16.1 ad }
399 1.1.16.1 ad
400 1.1.16.1 ad void
401 1.1.16.1 ad pm_cursor_on(struct pm_softc *sc)
402 1.1.16.1 ad {
403 1.1.16.1 ad PCCRegs *pcc;
404 1.1.16.1 ad
405 1.1.16.1 ad if (sc->sc_curenb) {
406 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
407 1.1.16.1 ad pcc->cmdr = (pm_creg |= (PCC_ENPA | PCC_ENPB));
408 1.1.16.1 ad wbflush();
409 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CURSOR_DOCMAP;
410 1.1.16.1 ad }
411 1.1.16.1 ad }
412 1.1.16.1 ad
413 1.1.16.1 ad int
414 1.1.16.1 ad pm_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
415 1.1.16.1 ad {
416 1.1.16.1 ad struct pm_softc *sc;
417 1.1.16.1 ad struct rasops_info *ri;
418 1.1.16.1 ad int turnoff, rv;
419 1.1.16.1 ad PCCRegs *pcc;
420 1.1.16.1 ad
421 1.1.16.1 ad sc = v;
422 1.1.16.1 ad ri = &pm_ri;
423 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
424 1.1.16.1 ad
425 1.1.16.1 ad switch (cmd) {
426 1.1.16.1 ad case WSDISPLAYIO_GTYPE:
427 1.1.16.1 ad *(u_int *)data = sc->sc_type;
428 1.1.16.1 ad rv = 0;
429 1.1.16.1 ad break;
430 1.1.16.1 ad
431 1.1.16.1 ad case WSDISPLAYIO_SMODE:
432 1.1.16.1 ad if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) {
433 1.1.16.2 ad pm_cursor_off();
434 1.1.16.1 ad pm_init_cmap(sc);
435 1.1.16.1 ad memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
436 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
437 1.1.16.1 ad }
438 1.1.16.1 ad rv = 0;
439 1.1.16.1 ad break;
440 1.1.16.1 ad
441 1.1.16.1 ad case WSDISPLAYIO_GINFO:
442 1.1.16.1 ad #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
443 1.1.16.1 ad wsd_fbip->height = ri->ri_height;
444 1.1.16.1 ad wsd_fbip->width = ri->ri_width;
445 1.1.16.1 ad wsd_fbip->depth = ri->ri_depth;
446 1.1.16.1 ad wsd_fbip->cmsize = sc->sc_cmap_size;
447 1.1.16.1 ad #undef fbt
448 1.1.16.1 ad rv = 0;
449 1.1.16.1 ad break;
450 1.1.16.1 ad
451 1.1.16.1 ad case WSDISPLAYIO_GETCMAP:
452 1.1.16.1 ad rv = pm_get_cmap(sc, (struct wsdisplay_cmap *)data);
453 1.1.16.1 ad break;
454 1.1.16.1 ad
455 1.1.16.1 ad case WSDISPLAYIO_PUTCMAP:
456 1.1.16.1 ad rv = pm_set_cmap(sc, (struct wsdisplay_cmap *)data);
457 1.1.16.1 ad break;
458 1.1.16.1 ad
459 1.1.16.1 ad case WSDISPLAYIO_SVIDEO:
460 1.1.16.1 ad turnoff = *(int *)data == WSDISPLAYIO_VIDEO_OFF;
461 1.1.16.1 ad if ((sc->sc_blanked == 0) ^ turnoff) {
462 1.1.16.1 ad sc->sc_blanked = turnoff;
463 1.1.16.1 ad if (turnoff == 1) {
464 1.1.16.1 ad pcc->cmdr =
465 1.1.16.1 ad (pm_creg &= ~(PCC_FOPA | PCC_FOPB));
466 1.1.16.1 ad pm_cursor_on(sc);
467 1.1.16.1 ad } else {
468 1.1.16.1 ad pcc->cmdr =
469 1.1.16.1 ad (pm_creg |= (PCC_FOPA | PCC_FOPB));
470 1.1.16.2 ad pm_cursor_off();
471 1.1.16.1 ad }
472 1.1.16.1 ad }
473 1.1.16.1 ad rv = 0;
474 1.1.16.1 ad break;
475 1.1.16.1 ad
476 1.1.16.1 ad case WSDISPLAYIO_GVIDEO:
477 1.1.16.1 ad *(u_int *)data = sc->sc_blanked ?
478 1.1.16.1 ad WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
479 1.1.16.1 ad rv = 0;
480 1.1.16.1 ad break;
481 1.1.16.1 ad
482 1.1.16.1 ad case WSDISPLAYIO_GCURPOS:
483 1.1.16.1 ad *(struct wsdisplay_curpos *)data = sc->sc_cursor.cc_pos;
484 1.1.16.1 ad rv = 0;
485 1.1.16.1 ad break;
486 1.1.16.1 ad
487 1.1.16.1 ad case WSDISPLAYIO_SCURPOS:
488 1.1.16.1 ad pm_set_curpos(sc, (struct wsdisplay_curpos *)data);
489 1.1.16.1 ad rv = 0;
490 1.1.16.1 ad break;
491 1.1.16.1 ad
492 1.1.16.1 ad case WSDISPLAYIO_GCURMAX:
493 1.1.16.1 ad ((struct wsdisplay_curpos *)data)->x =
494 1.1.16.1 ad ((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_SIZE;
495 1.1.16.1 ad rv = 0;
496 1.1.16.1 ad break;
497 1.1.16.1 ad
498 1.1.16.1 ad case WSDISPLAYIO_GCURSOR:
499 1.1.16.1 ad rv = pm_get_cursor(sc, (struct wsdisplay_cursor *)data);
500 1.1.16.1 ad break;
501 1.1.16.1 ad
502 1.1.16.1 ad case WSDISPLAYIO_SCURSOR:
503 1.1.16.1 ad rv = pm_set_cursor(sc, (struct wsdisplay_cursor *)data);
504 1.1.16.1 ad break;
505 1.1.16.1 ad
506 1.1.16.1 ad default:
507 1.1.16.1 ad rv = ENOTTY;
508 1.1.16.1 ad break;
509 1.1.16.1 ad }
510 1.1.16.1 ad
511 1.1.16.1 ad pm_flush(sc);
512 1.1.16.1 ad return (rv);
513 1.1.16.1 ad }
514 1.1.16.1 ad
515 1.1.16.1 ad paddr_t
516 1.1.16.1 ad pm_mmap(void *v, off_t offset, int prot)
517 1.1.16.1 ad {
518 1.1.16.1 ad struct pm_softc *sc;
519 1.1.16.1 ad
520 1.1.16.1 ad sc = v;
521 1.1.16.1 ad
522 1.1.16.1 ad if (offset >= sc->sc_fb_size || offset < 0)
523 1.1.16.1 ad return (-1);
524 1.1.16.1 ad
525 1.1.16.1 ad return (mips_btop((caddr_t)pm_ri.ri_bits + offset));
526 1.1.16.1 ad }
527 1.1.16.1 ad
528 1.1.16.1 ad int
529 1.1.16.1 ad pm_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
530 1.1.16.1 ad int *curxp, int *curyp, long *attrp)
531 1.1.16.1 ad {
532 1.1.16.1 ad struct pm_softc *sc;
533 1.1.16.1 ad struct rasops_info *ri;
534 1.1.16.1 ad long defattr;
535 1.1.16.1 ad
536 1.1.16.1 ad sc = v;
537 1.1.16.1 ad ri = &pm_ri;
538 1.1.16.1 ad
539 1.1.16.1 ad if (sc->sc_nscreens > 0)
540 1.1.16.1 ad return (ENOMEM);
541 1.1.16.1 ad
542 1.1.16.1 ad *cookiep = ri; /* one and only for now */
543 1.1.16.1 ad *curxp = 0;
544 1.1.16.1 ad *curyp = 0;
545 1.1.16.1 ad (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
546 1.1.16.1 ad *attrp = defattr;
547 1.1.16.1 ad sc->sc_nscreens++;
548 1.1.16.1 ad return (0);
549 1.1.16.1 ad }
550 1.1.16.1 ad
551 1.1.16.1 ad void
552 1.1.16.1 ad pm_free_screen(void *v, void *cookie)
553 1.1.16.1 ad {
554 1.1.16.1 ad
555 1.1.16.1 ad panic("pm_free_screen: console");
556 1.1.16.1 ad }
557 1.1.16.1 ad
558 1.1.16.1 ad int
559 1.1.16.1 ad pm_show_screen(void *v, void *cookie, int waitok,
560 1.1.16.1 ad void (*cb)(void *, int, int), void *cbarg)
561 1.1.16.1 ad {
562 1.1.16.1 ad
563 1.1.16.1 ad return (0);
564 1.1.16.1 ad }
565 1.1.16.1 ad
566 1.1.16.1 ad /* EXPORT */ int
567 1.1.16.1 ad pm_cnattach(void)
568 1.1.16.1 ad {
569 1.1.16.1 ad struct rasops_info *ri;
570 1.1.16.1 ad long defattr;
571 1.1.16.1 ad
572 1.1.16.2 ad ri = &pm_ri;
573 1.1.16.2 ad
574 1.1.16.1 ad printf("pm_cnattach: 0\n");
575 1.1.16.1 ad
576 1.1.16.2 ad pm_common_init();
577 1.1.16.1 ad
578 1.1.16.1 ad printf("pm_cnattach: 1\n");
579 1.1.16.1 ad
580 1.1.16.1 ad (*ri->ri_ops.alloc_attr)(ri, 0, 0, 0, &defattr);
581 1.1.16.1 ad
582 1.1.16.1 ad printf("pm_cnattach: 2\n");
583 1.1.16.1 ad
584 1.1.16.1 ad wsdisplay_cnattach(&pm_stdscreen, ri, 0, 0, defattr);
585 1.1.16.1 ad
586 1.1.16.1 ad printf("pm_cnattach: 3\n");
587 1.1.16.1 ad
588 1.1.16.2 ad return (1);
589 1.1.16.1 ad }
590 1.1.16.1 ad
591 1.1.16.1 ad int
592 1.1.16.1 ad pm_flush(struct pm_softc *sc)
593 1.1.16.1 ad {
594 1.1.16.1 ad VDACRegs *vdac;
595 1.1.16.1 ad PCCRegs *pcc;
596 1.1.16.1 ad u_int8_t *cp;
597 1.1.16.1 ad int v, i, x, y;
598 1.1.16.1 ad u_short *p, *pe;
599 1.1.16.1 ad struct hwcmap256 *cm;
600 1.1.16.1 ad struct rasops_info *ri;
601 1.1.16.1 ad
602 1.1.16.1 ad if (sc->sc_changed == 0)
603 1.1.16.1 ad return (1);
604 1.1.16.1 ad
605 1.1.16.1 ad vdac = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_VDAC);
606 1.1.16.1 ad pcc = (void *)MIPS_PHYS_TO_KSEG1(KN01_SYS_PCC);
607 1.1.16.1 ad ri = &pm_ri;
608 1.1.16.1 ad
609 1.1.16.1 ad if ((sc->sc_changed & WSDISPLAY_CURSOR_DOCUR) != 0) {
610 1.1.16.1 ad if (sc->sc_curenb)
611 1.1.16.1 ad pm_cursor_on(sc);
612 1.1.16.1 ad else
613 1.1.16.2 ad pm_cursor_off();
614 1.1.16.1 ad }
615 1.1.16.1 ad
616 1.1.16.1 ad /*
617 1.1.16.1 ad * sc_changed may be modified by pm_cursor_on().
618 1.1.16.1 ad */
619 1.1.16.1 ad v = sc->sc_changed;
620 1.1.16.1 ad
621 1.1.16.1 ad if ((v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) != 0) {
622 1.1.16.1 ad x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
623 1.1.16.1 ad y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
624 1.1.16.1 ad pcc->xpos = x + PCC_X_OFFSET;
625 1.1.16.1 ad pcc->ypos = y + PCC_Y_OFFSET;
626 1.1.16.1 ad wbflush();
627 1.1.16.1 ad }
628 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
629 1.1.16.1 ad cp = sc->sc_cursor.cc_color;
630 1.1.16.1 ad
631 1.1.16.1 ad vdac->overWA = 0x04;
632 1.1.16.1 ad wbflush();
633 1.1.16.1 ad for (i = 0; i < 6; i += 2) {
634 1.1.16.1 ad vdac->over = cp[i];
635 1.1.16.1 ad wbflush();
636 1.1.16.1 ad }
637 1.1.16.1 ad
638 1.1.16.1 ad vdac->overWA = 0x08;
639 1.1.16.1 ad wbflush();
640 1.1.16.1 ad vdac->over = 0x00;
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 = 0x7f;
645 1.1.16.1 ad wbflush();
646 1.1.16.1 ad
647 1.1.16.1 ad vdac->overWA = 0x0c;
648 1.1.16.1 ad wbflush();
649 1.1.16.1 ad for (i = 1; i < 6; i += 2) {
650 1.1.16.1 ad vdac->over = cp[i];
651 1.1.16.1 ad wbflush();
652 1.1.16.1 ad }
653 1.1.16.1 ad }
654 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
655 1.1.16.1 ad pcc->cmdr = (pm_creg | PCC_LODSA);
656 1.1.16.1 ad wbflush();
657 1.1.16.1 ad
658 1.1.16.1 ad p = sc->sc_cursor.cc_image;
659 1.1.16.1 ad pe = p + 32;
660 1.1.16.1 ad while (p < pe) {
661 1.1.16.1 ad pcc->memory = *p++;
662 1.1.16.1 ad wbflush();
663 1.1.16.1 ad }
664 1.1.16.1 ad
665 1.1.16.1 ad pcc->cmdr = (pm_creg &= ~PCC_LODSA);
666 1.1.16.1 ad wbflush();
667 1.1.16.1 ad }
668 1.1.16.1 ad
669 1.1.16.1 ad if ((v & WSDISPLAY_CMAP_DOLUT) != 0) {
670 1.1.16.1 ad cm = &sc->sc_cmap;
671 1.1.16.1 ad
672 1.1.16.1 ad vdac->mapWA = 0;
673 1.1.16.1 ad wbflush();
674 1.1.16.1 ad
675 1.1.16.2 ad if (sc->sc_cmap_size == 2) {
676 1.1.16.2 ad for (i = 0; i < 128; i++) {
677 1.1.16.2 ad vdac->map = cm->r[0];
678 1.1.16.2 ad wbflush();
679 1.1.16.2 ad vdac->map = cm->g[0];
680 1.1.16.2 ad wbflush();
681 1.1.16.2 ad vdac->map = cm->b[0];
682 1.1.16.2 ad wbflush();
683 1.1.16.2 ad }
684 1.1.16.2 ad for (; i < 256; i++) {
685 1.1.16.2 ad vdac->map = cm->r[1];
686 1.1.16.2 ad wbflush();
687 1.1.16.2 ad vdac->map = cm->g[1];
688 1.1.16.2 ad wbflush();
689 1.1.16.2 ad vdac->map = cm->b[1];
690 1.1.16.2 ad wbflush();
691 1.1.16.2 ad }
692 1.1.16.2 ad } else {
693 1.1.16.2 ad for (i = 0; i < sc->sc_cmap_size; i++) {
694 1.1.16.2 ad vdac->map = cm->r[i];
695 1.1.16.2 ad wbflush();
696 1.1.16.2 ad vdac->map = cm->g[i];
697 1.1.16.2 ad wbflush();
698 1.1.16.2 ad vdac->map = cm->b[i];
699 1.1.16.2 ad wbflush();
700 1.1.16.2 ad }
701 1.1.16.1 ad }
702 1.1.16.1 ad }
703 1.1.16.1 ad
704 1.1.16.1 ad sc->sc_changed = 0;
705 1.1.16.1 ad return (1);
706 1.1.16.1 ad }
707 1.1.16.1 ad
708 1.1.16.1 ad int
709 1.1.16.1 ad pm_get_cmap(struct pm_softc *sc, struct wsdisplay_cmap *p)
710 1.1.16.1 ad {
711 1.1.16.1 ad u_int index, count;
712 1.1.16.1 ad
713 1.1.16.1 ad index = p->index;
714 1.1.16.1 ad count = p->count;
715 1.1.16.1 ad
716 1.1.16.1 ad if (index >= sc->sc_cmap_size || (index + count) > sc->sc_cmap_size)
717 1.1.16.1 ad return (EINVAL);
718 1.1.16.1 ad
719 1.1.16.1 ad if (!uvm_useracc(p->red, count, B_WRITE) ||
720 1.1.16.1 ad !uvm_useracc(p->green, count, B_WRITE) ||
721 1.1.16.1 ad !uvm_useracc(p->blue, count, B_WRITE))
722 1.1.16.1 ad return (EFAULT);
723 1.1.16.1 ad
724 1.1.16.1 ad copyout(&sc->sc_cmap.r[index], p->red, count);
725 1.1.16.1 ad copyout(&sc->sc_cmap.g[index], p->green, count);
726 1.1.16.1 ad copyout(&sc->sc_cmap.b[index], p->blue, count);
727 1.1.16.1 ad
728 1.1.16.1 ad return (0);
729 1.1.16.1 ad }
730 1.1.16.1 ad
731 1.1.16.1 ad int
732 1.1.16.1 ad pm_set_cmap(struct pm_softc *sc, struct wsdisplay_cmap *p)
733 1.1.16.1 ad {
734 1.1.16.1 ad u_int index, count;
735 1.1.16.1 ad
736 1.1.16.1 ad index = p->index;
737 1.1.16.1 ad count = p->count;
738 1.1.16.1 ad
739 1.1.16.1 ad if (index >= sc->sc_cmap_size || (index + count) > sc->sc_cmap_size)
740 1.1.16.1 ad return (EINVAL);
741 1.1.16.1 ad
742 1.1.16.1 ad if (!uvm_useracc(p->red, count, B_READ) ||
743 1.1.16.1 ad !uvm_useracc(p->green, count, B_READ) ||
744 1.1.16.1 ad !uvm_useracc(p->blue, count, B_READ))
745 1.1.16.1 ad return (EFAULT);
746 1.1.16.1 ad
747 1.1.16.1 ad copyin(p->red, &sc->sc_cmap.r[index], count);
748 1.1.16.1 ad copyin(p->green, &sc->sc_cmap.g[index], count);
749 1.1.16.1 ad copyin(p->blue, &sc->sc_cmap.b[index], count);
750 1.1.16.1 ad sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
751 1.1.16.1 ad return (0);
752 1.1.16.1 ad }
753 1.1.16.1 ad
754 1.1.16.1 ad int
755 1.1.16.1 ad pm_set_cursor(struct pm_softc *sc, struct wsdisplay_cursor *p)
756 1.1.16.1 ad {
757 1.1.16.1 ad #define cc (&sc->sc_cursor)
758 1.1.16.1 ad u_int v, index, count;
759 1.1.16.1 ad
760 1.1.16.1 ad v = p->which;
761 1.1.16.1 ad
762 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
763 1.1.16.1 ad index = p->cmap.index;
764 1.1.16.1 ad count = p->cmap.count;
765 1.1.16.1 ad if (index >= 2 || (index + count) > 2)
766 1.1.16.1 ad return (EINVAL);
767 1.1.16.1 ad if (!uvm_useracc(p->cmap.red, count, B_READ) ||
768 1.1.16.1 ad !uvm_useracc(p->cmap.green, count, B_READ) ||
769 1.1.16.1 ad !uvm_useracc(p->cmap.blue, count, B_READ))
770 1.1.16.1 ad return (EFAULT);
771 1.1.16.1 ad }
772 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
773 1.1.16.1 ad if (p->size.x > CURSOR_MAX_SIZE ||
774 1.1.16.1 ad p->size.y > CURSOR_MAX_SIZE ||
775 1.1.16.1 ad p->size.x < 9)
776 1.1.16.1 ad return (EINVAL);
777 1.1.16.1 ad if (!uvm_useracc(p->image, p->size.y * 2, B_READ) ||
778 1.1.16.1 ad !uvm_useracc(p->mask, p->size.y * 2, B_READ))
779 1.1.16.1 ad return (EFAULT);
780 1.1.16.1 ad }
781 1.1.16.1 ad
782 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCUR) != 0)
783 1.1.16.1 ad sc->sc_curenb = p->enable;
784 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOPOS) != 0)
785 1.1.16.1 ad pm_set_curpos(sc, &p->pos);
786 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOHOT) != 0)
787 1.1.16.1 ad cc->cc_hot = p->hot;
788 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOCMAP) != 0) {
789 1.1.16.1 ad copyin(p->cmap.red, &cc->cc_color[index], count);
790 1.1.16.1 ad copyin(p->cmap.green, &cc->cc_color[index + 2], count);
791 1.1.16.1 ad copyin(p->cmap.blue, &cc->cc_color[index + 4], count);
792 1.1.16.1 ad }
793 1.1.16.1 ad if ((v & WSDISPLAY_CURSOR_DOSHAPE) != 0) {
794 1.1.16.1 ad cc->cc_size = p->size;
795 1.1.16.1 ad memset(cc->cc_image, 0, sizeof(cc->cc_image));
796 1.1.16.1 ad copyin(p->image, cc->cc_image, p->size.y * 2);
797 1.1.16.1 ad copyin(p->mask, cc->cc_image+CURSOR_MAX_SIZE, p->size.y * 2);
798 1.1.16.1 ad }
799 1.1.16.1 ad sc->sc_changed |= v;
800 1.1.16.1 ad
801 1.1.16.1 ad return (0);
802 1.1.16.1 ad #undef cc
803 1.1.16.1 ad }
804 1.1.16.1 ad
805 1.1.16.1 ad int
806 1.1.16.1 ad pm_get_cursor(struct pm_softc *sc, struct wsdisplay_cursor *p)
807 1.1.16.1 ad {
808 1.1.16.1 ad
809 1.1.16.1 ad return (ENOTTY); /* XXX */
810 1.1.16.1 ad }
811 1.1.16.1 ad
812 1.1.16.1 ad void
813 1.1.16.1 ad pm_set_curpos(struct pm_softc *sc, struct wsdisplay_curpos *curpos)
814 1.1.16.1 ad {
815 1.1.16.1 ad struct rasops_info *ri;
816 1.1.16.1 ad int x, y;
817 1.1.16.1 ad
818 1.1.16.1 ad ri = &pm_ri;
819 1.1.16.1 ad x = curpos->x;
820 1.1.16.1 ad y = curpos->y;
821 1.1.16.1 ad
822 1.1.16.1 ad if (y < 0)
823 1.1.16.1 ad y = 0;
824 1.1.16.1 ad else if (y > ri->ri_height)
825 1.1.16.1 ad y = ri->ri_height;
826 1.1.16.1 ad if (x < 0)
827 1.1.16.1 ad x = 0;
828 1.1.16.1 ad else if (x > ri->ri_width)
829 1.1.16.1 ad x = ri->ri_width;
830 1.1.16.1 ad sc->sc_cursor.cc_pos.x = x;
831 1.1.16.1 ad sc->sc_cursor.cc_pos.y = y;
832 1.1.16.1 ad }
833