Mon Jan 21 19:49:16 2013 UTC ()
Make internal functions static


(mlelstv)
diff -r1.109 -r1.110 src/sys/dev/ic/vga.c
diff -r1.35 -r1.36 src/sys/dev/ic/vga_raster.c
diff -r1.29 -r1.30 src/sys/dev/ic/vgavar.h

cvs diff -r1.109 -r1.110 src/sys/dev/ic/vga.c (expand / switch to unified diff)

--- src/sys/dev/ic/vga.c 2012/08/09 23:56:35 1.109
+++ src/sys/dev/ic/vga.c 2013/01/21 19:49:15 1.110
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vga.c,v 1.109 2012/08/09 23:56:35 uwe Exp $ */ 1/* $NetBSD: vga.c,v 1.110 2013/01/21 19:49:15 mlelstv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * 18 *
19 * Carnegie Mellon requests users of this software to return to 19 * Carnegie Mellon requests users of this software to return to
20 * 20 *
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science 22 * School of Computer Science
23 * Carnegie Mellon University 23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890 24 * Pittsburgh PA 15213-3890
25 * 25 *
26 * any improvements or extensions that they make and grant Carnegie the 26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes. 27 * rights to redistribute these changes.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.109 2012/08/09 23:56:35 uwe Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.110 2013/01/21 19:49:15 mlelstv Exp $");
32 32
33/* for WSCONS_SUPPORT_PCVTFONTS */ 33/* for WSCONS_SUPPORT_PCVTFONTS */
34#include "opt_wsdisplay_compat.h" 34#include "opt_wsdisplay_compat.h"
35/* for WSDISPLAY_CUSTOM_BORDER */ 35/* for WSDISPLAY_CUSTOM_BORDER */
36#include "opt_wsdisplay_border.h" 36#include "opt_wsdisplay_border.h"
37/* for WSDISPLAY_CUSTOM_OUTPUT */ 37/* for WSDISPLAY_CUSTOM_OUTPUT */
38#include "opt_wsmsgattrs.h" 38#include "opt_wsmsgattrs.h"
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/callout.h> 42#include <sys/callout.h>
43#include <sys/kernel.h> 43#include <sys/kernel.h>
44#include <sys/device.h> 44#include <sys/device.h>
@@ -101,43 +101,43 @@ struct vgascreen { @@ -101,43 +101,43 @@ struct vgascreen {
101 /* videostate */ 101 /* videostate */
102 struct egavga_font *fontset1, *fontset2; 102 struct egavga_font *fontset1, *fontset2;
103 /* font data */ 103 /* font data */
104 104
105 int mindispoffset, maxdispoffset; 105 int mindispoffset, maxdispoffset;
106 int vga_rollover; 106 int vga_rollover;
107 int visibleoffset; 107 int visibleoffset;
108}; 108};
109 109
110static int vgaconsole, vga_console_type, vga_console_attached; 110static int vgaconsole, vga_console_type, vga_console_attached;
111static struct vgascreen vga_console_screen; 111static struct vgascreen vga_console_screen;
112static struct vga_config vga_console_vc; 112static struct vga_config vga_console_vc;
113 113
114struct egavga_font *egavga_getfont(struct vga_config *, struct vgascreen *, 114static struct egavga_font *egavga_getfont(struct vga_config *, struct vgascreen *,
115 const char *, int); 115 const char *, int);
116void egavga_unreffont(struct vga_config *, struct egavga_font *); 116static void egavga_unreffont(struct vga_config *, struct egavga_font *);
117 117
118int vga_selectfont(struct vga_config *, struct vgascreen *, const char *, 118static int vga_selectfont(struct vga_config *, struct vgascreen *, const char *,
119 const char *); 119 const char *);
120void vga_init_screen(struct vga_config *, struct vgascreen *, 120static void vga_init_screen(struct vga_config *, struct vgascreen *,
121 const struct wsscreen_descr *, int, long *); 121 const struct wsscreen_descr *, int, long *);
122void vga_init(struct vga_config *, bus_space_tag_t, bus_space_tag_t); 122static void vga_init(struct vga_config *, bus_space_tag_t, bus_space_tag_t);
123static void vga_setfont(struct vga_config *, struct vgascreen *); 123static void vga_setfont(struct vga_config *, struct vgascreen *);
124 124
125static int vga_mapchar(void *, int, unsigned int *); 125static int vga_mapchar(void *, int, unsigned int *);
126void vga_putchar(void *, int, int, u_int, long); 126static void vga_putchar(void *, int, int, u_int, long);
127static int vga_allocattr(void *, int, int, int, long *); 127static int vga_allocattr(void *, int, int, int, long *);
128static void vga_copyrows(void *, int, int, int); 128static void vga_copyrows(void *, int, int, int);
129#ifdef WSDISPLAY_SCROLLSUPPORT 129#ifdef WSDISPLAY_SCROLLSUPPORT
130void vga_scroll (void *, void *, int); 130static void vga_scroll (void *, void *, int);
131#endif 131#endif
132 132
133const struct wsdisplay_emulops vga_emulops = { 133const struct wsdisplay_emulops vga_emulops = {
134 pcdisplay_cursor, 134 pcdisplay_cursor,
135 vga_mapchar, 135 vga_mapchar,
136 vga_putchar, 136 vga_putchar,
137 pcdisplay_copycols, 137 pcdisplay_copycols,
138 pcdisplay_erasecols, 138 pcdisplay_erasecols,
139 vga_copyrows, 139 vga_copyrows,
140 pcdisplay_eraserows, 140 pcdisplay_eraserows,
141 vga_allocattr, 141 vga_allocattr,
142#ifdef WSDISPLAY_CUSTOM_OUTPUT 142#ifdef WSDISPLAY_CUSTOM_OUTPUT
143 pcdisplay_replaceattr, 143 pcdisplay_replaceattr,
@@ -277,27 +277,30 @@ const struct wsscreen_list vga_screenlis @@ -277,27 +277,30 @@ const struct wsscreen_list vga_screenlis
277static int vga_ioctl(void *, void *, u_long, void *, int, struct lwp *); 277static int vga_ioctl(void *, void *, u_long, void *, int, struct lwp *);
278static paddr_t vga_mmap(void *, void *, off_t, int); 278static paddr_t vga_mmap(void *, void *, off_t, int);
279static int vga_alloc_screen(void *, const struct wsscreen_descr *, 279static int vga_alloc_screen(void *, const struct wsscreen_descr *,
280 void **, int *, int *, long *); 280 void **, int *, int *, long *);
281static void vga_free_screen(void *, void *); 281static void vga_free_screen(void *, void *);
282static int vga_show_screen(void *, void *, int, 282static int vga_show_screen(void *, void *, int,
283 void (*)(void *, int, int), void *); 283 void (*)(void *, int, int), void *);
284static int vga_load_font(void *, void *, struct wsdisplay_font *); 284static int vga_load_font(void *, void *, struct wsdisplay_font *);
285#ifdef WSDISPLAY_CUSTOM_BORDER 285#ifdef WSDISPLAY_CUSTOM_BORDER
286static int vga_getborder(struct vga_config *, u_int *); 286static int vga_getborder(struct vga_config *, u_int *);
287static int vga_setborder(struct vga_config *, u_int); 287static int vga_setborder(struct vga_config *, u_int);
288#endif /* WSDISPLAY_CUSTOM_BORDER */ 288#endif /* WSDISPLAY_CUSTOM_BORDER */
289 289
290void vga_doswitch(struct vga_config *); 290static void vga_doswitch(struct vga_config *);
 291static void vga_save_palette(struct vga_config *);
 292static void vga_restore_palette(struct vga_config *);
 293
291 294
292const struct wsdisplay_accessops vga_accessops = { 295const struct wsdisplay_accessops vga_accessops = {
293 vga_ioctl, 296 vga_ioctl,
294 vga_mmap, 297 vga_mmap,
295 vga_alloc_screen, 298 vga_alloc_screen,
296 vga_free_screen, 299 vga_free_screen,
297 vga_show_screen, 300 vga_show_screen,
298 vga_load_font, 301 vga_load_font,
299 NULL, 302 NULL,
300#ifdef WSDISPLAY_SCROLLSUPPORT 303#ifdef WSDISPLAY_SCROLLSUPPORT
301 vga_scroll, 304 vga_scroll,
302#else 305#else
303 NULL, 306 NULL,
@@ -305,27 +308,27 @@ const struct wsdisplay_accessops vga_acc @@ -305,27 +308,27 @@ const struct wsdisplay_accessops vga_acc
305}; 308};
306 309
307/* 310/*
308 * We want at least ASCII 32..127 be present in the 311 * We want at least ASCII 32..127 be present in the
309 * first font slot. 312 * first font slot.
310 */ 313 */
311#define vga_valid_primary_font(f) \ 314#define vga_valid_primary_font(f) \
312 (f->wsfont->encoding == WSDISPLAY_FONTENC_IBM || \ 315 (f->wsfont->encoding == WSDISPLAY_FONTENC_IBM || \
313 f->wsfont->encoding == WSDISPLAY_FONTENC_ISO || \ 316 f->wsfont->encoding == WSDISPLAY_FONTENC_ISO || \
314 f->wsfont->encoding == WSDISPLAY_FONTENC_ISO2 || \ 317 f->wsfont->encoding == WSDISPLAY_FONTENC_ISO2 || \
315 f->wsfont->encoding == WSDISPLAY_FONTENC_ISO7 || \ 318 f->wsfont->encoding == WSDISPLAY_FONTENC_ISO7 || \
316 f->wsfont->encoding == WSDISPLAY_FONTENC_KOI8_R) 319 f->wsfont->encoding == WSDISPLAY_FONTENC_KOI8_R)
317 320
318struct egavga_font * 321static struct egavga_font *
319egavga_getfont(struct vga_config *vc, struct vgascreen *scr, const char *name, 322egavga_getfont(struct vga_config *vc, struct vgascreen *scr, const char *name,
320 int primary) 323 int primary)
321{ 324{
322 struct egavga_font *f; 325 struct egavga_font *f;
323 int cookie; 326 int cookie;
324 struct wsdisplay_font *wf; 327 struct wsdisplay_font *wf;
325 328
326 TAILQ_FOREACH(f, &vc->vc_fontlist, next) { 329 TAILQ_FOREACH(f, &vc->vc_fontlist, next) {
327 if (wsfont_matches(f->wsfont, name, 330 if (wsfont_matches(f->wsfont, name,
328 8, scr->pcs.type->fontheight, 0, WSFONT_FIND_BITMAP) && 331 8, scr->pcs.type->fontheight, 0, WSFONT_FIND_BITMAP) &&
329 (!primary || vga_valid_primary_font(f))) { 332 (!primary || vga_valid_primary_font(f))) {
330#ifdef VGAFONTDEBUG 333#ifdef VGAFONTDEBUG
331 if (scr != &vga_console_screen || vga_console_attached) 334 if (scr != &vga_console_screen || vga_console_attached)
@@ -366,49 +369,49 @@ egavga_getfont(struct vga_config *vc, st @@ -366,49 +369,49 @@ egavga_getfont(struct vga_config *vc, st
366 f->slot = -1; /* not yet loaded */ 369 f->slot = -1; /* not yet loaded */
367 f->usecount = 0; /* incremented below */ 370 f->usecount = 0; /* incremented below */
368 TAILQ_INSERT_TAIL(&vc->vc_fontlist, f, next); 371 TAILQ_INSERT_TAIL(&vc->vc_fontlist, f, next);
369 372
370found: 373found:
371 f->usecount++; 374 f->usecount++;
372#ifdef VGAFONTDEBUG 375#ifdef VGAFONTDEBUG
373 if (scr != &vga_console_screen || vga_console_attached) 376 if (scr != &vga_console_screen || vga_console_attached)
374 printf("vga_getfont: usecount=%d\n", f->usecount); 377 printf("vga_getfont: usecount=%d\n", f->usecount);
375#endif 378#endif
376 return (f); 379 return (f);
377} 380}
378 381
379void 382static void
380egavga_unreffont(struct vga_config *vc, struct egavga_font *f) 383egavga_unreffont(struct vga_config *vc, struct egavga_font *f)
381{ 384{
382 385
383 f->usecount--; 386 f->usecount--;
384#ifdef VGAFONTDEBUG 387#ifdef VGAFONTDEBUG
385 printf("vga_unreffont: usecount=%d\n", f->usecount); 388 printf("vga_unreffont: usecount=%d\n", f->usecount);
386#endif 389#endif
387 if (f->usecount == 0 && f->cookie != -1) { 390 if (f->usecount == 0 && f->cookie != -1) {
388 TAILQ_REMOVE(&vc->vc_fontlist, f, next); 391 TAILQ_REMOVE(&vc->vc_fontlist, f, next);
389 if (f->slot != -1) { 392 if (f->slot != -1) {
390 KASSERT(vc->vc_fonts[f->slot] == f); 393 KASSERT(vc->vc_fonts[f->slot] == f);
391 vc->vc_fonts[f->slot] = 0; 394 vc->vc_fonts[f->slot] = 0;
392 } 395 }
393 wsfont_unlock(f->cookie); 396 wsfont_unlock(f->cookie);
394#ifdef VGA_CONSOLE_SCREENTYPE 397#ifdef VGA_CONSOLE_SCREENTYPE
395 if (f != &vga_consolefont) 398 if (f != &vga_consolefont)
396#endif 399#endif
397 free(f, M_DEVBUF); 400 free(f, M_DEVBUF);
398 } 401 }
399} 402}
400 403
401int 404static int
402vga_selectfont(struct vga_config *vc, struct vgascreen *scr, const char *name1, 405vga_selectfont(struct vga_config *vc, struct vgascreen *scr, const char *name1,
403 const char *name2) 406 const char *name2)
404{ 407{
405 const struct wsscreen_descr *type = scr->pcs.type; 408 const struct wsscreen_descr *type = scr->pcs.type;
406 struct egavga_font *f1, *f2; 409 struct egavga_font *f1, *f2;
407 410
408 f1 = egavga_getfont(vc, scr, name1, 1); 411 f1 = egavga_getfont(vc, scr, name1, 1);
409 if (!f1) 412 if (!f1)
410 return (ENXIO); 413 return (ENXIO);
411 414
412 if (VGA_SCREEN_CANTWOFONTS(type) && name2) { 415 if (VGA_SCREEN_CANTWOFONTS(type) && name2) {
413 f2 = egavga_getfont(vc, scr, name2, 0); 416 f2 = egavga_getfont(vc, scr, name2, 0);
414 if (!f2) { 417 if (!f2) {
@@ -427,27 +430,27 @@ vga_selectfont(struct vga_config *vc, st @@ -427,27 +430,27 @@ vga_selectfont(struct vga_config *vc, st
427 f2->wsfont->name, f2->slot); 430 f2->wsfont->name, f2->slot);
428 printf("\n"); 431 printf("\n");
429 } 432 }
430#endif 433#endif
431 if (scr->fontset1) 434 if (scr->fontset1)
432 egavga_unreffont(vc, scr->fontset1); 435 egavga_unreffont(vc, scr->fontset1);
433 scr->fontset1 = f1; 436 scr->fontset1 = f1;
434 if (scr->fontset2) 437 if (scr->fontset2)
435 egavga_unreffont(vc, scr->fontset2); 438 egavga_unreffont(vc, scr->fontset2);
436 scr->fontset2 = f2; 439 scr->fontset2 = f2;
437 return (0); 440 return (0);
438} 441}
439 442
440void 443static void
441vga_init_screen(struct vga_config *vc, struct vgascreen *scr, 444vga_init_screen(struct vga_config *vc, struct vgascreen *scr,
442 const struct wsscreen_descr *type, int existing, long *attrp) 445 const struct wsscreen_descr *type, int existing, long *attrp)
443{ 446{
444 int cpos; 447 int cpos;
445 int res; 448 int res;
446 449
447 scr->cfg = vc; 450 scr->cfg = vc;
448 scr->pcs.hdl = (struct pcdisplay_handle *)&vc->hdl; 451 scr->pcs.hdl = (struct pcdisplay_handle *)&vc->hdl;
449 scr->pcs.type = type; 452 scr->pcs.type = type;
450 scr->pcs.active = existing; 453 scr->pcs.active = existing;
451 scr->mindispoffset = 0; 454 scr->mindispoffset = 0;
452 if (vc->vc_quirks & VGA_QUIRK_NOFASTSCROLL) 455 if (vc->vc_quirks & VGA_QUIRK_NOFASTSCROLL)
453 scr->maxdispoffset = 0; 456 scr->maxdispoffset = 0;
@@ -513,27 +516,27 @@ vga_init_screen(struct vga_config *vc, s @@ -513,27 +516,27 @@ vga_init_screen(struct vga_config *vc, s
513 if (vga_selectfont(vc, scr, 0, 0)) { 516 if (vga_selectfont(vc, scr, 0, 0)) {
514 if (scr == &vga_console_screen) 517 if (scr == &vga_console_screen)
515 panic("vga_init_screen: no font"); 518 panic("vga_init_screen: no font");
516 else 519 else
517 printf("vga_init_screen: no font\n"); 520 printf("vga_init_screen: no font\n");
518 } 521 }
519 if (existing) 522 if (existing)
520 vga_setfont(vc, scr); 523 vga_setfont(vc, scr);
521 524
522 vc->nscreens++; 525 vc->nscreens++;
523 LIST_INSERT_HEAD(&vc->screens, scr, next); 526 LIST_INSERT_HEAD(&vc->screens, scr, next);
524} 527}
525 528
526void 529static void
527vga_init(struct vga_config *vc, bus_space_tag_t iot, bus_space_tag_t memt) 530vga_init(struct vga_config *vc, bus_space_tag_t iot, bus_space_tag_t memt)
528{ 531{
529 struct vga_handle *vh = &vc->hdl; 532 struct vga_handle *vh = &vc->hdl;
530 uint8_t mor; 533 uint8_t mor;
531 int i; 534 int i;
532 535
533 vh->vh_iot = iot; 536 vh->vh_iot = iot;
534 vh->vh_memt = memt; 537 vh->vh_memt = memt;
535 538
536 if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga)) 539 if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga))
537 panic("vga_init: couldn't map vga io"); 540 panic("vga_init: couldn't map vga io");
538 541
539 /* read "misc output register" */ 542 /* read "misc output register" */
@@ -765,27 +768,27 @@ vga_set_video(struct vga_config *vc, int @@ -765,27 +768,27 @@ vga_set_video(struct vga_config *vc, int
765 vga_6845_write(&vc->hdl, mode, val | 0x80); 768 vga_6845_write(&vc->hdl, mode, val | 0x80);
766#endif 769#endif
767 } else { /* blank screen */ 770 } else { /* blank screen */
768 val = vga_ts_read(&vc->hdl, mode); 771 val = vga_ts_read(&vc->hdl, mode);
769 vga_ts_write(&vc->hdl, mode, val | VGA_TS_MODE_BLANK); 772 vga_ts_write(&vc->hdl, mode, val | VGA_TS_MODE_BLANK);
770#ifndef VGA_NO_VBLANK 773#ifndef VGA_NO_VBLANK
771 val = vga_6845_read(&vc->hdl, mode); 774 val = vga_6845_read(&vc->hdl, mode);
772 vga_6845_write(&vc->hdl, mode, val & ~0x80); 775 vga_6845_write(&vc->hdl, mode, val & ~0x80);
773#endif 776#endif
774 } 777 }
775 vga_ts_write(&vc->hdl, syncreset, 0x03); 778 vga_ts_write(&vc->hdl, syncreset, 0x03);
776} 779}
777 780
778int 781static int
779vga_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l) 782vga_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
780{ 783{
781 struct vga_config *vc = v; 784 struct vga_config *vc = v;
782 struct vgascreen *scr = vs; 785 struct vgascreen *scr = vs;
783 const struct vga_funcs *vf = vc->vc_funcs; 786 const struct vga_funcs *vf = vc->vc_funcs;
784 787
785 switch (cmd) { 788 switch (cmd) {
786 case WSDISPLAYIO_SMODE: 789 case WSDISPLAYIO_SMODE:
787 if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL) 790 if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL)
788 vga_restore_palette(vc); 791 vga_restore_palette(vc);
789 return 0; 792 return 0;
790 793
791 case WSDISPLAYIO_GTYPE: 794 case WSDISPLAYIO_GTYPE:
@@ -848,27 +851,27 @@ vga_mmap(void *v, void *vs, off_t offset @@ -848,27 +851,27 @@ vga_mmap(void *v, void *vs, off_t offset
848{ 851{
849 struct vga_config *vc = v; 852 struct vga_config *vc = v;
850 const struct vga_funcs *vf = vc->vc_funcs; 853 const struct vga_funcs *vf = vc->vc_funcs;
851 854
852 if (vc->vc_funcs == NULL) 855 if (vc->vc_funcs == NULL)
853 return (-1); 856 return (-1);
854 857
855 if (vf->vf_mmap == NULL) 858 if (vf->vf_mmap == NULL)
856 return (-1); 859 return (-1);
857 860
858 return ((*vf->vf_mmap)(v, offset, prot)); 861 return ((*vf->vf_mmap)(v, offset, prot));
859} 862}
860 863
861int 864static int
862vga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, 865vga_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
863 int *curxp, int *curyp, long *defattrp) 866 int *curxp, int *curyp, long *defattrp)
864{ 867{
865 struct vga_config *vc = v; 868 struct vga_config *vc = v;
866 struct vgascreen *scr; 869 struct vgascreen *scr;
867 870
868 if (vc->nscreens == 1) { 871 if (vc->nscreens == 1) {
869 struct vgascreen *scr1 = vc->screens.lh_first; 872 struct vgascreen *scr1 = vc->screens.lh_first;
870 /* 873 /*
871 * When allocating the second screen, get backing store 874 * When allocating the second screen, get backing store
872 * for the first one too. 875 * for the first one too.
873 * XXX We could be more clever and use video RAM. 876 * XXX We could be more clever and use video RAM.
874 */ 877 */
@@ -883,27 +886,27 @@ vga_alloc_screen(void *v, const struct w @@ -883,27 +886,27 @@ vga_alloc_screen(void *v, const struct w
883 if (vc->nscreens > 1) { 886 if (vc->nscreens > 1) {
884 scr->pcs.mem = malloc(type->ncols * type->nrows * 2, 887 scr->pcs.mem = malloc(type->ncols * type->nrows * 2,
885 M_DEVBUF, M_WAITOK); 888 M_DEVBUF, M_WAITOK);
886 pcdisplay_eraserows(&scr->pcs, 0, type->nrows, *defattrp); 889 pcdisplay_eraserows(&scr->pcs, 0, type->nrows, *defattrp);
887 } 890 }
888 891
889 *cookiep = scr; 892 *cookiep = scr;
890 *curxp = scr->pcs.cursorcol; 893 *curxp = scr->pcs.cursorcol;
891 *curyp = scr->pcs.cursorrow; 894 *curyp = scr->pcs.cursorrow;
892 895
893 return (0); 896 return (0);
894} 897}
895 898
896void 899static void
897vga_free_screen(void *v, void *cookie) 900vga_free_screen(void *v, void *cookie)
898{ 901{
899 struct vgascreen *vs = cookie; 902 struct vgascreen *vs = cookie;
900 struct vga_config *vc = vs->cfg; 903 struct vga_config *vc = vs->cfg;
901 904
902 LIST_REMOVE(vs, next); 905 LIST_REMOVE(vs, next);
903 vc->nscreens--; 906 vc->nscreens--;
904 if (vs->fontset1) 907 if (vs->fontset1)
905 egavga_unreffont(vc, vs->fontset1); 908 egavga_unreffont(vc, vs->fontset1);
906 if (vs->fontset2) 909 if (vs->fontset2)
907 egavga_unreffont(vc, vs->fontset2); 910 egavga_unreffont(vc, vs->fontset2);
908 911
909 if (vs != &vga_console_screen) 912 if (vs != &vga_console_screen)
@@ -963,52 +966,52 @@ vga_setfont(struct vga_config *vc, struc @@ -963,52 +966,52 @@ vga_setfont(struct vga_config *vc, struc
963 if (scr->fontset2) 966 if (scr->fontset2)
964 vga_usefont(vc, scr->fontset2); 967 vga_usefont(vc, scr->fontset2);
965 968
966 fontslot1 = (scr->fontset1 ? scr->fontset1->slot : 0); 969 fontslot1 = (scr->fontset1 ? scr->fontset1->slot : 0);
967 fontslot2 = (scr->fontset2 ? scr->fontset2->slot : fontslot1); 970 fontslot2 = (scr->fontset2 ? scr->fontset2->slot : fontslot1);
968 if (vc->currentfontset1 != fontslot1 || 971 if (vc->currentfontset1 != fontslot1 ||
969 vc->currentfontset2 != fontslot2) { 972 vc->currentfontset2 != fontslot2) {
970 vga_setfontset(&vc->hdl, fontslot1, fontslot2); 973 vga_setfontset(&vc->hdl, fontslot1, fontslot2);
971 vc->currentfontset1 = fontslot1; 974 vc->currentfontset1 = fontslot1;
972 vc->currentfontset2 = fontslot2; 975 vc->currentfontset2 = fontslot2;
973 } 976 }
974} 977}
975 978
976int 979static int
977vga_show_screen(void *v, void *cookie, int waitok, 980vga_show_screen(void *v, void *cookie, int waitok,
978 void (*cb)(void *, int, int), void *cbarg) 981 void (*cb)(void *, int, int), void *cbarg)
979{ 982{
980 struct vgascreen *scr = cookie, *oldscr; 983 struct vgascreen *scr = cookie, *oldscr;
981 struct vga_config *vc = scr->cfg; 984 struct vga_config *vc = scr->cfg;
982 985
983 oldscr = vc->active; /* can be NULL! */ 986 oldscr = vc->active; /* can be NULL! */
984 if (scr == oldscr) { 987 if (scr == oldscr) {
985 return (0); 988 return (0);
986 } 989 }
987 990
988 vc->wantedscreen = cookie; 991 vc->wantedscreen = cookie;
989 vc->switchcb = cb; 992 vc->switchcb = cb;
990 vc->switchcbarg = cbarg; 993 vc->switchcbarg = cbarg;
991 if (cb) { 994 if (cb) {
992 callout_reset(&vc->vc_switch_callout, 0, 995 callout_reset(&vc->vc_switch_callout, 0,
993 (void(*)(void *))vga_doswitch, vc); 996 (void(*)(void *))vga_doswitch, vc);
994 return (EAGAIN); 997 return (EAGAIN);
995 } 998 }
996 999
997 vga_doswitch(vc); 1000 vga_doswitch(vc);
998 return (0); 1001 return (0);
999} 1002}
1000 1003
1001void 1004static void
1002vga_doswitch(struct vga_config *vc) 1005vga_doswitch(struct vga_config *vc)
1003{ 1006{
1004 struct vgascreen *scr, *oldscr; 1007 struct vgascreen *scr, *oldscr;
1005 struct vga_handle *vh = &vc->hdl; 1008 struct vga_handle *vh = &vc->hdl;
1006 const struct wsscreen_descr *type; 1009 const struct wsscreen_descr *type;
1007 1010
1008 scr = vc->wantedscreen; 1011 scr = vc->wantedscreen;
1009 if (!scr) { 1012 if (!scr) {
1010 printf("vga_doswitch: disappeared\n"); 1013 printf("vga_doswitch: disappeared\n");
1011 (*vc->switchcb)(vc->switchcbarg, EIO, 0); 1014 (*vc->switchcb)(vc->switchcbarg, EIO, 0);
1012 return; 1015 return;
1013 } 1016 }
1014 type = scr->pcs.type; 1017 type = scr->pcs.type;
@@ -1442,27 +1445,27 @@ vga_mapchar(void *id, int uni, u_int *in @@ -1442,27 +1445,27 @@ vga_mapchar(void *id, int uni, u_int *in
1442 if (scr->fontset2) { 1445 if (scr->fontset2) {
1443 KASSERT(VGA_SCREEN_CANTWOFONTS(scr->pcs.type)); 1446 KASSERT(VGA_SCREEN_CANTWOFONTS(scr->pcs.type));
1444 res2 = _vga_mapchar(id, scr->fontset2, uni, &idx2); 1447 res2 = _vga_mapchar(id, scr->fontset2, uni, &idx2);
1445 } 1448 }
1446 if (res2 > res1) { 1449 if (res2 > res1) {
1447 *index = idx2 | 0x0800; /* attribute bit 3 */ 1450 *index = idx2 | 0x0800; /* attribute bit 3 */
1448 return (res2); 1451 return (res2);
1449 } 1452 }
1450 *index = idx1; 1453 *index = idx1;
1451 return (res1); 1454 return (res1);
1452} 1455}
1453 1456
1454#ifdef WSDISPLAY_SCROLLSUPPORT 1457#ifdef WSDISPLAY_SCROLLSUPPORT
1455void 1458static void
1456vga_scroll(void *v, void *cookie, int lines) 1459vga_scroll(void *v, void *cookie, int lines)
1457{ 1460{
1458 struct vga_config *vc = v; 1461 struct vga_config *vc = v;
1459 struct vgascreen *scr = cookie; 1462 struct vgascreen *scr = cookie;
1460 struct vga_handle *vh = &vc->hdl; 1463 struct vga_handle *vh = &vc->hdl;
1461 1464
1462 if (lines == 0) { 1465 if (lines == 0) {
1463 if (scr->pcs.visibleoffset == scr->pcs.dispoffset) 1466 if (scr->pcs.visibleoffset == scr->pcs.dispoffset)
1464 return; 1467 return;
1465 1468
1466 scr->pcs.visibleoffset = scr->pcs.dispoffset; 1469 scr->pcs.visibleoffset = scr->pcs.dispoffset;
1467 } 1470 }
1468 else { 1471 else {
@@ -1484,27 +1487,27 @@ vga_scroll(void *v, void *cookie, int li @@ -1484,27 +1487,27 @@ vga_scroll(void *v, void *cookie, int li
1484 st = (scr->pcs.dispoffset - ul + we) % we; 1487 st = (scr->pcs.dispoffset - ul + we) % we;
1485 if (p < margin) 1488 if (p < margin)
1486 p = 0; 1489 p = 0;
1487 if (p > st - margin) 1490 if (p > st - margin)
1488 p = st; 1491 p = st;
1489 scr->pcs.visibleoffset = (p + ul) % we; 1492 scr->pcs.visibleoffset = (p + ul) % we;
1490 } 1493 }
1491 1494
1492 vga_6845_write(vh, startadrh, scr->pcs.visibleoffset >> 9); 1495 vga_6845_write(vh, startadrh, scr->pcs.visibleoffset >> 9);
1493 vga_6845_write(vh, startadrl, scr->pcs.visibleoffset >> 1); 1496 vga_6845_write(vh, startadrl, scr->pcs.visibleoffset >> 1);
1494} 1497}
1495#endif 1498#endif
1496 1499
1497void 1500static void
1498vga_putchar(void *c, int row, int col, u_int uc, long attr) 1501vga_putchar(void *c, int row, int col, u_int uc, long attr)
1499{ 1502{
1500 1503
1501 pcdisplay_putchar(c, row, col, uc, attr); 1504 pcdisplay_putchar(c, row, col, uc, attr);
1502} 1505}
1503 1506
1504#ifdef WSDISPLAY_CUSTOM_BORDER 1507#ifdef WSDISPLAY_CUSTOM_BORDER
1505static int 1508static int
1506vga_getborder(struct vga_config *vc, u_int *valuep) 1509vga_getborder(struct vga_config *vc, u_int *valuep)
1507{ 1510{
1508 struct vga_handle *vh = &vc->hdl; 1511 struct vga_handle *vh = &vc->hdl;
1509 u_int idx; 1512 u_int idx;
1510 uint8_t value; 1513 uint8_t value;
@@ -1540,45 +1543,45 @@ vga_setborder(struct vga_config *vc, u_i @@ -1540,45 +1543,45 @@ vga_setborder(struct vga_config *vc, u_i
1540void 1543void
1541vga_resume(struct vga_softc *sc) 1544vga_resume(struct vga_softc *sc)
1542{ 1545{
1543#ifdef VGA_RESET_ON_RESUME 1546#ifdef VGA_RESET_ON_RESUME
1544 vga_initregs(&sc->sc_vc->hdl); 1547 vga_initregs(&sc->sc_vc->hdl);
1545#endif 1548#endif
1546#ifdef PCDISPLAY_SOFTCURSOR 1549#ifdef PCDISPLAY_SOFTCURSOR
1547 /* Disable the hardware cursor */ 1550 /* Disable the hardware cursor */
1548 vga_6845_write(&sc->sc_vc->hdl, curstart, 0x20); 1551 vga_6845_write(&sc->sc_vc->hdl, curstart, 0x20);
1549 vga_6845_write(&sc->sc_vc->hdl, curend, 0x00); 1552 vga_6845_write(&sc->sc_vc->hdl, curend, 0x00);
1550#endif 1553#endif
1551} 1554}
1552 1555
1553void 1556static void
1554vga_save_palette(struct vga_config *vc) 1557vga_save_palette(struct vga_config *vc)
1555{ 1558{
1556 struct vga_handle *vh = &vc->hdl; 1559 struct vga_handle *vh = &vc->hdl;
1557 size_t i; 1560 size_t i;
1558 uint8_t *palette = vc->palette; 1561 uint8_t *palette = vc->palette;
1559 1562
1560 if (vh->vh_mono) 1563 if (vh->vh_mono)
1561 return; 1564 return;
1562 1565
1563 vga_raw_write(vh, VGA_DAC_PELMASK, 0xff); 1566 vga_raw_write(vh, VGA_DAC_PELMASK, 0xff);
1564 vga_raw_write(vh, VGA_DAC_ADDRR, 0x00); 1567 vga_raw_write(vh, VGA_DAC_ADDRR, 0x00);
1565 for (i = 0; i < sizeof(vc->palette); i++) 1568 for (i = 0; i < sizeof(vc->palette); i++)
1566 *palette++ = vga_raw_read(vh, VGA_DAC_PALETTE); 1569 *palette++ = vga_raw_read(vh, VGA_DAC_PALETTE);
1567 1570
1568 vga_reset_state(vh); /* reset flip/flop */ 1571 vga_reset_state(vh); /* reset flip/flop */
1569} 1572}
1570 1573
1571void 1574static void
1572vga_restore_palette(struct vga_config *vc) 1575vga_restore_palette(struct vga_config *vc)
1573{ 1576{
1574 struct vga_handle *vh = &vc->hdl; 1577 struct vga_handle *vh = &vc->hdl;
1575 size_t i; 1578 size_t i;
1576 uint8_t *palette = vc->palette; 1579 uint8_t *palette = vc->palette;
1577 1580
1578 if (vh->vh_mono) 1581 if (vh->vh_mono)
1579 return; 1582 return;
1580 1583
1581 vga_raw_write(vh, VGA_DAC_PELMASK, 0xff); 1584 vga_raw_write(vh, VGA_DAC_PELMASK, 0xff);
1582 vga_raw_write(vh, VGA_DAC_ADDRW, 0x00); 1585 vga_raw_write(vh, VGA_DAC_ADDRW, 0x00);
1583 for (i = 0; i < sizeof(vc->palette); i++) 1586 for (i = 0; i < sizeof(vc->palette); i++)
1584 vga_raw_write(vh, VGA_DAC_PALETTE, *palette++); 1587 vga_raw_write(vh, VGA_DAC_PALETTE, *palette++);

cvs diff -r1.35 -r1.36 src/sys/dev/ic/vga_raster.c (expand / switch to unified diff)

--- src/sys/dev/ic/vga_raster.c 2012/01/11 20:41:28 1.35
+++ src/sys/dev/ic/vga_raster.c 2013/01/21 19:49:15 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vga_raster.c,v 1.35 2012/01/11 20:41:28 macallan Exp $ */ 1/* $NetBSD: vga_raster.c,v 1.36 2013/01/21 19:49:15 mlelstv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002 Bang Jun-Young 4 * Copyright (c) 2001, 2002 Bang Jun-Young
5 * Copyright (c) 2004 Julio M. Merino Vidal 5 * Copyright (c) 2004 Julio M. Merino Vidal
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -46,27 +46,27 @@ @@ -46,27 +46,27 @@
46 * 46 *
47 * Carnegie Mellon requests users of this software to return to 47 * Carnegie Mellon requests users of this software to return to
48 * 48 *
49 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
50 * School of Computer Science 50 * School of Computer Science
51 * Carnegie Mellon University 51 * Carnegie Mellon University
52 * Pittsburgh PA 15213-3890 52 * Pittsburgh PA 15213-3890
53 * 53 *
54 * any improvements or extensions that they make and grant Carnegie the 54 * any improvements or extensions that they make and grant Carnegie the
55 * rights to redistribute these changes. 55 * rights to redistribute these changes.
56 */ 56 */
57 57
58#include <sys/cdefs.h> 58#include <sys/cdefs.h>
59__KERNEL_RCSID(0, "$NetBSD: vga_raster.c,v 1.35 2012/01/11 20:41:28 macallan Exp $"); 59__KERNEL_RCSID(0, "$NetBSD: vga_raster.c,v 1.36 2013/01/21 19:49:15 mlelstv Exp $");
60 60
61#include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */ 61#include "opt_wsmsgattrs.h" /* for WSDISPLAY_CUSTOM_OUTPUT */
62 62
63#include <sys/param.h> 63#include <sys/param.h>
64#include <sys/systm.h> 64#include <sys/systm.h>
65#include <sys/callout.h> 65#include <sys/callout.h>
66#include <sys/kernel.h> 66#include <sys/kernel.h>
67#include <sys/device.h> 67#include <sys/device.h>
68#include <sys/malloc.h> 68#include <sys/malloc.h>
69#include <sys/queue.h> 69#include <sys/queue.h>
70#include <sys/bus.h> 70#include <sys/bus.h>
71 71
72#include <dev/ic/mc6845reg.h> 72#include <dev/ic/mc6845reg.h>
@@ -362,27 +362,27 @@ vga_cnattach(bus_space_tag_t iot, bus_sp @@ -362,27 +362,27 @@ vga_cnattach(bus_space_tag_t iot, bus_sp
362 362
363 vga_console_screen.active = 1; 363 vga_console_screen.active = 1;
364 vga_console_vc.active = &vga_console_screen; 364 vga_console_vc.active = &vga_console_screen;
365 365
366 wsdisplay_cnattach(scr, &vga_console_screen, 366 wsdisplay_cnattach(scr, &vga_console_screen,
367 vga_console_screen.cursorcol, vga_console_screen.cursorrow, 367 vga_console_screen.cursorcol, vga_console_screen.cursorrow,
368 defattr); 368 defattr);
369 369
370 vgaconsole = 1; 370 vgaconsole = 1;
371 vga_console_type = type; 371 vga_console_type = type;
372 return (0); 372 return (0);
373} 373}
374 374
375void 375static void
376vga_raster_init(struct vga_config *vc, bus_space_tag_t iot, 376vga_raster_init(struct vga_config *vc, bus_space_tag_t iot,
377 bus_space_tag_t memt) 377 bus_space_tag_t memt)
378{ 378{
379 struct vga_handle *vh = &vc->hdl; 379 struct vga_handle *vh = &vc->hdl;
380 u_int8_t mor; 380 u_int8_t mor;
381 struct vga_raster_font *vf; 381 struct vga_raster_font *vf;
382 382
383 vh->vh_iot = iot; 383 vh->vh_iot = iot;
384 vh->vh_memt = memt; 384 vh->vh_memt = memt;
385 385
386 if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga)) 386 if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga))
387 panic("vga_raster_init: couldn't map vga io"); 387 panic("vga_raster_init: couldn't map vga io");
388 388
@@ -429,27 +429,27 @@ vga_raster_init(struct vga_config *vc, b @@ -429,27 +429,27 @@ vga_raster_init(struct vga_config *vc, b
429 cookie = wsfont_find(NULL, 0, 0, 0, 429 cookie = wsfont_find(NULL, 0, 0, 0,
430 WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R, 430 WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R,
431 WSFONT_FIND_BITMAP); 431 WSFONT_FIND_BITMAP);
432 if (cookie == -1 || wsfont_lock(cookie, &wf)) 432 if (cookie == -1 || wsfont_lock(cookie, &wf))
433 panic("vga_raster_init: can't load console font"); 433 panic("vga_raster_init: can't load console font");
434 vf->font = wf; 434 vf->font = wf;
435 } else { 435 } else {
436 vga_load_builtinfont(vh, builtinfont_data, 0, 256); 436 vga_load_builtinfont(vh, builtinfont_data, 0, 256);
437 vf->font = &builtinfont; 437 vf->font = &builtinfont;
438 } 438 }
439 LIST_INSERT_HEAD(&vc->vc_fontlist, vf, next); 439 LIST_INSERT_HEAD(&vc->vc_fontlist, vf, next);
440} 440}
441 441
442void 442static void
443vga_raster_init_screen(struct vga_config *vc, struct vgascreen *scr, 443vga_raster_init_screen(struct vga_config *vc, struct vgascreen *scr,
444 const struct wsscreen_descr *type, int existing, long *attrp) 444 const struct wsscreen_descr *type, int existing, long *attrp)
445{ 445{
446 int cpos; 446 int cpos;
447 int res; 447 int res;
448 struct vga_handle *vh; 448 struct vga_handle *vh;
449 449
450 scr->cfg = vc; 450 scr->cfg = vc;
451 scr->hdl = &vc->hdl; 451 scr->hdl = &vc->hdl;
452 scr->type = type; 452 scr->type = type;
453 scr->mindispoffset = 0; 453 scr->mindispoffset = 0;
454 scr->maxdispoffset = scr->dispoffset + 454 scr->maxdispoffset = scr->dispoffset +
455 type->nrows * type->ncols * type->fontheight; 455 type->nrows * type->ncols * type->fontheight;
@@ -674,27 +674,27 @@ vga_raster_mmap(void *v, void *vs, off_t @@ -674,27 +674,27 @@ vga_raster_mmap(void *v, void *vs, off_t
674{ 674{
675 struct vga_config *vc = v; 675 struct vga_config *vc = v;
676 const struct vga_funcs *vf = vc->vc_funcs; 676 const struct vga_funcs *vf = vc->vc_funcs;
677 677
678 if (vc->vc_funcs == NULL) 678 if (vc->vc_funcs == NULL)
679 return (-1); 679 return (-1);
680 680
681 if (vf->vf_mmap == NULL) 681 if (vf->vf_mmap == NULL)
682 return (-1); 682 return (-1);
683 683
684 return ((*vf->vf_mmap)(v, offset, prot)); 684 return ((*vf->vf_mmap)(v, offset, prot));
685} 685}
686 686
687int 687static int
688vga_raster_alloc_screen(void *v, const struct wsscreen_descr *type, 688vga_raster_alloc_screen(void *v, const struct wsscreen_descr *type,
689 void **cookiep, int *curxp, int *curyp, long *defattrp) 689 void **cookiep, int *curxp, int *curyp, long *defattrp)
690{ 690{
691 struct vga_config *vc = v; 691 struct vga_config *vc = v;
692 struct vgascreen *scr; 692 struct vgascreen *scr;
693 693
694 if (vc->nscreens == 1) { 694 if (vc->nscreens == 1) {
695 vc->screens.lh_first->mem = boot_scrmem; 695 vc->screens.lh_first->mem = boot_scrmem;
696 } 696 }
697 697
698 scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK); 698 scr = malloc(sizeof(struct vgascreen), M_DEVBUF, M_WAITOK);
699 vga_raster_init_screen(vc, scr, type, vc->nscreens == 0, defattrp); 699 vga_raster_init_screen(vc, scr, type, vc->nscreens == 0, defattrp);
700 700
@@ -705,69 +705,69 @@ vga_raster_alloc_screen(void *v, const s @@ -705,69 +705,69 @@ vga_raster_alloc_screen(void *v, const s
705 } else { 705 } else {
706 scr->mem = malloc(sizeof(struct vga_scrmem) * 706 scr->mem = malloc(sizeof(struct vga_scrmem) *
707 type->ncols * type->nrows, M_DEVBUF, M_WAITOK); 707 type->ncols * type->nrows, M_DEVBUF, M_WAITOK);
708 vga_raster_eraserows(scr, 0, type->nrows, *defattrp); 708 vga_raster_eraserows(scr, 0, type->nrows, *defattrp);
709 } 709 }
710 710
711 *cookiep = scr; 711 *cookiep = scr;
712 *curxp = scr->cursorcol; 712 *curxp = scr->cursorcol;
713 *curyp = scr->cursorrow; 713 *curyp = scr->cursorrow;
714 714
715 return (0); 715 return (0);
716} 716}
717 717
718void 718static void
719vga_raster_free_screen(void *v, void *cookie) 719vga_raster_free_screen(void *v, void *cookie)
720{ 720{
721 struct vgascreen *vs = cookie; 721 struct vgascreen *vs = cookie;
722 struct vga_config *vc = vs->cfg; 722 struct vga_config *vc = vs->cfg;
723 723
724 LIST_REMOVE(vs, next); 724 LIST_REMOVE(vs, next);
725 vc->nscreens--; 725 vc->nscreens--;
726 if (vs != &vga_console_screen) 726 if (vs != &vga_console_screen)
727 free(vs, M_DEVBUF); 727 free(vs, M_DEVBUF);
728 else 728 else
729 panic("vga_raster_free_screen: console"); 729 panic("vga_raster_free_screen: console");
730 730
731 if (vc->active == vs) 731 if (vc->active == vs)
732 vc->active = 0; 732 vc->active = 0;
733} 733}
734 734
735int 735static int
736vga_raster_show_screen(void *v, void *cookie, int waitok, 736vga_raster_show_screen(void *v, void *cookie, int waitok,
737 void (*cb)(void *, int, int), void *cbarg) 737 void (*cb)(void *, int, int), void *cbarg)
738{ 738{
739 struct vgascreen *scr = cookie, *oldscr; 739 struct vgascreen *scr = cookie, *oldscr;
740 struct vga_config *vc = scr->cfg; 740 struct vga_config *vc = scr->cfg;
741 741
742 oldscr = vc->active; /* can be NULL! */ 742 oldscr = vc->active; /* can be NULL! */
743 if (scr == oldscr) { 743 if (scr == oldscr) {
744 return (0); 744 return (0);
745 } 745 }
746 746
747 vc->wantedscreen = cookie; 747 vc->wantedscreen = cookie;
748 vc->switchcb = cb; 748 vc->switchcb = cb;
749 vc->switchcbarg = cbarg; 749 vc->switchcbarg = cbarg;
750 if (cb) { 750 if (cb) {
751 callout_reset(&vc->vc_switch_callout, 0, 751 callout_reset(&vc->vc_switch_callout, 0,
752 (void(*)(void *))vga_switch_screen, vc); 752 (void(*)(void *))vga_switch_screen, vc);
753 return (EAGAIN); 753 return (EAGAIN);
754 } 754 }
755 755
756 vga_switch_screen(vc); 756 vga_switch_screen(vc);
757 return (0); 757 return (0);
758} 758}
759 759
760void 760static void
761vga_switch_screen(struct vga_config *vc) 761vga_switch_screen(struct vga_config *vc)
762{ 762{
763 struct vgascreen *scr, *oldscr; 763 struct vgascreen *scr, *oldscr;
764 struct vga_handle *vh = &vc->hdl; 764 struct vga_handle *vh = &vc->hdl;
765 const struct wsscreen_descr *type; 765 const struct wsscreen_descr *type;
766 766
767 scr = vc->wantedscreen; 767 scr = vc->wantedscreen;
768 if (!scr) { 768 if (!scr) {
769 printf("vga_switch_screen: disappeared\n"); 769 printf("vga_switch_screen: disappeared\n");
770 (*vc->switchcb)(vc->switchcbarg, EIO, 0); 770 (*vc->switchcb)(vc->switchcbarg, EIO, 0);
771 return; 771 return;
772 } 772 }
773 type = scr->type; 773 type = scr->type;
@@ -819,27 +819,27 @@ vga_switch_screen(struct vga_config *vc) @@ -819,27 +819,27 @@ vga_switch_screen(struct vga_config *vc)
819 (*vc->switchcb)(vc->switchcbarg, 0, 0); 819 (*vc->switchcb)(vc->switchcbarg, 0, 0);
820} 820}
821 821
822static int 822static int
823vga_raster_load_font(void *v, void *id, 823vga_raster_load_font(void *v, void *id,
824 struct wsdisplay_font *data) 824 struct wsdisplay_font *data)
825{ 825{
826 /* XXX */ 826 /* XXX */
827 printf("vga_raster_load_font: called\n"); 827 printf("vga_raster_load_font: called\n");
828 828
829 return (0); 829 return (0);
830} 830}
831 831
832void 832static void
833vga_raster_setup_font(struct vga_config *vc, struct vgascreen *scr) 833vga_raster_setup_font(struct vga_config *vc, struct vgascreen *scr)
834{ 834{
835 struct vga_raster_font *vf; 835 struct vga_raster_font *vf;
836 struct wsdisplay_font *wf; 836 struct wsdisplay_font *wf;
837 int cookie; 837 int cookie;
838 838
839 LIST_FOREACH(vf, &vc->vc_fontlist, next) { 839 LIST_FOREACH(vf, &vc->vc_fontlist, next) {
840 if (wsfont_matches(vf->font, 0, 0, scr->type->fontheight, 0, 840 if (wsfont_matches(vf->font, 0, 0, scr->type->fontheight, 0,
841 WSFONT_FIND_BITMAP)) { 841 WSFONT_FIND_BITMAP)) {
842 scr->encoding = vf->font->encoding; 842 scr->encoding = vf->font->encoding;
843 LIST_INSERT_HEAD(&scr->fontset, vf, next); 843 LIST_INSERT_HEAD(&scr->fontset, vf, next);
844 return; 844 return;
845 } 845 }
@@ -854,27 +854,27 @@ vga_raster_setup_font(struct vga_config  @@ -854,27 +854,27 @@ vga_raster_setup_font(struct vga_config
854 return; 854 return;
855 855
856 vf = malloc(sizeof(struct vga_raster_font), M_DEVBUF, M_NOWAIT); 856 vf = malloc(sizeof(struct vga_raster_font), M_DEVBUF, M_NOWAIT);
857 if (!vf) { 857 if (!vf) {
858 wsfont_unlock(cookie); 858 wsfont_unlock(cookie);
859 return; 859 return;
860 } 860 }
861 861
862 vf->font = wf; 862 vf->font = wf;
863 scr->encoding = vf->font->encoding; 863 scr->encoding = vf->font->encoding;
864 LIST_INSERT_HEAD(&scr->fontset, vf, next); 864 LIST_INSERT_HEAD(&scr->fontset, vf, next);
865} 865}
866 866
867void 867static void
868vga_setup_regs(struct videomode *mode, struct vga_moderegs *regs) 868vga_setup_regs(struct videomode *mode, struct vga_moderegs *regs)
869{ 869{
870 int i; 870 int i;
871 int depth = 4; /* XXXBJY hardcoded for now */ 871 int depth = 4; /* XXXBJY hardcoded for now */
872 const u_int8_t palette[] = { 872 const u_int8_t palette[] = {
873 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 873 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
874 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f 874 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
875 }; 875 };
876 876
877 /* 877 /*
878 * Compute hsync and vsync polarity. 878 * Compute hsync and vsync polarity.
879 */ 879 */
880 if ((mode->flags & (VID_PHSYNC | VID_NHSYNC)) 880 if ((mode->flags & (VID_PHSYNC | VID_NHSYNC))
@@ -979,27 +979,27 @@ vga_setup_regs(struct videomode *mode, s @@ -979,27 +979,27 @@ vga_setup_regs(struct videomode *mode, s
979 /* Set palette registers. */ 979 /* Set palette registers. */
980 for (i = 0; i < 16; i++) 980 for (i = 0; i < 16; i++)
981 regs->atc[i] = palette[i]; 981 regs->atc[i] = palette[i];
982 if (depth == 4) 982 if (depth == 4)
983 regs->atc[16] = 0x01; /* XXXBJY was 0x81 in XFree86 */ 983 regs->atc[16] = 0x01; /* XXXBJY was 0x81 in XFree86 */
984 else 984 else
985 regs->atc[16] = 0x41; 985 regs->atc[16] = 0x41;
986 regs->atc[17] = 0x00; /* XXXBJY just a guess */ 986 regs->atc[17] = 0x00; /* XXXBJY just a guess */
987 regs->atc[18] = 0x0f; 987 regs->atc[18] = 0x0f;
988 regs->atc[19] = 0x00; 988 regs->atc[19] = 0x00;
989 regs->atc[20] = 0x00; 989 regs->atc[20] = 0x00;
990} 990}
991 991
992void 992static void
993vga_set_mode(struct vga_handle *vh, struct vga_moderegs *regs) 993vga_set_mode(struct vga_handle *vh, struct vga_moderegs *regs)
994{ 994{
995 int i; 995 int i;
996 996
997 /* Disable display. */ 997 /* Disable display. */
998 vga_ts_write(vh, mode, vga_ts_read(vh, mode) | VGA_TS_MODE_BLANK); 998 vga_ts_write(vh, mode, vga_ts_read(vh, mode) | VGA_TS_MODE_BLANK);
999 999
1000 /* Write misc output register. */ 1000 /* Write misc output register. */
1001 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAW, 1001 bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAW,
1002 regs->miscout); 1002 regs->miscout);
1003 1003
1004 /* Set synchronous reset. */ 1004 /* Set synchronous reset. */
1005 vga_ts_write(vh, syncreset, 0x01); 1005 vga_ts_write(vh, syncreset, 0x01);
@@ -1017,27 +1017,27 @@ vga_set_mode(struct vga_handle *vh, stru @@ -1017,27 +1017,27 @@ vga_set_mode(struct vga_handle *vh, stru
1017 1017
1018 /* Write graphics display registers. */ 1018 /* Write graphics display registers. */
1019 for (i = 0; i < VGA_GDC_NREGS; i++) 1019 for (i = 0; i < VGA_GDC_NREGS; i++)
1020 _vga_gdc_write(vh, i, regs->gdc[i]); 1020 _vga_gdc_write(vh, i, regs->gdc[i]);
1021 1021
1022 /* Write attribute controller registers. */ 1022 /* Write attribute controller registers. */
1023 for (i = 0; i < VGA_ATC_NREGS; i++) 1023 for (i = 0; i < VGA_ATC_NREGS; i++)
1024 _vga_attr_write(vh, i, regs->atc[i]); 1024 _vga_attr_write(vh, i, regs->atc[i]);
1025 1025
1026 /* Enable display. */ 1026 /* Enable display. */
1027 vga_ts_write(vh, mode, vga_ts_read(vh, mode) & ~VGA_TS_MODE_BLANK); 1027 vga_ts_write(vh, mode, vga_ts_read(vh, mode) & ~VGA_TS_MODE_BLANK);
1028} 1028}
1029 1029
1030void 1030static void
1031vga_raster_cursor_init(struct vgascreen *scr, int existing) 1031vga_raster_cursor_init(struct vgascreen *scr, int existing)
1032{ 1032{
1033 struct vga_handle *vh = scr->hdl; 1033 struct vga_handle *vh = scr->hdl;
1034 bus_space_tag_t memt; 1034 bus_space_tag_t memt;
1035 bus_space_handle_t memh; 1035 bus_space_handle_t memh;
1036 int off; 1036 int off;
1037 1037
1038 if (existing) { 1038 if (existing) {
1039 /* 1039 /*
1040 * This is the first screen. At this point, scr->active is 1040 * This is the first screen. At this point, scr->active is
1041 * false, so we can't use vga_raster_cursor() to do this. 1041 * false, so we can't use vga_raster_cursor() to do this.
1042 */ 1042 */
1043 memt = vh->vh_memt; 1043 memt = vh->vh_memt;
@@ -1048,27 +1048,27 @@ vga_raster_cursor_init(struct vgascreen  @@ -1048,27 +1048,27 @@ vga_raster_cursor_init(struct vgascreen
1048 scr->cursortmp = scr->mem[off]; 1048 scr->cursortmp = scr->mem[off];
1049 vga_raster_putchar(scr, scr->cursorrow, scr->cursorcol, 1049 vga_raster_putchar(scr, scr->cursorrow, scr->cursorcol,
1050 scr->cursortmp.ch, scr->cursortmp.attr ^ 0x77); 1050 scr->cursortmp.ch, scr->cursortmp.attr ^ 0x77);
1051 } else { 1051 } else {
1052 scr->cursortmp.ch = 0; 1052 scr->cursortmp.ch = 0;
1053 scr->cursortmp.attr = 0; 1053 scr->cursortmp.attr = 0;
1054 scr->cursortmp.second = 0; 1054 scr->cursortmp.second = 0;
1055 scr->cursortmp.enc = scr->encoding; 1055 scr->cursortmp.enc = scr->encoding;
1056 } 1056 }
1057 1057
1058 scr->cursoron = 1; 1058 scr->cursoron = 1;
1059} 1059}
1060 1060
1061void 1061static void
1062vga_raster_cursor(void *id, int on, int row, int col) 1062vga_raster_cursor(void *id, int on, int row, int col)
1063{ 1063{
1064 struct vgascreen *scr = id; 1064 struct vgascreen *scr = id;
1065 int off, tmp; 1065 int off, tmp;
1066 1066
1067 /* Remove old cursor image */ 1067 /* Remove old cursor image */
1068 if (scr->cursoron) { 1068 if (scr->cursoron) {
1069 off = scr->cursorrow * scr->type->ncols + scr->cursorcol; 1069 off = scr->cursorrow * scr->type->ncols + scr->cursorcol;
1070 if (scr->active) { 1070 if (scr->active) {
1071 tmp = scr->encoding; 1071 tmp = scr->encoding;
1072 scr->encoding = scr->cursortmp.enc; 1072 scr->encoding = scr->cursortmp.enc;
1073 if (scr->cursortmp.second) 1073 if (scr->cursortmp.second)
1074 vga_raster_putchar(id, scr->cursorrow, 1074 vga_raster_putchar(id, scr->cursorrow,
@@ -1108,27 +1108,27 @@ vga_raster_cursor(void *id, int on, int  @@ -1108,27 +1108,27 @@ vga_raster_cursor(void *id, int on, int
1108static int 1108static int
1109vga_raster_mapchar(void *id, int uni, u_int *index) 1109vga_raster_mapchar(void *id, int uni, u_int *index)
1110{ 1110{
1111 struct vgascreen *scr = id; 1111 struct vgascreen *scr = id;
1112 1112
1113 if (scr->encoding == WSDISPLAY_FONTENC_IBM) 1113 if (scr->encoding == WSDISPLAY_FONTENC_IBM)
1114 return pcdisplay_mapchar(id, uni, index); 1114 return pcdisplay_mapchar(id, uni, index);
1115 else { 1115 else {
1116 *index = uni; 1116 *index = uni;
1117 return 5; 1117 return 5;
1118 } 1118 }
1119} 1119}
1120 1120
1121void 1121static void
1122vga_raster_putchar(void *id, int row, int col, u_int c, long attr) 1122vga_raster_putchar(void *id, int row, int col, u_int c, long attr)
1123{ 1123{
1124 struct vgascreen *scr = id; 1124 struct vgascreen *scr = id;
1125 size_t off; 1125 size_t off;
1126 struct vga_raster_font *fs; 1126 struct vga_raster_font *fs;
1127 u_int tmp_ch; 1127 u_int tmp_ch;
1128 1128
1129 off = row * scr->type->ncols + col; 1129 off = row * scr->type->ncols + col;
1130 1130
1131 if (__predict_false(off >= (scr->type->ncols * scr->type->nrows))) 1131 if (__predict_false(off >= (scr->type->ncols * scr->type->nrows)))
1132 return; 1132 return;
1133 1133
1134 LIST_FOREACH(fs, &scr->fontset, next) { 1134 LIST_FOREACH(fs, &scr->fontset, next) {
@@ -1241,27 +1241,27 @@ _vga_raster_putchar(void *id, int row, i @@ -1241,27 +1241,27 @@ _vga_raster_putchar(void *id, int row, i
1241 pattern = ((u_int8_t *)fs->font->data) 1241 pattern = ((u_int8_t *)fs->font->data)
1242 [(c * fheight + i) * 2 + 1]; 1242 [(c * fheight + i) * 2 + 1];
1243 if (pattern != 0) { 1243 if (pattern != 0) {
1244 rasoff2++; 1244 rasoff2++;
1245 dummy = bus_space_read_1(memt, memh, rasoff2); 1245 dummy = bus_space_read_1(memt, memh, rasoff2);
1246 bus_space_write_1(memt, memh, rasoff2, pattern); 1246 bus_space_write_1(memt, memh, rasoff2, pattern);
1247 rasoff2--; 1247 rasoff2--;
1248 } 1248 }
1249 rasoff2 += scr->type->ncols; 1249 rasoff2 += scr->type->ncols;
1250 } 1250 }
1251 } 1251 }
1252} 1252}
1253 1253
1254void 1254static void
1255vga_raster_copycols(void *id, int row, int srccol, int dstcol, int ncols) 1255vga_raster_copycols(void *id, int row, int srccol, int dstcol, int ncols)
1256{ 1256{
1257 struct vgascreen *scr = id; 1257 struct vgascreen *scr = id;
1258 struct vga_handle *vh = scr->hdl; 1258 struct vga_handle *vh = scr->hdl;
1259 bus_space_tag_t memt = vh->vh_memt; 1259 bus_space_tag_t memt = vh->vh_memt;
1260 bus_space_handle_t memh = vh->vh_memh; 1260 bus_space_handle_t memh = vh->vh_memh;
1261 bus_size_t srcoff, dstoff; 1261 bus_size_t srcoff, dstoff;
1262 bus_size_t rassrcoff, rasdstoff; 1262 bus_size_t rassrcoff, rasdstoff;
1263 int i; 1263 int i;
1264 int fheight = scr->type->fontheight; 1264 int fheight = scr->type->fontheight;
1265 1265
1266 srcoff = row * scr->type->ncols + srccol; 1266 srcoff = row * scr->type->ncols + srccol;
1267 dstoff = row * scr->type->ncols + dstcol; 1267 dstoff = row * scr->type->ncols + dstcol;
@@ -1271,40 +1271,40 @@ vga_raster_copycols(void *id, int row, i @@ -1271,40 +1271,40 @@ vga_raster_copycols(void *id, int row, i
1271 memcpy(&scr->mem[dstoff], &scr->mem[srcoff], 1271 memcpy(&scr->mem[dstoff], &scr->mem[srcoff],
1272 ncols * sizeof(struct vga_scrmem)); 1272 ncols * sizeof(struct vga_scrmem));
1273 1273
1274 vga_gdc_write(vh, mode, 0x01); 1274 vga_gdc_write(vh, mode, 0x01);
1275 if (scr->active) { 1275 if (scr->active) {
1276 for (i = 0; i < fheight; i++) { 1276 for (i = 0; i < fheight; i++) {
1277 bus_space_copy_region_1(memt, memh, 1277 bus_space_copy_region_1(memt, memh,
1278 rassrcoff + i * scr->type->ncols, memh, 1278 rassrcoff + i * scr->type->ncols, memh,
1279 rasdstoff + i * scr->type->ncols, ncols); 1279 rasdstoff + i * scr->type->ncols, ncols);
1280 } 1280 }
1281 } 1281 }
1282} 1282}
1283 1283
1284void 1284static void
1285vga_raster_erasecols(void *id, int row, int startcol, int ncols, long fillattr) 1285vga_raster_erasecols(void *id, int row, int startcol, int ncols, long fillattr)
1286{ 1286{
1287 struct vgascreen *scr = id; 1287 struct vgascreen *scr = id;
1288 int i; 1288 int i;
1289 1289
1290 if (scr->active == 0) 1290 if (scr->active == 0)
1291 return; 1291 return;
1292 1292
1293 for (i = startcol; i < startcol + ncols; i++) 1293 for (i = startcol; i < startcol + ncols; i++)
1294 vga_raster_putchar(id, row, i, ' ', fillattr); 1294 vga_raster_putchar(id, row, i, ' ', fillattr);
1295} 1295}
1296 1296
1297void 1297static void
1298vga_raster_copyrows(void *id, int srcrow, int dstrow, int nrows) 1298vga_raster_copyrows(void *id, int srcrow, int dstrow, int nrows)
1299{ 1299{
1300 struct vgascreen *scr = id; 1300 struct vgascreen *scr = id;
1301 struct vga_handle *vh = scr->hdl; 1301 struct vga_handle *vh = scr->hdl;
1302 bus_space_tag_t memt = vh->vh_memt; 1302 bus_space_tag_t memt = vh->vh_memt;
1303 bus_space_handle_t memh = vh->vh_memh; 1303 bus_space_handle_t memh = vh->vh_memh;
1304 int ncols; 1304 int ncols;
1305 bus_size_t srcoff, dstoff; 1305 bus_size_t srcoff, dstoff;
1306 bus_size_t rassrcoff, rasdstoff; 1306 bus_size_t rassrcoff, rasdstoff;
1307 int fheight; 1307 int fheight;
1308 1308
1309 ncols = scr->type->ncols; 1309 ncols = scr->type->ncols;
1310 fheight = scr->type->fontheight; 1310 fheight = scr->type->fontheight;
@@ -1342,27 +1342,27 @@ vga_raster_copyrows(void *id, int srcrow @@ -1342,27 +1342,27 @@ vga_raster_copyrows(void *id, int srcrow
1342 /* Enable cursor. */ 1342 /* Enable cursor. */
1343 vga_raster_cursor(scr, 1, scr->cursorrow, 1343 vga_raster_cursor(scr, 1, scr->cursorrow,
1344 scr->cursorcol); 1344 scr->cursorcol);
1345 } else 1345 } else
1346 bus_space_copy_region_1(memt, memh, 1346 bus_space_copy_region_1(memt, memh,
1347 scr->dispoffset + rassrcoff, memh, 1347 scr->dispoffset + rassrcoff, memh,
1348 scr->dispoffset + rasdstoff, 1348 scr->dispoffset + rasdstoff,
1349 nrows * ncols * fheight); 1349 nrows * ncols * fheight);
1350 } 1350 }
1351 memcpy(&scr->mem[dstoff], &scr->mem[srcoff], 1351 memcpy(&scr->mem[dstoff], &scr->mem[srcoff],
1352 nrows * ncols * sizeof(struct vga_scrmem)); 1352 nrows * ncols * sizeof(struct vga_scrmem));
1353} 1353}
1354 1354
1355void 1355static void
1356vga_raster_eraserows(void *id, int startrow, int nrows, long fillattr) 1356vga_raster_eraserows(void *id, int startrow, int nrows, long fillattr)
1357{ 1357{
1358 struct vgascreen *scr = id; 1358 struct vgascreen *scr = id;
1359 struct vga_handle *vh = scr->hdl; 1359 struct vga_handle *vh = scr->hdl;
1360 bus_space_tag_t memt = vh->vh_memt; 1360 bus_space_tag_t memt = vh->vh_memt;
1361 bus_space_handle_t memh = vh->vh_memh; 1361 bus_space_handle_t memh = vh->vh_memh;
1362 bus_size_t off, count; 1362 bus_size_t off, count;
1363 bus_size_t rasoff, rascount; 1363 bus_size_t rasoff, rascount;
1364 int i; 1364 int i;
1365 1365
1366 off = startrow * scr->type->ncols; 1366 off = startrow * scr->type->ncols;
1367 count = nrows * scr->type->ncols; 1367 count = nrows * scr->type->ncols;
1368 rasoff = off * scr->type->fontheight; 1368 rasoff = off * scr->type->fontheight;
@@ -1421,59 +1421,59 @@ vga_raster_allocattr(void *id, int fg, i @@ -1421,59 +1421,59 @@ vga_raster_allocattr(void *id, int fg, i
1421 return (EINVAL); 1421 return (EINVAL);
1422 if (flags & WSATTR_WSCOLORS) 1422 if (flags & WSATTR_WSCOLORS)
1423 *attrp = fgansitopc[fg] | bgansitopc[bg]; 1423 *attrp = fgansitopc[fg] | bgansitopc[bg];
1424 else 1424 else
1425 *attrp = 7; 1425 *attrp = 7;
1426 if (flags & WSATTR_HILIT) 1426 if (flags & WSATTR_HILIT)
1427 *attrp += 8; 1427 *attrp += 8;
1428 } 1428 }
1429 if (flags & WSATTR_BLINK) 1429 if (flags & WSATTR_BLINK)
1430 *attrp |= FG_BLINK; 1430 *attrp |= FG_BLINK;
1431 return (0); 1431 return (0);
1432} 1432}
1433 1433
1434void 1434static void
1435vga_restore_screen(struct vgascreen *scr, 1435vga_restore_screen(struct vgascreen *scr,
1436 const struct wsscreen_descr *type, struct vga_scrmem *mem) 1436 const struct wsscreen_descr *type, struct vga_scrmem *mem)
1437{ 1437{
1438 int i, j, off, tmp; 1438 int i, j, off, tmp;
1439 1439
1440 tmp = scr->encoding; 1440 tmp = scr->encoding;
1441 for (i = 0; i < type->nrows; i++) { 1441 for (i = 0; i < type->nrows; i++) {
1442 for (j = 0; j < type->ncols; j++) { 1442 for (j = 0; j < type->ncols; j++) {
1443 off = i * type->ncols + j; 1443 off = i * type->ncols + j;
1444 if (mem[off].second != 1) { 1444 if (mem[off].second != 1) {
1445 scr->encoding = mem[off].enc; 1445 scr->encoding = mem[off].enc;
1446 vga_raster_putchar(scr, i, j, mem[off].ch, 1446 vga_raster_putchar(scr, i, j, mem[off].ch,
1447 mem[off].attr); 1447 mem[off].attr);
1448 } 1448 }
1449 } 1449 }
1450 } 1450 }
1451 scr->encoding = tmp; 1451 scr->encoding = tmp;
1452} 1452}
1453 1453
1454void 1454static void
1455vga_raster_setscreentype(struct vga_config *vc, 1455vga_raster_setscreentype(struct vga_config *vc,
1456 const struct wsscreen_descr *type) 1456 const struct wsscreen_descr *type)
1457{ 1457{
1458 struct vga_handle *vh = &vc->hdl; 1458 struct vga_handle *vh = &vc->hdl;
1459 struct vga_moderegs moderegs; 1459 struct vga_moderegs moderegs;
1460 1460
1461 vga_setup_regs((struct videomode *)type->modecookie, &moderegs); 1461 vga_setup_regs((struct videomode *)type->modecookie, &moderegs);
1462 vga_set_mode(vh, &moderegs); 1462 vga_set_mode(vh, &moderegs);
1463} 1463}
1464 1464
1465#ifdef WSDISPLAY_CUSTOM_OUTPUT 1465#ifdef WSDISPLAY_CUSTOM_OUTPUT
1466void 1466static void
1467vga_raster_replaceattr(void *id, long oldattr, long newattr) 1467vga_raster_replaceattr(void *id, long oldattr, long newattr)
1468{ 1468{
1469 struct vgascreen *scr = id; 1469 struct vgascreen *scr = id;
1470 const struct wsscreen_descr *type = scr->type; 1470 const struct wsscreen_descr *type = scr->type;
1471 int off; 1471 int off;
1472 1472
1473 for (off = 0; off < type->nrows * type->ncols; off++) { 1473 for (off = 0; off < type->nrows * type->ncols; off++) {
1474 if (scr->mem[off].attr == oldattr) 1474 if (scr->mem[off].attr == oldattr)
1475 scr->mem[off].attr = newattr; 1475 scr->mem[off].attr = newattr;
1476 } 1476 }
1477 1477
1478 /* Repaint the whole screen, if needed */ 1478 /* Repaint the whole screen, if needed */
1479 if (scr->active) 1479 if (scr->active)

cvs diff -r1.29 -r1.30 src/sys/dev/ic/vgavar.h (expand / switch to unified diff)

--- src/sys/dev/ic/vgavar.h 2010/12/09 23:33:30 1.29
+++ src/sys/dev/ic/vgavar.h 2013/01/21 19:49:15 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vgavar.h,v 1.29 2010/12/09 23:33:30 christos Exp $ */ 1/* $NetBSD: vgavar.h,v 1.30 2013/01/21 19:49:15 mlelstv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -207,17 +207,15 @@ void vga_resume(struct vga_softc *); @@ -207,17 +207,15 @@ void vga_resume(struct vga_softc *);
207struct wsscreen_descr; 207struct wsscreen_descr;
208void vga_loadchars(struct vga_handle *, int, int, int, int, const char *); 208void vga_loadchars(struct vga_handle *, int, int, int, int, const char *);
209void vga_readoutchars(struct vga_handle *, int, int, int, int, char *); 209void vga_readoutchars(struct vga_handle *, int, int, int, int, char *);
210#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL 210#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
211void vga_copyfont01(struct vga_handle *); 211void vga_copyfont01(struct vga_handle *);
212#endif 212#endif
213void vga_setfontset(struct vga_handle *, int, int); 213void vga_setfontset(struct vga_handle *, int, int);
214void vga_setscreentype(struct vga_handle *, const struct wsscreen_descr *); 214void vga_setscreentype(struct vga_handle *, const struct wsscreen_descr *);
215#else /* !VGA_RASTERCONSOLE */ 215#else /* !VGA_RASTERCONSOLE */
216void vga_load_builtinfont(struct vga_handle *, u_int8_t *, int, int); 216void vga_load_builtinfont(struct vga_handle *, u_int8_t *, int, int);
217#endif /* !VGA_RASTERCONSOLE */ 217#endif /* !VGA_RASTERCONSOLE */
218void vga_reset(struct vga_handle *, void (*)(struct vga_handle *)); 218void vga_reset(struct vga_handle *, void (*)(struct vga_handle *));
219void vga_initregs(struct vga_handle *); 219void vga_initregs(struct vga_handle *);
220void vga_save_palette(struct vga_config *); 
221void vga_restore_palette(struct vga_config *); 
222 220
223extern int vga_no_builtinfont; 221extern int vga_no_builtinfont;