Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Changes to allow machines which don't use text mode at t...
details: https://anonhg.NetBSD.org/src/rev/ff15cde564ed
branches: trunk
changeset: 542521:ff15cde564ed
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Fri Jan 31 21:57:23 2003 +0000
description:
Changes to allow machines which don't use text mode at the boot time
to use generic VGA driver(s):
- Allow VGA drivers to use wsfont instead of builtin font.
- Add vga_reset() function, which will be called from MD consinit(),
to put VGA into text mode. This function is enabled by options VGA_RESET.
diffstat:
sys/conf/files | 3 +-
sys/dev/ic/vga.c | 36 +++++-
sys/dev/ic/vga_raster.c | 36 +++++-
sys/dev/ic/vga_subr.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++-
sys/dev/ic/vgareg.h | 9 +-
sys/dev/ic/vgavar.h | 7 +-
6 files changed, 291 insertions(+), 23 deletions(-)
diffs (truncated from 502 to 300 lines):
diff -r 888999c983f5 -r ff15cde564ed sys/conf/files
--- a/sys/conf/files Fri Jan 31 20:50:29 2003 +0000
+++ b/sys/conf/files Fri Jan 31 21:57:23 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.592 2003/01/20 20:02:01 christos Exp $
+# $NetBSD: files,v 1.593 2003/01/31 21:57:23 tsutsui Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -781,6 +781,7 @@
defparam opt_vga.h VGA_CONSOLE_SCREENTYPE
defflag opt_vga.h VGA_CONSOLE_ATI_BROKEN_FONTSEL
defflag opt_vga.h VGA_RASTERCONSOLE
+defflag opt_vga.h VGA_RESET
device vga: wsemuldisplaydev, pcdisplayops
file dev/ic/vga.c vga & !vga_rasterconsole needs-flag
file dev/ic/vga_raster.c vga_rasterconsole needs-flag
diff -r 888999c983f5 -r ff15cde564ed sys/dev/ic/vga.c
--- a/sys/dev/ic/vga.c Fri Jan 31 20:50:29 2003 +0000
+++ b/sys/dev/ic/vga.c Fri Jan 31 21:57:23 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga.c,v 1.67 2003/01/27 15:16:10 tsutsui Exp $ */
+/* $NetBSD: vga.c,v 1.68 2003/01/31 21:57:25 tsutsui Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.67 2003/01/27 15:16:10 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.68 2003/01/31 21:57:25 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,6 +54,8 @@
/* for WSCONS_SUPPORT_PCVTFONTS and WSDISPLAY_CHARFUNCS */
#include "opt_wsdisplay_compat.h"
+int vga_no_builtinfont = 0;
+
static struct wsdisplay_font _vga_builtinfont = {
"builtin", /* typeface name */
0, /* firstchar */
@@ -472,7 +474,6 @@
scr->pcs.mem = NULL;
- wsfont_init();
scr->fontset1 = scr->fontset2 = 0;
if (vga_selectfont(vc, scr, 0, 0)) {
if (scr == &vga_console_screen)
@@ -528,6 +529,21 @@
vc->currenttype = vh->vh_mono ? &vga_25lscreen_mono : &vga_25lscreen;
callout_init(&vc->vc_switch_callout);
+ wsfont_init();
+ if (vga_no_builtinfont) {
+ struct wsdisplay_font *wf;
+ int cookie;
+
+ cookie = wsfont_find(NULL, 8, 16, 0,
+ WSDISPLAY_FONTORDER_L2R, 0);
+ if (cookie == -1 || wsfont_lock(cookie, &wf))
+ panic("vga_init: can't load console font");
+ vga_loadchars(&vc->hdl, 0, wf->firstchar, wf->numchars,
+ wf->fontheight, wf->data);
+ vga_builtinfont.wsfont = wf;
+ vga_builtinfont.cookie = cookie;
+ vga_builtinfont.slot = 0;
+ }
vc->vc_fonts[0] = &vga_builtinfont;
for (i = 1; i < 8; i++)
vc->vc_fonts[i] = 0;
@@ -586,12 +602,14 @@
KASSERT(vga_builtinfont.slot == 0);
#define BUILTINFONTLOC (0)
#endif
- vga_builtinfont.wsfont->data =
- malloc(256 * vga_builtinfont.wsfont->fontheight,
- M_DEVBUF, M_WAITOK);
- vga_readoutchars(&vc->hdl, BUILTINFONTLOC, 0, 256,
- vga_builtinfont.wsfont->fontheight,
- vga_builtinfont.wsfont->data);
+ if (!vga_no_builtinfont) {
+ vga_builtinfont.wsfont->data =
+ malloc(256 * vga_builtinfont.wsfont->fontheight,
+ M_DEVBUF, M_WAITOK);
+ vga_readoutchars(&vc->hdl, BUILTINFONTLOC, 0, 256,
+ vga_builtinfont.wsfont->fontheight,
+ vga_builtinfont.wsfont->data);
+ }
vc->vc_type = type;
vc->vc_funcs = vf;
diff -r 888999c983f5 -r ff15cde564ed sys/dev/ic/vga_raster.c
--- a/sys/dev/ic/vga_raster.c Fri Jan 31 20:50:29 2003 +0000
+++ b/sys/dev/ic/vga_raster.c Fri Jan 31 21:57:23 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_raster.c,v 1.9 2003/01/27 15:27:44 tsutsui Exp $ */
+/* $NetBSD: vga_raster.c,v 1.10 2003/01/31 21:57:26 tsutsui Exp $ */
/*
* Copyright (c) 2001, 2002 Bang Jun-Young
@@ -75,6 +75,8 @@
#include <dev/ic/pcdisplay.h>
+int vga_no_builtinfont = 0;
+
u_int8_t builtinfont_data[256 * 16];
struct wsdisplay_font builtinfont = {
@@ -394,11 +396,27 @@
vc->currenttype = vh->vh_mono ? &vga_25lscreen_mono : &vga_25lscreen;
callout_init(&vc->vc_switch_callout);
+ wsfont_init();
vc->nfonts = 1;
LIST_INIT(&vc->vc_fontlist);
vf = &vga_console_fontset_ascii;
- vga_load_builtinfont(vh, builtinfont_data, 0, 256);
- vf->font = &builtinfont;
+ if (vga_no_builtinfont) {
+ struct wsdisplay_font *wf;
+ int cookie;
+
+ /* prefer 8x16 pixel font */
+ cookie = wsfont_find(NULL, 8, 16, 0,
+ WSDISPLAY_FONTORDER_L2R, 0);
+ if (cookie == -1)
+ cookie = wsfont_find(NULL, 0, 0, 0,
+ WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R);
+ if (cookie == -1 || wsfont_lock(cookie, &wf))
+ panic("vga_raster_init: can't load console font");
+ vf->font = wf;
+ } else {
+ vga_load_builtinfont(vh, builtinfont_data, 0, 256);
+ vf->font = &builtinfont;
+ }
LIST_INSERT_HEAD(&vc->vc_fontlist, vf, next);
}
@@ -415,10 +433,8 @@
scr->type = type;
scr->mindispoffset = 0;
scr->maxdispoffset = 0x10000;
- scr->encoding = WSDISPLAY_FONTENC_IBM;
vh = &vc->hdl;
- wsfont_init();
LIST_INIT(&scr->fontset);
vga_raster_setup_font(vc, scr);
@@ -449,7 +465,7 @@
vh->vh_allmemh, 0x18000 + i * 2);
scr->mem[i].attr = bus_space_read_1(vh->vh_memt,
vh->vh_allmemh, 0x18000 + i * 2 + 1);
- scr->mem[i].enc = WSDISPLAY_FONTENC_IBM;
+ scr->mem[i].enc = scr->encoding;
}
vga_raster_setscreentype(vc, type);
@@ -782,6 +798,7 @@
LIST_FOREACH(vf, &vc->vc_fontlist, next) {
if (wsfont_matches(vf->font, 0, 0, scr->type->fontheight, 0)) {
+ scr->encoding = vf->font->encoding;
LIST_INSERT_HEAD(&scr->fontset, vf, next);
return;
}
@@ -802,6 +819,7 @@
}
vf->font = wf;
+ scr->encoding = vf->font->encoding;
LIST_INSERT_HEAD(&scr->fontset, vf, next);
}
@@ -993,7 +1011,7 @@
scr->cursortmp.ch = 0;
scr->cursortmp.attr = 0;
scr->cursortmp.second = 0;
- scr->cursortmp.enc = WSDISPLAY_FONTENC_IBM;
+ scr->cursortmp.enc = scr->encoding;
}
scr->cursoron = 1;
@@ -1109,7 +1127,7 @@
scr->mem[off].ch = c;
scr->mem[off].attr = attr;
scr->mem[off].second = 0;
- scr->mem[off].enc = WSDISPLAY_FONTENC_IBM;
+ scr->mem[off].enc = scr->encoding;
}
static void
@@ -1323,7 +1341,7 @@
scr->mem[off + i].ch = ' ';
scr->mem[off + i].attr = fillattr;
scr->mem[off + i].second = 0;
- scr->mem[off + i].enc = WSDISPLAY_FONTENC_IBM;
+ scr->mem[off + i].enc = scr->encoding;
}
}
diff -r 888999c983f5 -r ff15cde564ed sys/dev/ic/vga_subr.c
--- a/sys/dev/ic/vga_subr.c Fri Jan 31 20:50:29 2003 +0000
+++ b/sys/dev/ic/vga_subr.c Fri Jan 31 21:57:23 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_subr.c,v 1.13 2003/01/27 15:22:47 tsutsui Exp $ */
+/* $NetBSD: vga_subr.c,v 1.14 2003/01/31 21:57:26 tsutsui Exp $ */
/*
* Copyright (c) 1998
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.13 2003/01/27 15:22:47 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.14 2003/01/31 21:57:26 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -42,6 +42,7 @@
#include <machine/bus.h>
#include <dev/ic/mc6845reg.h>
+#include <dev/ic/pcdisplay.h>
#include <dev/ic/pcdisplayvar.h>
#include <dev/ic/vgareg.h>
#include <dev/ic/vgavar.h>
@@ -50,6 +51,9 @@
static void fontram(struct vga_handle *);
static void textram(struct vga_handle *);
+#ifdef VGA_RESET
+static void vga_initregs(struct vga_handle *);
+#endif
static void
fontram(struct vga_handle *vh)
@@ -212,3 +216,218 @@
splx(s);
}
#endif /* !VGA_RASTERCONSOLE */
+
+#ifdef VGA_RESET
+/*
+ * vga_reset():
+ * Reset VGA registers to put it into 80x25 text mode. (mode 3)
+ * This function should be called from MD consinit() on ports
+ * whose firmware does not use text mode at boot time.
+ */
+void
+vga_reset(vh, md_initfunc)
+ struct vga_handle *vh;
+ void (*md_initfunc)(struct vga_handle *);
+{
+ u_int8_t reg;
+
+ if (bus_space_map(vh->vh_iot, 0x3c0, 0x10, 0, &vh->vh_ioh_vga))
+ return;
+
+ reg = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_MISC_DATAR);
+ vh->vh_mono = !(reg & 0x01);
+
+ if (bus_space_map(vh->vh_iot, vh->vh_mono ? 0x3b0 : 0x3d0, 0x10,
+ 0, &vh->vh_ioh_6845))
+ goto out1;
+
+ if (bus_space_map(vh->vh_memt, 0xa0000, 0x20000, 0, &vh->vh_allmemh))
+ goto out2;
+
+ if (bus_space_subregion(vh->vh_memt, vh->vh_allmemh,
+ vh->vh_mono ? 0x10000 : 0x18000, 0x8000, &vh->vh_memh))
+ goto out3;
+
+ /* check if VGA already in text mode. */
+ if ((vga_gdc_read(vh, misc) & 0x01) == 0)
+ goto out3;
+
+ /* initialize common VGA registers */
+ vga_initregs(vh);
+
+ /* initialize chipset specific registers */
+ if (md_initfunc != NULL)
+ (*md_initfunc)(vh);
+
+ delay(10000);
+
+ /* clear text buffer RAM */
+ bus_space_set_region_2(vh->vh_memt, vh->vh_memh, 0,
+ ((BG_BLACK | FG_LIGHTGREY) << 8) | ' ', 80 * 25 /*XXX*/);
+
+ out3:
+ bus_space_unmap(vh->vh_memt, vh->vh_allmemh, 0x20000);
+ out2:
+ bus_space_unmap(vh->vh_iot, vh->vh_ioh_6845, 0x10);
+ out1:
Home |
Main Index |
Thread Index |
Old Index