Annotation of sys/dev/ic/vga_subr.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: vga_subr.c,v 1.3 2004/04/02 04:39:50 deraadt Exp $ */
! 2: /* $NetBSD: vga_subr.c,v 1.6 2000/01/25 02:44:03 ad Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1998
! 6: * Matthias Drochner. All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: *
! 17: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 18: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 19: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 20: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 21: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 22: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 23: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 24: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 25: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 26: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 27: *
! 28: */
! 29:
! 30: #include <sys/param.h>
! 31: #include <sys/systm.h>
! 32: #include <sys/device.h>
! 33: #include <sys/queue.h>
! 34: #include <machine/bus.h>
! 35:
! 36: #include <dev/ic/mc6845reg.h>
! 37: #include <dev/ic/pcdisplayvar.h>
! 38: #include <dev/ic/vgareg.h>
! 39: #include <dev/ic/vgavar.h>
! 40:
! 41: #include <dev/wscons/wsdisplayvar.h>
! 42:
! 43: static void fontram(struct vga_handle *);
! 44: static void textram(struct vga_handle *);
! 45:
! 46: static void
! 47: fontram(vh)
! 48: struct vga_handle *vh;
! 49: {
! 50: /* program sequencer to access character generator */
! 51:
! 52: vga_ts_write(vh, syncreset, 0x01); /* synchronous reset */
! 53: vga_ts_write(vh, wrplmask, 0x04); /* write to map 2 */
! 54: vga_ts_write(vh, memmode, 0x07); /* sequential addressing */
! 55: vga_ts_write(vh, syncreset, 0x03); /* clear synchronous reset */
! 56:
! 57: /* program graphics controller to access character generator */
! 58:
! 59: vga_gdc_write(vh, rdplanesel, 0x02); /* select map 2 for cpu reads */
! 60: vga_gdc_write(vh, mode, 0x00); /* disable odd-even addressing */
! 61: vga_gdc_write(vh, misc, 0x04); /* map starts at 0xA000 */
! 62: }
! 63:
! 64: static void
! 65: textram(vh)
! 66: struct vga_handle *vh;
! 67: {
! 68: /* program sequencer to access video ram */
! 69:
! 70: vga_ts_write(vh, syncreset, 0x01); /* synchronous reset */
! 71: vga_ts_write(vh, wrplmask, 0x03); /* write to map 0 & 1 */
! 72: vga_ts_write(vh, memmode, 0x03); /* odd-even addressing */
! 73: vga_ts_write(vh, syncreset, 0x03); /* clear synchronous reset */
! 74:
! 75: /* program graphics controller for text mode */
! 76:
! 77: vga_gdc_write(vh, rdplanesel, 0x00); /* select map 0 for cpu reads */
! 78: vga_gdc_write(vh, mode, 0x10); /* enable odd-even addressing */
! 79: /* map starts at 0xb800 or 0xb000 (mono) */
! 80: vga_gdc_write(vh, misc, (vh->vh_mono ? 0x0a : 0x0e));
! 81: }
! 82:
! 83: void
! 84: vga_loadchars(vh, fontset, first, num, lpc, data)
! 85: struct vga_handle *vh;
! 86: int fontset, first, num;
! 87: int lpc;
! 88: char *data;
! 89: {
! 90: int offset, i, j, s;
! 91:
! 92: /* fontset number swizzle done in vga_setfontset() */
! 93: offset = (fontset << 13) | (first << 5);
! 94:
! 95: s = splhigh();
! 96: fontram(vh);
! 97:
! 98: for (i = 0; i < num; i++)
! 99: for (j = 0; j < lpc; j++)
! 100: bus_space_write_1(vh->vh_memt, vh->vh_allmemh,
! 101: offset + (i << 5) + j,
! 102: data[i * lpc + j]);
! 103:
! 104: textram(vh);
! 105: splx(s);
! 106: }
! 107:
! 108: void
! 109: vga_setfontset(vh, fontset1, fontset2)
! 110: struct vga_handle *vh;
! 111: int fontset1, fontset2;
! 112: {
! 113: u_int8_t cmap;
! 114: static u_int8_t cmaptaba[] = {
! 115: 0x00, 0x10, 0x01, 0x11,
! 116: 0x02, 0x12, 0x03, 0x13
! 117: };
! 118: static u_int8_t cmaptabb[] = {
! 119: 0x00, 0x20, 0x04, 0x24,
! 120: 0x08, 0x28, 0x0c, 0x2c
! 121: };
! 122:
! 123: /* extended font if fontset1 != fontset2 */
! 124: cmap = cmaptaba[fontset1] | cmaptabb[fontset2];
! 125:
! 126: vga_ts_write(vh, fontsel, cmap);
! 127: }
! 128:
! 129: void
! 130: vga_setscreentype(vh, type)
! 131: struct vga_handle *vh;
! 132: const struct wsscreen_descr *type;
! 133: {
! 134: vga_6845_write(vh, maxrow, type->fontheight - 1);
! 135:
! 136: /* lo byte */
! 137: vga_6845_write(vh, vde, type->fontheight * type->nrows - 1);
! 138:
! 139: #ifndef PCDISPLAY_SOFTCURSOR
! 140: /* set cursor to last 2 lines */
! 141: vga_6845_write(vh, curstart, type->fontheight - 2);
! 142: vga_6845_write(vh, curend, type->fontheight - 1);
! 143: #endif
! 144: /*
! 145: * disable colour plane 3 if needed for font selection
! 146: */
! 147: if (type->capabilities & WSSCREEN_HILIT) {
! 148: /*
! 149: * these are the screens which don't support
! 150: * 512-character fonts
! 151: */
! 152: vga_attr_write(vh, colplen, 0x0f);
! 153: } else
! 154: vga_attr_write(vh, colplen, 0x07);
! 155: }
CVSweb