~kris/9p

9hist

ref: 90f6e3533941b1db7af8caf03641c3275d111a4f 9hist/pc/vga.c -rw-r--r-- 862 bytes
90f6e353 — David du Colombier Plan 9 from Bell Labs 1991-07-26 35 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"

enum
{
	GRX=		0x3CE,		/* index to graphics registers */
	GR=		0x3CF,		/* graphics registers 0-8 */
	SRX=		0x3C4,		/* index to sequence registers */
	SR=		0x3C5,		/* sequence registers 0-7 */
};

void
srout(int reg, int val)
{
	outb(SRX, reg);
	outb(SR, val);
}

void
grout(int reg, int val)
{
	outb(GRX, reg);
	outb(GR, val);
}

/*
 *  look at VGA registers
 */
void
vgainit(void)
{
	uchar *display;
	int i;

	srout(2, 0x0f);		/* enable all 4 color planes */
	srout(4, 0x08);		/* quad mode */
	grout(5, 0x40);		/* pixel bits are sequential */
	grout(6, 0x01);		/* graphics mode - display starts at 0xA0000 */

	for(;;);
	display = (uchar*)(0xA0000 | KZERO);
	for(i = 0; i < 128*1024; i++)
		display[i] = 0x00;

	for(i = 0; i < 4*640; i++)
		display[i] = 0xff;
}