wcfb.c revision 1.2 1 1.2 macallan /* $NetBSD: wcfb.c,v 1.2 2010/02/25 20:56:20 macallan Exp $ */
2 1.1 macallan
3 1.1 macallan /*-
4 1.2 macallan * Copyright (c) 2010 Michael Lorenz
5 1.1 macallan * All rights reserved.
6 1.1 macallan *
7 1.1 macallan * Redistribution and use in source and binary forms, with or without
8 1.1 macallan * modification, are permitted provided that the following conditions
9 1.1 macallan * are met:
10 1.1 macallan * 1. Redistributions of source code must retain the above copyright
11 1.1 macallan * notice, this list of conditions and the following disclaimer.
12 1.1 macallan * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 macallan * notice, this list of conditions and the following disclaimer in the
14 1.1 macallan * documentation and/or other materials provided with the distribution.
15 1.1 macallan *
16 1.1 macallan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 macallan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 macallan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 macallan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 macallan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 macallan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 macallan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 macallan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 macallan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 macallan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 macallan * POSSIBILITY OF SUCH DAMAGE.
27 1.1 macallan */
28 1.1 macallan
29 1.1 macallan #include <sys/cdefs.h>
30 1.2 macallan __KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.2 2010/02/25 20:56:20 macallan Exp $");
31 1.1 macallan
32 1.1 macallan #include <sys/param.h>
33 1.1 macallan #include <sys/systm.h>
34 1.1 macallan #include <sys/kernel.h>
35 1.1 macallan #include <sys/device.h>
36 1.1 macallan #include <sys/proc.h>
37 1.1 macallan #include <sys/mutex.h>
38 1.1 macallan #include <sys/ioctl.h>
39 1.1 macallan #include <sys/kernel.h>
40 1.1 macallan #include <sys/systm.h>
41 1.1 macallan #include <sys/kauth.h>
42 1.1 macallan
43 1.1 macallan #include <dev/pci/pcidevs.h>
44 1.1 macallan #include <dev/pci/pcireg.h>
45 1.1 macallan #include <dev/pci/pcivar.h>
46 1.1 macallan #include <dev/pci/pciio.h>
47 1.1 macallan
48 1.1 macallan #include <dev/wscons/wsdisplayvar.h>
49 1.1 macallan #include <dev/wscons/wsconsio.h>
50 1.1 macallan #include <dev/wsfont/wsfont.h>
51 1.1 macallan #include <dev/rasops/rasops.h>
52 1.1 macallan #include <dev/wscons/wsdisplay_vconsvar.h>
53 1.1 macallan
54 1.1 macallan #include "opt_wsfb.h"
55 1.1 macallan #include "opt_wcfb.h"
56 1.1 macallan
57 1.1 macallan #ifdef WCFB_DEBUG
58 1.1 macallan # define DPRINTF printf
59 1.1 macallan #else
60 1.1 macallan # define DPRINTF while (0) printf
61 1.1 macallan #endif
62 1.1 macallan
63 1.1 macallan static int wcfb_match(device_t, cfdata_t, void *);
64 1.1 macallan static void wcfb_attach(device_t, device_t, void *);
65 1.1 macallan static int wcfb_ioctl(void *, void *, u_long, void *, int,
66 1.1 macallan struct lwp *);
67 1.1 macallan static paddr_t wcfb_mmap(void *, void *, off_t, int);
68 1.1 macallan
69 1.1 macallan struct wcfb_softc {
70 1.1 macallan device_t sc_dev;
71 1.1 macallan
72 1.1 macallan pci_chipset_tag_t sc_pc;
73 1.1 macallan pcitag_t sc_pcitag;
74 1.1 macallan
75 1.1 macallan bus_space_tag_t sc_memt;
76 1.1 macallan bus_space_tag_t sc_regt, sc_wtft;
77 1.1 macallan bus_space_tag_t sc_iot;
78 1.1 macallan
79 1.1 macallan bus_space_handle_t sc_fbh, sc_wtfh;
80 1.1 macallan bus_space_handle_t sc_regh;
81 1.1 macallan bus_addr_t sc_fb, sc_reg, sc_wtf;
82 1.1 macallan bus_size_t sc_fbsize, sc_regsize, sc_wtfsize;
83 1.1 macallan
84 1.1 macallan int sc_width, sc_height, sc_stride;
85 1.1 macallan int sc_locked;
86 1.1 macallan uint8_t *sc_fbaddr;
87 1.1 macallan struct vcons_screen sc_console_screen;
88 1.1 macallan struct wsscreen_descr sc_defaultscreen_descr;
89 1.1 macallan const struct wsscreen_descr *sc_screens[1];
90 1.1 macallan struct wsscreen_list sc_screenlist;
91 1.1 macallan struct vcons_data vd;
92 1.1 macallan int sc_mode;
93 1.1 macallan u_char sc_cmap_red[256];
94 1.1 macallan u_char sc_cmap_green[256];
95 1.1 macallan u_char sc_cmap_blue[256];
96 1.1 macallan uint32_t sc_fb0off;
97 1.1 macallan
98 1.1 macallan void (*copycols)(void *, int, int, int, int);
99 1.1 macallan void (*erasecols)(void *, int, int, int, long);
100 1.1 macallan void (*copyrows)(void *, int, int, int);
101 1.1 macallan void (*eraserows)(void *, int, int, long);
102 1.1 macallan void (*putchar)(void *, int, int, u_int, long);
103 1.1 macallan void (*cursor)(void *, int, int, int);
104 1.1 macallan
105 1.1 macallan };
106 1.1 macallan
107 1.1 macallan static void wcfb_init_screen(void *, struct vcons_screen *, int, long *);
108 1.1 macallan
109 1.1 macallan CFATTACH_DECL_NEW(wcfb, sizeof(struct wcfb_softc),
110 1.1 macallan wcfb_match, wcfb_attach, NULL, NULL);
111 1.1 macallan
112 1.1 macallan struct wsdisplay_accessops wcfb_accessops = {
113 1.1 macallan wcfb_ioctl,
114 1.1 macallan wcfb_mmap,
115 1.1 macallan NULL, /* alloc_screen */
116 1.1 macallan NULL, /* free_screen */
117 1.1 macallan NULL, /* show_screen */
118 1.1 macallan NULL, /* load_font */
119 1.1 macallan NULL, /* pollc */
120 1.1 macallan NULL /* scroll */
121 1.1 macallan };
122 1.1 macallan
123 1.1 macallan static void wcfb_putchar(void *, int, int, u_int, long);
124 1.1 macallan static void wcfb_cursor(void *, int, int, int);
125 1.1 macallan static void wcfb_copycols(void *, int, int, int, int);
126 1.1 macallan static void wcfb_erasecols(void *, int, int, int, long);
127 1.1 macallan static void wcfb_copyrows(void *, int, int, int);
128 1.1 macallan static void wcfb_eraserows(void *, int, int, long);
129 1.1 macallan
130 1.1 macallan static void wcfb_putpalreg(struct wcfb_softc *, int, int, int, int);
131 1.1 macallan
132 1.1 macallan static int
133 1.1 macallan wcfb_match(device_t parent, cfdata_t match, void *aux)
134 1.1 macallan {
135 1.1 macallan struct pci_attach_args *pa = aux;
136 1.1 macallan
137 1.1 macallan if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_3DLABS &&
138 1.1 macallan PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_3DLABS_WILDCAT5110)
139 1.1 macallan return 100;
140 1.1 macallan
141 1.1 macallan return 0;
142 1.1 macallan }
143 1.1 macallan
144 1.1 macallan static void
145 1.1 macallan wcfb_attach(device_t parent, device_t self, void *aux)
146 1.1 macallan {
147 1.1 macallan struct wcfb_softc *sc = device_private(self);
148 1.1 macallan struct pci_attach_args *pa = aux;
149 1.1 macallan struct rasops_info *ri;
150 1.1 macallan prop_dictionary_t dict;
151 1.1 macallan struct wsemuldisplaydev_attach_args aa;
152 1.1 macallan int i, j;
153 1.1 macallan unsigned long defattr;
154 1.1 macallan bool is_console;
155 1.1 macallan char devinfo[256];
156 1.1 macallan void *wtf;
157 1.1 macallan
158 1.1 macallan sc->sc_dev = self;
159 1.1 macallan sc->putchar = NULL;
160 1.1 macallan pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
161 1.1 macallan aprint_naive("\n");
162 1.1 macallan aprint_normal(": %s\n", devinfo);
163 1.1 macallan
164 1.1 macallan dict = device_properties(self);
165 1.1 macallan prop_dictionary_get_bool(dict, "is_console", &is_console);
166 1.2 macallan if(!is_console) return;
167 1.1 macallan
168 1.1 macallan sc->sc_memt = pa->pa_memt;
169 1.1 macallan sc->sc_iot = pa->pa_iot;
170 1.1 macallan sc->sc_pc = pa->pa_pc;
171 1.1 macallan sc->sc_pcitag = pa->pa_tag;
172 1.1 macallan
173 1.1 macallan /* fill in parameters from properties */
174 1.1 macallan if (!prop_dictionary_get_uint32(dict, "width", &sc->sc_width)) {
175 1.1 macallan aprint_error("%s: no width property\n", device_xname(self));
176 1.1 macallan return;
177 1.1 macallan }
178 1.1 macallan if (!prop_dictionary_get_uint32(dict, "height", &sc->sc_height)) {
179 1.1 macallan aprint_error("%s: no height property\n", device_xname(self));
180 1.1 macallan return;
181 1.1 macallan }
182 1.1 macallan
183 1.1 macallan if (pci_mapreg_map(pa, 0x14, PCI_MAPREG_TYPE_MEM, 0,
184 1.1 macallan &sc->sc_regt, &sc->sc_regh, &sc->sc_reg, &sc->sc_regsize)) {
185 1.1 macallan aprint_error("%s: failed to map registers.\n",
186 1.1 macallan device_xname(sc->sc_dev));
187 1.1 macallan }
188 1.1 macallan
189 1.1 macallan if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_MEM, BUS_SPACE_MAP_LINEAR,
190 1.1 macallan &sc->sc_memt, &sc->sc_fbh, &sc->sc_fb, &sc->sc_fbsize)) {
191 1.1 macallan aprint_error("%s: failed to map framebuffer.\n",
192 1.1 macallan device_xname(sc->sc_dev));
193 1.1 macallan }
194 1.1 macallan
195 1.1 macallan if (pci_mapreg_map(pa, 0x18, PCI_MAPREG_TYPE_MEM, BUS_SPACE_MAP_LINEAR,
196 1.1 macallan &sc->sc_wtft, &sc->sc_wtfh, &sc->sc_wtf, &sc->sc_wtfsize)) {
197 1.1 macallan aprint_error("%s: failed to map wtf.\n",
198 1.1 macallan device_xname(sc->sc_dev));
199 1.1 macallan }
200 1.1 macallan wtf = bus_space_vaddr(sc->sc_wtft, sc->sc_wtfh);
201 1.1 macallan memset(wtf, 0, 0x100000);
202 1.1 macallan
203 1.1 macallan sc->sc_fbaddr = bus_space_vaddr(sc->sc_memt, sc->sc_fbh);
204 1.1 macallan
205 1.1 macallan sc->sc_fb0off = bus_space_read_4(sc->sc_regt, sc->sc_regh, 0x8080) -
206 1.1 macallan sc->sc_fb;
207 1.1 macallan sc->sc_stride = 1 <<
208 1.1 macallan ((bus_space_read_4(sc->sc_regt, sc->sc_regh, 0x8074) & 0x00ff0000) >> 16);
209 1.1 macallan printf("%s: %d x %d, %d\n", device_xname(sc->sc_dev),
210 1.1 macallan sc->sc_width, sc->sc_height, sc->sc_stride);
211 1.1 macallan for (i = 0x40; i < 0x100; i += 16) {
212 1.1 macallan printf("%04x:", i);
213 1.1 macallan for (j = 0; j < 16; j += 4) {
214 1.1 macallan printf(" %08x", bus_space_read_4(sc->sc_regt,
215 1.1 macallan sc->sc_regh, 0x8000 + i + j));
216 1.1 macallan }
217 1.1 macallan printf("\n");
218 1.1 macallan }
219 1.1 macallan
220 1.1 macallan sc->sc_defaultscreen_descr = (struct wsscreen_descr){
221 1.1 macallan "default",
222 1.1 macallan 0, 0,
223 1.1 macallan NULL,
224 1.1 macallan 8, 16,
225 1.1 macallan WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
226 1.1 macallan NULL
227 1.1 macallan };
228 1.1 macallan sc->sc_screens[0] = &sc->sc_defaultscreen_descr;
229 1.1 macallan sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens};
230 1.1 macallan sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
231 1.1 macallan sc->sc_locked = 0;
232 1.1 macallan
233 1.1 macallan vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr,
234 1.1 macallan &wcfb_accessops);
235 1.1 macallan sc->vd.init_screen = wcfb_init_screen;
236 1.1 macallan
237 1.1 macallan /* init engine here */
238 1.1 macallan #if 0
239 1.1 macallan wcfb_init(sc);
240 1.1 macallan #endif
241 1.1 macallan
242 1.1 macallan ri = &sc->sc_console_screen.scr_ri;
243 1.1 macallan
244 1.1 macallan j = 0;
245 1.1 macallan for (i = 0; i < 256; i++) {
246 1.1 macallan
247 1.1 macallan sc->sc_cmap_red[i] = rasops_cmap[j];
248 1.1 macallan sc->sc_cmap_green[i] = rasops_cmap[j + 1];
249 1.1 macallan sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
250 1.1 macallan wcfb_putpalreg(sc, i, rasops_cmap[j], rasops_cmap[j + 1],
251 1.1 macallan rasops_cmap[j + 2]);
252 1.1 macallan j += 3;
253 1.1 macallan }
254 1.1 macallan wcfb_putpalreg(sc, 0, 0, 0, 0);
255 1.1 macallan wcfb_putpalreg(sc, 15, 0xff, 0xff, 0xff);
256 1.1 macallan
257 1.1 macallan if (is_console) {
258 1.1 macallan vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
259 1.1 macallan &defattr);
260 1.1 macallan sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
261 1.1 macallan
262 1.1 macallan #if 0
263 1.1 macallan wcfb_rectfill(sc, 0, 0, sc->sc_width, sc->sc_height,
264 1.1 macallan ri->ri_devcmap[(defattr >> 16) & 0xff]);
265 1.1 macallan #else
266 1.1 macallan /*memset(sc->sc_fbaddr + sc->sc_fb0off, 0, 0x400000);*/
267 1.1 macallan #endif
268 1.1 macallan sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
269 1.1 macallan sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
270 1.1 macallan sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
271 1.1 macallan sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
272 1.1 macallan wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
273 1.1 macallan defattr);
274 1.1 macallan vcons_replay_msgbuf(&sc->sc_console_screen);
275 1.1 macallan } else {
276 1.1 macallan /*
277 1.1 macallan * since we're not the console we can postpone the rest
278 1.1 macallan * until someone actually allocates a screen for us
279 1.1 macallan */
280 1.1 macallan (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
281 1.1 macallan }
282 1.1 macallan
283 1.1 macallan aa.console = is_console;
284 1.1 macallan aa.scrdata = &sc->sc_screenlist;
285 1.1 macallan aa.accessops = &wcfb_accessops;
286 1.1 macallan aa.accesscookie = &sc->vd;
287 1.1 macallan
288 1.1 macallan config_found(sc->sc_dev, &aa, wsemuldisplaydevprint);
289 1.1 macallan }
290 1.1 macallan
291 1.1 macallan static int
292 1.1 macallan wcfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
293 1.1 macallan struct lwp *l)
294 1.1 macallan {
295 1.1 macallan struct wcfb_softc *sc = v;
296 1.1 macallan
297 1.1 macallan switch (cmd) {
298 1.1 macallan case WSDISPLAYIO_GTYPE:
299 1.1 macallan *(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
300 1.1 macallan return 0;
301 1.1 macallan
302 1.1 macallan /* PCI config read/write passthrough. */
303 1.1 macallan case PCI_IOC_CFGREAD:
304 1.1 macallan case PCI_IOC_CFGWRITE:
305 1.1 macallan return (pci_devioctl(sc->sc_pc, sc->sc_pcitag,
306 1.1 macallan cmd, data, flag, l));
307 1.1 macallan case WSDISPLAYIO_SMODE:
308 1.1 macallan {
309 1.1 macallan /*int new_mode = *(int*)data, i;*/
310 1.1 macallan }
311 1.1 macallan return 0;
312 1.1 macallan }
313 1.1 macallan
314 1.1 macallan return EPASSTHROUGH;
315 1.1 macallan }
316 1.1 macallan
317 1.1 macallan static paddr_t
318 1.1 macallan wcfb_mmap(void *v, void *vs, off_t offset, int prot)
319 1.1 macallan {
320 1.1 macallan struct wcfb_softc *sc = v;
321 1.1 macallan
322 1.1 macallan /* no point in allowing a wsfb map if we can't provide one */
323 1.1 macallan /*
324 1.1 macallan * restrict all other mappings to processes with superuser privileges
325 1.1 macallan * or the kernel itself
326 1.1 macallan */
327 1.1 macallan if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
328 1.1 macallan NULL) != 0) {
329 1.1 macallan aprint_normal_dev(sc->sc_dev, "mmap() rejected.\n");
330 1.1 macallan return -1;
331 1.1 macallan }
332 1.1 macallan
333 1.1 macallan #ifdef WSFB_FAKE_VGA_FB
334 1.1 macallan if ((offset >= 0xa0000) && (offset < 0xbffff)) {
335 1.1 macallan
336 1.1 macallan return bus_space_mmap(sc->sc_memt, sc->sc_gen.sc_fboffset,
337 1.1 macallan offset - 0xa0000, prot, BUS_SPACE_MAP_LINEAR);
338 1.1 macallan }
339 1.1 macallan #endif
340 1.1 macallan
341 1.1 macallan /*
342 1.1 macallan * XXX this should be generalized, let's just
343 1.1 macallan * #define PCI_IOAREA_PADDR
344 1.1 macallan * #define PCI_IOAREA_OFFSET
345 1.1 macallan * #define PCI_IOAREA_SIZE
346 1.1 macallan * somewhere in a MD header and compile this code only if all are
347 1.1 macallan * present
348 1.1 macallan */
349 1.2 macallan /*
350 1.2 macallan * PCI_IOAREA_PADDR is useless, that's what the IO tag is for
351 1.2 macallan * the address isn't guaranteed to be the same on each host bridge
352 1.2 macallan * either, never mind the fact that it would be a bus address
353 1.2 macallan */
354 1.1 macallan #ifdef PCI_MAGIC_IO_RANGE
355 1.1 macallan /* allow to map our IO space */
356 1.1 macallan if ((offset >= PCI_MAGIC_IO_RANGE) &&
357 1.1 macallan (offset < PCI_MAGIC_IO_RANGE + 0x10000)) {
358 1.1 macallan return bus_space_mmap(sc->sc_iot, offset - PCI_MAGIC_IO_RANGE,
359 1.1 macallan 0, prot, BUS_SPACE_MAP_LINEAR);
360 1.1 macallan }
361 1.1 macallan #endif
362 1.1 macallan return -1;
363 1.1 macallan }
364 1.1 macallan
365 1.1 macallan static void
366 1.1 macallan wcfb_init_screen(void *cookie, struct vcons_screen *scr,
367 1.1 macallan int existing, long *defattr)
368 1.1 macallan {
369 1.1 macallan struct wcfb_softc *sc = cookie;
370 1.1 macallan struct rasops_info *ri = &scr->scr_ri;
371 1.1 macallan
372 1.1 macallan ri->ri_depth = 8;
373 1.1 macallan ri->ri_width = sc->sc_width;
374 1.1 macallan ri->ri_height = sc->sc_height;
375 1.1 macallan ri->ri_stride = sc->sc_stride;
376 1.1 macallan ri->ri_flg = RI_CENTER /*| RI_FULLCLEAR*/;
377 1.1 macallan
378 1.1 macallan ri->ri_bits = (char *)sc->sc_fbaddr + sc->sc_fb0off;
379 1.1 macallan
380 1.1 macallan if (existing) {
381 1.1 macallan ri->ri_flg |= RI_CLEAR;
382 1.1 macallan }
383 1.1 macallan
384 1.1 macallan rasops_init(ri, sc->sc_height / 8, sc->sc_width / 8);
385 1.1 macallan ri->ri_caps = WSSCREEN_WSCOLORS;
386 1.1 macallan
387 1.1 macallan rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
388 1.1 macallan sc->sc_width / ri->ri_font->fontwidth);
389 1.1 macallan
390 1.1 macallan ri->ri_hw = scr;
391 1.1 macallan sc->putchar = ri->ri_ops.putchar;
392 1.1 macallan sc->copyrows = ri->ri_ops.copyrows;
393 1.1 macallan sc->eraserows = ri->ri_ops.eraserows;
394 1.1 macallan sc->copycols = ri->ri_ops.copycols;
395 1.1 macallan sc->erasecols = ri->ri_ops.erasecols;
396 1.1 macallan
397 1.1 macallan ri->ri_ops.copyrows = wcfb_copyrows;
398 1.1 macallan ri->ri_ops.copycols = wcfb_copycols;
399 1.1 macallan ri->ri_ops.eraserows = wcfb_eraserows;
400 1.1 macallan ri->ri_ops.erasecols = wcfb_erasecols;
401 1.1 macallan ri->ri_ops.putchar = wcfb_putchar;
402 1.1 macallan ri->ri_ops.cursor = wcfb_cursor;
403 1.1 macallan }
404 1.1 macallan
405 1.1 macallan static void
406 1.1 macallan wcfb_putchar(void *cookie, int row, int col, u_int c, long attr)
407 1.1 macallan {
408 1.1 macallan struct rasops_info *ri = cookie;
409 1.1 macallan struct vcons_screen *scr = ri->ri_hw;
410 1.1 macallan struct wcfb_softc *sc = scr->scr_cookie;
411 1.1 macallan
412 1.1 macallan sc->putchar(ri, row, col, c, attr);
413 1.1 macallan ri->ri_bits += 0x200000;
414 1.1 macallan sc->putchar(ri, row, col, c, attr);
415 1.1 macallan ri->ri_bits -= 0x200000;
416 1.1 macallan }
417 1.1 macallan
418 1.1 macallan static void
419 1.1 macallan wcfb_putpalreg(struct wcfb_softc *sc, int i, int r, int g, int b)
420 1.1 macallan {
421 1.1 macallan uint32_t rgb;
422 1.1 macallan
423 1.1 macallan bus_space_write_4(sc->sc_regt, sc->sc_regh, 0x80bc, i);
424 1.1 macallan rgb = (b << 22) | (g << 12) | (r << 2);
425 1.1 macallan bus_space_write_4(sc->sc_regt, sc->sc_regh, 0x80c0, rgb);
426 1.1 macallan }
427 1.1 macallan
428 1.1 macallan static void
429 1.1 macallan wcfb_cursor(void *cookie, int on, int row, int col)
430 1.1 macallan {
431 1.1 macallan #if 0
432 1.1 macallan struct rasops_info *ri = cookie;
433 1.1 macallan struct vcons_screen *scr = ri->ri_hw;
434 1.1 macallan struct wcfb_softc *sc = scr->scr_cookie;
435 1.1 macallan #endif
436 1.1 macallan }
437 1.1 macallan
438 1.1 macallan static void
439 1.1 macallan wcfb_copycols(void *cookie, int row, int srccol, int dstcol, int ncols)
440 1.1 macallan {
441 1.1 macallan struct rasops_info *ri = cookie;
442 1.1 macallan struct vcons_screen *scr = ri->ri_hw;
443 1.1 macallan struct wcfb_softc *sc = scr->scr_cookie;
444 1.1 macallan
445 1.1 macallan sc->copycols(ri, row, srccol, dstcol, ncols);
446 1.1 macallan ri->ri_bits += 0x200000;
447 1.1 macallan sc->copycols(ri, row, srccol, dstcol, ncols);
448 1.1 macallan ri->ri_bits -= 0x200000;
449 1.1 macallan }
450 1.1 macallan
451 1.1 macallan static void
452 1.1 macallan wcfb_erasecols(void *cookie, int row, int startcol, int ncol, long fillattr)
453 1.1 macallan {
454 1.1 macallan struct rasops_info *ri = cookie;
455 1.1 macallan struct vcons_screen *scr = ri->ri_hw;
456 1.1 macallan struct wcfb_softc *sc = scr->scr_cookie;
457 1.1 macallan
458 1.1 macallan sc->erasecols(ri, row, startcol, ncol, fillattr);
459 1.1 macallan ri->ri_bits += 0x200000;
460 1.1 macallan sc->erasecols(ri, row, startcol, ncol, fillattr);
461 1.1 macallan ri->ri_bits -= 0x200000;
462 1.1 macallan }
463 1.1 macallan
464 1.1 macallan static void
465 1.1 macallan wcfb_copyrows(void *cookie, int srcrow, int dstrow, int nrow)
466 1.1 macallan {
467 1.1 macallan struct rasops_info *ri = cookie;
468 1.1 macallan struct vcons_screen *scr = ri->ri_hw;
469 1.1 macallan struct wcfb_softc *sc = scr->scr_cookie;
470 1.1 macallan
471 1.1 macallan sc->copyrows(ri, srcrow, dstrow, nrow);
472 1.1 macallan ri->ri_bits += 0x200000;
473 1.1 macallan sc->copyrows(ri, srcrow, dstrow, nrow);
474 1.1 macallan ri->ri_bits -= 0x200000;
475 1.1 macallan }
476 1.1 macallan
477 1.1 macallan static void
478 1.1 macallan wcfb_eraserows(void *cookie, int row, int nrows, long fillattr)
479 1.1 macallan {
480 1.1 macallan struct rasops_info *ri = cookie;
481 1.1 macallan struct vcons_screen *scr = ri->ri_hw;
482 1.1 macallan struct wcfb_softc *sc = scr->scr_cookie;
483 1.1 macallan
484 1.1 macallan sc->eraserows(ri, row, nrows, fillattr);
485 1.1 macallan ri->ri_bits += 0x200000;
486 1.1 macallan sc->eraserows(ri, row, nrows, fillattr);
487 1.1 macallan ri->ri_bits -= 0x200000;
488 1.1 macallan }
489