grf_obio.c revision 1.4 1 1.4 briggs /* $NetBSD: grf_obio.c,v 1.4 1995/07/04 18:55:23 briggs Exp $ */
2 1.1 briggs
3 1.1 briggs /*
4 1.1 briggs * Copyright (c) 1995 Allen Briggs. All rights reserved.
5 1.1 briggs *
6 1.1 briggs * Redistribution and use in source and binary forms, with or without
7 1.1 briggs * modification, are permitted provided that the following conditions
8 1.1 briggs * are met:
9 1.1 briggs * 1. Redistributions of source code must retain the above copyright
10 1.1 briggs * notice, this list of conditions and the following disclaimer.
11 1.1 briggs * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 briggs * notice, this list of conditions and the following disclaimer in the
13 1.1 briggs * documentation and/or other materials provided with the distribution.
14 1.1 briggs * 3. All advertising materials mentioning features or use of this software
15 1.1 briggs * must display the following acknowledgement:
16 1.1 briggs * This product includes software developed by Allen Briggs.
17 1.1 briggs * 4. The name of the author may not be used to endorse or promote products
18 1.1 briggs * derived from this software without specific prior written permission.
19 1.1 briggs *
20 1.1 briggs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 briggs * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 briggs * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 briggs * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 briggs * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 briggs * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 briggs * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 briggs * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 briggs * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 briggs * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 briggs */
31 1.1 briggs /*
32 1.1 briggs * Graphics display driver for the Macintosh internal video for machines
33 1.1 briggs * that don't map it into a fake nubus card.
34 1.1 briggs */
35 1.1 briggs
36 1.1 briggs #include <sys/param.h>
37 1.1 briggs
38 1.1 briggs #include <sys/device.h>
39 1.1 briggs #include <sys/ioctl.h>
40 1.1 briggs #include <sys/file.h>
41 1.1 briggs #include <sys/malloc.h>
42 1.1 briggs #include <sys/mman.h>
43 1.1 briggs #include <sys/proc.h>
44 1.1 briggs
45 1.1 briggs #include <machine/grfioctl.h>
46 1.1 briggs #include <machine/cpu.h>
47 1.1 briggs
48 1.1 briggs #include "nubus.h"
49 1.1 briggs #include "grfvar.h"
50 1.1 briggs
51 1.1 briggs extern int grfiv_probe __P((struct grf_softc *sc, nubus_slot *ignore));
52 1.1 briggs extern int grfiv_init __P((struct grf_softc *sc));
53 1.1 briggs extern int grfiv_mode __P((struct grf_softc *sc, int cmd, void *arg));
54 1.1 briggs
55 1.1 briggs extern int
56 1.2 briggs grfiv_probe(sc, slotinfo)
57 1.1 briggs struct grf_softc *sc;
58 1.2 briggs nubus_slot *slotinfo;
59 1.1 briggs {
60 1.4 briggs extern u_long int_video_start;
61 1.4 briggs extern u_int32_t mac68k_vidlog;
62 1.1 briggs
63 1.4 briggs if (int_video_start == 0 && mac68k_vidlog == 0) {
64 1.1 briggs return 0;
65 1.2 briggs }
66 1.2 briggs if (slotinfo->slot < 0xe) {
67 1.2 briggs if (NUBUS_SLOT_TO_BASE(slotinfo->slot) > int_video_start)
68 1.2 briggs return 0;
69 1.2 briggs if (NUBUS_SLOT_TO_BASE(slotinfo->slot + 1) <= int_video_start)
70 1.2 briggs return 0;
71 1.1 briggs }
72 1.1 briggs return 1;
73 1.1 briggs }
74 1.1 briggs
75 1.1 briggs extern int
76 1.1 briggs grfiv_init(sc)
77 1.1 briggs struct grf_softc *sc;
78 1.1 briggs {
79 1.1 briggs struct grfmode *gm;
80 1.1 briggs int i, j;
81 1.1 briggs
82 1.1 briggs sc->card_id = 0;
83 1.1 briggs
84 1.1 briggs strcpy(sc->card_name, "Internal video");
85 1.1 briggs
86 1.1 briggs gm = &(sc->curr_mode);
87 1.1 briggs gm->mode_id = 0;
88 1.1 briggs gm->psize = 1;
89 1.1 briggs gm->ptype = 0;
90 1.1 briggs gm->width = 640; /* XXX */
91 1.1 briggs gm->height = 480; /* XXX */
92 1.1 briggs gm->rowbytes = 80; /* XXX Hack */
93 1.1 briggs gm->hres = 80; /* XXX Hack */
94 1.1 briggs gm->vres = 80; /* XXX Hack */
95 1.1 briggs gm->fbsize = gm->width * gm->height;
96 1.1 briggs gm->fbbase = (caddr_t) 0;
97 1.3 briggs gm->fboff = 0;
98 1.1 briggs
99 1.1 briggs return 1;
100 1.1 briggs }
101 1.1 briggs
102 1.1 briggs extern int
103 1.1 briggs grfiv_mode(sc, cmd, arg)
104 1.1 briggs struct grf_softc *sc;
105 1.1 briggs int cmd;
106 1.1 briggs void *arg;
107 1.1 briggs {
108 1.4 briggs switch (cmd) {
109 1.4 briggs case GM_GRFON:
110 1.4 briggs case GM_GRFOFF:
111 1.4 briggs return 0;
112 1.4 briggs case GM_CURRMODE:
113 1.4 briggs break;
114 1.4 briggs case GM_NEWMODE:
115 1.4 briggs break;
116 1.4 briggs case GM_LISTMODES:
117 1.4 briggs break;
118 1.4 briggs }
119 1.4 briggs return EINVAL;
120 1.1 briggs }
121