zx.c revision 1.23 1 1.23 cegger /* $NetBSD: zx.c,v 1.23 2008/06/11 18:50:59 cegger Exp $ */
2 1.1 ad
3 1.1 ad /*
4 1.1 ad * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.1 ad * All rights reserved.
6 1.1 ad *
7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1 ad * by Andrew Doran.
9 1.1 ad *
10 1.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1 ad * modification, are permitted provided that the following conditions
12 1.1 ad * are met:
13 1.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1 ad * documentation and/or other materials provided with the distribution.
18 1.1 ad *
19 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
30 1.1 ad */
31 1.1 ad
32 1.1 ad /*
33 1.1 ad * Driver for the Sun ZX display adapter. This would be called 'leo', but
34 1.1 ad * NetBSD/amiga already has a driver by that name. The XFree86 and Linux
35 1.1 ad * drivers were used as "living documentation" when writing this; thanks
36 1.1 ad * to the authors.
37 1.1 ad *
38 1.1 ad * Issues (which can be solved with wscons, happily enough):
39 1.1 ad *
40 1.1 ad * o There is lots of unnecessary mucking about rasops in here, primarily
41 1.1 ad * to appease the sparc fb code.
42 1.1 ad *
43 1.1 ad * o RASTERCONSOLE is required. X needs the board set up correctly, and
44 1.1 ad * that's difficult to reconcile with using the PROM for output.
45 1.1 ad */
46 1.1 ad
47 1.1 ad #include <sys/cdefs.h>
48 1.23 cegger __KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.23 2008/06/11 18:50:59 cegger Exp $");
49 1.1 ad
50 1.1 ad #include <sys/param.h>
51 1.1 ad #include <sys/systm.h>
52 1.1 ad #include <sys/device.h>
53 1.1 ad #include <sys/ioctl.h>
54 1.1 ad #include <sys/malloc.h>
55 1.1 ad #include <sys/mman.h>
56 1.1 ad #include <sys/tty.h>
57 1.1 ad #include <sys/conf.h>
58 1.1 ad #include <sys/syslog.h>
59 1.1 ad #include <sys/buf.h>
60 1.1 ad
61 1.20 ad #include <sys/bus.h>
62 1.1 ad #include <machine/autoconf.h>
63 1.1 ad
64 1.1 ad #include <uvm/uvm_extern.h>
65 1.1 ad
66 1.1 ad #include <dev/sun/fbio.h>
67 1.1 ad #include <dev/sun/fbvar.h>
68 1.1 ad
69 1.1 ad #include <dev/sbus/zxreg.h>
70 1.1 ad #include <dev/sbus/zxvar.h>
71 1.1 ad #include <dev/sbus/sbusvar.h>
72 1.1 ad
73 1.1 ad #include <dev/wscons/wsconsio.h>
74 1.1 ad
75 1.1 ad #ifndef RASTERCONSOLE
76 1.1 ad #error Sorry, this driver needs the RASTERCONSOLE option
77 1.1 ad #endif
78 1.1 ad
79 1.1 ad /* Force 32-bit writes. */
80 1.1 ad #define SETREG(r, v) (*((volatile u_int32_t *)&r) = (v))
81 1.1 ad
82 1.1 ad #define ZX_STD_ROP (ZX_ROP_NEW | ZX_ATTR_WE_ENABLE | \
83 1.1 ad ZX_ATTR_OE_ENABLE | ZX_ATTR_FORCE_WID)
84 1.1 ad
85 1.1 ad void zx_attach(struct device *, struct device *, void *);
86 1.1 ad int zx_match(struct device *, struct cfdata *, void *);
87 1.1 ad
88 1.1 ad void zx_blank(struct device *);
89 1.1 ad int zx_cmap_put(struct zx_softc *);
90 1.1 ad void zx_copyrect(struct rasops_info *, int, int, int, int, int, int);
91 1.1 ad int zx_cross_loadwid(struct zx_softc *, u_int, u_int, u_int);
92 1.1 ad int zx_cross_wait(struct zx_softc *);
93 1.1 ad void zx_fillrect(struct rasops_info *, int, int, int, int, long, int);
94 1.1 ad int zx_intr(void *);
95 1.1 ad void zx_reset(struct zx_softc *);
96 1.1 ad void zx_unblank(struct device *);
97 1.1 ad
98 1.1 ad void zx_cursor_blank(struct zx_softc *);
99 1.1 ad void zx_cursor_color(struct zx_softc *);
100 1.1 ad void zx_cursor_move(struct zx_softc *);
101 1.1 ad void zx_cursor_set(struct zx_softc *);
102 1.1 ad void zx_cursor_unblank(struct zx_softc *);
103 1.1 ad
104 1.1 ad void zx_copycols(void *, int, int, int, int);
105 1.1 ad void zx_copyrows(void *, int, int, int);
106 1.1 ad void zx_cursor(void *, int, int, int);
107 1.1 ad void zx_do_cursor(struct rasops_info *);
108 1.1 ad void zx_erasecols(void *, int, int, int, long);
109 1.1 ad void zx_eraserows(void *, int, int, long);
110 1.1 ad void zx_putchar(void *, int, int, u_int, long);
111 1.1 ad
112 1.1 ad struct zx_mmo {
113 1.1 ad off_t mo_va;
114 1.1 ad off_t mo_pa;
115 1.1 ad off_t mo_size;
116 1.1 ad } static const zx_mmo[] = {
117 1.1 ad { ZX_FB0_VOFF, ZX_OFF_SS0, 0x00800000 },
118 1.1 ad { ZX_LC0_VOFF, ZX_OFF_LC_SS0_USR, 0x00001000 },
119 1.1 ad { ZX_LD0_VOFF, ZX_OFF_LD_SS0, 0x00001000 },
120 1.1 ad { ZX_LX0_CURSOR_VOFF, ZX_OFF_LX_CURSOR, 0x00001000 },
121 1.1 ad { ZX_FB1_VOFF, ZX_OFF_SS1, 0x00800000 },
122 1.1 ad { ZX_LC1_VOFF, ZX_OFF_LC_SS1_USR, 0x00001000 },
123 1.1 ad { ZX_LD1_VOFF, ZX_OFF_LD_SS1, 0x00001000 },
124 1.1 ad { ZX_LX_KRN_VOFF, ZX_OFF_LX_CROSS, 0x00001000 },
125 1.1 ad { ZX_LC0_KRN_VOFF, ZX_OFF_LC_SS0_KRN, 0x00001000 },
126 1.1 ad { ZX_LC1_KRN_VOFF, ZX_OFF_LC_SS1_KRN, 0x00001000 },
127 1.1 ad { ZX_LD_GBL_VOFF, ZX_OFF_LD_GBL, 0x00001000 },
128 1.14 perry };
129 1.1 ad
130 1.4 thorpej CFATTACH_DECL(zx, sizeof(struct zx_softc),
131 1.5 thorpej zx_match, zx_attach, NULL, NULL);
132 1.1 ad
133 1.1 ad extern struct cfdriver zx_cd;
134 1.1 ad
135 1.1 ad dev_type_open(zxopen);
136 1.1 ad dev_type_close(zxclose);
137 1.1 ad dev_type_ioctl(zxioctl);
138 1.1 ad dev_type_mmap(zxmmap);
139 1.1 ad
140 1.1 ad static struct fbdriver zx_fbdriver = {
141 1.1 ad zx_unblank, zxopen, zxclose, zxioctl, nopoll, zxmmap
142 1.1 ad };
143 1.1 ad
144 1.1 ad int
145 1.1 ad zx_match(struct device *parent, struct cfdata *cf, void *aux)
146 1.1 ad {
147 1.1 ad struct sbus_attach_args *sa;
148 1.14 perry
149 1.1 ad sa = (struct sbus_attach_args *)aux;
150 1.1 ad
151 1.1 ad return (strcmp(sa->sa_name, "SUNW,leo") == 0);
152 1.1 ad }
153 1.1 ad
154 1.1 ad void
155 1.1 ad zx_attach(struct device *parent, struct device *self, void *args)
156 1.1 ad {
157 1.1 ad struct zx_softc *sc;
158 1.1 ad struct sbus_attach_args *sa;
159 1.1 ad bus_space_handle_t bh;
160 1.1 ad bus_space_tag_t bt;
161 1.1 ad struct fbdevice *fb;
162 1.1 ad struct rasops_info *ri;
163 1.1 ad volatile struct zx_command *zc;
164 1.1 ad int isconsole;
165 1.1 ad
166 1.1 ad sc = (struct zx_softc *)self;
167 1.1 ad sa = args;
168 1.1 ad fb = &sc->sc_fb;
169 1.1 ad ri = &fb->fb_rinfo;
170 1.1 ad bt = sa->sa_bustag;
171 1.1 ad sc->sc_bt = bt;
172 1.1 ad
173 1.1 ad sc->sc_paddr = sbus_bus_addr(bt, sa->sa_slot, sa->sa_offset);
174 1.1 ad
175 1.1 ad if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0,
176 1.1 ad 0x800000, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
177 1.21 cegger aprint_error_dev(self, "can't map bits\n");
178 1.1 ad return;
179 1.1 ad }
180 1.19 christos fb->fb_pixels = (void *)bus_space_vaddr(bt, bh);
181 1.1 ad sc->sc_pixels = (u_int32_t *)fb->fb_pixels;
182 1.1 ad
183 1.1 ad if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LC_SS0_USR,
184 1.1 ad PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
185 1.21 cegger aprint_error_dev(self, "can't map zc\n");
186 1.1 ad return;
187 1.1 ad }
188 1.1 ad sc->sc_zc = (struct zx_command *)bus_space_vaddr(bt, bh);
189 1.1 ad
190 1.1 ad if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS0,
191 1.1 ad PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
192 1.21 cegger aprint_error_dev(self, "can't map ld/ss0\n");
193 1.1 ad return;
194 1.1 ad }
195 1.1 ad sc->sc_zd_ss0 = (struct zx_draw *)bus_space_vaddr(bt, bh);
196 1.1 ad
197 1.1 ad if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS1,
198 1.1 ad PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
199 1.21 cegger aprint_error_dev(self, "can't map ld/ss1\n");
200 1.1 ad return;
201 1.1 ad }
202 1.1 ad sc->sc_zd_ss1 =
203 1.1 ad (struct zx_draw_ss1 *)bus_space_vaddr(bt, bh);
204 1.1 ad
205 1.1 ad if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CROSS,
206 1.1 ad PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
207 1.21 cegger aprint_error_dev(self, "can't map zx\n");
208 1.1 ad return;
209 1.1 ad }
210 1.1 ad sc->sc_zx = (struct zx_cross *)bus_space_vaddr(bt, bh);
211 1.1 ad
212 1.1 ad if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CURSOR,
213 1.1 ad PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
214 1.21 cegger aprint_error_dev(self, "can't map zcu\n");
215 1.1 ad return;
216 1.1 ad }
217 1.1 ad sc->sc_zcu = (struct zx_cursor *)bus_space_vaddr(bt, bh);
218 1.1 ad
219 1.1 ad fb->fb_driver = &zx_fbdriver;
220 1.1 ad fb->fb_device = &sc->sc_dv;
221 1.17 thorpej fb->fb_flags = device_cfdata(&sc->sc_dv)->cf_flags & FB_USERMASK;
222 1.1 ad fb->fb_pfour = NULL;
223 1.1 ad fb->fb_linebytes = 8192;
224 1.1 ad
225 1.1 ad fb_setsize_obp(fb, 32, 1280, 1024, sa->sa_node);
226 1.1 ad
227 1.1 ad fb->fb_type.fb_cmsize = 256;
228 1.1 ad fb->fb_type.fb_depth = 32;
229 1.1 ad fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
230 1.1 ad fb->fb_type.fb_type = FBTYPE_SUNLEO;
231 1.1 ad
232 1.1 ad printf(": %d x %d", fb->fb_type.fb_width, fb->fb_type.fb_height);
233 1.1 ad isconsole = fb_is_console(sa->sa_node);
234 1.1 ad if (isconsole)
235 1.1 ad printf(" (console)");
236 1.1 ad printf("\n");
237 1.1 ad
238 1.1 ad sbus_establish(&sc->sc_sd, &sc->sc_dv);
239 1.1 ad if (sa->sa_nintr != 0)
240 1.6 pk bus_intr_establish(bt, sa->sa_pri, IPL_NONE, zx_intr, sc);
241 1.1 ad
242 1.1 ad sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT);
243 1.1 ad fb_attach(&sc->sc_fb, isconsole);
244 1.1 ad zx_reset(sc);
245 1.1 ad
246 1.1 ad /*
247 1.1 ad * Attach to rcons. XXX At this point, rasops_do_cursor() will be
248 1.1 ad * called before we get our hooks in place. So, we mask off access
249 1.1 ad * to the framebuffer until it's done.
250 1.1 ad */
251 1.1 ad zc = sc->sc_zc;
252 1.1 ad SETREG(zc->zc_fontt, 1);
253 1.1 ad SETREG(zc->zc_fontmsk, 0);
254 1.1 ad
255 1.1 ad fbrcons_init(&sc->sc_fb);
256 1.1 ad
257 1.1 ad SETREG(zc->zc_fontt, 0);
258 1.1 ad SETREG(zc->zc_fontmsk, 0xffffffff);
259 1.1 ad
260 1.1 ad ri->ri_hw = sc;
261 1.1 ad ri->ri_do_cursor = zx_do_cursor;
262 1.1 ad ri->ri_ops.copycols = zx_copycols;
263 1.1 ad ri->ri_ops.copyrows = zx_copyrows;
264 1.1 ad ri->ri_ops.erasecols = zx_erasecols;
265 1.1 ad ri->ri_ops.eraserows = zx_eraserows;
266 1.1 ad ri->ri_ops.putchar = zx_putchar;
267 1.1 ad
268 1.1 ad sc->sc_fontw = ri->ri_font->fontwidth;
269 1.1 ad sc->sc_fonth = ri->ri_font->fontheight;
270 1.1 ad }
271 1.1 ad
272 1.1 ad int
273 1.16 christos zxopen(dev_t dev, int flags, int mode, struct lwp *l)
274 1.1 ad {
275 1.1 ad
276 1.1 ad if (device_lookup(&zx_cd, minor(dev)) == NULL)
277 1.1 ad return (ENXIO);
278 1.1 ad return (0);
279 1.1 ad }
280 1.1 ad
281 1.1 ad int
282 1.16 christos zxclose(dev_t dev, int flags, int mode, struct lwp *l)
283 1.1 ad {
284 1.1 ad struct zx_softc *sc;
285 1.1 ad
286 1.23 cegger sc = device_lookup_private(&zx_cd, minor(dev));
287 1.1 ad
288 1.1 ad zx_reset(sc);
289 1.1 ad zx_cursor_blank(sc);
290 1.1 ad return (0);
291 1.1 ad }
292 1.1 ad
293 1.1 ad int
294 1.19 christos zxioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
295 1.1 ad {
296 1.1 ad struct zx_softc *sc;
297 1.1 ad struct fbcmap *cm;
298 1.1 ad struct fbcursor *cu;
299 1.13 chs uint32_t curbits[2][32];
300 1.1 ad int rv, v, count, i;
301 1.1 ad
302 1.23 cegger sc = device_lookup_private(&zx_cd, minor(dev));
303 1.14 perry
304 1.1 ad switch (cmd) {
305 1.1 ad case FBIOGTYPE:
306 1.1 ad *(struct fbtype *)data = sc->sc_fb.fb_type;
307 1.1 ad break;
308 1.1 ad
309 1.1 ad case FBIOGATTR:
310 1.1 ad #define fba ((struct fbgattr *)data)
311 1.1 ad fba->real_type = sc->sc_fb.fb_type.fb_type;
312 1.1 ad fba->owner = 0; /* XXX ??? */
313 1.1 ad fba->fbtype = sc->sc_fb.fb_type;
314 1.1 ad fba->sattr.flags = 0;
315 1.1 ad fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
316 1.1 ad fba->sattr.dev_specific[0] = -1;
317 1.1 ad fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
318 1.1 ad fba->emu_types[1] = -1;
319 1.1 ad fba->emu_types[2] = -1;
320 1.1 ad #undef fba
321 1.1 ad break;
322 1.1 ad
323 1.1 ad case FBIOGVIDEO:
324 1.1 ad *(int *)data = ((sc->sc_flags & ZX_BLANKED) != 0);
325 1.1 ad break;
326 1.1 ad
327 1.1 ad case FBIOSVIDEO:
328 1.1 ad if (*(int *)data)
329 1.1 ad zx_unblank(&sc->sc_dv);
330 1.1 ad else
331 1.1 ad zx_blank(&sc->sc_dv);
332 1.1 ad break;
333 1.1 ad
334 1.1 ad case FBIOGETCMAP:
335 1.1 ad cm = (struct fbcmap *)data;
336 1.1 ad if (cm->index > 256 || cm->count > 256 - cm->index)
337 1.1 ad return (EINVAL);
338 1.1 ad rv = copyout(sc->sc_cmap + cm->index, cm->red, cm->count);
339 1.2 ad if (rv == 0)
340 1.1 ad rv = copyout(sc->sc_cmap + 256 + cm->index, cm->green,
341 1.1 ad cm->count);
342 1.2 ad if (rv == 0)
343 1.1 ad rv = copyout(sc->sc_cmap + 512 + cm->index, cm->blue,
344 1.1 ad cm->count);
345 1.1 ad return (rv);
346 1.1 ad
347 1.1 ad case FBIOPUTCMAP:
348 1.1 ad cm = (struct fbcmap *)data;
349 1.1 ad if (cm->index > 256 || cm->count > 256 - cm->index)
350 1.1 ad return (EINVAL);
351 1.1 ad rv = copyin(cm->red, sc->sc_cmap + cm->index, cm->count);
352 1.2 ad if (rv == 0)
353 1.1 ad rv = copyin(cm->green, sc->sc_cmap + 256 + cm->index,
354 1.1 ad cm->count);
355 1.2 ad if (rv == 0)
356 1.1 ad rv = copyin(cm->blue, sc->sc_cmap + 512 + cm->index,
357 1.1 ad cm->count);
358 1.1 ad zx_cmap_put(sc);
359 1.1 ad return (rv);
360 1.1 ad
361 1.1 ad case FBIOGCURPOS:
362 1.1 ad *(struct fbcurpos *)data = sc->sc_curpos;
363 1.1 ad break;
364 1.1 ad
365 1.1 ad case FBIOSCURPOS:
366 1.1 ad sc->sc_curpos = *(struct fbcurpos *)data;
367 1.1 ad zx_cursor_move(sc);
368 1.1 ad break;
369 1.1 ad
370 1.1 ad case FBIOGCURMAX:
371 1.1 ad ((struct fbcurpos *)data)->x = 32;
372 1.1 ad ((struct fbcurpos *)data)->y = 32;
373 1.1 ad break;
374 1.1 ad
375 1.1 ad case FBIOSCURSOR:
376 1.1 ad cu = (struct fbcursor *)data;
377 1.1 ad v = cu->set;
378 1.1 ad
379 1.1 ad if ((v & FB_CUR_SETSHAPE) != 0) {
380 1.1 ad if ((u_int)cu->size.x > 32 || (u_int)cu->size.y > 32)
381 1.1 ad return (EINVAL);
382 1.1 ad count = cu->size.y * 4;
383 1.13 chs rv = copyin(cu->mask, curbits[0], count);
384 1.13 chs if (rv)
385 1.13 chs return rv;
386 1.13 chs rv = copyin(cu->image, curbits[1], count);
387 1.13 chs if (rv)
388 1.13 chs return rv;
389 1.1 ad }
390 1.1 ad if ((v & FB_CUR_SETCUR) != 0) {
391 1.1 ad if (cu->enable)
392 1.1 ad zx_cursor_unblank(sc);
393 1.1 ad else
394 1.1 ad zx_cursor_blank(sc);
395 1.1 ad }
396 1.1 ad if ((v & (FB_CUR_SETPOS | FB_CUR_SETHOT)) != 0) {
397 1.1 ad if ((v & FB_CUR_SETPOS) != 0)
398 1.1 ad sc->sc_curpos = cu->pos;
399 1.1 ad if ((v & FB_CUR_SETHOT) != 0)
400 1.1 ad sc->sc_curhot = cu->hot;
401 1.1 ad zx_cursor_move(sc);
402 1.1 ad }
403 1.1 ad if ((v & FB_CUR_SETCMAP) != 0) {
404 1.1 ad if (cu->cmap.index > 2 ||
405 1.1 ad cu->cmap.count > 2 - cu->cmap.index)
406 1.1 ad return (EINVAL);
407 1.1 ad for (i = 0; i < cu->cmap.count; i++) {
408 1.1 ad if ((v = fubyte(&cu->cmap.red[i])) < 0)
409 1.1 ad return (EFAULT);
410 1.1 ad sc->sc_curcmap[i + cu->cmap.index + 0] = v;
411 1.1 ad if ((v = fubyte(&cu->cmap.green[i])) < 0)
412 1.1 ad return (EFAULT);
413 1.1 ad sc->sc_curcmap[i + cu->cmap.index + 2] = v;
414 1.1 ad if ((v = fubyte(&cu->cmap.blue[i])) < 0)
415 1.1 ad return (EFAULT);
416 1.1 ad sc->sc_curcmap[i + cu->cmap.index + 4] = v;
417 1.1 ad }
418 1.1 ad zx_cursor_color(sc);
419 1.1 ad }
420 1.1 ad if ((v & FB_CUR_SETSHAPE) != 0) {
421 1.1 ad sc->sc_cursize = cu->size;
422 1.1 ad count = cu->size.y * 4;
423 1.1 ad memset(sc->sc_curbits, 0, sizeof(sc->sc_curbits));
424 1.13 chs memcpy(sc->sc_curbits[0], curbits[0], count);
425 1.13 chs memcpy(sc->sc_curbits[1], curbits[1], count);
426 1.1 ad zx_cursor_set(sc);
427 1.1 ad }
428 1.1 ad break;
429 1.1 ad
430 1.1 ad case FBIOGCURSOR:
431 1.1 ad cu = (struct fbcursor *)data;
432 1.1 ad
433 1.1 ad cu->set = FB_CUR_SETALL;
434 1.1 ad cu->enable = ((sc->sc_flags & ZX_CURSOR) != 0);
435 1.1 ad cu->pos = sc->sc_curpos;
436 1.1 ad cu->hot = sc->sc_curhot;
437 1.1 ad cu->size = sc->sc_cursize;
438 1.1 ad
439 1.1 ad if (cu->image != NULL) {
440 1.1 ad count = sc->sc_cursize.y * 4;
441 1.13 chs rv = copyout(sc->sc_curbits[1], cu->image, count);
442 1.1 ad if (rv)
443 1.1 ad return (rv);
444 1.13 chs rv = copyout(sc->sc_curbits[0], cu->mask, count);
445 1.1 ad if (rv)
446 1.1 ad return (rv);
447 1.1 ad }
448 1.1 ad if (cu->cmap.red != NULL) {
449 1.1 ad if (cu->cmap.index > 2 ||
450 1.1 ad cu->cmap.count > 2 - cu->cmap.index)
451 1.1 ad return (EINVAL);
452 1.1 ad for (i = 0; i < cu->cmap.count; i++) {
453 1.1 ad v = sc->sc_curcmap[i + cu->cmap.index + 0];
454 1.1 ad if (subyte(&cu->cmap.red[i], v))
455 1.1 ad return (EFAULT);
456 1.1 ad v = sc->sc_curcmap[i + cu->cmap.index + 2];
457 1.1 ad if (subyte(&cu->cmap.green[i], v))
458 1.1 ad return (EFAULT);
459 1.1 ad v = sc->sc_curcmap[i + cu->cmap.index + 4];
460 1.1 ad if (subyte(&cu->cmap.blue[i], v))
461 1.1 ad return (EFAULT);
462 1.1 ad }
463 1.1 ad } else {
464 1.1 ad cu->cmap.index = 0;
465 1.1 ad cu->cmap.count = 2;
466 1.1 ad }
467 1.1 ad break;
468 1.1 ad
469 1.1 ad default:
470 1.1 ad #ifdef DEBUG
471 1.1 ad log(LOG_NOTICE, "zxioctl(0x%lx) (%s[%d])\n", cmd,
472 1.18 jdc l->l_proc->p_comm, l->l_proc->p_pid);
473 1.1 ad #endif
474 1.1 ad return (ENOTTY);
475 1.1 ad }
476 1.1 ad
477 1.1 ad return (0);
478 1.1 ad }
479 1.1 ad
480 1.1 ad int
481 1.1 ad zx_intr(void *cookie)
482 1.1 ad {
483 1.1 ad
484 1.1 ad return (1);
485 1.1 ad }
486 1.1 ad
487 1.1 ad void
488 1.1 ad zx_reset(struct zx_softc *sc)
489 1.1 ad {
490 1.1 ad volatile struct zx_draw *zd;
491 1.1 ad volatile struct zx_command *zc;
492 1.1 ad struct fbtype *fbt;
493 1.1 ad u_int i;
494 1.1 ad
495 1.1 ad zd = sc->sc_zd_ss0;
496 1.1 ad zc = sc->sc_zc;
497 1.1 ad fbt = &sc->sc_fb.fb_type;
498 1.1 ad
499 1.1 ad zx_cross_loadwid(sc, ZX_WID_DBL_8, 0, 0x2c0);
500 1.1 ad zx_cross_loadwid(sc, ZX_WID_DBL_8, 1, 0x30);
501 1.1 ad zx_cross_loadwid(sc, ZX_WID_DBL_8, 2, 0x20);
502 1.1 ad zx_cross_loadwid(sc, ZX_WID_DBL_24, 1, 0x30);
503 1.1 ad
504 1.1 ad i = sc->sc_zd_ss1->zd_misc;
505 1.1 ad i |= ZX_SS1_MISC_ENABLE;
506 1.1 ad SETREG(sc->sc_zd_ss1->zd_misc, i);
507 1.1 ad
508 1.2 ad SETREG(zd->zd_wid, 0xffffffff);
509 1.2 ad SETREG(zd->zd_widclip, 0);
510 1.1 ad SETREG(zd->zd_wmask, 0xffff);
511 1.1 ad SETREG(zd->zd_vclipmin, 0);
512 1.1 ad SETREG(zd->zd_vclipmax,
513 1.1 ad (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 16));
514 1.1 ad SETREG(zd->zd_fg, 0);
515 1.1 ad SETREG(zd->zd_planemask, 0xff000000);
516 1.1 ad SETREG(zd->zd_rop, ZX_STD_ROP);
517 1.1 ad
518 1.1 ad SETREG(zc->zc_extent,
519 1.1 ad (fbt->fb_width - 1) | ((fbt->fb_height - 1) << 11));
520 1.1 ad SETREG(zc->zc_addrspace, ZX_ADDRSPC_FONT_OBGR);
521 1.1 ad SETREG(zc->zc_fontt, 0);
522 1.1 ad
523 1.1 ad for (i = 0; i < 256; i++) {
524 1.1 ad sc->sc_cmap[i] = rasops_cmap[i * 3];
525 1.1 ad sc->sc_cmap[i + 256] = rasops_cmap[i * 3 + 1];
526 1.1 ad sc->sc_cmap[i + 512] = rasops_cmap[i * 3 + 2];
527 1.1 ad }
528 1.1 ad
529 1.1 ad zx_cmap_put(sc);
530 1.1 ad }
531 1.1 ad
532 1.1 ad int
533 1.1 ad zx_cross_wait(struct zx_softc *sc)
534 1.1 ad {
535 1.1 ad volatile struct zx_cross *zx;
536 1.1 ad int i;
537 1.1 ad
538 1.1 ad zx = sc->sc_zx;
539 1.1 ad
540 1.1 ad for (i = 300000; i != 0; i--) {
541 1.1 ad if ((zx->zx_csr & ZX_CROSS_CSR_PROGRESS) == 0)
542 1.1 ad break;
543 1.1 ad DELAY(1);
544 1.1 ad }
545 1.1 ad
546 1.1 ad if (i == 0)
547 1.1 ad printf("zx_cross_wait: timed out\n");
548 1.1 ad
549 1.1 ad return (i);
550 1.1 ad }
551 1.1 ad
552 1.1 ad int
553 1.1 ad zx_cross_loadwid(struct zx_softc *sc, u_int type, u_int index, u_int value)
554 1.1 ad {
555 1.1 ad volatile struct zx_cross *zx;
556 1.12 chs u_int tmp = 0;
557 1.1 ad
558 1.1 ad zx = sc->sc_zx;
559 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_WID);
560 1.1 ad
561 1.1 ad if (zx_cross_wait(sc))
562 1.1 ad return (1);
563 1.1 ad
564 1.1 ad if (type == ZX_WID_DBL_8)
565 1.1 ad tmp = (index & 0x0f) + 0x40;
566 1.1 ad else if (type == ZX_WID_DBL_24)
567 1.1 ad tmp = index & 0x3f;
568 1.1 ad
569 1.1 ad SETREG(zx->zx_type, 0x5800 + tmp);
570 1.1 ad SETREG(zx->zx_value, value);
571 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_WID);
572 1.1 ad SETREG(zx->zx_csr, ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2);
573 1.1 ad
574 1.1 ad return (0);
575 1.1 ad }
576 1.1 ad
577 1.1 ad int
578 1.1 ad zx_cmap_put(struct zx_softc *sc)
579 1.1 ad {
580 1.1 ad volatile struct zx_cross *zx;
581 1.1 ad const u_char *b;
582 1.1 ad u_int i, t;
583 1.1 ad
584 1.1 ad zx = sc->sc_zx;
585 1.1 ad
586 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_CLUT0);
587 1.1 ad if (zx_cross_wait(sc))
588 1.1 ad return (1);
589 1.1 ad
590 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_CLUTDATA);
591 1.1 ad
592 1.1 ad for (i = 0, b = sc->sc_cmap; i < 256; i++) {
593 1.1 ad t = b[i];
594 1.1 ad t |= b[i + 256] << 8;
595 1.1 ad t |= b[i + 512] << 16;
596 1.1 ad SETREG(zx->zx_value, t);
597 1.1 ad }
598 1.1 ad
599 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_CLUT0);
600 1.1 ad i = zx->zx_csr;
601 1.1 ad i = i | ZX_CROSS_CSR_UNK | ZX_CROSS_CSR_UNK2;
602 1.1 ad SETREG(zx->zx_csr, i);
603 1.1 ad return (0);
604 1.1 ad }
605 1.1 ad
606 1.1 ad void
607 1.1 ad zx_cursor_move(struct zx_softc *sc)
608 1.1 ad {
609 1.1 ad volatile struct zx_cursor *zcu;
610 1.1 ad int sx, sy, x, y;
611 1.1 ad
612 1.1 ad x = sc->sc_curpos.x - sc->sc_curhot.x;
613 1.1 ad y = sc->sc_curpos.y - sc->sc_curhot.y;
614 1.1 ad zcu = sc->sc_zcu;
615 1.1 ad
616 1.1 ad if (x < 0) {
617 1.1 ad sx = min(-x, 32);
618 1.1 ad x = 0;
619 1.1 ad } else
620 1.1 ad sx = 0;
621 1.1 ad
622 1.1 ad if (y < 0) {
623 1.1 ad sy = min(-y, 32);
624 1.1 ad y = 0;
625 1.1 ad } else
626 1.1 ad sy = 0;
627 1.1 ad
628 1.1 ad if (sx != sc->sc_shiftx || sy != sc->sc_shifty) {
629 1.1 ad sc->sc_shiftx = sx;
630 1.1 ad sc->sc_shifty = sy;
631 1.1 ad zx_cursor_set(sc);
632 1.1 ad }
633 1.1 ad
634 1.1 ad SETREG(zcu->zcu_sxy, ((y & 0x7ff) << 11) | (x & 0x7ff));
635 1.1 ad SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x30);
636 1.1 ad
637 1.1 ad /* XXX Necessary? */
638 1.1 ad SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x80);
639 1.1 ad }
640 1.1 ad
641 1.1 ad void
642 1.1 ad zx_cursor_set(struct zx_softc *sc)
643 1.1 ad {
644 1.1 ad volatile struct zx_cursor *zcu;
645 1.1 ad int i, j, data;
646 1.1 ad
647 1.1 ad zcu = sc->sc_zcu;
648 1.2 ad
649 1.2 ad if ((sc->sc_flags & ZX_CURSOR) != 0)
650 1.2 ad SETREG(zcu->zcu_misc, zcu->zcu_misc & ~0x80);
651 1.1 ad
652 1.1 ad for (j = 0; j < 2; j++) {
653 1.11 ad SETREG(zcu->zcu_type, 0x20 << j);
654 1.2 ad
655 1.1 ad for (i = sc->sc_shifty; i < 32; i++) {
656 1.1 ad data = sc->sc_curbits[j][i];
657 1.1 ad SETREG(zcu->zcu_data, data >> sc->sc_shiftx);
658 1.1 ad }
659 1.1 ad for (i = sc->sc_shifty; i != 0; i--)
660 1.1 ad SETREG(zcu->zcu_data, 0);
661 1.1 ad }
662 1.2 ad
663 1.2 ad if ((sc->sc_flags & ZX_CURSOR) != 0)
664 1.2 ad SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x80);
665 1.1 ad }
666 1.1 ad
667 1.1 ad void
668 1.1 ad zx_cursor_blank(struct zx_softc *sc)
669 1.1 ad {
670 1.1 ad volatile struct zx_cursor *zcu;
671 1.1 ad
672 1.1 ad sc->sc_flags &= ~ZX_CURSOR;
673 1.1 ad zcu = sc->sc_zcu;
674 1.1 ad SETREG(zcu->zcu_misc, zcu->zcu_misc & ~0x80);
675 1.1 ad }
676 1.1 ad
677 1.1 ad void
678 1.1 ad zx_cursor_unblank(struct zx_softc *sc)
679 1.1 ad {
680 1.1 ad volatile struct zx_cursor *zcu;
681 1.1 ad
682 1.1 ad sc->sc_flags |= ZX_CURSOR;
683 1.1 ad zcu = sc->sc_zcu;
684 1.1 ad SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x80);
685 1.1 ad }
686 1.1 ad
687 1.1 ad void
688 1.1 ad zx_cursor_color(struct zx_softc *sc)
689 1.1 ad {
690 1.1 ad volatile struct zx_cursor *zcu;
691 1.1 ad u_int8_t tmp;
692 1.1 ad
693 1.1 ad zcu = sc->sc_zcu;
694 1.1 ad
695 1.1 ad SETREG(zcu->zcu_type, 0x50);
696 1.1 ad
697 1.1 ad tmp = sc->sc_curcmap[0] | (sc->sc_curcmap[2] << 8) |
698 1.1 ad (sc->sc_curcmap[4] << 16);
699 1.1 ad SETREG(zcu->zcu_data, tmp);
700 1.1 ad
701 1.1 ad tmp = sc->sc_curcmap[1] | (sc->sc_curcmap[3] << 8) |
702 1.1 ad (sc->sc_curcmap[5] << 16);
703 1.1 ad SETREG(zcu->zcu_data, sc->sc_curcmap[1]);
704 1.1 ad
705 1.1 ad SETREG(zcu->zcu_misc, zcu->zcu_misc | 0x03);
706 1.1 ad }
707 1.1 ad
708 1.1 ad void
709 1.1 ad zx_blank(struct device *dv)
710 1.1 ad {
711 1.1 ad struct zx_softc *sc;
712 1.1 ad volatile struct zx_cross *zx;
713 1.1 ad
714 1.1 ad sc = (struct zx_softc *)dv;
715 1.1 ad
716 1.1 ad if ((sc->sc_flags & ZX_BLANKED) != 0)
717 1.1 ad return;
718 1.1 ad sc->sc_flags |= ZX_BLANKED;
719 1.1 ad
720 1.1 ad zx = sc->sc_zx;
721 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_VIDEO);
722 1.1 ad SETREG(zx->zx_csr, zx->zx_csr & ~ZX_CROSS_CSR_ENABLE);
723 1.1 ad }
724 1.1 ad
725 1.1 ad void
726 1.1 ad zx_unblank(struct device *dv)
727 1.1 ad {
728 1.1 ad struct zx_softc *sc;
729 1.1 ad volatile struct zx_cross *zx;
730 1.1 ad
731 1.1 ad sc = (struct zx_softc *)dv;
732 1.1 ad
733 1.1 ad if ((sc->sc_flags & ZX_BLANKED) == 0)
734 1.1 ad return;
735 1.1 ad sc->sc_flags &= ~ZX_BLANKED;
736 1.1 ad
737 1.1 ad zx = sc->sc_zx;
738 1.1 ad SETREG(zx->zx_type, ZX_CROSS_TYPE_VIDEO);
739 1.1 ad SETREG(zx->zx_csr, zx->zx_csr | ZX_CROSS_CSR_ENABLE);
740 1.1 ad }
741 1.1 ad
742 1.1 ad paddr_t
743 1.1 ad zxmmap(dev_t dev, off_t off, int prot)
744 1.1 ad {
745 1.1 ad struct zx_softc *sc;
746 1.15 tsutsui const struct zx_mmo *mm, *mmmax;
747 1.2 ad
748 1.23 cegger sc = device_lookup_private(&zx_cd, minor(dev));
749 1.2 ad off = trunc_page(off);
750 1.1 ad mm = zx_mmo;
751 1.15 tsutsui mmmax = mm + sizeof(zx_mmo) / sizeof(zx_mmo[0]);
752 1.1 ad
753 1.15 tsutsui for (; mm < mmmax; mm++)
754 1.1 ad if (off >= mm->mo_va && off < mm->mo_va + mm->mo_size) {
755 1.1 ad off = off - mm->mo_va + mm->mo_pa;
756 1.1 ad return (bus_space_mmap(sc->sc_bt, sc->sc_paddr,
757 1.1 ad off, prot, BUS_SPACE_MAP_LINEAR));
758 1.1 ad }
759 1.1 ad
760 1.1 ad return (-1);
761 1.1 ad }
762 1.1 ad
763 1.1 ad void
764 1.1 ad zx_fillrect(struct rasops_info *ri, int x, int y, int w, int h, long attr,
765 1.1 ad int rop)
766 1.1 ad {
767 1.1 ad struct zx_softc *sc;
768 1.1 ad volatile struct zx_command *zc;
769 1.1 ad volatile struct zx_draw *zd;
770 1.1 ad int fg, bg;
771 1.1 ad
772 1.1 ad sc = ri->ri_hw;
773 1.1 ad zc = sc->sc_zc;
774 1.1 ad zd = sc->sc_zd_ss0;
775 1.1 ad
776 1.1 ad rasops_unpack_attr(attr, &fg, &bg, NULL);
777 1.1 ad x = x * sc->sc_fontw + ri->ri_xorigin;
778 1.1 ad y = y * sc->sc_fonth + ri->ri_yorigin;
779 1.1 ad w = sc->sc_fontw * w - 1;
780 1.1 ad h = sc->sc_fonth * h - 1;
781 1.1 ad
782 1.1 ad while ((zc->zc_csr & ZX_CSR_BLT_BUSY) != 0)
783 1.1 ad ;
784 1.1 ad
785 1.1 ad SETREG(zd->zd_rop, rop);
786 1.1 ad SETREG(zd->zd_fg, (bg & 7) ? 0x00000000 : 0xff000000);
787 1.1 ad SETREG(zc->zc_extent, w | (h << 11));
788 1.1 ad SETREG(zc->zc_fill, x | (y << 11) | 0x80000000);
789 1.1 ad }
790 1.1 ad
791 1.1 ad void
792 1.1 ad zx_copyrect(struct rasops_info *ri, int sx, int sy, int dx, int dy, int w,
793 1.1 ad int h)
794 1.1 ad {
795 1.1 ad struct zx_softc *sc;
796 1.1 ad volatile struct zx_command *zc;
797 1.1 ad volatile struct zx_draw *zd;
798 1.1 ad int dir;
799 1.1 ad
800 1.1 ad sc = ri->ri_hw;
801 1.1 ad zc = sc->sc_zc;
802 1.1 ad zd = sc->sc_zd_ss0;
803 1.1 ad
804 1.1 ad sx = sx * sc->sc_fontw + ri->ri_xorigin;
805 1.1 ad sy = sy * sc->sc_fonth + ri->ri_yorigin;
806 1.1 ad dx = dx * sc->sc_fontw + ri->ri_xorigin;
807 1.1 ad dy = dy * sc->sc_fonth + ri->ri_yorigin;
808 1.1 ad w = w * sc->sc_fontw - 1;
809 1.1 ad h = h * sc->sc_fonth - 1;
810 1.1 ad
811 1.1 ad if (sy < dy || sx < dx) {
812 1.1 ad dir = 0x80000000;
813 1.1 ad sx += w;
814 1.1 ad sy += h;
815 1.1 ad dx += w;
816 1.1 ad dy += h;
817 1.1 ad } else
818 1.1 ad dir = 0;
819 1.1 ad
820 1.1 ad while ((zc->zc_csr & ZX_CSR_BLT_BUSY) != 0)
821 1.1 ad ;
822 1.1 ad
823 1.1 ad SETREG(zd->zd_rop, ZX_STD_ROP);
824 1.1 ad SETREG(zc->zc_extent, w | (h << 11) | dir);
825 1.1 ad SETREG(zc->zc_src, sx | (sy << 11));
826 1.1 ad SETREG(zc->zc_copy, dx | (dy << 11));
827 1.1 ad }
828 1.1 ad
829 1.1 ad void
830 1.1 ad zx_do_cursor(struct rasops_info *ri)
831 1.1 ad {
832 1.1 ad
833 1.1 ad zx_fillrect(ri, ri->ri_ccol, ri->ri_crow, 1, 1, 0,
834 1.1 ad ZX_ROP_NEW_XOR_OLD | ZX_ATTR_WE_ENABLE | ZX_ATTR_OE_ENABLE |
835 1.1 ad ZX_ATTR_FORCE_WID);
836 1.1 ad }
837 1.1 ad
838 1.1 ad void
839 1.1 ad zx_erasecols(void *cookie, int row, int col, int num, long attr)
840 1.1 ad {
841 1.1 ad struct rasops_info *ri;
842 1.1 ad
843 1.1 ad ri = (struct rasops_info *)cookie;
844 1.1 ad
845 1.1 ad zx_fillrect(ri, col, row, num, 1, attr, ZX_STD_ROP);
846 1.1 ad }
847 1.1 ad
848 1.1 ad void
849 1.1 ad zx_eraserows(void *cookie, int row, int num, long attr)
850 1.1 ad {
851 1.1 ad struct rasops_info *ri;
852 1.1 ad
853 1.1 ad ri = (struct rasops_info *)cookie;
854 1.1 ad
855 1.1 ad zx_fillrect(ri, 0, row, ri->ri_cols, num, attr, ZX_STD_ROP);
856 1.1 ad }
857 1.1 ad
858 1.1 ad void
859 1.1 ad zx_copyrows(void *cookie, int src, int dst, int num)
860 1.1 ad {
861 1.1 ad struct rasops_info *ri;
862 1.1 ad
863 1.1 ad ri = (struct rasops_info *)cookie;
864 1.1 ad
865 1.1 ad zx_copyrect(ri, 0, src, 0, dst, ri->ri_cols, num);
866 1.1 ad }
867 1.1 ad
868 1.1 ad void
869 1.1 ad zx_copycols(void *cookie, int row, int src, int dst, int num)
870 1.1 ad {
871 1.1 ad struct rasops_info *ri;
872 1.1 ad
873 1.1 ad ri = (struct rasops_info *)cookie;
874 1.1 ad
875 1.1 ad zx_copyrect(ri, src, row, dst, row, num, 1);
876 1.1 ad }
877 1.1 ad
878 1.1 ad void
879 1.1 ad zx_putchar(void *cookie, int row, int col, u_int uc, long attr)
880 1.1 ad {
881 1.1 ad struct rasops_info *ri;
882 1.1 ad struct zx_softc *sc;
883 1.1 ad struct wsdisplay_font *font;
884 1.1 ad volatile struct zx_command *zc;
885 1.1 ad volatile struct zx_draw *zd;
886 1.1 ad volatile u_int32_t *dp;
887 1.1 ad u_int8_t *fb;
888 1.1 ad int fs, i, fg, bg, ul;
889 1.1 ad
890 1.1 ad ri = (struct rasops_info *)cookie;
891 1.1 ad
892 1.1 ad if (uc == ' ') {
893 1.1 ad zx_fillrect(ri, col, row, 1, 1, attr, ZX_STD_ROP);
894 1.1 ad return;
895 1.1 ad }
896 1.1 ad
897 1.1 ad sc = (struct zx_softc *)ri->ri_hw;
898 1.1 ad font = ri->ri_font;
899 1.1 ad zc = sc->sc_zc;
900 1.1 ad zd = sc->sc_zd_ss0;
901 1.1 ad
902 1.1 ad dp = (volatile u_int32_t *)sc->sc_pixels +
903 1.1 ad ((row * sc->sc_fonth + ri->ri_yorigin) << 11) +
904 1.1 ad (col * sc->sc_fontw + ri->ri_xorigin);
905 1.1 ad fb = (u_int8_t *)font->data + (uc - font->firstchar) *
906 1.1 ad ri->ri_fontscale;
907 1.1 ad fs = font->stride;
908 1.1 ad rasops_unpack_attr(attr, &fg, &bg, &ul);
909 1.1 ad
910 1.1 ad while ((zc->zc_csr & ZX_CSR_BLT_BUSY) != 0)
911 1.1 ad ;
912 1.1 ad
913 1.1 ad SETREG(zd->zd_rop, ZX_STD_ROP);
914 1.1 ad SETREG(zd->zd_fg, (fg & 7) ? 0x00000000 : 0xff000000);
915 1.1 ad SETREG(zd->zd_bg, (bg & 7) ? 0x00000000 : 0xff000000);
916 1.1 ad SETREG(zc->zc_fontmsk, 0xffffffff << (32 - sc->sc_fontw));
917 1.1 ad
918 1.1 ad if (sc->sc_fontw <= 8) {
919 1.1 ad for (i = sc->sc_fonth; i != 0; i--, dp += 2048) {
920 1.1 ad *dp = *fb << 24;
921 1.1 ad fb += fs;
922 1.1 ad }
923 1.1 ad } else {
924 1.1 ad for (i = sc->sc_fonth; i != 0; i--, dp += 2048) {
925 1.1 ad *dp = *((u_int16_t *)fb) << 16;
926 1.1 ad fb += fs;
927 1.1 ad }
928 1.1 ad }
929 1.1 ad
930 1.1 ad if (ul) {
931 1.1 ad dp -= 4096;
932 1.1 ad *dp = 0xffffffff;
933 1.1 ad }
934 1.1 ad }
935