Home | History | Annotate | Line # | Download | only in boot
vreset.c revision 1.8.44.1
      1  1.8.44.1    rmind /* $NetBSD: vreset.c,v 1.8.44.1 2014/05/18 17:45:23 rmind Exp $ */
      2       1.5  garbled /*-
      3       1.5  garbled  * Copyright (c) 2006 The NetBSD Foundation, Inc.
      4       1.1   nonaka  * All rights reserved.
      5       1.1   nonaka  *
      6       1.5  garbled  * This code is derived from software contributed to The NetBSD Foundation
      7       1.5  garbled  * by Tim Rightnour
      8       1.1   nonaka  *
      9       1.1   nonaka  * Redistribution and use in source and binary forms, with or without
     10       1.1   nonaka  * modification, are permitted provided that the following conditions
     11       1.1   nonaka  * are met:
     12       1.1   nonaka  * 1. Redistributions of source code must retain the above copyright
     13       1.1   nonaka  *    notice, this list of conditions and the following disclaimer.
     14       1.1   nonaka  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1   nonaka  *    notice, this list of conditions and the following disclaimer in the
     16       1.1   nonaka  *    documentation and/or other materials provided with the distribution.
     17       1.1   nonaka  *
     18       1.5  garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19       1.5  garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20       1.5  garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21       1.5  garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22       1.5  garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23       1.5  garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24       1.5  garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25       1.5  garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26       1.5  garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27       1.5  garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28       1.5  garbled  * POSSIBILITY OF SUCH DAMAGE.
     29       1.1   nonaka  */
     30       1.1   nonaka 
     31       1.5  garbled #ifdef VGA_RESET
     32       1.1   nonaka #include <lib/libsa/stand.h>
     33       1.1   nonaka #include "boot.h"
     34       1.1   nonaka #include "iso_font.h"
     35       1.1   nonaka 
     36       1.5  garbled #define VGA_SR_PORT	0x3c4
     37       1.5  garbled #define VGA_CR_PORT	0x3d4
     38       1.5  garbled #define VGA_CR_DATA	0x3d5
     39       1.5  garbled #define VGA_GR_PORT	0x3ce
     40       1.5  garbled #define VGA_GR_DATA	0x3cf
     41       1.5  garbled #define SRREGS	4
     42       1.5  garbled #define CRREGS	24
     43       1.5  garbled #define GRREGS	9
     44       1.5  garbled #define LINES 25
     45       1.5  garbled #define COLS 80
     46       1.5  garbled #define PCI_VENDOR_S3		0x5333
     47       1.5  garbled #define PCI_VENDOR_CIRRUS	0x1013
     48       1.5  garbled #define PCI_VENDOR_DIAMOND	0x100E
     49       1.5  garbled #define PCI_VENDOR_MATROX	0x102B
     50       1.5  garbled #define PCI_VENDOR_PARADISE	0x101C
     51       1.5  garbled 
     52       1.5  garbled static void write_attr(u_int8_t, u_int8_t, u_int8_t);
     53       1.5  garbled static void set_text_regs(void);
     54       1.5  garbled static void set_text_clut(int);
     55       1.5  garbled static void load_font(u_int8_t *);
     56       1.5  garbled static void unlock_S3(void);
     57       1.5  garbled static void clear_video_memory(void);
     58       1.5  garbled 
     59       1.5  garbled extern char *videomem;
     60       1.5  garbled 
     61       1.5  garbled typedef struct vga_reg {
     62       1.5  garbled 	u_int8_t idx;
     63       1.5  garbled 	u_int8_t val;
     64       1.5  garbled } vga_reg_t;
     65       1.5  garbled 
     66       1.5  garbled static vga_reg_t SR_regs[SRREGS] = {
     67       1.5  garbled 	/* idx  val */
     68       1.5  garbled 	{ 0x1,	0x0 },	/* 01: clocking mode */
     69       1.5  garbled 	{ 0x2,	0x3 },	/* 02: map mask */
     70       1.5  garbled 	{ 0x3,	0x0 },	/* 03: character map select */
     71       1.5  garbled 	{ 0x4,	0x2 }	/* 04: memory mode */
     72       1.1   nonaka };
     73       1.1   nonaka 
     74       1.5  garbled static vga_reg_t CR_regs[CRREGS] = {
     75       1.5  garbled 	/* idx  val */
     76       1.5  garbled 	{ 0x0,	0x61 }, /* 00: horizontal total */
     77       1.5  garbled 	{ 0x1,	0x4f }, /* 01: horizontal display-enable end */
     78       1.5  garbled 	{ 0x2,	0x50 }, /* 02: start horizontal blanking */
     79       1.8  tsutsui 	{ 0x3,	0x82 }, /* 03: display skew control / end horizontal blanking */
     80       1.8  tsutsui 	{ 0x4,	0x55 }, /* 04: start horizontal retrace pulse */
     81       1.5  garbled 	{ 0x5,	0x81 }, /* 05: horizontal retrace delay / end horiz. retrace */
     82       1.5  garbled 	{ 0x6,	0xf0 }, /* 06: vertical total */
     83       1.5  garbled 	{ 0x7,	0x1f }, /* 07: overflow register */
     84       1.5  garbled 	{ 0x8,	0x00 }, /* 08: preset row scan */
     85       1.5  garbled 	{ 0x9,	0x4f }, /* 09: overflow / maximum scan line */
     86       1.5  garbled 	{ 0xa,	0x0d }, /* 0A: cursor off / cursor start */
     87       1.5  garbled 	{ 0xb,	0x0e }, /* 0B: cursor skew / cursor end */
     88       1.5  garbled 	{ 0xc,	0x00 }, /* 0C: start regenerative buffer address high */
     89       1.5  garbled 	{ 0xd,	0x00 }, /* 0D: start regenerative buffer address low */
     90       1.5  garbled 	{ 0xe,	0x00 }, /* 0E: cursor location high */
     91       1.5  garbled 	{ 0xf,	0x00 }, /* 0F: cursor location low */
     92       1.5  garbled 	{ 0x10, 0x9a }, /* 10: vertical retrace start */
     93       1.5  garbled 	{ 0x11, 0x8c }, /* 11: vertical interrupt / vertical retrace end */
     94       1.5  garbled 	{ 0x12, 0x8f }, /* 12: vertical display enable end */
     95       1.5  garbled 	{ 0x13, 0x28 }, /* 13: logical line width */
     96       1.5  garbled 	{ 0x14, 0x1f }, /* 14: underline location */
     97       1.5  garbled 	{ 0x15, 0x97 }, /* 15: start vertical blanking */
     98       1.5  garbled 	{ 0x16, 0x00 }, /* 16: end vertical blanking */
     99       1.5  garbled 	{ 0x17, 0xa3 }, /* 17: CRT mode control */
    100       1.1   nonaka };
    101       1.1   nonaka 
    102       1.5  garbled static vga_reg_t GR_regs[GRREGS] = {
    103       1.5  garbled 	/* idx  val */
    104       1.5  garbled 	{ 0x0,	0x00 }, /* 00: set/reset map */
    105       1.5  garbled 	{ 0x1,	0x00 }, /* 01: enable set/reset */
    106       1.5  garbled 	{ 0x2,	0x00 }, /* 02: color compare */
    107       1.5  garbled 	{ 0x3,	0x00 }, /* 03: data rotate */
    108       1.5  garbled 	{ 0x4,	0x00 }, /* 04: read map select */
    109       1.5  garbled 	{ 0x5,	0x10 }, /* 05: graphics mode */
    110       1.5  garbled 	{ 0x6,	0x0e }, /* 06: miscellaneous */
    111       1.5  garbled 	{ 0x7,	0x00 }, /* 07: color don't care */
    112       1.5  garbled 	{ 0x8,	0xff }, /* 08: bit mask */
    113       1.1   nonaka };
    114       1.1   nonaka 
    115       1.5  garbled /* video DAC palette registers */
    116       1.5  garbled /* XXX only set up 16 colors used by internal palette in ATC regsters */
    117       1.5  garbled static const u_int8_t vga_dacpal[] = {
    118       1.5  garbled 	/* R     G     B */
    119       1.5  garbled 	0x00, 0x00, 0x00,	/* BLACK        */
    120       1.5  garbled 	0x00, 0x00, 0x2a,	/* BLUE         */
    121       1.5  garbled 	0x00, 0x2a, 0x00,	/* GREEN        */
    122       1.5  garbled 	0x00, 0x2a, 0x2a,	/* CYAN         */
    123       1.5  garbled 	0x2a, 0x00, 0x00,	/* RED          */
    124       1.5  garbled 	0x2a, 0x00, 0x2a,	/* MAGENTA      */
    125       1.5  garbled 	0x2a, 0x15, 0x00,	/* BROWN        */
    126       1.5  garbled 	0x2a, 0x2a, 0x2a,	/* LIGHTGREY    */
    127       1.5  garbled 	0x15, 0x15, 0x15,	/* DARKGREY     */
    128       1.5  garbled 	0x15, 0x15, 0x3f,	/* LIGHTBLUE    */
    129       1.5  garbled 	0x15, 0x3f, 0x15,	/* LIGHTGREEN   */
    130       1.5  garbled 	0x15, 0x3f, 0x3f,	/* LIGHTCYAN    */
    131       1.5  garbled 	0x3f, 0x15, 0x15,	/* LIGHTRED     */
    132       1.5  garbled 	0x3f, 0x15, 0x3f,	/* LIGHTMAGENTA */
    133       1.5  garbled 	0x3f, 0x3f, 0x15,	/* YELLOW       */
    134       1.5  garbled 	0x3f, 0x3f, 0x3f	/* WHITE        */
    135       1.1   nonaka };
    136       1.1   nonaka 
    137       1.5  garbled static const u_int8_t vga_atc[] = {
    138       1.5  garbled 	0x00,	/* 00: internal palette  0 */
    139       1.5  garbled 	0x01,	/* 01: internal palette  1 */
    140       1.5  garbled 	0x02,	/* 02: internal palette  2 */
    141       1.5  garbled 	0x03,	/* 03: internal palette  3 */
    142       1.5  garbled 	0x04,	/* 04: internal palette  4 */
    143       1.5  garbled 	0x05,	/* 05: internal palette  5 */
    144       1.5  garbled 	0x14,	/* 06: internal palette  6 */
    145       1.5  garbled 	0x07,	/* 07: internal palette  7 */
    146       1.5  garbled 	0x38,	/* 08: internal palette  8 */
    147       1.5  garbled 	0x39,	/* 09: internal palette  9 */
    148       1.5  garbled 	0x3a,	/* 0A: internal palette 10 */
    149       1.5  garbled 	0x3b,	/* 0B: internal palette 11 */
    150       1.5  garbled 	0x3c,	/* 0C: internal palette 12 */
    151       1.5  garbled 	0x3d,	/* 0D: internal palette 13 */
    152       1.5  garbled 	0x3e,	/* 0E: internal palette 14 */
    153       1.5  garbled 	0x3f,	/* 0F: internal palette 15 */
    154       1.5  garbled 	0x0c,	/* 10: attribute mode control */
    155       1.5  garbled 	0x00,	/* 11: overscan color */
    156       1.5  garbled 	0x0f,	/* 12: color plane enable */
    157       1.5  garbled 	0x08,	/* 13: horizontal PEL panning */
    158       1.5  garbled 	0x00	/* 14: color select */
    159       1.1   nonaka };
    160       1.1   nonaka 
    161       1.1   nonaka void
    162       1.4  garbled vga_reset(u_char *ISA_mem)
    163       1.1   nonaka {
    164       1.6  garbled 	int slot, cardfound;
    165       1.1   nonaka 
    166       1.5  garbled 	/* check if we are in text mode, if so, punt */
    167       1.5  garbled 	outb(VGA_GR_PORT, 0x06);
    168       1.5  garbled 	if ((inb(VGA_GR_DATA) & 0x01) == 0)
    169       1.5  garbled 		return;
    170       1.5  garbled 
    171       1.5  garbled 	/* guess not, we lose. */
    172       1.5  garbled 	slot = -1;
    173       1.5  garbled 	while ((slot = scan_PCI(slot)) > -1) {
    174       1.6  garbled 		cardfound = 0;
    175       1.5  garbled 		switch (PCI_vendor(slot)) {
    176       1.5  garbled 		case PCI_VENDOR_CIRRUS:
    177       1.6  garbled 			unlockVideo(slot);
    178       1.5  garbled 			outw(VGA_SR_PORT, 0x0612); /* unlock ext regs */
    179       1.5  garbled 			outw(VGA_SR_PORT, 0x0700); /* reset ext sequence mode */
    180       1.6  garbled 			cardfound++;
    181       1.5  garbled 			break;
    182       1.5  garbled 		case PCI_VENDOR_PARADISE:
    183       1.6  garbled 			unlockVideo(slot);
    184       1.5  garbled 			outw(VGA_GR_PORT, 0x0f05); /* unlock registers */
    185       1.5  garbled 			outw(VGA_SR_PORT, 0x0648);
    186       1.5  garbled 			outw(VGA_CR_PORT, 0x2985);
    187       1.5  garbled 			outw(VGA_CR_PORT, 0x34a6);
    188       1.5  garbled 			outb(VGA_GR_PORT, 0x0b); /* disable linear addressing */
    189       1.5  garbled 			outb(VGA_GR_DATA, inb(VGA_GR_DATA) & ~0x30);
    190       1.5  garbled 			outw(VGA_SR_PORT, 0x1400);
    191       1.5  garbled 			outb(VGA_GR_PORT, 0x0e); /* disable 256 color mode */
    192       1.5  garbled 			outb(VGA_GR_DATA, inb(VGA_GR_DATA) & ~0x01);
    193       1.5  garbled 			outb(0xd00, 0xff); /* enable auto-centering */
    194       1.5  garbled 			if (!(inb(0xd01) & 0x03)) {
    195       1.5  garbled 				outb(VGA_CR_PORT, 0x33);
    196       1.5  garbled 				outb(VGA_CR_DATA, inb(VGA_CR_DATA) & ~0x90);
    197       1.5  garbled 				outb(VGA_CR_PORT, 0x32);
    198       1.5  garbled 				outb(VGA_CR_DATA, inb(VGA_CR_DATA) | 0x04);
    199       1.5  garbled 				outw(VGA_CR_PORT, 0x0250);
    200       1.5  garbled 				outw(VGA_CR_PORT, 0x07ba);
    201       1.5  garbled 				outw(VGA_CR_PORT, 0x0900);
    202       1.5  garbled 				outw(VGA_CR_PORT, 0x15e7);
    203       1.5  garbled 				outw(VGA_CR_PORT, 0x2a95);
    204       1.5  garbled 			}
    205       1.5  garbled 			outw(VGA_CR_PORT, 0x34a0);
    206       1.6  garbled 			cardfound++;
    207       1.5  garbled 			break;
    208       1.5  garbled 		case PCI_VENDOR_S3:
    209       1.6  garbled 			unlockVideo(slot);
    210       1.5  garbled 			unlock_S3();
    211       1.6  garbled 			cardfound++;
    212       1.5  garbled 			break;
    213       1.5  garbled 		default:
    214       1.5  garbled 			break;
    215       1.5  garbled 		}
    216       1.6  garbled 		if (cardfound) {
    217       1.6  garbled 			outw(VGA_SR_PORT, 0x0120); /* disable video */
    218       1.6  garbled 			set_text_regs();
    219       1.6  garbled 			set_text_clut(0);
    220       1.6  garbled 			load_font(ISA_mem);
    221       1.6  garbled 			set_text_regs();
    222       1.6  garbled 			outw(VGA_SR_PORT, 0x0100); /* re-enable video */
    223       1.6  garbled 			clear_video_memory();
    224       1.6  garbled 
    225       1.6  garbled 			if (PCI_vendor(slot) == PCI_VENDOR_S3)
    226       1.6  garbled 				outb(0x3c2, 0x63);	/* ??? */
    227       1.6  garbled 			delay(1000);
    228       1.6  garbled 		}
    229       1.5  garbled 	}
    230       1.5  garbled 	return;
    231       1.1   nonaka }
    232       1.1   nonaka 
    233       1.5  garbled /* write something to a VGA attribute register */
    234       1.5  garbled static void
    235       1.5  garbled write_attr(u_int8_t index, u_int8_t data, u_int8_t videoOn)
    236       1.1   nonaka {
    237       1.5  garbled 
    238  1.8.44.1    rmind 	(void)inb(0x3da);	/* reset attr addr toggle */
    239       1.1   nonaka 	if (videoOn)
    240       1.1   nonaka 		outb(0x3c0, (index & 0x1F) | 0x20);
    241       1.1   nonaka 	else
    242       1.1   nonaka 		outb(0x3c0, (index & 0x1F));
    243       1.1   nonaka 	outb(0x3c0, data);
    244       1.1   nonaka }
    245       1.1   nonaka 
    246       1.5  garbled static void
    247       1.5  garbled set_text_regs(void)
    248       1.1   nonaka {
    249       1.1   nonaka 	int i;
    250       1.1   nonaka 
    251       1.5  garbled 	for (i = 0; i < SRREGS; i++) {
    252       1.5  garbled 		outb(VGA_SR_PORT, SR_regs[i].idx);
    253       1.5  garbled 		outb(VGA_SR_PORT + 1, SR_regs[i].val);
    254       1.5  garbled 	}
    255       1.5  garbled 	for (i = 0; i < CRREGS; i++) {
    256       1.5  garbled 		outb(VGA_CR_PORT, CR_regs[i].idx);
    257       1.5  garbled 		outb(VGA_CR_PORT + 1, CR_regs[i].val);
    258       1.5  garbled 	}
    259       1.5  garbled 	for (i = 0; i < GRREGS; i++) {
    260       1.5  garbled 		outb(VGA_GR_PORT, GR_regs[i].idx);
    261       1.5  garbled 		outb(VGA_GR_PORT + 1, GR_regs[i].val);
    262       1.1   nonaka 	}
    263       1.1   nonaka 
    264       1.1   nonaka 	outb(0x3c2, 0x67);  /* MISC */
    265       1.1   nonaka 	outb(0x3c6, 0xff);  /* MASK */
    266       1.1   nonaka 
    267       1.5  garbled 	for (i = 0; i < 0x14; i++)
    268       1.5  garbled 		write_attr(i, vga_atc[i], 0);
    269       1.5  garbled 	write_attr(0x14, 0x00, 1); /* color select; video on  */
    270       1.1   nonaka }
    271       1.1   nonaka 
    272       1.5  garbled static void
    273       1.5  garbled set_text_clut(int shift)
    274       1.1   nonaka {
    275       1.1   nonaka 	int i;
    276       1.1   nonaka 
    277       1.5  garbled 	outb(0x3C6, 0xFF);
    278       1.5  garbled 	inb(0x3C7);
    279       1.5  garbled 	outb(0x3C8, 0);
    280       1.5  garbled 	inb(0x3C7);
    281       1.5  garbled 
    282       1.5  garbled 	for (i = 0; i < (16 * 3); ) {
    283       1.5  garbled 		outb(0x3c9, vga_dacpal[i++] << shift);
    284       1.5  garbled 		outb(0x3c9, vga_dacpal[i++] << shift);
    285       1.5  garbled 		outb(0x3c9, vga_dacpal[i++] << shift);
    286       1.1   nonaka 	}
    287       1.1   nonaka }
    288       1.1   nonaka 
    289       1.5  garbled static void
    290       1.5  garbled load_font(u_int8_t *ISA_mem)
    291       1.1   nonaka {
    292       1.1   nonaka 	int i, j;
    293       1.5  garbled 	u_int8_t *font_page = (u_int8_t *)&ISA_mem[0xA0000];
    294       1.5  garbled 
    295       1.1   nonaka 	outb(0x3C2, 0x67);
    296       1.5  garbled 	inb(0x3DA);  /* Reset Attr toggle */
    297       1.5  garbled 
    298       1.5  garbled 	outb(0x3C0, 0x30);
    299       1.5  garbled 	outb(0x3C0, 0x01);	/* graphics mode */
    300       1.5  garbled 	outw(0x3C4, 0x0001);	/* reset sequencer */
    301       1.5  garbled 	outw(0x3C4, 0x0204);	/* write to plane 2 */
    302       1.5  garbled 	outw(0x3C4, 0x0406);	/* enable plane graphics */
    303       1.5  garbled 	outw(0x3C4, 0x0003);	/* reset sequencer */
    304       1.5  garbled 	outw(0x3CE, 0x0402);	/* read plane 2 */
    305       1.5  garbled 	outw(0x3CE, 0x0500);	/* write mode 0, read mode 0 */
    306       1.5  garbled 	outw(0x3CE, 0x0605);	/* set graphics mode */
    307       1.1   nonaka 
    308       1.1   nonaka 	for (i = 0;  i < sizeof(font);  i += 16) {
    309       1.1   nonaka 		for (j = 0;  j < 16;  j++) {
    310       1.5  garbled 			__asm__ volatile("eieio");
    311       1.1   nonaka 			font_page[(2*i)+j] = font[i+j];
    312       1.1   nonaka 		}
    313       1.1   nonaka 	}
    314       1.1   nonaka }
    315       1.1   nonaka 
    316       1.5  garbled static void
    317       1.5  garbled unlock_S3(void)
    318       1.1   nonaka {
    319       1.5  garbled 	int s3_devid;
    320       1.1   nonaka 
    321       1.5  garbled 	outw(VGA_CR_PORT, 0x3848);
    322       1.5  garbled 	outw(VGA_CR_PORT, 0x39a5);
    323       1.5  garbled 	outb(VGA_CR_PORT, 0x2d);
    324       1.5  garbled 	s3_devid = inb(VGA_CR_DATA) << 8;
    325       1.5  garbled 	outb(VGA_CR_PORT, 0x2e);
    326       1.5  garbled 	s3_devid |= inb(VGA_CR_DATA);
    327       1.5  garbled 
    328       1.5  garbled 	if (s3_devid != 0x8812) {
    329       1.5  garbled 		/* from the S3 manual */
    330       1.5  garbled 		outb(0x46E8, 0x10);  /* Put into setup mode */
    331       1.5  garbled 		outb(0x3C3, 0x10);
    332       1.5  garbled 		outb(0x102, 0x01);   /* Enable registers */
    333       1.5  garbled 		outb(0x46E8, 0x08);  /* Enable video */
    334       1.5  garbled 		outb(0x3C3, 0x08);
    335       1.5  garbled 		outb(0x4AE8, 0x00);
    336       1.5  garbled                 outb(VGA_CR_PORT, 0x38);  /* Unlock all registers */
    337       1.5  garbled 		outb(VGA_CR_DATA, 0x48);
    338       1.5  garbled 		outb(VGA_CR_PORT, 0x39);
    339       1.5  garbled 		outb(VGA_CR_DATA, 0xA5);
    340       1.5  garbled 		outb(VGA_CR_PORT, 0x40);
    341       1.5  garbled 		outb(VGA_CR_DATA, inb(0x3D5)|0x01);
    342       1.5  garbled 		outb(VGA_CR_PORT, 0x33);
    343       1.5  garbled 		outb(VGA_CR_DATA, inb(0x3D5)&~0x52);
    344       1.5  garbled 		outb(VGA_CR_PORT, 0x35);
    345       1.5  garbled 		outb(VGA_CR_DATA, inb(0x3D5)&~0x30);
    346       1.5  garbled 		outb(VGA_CR_PORT, 0x3A);
    347       1.5  garbled 		outb(VGA_CR_DATA, 0x00);
    348       1.5  garbled 		outb(VGA_CR_PORT, 0x53);
    349       1.5  garbled 		outb(VGA_CR_DATA, 0x00);
    350       1.5  garbled 		outb(VGA_CR_PORT, 0x31);
    351       1.5  garbled 		outb(VGA_CR_DATA, inb(0x3D5)&~0x4B);
    352       1.5  garbled 		outb(VGA_CR_PORT, 0x58);
    353       1.5  garbled 
    354       1.5  garbled 		outb(VGA_CR_DATA, 0);
    355       1.5  garbled 
    356       1.5  garbled 		outb(VGA_CR_PORT, 0x54);
    357       1.5  garbled 		outb(VGA_CR_DATA, 0x38);
    358       1.5  garbled 		outb(VGA_CR_PORT, 0x60);
    359       1.5  garbled 		outb(VGA_CR_DATA, 0x07);
    360       1.5  garbled 		outb(VGA_CR_PORT, 0x61);
    361       1.5  garbled 		outb(VGA_CR_DATA, 0x80);
    362       1.5  garbled 		outb(VGA_CR_PORT, 0x62);
    363       1.5  garbled 		outb(VGA_CR_DATA, 0xA1);
    364       1.5  garbled 		outb(VGA_CR_PORT, 0x69);  /* High order bits for cursor address */
    365       1.5  garbled 		outb(VGA_CR_DATA, 0);
    366       1.5  garbled 
    367       1.5  garbled 		outb(VGA_CR_PORT, 0x32);
    368       1.5  garbled 		outb(VGA_CR_DATA, inb(0x3D5)&~0x10);
    369       1.5  garbled 	} else {
    370       1.5  garbled 		/* IBM Portable 860 */
    371       1.5  garbled 		outw(VGA_SR_PORT, 0x0806);
    372       1.5  garbled 		outw(VGA_SR_PORT, 0x1041);
    373       1.5  garbled 		outw(VGA_SR_PORT, 0x1128);
    374       1.5  garbled 		outw(VGA_CR_PORT, 0x4000);
    375       1.5  garbled 		outw(VGA_CR_PORT, 0x3100);
    376       1.5  garbled 		outw(VGA_CR_PORT, 0x3a05);
    377       1.5  garbled 		outw(VGA_CR_PORT, 0x6688);
    378       1.5  garbled 		outw(VGA_CR_PORT, 0x5800); /* disable linear addressing */
    379       1.5  garbled 		outw(VGA_CR_PORT, 0x4500); /* disable H/W cursor */
    380       1.5  garbled 		outw(VGA_SR_PORT, 0x5410); /* enable auto-centering */
    381       1.5  garbled 		outw(VGA_SR_PORT, 0x561f);
    382       1.5  garbled 		outw(VGA_SR_PORT, 0x1b80); /* lock DCLK selection */
    383       1.5  garbled 		outw(VGA_CR_PORT, 0x3900); /* lock S3 registers */
    384       1.5  garbled 		outw(VGA_CR_PORT, 0x3800);
    385       1.5  garbled 	}
    386       1.1   nonaka }
    387       1.1   nonaka 
    388       1.5  garbled static void
    389       1.5  garbled clear_video_memory(void)
    390       1.1   nonaka {
    391       1.5  garbled 	int i, j;
    392       1.1   nonaka 
    393       1.5  garbled 	for (i = 0;  i < LINES; i++) {
    394       1.5  garbled 		for (j = 0; j < COLS; j++) {
    395       1.5  garbled 			videomem[((i * COLS)+j) * 2] = 0x20; /* space */
    396       1.5  garbled 			videomem[((i * COLS)+j) * 2 + 1] = 0x07; /* fg/bg */
    397       1.1   nonaka 		}
    398       1.1   nonaka 	}
    399       1.1   nonaka }
    400       1.1   nonaka 
    401       1.5  garbled #endif /* VGA_RESET */
    402