sti_machdep.c revision 1.7.4.2 1 1.7.4.2 perseant /* $NetBSD: sti_machdep.c,v 1.7.4.2 2025/08/02 05:55:38 perseant Exp $ */
2 1.7.4.2 perseant /* $OpenBSD: sti_sgc.c,v 1.14 2007/05/26 00:36:03 krw Exp $ */
3 1.7.4.2 perseant
4 1.7.4.2 perseant /*
5 1.7.4.2 perseant * Copyright (c) 2005, Miodrag Vallat
6 1.7.4.2 perseant *
7 1.7.4.2 perseant * Redistribution and use in source and binary forms, with or without
8 1.7.4.2 perseant * modification, are permitted provided that the following conditions
9 1.7.4.2 perseant * are met:
10 1.7.4.2 perseant * 1. Redistributions of source code must retain the above copyright
11 1.7.4.2 perseant * notice, this list of conditions and the following disclaimer.
12 1.7.4.2 perseant * 2. Redistributions in binary form must reproduce the above copyright
13 1.7.4.2 perseant * notice, this list of conditions and the following disclaimer in the
14 1.7.4.2 perseant * documentation and/or other materials provided with the distribution.
15 1.7.4.2 perseant *
16 1.7.4.2 perseant * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.7.4.2 perseant * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 1.7.4.2 perseant * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 1.7.4.2 perseant * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 1.7.4.2 perseant * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 1.7.4.2 perseant * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 1.7.4.2 perseant * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.7.4.2 perseant * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 1.7.4.2 perseant * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 1.7.4.2 perseant * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.7.4.2 perseant * POSSIBILITY OF SUCH DAMAGE.
27 1.7.4.2 perseant *
28 1.7.4.2 perseant */
29 1.7.4.2 perseant /*-
30 1.7.4.2 perseant * Copyright (c) 2020, 2025 Izumi Tsutsui. All rights reserved.
31 1.7.4.2 perseant *
32 1.7.4.2 perseant * Redistribution and use in source and binary forms, with or without
33 1.7.4.2 perseant * modification, are permitted provided that the following conditions
34 1.7.4.2 perseant * are met:
35 1.7.4.2 perseant * 1. Redistributions of source code must retain the above copyright
36 1.7.4.2 perseant * notice, this list of conditions and the following disclaimer.
37 1.7.4.2 perseant * 2. Redistributions in binary form must reproduce the above copyright
38 1.7.4.2 perseant * notice, this list of conditions and the following disclaimer in the
39 1.7.4.2 perseant * documentation and/or other materials provided with the distribution.
40 1.7.4.2 perseant *
41 1.7.4.2 perseant * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 1.7.4.2 perseant * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 1.7.4.2 perseant * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 1.7.4.2 perseant * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
45 1.7.4.2 perseant * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 1.7.4.2 perseant * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 1.7.4.2 perseant * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 1.7.4.2 perseant * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 1.7.4.2 perseant * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
50 1.7.4.2 perseant * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 1.7.4.2 perseant */
52 1.7.4.2 perseant
53 1.7.4.2 perseant #include <sys/cdefs.h>
54 1.7.4.2 perseant __KERNEL_RCSID(0, "$NetBSD: sti_machdep.c,v 1.7.4.2 2025/08/02 05:55:38 perseant Exp $");
55 1.7.4.2 perseant
56 1.7.4.2 perseant #include <sys/param.h>
57 1.7.4.2 perseant #include <sys/device.h>
58 1.7.4.2 perseant #include <sys/bus.h>
59 1.7.4.2 perseant
60 1.7.4.2 perseant #include <dev/wscons/wsconsio.h>
61 1.7.4.2 perseant
62 1.7.4.2 perseant #include <hp300/dev/sti_machdep.h>
63 1.7.4.2 perseant
64 1.7.4.2 perseant /*
65 1.7.4.2 perseant * 425e and 362/382 EVRX specific hardware
66 1.7.4.2 perseant */
67 1.7.4.2 perseant /*
68 1.7.4.2 perseant * RAMDAC (Bt458) on 425e EVRX is found at offset 0x00060000 from SGC bus PA.
69 1.7.4.2 perseant * RAMDAC (Bt474) on 362/382 EVRX is also found at offset 0x00060000
70 1.7.4.2 perseant * from DIO scode (132) + STI_DIO_SCODE_OFFSET PA (i.e. 0x01800000).
71 1.7.4.2 perseant *
72 1.7.4.2 perseant * Offset 0x040000 length 0x1c0000 is mapped in MI sti via ROM region 2
73 1.7.4.2 perseant * on both 425e and 362/382.
74 1.7.4.2 perseant */
75 1.7.4.2 perseant #define STI_EVRX_REGNO2OFFSET 0x00020000 /* 0x00060000 - 0x00040000 */
76 1.7.4.2 perseant
77 1.7.4.2 perseant /* bitmap memory can be accessed at offset +0x200000 */
78 1.7.4.2 perseant #define STI_EVRX_FBOFFSET 0x00200000
79 1.7.4.2 perseant
80 1.7.4.2 perseant #define EVRX_BT458_ADDR (STI_EVRX_REGNO2OFFSET + 0x200 + 2)
81 1.7.4.2 perseant #define EVRX_BT458_CMAP (STI_EVRX_REGNO2OFFSET + 0x204 + 2)
82 1.7.4.2 perseant #define EVRX_BT458_CTRL (STI_EVRX_REGNO2OFFSET + 0x208 + 2)
83 1.7.4.2 perseant #define EVRX_BT458_OMAP (STI_EVRX_REGNO2OFFSET + 0x20C + 2)
84 1.7.4.2 perseant
85 1.7.4.2 perseant /* These registers are partially common between Bt474 and Bt458 */
86 1.7.4.2 perseant #define EVRX_BT4xx_ADDR EVRX_BT458_ADDR
87 1.7.4.2 perseant #define EVRX_BT4xx_CMAP EVRX_BT458_CMAP
88 1.7.4.2 perseant #define EVRX_BT4xx_CTRL EVRX_BT458_CTRL
89 1.7.4.2 perseant
90 1.7.4.2 perseant /* from HP-UX /usr/lib/libddevrx.a */
91 1.7.4.2 perseant #define EVRX_MAGIC00 (STI_EVRX_REGNO2OFFSET + 0x600)
92 1.7.4.2 perseant #define EVRX_MAGIC04 (STI_EVRX_REGNO2OFFSET + 0x604)
93 1.7.4.2 perseant #define EVRX_MAGIC08 (STI_EVRX_REGNO2OFFSET + 0x608)
94 1.7.4.2 perseant #define EVRX_MAGIC0C (STI_EVRX_REGNO2OFFSET + 0x60c)
95 1.7.4.2 perseant #define EVRX_MAGIC10 (STI_EVRX_REGNO2OFFSET + 0x610)
96 1.7.4.2 perseant #define EVRX_MAGIC10_BSY 0x00010000
97 1.7.4.2 perseant #define EVRX_MAGIC18 (STI_EVRX_REGNO2OFFSET + 0x618)
98 1.7.4.2 perseant #define EVRX_MAGIC1C (STI_EVRX_REGNO2OFFSET + 0x61c)
99 1.7.4.2 perseant
100 1.7.4.2 perseant /*
101 1.7.4.2 perseant * HP A1659A CRX specific hardware
102 1.7.4.2 perseant */
103 1.7.4.2 perseant /* bitmap memory can be accessed at offset +0x1000000 */
104 1.7.4.2 perseant #define STI_CRX_FBOFFSET 0x01000000
105 1.7.4.2 perseant
106 1.7.4.2 perseant /* hp300 EVRX and CRX specific access functions */
107 1.7.4.2 perseant static int sti_evrx_putcmap(struct sti_screen *, u_int, u_int);
108 1.7.4.2 perseant static void sti_evrx_resetramdac(struct sti_screen *);
109 1.7.4.2 perseant static void sti_evrx_resetcmap(struct sti_screen *);
110 1.7.4.2 perseant static void sti_evrx_setupfb(struct sti_screen *);
111 1.7.4.2 perseant static paddr_t sti_m68k_mmap(void *, void *, off_t, int);
112 1.7.4.2 perseant
113 1.7.4.2 perseant static struct bus_space_tag sticn_tag;
114 1.7.4.2 perseant static struct sti_rom sticn_rom;
115 1.7.4.2 perseant static struct sti_screen sticn_scr;
116 1.7.4.2 perseant static bus_addr_t sticn_bases[STI_REGION_MAX];
117 1.7.4.2 perseant
118 1.7.4.2 perseant static const struct wsdisplay_accessops sti_m68k_accessops = {
119 1.7.4.2 perseant .ioctl = sti_ioctl,
120 1.7.4.2 perseant .mmap = sti_m68k_mmap,
121 1.7.4.2 perseant .alloc_screen = sti_alloc_screen,
122 1.7.4.2 perseant .free_screen = sti_free_screen,
123 1.7.4.2 perseant .show_screen = sti_show_screen,
124 1.7.4.2 perseant .load_font = sti_load_font
125 1.7.4.2 perseant };
126 1.7.4.2 perseant
127 1.7.4.2 perseant void
128 1.7.4.2 perseant sti_machdep_attach_console(struct sti_machdep_softc *sc)
129 1.7.4.2 perseant {
130 1.7.4.2 perseant struct sti_softc *ssc = &sc->sc_sti;
131 1.7.4.2 perseant
132 1.7.4.2 perseant ssc->sc_flags |= STI_CONSOLE | STI_ATTACHED;
133 1.7.4.2 perseant ssc->sc_rom = &sticn_rom;
134 1.7.4.2 perseant ssc->sc_rom->rom_softc = ssc;
135 1.7.4.2 perseant ssc->sc_scr = &sticn_scr;
136 1.7.4.2 perseant ssc->sc_scr->scr_rom = ssc->sc_rom;
137 1.7.4.2 perseant memcpy(ssc->bases, sticn_bases, sizeof(ssc->bases));
138 1.7.4.2 perseant
139 1.7.4.2 perseant sti_describe(ssc);
140 1.7.4.2 perseant }
141 1.7.4.2 perseant
142 1.7.4.2 perseant void
143 1.7.4.2 perseant sti_machdep_attach(struct sti_machdep_softc *sc)
144 1.7.4.2 perseant {
145 1.7.4.2 perseant struct sti_softc *ssc = &sc->sc_sti;
146 1.7.4.2 perseant struct sti_screen *scr;
147 1.7.4.2 perseant paddr_t base = sc->sc_base;
148 1.7.4.2 perseant struct wsemuldisplaydev_attach_args waa;
149 1.7.4.2 perseant struct sti_dd *rom_dd;
150 1.7.4.2 perseant uint32_t grid0;
151 1.7.4.2 perseant
152 1.7.4.2 perseant /* Identify the board model by dd_grid */
153 1.7.4.2 perseant rom_dd = &ssc->sc_rom->rom_dd;
154 1.7.4.2 perseant grid0 = rom_dd->dd_grid[0];
155 1.7.4.2 perseant scr = ssc->sc_scr;
156 1.7.4.2 perseant
157 1.7.4.2 perseant switch (grid0) {
158 1.7.4.2 perseant case STI_DD_EVRX:
159 1.7.4.2 perseant case STI_DD_382C:
160 1.7.4.2 perseant case STI_DD_3X2V:
161 1.7.4.2 perseant /*
162 1.7.4.2 perseant * 425e and 362/382 on-board EVRX framebuffer.
163 1.7.4.2 perseant */
164 1.7.4.2 perseant sc->sc_bitmap = base + STI_EVRX_FBOFFSET;
165 1.7.4.2 perseant
166 1.7.4.2 perseant /*
167 1.7.4.2 perseant * initialize Bt458/474 RAMDAC and preserve initial color map
168 1.7.4.2 perseant */
169 1.7.4.2 perseant sti_evrx_resetramdac(scr);
170 1.7.4.2 perseant sti_evrx_resetcmap(scr);
171 1.7.4.2 perseant scr->setupfb = sti_evrx_setupfb;
172 1.7.4.2 perseant scr->putcmap = sti_evrx_putcmap;
173 1.7.4.2 perseant break;
174 1.7.4.2 perseant
175 1.7.4.2 perseant case STI_DD_CRX:
176 1.7.4.2 perseant /*
177 1.7.4.2 perseant * HP A1659A CRX on some 425t variants.
178 1.7.4.2 perseant */
179 1.7.4.2 perseant sc->sc_bitmap = base + STI_CRX_FBOFFSET;
180 1.7.4.2 perseant break;
181 1.7.4.2 perseant
182 1.7.4.2 perseant default:
183 1.7.4.2 perseant /*
184 1.7.4.2 perseant * Unsupported variants.
185 1.7.4.2 perseant * Use default common sti(4) attachment (no bitmap support).
186 1.7.4.2 perseant */
187 1.7.4.2 perseant sti_end_attach(ssc);
188 1.7.4.2 perseant return;
189 1.7.4.2 perseant }
190 1.7.4.2 perseant
191 1.7.4.2 perseant aprint_normal_dev(ssc->sc_dev, "Enable mmap support\n");
192 1.7.4.2 perseant
193 1.7.4.2 perseant scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;
194 1.7.4.2 perseant waa.console = ssc->sc_flags & STI_CONSOLE ? 1 : 0;
195 1.7.4.2 perseant waa.scrdata = &scr->scr_screenlist;
196 1.7.4.2 perseant waa.accessops = &sti_m68k_accessops;
197 1.7.4.2 perseant waa.accesscookie = scr;
198 1.7.4.2 perseant
199 1.7.4.2 perseant config_found(ssc->sc_dev, &waa, wsemuldisplaydevprint,
200 1.7.4.2 perseant CFARGS_NONE);
201 1.7.4.2 perseant }
202 1.7.4.2 perseant
203 1.7.4.2 perseant static int
204 1.7.4.2 perseant sti_evrx_putcmap(struct sti_screen *scr, u_int index, u_int count)
205 1.7.4.2 perseant {
206 1.7.4.2 perseant struct sti_rom *rom = scr->scr_rom;
207 1.7.4.2 perseant bus_space_tag_t bst = rom->memt;
208 1.7.4.2 perseant bus_space_handle_t bsh = rom->regh[2];
209 1.7.4.2 perseant int i;
210 1.7.4.2 perseant
211 1.7.4.2 perseant /* magic setup from HP-UX */
212 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC08, 0x00000001);
213 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC00, 0x00000001);
214 1.7.4.2 perseant for (i = index; i < index + count; i++) {
215 1.7.4.2 perseant /* this is what HP-UX woodDownloadCmap() does */
216 1.7.4.2 perseant while ((bus_space_read_4(bst, bsh, EVRX_MAGIC10) &
217 1.7.4.2 perseant EVRX_MAGIC10_BSY) != 0)
218 1.7.4.2 perseant continue;
219 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT4xx_ADDR, i);
220 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT4xx_CMAP, scr->scr_rcmap[i]);
221 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT4xx_CMAP, scr->scr_gcmap[i]);
222 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC10, scr->scr_bcmap[i]);
223 1.7.4.2 perseant }
224 1.7.4.2 perseant return 0;
225 1.7.4.2 perseant }
226 1.7.4.2 perseant
227 1.7.4.2 perseant static void
228 1.7.4.2 perseant sti_evrx_resetramdac(struct sti_screen *scr)
229 1.7.4.2 perseant {
230 1.7.4.2 perseant struct sti_rom *rom = scr->scr_rom;
231 1.7.4.2 perseant bus_space_tag_t bst = rom->memt;
232 1.7.4.2 perseant bus_space_handle_t bsh = rom->regh[2];
233 1.7.4.2 perseant #if 0
234 1.7.4.2 perseant int i;
235 1.7.4.2 perseant #endif
236 1.7.4.2 perseant
237 1.7.4.2 perseant /*
238 1.7.4.2 perseant * Initialize the Bt458. When we write to control registers,
239 1.7.4.2 perseant * the address is not incremented automatically. So we specify
240 1.7.4.2 perseant * it ourselves for each control register.
241 1.7.4.2 perseant */
242 1.7.4.2 perseant
243 1.7.4.2 perseant /* all planes will be read */
244 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT4xx_ADDR, 0x04);
245 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT4xx_CTRL, 0xff);
246 1.7.4.2 perseant
247 1.7.4.2 perseant #if 0
248 1.7.4.2 perseant /*
249 1.7.4.2 perseant * HP-UX woodInitializeHardware() doesn't touch these
250 1.7.4.2 perseant * Bt458 specific registers. Maybe initialized by STI ROM?
251 1.7.4.2 perseant */
252 1.7.4.2 perseant /* all planes have non-blink */
253 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x05);
254 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_CTRL, 0x00);
255 1.7.4.2 perseant
256 1.7.4.2 perseant /* palette enabled, ovly plane disabled */
257 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x06);
258 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_CTRL, 0x40);
259 1.7.4.2 perseant
260 1.7.4.2 perseant /* no test mode */
261 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x07);
262 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_CTRL, 0x00);
263 1.7.4.2 perseant #endif
264 1.7.4.2 perseant
265 1.7.4.2 perseant /* magic initialization from HP-UX woodInitializeHardware() */
266 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC00, 0x00000001);
267 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC04, 0x00000001);
268 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC08, 0x00000001);
269 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC0C, 0x00000001);
270 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC18, 0xFFFFFFFF);
271 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC1C, 0x00000000);
272 1.7.4.2 perseant
273 1.7.4.2 perseant #if 0
274 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x00);
275 1.7.4.2 perseant for (i = 0; i < 4; i++) {
276 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_OMAP, 0x00);
277 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_OMAP, 0x00);
278 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_OMAP, 0x00);
279 1.7.4.2 perseant }
280 1.7.4.2 perseant #endif
281 1.7.4.2 perseant }
282 1.7.4.2 perseant
283 1.7.4.2 perseant static void
284 1.7.4.2 perseant sti_evrx_resetcmap(struct sti_screen *scr)
285 1.7.4.2 perseant {
286 1.7.4.2 perseant struct sti_rom *rom = scr->scr_rom;
287 1.7.4.2 perseant bus_space_tag_t bst = rom->memt;
288 1.7.4.2 perseant bus_space_handle_t bsh = rom->regh[2];
289 1.7.4.2 perseant int i;
290 1.7.4.2 perseant
291 1.7.4.2 perseant /* magic setup from HP-UX */
292 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC08, 0x00000001);
293 1.7.4.2 perseant bus_space_write_4(bst, bsh, EVRX_MAGIC00, 0x00000001);
294 1.7.4.2 perseant
295 1.7.4.2 perseant /* preserve palette values initialized by STI firmware */
296 1.7.4.2 perseant for (i = 0; i < STI_NCMAP; i++) {
297 1.7.4.2 perseant /* this is what HP-UX woodUploadCmap() does */
298 1.7.4.2 perseant while ((bus_space_read_4(bst, bsh, EVRX_MAGIC10) &
299 1.7.4.2 perseant EVRX_MAGIC10_BSY) != 0)
300 1.7.4.2 perseant continue;
301 1.7.4.2 perseant bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, i);
302 1.7.4.2 perseant scr->scr_rcmap[i] = bus_space_read_1(bst, bsh, EVRX_BT4xx_CMAP);
303 1.7.4.2 perseant scr->scr_gcmap[i] = bus_space_read_1(bst, bsh, EVRX_BT4xx_CMAP);
304 1.7.4.2 perseant scr->scr_bcmap[i] = bus_space_read_1(bst, bsh, EVRX_BT4xx_CMAP);
305 1.7.4.2 perseant }
306 1.7.4.2 perseant }
307 1.7.4.2 perseant
308 1.7.4.2 perseant static void
309 1.7.4.2 perseant sti_evrx_setupfb(struct sti_screen *scr)
310 1.7.4.2 perseant {
311 1.7.4.2 perseant
312 1.7.4.2 perseant sti_init(scr, 0);
313 1.7.4.2 perseant sti_evrx_resetramdac(scr);
314 1.7.4.2 perseant }
315 1.7.4.2 perseant
316 1.7.4.2 perseant static paddr_t
317 1.7.4.2 perseant sti_m68k_mmap(void *v, void *vs, off_t offset, int prot)
318 1.7.4.2 perseant {
319 1.7.4.2 perseant struct sti_screen *scr = (struct sti_screen *)v;
320 1.7.4.2 perseant struct sti_rom *rom = scr->scr_rom;
321 1.7.4.2 perseant struct sti_softc *ssc = rom->rom_softc;
322 1.7.4.2 perseant struct sti_machdep_softc *sc = device_private(ssc->sc_dev);
323 1.7.4.2 perseant paddr_t cookie = -1;
324 1.7.4.2 perseant
325 1.7.4.2 perseant if ((offset & PAGE_MASK) != 0)
326 1.7.4.2 perseant return -1;
327 1.7.4.2 perseant
328 1.7.4.2 perseant switch (scr->scr_wsmode) {
329 1.7.4.2 perseant case WSDISPLAYIO_MODE_MAPPED:
330 1.7.4.2 perseant /* not implemented yet; what should be shown? */
331 1.7.4.2 perseant break;
332 1.7.4.2 perseant case WSDISPLAYIO_MODE_DUMBFB:
333 1.7.4.2 perseant if (offset >= 0 && offset < (scr->fbwidth * scr->fbheight))
334 1.7.4.2 perseant cookie = m68k_btop(sc->sc_bitmap + offset);
335 1.7.4.2 perseant break;
336 1.7.4.2 perseant default:
337 1.7.4.2 perseant break;
338 1.7.4.2 perseant }
339 1.7.4.2 perseant
340 1.7.4.2 perseant return cookie;
341 1.7.4.2 perseant }
342 1.7.4.2 perseant
343 1.7.4.2 perseant void
344 1.7.4.2 perseant sti_machdep_cnattach(bus_space_tag_t bst, paddr_t base)
345 1.7.4.2 perseant {
346 1.7.4.2 perseant int i;
347 1.7.4.2 perseant
348 1.7.4.2 perseant sticn_tag = *bst;
349 1.7.4.2 perseant
350 1.7.4.2 perseant /* sticn_bases[0] will be fixed in sti_cnattach() */
351 1.7.4.2 perseant for (i = 0; i < STI_REGION_MAX; i++)
352 1.7.4.2 perseant sticn_bases[i] = (bus_addr_t)base;
353 1.7.4.2 perseant
354 1.7.4.2 perseant sti_cnattach(&sticn_rom, &sticn_scr, &sticn_tag, sticn_bases,
355 1.7.4.2 perseant STI_CODEBASE_M68K);
356 1.7.4.2 perseant }
357