qv.c revision 1.32 1 1.32 msaitoh /*$Header: /tank/opengrok/rsync2/NetBSD/src/sys/arch/vax/uba/qv.c,v 1.32 2016/07/07 06:55:39 msaitoh Exp $*/
2 1.31 matt /*
3 1.31 matt * Copyright (c) 2015 Charles H. Dickman. All rights reserved.
4 1.31 matt * Derived from smg.c
5 1.31 matt * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
6 1.31 matt * All rights reserved.
7 1.1 jonathan *
8 1.1 jonathan * Redistribution and use in source and binary forms, with or without
9 1.1 jonathan * modification, are permitted provided that the following conditions
10 1.1 jonathan * are met:
11 1.1 jonathan * 1. Redistributions of source code must retain the above copyright
12 1.1 jonathan * notice, this list of conditions and the following disclaimer.
13 1.1 jonathan * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 jonathan * notice, this list of conditions and the following disclaimer in the
15 1.1 jonathan * documentation and/or other materials provided with the distribution.
16 1.31 matt * 3. All advertising materials mentioning features or use of this software
17 1.31 matt * must display the following acknowledgement:
18 1.31 matt * This product includes software developed at Ludd, University of
19 1.31 matt * Lule}, Sweden and its contributors.
20 1.31 matt * 4. The name of the author may not be used to endorse or promote products
21 1.31 matt * derived from this software without specific prior written permission
22 1.1 jonathan *
23 1.31 matt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.31 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.31 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.31 matt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.31 matt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.31 matt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.31 matt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.31 matt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.31 matt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.31 matt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1 jonathan */
34 1.31 matt /* 1 2 3 4 5 6 7 */
35 1.31 matt /*3456789012345678901234567890123456789012345678901234567890123456789012345678*/
36 1.31 matt
37 1.31 matt #include <sys/cdefs.h>
38 1.32 msaitoh __KERNEL_RCSID(0, "$Header: /tank/opengrok/rsync2/NetBSD/src/sys/arch/vax/uba/qv.c,v 1.32 2016/07/07 06:55:39 msaitoh Exp $");
39 1.31 matt
40 1.31 matt #include <sys/param.h>
41 1.31 matt #include <sys/systm.h>
42 1.31 matt #include <sys/callout.h>
43 1.31 matt #include <sys/conf.h>
44 1.31 matt #include <sys/cpu.h>
45 1.31 matt #include <sys/device.h>
46 1.31 matt #include <sys/kernel.h>
47 1.31 matt #include <sys/malloc.h>
48 1.31 matt #include <sys/extent.h> /***/
49 1.31 matt #include <sys/time.h>
50 1.31 matt #include <sys/bus.h>
51 1.31 matt #include <vax/include/pte.h> /* temporary */
52 1.31 matt #include <machine/sid.h>
53 1.31 matt #include <dev/cons.h>
54 1.31 matt #include <dev/qbus/ubavar.h>
55 1.31 matt #include <dev/wscons/wsdisplayvar.h>
56 1.31 matt #include <dev/wscons/wsconsio.h>
57 1.31 matt #include <dev/wscons/wscons_callbacks.h>
58 1.31 matt #include <dev/wsfont/wsfont.h>
59 1.31 matt #include <dev/wsfb/genfbvar.h>
60 1.31 matt #include <vax/include/sgmap.h> /***/
61 1.31 matt
62 1.31 matt #include "uba_common.h" /***/
63 1.31 matt #include "qv.h"
64 1.31 matt #include "qv_ic.h"
65 1.31 matt #include "qvaux.h"
66 1.31 matt #include "opt_wsfont.h"
67 1.31 matt
68 1.31 matt #define QMEMBASE 0x30000000
69 1.31 matt #define QVSIZE 0x40000
70 1.31 matt #define QV_SCANMAP 0x3F800
71 1.31 matt #define QV_CURSRAM 0x3FFE0
72 1.31 matt
73 1.31 matt #define QV_CSR 0
74 1.31 matt #define QV_CSR_1 (1 << 2)
75 1.31 matt #define QV_CSR_2 (1 << 3)
76 1.31 matt #define QV_CSR_BANK (15 << 11)
77 1.31 matt #define QV_CUR_X 2
78 1.31 matt #define QV_CRTC_AR 8
79 1.31 matt #define QV_CRTC_DR 10
80 1.31 matt #define QV_IC 12
81 1.31 matt #define QV_ICDR QV_ICDR
82 1.31 matt #define QV_ICSR (QV_ICDR + 2)
83 1.31 matt
84 1.31 matt /* Screen hardware defs */
85 1.31 matt #define QV_COLS 128 /* char width of screen */
86 1.31 matt #define QV_ROWS 57 /* rows of char on screen */
87 1.31 matt #define QV_CHEIGHT 15 /* lines a char consists of */
88 1.31 matt #define QV_NEXTROW (QV_COLS * QV_CHEIGHT)
89 1.31 matt #define QV_YWIDTH 864
90 1.31 matt #define QV_XWIDTH 1024
91 1.31 matt
92 1.31 matt /* hardware cursor */
93 1.31 matt #define CUR_BLINKN 0x00
94 1.31 matt #define CUR_BLANK 0x20
95 1.31 matt #define CUR_BLINKS 0x40
96 1.31 matt #define CUR_BLINKF 0x60
97 1.31 matt #define CUR_BLINKM 0x60
98 1.31 matt #define CUR_OFF CUR_BLANK
99 1.31 matt #define CUR_ON CUR_BLINKS
100 1.31 matt #define CUR_START 10
101 1.31 matt #define CUR_END 11
102 1.31 matt #define CUR_HI 14
103 1.31 matt #define CUR_LO 15
104 1.31 matt
105 1.31 matt //static uint16_t curcmd, curx, cury, hotX, hotY;
106 1.32 msaitoh static int bgmask, fgmask;
107 1.31 matt
108 1.31 matt static int qv_match(device_t, cfdata_t, void *);
109 1.31 matt static void qv_attach(device_t, device_t, void *);
110 1.31 matt
111 1.31 matt static void qv_cursor(void *, int, int, int);
112 1.31 matt static int qv_mapchar(void *, int, unsigned int *);
113 1.31 matt static void qv_putchar(void *, int, int, u_int, long);
114 1.31 matt static void qv_copycols(void *, int, int, int,int);
115 1.31 matt static void qv_erasecols(void *, int, int, int, long);
116 1.31 matt static void qv_copyrows(void *, int, int, int);
117 1.31 matt static void qv_eraserows(void *, int, int, long);
118 1.31 matt static int qv_allocattr(void *, int, int, int, long *);
119 1.31 matt
120 1.31 matt const struct wsdisplay_emulops qv_emulops = {
121 1.31 matt .cursor = qv_cursor,
122 1.31 matt .mapchar = qv_mapchar,
123 1.31 matt .putchar = qv_putchar,
124 1.31 matt .copycols = qv_copycols,
125 1.31 matt .erasecols = qv_erasecols,
126 1.31 matt .copyrows = qv_copyrows,
127 1.31 matt .eraserows = qv_eraserows,
128 1.31 matt .allocattr = qv_allocattr
129 1.31 matt };
130 1.31 matt
131 1.31 matt struct _wsscreen_descr {
132 1.31 matt const struct wsscreen_descr qv_stdscreen; /* MUST BE FIRST */
133 1.31 matt const uint16_t qv_crtc_param[16];
134 1.31 matt };
135 1.1 jonathan
136 1.1 jonathan /*
137 1.31 matt * Notes from the original Ultrix drivers
138 1.31 matt *
139 1.31 matt * Screen controller initialization parameters. The definations [sic] and use
140 1.31 matt * of these parameters can be found in the Motorola 68045 [sic] crtc specs. In
141 1.31 matt * essence they set the display parameters for the chip. The first set is
142 1.31 matt * for the 15" screen and the second is for the 19" separate sync. There
143 1.31 matt * is also a third set for a 19" composite sync monitor which we have not
144 1.31 matt * tested and which is not supported.
145 1.1 jonathan */
146 1.1 jonathan
147 1.31 matt const struct _wsscreen_descr qv_stdscreen[] = {
148 1.31 matt { { "80x30", 80, 30, &qv_emulops, 8,
149 1.31 matt QV_CHEIGHT, WSSCREEN_UNDERLINE|WSSCREEN_REVERSE },
150 1.31 matt { 31, 25, 27, 0142, 31, 13, 30, 31, 4, 15, 040, 0, 0, 0, 0, 0 } },
151 1.31 matt { { "120x55", 120, 55, &qv_emulops, 8,
152 1.31 matt QV_CHEIGHT, WSSCREEN_UNDERLINE|WSSCREEN_REVERSE },
153 1.31 matt { 39, 30, 32, 0262, 55, 5, 54, 54, 4, 15, 040, 0, 0, 0, 0, 0 } },
154 1.31 matt { { "128x57", QV_COLS, QV_ROWS, &qv_emulops, 8,
155 1.31 matt QV_CHEIGHT, WSSCREEN_UNDERLINE|WSSCREEN_REVERSE },
156 1.31 matt { 39, 32, 33, 0264, 56, 5, 54, 54, 4, 15, 040, 0, 0, 0, 0, 0 } },
157 1.31 matt };
158 1.31 matt
159 1.31 matt const struct wsscreen_descr *_qv_scrlist[] = {
160 1.31 matt &qv_stdscreen[2].qv_stdscreen, /* default */
161 1.31 matt &qv_stdscreen[1].qv_stdscreen,
162 1.31 matt &qv_stdscreen[0].qv_stdscreen,
163 1.31 matt };
164 1.31 matt
165 1.31 matt const struct wsscreen_list qv_screenlist = {
166 1.31 matt .nscreens = __arraycount(_qv_scrlist),
167 1.31 matt .screens = _qv_scrlist,
168 1.31 matt };
169 1.31 matt
170 1.31 matt struct qv_softc {
171 1.31 matt device_t sc_dev; /* device pointer */
172 1.31 matt bus_space_tag_t sc_iot; /* register base */
173 1.31 matt bus_space_handle_t sc_ioh;
174 1.31 matt bus_space_tag_t sc_fbt; /* frame buffer base */
175 1.31 matt bus_space_handle_t sc_fbh;
176 1.31 matt paddr_t sc_fbphys; /* frame buffer phys addr */
177 1.31 matt char *sc_fb; /* frame buffer virt addr */
178 1.31 matt uint16_t *sc_scanmap; /* scan map virt addr */
179 1.31 matt char *sc_font; /* font glyph table */
180 1.31 matt
181 1.31 matt uint8_t sc_curon; /* cursor on */
182 1.31 matt uint16_t sc_curx; /* cursor x position */
183 1.31 matt uint16_t sc_cury; /* cursor y position */
184 1.31 matt uint16_t sc_curhotX; /* cursor x hot spot */
185 1.31 matt uint16_t sc_curhotY; /* cursor y hot spot */
186 1.31 matt
187 1.31 matt struct qv_screen *sc_curscr; /* current screen */
188 1.31 matt };
189 1.1 jonathan
190 1.31 matt #if 0
191 1.31 matt struct genfb_qv_softc {
192 1.31 matt struct genfb_softc sc_gen;
193 1.31 matt bus_space_tag_t sc_iot;
194 1.31 matt bus_space_handle_t sc_ioh;
195 1.31 matt uint32_t sc_wstype;
196 1.31 matt };
197 1.31 matt #endif
198 1.1 jonathan
199 1.31 matt static void qv_crtc_wr(struct qv_softc *, uint16_t, uint16_t);
200 1.31 matt static void qv_setcrtc(struct qv_softc *, const uint16_t *);
201 1.1 jonathan
202 1.31 matt static int qv_ioctl(void *, void *, u_long, void *, int, struct lwp *);
203 1.31 matt static paddr_t qv_mmap(void *, void *, off_t, int);
204 1.31 matt static int qv_alloc_screen(void *, const struct wsscreen_descr *,
205 1.31 matt void **, int *, int *, long *);
206 1.31 matt static void qv_free_screen(void *, void *);
207 1.31 matt static int qv_show_screen(void *, void *, int,
208 1.31 matt void (*) (void *, int, int), void *);
209 1.31 matt //static void qv_crsr_blink(void *);
210 1.31 matt
211 1.31 matt int qvauxprint(void *, const char *);
212 1.31 matt
213 1.31 matt const struct wsdisplay_accessops qv_accessops = {
214 1.31 matt .ioctl = qv_ioctl,
215 1.31 matt .mmap = qv_mmap,
216 1.31 matt .alloc_screen = qv_alloc_screen,
217 1.31 matt .free_screen = qv_free_screen,
218 1.31 matt .show_screen = qv_show_screen,
219 1.31 matt };
220 1.1 jonathan
221 1.31 matt struct qv_screen {
222 1.31 matt struct qv_softc *ss_sc;
223 1.31 matt const struct wsscreen_descr *ss_type;
224 1.31 matt int ss_curx;
225 1.31 matt int ss_cury;
226 1.31 matt u_char ss_image[QV_ROWS][QV_COLS]; /* Image of screen */
227 1.31 matt u_char ss_attr[QV_ROWS][QV_COLS]; /* Reversed etc... */
228 1.31 matt };
229 1.1 jonathan
230 1.31 matt static struct qv_screen qv_conscreen; /* XXX no console support */
231 1.1 jonathan
232 1.31 matt static callout_t qv_cursor_ch;
233 1.1 jonathan
234 1.31 matt CFATTACH_DECL_NEW(qv, sizeof(struct qv_softc),
235 1.31 matt qv_match, qv_attach, NULL, NULL);
236 1.31 matt #if 0
237 1.31 matt static int genfb_match_qv(device_t, cfdata_t, void *);
238 1.31 matt static void genfb_attach_qv(device_t, device_t, void *);
239 1.32 msaitoh static int genfb_ioctl_qv(void *, void *, u_long, void *, int,
240 1.32 msaitoh struct lwp*);
241 1.31 matt static paddr_t genfb_mmap_qv(void *, void *, off_t, int);
242 1.31 matt static int genfb_borrow_qv(void *, bus_addr_t, bus_space_handle_t *);
243 1.1 jonathan
244 1.31 matt CFATTACH_DECL_NEW(genfb_qv, sizeof(struct genfb_qv_softc),
245 1.31 matt genfb_match_qv, genfb_attach_qv, NULL, NULL);
246 1.31 matt #endif
247 1.1 jonathan
248 1.1 jonathan /*
249 1.31 matt * autoconf match function
250 1.1 jonathan */
251 1.31 matt int
252 1.31 matt qv_match(device_t parent, cfdata_t match, void *aux)
253 1.31 matt {
254 1.31 matt struct uba_attach_args *ua = aux;
255 1.31 matt struct uba_softc *uh = device_private(parent);
256 1.31 matt
257 1.31 matt /* set up interrupts so the vector can be detected */
258 1.31 matt
259 1.31 matt /* initialize qv interrupt controller */
260 1.31 matt qv_ic_init(ua, QV_IC);
261 1.31 matt
262 1.31 matt /* set vertical retrace interrupt */
263 1.31 matt qv_ic_setvec(ua, QV_IC, QV_SYNC_VEC, uh->uh_lastiv - 4);
264 1.31 matt qv_ic_enable(ua, QV_IC, QV_SYNC_VEC, QV_IC_ENA);
265 1.31 matt qv_ic_arm(ua, QV_IC, QV_SYNC_VEC);
266 1.31 matt
267 1.31 matt /* enable interrupts */
268 1.31 matt bus_space_write_2(ua->ua_iot, ua->ua_ioh, QV_CSR,
269 1.31 matt bus_space_read_2(ua->ua_iot, ua->ua_ioh, QV_CSR) | (1 << 6));
270 1.1 jonathan
271 1.31 matt qv_ic_force(ua, QV_IC, QV_SYNC_VEC);
272 1.31 matt
273 1.31 matt DELAY(20000);
274 1.31 matt
275 1.31 matt /* disable interrupts */
276 1.31 matt qv_ic_enable(ua, QV_IC, QV_SYNC_VEC, QV_IC_DIS);
277 1.31 matt
278 1.31 matt return 1;
279 1.31 matt }
280 1.1 jonathan
281 1.31 matt /* controller register write helper function */
282 1.31 matt static inline void
283 1.31 matt qv_reg_wr(struct qv_softc *sc, uint16_t addr, uint16_t data)
284 1.31 matt {
285 1.32 msaitoh bus_space_write_2(sc->sc_iot, sc->sc_ioh, addr, data);
286 1.31 matt }
287 1.1 jonathan
288 1.31 matt /* controller register read helper function */
289 1.31 matt static inline uint16_t
290 1.31 matt qv_reg_rd(struct qv_softc *sc, uint16_t addr)
291 1.31 matt {
292 1.32 msaitoh return bus_space_read_2(sc->sc_iot, sc->sc_ioh, addr);
293 1.31 matt }
294 1.1 jonathan
295 1.1 jonathan /*
296 1.31 matt * write a 6845 CRT controller register
297 1.1 jonathan */
298 1.31 matt static void
299 1.31 matt qv_crtc_wr(struct qv_softc *sc, uint16_t addr, uint16_t data)
300 1.31 matt {
301 1.31 matt qv_reg_wr(sc, QV_CRTC_AR, addr);
302 1.32 msaitoh qv_reg_wr(sc, QV_CRTC_DR, data);
303 1.31 matt }
304 1.31 matt
305 1.1 jonathan /*
306 1.31 matt * write a set of a set of video timing parameters to the CRTC
307 1.1 jonathan */
308 1.31 matt static void
309 1.31 matt qv_setcrtc(struct qv_softc *sc, const uint16_t *pp)
310 1.31 matt {
311 1.31 matt int i;
312 1.31 matt
313 1.31 matt for (i = 0; i < 14; i++)
314 1.31 matt qv_crtc_wr(sc, i, pp[i]);
315 1.31 matt }
316 1.1 jonathan
317 1.31 matt static void inline
318 1.31 matt qv_ic_write(struct uba_attach_args *ua, bus_size_t offs, uint16_t value)
319 1.31 matt {
320 1.31 matt bus_space_write_2(ua->ua_iot, ua->ua_ioh, offs, value);
321 1.31 matt }
322 1.1 jonathan
323 1.31 matt void
324 1.31 matt qv_ic_init(struct uba_attach_args *ua, bus_size_t offs)
325 1.31 matt {
326 1.31 matt static int initted;
327 1.31 matt int i;
328 1.31 matt
329 1.31 matt if (!initted) {
330 1.31 matt /* init the interrupt controller */
331 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_RESET);
332 1.31 matt /* reset irr */
333 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_CLRIRR);
334 1.31 matt /* specify individual vectors */
335 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_MODE);
336 1.31 matt /* preset autoclear data */
337 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_ACREG);
338 1.31 matt /* all setup as autoclear */
339 1.32 msaitoh qv_ic_write(ua, QV_IC_DR + offs, 0xff);
340 1.32 msaitoh
341 1.31 matt /* clear all vector addresses */
342 1.31 matt for (i = 0; i < 8; i++)
343 1.31 matt qv_ic_setvec(ua, offs, i, 0);
344 1.31 matt
345 1.31 matt initted = 1;
346 1.31 matt }
347 1.31 matt }
348 1.31 matt
349 1.31 matt void
350 1.32 msaitoh qv_ic_setvec(struct uba_attach_args *ua, bus_size_t offs, int ic_vec,
351 1.32 msaitoh int vecnum)
352 1.31 matt {
353 1.31 matt /* preset vector address */
354 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_RMEM | RMEM_BC_1 | ic_vec);
355 1.32 msaitoh
356 1.31 matt /* give it the vector number */
357 1.32 msaitoh qv_ic_write(ua, QV_IC_DR + offs, vecnum);
358 1.31 matt }
359 1.31 matt
360 1.31 matt void
361 1.32 msaitoh qv_ic_enable(struct uba_attach_args *ua, bus_size_t offs, int ic_vec,
362 1.32 msaitoh int enable)
363 1.31 matt {
364 1.31 matt if (enable)
365 1.31 matt /* enable the interrupt */
366 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_CIMR | ic_vec);
367 1.31 matt else
368 1.32 msaitoh /* disable the interrupt */
369 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_SIMR | ic_vec);
370 1.31 matt }
371 1.31 matt
372 1.31 matt void
373 1.31 matt qv_ic_arm(struct uba_attach_args *ua, bus_size_t offs, int arm)
374 1.31 matt {
375 1.31 matt if (arm)
376 1.31 matt /* arm the interrupt ctrl */
377 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_ARM);
378 1.31 matt else
379 1.31 matt /* disarm the interrupt ctrl */
380 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_DISARM);
381 1.31 matt }
382 1.31 matt
383 1.31 matt void
384 1.31 matt qv_ic_force(struct uba_attach_args *ua, bus_size_t offs, int ic_vec)
385 1.31 matt {
386 1.31 matt /* force an interrupt */
387 1.32 msaitoh qv_ic_write(ua, QV_IC_SR + offs, QV_IC_SIRR | ic_vec);
388 1.31 matt }
389 1.1 jonathan
390 1.1 jonathan /*
391 1.31 matt * print attachment message
392 1.1 jonathan */
393 1.31 matt int
394 1.31 matt qvauxprint(void *aux, const char *pnp)
395 1.31 matt {
396 1.31 matt if (pnp) {
397 1.31 matt aprint_normal("qvaux at %s", pnp);
398 1.31 matt return (UNCONF);
399 1.31 matt }
400 1.31 matt return 0;
401 1.31 matt }
402 1.1 jonathan
403 1.1 jonathan /*
404 1.31 matt * autoconf attach function
405 1.1 jonathan */
406 1.31 matt void
407 1.31 matt qv_attach(device_t parent, device_t self, void *aux)
408 1.31 matt {
409 1.31 matt struct qv_softc *sc = device_private(self);
410 1.31 matt struct uba_softc *uh = device_private(parent);
411 1.31 matt struct uba_attach_args *ua = aux;
412 1.31 matt struct uba_attach_args aa;
413 1.31 matt int fcookie;
414 1.31 matt struct wsemuldisplaydev_attach_args emulaa;
415 1.31 matt // struct wsdisplaydev_attach_args dispaa;
416 1.31 matt struct wsdisplay_font *console_font;
417 1.31 matt int line;
418 1.31 matt
419 1.31 matt sc->sc_dev = self;
420 1.31 matt sc->sc_iot = ua->ua_iot;
421 1.31 matt sc->sc_ioh = ua->ua_ioh;
422 1.31 matt sc->sc_fbt = sc->sc_iot;
423 1.31 matt sc->sc_fbphys = QMEMBASE + ((qv_reg_rd(sc, QV_CSR) & QV_CSR_BANK) << 7);
424 1.31 matt if (bus_space_map(sc->sc_fbt, sc->sc_fbphys, QVSIZE,
425 1.31 matt BUS_SPACE_MAP_LINEAR, &sc->sc_fbh)) {
426 1.31 matt aprint_error_dev(self, "Couldn't alloc graphics memory.\n");
427 1.31 matt return;
428 1.31 matt }
429 1.1 jonathan
430 1.31 matt aprint_normal(": fb %8lo", sc->sc_fbphys & 0x3fffff);
431 1.31 matt sc->sc_fb = bus_space_vaddr(sc->sc_fbt, sc->sc_fbh);
432 1.31 matt sc->sc_scanmap = (uint16_t *)&sc->sc_fb[QV_SCANMAP];
433 1.31 matt #if 0
434 1.31 matt if (extent_alloc_region(((struct uba_vsoftc*)uh)->uv_sgmap.aps_ex,
435 1.31 matt sc->sc_fbphys & 0x3fffff, QVSIZE, EX_NOWAIT)) {
436 1.31 matt aprint_error_dev(self,
437 1.31 matt "Couldn't alloc graphics memory in sgmap.\n");
438 1.31 matt return;
439 1.31 matt }
440 1.31 matt #endif
441 1.31 matt //aprint_normal(": fb 0x%08lx", sc->sc_fbphys & 0x3fffff);
442 1.8 gehenna
443 1.31 matt bzero(sc->sc_fb, QVSIZE);
444 1.31 matt
445 1.31 matt for (line = 0; line < QV_YWIDTH; line++) {
446 1.31 matt sc->sc_scanmap[line] = line;
447 1.31 matt }
448 1.1 jonathan
449 1.31 matt /* program crtc */
450 1.31 matt qv_setcrtc(sc, qv_stdscreen[2].qv_crtc_param);
451 1.31 matt
452 1.31 matt /* enable video output */
453 1.31 matt qv_reg_wr(sc, QV_CSR, qv_reg_rd(sc, QV_CSR) | (1 << 2) | (1 << 3));
454 1.31 matt #if 0
455 1.31 matt if (sc->sc_curscr == NULL)
456 1.31 matt callout_init(&qv_cursor_ch, 0);
457 1.31 matt sc->sc_curscr = &qv_conscreen;
458 1.1 jonathan
459 1.31 matt callout_reset(&qv_cursor_ch, hz / 2, qv_crsr_blink, sc);
460 1.1 jonathan #endif
461 1.31 matt /* interrupt handlers - XXX */
462 1.1 jonathan
463 1.31 matt uh->uh_lastiv -= 4;
464 1.1 jonathan
465 1.31 matt wsfont_init();
466 1.31 matt if ((fcookie = wsfont_find(NULL, 8, 15, 0, WSDISPLAY_FONTORDER_R2L,
467 1.31 matt WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP)) < 0) {
468 1.31 matt aprint_error_dev(self, "could not find 8x15 font\n");
469 1.31 matt return;
470 1.31 matt }
471 1.31 matt if (wsfont_lock(fcookie, &console_font) != 0) {
472 1.31 matt aprint_error_dev(self, "could not lock 8x15 font\n");
473 1.31 matt return;
474 1.31 matt }
475 1.31 matt sc->sc_font = console_font->data;
476 1.1 jonathan
477 1.31 matt aprint_normal("\n");
478 1.1 jonathan
479 1.31 matt aa.ua_iot = ua->ua_iot;
480 1.31 matt aa.ua_ioh = ua->ua_ioh + 32; // offset
481 1.31 matt aa.ua_cvec = ua->ua_cvec - 4;
482 1.31 matt if (config_search_ia(NULL, self, "qv", &aa) != NULL) {
483 1.31 matt config_found_ia(self, "qv", &aa, qvauxprint);
484 1.31 matt uh->uh_lastiv -= 4;
485 1.31 matt }
486 1.1 jonathan
487 1.31 matt emulaa.console = 0; /* Not console */
488 1.31 matt emulaa.scrdata = &qv_screenlist;
489 1.31 matt emulaa.accessops = &qv_accessops;
490 1.31 matt emulaa.accesscookie = self;
491 1.31 matt if (config_search_ia(NULL, self, "wsemuldisplaydev", &emulaa) != NULL) {
492 1.31 matt config_found_ia(self, "wsemuldisplaydev", &emulaa,
493 1.31 matt wsemuldisplaydevprint);
494 1.31 matt }
495 1.31 matt
496 1.31 matt //console_debugger();
497 1.31 matt return;
498 1.31 matt }
499 1.31 matt
500 1.31 matt /* QVSS frame buffer */
501 1.1 jonathan
502 1.31 matt /* uint_32 is stored little endian in frame buffer */
503 1.31 matt /* bits are stored little endian in frame buffer */
504 1.1 jonathan
505 1.31 matt /* uint_32 *fb; */
506 1.31 matt /* fb = (int *)phystova(0x303c0000); */
507 1.31 matt /* *fb = 0x00000001; */ /* sets bit in first column */
508 1.1 jonathan
509 1.31 matt /* Frame Buffer Usage */
510 1.31 matt
511 1.31 matt /* characters are 8 bits wide and QVHEIGHT high */
512 1.31 matt /* the scan map is allocated in terms of character height, */
513 1.31 matt /* so a pointer to the top line of a character can step to the */
514 1.31 matt /* next row without looking up the memory location in the scan map */
515 1.31 matt
516 1.31 matt static char *cursor;
517 1.31 matt static int cur_on;
518 1.31 matt
519 1.31 matt /*
520 1.31 matt * return pointer to line in character glyph
521 1.31 matt */
522 1.31 matt static inline char *
523 1.31 matt qv_font(struct qv_softc *sc, int c, int line)
524 1.31 matt {
525 1.31 matt /* map char to font table offset */
526 1.31 matt if (c < 32)
527 1.31 matt c = 32;
528 1.31 matt else if (c > 127)
529 1.31 matt c -= 66;
530 1.31 matt else
531 1.31 matt c -= 32;
532 1.31 matt
533 1.31 matt /* return pointer line in font glyph */
534 1.32 msaitoh return &sc->sc_font[c*QV_CHEIGHT + line];
535 1.1 jonathan }
536 1.1 jonathan
537 1.1 jonathan /*
538 1.31 matt * return pointer to character line in frame buffer
539 1.1 jonathan */
540 1.31 matt static inline char *
541 1.31 matt qv_fbp(struct qv_softc *sc, int row, int col, int line)
542 1.1 jonathan {
543 1.31 matt return &sc->sc_fb[col + sc->sc_scanmap[row*QV_CHEIGHT + line]*QV_COLS];
544 1.1 jonathan }
545 1.1 jonathan
546 1.31 matt /*
547 1.31 matt * callout callback function to blink cursor
548 1.31 matt */
549 1.31 matt #if 0
550 1.31 matt static void
551 1.31 matt qv_crsr_blink(void *arg)
552 1.1 jonathan {
553 1.31 matt struct qv_softc *sc = arg;
554 1.31 matt
555 1.31 matt if (cur_on)
556 1.31 matt *cursor ^= 255;
557 1.31 matt callout_reset(&qv_cursor_ch, hz / 2, qv_crsr_blink, sc);
558 1.31 matt }
559 1.1 jonathan #endif
560 1.31 matt /*
561 1.31 matt * emulop cursor
562 1.31 matt */
563 1.31 matt void
564 1.31 matt qv_cursor(void *id, int on, int row, int col)
565 1.31 matt {
566 1.31 matt struct qv_screen * const ss = id;
567 1.31 matt
568 1.31 matt if (ss == ss->ss_sc->sc_curscr) {
569 1.31 matt *qv_fbp(ss->ss_sc, ss->ss_cury, ss->ss_curx, 14)
570 1.31 matt = *qv_font(ss->ss_sc,
571 1.31 matt ss->ss_image[ss->ss_cury][ss->ss_curx], 14);
572 1.31 matt cursor = qv_fbp(ss->ss_sc, row, col, 14);
573 1.31 matt if ((cur_on = on))
574 1.31 matt *cursor ^= 255;
575 1.1 jonathan }
576 1.31 matt ss->ss_curx = col;
577 1.31 matt ss->ss_cury = row;
578 1.1 jonathan }
579 1.1 jonathan
580 1.1 jonathan /*
581 1.31 matt * emulop mapchar
582 1.1 jonathan */
583 1.8 gehenna int
584 1.31 matt qv_mapchar(void *id, int uni, unsigned int *index)
585 1.1 jonathan {
586 1.31 matt if (uni < 256) {
587 1.31 matt *index = uni;
588 1.31 matt return (5);
589 1.1 jonathan }
590 1.31 matt *index = ' ';
591 1.31 matt return (0);
592 1.1 jonathan }
593 1.1 jonathan
594 1.31 matt /*
595 1.31 matt * emulop putchar
596 1.31 matt */
597 1.31 matt static void
598 1.31 matt qv_putchar(void *id, int row, int col, u_int c, long attr)
599 1.1 jonathan {
600 1.31 matt struct qv_screen * const ss = id;
601 1.31 matt int i;
602 1.31 matt char *gp;
603 1.31 matt char *fp;
604 1.31 matt char rvid;
605 1.31 matt
606 1.31 matt c &= 0xff;
607 1.31 matt
608 1.31 matt ss->ss_image[row][col] = c;
609 1.31 matt ss->ss_attr[row][col] = attr;
610 1.31 matt if (ss != ss->ss_sc->sc_curscr)
611 1.31 matt return;
612 1.31 matt
613 1.31 matt gp = qv_font(ss->ss_sc, c, 0);
614 1.31 matt fp = qv_fbp(ss->ss_sc, row, col, 0);
615 1.31 matt rvid = (attr & WSATTR_REVERSE) ? 0xff : 0x00;
616 1.31 matt for (i = 0; i < QV_CHEIGHT; i++) {
617 1.31 matt *fp = *gp++ ^ rvid;
618 1.31 matt fp += QV_COLS;
619 1.31 matt }
620 1.1 jonathan
621 1.31 matt if (attr & WSATTR_UNDERLINE)
622 1.31 matt *qv_fbp(ss->ss_sc, row, col, 14)
623 1.31 matt ^= *qv_fbp(ss->ss_sc, row, col, 14);
624 1.1 jonathan }
625 1.1 jonathan
626 1.31 matt /*
627 1.31 matt * emulop copy columns - copies columns inside a row
628 1.31 matt */
629 1.31 matt static void
630 1.31 matt qv_copycols(void *id, int row, int srccol, int dstcol, int ncols)
631 1.1 jonathan {
632 1.31 matt struct qv_screen * const ss = id;
633 1.31 matt int i;
634 1.1 jonathan
635 1.31 matt memcpy(&ss->ss_image[row][dstcol], &ss->ss_image[row][srccol], ncols);
636 1.31 matt memcpy(&ss->ss_attr[row][dstcol], &ss->ss_attr[row][srccol], ncols);
637 1.31 matt if (ss != ss->ss_sc->sc_curscr)
638 1.31 matt return;
639 1.31 matt for (i = 0; i < QV_CHEIGHT; i++)
640 1.31 matt memcpy(qv_fbp(ss->ss_sc, row, dstcol, i),
641 1.31 matt qv_fbp(ss->ss_sc, row, srccol, i), ncols);
642 1.1 jonathan }
643 1.1 jonathan
644 1.31 matt /*
645 1.31 matt * emulop erase columns - erases a bunch of chars inside one row
646 1.31 matt */
647 1.31 matt static void
648 1.31 matt qv_erasecols(void *id, int row, int startcol, int ncols, long fillattr)
649 1.5 scw {
650 1.31 matt struct qv_screen * const ss = id;
651 1.31 matt int i;
652 1.5 scw
653 1.31 matt memset(&ss->ss_image[row][startcol], 0, ncols);
654 1.31 matt memset(&ss->ss_attr[row][startcol], 0, ncols);
655 1.31 matt if (ss != ss->ss_sc->sc_curscr)
656 1.31 matt return;
657 1.31 matt for (i = 0; i < QV_CHEIGHT; i++)
658 1.31 matt memset(qv_fbp(ss->ss_sc, row, startcol, i), 0, ncols);
659 1.5 scw }
660 1.5 scw
661 1.5 scw /*
662 1.31 matt * overlap check
663 1.31 matt * return 0 if no overlap
664 1.31 matt * -1 if overlap and dst is less than src (move up)
665 1.31 matt * +1 if overlap and src is less than dst (move down)
666 1.5 scw */
667 1.31 matt static inline int
668 1.31 matt qv_rows_overlap(int srcrow, int dstrow, int nrows)
669 1.31 matt {
670 1.31 matt if (dstrow < srcrow) {
671 1.31 matt if (dstrow + nrows <= srcrow)
672 1.31 matt return 0;
673 1.31 matt else
674 1.31 matt return -1;
675 1.31 matt }
676 1.31 matt else {
677 1.31 matt if (srcrow + nrows <= dstrow)
678 1.31 matt return 0;
679 1.31 matt else
680 1.31 matt return 1;
681 1.31 matt }
682 1.31 matt }
683 1.1 jonathan
684 1.1 jonathan /*
685 1.31 matt * emulop copyrows - copy entire rows
686 1.1 jonathan */
687 1.31 matt static void
688 1.31 matt qv_copyrows(void *id, int srcrow, int dstrow, int nrows)
689 1.1 jonathan {
690 1.31 matt struct qv_screen * const ss = id;
691 1.31 matt int ol;
692 1.31 matt int n;
693 1.31 matt int line;
694 1.31 matt int tmp;
695 1.31 matt uint16_t *sp;
696 1.31 matt uint16_t *dp;
697 1.31 matt
698 1.31 matt memcpy(&ss->ss_image[dstrow][0], &ss->ss_image[srcrow][0],
699 1.31 matt nrows * QV_COLS);
700 1.31 matt memcpy(&ss->ss_attr[dstrow][0], &ss->ss_attr[srcrow][0],
701 1.31 matt nrows * QV_COLS);
702 1.31 matt if (ss != ss->ss_sc->sc_curscr)
703 1.31 matt return;
704 1.31 matt
705 1.31 matt ol = qv_rows_overlap(srcrow, dstrow, nrows);
706 1.31 matt if (ol == 0)
707 1.31 matt for (n = 0; n < nrows; n++)
708 1.31 matt bcopy(qv_fbp(ss->ss_sc, srcrow + n, 0, 0),
709 1.31 matt qv_fbp(ss->ss_sc, dstrow + n, 0, 0), QV_NEXTROW);
710 1.31 matt else if (ol < 0) {
711 1.31 matt for (n = 0; n < nrows; n++) {
712 1.32 msaitoh dp = &ss->ss_sc->sc_scanmap[(dstrow + n)*QV_CHEIGHT];
713 1.31 matt sp = &ss->ss_sc->sc_scanmap[(srcrow + n)*QV_CHEIGHT];
714 1.31 matt for (line = 0; line < QV_CHEIGHT; line++) {
715 1.32 msaitoh tmp = *dp;
716 1.31 matt *dp = *sp;
717 1.31 matt *sp = tmp;
718 1.31 matt dp++;
719 1.31 matt sp++;
720 1.1 jonathan }
721 1.31 matt }
722 1.31 matt qv_copyrows(id, dstrow + nrows - srcrow + dstrow,
723 1.31 matt dstrow + nrows, srcrow - dstrow);
724 1.31 matt }
725 1.1 jonathan else {
726 1.31 matt for (n = nrows - 1; n >= 0; n--) {
727 1.32 msaitoh dp = &ss->ss_sc->sc_scanmap[(dstrow + n)*QV_CHEIGHT];
728 1.31 matt sp = &ss->ss_sc->sc_scanmap[(srcrow + n)*QV_CHEIGHT];
729 1.31 matt for (line = 0; line < QV_CHEIGHT; line++) {
730 1.32 msaitoh tmp = *dp;
731 1.31 matt *dp = *sp;
732 1.31 matt *sp = tmp;
733 1.31 matt dp++;
734 1.31 matt sp++;
735 1.31 matt }
736 1.31 matt }
737 1.31 matt qv_copyrows(id, srcrow, dstrow, dstrow - srcrow);
738 1.1 jonathan }
739 1.1 jonathan }
740 1.31 matt
741 1.1 jonathan /*
742 1.31 matt * emulop eraserows - erase a number of entire rows
743 1.1 jonathan */
744 1.31 matt static void
745 1.31 matt qv_eraserows(void *id, int startrow, int nrows, long fillattr)
746 1.1 jonathan {
747 1.31 matt struct qv_screen * const ss = id;
748 1.31 matt int row;
749 1.1 jonathan
750 1.31 matt memset(&ss->ss_image[startrow][0], 0, nrows * QV_COLS);
751 1.31 matt memset(&ss->ss_attr[startrow][0], 0, nrows * QV_COLS);
752 1.31 matt if (ss != ss->ss_sc->sc_curscr)
753 1.1 jonathan return;
754 1.31 matt
755 1.31 matt for (row = startrow; row < startrow + nrows; row++) {
756 1.31 matt memset(qv_fbp(ss->ss_sc, row, 0, 0), 0, QV_NEXTROW);
757 1.31 matt }
758 1.31 matt }
759 1.31 matt
760 1.31 matt /*
761 1.31 matt * emulop allocattr
762 1.31 matt */
763 1.31 matt static int
764 1.31 matt qv_allocattr(void *id, int fg, int bg, int flags, long *attrp)
765 1.31 matt {
766 1.31 matt *attrp = flags;
767 1.31 matt return 0;
768 1.31 matt }
769 1.1 jonathan
770 1.31 matt /*
771 1.31 matt * emulop setcursor
772 1.31 matt */
773 1.31 matt static void
774 1.31 matt qv_setcursor(struct qv_softc *sc, struct wsdisplay_cursor *v)
775 1.31 matt {
776 1.31 matt uint16_t red, green, blue;
777 1.31 matt uint32_t curfg[16], curmask[16];
778 1.31 matt uint16_t *curp;
779 1.31 matt int i;
780 1.1 jonathan
781 1.31 matt /* Enable cursor */
782 1.31 matt if (v->which & WSDISPLAY_CURSOR_DOCUR) {
783 1.31 matt sc->sc_curon = (v->enable) ? CUR_ON : CUR_OFF;
784 1.31 matt qv_crtc_wr(sc, CUR_START, sc->sc_curon | (sc->sc_cury & 0x0f));
785 1.31 matt }
786 1.31 matt if (v->which & WSDISPLAY_CURSOR_DOHOT) {
787 1.31 matt sc->sc_curhotX = v->hot.x;
788 1.31 matt sc->sc_curhotY = v->hot.y;
789 1.31 matt }
790 1.31 matt if (v->which & WSDISPLAY_CURSOR_DOCMAP) {
791 1.31 matt /* First background */
792 1.31 matt red = fusword(v->cmap.red);
793 1.31 matt green = fusword(v->cmap.green);
794 1.31 matt blue = fusword(v->cmap.blue);
795 1.31 matt bgmask = (((30L * red + 59L * green + 11L * blue) >> 8) >=
796 1.31 matt (((1<<8)-1)*50)) ? ~0 : 0;
797 1.31 matt red = fusword(v->cmap.red+2);
798 1.31 matt green = fusword(v->cmap.green+2);
799 1.31 matt blue = fusword(v->cmap.blue+2);
800 1.31 matt fgmask = (((30L * red + 59L * green + 11L * blue) >> 8) >=
801 1.31 matt (((1<<8)-1)*50)) ? ~0 : 0;
802 1.31 matt }
803 1.31 matt if (v->which & WSDISPLAY_CURSOR_DOSHAPE) {
804 1.31 matt copyin(v->image, curfg, sizeof(curfg));
805 1.31 matt copyin(v->mask, curmask, sizeof(curmask)); /* not used */
806 1.31 matt curp = (uint16_t *) &(sc->sc_fb)[QV_CURSRAM];
807 1.31 matt for (i = 0; i < sizeof(curfg)/sizeof(curfg[0]); i++) {
808 1.31 matt curp[i] = (uint16_t)curfg[i];
809 1.1 jonathan }
810 1.1 jonathan }
811 1.1 jonathan }
812 1.1 jonathan
813 1.1 jonathan /*
814 1.31 matt * emulop ioctl
815 1.1 jonathan */
816 1.8 gehenna int
817 1.31 matt qv_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
818 1.1 jonathan {
819 1.31 matt struct wsdisplay_fbinfo *fb = (void *)data;
820 1.31 matt //static uint16_t curc;
821 1.31 matt struct qv_softc *sc = device_private(v);
822 1.31 matt
823 1.31 matt switch (cmd) {
824 1.31 matt case WSDISPLAYIO_GTYPE:
825 1.31 matt *(u_int *)data = WSDISPLAY_TYPE_VAX_MONO;
826 1.1 jonathan break;
827 1.1 jonathan
828 1.31 matt case WSDISPLAYIO_GINFO:
829 1.31 matt fb->height = QV_YWIDTH;
830 1.31 matt fb->width = QV_XWIDTH;
831 1.31 matt fb->depth = 1;
832 1.31 matt fb->cmsize = 2;
833 1.1 jonathan break;
834 1.1 jonathan
835 1.31 matt case WSDISPLAYIO_SVIDEO:
836 1.31 matt if (*(u_int *)data == WSDISPLAYIO_VIDEO_ON) {
837 1.31 matt /* enable video output */
838 1.31 matt qv_reg_wr(sc, QV_CSR,
839 1.31 matt qv_reg_rd(sc, QV_CSR) | (1 << 2));
840 1.31 matt } else {
841 1.31 matt /* disable video output */
842 1.31 matt qv_reg_wr(sc, QV_CSR,
843 1.31 matt qv_reg_rd(sc, QV_CSR) & ~(1 << 2));
844 1.31 matt }
845 1.31 matt break;
846 1.31 matt
847 1.31 matt case WSDISPLAYIO_GVIDEO:
848 1.31 matt *(u_int *)data = (qv_reg_rd(sc, QV_CSR) & (1 << 2))
849 1.31 matt ? WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
850 1.31 matt break;
851 1.31 matt
852 1.31 matt case WSDISPLAYIO_SCURSOR:
853 1.31 matt qv_setcursor(sc, (struct wsdisplay_cursor *)data);
854 1.1 jonathan break;
855 1.1 jonathan
856 1.31 matt case WSDISPLAYIO_SCURPOS:
857 1.31 matt sc->sc_curx = ((struct wsdisplay_curpos *)data)->x;
858 1.31 matt sc->sc_cury = ((struct wsdisplay_curpos *)data)->y;
859 1.31 matt qv_crtc_wr(sc, CUR_START, CUR_OFF | (sc->sc_cury & 0x0f));
860 1.31 matt qv_crtc_wr(sc, CUR_HI, sc->sc_cury >> 4);
861 1.31 matt qv_reg_wr(sc, QV_CUR_X, sc->sc_curx);
862 1.31 matt qv_crtc_wr(sc, CUR_START,
863 1.32 msaitoh sc->sc_curon | (sc->sc_cury & 0x0f));
864 1.1 jonathan break;
865 1.31 matt
866 1.31 matt case WSDISPLAYIO_GCURPOS:
867 1.31 matt ((struct wsdisplay_curpos *)data)->x = sc->sc_curx;
868 1.31 matt ((struct wsdisplay_curpos *)data)->y = sc->sc_cury;
869 1.1 jonathan break;
870 1.31 matt
871 1.31 matt case WSDISPLAYIO_GCURMAX:
872 1.31 matt ((struct wsdisplay_curpos *)data)->x = 16;
873 1.31 matt ((struct wsdisplay_curpos *)data)->y = 16;
874 1.1 jonathan break;
875 1.31 matt
876 1.31 matt default:
877 1.31 matt return EPASSTHROUGH;
878 1.1 jonathan }
879 1.31 matt return 0;
880 1.1 jonathan }
881 1.31 matt
882 1.1 jonathan /*
883 1.31 matt * emulop mmap
884 1.1 jonathan */
885 1.31 matt static paddr_t
886 1.31 matt qv_mmap(void *v, void *vs, off_t offset, int prot)
887 1.1 jonathan {
888 1.31 matt struct qv_softc *sc = device_private(v);
889 1.31 matt
890 1.31 matt if (offset >= QVSIZE || offset < 0)
891 1.31 matt return -1;
892 1.31 matt return (sc->sc_fbphys) >> PGSHIFT;
893 1.1 jonathan }
894 1.1 jonathan
895 1.1 jonathan /*
896 1.31 matt * emulop allocate screen
897 1.1 jonathan */
898 1.31 matt int
899 1.31 matt qv_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
900 1.31 matt int *curxp, int *curyp, long *defattrp)
901 1.1 jonathan {
902 1.31 matt struct qv_softc *sc = device_private(v);
903 1.31 matt struct qv_screen *ss;
904 1.1 jonathan
905 1.31 matt ss = malloc(sizeof(struct qv_screen), M_DEVBUF, M_WAITOK|M_ZERO);
906 1.31 matt ss->ss_sc = sc;
907 1.31 matt ss->ss_type = type;
908 1.31 matt *cookiep = ss;
909 1.31 matt *curxp = *curyp = *defattrp = 0;
910 1.31 matt printf("qv_alloc_screen: \"%s\" %p\n", type->name, ss);
911 1.31 matt return 0;
912 1.1 jonathan }
913 1.1 jonathan
914 1.1 jonathan /*
915 1.31 matt * emulop free screen
916 1.1 jonathan */
917 1.2 mycroft void
918 1.31 matt qv_free_screen(void *v, void *cookie)
919 1.1 jonathan {
920 1.31 matt printf("qv_free_screen: %p\n", cookie);
921 1.31 matt free(cookie, M_DEVBUF);
922 1.31 matt }
923 1.1 jonathan
924 1.31 matt /*
925 1.31 matt * emulop show screen
926 1.31 matt */
927 1.31 matt int
928 1.31 matt qv_show_screen(void *v, void *cookie, int waitok,
929 1.31 matt void (*cb)(void *, int, int), void *cbarg)
930 1.31 matt {
931 1.31 matt struct qv_screen *ss = cookie;
932 1.31 matt const struct _wsscreen_descr *descr;
933 1.31 matt int row, col, line;
934 1.31 matt printf("qv_show_screen: %p\n", cookie);
935 1.31 matt
936 1.31 matt if (ss == ss->ss_sc->sc_curscr)
937 1.31 matt return (0);
938 1.31 matt
939 1.31 matt descr = (const struct _wsscreen_descr *)(ss->ss_type);
940 1.31 matt qv_setcrtc(ss->ss_sc, descr->qv_crtc_param);
941 1.31 matt for (row = 0; row < QV_ROWS; row++)
942 1.31 matt for (line = 0; line < QV_CHEIGHT; line++) {
943 1.31 matt for (col = 0; col < QV_COLS; col++) {
944 1.31 matt u_char s, c = ss->ss_image[row][col];
945 1.31 matt
946 1.31 matt if (c < 32)
947 1.31 matt c = 32;
948 1.31 matt s = *qv_font(ss->ss_sc, c, line);
949 1.31 matt if (ss->ss_attr[row][col] & WSATTR_REVERSE)
950 1.31 matt s ^= 255;
951 1.31 matt *qv_fbp(ss->ss_sc, row, col, line) = s;
952 1.31 matt
953 1.31 matt if (ss->ss_attr[row][col] & WSATTR_UNDERLINE)
954 1.31 matt *qv_fbp(ss->ss_sc, row, col, line)
955 1.31 matt = 255;
956 1.31 matt }
957 1.31 matt }
958 1.31 matt cursor = qv_fbp(ss->ss_sc, ss->ss_cury, ss->ss_curx, 14);
959 1.31 matt ss->ss_sc->sc_curscr = ss;
960 1.31 matt return (0);
961 1.1 jonathan }
962 1.1 jonathan
963 1.31 matt #if 0
964 1.31 matt void
965 1.31 matt qv_reset_establish(void (*reset)(device_t), device_t dev)
966 1.1 jonathan {
967 1.31 matt uba_reset_establish(reset, device_parent(dev));
968 1.1 jonathan }
969 1.31 matt #endif
970 1.31 matt cons_decl(qv);
971 1.1 jonathan
972 1.31 matt void
973 1.31 matt qvcninit(struct consdev *cndev)
974 1.1 jonathan {
975 1.31 matt int fcookie;
976 1.31 matt struct wsdisplay_font *console_font;
977 1.31 matt extern void lkccninit(struct consdev *);
978 1.31 matt extern int lkccngetc(dev_t);
979 1.31 matt extern int dz_vsbus_lk201_cnattach(int);
980 1.31 matt
981 1.31 matt //printf("qvcninit: \n");
982 1.31 matt /* Clear screen */
983 1.31 matt //memset(qv_addr, 0, 128*864);
984 1.31 matt
985 1.31 matt callout_init(&qv_cursor_ch, 0);
986 1.31 matt //curscr = &qv_conscreen;
987 1.31 matt wsdisplay_cnattach(&qv_stdscreen[0].qv_stdscreen,
988 1.31 matt &qv_conscreen, 0, 0, 0);
989 1.31 matt cn_tab->cn_pri = CN_INTERNAL;
990 1.31 matt wsfont_init();
991 1.31 matt if ((fcookie = wsfont_find(NULL, 8, 15, 0, WSDISPLAY_FONTORDER_R2L,
992 1.31 matt WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP)) < 0)
993 1.31 matt {
994 1.31 matt printf("qv: could not find 8x15 font\n");
995 1.1 jonathan return;
996 1.31 matt }
997 1.31 matt if (wsfont_lock(fcookie, &console_font) != 0) {
998 1.31 matt printf("qv: could not lock 8x15 font\n");
999 1.1 jonathan return;
1000 1.31 matt }
1001 1.31 matt //qf = console_font->data;
1002 1.1 jonathan
1003 1.31 matt #if NQVKBD > 0 && 0
1004 1.31 matt qvkbd_cnattach(0); /* Connect keyboard and screen together */
1005 1.31 matt #endif
1006 1.1 jonathan }
1007 1.1 jonathan
1008 1.1 jonathan /*
1009 1.31 matt * Called very early to setup the glass tty as console.
1010 1.31 matt * Because it's called before the VM system is inited, virtual memory
1011 1.31 matt * for the framebuffer can be stolen directly without disturbing anything.
1012 1.1 jonathan */
1013 1.31 matt void
1014 1.31 matt qvcnprobe(struct consdev *cndev)
1015 1.1 jonathan {
1016 1.31 matt printf("qvcnprobe: \n");
1017 1.31 matt #if 0
1018 1.31 matt extern vaddr_t virtual_avail;
1019 1.31 matt extern const struct cdevsw wsdisplay_cdevsw;
1020 1.31 matt
1021 1.31 matt switch (vax_boardtype) {
1022 1.31 matt case VAX_BTYP_410:
1023 1.31 matt case VAX_BTYP_420:
1024 1.31 matt case VAX_BTYP_43:
1025 1.31 matt if ((vax_confdata & KA420_CFG_L3CON) ||
1026 1.31 matt (vax_confdata & KA420_CFG_MULTU))
1027 1.31 matt break; /* doesn't use graphics console */
1028 1.31 matt qv_addr = (void *)virtual_avail;
1029 1.31 matt virtual_avail += QVSIZE;
1030 1.31 matt ioaccess((vaddr_t)qv_addr, QVADDR, (QVSIZE/VAX_NBPG));
1031 1.31 matt cndev->cn_pri = CN_INTERNAL;
1032 1.31 matt cndev->cn_dev = makedev(cdevsw_lookup_major(&wsdisplay_cdevsw),
1033 1.31 matt 0);
1034 1.31 matt break;
1035 1.31 matt default:
1036 1.31 matt break;
1037 1.1 jonathan }
1038 1.31 matt #endif
1039 1.1 jonathan }
1040