tcx.c revision 1.3 1 1.3 eeh /* $NetBSD: tcx.c,v 1.3 2001/09/24 23:49:34 eeh Exp $ */
2 1.1 pk
3 1.1 pk /*
4 1.1 pk * Copyright (c) 1996,1998 The NetBSD Foundation, Inc.
5 1.1 pk * All rights reserved.
6 1.1 pk *
7 1.1 pk * This code is derived from software contributed to The NetBSD Foundation
8 1.1 pk * by Paul Kranenburg.
9 1.1 pk *
10 1.1 pk * Redistribution and use in source and binary forms, with or without
11 1.1 pk * modification, are permitted provided that the following conditions
12 1.1 pk * are met:
13 1.1 pk * 1. Redistributions of source code must retain the above copyright
14 1.1 pk * notice, this list of conditions and the following disclaimer.
15 1.1 pk * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 pk * notice, this list of conditions and the following disclaimer in the
17 1.1 pk * documentation and/or other materials provided with the distribution.
18 1.1 pk * 3. All advertising materials mentioning features or use of this software
19 1.1 pk * must display the following acknowledgement:
20 1.1 pk * This product includes software developed by the NetBSD
21 1.1 pk * Foundation, Inc. and its contributors.
22 1.1 pk * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 pk * contributors may be used to endorse or promote products derived
24 1.1 pk * from this software without specific prior written permission.
25 1.1 pk *
26 1.1 pk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 pk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 pk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 pk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 pk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 pk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 pk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 pk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 pk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 pk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 pk * POSSIBILITY OF SUCH DAMAGE.
37 1.1 pk */
38 1.1 pk
39 1.1 pk /*
40 1.1 pk * color display (TCX) driver.
41 1.1 pk *
42 1.1 pk * Does not handle interrupts, even though they can occur.
43 1.1 pk *
44 1.1 pk * XXX should defer colormap updates to vertical retrace interrupts
45 1.1 pk */
46 1.1 pk
47 1.1 pk #include <sys/param.h>
48 1.1 pk #include <sys/systm.h>
49 1.1 pk #include <sys/buf.h>
50 1.1 pk #include <sys/device.h>
51 1.1 pk #include <sys/ioctl.h>
52 1.1 pk #include <sys/malloc.h>
53 1.1 pk #include <sys/mman.h>
54 1.1 pk #include <sys/tty.h>
55 1.1 pk #include <sys/conf.h>
56 1.1 pk
57 1.1 pk #ifdef DEBUG
58 1.1 pk #include <sys/proc.h>
59 1.1 pk #include <sys/syslog.h>
60 1.1 pk #endif
61 1.1 pk
62 1.1 pk #include <machine/bus.h>
63 1.1 pk #include <machine/autoconf.h>
64 1.1 pk
65 1.1 pk #include <dev/sun/fbio.h>
66 1.1 pk #include <dev/sun/fbvar.h>
67 1.1 pk #include <dev/sun/btreg.h>
68 1.1 pk #include <dev/sun/btvar.h>
69 1.2 pk
70 1.2 pk #include <dev/sbus/sbusvar.h>
71 1.2 pk #include <dev/sbus/tcxreg.h>
72 1.1 pk
73 1.1 pk #include <machine/conf.h>
74 1.1 pk
75 1.1 pk /* per-display variables */
76 1.1 pk struct tcx_softc {
77 1.1 pk struct device sc_dev; /* base device */
78 1.1 pk struct sbusdev sc_sd; /* sbus device */
79 1.1 pk struct fbdevice sc_fb; /* frame buffer device */
80 1.1 pk bus_space_tag_t sc_bustag;
81 1.1 pk struct sbus_reg sc_physadr[TCX_NREG]; /* phys addr of h/w */
82 1.1 pk
83 1.1 pk volatile struct bt_regs *sc_bt; /* Brooktree registers */
84 1.1 pk volatile struct tcx_thc *sc_thc;/* THC registers */
85 1.1 pk short sc_blanked; /* true if blanked */
86 1.1 pk union bt_cmap sc_cmap; /* Brooktree color map */
87 1.1 pk };
88 1.1 pk
89 1.1 pk /* autoconfiguration driver */
90 1.1 pk static void tcxattach __P((struct device *, struct device *, void *));
91 1.1 pk static int tcxmatch __P((struct device *, struct cfdata *, void *));
92 1.1 pk static void tcx_unblank __P((struct device *));
93 1.1 pk
94 1.1 pk /* cdevsw prototypes */
95 1.1 pk cdev_decl(tcx);
96 1.1 pk
97 1.1 pk struct cfattach tcx_ca = {
98 1.1 pk sizeof(struct tcx_softc), tcxmatch, tcxattach
99 1.1 pk };
100 1.1 pk
101 1.1 pk extern struct cfdriver tcx_cd;
102 1.1 pk
103 1.1 pk /* frame buffer generic driver */
104 1.1 pk static struct fbdriver tcx_fbdriver = {
105 1.1 pk tcx_unblank, tcxopen, tcxclose, tcxioctl, tcxpoll, tcxmmap
106 1.1 pk };
107 1.1 pk
108 1.1 pk static void tcx_reset __P((struct tcx_softc *));
109 1.1 pk static void tcx_loadcmap __P((struct tcx_softc *, int, int));
110 1.1 pk
111 1.1 pk #define OBPNAME "SUNW,tcx"
112 1.1 pk /*
113 1.1 pk * Match a tcx.
114 1.1 pk */
115 1.1 pk int
116 1.1 pk tcxmatch(parent, cf, aux)
117 1.1 pk struct device *parent;
118 1.1 pk struct cfdata *cf;
119 1.1 pk void *aux;
120 1.1 pk {
121 1.1 pk struct sbus_attach_args *sa = aux;
122 1.1 pk
123 1.1 pk return (strcmp(sa->sa_name, OBPNAME) == 0);
124 1.1 pk }
125 1.1 pk
126 1.1 pk /*
127 1.1 pk * Attach a display.
128 1.1 pk */
129 1.1 pk void
130 1.1 pk tcxattach(parent, self, args)
131 1.1 pk struct device *parent, *self;
132 1.1 pk void *args;
133 1.1 pk {
134 1.1 pk struct tcx_softc *sc = (struct tcx_softc *)self;
135 1.1 pk struct sbus_attach_args *sa = args;
136 1.1 pk int node, ramsize;
137 1.1 pk volatile struct bt_regs *bt;
138 1.1 pk struct fbdevice *fb = &sc->sc_fb;
139 1.1 pk bus_space_handle_t bh;
140 1.1 pk int isconsole;
141 1.1 pk
142 1.1 pk sc->sc_bustag = sa->sa_bustag;
143 1.1 pk node = sa->sa_node;
144 1.1 pk
145 1.1 pk fb->fb_driver = &tcx_fbdriver;
146 1.1 pk fb->fb_device = &sc->sc_dev;
147 1.1 pk /* Mask out invalid flags from the user. */
148 1.1 pk fb->fb_flags = sc->sc_dev.dv_cfdata->cf_flags & FB_USERMASK;
149 1.1 pk fb->fb_type.fb_depth = node_has_property(node, "tcx-24-bit")
150 1.1 pk ? 24
151 1.1 pk : (node_has_property(node, "tcx-8-bit")
152 1.1 pk ? 8
153 1.1 pk : 8);
154 1.1 pk
155 1.1 pk fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node);
156 1.1 pk
157 1.1 pk ramsize = fb->fb_type.fb_height * fb->fb_linebytes;
158 1.1 pk fb->fb_type.fb_cmsize = 256;
159 1.1 pk fb->fb_type.fb_size = ramsize;
160 1.1 pk printf(": %s, %d x %d", OBPNAME,
161 1.1 pk fb->fb_type.fb_width,
162 1.1 pk fb->fb_type.fb_height);
163 1.1 pk
164 1.1 pk /*
165 1.1 pk * XXX - should be set to FBTYPE_TCX.
166 1.1 pk * XXX For CG3 emulation to work in current (96/6) X11 servers,
167 1.1 pk * XXX `fbtype' must point to an "unregocnised" entry.
168 1.1 pk */
169 1.1 pk fb->fb_type.fb_type = FBTYPE_RESERVED3;
170 1.1 pk
171 1.1 pk
172 1.1 pk if (sa->sa_nreg != TCX_NREG) {
173 1.1 pk printf("%s: only %d register sets\n",
174 1.1 pk self->dv_xname, sa->sa_nreg);
175 1.1 pk return;
176 1.1 pk }
177 1.1 pk bcopy(sa->sa_reg, sc->sc_physadr,
178 1.1 pk sa->sa_nreg * sizeof(struct sbus_reg));
179 1.1 pk
180 1.1 pk /* XXX - fix THC and TEC offsets */
181 1.1 pk sc->sc_physadr[TCX_REG_TEC].sbr_offset += 0x1000;
182 1.1 pk sc->sc_physadr[TCX_REG_THC].sbr_offset += 0x1000;
183 1.1 pk
184 1.1 pk /* Map the register banks we care about */
185 1.1 pk if (sbus_bus_map(sa->sa_bustag,
186 1.1 pk (bus_type_t)sc->sc_physadr[TCX_REG_THC].sbr_slot,
187 1.1 pk (bus_addr_t)sc->sc_physadr[TCX_REG_THC].sbr_offset,
188 1.1 pk sizeof (struct tcx_thc),
189 1.1 pk BUS_SPACE_MAP_LINEAR,
190 1.1 pk 0, &bh) != 0) {
191 1.1 pk printf("tcxattach: cannot map thc registers\n");
192 1.1 pk return;
193 1.1 pk }
194 1.1 pk sc->sc_thc = (volatile struct tcx_thc *)bh;
195 1.1 pk
196 1.1 pk if (sbus_bus_map(sa->sa_bustag,
197 1.1 pk (bus_type_t)sc->sc_physadr[TCX_REG_CMAP].sbr_slot,
198 1.1 pk (bus_addr_t)sc->sc_physadr[TCX_REG_CMAP].sbr_offset,
199 1.1 pk sizeof (struct bt_regs),
200 1.1 pk BUS_SPACE_MAP_LINEAR,
201 1.1 pk 0, &bh) != 0) {
202 1.1 pk printf("tcxattach: cannot map bt registers\n");
203 1.1 pk return;
204 1.1 pk }
205 1.1 pk sc->sc_bt = bt = (volatile struct bt_regs *)bh;
206 1.1 pk
207 1.1 pk isconsole = fb_is_console(node);
208 1.1 pk
209 1.1 pk printf(", id %d, rev %d, sense %d",
210 1.1 pk (sc->sc_thc->thc_config & THC_CFG_FBID) >> THC_CFG_FBID_SHIFT,
211 1.1 pk (sc->sc_thc->thc_config & THC_CFG_REV) >> THC_CFG_REV_SHIFT,
212 1.1 pk (sc->sc_thc->thc_config & THC_CFG_SENSE) >> THC_CFG_SENSE_SHIFT
213 1.1 pk );
214 1.1 pk
215 1.1 pk /* reset cursor & frame buffer controls */
216 1.1 pk tcx_reset(sc);
217 1.1 pk
218 1.1 pk /* Initialize the default color map. */
219 1.1 pk bt_initcmap(&sc->sc_cmap, 256);
220 1.1 pk tcx_loadcmap(sc, 0, 256);
221 1.1 pk
222 1.1 pk /* enable video */
223 1.1 pk sc->sc_thc->thc_hcmisc |= THC_MISC_VIDEN;
224 1.1 pk
225 1.1 pk if (isconsole) {
226 1.1 pk printf(" (console)\n");
227 1.1 pk } else
228 1.1 pk printf("\n");
229 1.1 pk
230 1.1 pk sbus_establish(&sc->sc_sd, &sc->sc_dev);
231 1.1 pk fb_attach(&sc->sc_fb, isconsole);
232 1.1 pk }
233 1.1 pk
234 1.1 pk int
235 1.1 pk tcxopen(dev, flags, mode, p)
236 1.1 pk dev_t dev;
237 1.1 pk int flags, mode;
238 1.1 pk struct proc *p;
239 1.1 pk {
240 1.1 pk int unit = minor(dev);
241 1.1 pk
242 1.1 pk if (unit >= tcx_cd.cd_ndevs || tcx_cd.cd_devs[unit] == NULL)
243 1.1 pk return (ENXIO);
244 1.1 pk return (0);
245 1.1 pk }
246 1.1 pk
247 1.1 pk int
248 1.1 pk tcxclose(dev, flags, mode, p)
249 1.1 pk dev_t dev;
250 1.1 pk int flags, mode;
251 1.1 pk struct proc *p;
252 1.1 pk {
253 1.1 pk struct tcx_softc *sc = tcx_cd.cd_devs[minor(dev)];
254 1.1 pk
255 1.1 pk tcx_reset(sc);
256 1.1 pk return (0);
257 1.1 pk }
258 1.1 pk
259 1.1 pk int
260 1.1 pk tcxioctl(dev, cmd, data, flags, p)
261 1.1 pk dev_t dev;
262 1.1 pk u_long cmd;
263 1.1 pk caddr_t data;
264 1.1 pk int flags;
265 1.1 pk struct proc *p;
266 1.1 pk {
267 1.1 pk struct tcx_softc *sc = tcx_cd.cd_devs[minor(dev)];
268 1.1 pk int error;
269 1.1 pk
270 1.1 pk switch (cmd) {
271 1.1 pk
272 1.1 pk case FBIOGTYPE:
273 1.1 pk *(struct fbtype *)data = sc->sc_fb.fb_type;
274 1.1 pk break;
275 1.1 pk
276 1.1 pk case FBIOGATTR:
277 1.1 pk #define fba ((struct fbgattr *)data)
278 1.1 pk fba->real_type = sc->sc_fb.fb_type.fb_type;
279 1.1 pk fba->owner = 0; /* XXX ??? */
280 1.1 pk fba->fbtype = sc->sc_fb.fb_type;
281 1.1 pk fba->sattr.flags = 0;
282 1.1 pk fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
283 1.1 pk fba->sattr.dev_specific[0] = -1;
284 1.1 pk fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
285 1.1 pk fba->emu_types[1] = FBTYPE_SUN3COLOR;
286 1.1 pk fba->emu_types[2] = -1;
287 1.1 pk #undef fba
288 1.1 pk break;
289 1.1 pk
290 1.1 pk case FBIOGETCMAP:
291 1.1 pk #define p ((struct fbcmap *)data)
292 1.1 pk return (bt_getcmap(p, &sc->sc_cmap, 256, 1));
293 1.1 pk
294 1.1 pk case FBIOPUTCMAP:
295 1.1 pk /* copy to software map */
296 1.1 pk error = bt_putcmap(p, &sc->sc_cmap, 256, 1);
297 1.1 pk if (error)
298 1.1 pk return (error);
299 1.1 pk /* now blast them into the chip */
300 1.1 pk /* XXX should use retrace interrupt */
301 1.1 pk tcx_loadcmap(sc, p->index, p->count);
302 1.1 pk #undef p
303 1.1 pk break;
304 1.1 pk
305 1.1 pk case FBIOGVIDEO:
306 1.1 pk *(int *)data = sc->sc_blanked;
307 1.1 pk break;
308 1.1 pk
309 1.1 pk case FBIOSVIDEO:
310 1.1 pk if (*(int *)data)
311 1.1 pk tcx_unblank(&sc->sc_dev);
312 1.1 pk else if (!sc->sc_blanked) {
313 1.1 pk sc->sc_blanked = 1;
314 1.1 pk sc->sc_thc->thc_hcmisc &= ~THC_MISC_VIDEN;
315 1.1 pk /* Put monitor in `power-saving mode' */
316 1.1 pk sc->sc_thc->thc_hcmisc |= THC_MISC_VSYNC_DISABLE;
317 1.1 pk sc->sc_thc->thc_hcmisc |= THC_MISC_HSYNC_DISABLE;
318 1.1 pk }
319 1.1 pk break;
320 1.1 pk
321 1.1 pk default:
322 1.1 pk #ifdef DEBUG
323 1.1 pk log(LOG_NOTICE, "tcxioctl(0x%lx) (%s[%d])\n", cmd,
324 1.1 pk p->p_comm, p->p_pid);
325 1.1 pk #endif
326 1.1 pk return (ENOTTY);
327 1.1 pk }
328 1.1 pk return (0);
329 1.1 pk }
330 1.1 pk
331 1.1 pk int
332 1.1 pk tcxpoll(dev, events, p)
333 1.1 pk dev_t dev;
334 1.1 pk int events;
335 1.1 pk struct proc *p;
336 1.1 pk {
337 1.1 pk
338 1.1 pk return (seltrue(dev, events, p));
339 1.1 pk }
340 1.1 pk
341 1.1 pk /*
342 1.1 pk * Clean up hardware state (e.g., after bootup or after X crashes).
343 1.1 pk */
344 1.1 pk static void
345 1.1 pk tcx_reset(sc)
346 1.1 pk struct tcx_softc *sc;
347 1.1 pk {
348 1.1 pk volatile struct bt_regs *bt;
349 1.1 pk
350 1.1 pk /* Enable cursor in Brooktree DAC. */
351 1.1 pk bt = sc->sc_bt;
352 1.1 pk bt->bt_addr = 0x06 << 24;
353 1.1 pk bt->bt_ctrl |= 0x03 << 24;
354 1.1 pk }
355 1.1 pk
356 1.1 pk /*
357 1.1 pk * Load a subset of the current (new) colormap into the color DAC.
358 1.1 pk */
359 1.1 pk static void
360 1.1 pk tcx_loadcmap(sc, start, ncolors)
361 1.1 pk struct tcx_softc *sc;
362 1.1 pk int start, ncolors;
363 1.1 pk {
364 1.1 pk volatile struct bt_regs *bt;
365 1.1 pk u_int *ip, i;
366 1.1 pk int count;
367 1.1 pk
368 1.1 pk ip = &sc->sc_cmap.cm_chip[BT_D4M3(start)]; /* start/4 * 3 */
369 1.1 pk count = BT_D4M3(start + ncolors - 1) - BT_D4M3(start) + 3;
370 1.1 pk bt = sc->sc_bt;
371 1.1 pk bt->bt_addr = BT_D4M4(start) << 24;
372 1.1 pk while (--count >= 0) {
373 1.1 pk i = *ip++;
374 1.1 pk /* hardware that makes one want to pound boards with hammers */
375 1.1 pk bt->bt_cmap = i;
376 1.1 pk bt->bt_cmap = i << 8;
377 1.1 pk bt->bt_cmap = i << 16;
378 1.1 pk bt->bt_cmap = i << 24;
379 1.1 pk }
380 1.1 pk }
381 1.1 pk
382 1.1 pk static void
383 1.1 pk tcx_unblank(dev)
384 1.1 pk struct device *dev;
385 1.1 pk {
386 1.1 pk struct tcx_softc *sc = (struct tcx_softc *)dev;
387 1.1 pk
388 1.1 pk if (sc->sc_blanked) {
389 1.1 pk sc->sc_blanked = 0;
390 1.1 pk sc->sc_thc->thc_hcmisc &= ~THC_MISC_VSYNC_DISABLE;
391 1.1 pk sc->sc_thc->thc_hcmisc &= ~THC_MISC_HSYNC_DISABLE;
392 1.1 pk sc->sc_thc->thc_hcmisc |= THC_MISC_VIDEN;
393 1.1 pk }
394 1.1 pk }
395 1.1 pk
396 1.1 pk /*
397 1.1 pk * Base addresses at which users can mmap() the various pieces of a tcx.
398 1.1 pk */
399 1.1 pk #define TCX_USER_RAM 0x00000000
400 1.1 pk #define TCX_USER_RAM24 0x01000000
401 1.1 pk #define TCX_USER_RAM_COMPAT 0x04000000 /* cg3 emulation */
402 1.1 pk #define TCX_USER_STIP 0x10000000
403 1.1 pk #define TCX_USER_BLIT 0x20000000
404 1.1 pk #define TCX_USER_RDFB32 0x28000000
405 1.1 pk #define TCX_USER_RSTIP 0x30000000
406 1.1 pk #define TCX_USER_RBLIT 0x38000000
407 1.1 pk #define TCX_USER_TEC 0x70001000
408 1.1 pk #define TCX_USER_BTREGS 0x70002000
409 1.1 pk #define TCX_USER_THC 0x70004000
410 1.1 pk #define TCX_USER_DHC 0x70008000
411 1.1 pk #define TCX_USER_ALT 0x7000a000
412 1.1 pk #define TCX_USER_UART 0x7000c000
413 1.1 pk #define TCX_USER_VRT 0x7000e000
414 1.1 pk #define TCX_USER_ROM 0x70010000
415 1.1 pk
416 1.1 pk struct mmo {
417 1.1 pk u_int mo_uaddr; /* user (virtual) address */
418 1.1 pk u_int mo_size; /* size, or 0 for video ram size */
419 1.1 pk u_int mo_bank; /* register bank number */
420 1.1 pk };
421 1.1 pk
422 1.1 pk /*
423 1.1 pk * Return the address that would map the given device at the given
424 1.1 pk * offset, allowing for the given protection, or return -1 for error.
425 1.1 pk *
426 1.1 pk * XXX needs testing against `demanding' applications (e.g., aviator)
427 1.1 pk */
428 1.1 pk paddr_t
429 1.1 pk tcxmmap(dev, off, prot)
430 1.1 pk dev_t dev;
431 1.1 pk off_t off;
432 1.1 pk int prot;
433 1.1 pk {
434 1.1 pk struct tcx_softc *sc = tcx_cd.cd_devs[minor(dev)];
435 1.1 pk struct sbus_reg *rr = sc->sc_physadr;
436 1.1 pk struct mmo *mo;
437 1.1 pk u_int u, sz;
438 1.1 pk static struct mmo mmo[] = {
439 1.1 pk { TCX_USER_RAM, 0, TCX_REG_DFB8 },
440 1.1 pk { TCX_USER_RAM24, 0, TCX_REG_DFB24 },
441 1.1 pk { TCX_USER_RAM_COMPAT, 0, TCX_REG_DFB8 },
442 1.1 pk
443 1.1 pk { TCX_USER_STIP, 1, TCX_REG_STIP },
444 1.1 pk { TCX_USER_BLIT, 1, TCX_REG_BLIT },
445 1.1 pk { TCX_USER_RDFB32, 1, TCX_REG_RDFB32 },
446 1.1 pk { TCX_USER_RSTIP, 1, TCX_REG_RSTIP },
447 1.1 pk { TCX_USER_RBLIT, 1, TCX_REG_RBLIT },
448 1.1 pk { TCX_USER_TEC, 1, TCX_REG_TEC },
449 1.1 pk { TCX_USER_BTREGS, 8192 /* XXX */, TCX_REG_CMAP },
450 1.1 pk { TCX_USER_THC, sizeof(struct tcx_thc), TCX_REG_THC },
451 1.1 pk { TCX_USER_DHC, 1, TCX_REG_DHC },
452 1.1 pk { TCX_USER_ALT, 1, TCX_REG_ALT },
453 1.1 pk { TCX_USER_ROM, 65536, TCX_REG_ROM },
454 1.1 pk };
455 1.1 pk #define NMMO (sizeof mmo / sizeof *mmo)
456 1.1 pk
457 1.1 pk if (off & PGOFSET)
458 1.1 pk panic("tcxmmap");
459 1.1 pk
460 1.1 pk /*
461 1.1 pk * Entries with size 0 map video RAM (i.e., the size in fb data).
462 1.1 pk *
463 1.1 pk * Since we work in pages, the fact that the map offset table's
464 1.1 pk * sizes are sometimes bizarre (e.g., 1) is effectively ignored:
465 1.1 pk * one byte is as good as one page.
466 1.1 pk */
467 1.1 pk for (mo = mmo; mo < &mmo[NMMO]; mo++) {
468 1.1 pk if ((u_int)off < mo->mo_uaddr)
469 1.1 pk continue;
470 1.1 pk u = off - mo->mo_uaddr;
471 1.1 pk sz = mo->mo_size ? mo->mo_size : sc->sc_fb.fb_type.fb_size;
472 1.1 pk if (u < sz) {
473 1.1 pk bus_type_t t = (bus_type_t)rr[mo->mo_bank].sbr_slot;
474 1.3 eeh bus_addr_t a = BUS_ADDR(t, rr[mo->mo_bank].sbr_offset);
475 1.1 pk
476 1.3 eeh return (bus_space_mmap(sc->sc_bustag,
477 1.3 eeh a,
478 1.3 eeh u,
479 1.3 eeh prot,
480 1.3 eeh BUS_SPACE_MAP_LINEAR));
481 1.1 pk }
482 1.1 pk }
483 1.3 eeh return (-1);
484 1.1 pk }
485