macfb.c revision 1.1.2.3 1 1.1.2.3 scottr /* $NetBSD: macfb.c,v 1.1.2.3 1999/05/16 23:34:37 scottr Exp $ */
2 1.1.2.1 scottr /*
3 1.1.2.1 scottr * Copyright (c) 1998 Matt DeBergalis
4 1.1.2.1 scottr * All rights reserved.
5 1.1.2.1 scottr *
6 1.1.2.1 scottr * Redistribution and use in source and binary forms, with or without
7 1.1.2.1 scottr * modification, are permitted provided that the following conditions
8 1.1.2.1 scottr * are met:
9 1.1.2.1 scottr * 1. Redistributions of source code must retain the above copyright
10 1.1.2.1 scottr * notice, this list of conditions and the following disclaimer.
11 1.1.2.1 scottr * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.1 scottr * notice, this list of conditions and the following disclaimer in the
13 1.1.2.1 scottr * documentation and/or other materials provided with the distribution.
14 1.1.2.1 scottr * 3. All advertising materials mentioning features or use of this software
15 1.1.2.1 scottr * must display the following acknowledgement:
16 1.1.2.1 scottr * This product includes software developed by Matt DeBergalis
17 1.1.2.1 scottr * 4. The name of the author may not be used to endorse or promote products
18 1.1.2.1 scottr * derived from this software without specific prior written permission
19 1.1.2.1 scottr *
20 1.1.2.1 scottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1.2.1 scottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1.2.1 scottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1.2.1 scottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1.2.1 scottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1.2.1 scottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1.2.1 scottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1.2.1 scottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1.2.1 scottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1.2.1 scottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.1 scottr */
31 1.1.2.1 scottr
32 1.1.2.2 scottr #include "opt_wsdisplay_compat.h"
33 1.1.2.1 scottr
34 1.1.2.1 scottr #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
35 1.1.2.1 scottr
36 1.1.2.1 scottr #include <sys/param.h>
37 1.1.2.1 scottr #include <sys/systm.h>
38 1.1.2.1 scottr #include <sys/kernel.h>
39 1.1.2.1 scottr #include <sys/device.h>
40 1.1.2.1 scottr #include <sys/malloc.h>
41 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_GRF
42 1.1.2.2 scottr #include <sys/device.h>
43 1.1.2.2 scottr #include <sys/mman.h>
44 1.1.2.2 scottr #include <sys/proc.h>
45 1.1.2.2 scottr #include <sys/vnode.h>
46 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_GRF */
47 1.1.2.1 scottr
48 1.1.2.1 scottr #include <machine/cpu.h>
49 1.1.2.1 scottr #include <machine/bus.h>
50 1.1.2.1 scottr
51 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_GRF
52 1.1.2.2 scottr #include <miscfs/specfs/specdev.h>
53 1.1.2.2 scottr
54 1.1.2.2 scottr #include <vm/vm.h>
55 1.1.2.2 scottr #include <vm/vm_kern.h>
56 1.1.2.2 scottr #include <vm/vm_page.h>
57 1.1.2.2 scottr #include <vm/vm_pager.h>
58 1.1.2.2 scottr
59 1.1.2.2 scottr #include <uvm/uvm.h>
60 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_GRF */
61 1.1.2.2 scottr
62 1.1.2.1 scottr #include <machine/grfioctl.h>
63 1.1.2.1 scottr #include <mac68k/nubus/nubus.h>
64 1.1.2.1 scottr #include <mac68k/dev/grfvar.h>
65 1.1.2.1 scottr #include <mac68k/dev/macfbvar.h>
66 1.1.2.1 scottr #include <dev/wscons/wsconsio.h>
67 1.1.2.1 scottr
68 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_ITE
69 1.1.2.2 scottr #include <machine/iteioctl.h>
70 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_ITE */
71 1.1.2.2 scottr
72 1.1.2.1 scottr #include <dev/rcons/raster.h>
73 1.1.2.1 scottr #include <dev/wscons/wscons_raster.h>
74 1.1.2.1 scottr #include <dev/wscons/wsdisplayvar.h>
75 1.1.2.1 scottr
76 1.1.2.1 scottr int macfb_match __P((struct device *, struct cfdata *, void *));
77 1.1.2.1 scottr void macfb_attach __P((struct device *, struct device *, void *));
78 1.1.2.1 scottr
79 1.1.2.1 scottr struct cfattach macfb_ca = {
80 1.1.2.1 scottr sizeof(struct macfb_softc),
81 1.1.2.1 scottr macfb_match,
82 1.1.2.1 scottr macfb_attach,
83 1.1.2.1 scottr };
84 1.1.2.1 scottr
85 1.1.2.1 scottr const struct wsdisplay_emulops macfb_emulops = {
86 1.1.2.1 scottr rcons_cursor,
87 1.1.2.1 scottr rcons_mapchar,
88 1.1.2.1 scottr rcons_putchar,
89 1.1.2.1 scottr rcons_copycols,
90 1.1.2.1 scottr rcons_erasecols,
91 1.1.2.1 scottr rcons_copyrows,
92 1.1.2.1 scottr rcons_eraserows,
93 1.1.2.1 scottr rcons_alloc_attr
94 1.1.2.1 scottr };
95 1.1.2.1 scottr
96 1.1.2.1 scottr struct wsscreen_descr macfb_stdscreen = {
97 1.1.2.1 scottr "std",
98 1.1.2.1 scottr 0, 0, /* will be filled in -- XXX shouldn't, it's global */
99 1.1.2.1 scottr &macfb_emulops,
100 1.1.2.1 scottr 0, 0,
101 1.1.2.1 scottr WSSCREEN_REVERSE
102 1.1.2.1 scottr };
103 1.1.2.1 scottr
104 1.1.2.1 scottr const struct wsscreen_descr *_macfb_scrlist[] = {
105 1.1.2.1 scottr &macfb_stdscreen,
106 1.1.2.1 scottr };
107 1.1.2.1 scottr
108 1.1.2.1 scottr const struct wsscreen_list macfb_screenlist = {
109 1.1.2.1 scottr sizeof(_macfb_scrlist) / sizeof(struct wsscreen_descr *),
110 1.1.2.1 scottr _macfb_scrlist
111 1.1.2.1 scottr };
112 1.1.2.1 scottr
113 1.1.2.1 scottr static int macfb_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
114 1.1.2.1 scottr static int macfb_mmap __P((void *, off_t, int));
115 1.1.2.1 scottr static int macfb_alloc_screen __P((void *, const struct wsscreen_descr *,
116 1.1.2.1 scottr void **, int *, int *, long *));
117 1.1.2.1 scottr static void macfb_free_screen __P((void *, void *));
118 1.1.2.1 scottr static void macfb_show_screen __P((void *, void *));
119 1.1.2.1 scottr
120 1.1.2.1 scottr const struct wsdisplay_accessops macfb_accessops = {
121 1.1.2.1 scottr macfb_ioctl,
122 1.1.2.1 scottr macfb_mmap,
123 1.1.2.1 scottr macfb_alloc_screen,
124 1.1.2.1 scottr macfb_free_screen,
125 1.1.2.1 scottr macfb_show_screen,
126 1.1.2.1 scottr 0 /* load_font */
127 1.1.2.1 scottr };
128 1.1.2.1 scottr
129 1.1.2.1 scottr void macfb_init __P((struct macfb_devconfig *));
130 1.1.2.1 scottr
131 1.1.2.1 scottr paddr_t macfb_consaddr;
132 1.1.2.1 scottr static int macfb_is_console __P((paddr_t addr));
133 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_ITEFONT
134 1.1.2.2 scottr static void init_itefont __P((void));
135 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_ITEFONT */
136 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_GRF
137 1.1.2.2 scottr int macfb_grfmap __P((void *, caddr_t *, struct proc *));
138 1.1.2.2 scottr int macfb_grfunmap __P((void *, caddr_t, struct proc *));
139 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_GRF */
140 1.1.2.1 scottr
141 1.1.2.1 scottr static struct macfb_devconfig macfb_console_dc;
142 1.1.2.1 scottr
143 1.1.2.1 scottr /* From Booter via locore */
144 1.1.2.1 scottr extern long videoaddr;
145 1.1.2.1 scottr extern long videorowbytes;
146 1.1.2.1 scottr extern long videobitdepth;
147 1.1.2.1 scottr extern u_long videosize;
148 1.1.2.1 scottr extern u_int32_t mac68k_vidlog;
149 1.1.2.1 scottr extern u_int32_t mac68k_vidphys;
150 1.1.2.1 scottr extern u_int32_t mac68k_vidlen;
151 1.1.2.1 scottr
152 1.1.2.1 scottr static int
153 1.1.2.1 scottr macfb_is_console(paddr_t addr)
154 1.1.2.1 scottr {
155 1.1.2.1 scottr return ((mac68k_machine.serial_console & 0x03) == 0
156 1.1.2.1 scottr && (addr == macfb_consaddr));
157 1.1.2.1 scottr }
158 1.1.2.1 scottr
159 1.1.2.1 scottr void
160 1.1.2.1 scottr macfb_init(dc)
161 1.1.2.1 scottr struct macfb_devconfig *dc;
162 1.1.2.1 scottr {
163 1.1.2.1 scottr struct raster *rap;
164 1.1.2.1 scottr struct rcons *rcp;
165 1.1.2.1 scottr int i;
166 1.1.2.1 scottr
167 1.1.2.2 scottr /* clear the display */
168 1.1.2.1 scottr for (i = 0; i < (dc->dc_ht * dc->dc_rowbytes); i += dc->dc_rowbytes)
169 1.1.2.2 scottr bzero((u_char *)dc->dc_vaddr + dc->dc_offset + i,
170 1.1.2.2 scottr dc->dc_rowbytes);
171 1.1.2.1 scottr
172 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_ITEFONT
173 1.1.2.2 scottr init_itefont();
174 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_ITEFONT */
175 1.1.2.1 scottr
176 1.1.2.1 scottr rap = &dc->dc_raster;
177 1.1.2.1 scottr rap->width = dc->dc_wid;
178 1.1.2.1 scottr rap->height = dc->dc_ht;
179 1.1.2.1 scottr rap->depth = dc->dc_depth;
180 1.1.2.1 scottr rap->linelongs = dc->dc_rowbytes / sizeof(u_int32_t);
181 1.1.2.2 scottr rap->pixels = (u_int32_t *)dc->dc_vaddr + dc->dc_offset;
182 1.1.2.1 scottr
183 1.1.2.1 scottr /* initialize the raster console blitter */
184 1.1.2.1 scottr rcp = &dc->dc_rcons;
185 1.1.2.1 scottr rcp->rc_sp = rap;
186 1.1.2.1 scottr rcp->rc_crow = rcp->rc_ccol = -1;
187 1.1.2.1 scottr rcp->rc_crowp = &rcp->rc_crow;
188 1.1.2.1 scottr rcp->rc_ccolp = &rcp->rc_ccol;
189 1.1.2.1 scottr rcons_init(rcp, 128, 128);
190 1.1.2.1 scottr
191 1.1.2.1 scottr macfb_stdscreen.nrows = dc->dc_rcons.rc_maxrow;
192 1.1.2.1 scottr macfb_stdscreen.ncols = dc->dc_rcons.rc_maxcol;
193 1.1.2.1 scottr }
194 1.1.2.1 scottr
195 1.1.2.1 scottr int
196 1.1.2.1 scottr macfb_match(parent, match, aux)
197 1.1.2.1 scottr struct device *parent;
198 1.1.2.1 scottr struct cfdata *match;
199 1.1.2.1 scottr void *aux;
200 1.1.2.1 scottr {
201 1.1.2.1 scottr return (1);
202 1.1.2.1 scottr }
203 1.1.2.1 scottr
204 1.1.2.1 scottr void
205 1.1.2.1 scottr macfb_attach(parent, self, aux)
206 1.1.2.1 scottr struct device *parent;
207 1.1.2.1 scottr struct device *self;
208 1.1.2.1 scottr void *aux;
209 1.1.2.1 scottr {
210 1.1.2.1 scottr struct grfbus_attach_args *ga = aux;
211 1.1.2.1 scottr struct grfmode *gm = ga->ga_grfmode;
212 1.1.2.1 scottr struct macfb_softc *sc;
213 1.1.2.1 scottr struct wsemuldisplaydev_attach_args waa;
214 1.1.2.1 scottr int isconsole;
215 1.1.2.1 scottr
216 1.1.2.1 scottr sc = (struct macfb_softc *)self;
217 1.1.2.1 scottr
218 1.1.2.1 scottr printf("\n");
219 1.1.2.1 scottr
220 1.1.2.1 scottr isconsole = macfb_is_console(ga->ga_phys);
221 1.1.2.2 scottr
222 1.1.2.1 scottr if (isconsole) {
223 1.1.2.1 scottr sc->sc_dc = &macfb_console_dc;
224 1.1.2.1 scottr sc->nscreens = 1;
225 1.1.2.1 scottr } else {
226 1.1.2.2 scottr sc->sc_dc = malloc(sizeof(struct macfb_devconfig), M_DEVBUF, M_WAITOK);
227 1.1.2.1 scottr sc->sc_dc->dc_vaddr = (vaddr_t)gm->fbbase;
228 1.1.2.1 scottr sc->sc_dc->dc_paddr = ga->ga_phys;
229 1.1.2.1 scottr sc->sc_dc->dc_size = gm->fbsize;
230 1.1.2.1 scottr
231 1.1.2.1 scottr sc->sc_dc->dc_wid = gm->width;
232 1.1.2.1 scottr sc->sc_dc->dc_ht = gm->height;
233 1.1.2.1 scottr sc->sc_dc->dc_depth = gm->psize;
234 1.1.2.1 scottr sc->sc_dc->dc_rowbytes = gm->rowbytes;
235 1.1.2.1 scottr
236 1.1.2.2 scottr sc->sc_dc->dc_offset = gm->fboff;
237 1.1.2.1 scottr
238 1.1.2.1 scottr macfb_init(sc->sc_dc);
239 1.1.2.2 scottr
240 1.1.2.2 scottr sc->nscreens = 1;
241 1.1.2.1 scottr }
242 1.1.2.1 scottr
243 1.1.2.1 scottr /* initialize the raster */
244 1.1.2.1 scottr waa.console = isconsole;
245 1.1.2.1 scottr waa.scrdata = &macfb_screenlist;
246 1.1.2.1 scottr waa.accessops = &macfb_accessops;
247 1.1.2.1 scottr waa.accesscookie = sc;
248 1.1.2.1 scottr
249 1.1.2.1 scottr config_found(self, &waa, wsemuldisplaydevprint);
250 1.1.2.1 scottr }
251 1.1.2.1 scottr
252 1.1.2.1 scottr
253 1.1.2.1 scottr int
254 1.1.2.1 scottr macfb_ioctl(v, cmd, data, flag, p)
255 1.1.2.1 scottr void *v;
256 1.1.2.1 scottr u_long cmd;
257 1.1.2.1 scottr caddr_t data;
258 1.1.2.1 scottr int flag;
259 1.1.2.1 scottr struct proc *p;
260 1.1.2.1 scottr {
261 1.1.2.1 scottr struct macfb_softc *sc = v;
262 1.1.2.1 scottr struct macfb_devconfig *dc = sc->sc_dc;
263 1.1.2.1 scottr struct wsdisplay_fbinfo *wdf;
264 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_GRF
265 1.1.2.2 scottr struct grfinfo *gd;
266 1.1.2.2 scottr struct grfmode *gm;
267 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_GRF */
268 1.1.2.1 scottr
269 1.1.2.1 scottr switch (cmd) {
270 1.1.2.1 scottr case WSDISPLAYIO_GTYPE:
271 1.1.2.1 scottr *(int *)data = dc->dc_type;
272 1.1.2.1 scottr return 0;
273 1.1.2.1 scottr
274 1.1.2.1 scottr case WSDISPLAYIO_GINFO:
275 1.1.2.2 scottr wdf = (struct wsdisplay_fbinfo *)data;
276 1.1.2.2 scottr wdf->height = dc->dc_raster.height;
277 1.1.2.2 scottr wdf->width = dc->dc_raster.width;
278 1.1.2.2 scottr wdf->depth = dc->dc_raster.depth;
279 1.1.2.1 scottr wdf->cmsize = 256;
280 1.1.2.1 scottr return 0;
281 1.1.2.1 scottr
282 1.1.2.1 scottr case WSDISPLAYIO_GCURMAX:
283 1.1.2.1 scottr case WSDISPLAYIO_GCURPOS:
284 1.1.2.1 scottr case WSDISPLAYIO_GCURSOR:
285 1.1.2.1 scottr case WSDISPLAYIO_GETCMAP:
286 1.1.2.1 scottr case WSDISPLAYIO_GVIDEO:
287 1.1.2.1 scottr case WSDISPLAYIO_PUTCMAP:
288 1.1.2.1 scottr case WSDISPLAYIO_SCURPOS:
289 1.1.2.1 scottr case WSDISPLAYIO_SCURSOR:
290 1.1.2.1 scottr case WSDISPLAYIO_SVIDEO:
291 1.1.2.1 scottr /* NONE of these operations are supported. */
292 1.1.2.1 scottr return ENOTTY;
293 1.1.2.2 scottr
294 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_ITE
295 1.1.2.2 scottr case ITEIOC_GETBELL:
296 1.1.2.2 scottr case ITEIOC_SETBELL:
297 1.1.2.2 scottr case ITEIOC_RINGBELL:
298 1.1.2.2 scottr /* NONE of these operations are supported. */
299 1.1.2.2 scottr return ENOTTY;
300 1.1.2.2 scottr
301 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_ITE */
302 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_GRF
303 1.1.2.2 scottr case GRFIOCGINFO:
304 1.1.2.2 scottr gd = (struct grfinfo *)data;
305 1.1.2.2 scottr bzero(gd, sizeof(struct grfinfo));
306 1.1.2.2 scottr gd->gd_fbaddr = (caddr_t)dc->dc_paddr;
307 1.1.2.2 scottr gd->gd_fbsize = dc->dc_size;
308 1.1.2.2 scottr gd->gd_colors = (short)(1 << dc->dc_depth);
309 1.1.2.2 scottr gd->gd_planes = (short)dc->dc_depth;
310 1.1.2.2 scottr gd->gd_fbwidth = dc->dc_wid;
311 1.1.2.2 scottr gd->gd_fbheight = dc->dc_ht;
312 1.1.2.2 scottr gd->gd_fbrowbytes = dc->dc_rowbytes;
313 1.1.2.2 scottr gd->gd_dwidth = dc->dc_raster.width;
314 1.1.2.2 scottr gd->gd_dheight = dc->dc_raster.height;
315 1.1.2.2 scottr return 0;
316 1.1.2.2 scottr
317 1.1.2.2 scottr case GRFIOCON:
318 1.1.2.2 scottr case GRFIOCOFF:
319 1.1.2.2 scottr /* Nothing to do */
320 1.1.2.2 scottr return 0;
321 1.1.2.2 scottr
322 1.1.2.2 scottr case GRFIOCMAP:
323 1.1.2.2 scottr return macfb_grfmap(v, (caddr_t *)data, p);
324 1.1.2.2 scottr
325 1.1.2.2 scottr case GRFIOCUNMAP:
326 1.1.2.2 scottr return macfb_grfunmap(v, *(caddr_t *)data, p);
327 1.1.2.2 scottr
328 1.1.2.2 scottr case GRFIOCGMODE:
329 1.1.2.2 scottr gm = (struct grfmode *)data;
330 1.1.2.2 scottr bzero(gm, sizeof(struct grfmode));
331 1.1.2.2 scottr gm->fbbase = (char *)dc->dc_vaddr;
332 1.1.2.2 scottr gm->fbsize = dc->dc_size;
333 1.1.2.2 scottr gm->fboff = dc->dc_offset;
334 1.1.2.2 scottr gm->rowbytes = dc->dc_rowbytes;
335 1.1.2.2 scottr gm->width = dc->dc_wid;
336 1.1.2.2 scottr gm->height = dc->dc_ht;
337 1.1.2.2 scottr gm->psize = dc->dc_depth;
338 1.1.2.2 scottr return 0;
339 1.1.2.2 scottr
340 1.1.2.2 scottr case GRFIOCLISTMODES:
341 1.1.2.2 scottr case GRFIOCGETMODE:
342 1.1.2.2 scottr case GRFIOCSETMODE:
343 1.1.2.2 scottr /* NONE of these operations are (or ever were) supported. */
344 1.1.2.2 scottr return ENOTTY;
345 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_GRF */
346 1.1.2.1 scottr }
347 1.1.2.1 scottr
348 1.1.2.1 scottr return -1;
349 1.1.2.1 scottr }
350 1.1.2.1 scottr
351 1.1.2.1 scottr static int
352 1.1.2.1 scottr macfb_mmap(v, offset, prot)
353 1.1.2.1 scottr void *v;
354 1.1.2.1 scottr off_t offset;
355 1.1.2.1 scottr int prot;
356 1.1.2.1 scottr {
357 1.1.2.2 scottr struct macfb_softc *sc = v;
358 1.1.2.2 scottr struct macfb_devconfig *dc = sc->sc_dc;
359 1.1.2.2 scottr u_long addr;
360 1.1.2.1 scottr
361 1.1.2.2 scottr if (offset >= 0 &&
362 1.1.2.2 scottr offset < m68k_round_page(dc->dc_rowbytes * dc->dc_ht))
363 1.1.2.2 scottr addr = m68k_btop(dc->dc_paddr + dc->dc_offset + offset);
364 1.1.2.2 scottr else
365 1.1.2.2 scottr addr = (-1); /* XXX bogus */
366 1.1.2.2 scottr
367 1.1.2.2 scottr return (int)addr;
368 1.1.2.1 scottr }
369 1.1.2.1 scottr
370 1.1.2.1 scottr int
371 1.1.2.1 scottr macfb_alloc_screen(v, type, cookiep, curxp, curyp, defattrp)
372 1.1.2.1 scottr void *v;
373 1.1.2.1 scottr const struct wsscreen_descr *type;
374 1.1.2.1 scottr void **cookiep;
375 1.1.2.1 scottr int *curxp, *curyp;
376 1.1.2.1 scottr long *defattrp;
377 1.1.2.1 scottr {
378 1.1.2.1 scottr struct macfb_softc *sc = v;
379 1.1.2.1 scottr long defattr;
380 1.1.2.1 scottr
381 1.1.2.1 scottr if (sc->nscreens > 0)
382 1.1.2.1 scottr return (ENOMEM);
383 1.1.2.1 scottr
384 1.1.2.1 scottr *cookiep = &sc->sc_dc->dc_rcons; /* one and only for now */
385 1.1.2.1 scottr *curxp = 0;
386 1.1.2.1 scottr *curyp = 0;
387 1.1.2.1 scottr rcons_alloc_attr(&sc->sc_dc->dc_rcons, 0, 0, 0, &defattr);
388 1.1.2.1 scottr *defattrp = defattr;
389 1.1.2.1 scottr sc->nscreens++;
390 1.1.2.1 scottr return (0);
391 1.1.2.1 scottr }
392 1.1.2.1 scottr
393 1.1.2.1 scottr void
394 1.1.2.1 scottr macfb_free_screen(v, cookie)
395 1.1.2.1 scottr void *v;
396 1.1.2.1 scottr void *cookie;
397 1.1.2.1 scottr {
398 1.1.2.1 scottr struct macfb_softc *sc = v;
399 1.1.2.1 scottr
400 1.1.2.1 scottr if (sc->sc_dc == &macfb_console_dc)
401 1.1.2.1 scottr panic("cfb_free_screen: console");
402 1.1.2.1 scottr
403 1.1.2.1 scottr sc->nscreens--;
404 1.1.2.1 scottr }
405 1.1.2.1 scottr
406 1.1.2.1 scottr void
407 1.1.2.1 scottr macfb_show_screen(v, cookie)
408 1.1.2.1 scottr void *v;
409 1.1.2.1 scottr void *cookie;
410 1.1.2.1 scottr {
411 1.1.2.1 scottr }
412 1.1.2.1 scottr
413 1.1.2.1 scottr int
414 1.1.2.1 scottr macfb_cnattach(addr)
415 1.1.2.1 scottr paddr_t addr;
416 1.1.2.1 scottr {
417 1.1.2.1 scottr struct macfb_devconfig *dc = &macfb_console_dc;
418 1.1.2.1 scottr long defattr;
419 1.1.2.1 scottr
420 1.1.2.1 scottr dc->dc_vaddr = videoaddr;
421 1.1.2.1 scottr dc->dc_paddr = mac68k_vidphys;
422 1.1.2.1 scottr
423 1.1.2.1 scottr dc->dc_wid = videosize & 0xffff;
424 1.1.2.1 scottr dc->dc_ht = (videosize >> 16) & 0xffff;
425 1.1.2.1 scottr dc->dc_depth = videobitdepth;
426 1.1.2.1 scottr dc->dc_rowbytes = videorowbytes;
427 1.1.2.1 scottr
428 1.1.2.2 scottr dc->dc_size = (mac68k_vidlen > 0) ?
429 1.1.2.2 scottr mac68k_vidlen : dc->dc_ht * dc->dc_rowbytes;
430 1.1.2.2 scottr dc->dc_offset = 0;
431 1.1.2.1 scottr
432 1.1.2.1 scottr /* set up the display */
433 1.1.2.1 scottr macfb_init(&macfb_console_dc);
434 1.1.2.1 scottr
435 1.1.2.1 scottr rcons_alloc_attr(&dc->dc_rcons, 0, 0, 0, &defattr);
436 1.1.2.1 scottr
437 1.1.2.1 scottr wsdisplay_cnattach(&macfb_stdscreen, &dc->dc_rcons,
438 1.1.2.1 scottr 0, 0, defattr);
439 1.1.2.1 scottr
440 1.1.2.1 scottr macfb_consaddr = addr;
441 1.1.2.1 scottr dc->isconsole = 1;
442 1.1.2.1 scottr return (0);
443 1.1.2.1 scottr }
444 1.1.2.1 scottr
445 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_ITEFONT
446 1.1.2.1 scottr #include <mac68k/dev/6x10.h>
447 1.1.2.1 scottr
448 1.1.2.1 scottr void
449 1.1.2.2 scottr init_itefont()
450 1.1.2.1 scottr {
451 1.1.2.2 scottr static int itefont_initted = 0;
452 1.1.2.1 scottr int i, j;
453 1.1.2.1 scottr
454 1.1.2.1 scottr extern struct raster_font gallant19; /* XXX */
455 1.1.2.1 scottr
456 1.1.2.2 scottr if (itefont_initted)
457 1.1.2.2 scottr return;
458 1.1.2.2 scottr itefont_initted = 1;
459 1.1.2.2 scottr
460 1.1.2.1 scottr /* XXX but we cannot use malloc here... */
461 1.1.2.1 scottr gallant19.width = 6;
462 1.1.2.1 scottr gallant19.height = 10;
463 1.1.2.1 scottr gallant19.ascent = 0;
464 1.1.2.1 scottr
465 1.1.2.1 scottr for (i = 32; i < 128; i++) {
466 1.1.2.1 scottr u_int *p;
467 1.1.2.1 scottr
468 1.1.2.1 scottr if (gallant19.chars[i].r == NULL)
469 1.1.2.1 scottr continue;
470 1.1.2.1 scottr
471 1.1.2.1 scottr gallant19.chars[i].r->width = 6;
472 1.1.2.1 scottr gallant19.chars[i].r->height = 10;
473 1.1.2.1 scottr p = gallant19.chars[i].r->pixels;
474 1.1.2.1 scottr
475 1.1.2.1 scottr for (j = 0; j < 10; j++)
476 1.1.2.1 scottr *p++ = Font6x10[i * 10 + j] << 26;
477 1.1.2.1 scottr }
478 1.1.2.1 scottr }
479 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_ITEFONT */
480 1.1.2.2 scottr
481 1.1.2.2 scottr #ifdef WSDISPLAY_COMPAT_GRF
482 1.1.2.2 scottr int
483 1.1.2.2 scottr macfb_grfmap(v, addrp, p)
484 1.1.2.2 scottr void *v;
485 1.1.2.2 scottr caddr_t *addrp;
486 1.1.2.2 scottr struct proc *p;
487 1.1.2.2 scottr {
488 1.1.2.2 scottr struct macfb_softc *sc = v;
489 1.1.2.2 scottr struct specinfo si;
490 1.1.2.2 scottr struct vnode vn;
491 1.1.2.2 scottr u_long len;
492 1.1.2.2 scottr int error, flags;
493 1.1.2.2 scottr
494 1.1.2.2 scottr *addrp = (caddr_t)sc->sc_dc->dc_paddr;
495 1.1.2.2 scottr len = m68k_round_page(sc->sc_dc->dc_offset + sc->sc_dc->dc_size);
496 1.1.2.2 scottr flags = MAP_SHARED | MAP_FIXED;
497 1.1.2.2 scottr
498 1.1.2.2 scottr vn.v_type = VCHR; /* XXX */
499 1.1.2.2 scottr vn.v_specinfo = &si; /* XXX */
500 1.1.2.2 scottr vn.v_rdev = makedev(44,sc->sc_dev.dv_unit); /* XXX */
501 1.1.2.2 scottr
502 1.1.2.2 scottr error = uvm_mmap(&p->p_vmspace->vm_map, (vaddr_t *)addrp,
503 1.1.2.2 scottr (vsize_t)len, VM_PROT_ALL, VM_PROT_ALL, flags, (caddr_t)&vn, 0);
504 1.1.2.2 scottr
505 1.1.2.2 scottr /* Offset into page: */
506 1.1.2.2 scottr *addrp += sc->sc_dc->dc_offset;
507 1.1.2.2 scottr
508 1.1.2.2 scottr return (error);
509 1.1.2.2 scottr }
510 1.1.2.2 scottr
511 1.1.2.2 scottr int
512 1.1.2.2 scottr macfb_grfunmap(v, addr, p)
513 1.1.2.2 scottr void *v;
514 1.1.2.2 scottr caddr_t addr;
515 1.1.2.2 scottr struct proc *p;
516 1.1.2.2 scottr {
517 1.1.2.2 scottr struct macfb_softc *sc = v;
518 1.1.2.2 scottr vm_size_t size;
519 1.1.2.2 scottr int rv;
520 1.1.2.2 scottr
521 1.1.2.2 scottr addr -= sc->sc_dc->dc_offset;
522 1.1.2.2 scottr
523 1.1.2.2 scottr if (addr <= 0)
524 1.1.2.2 scottr return (-1);
525 1.1.2.2 scottr
526 1.1.2.2 scottr size = m68k_round_page(sc->sc_dc->dc_offset + sc->sc_dc->dc_size);
527 1.1.2.2 scottr
528 1.1.2.2 scottr rv = uvm_unmap(&p->p_vmspace->vm_map, (vaddr_t)addr,
529 1.1.2.2 scottr (vaddr_t)addr + size);
530 1.1.2.2 scottr
531 1.1.2.2 scottr return (rv == KERN_SUCCESS ? 0 : EINVAL);
532 1.1.2.2 scottr }
533 1.1.2.2 scottr #endif /* WSDISPLAY_COMPAT_GRF */
534