plan 9 kernel history: overview | file list | diff list

1991/1109/pc/vga.c (diff list | history)

1991/1107/sys/src/9/pc/vga.c:24,291991/1109/sys/src/9/pc/vga.c:24,32 (short | long | prev | next)
1991/0730    
 */ 
#define MAXX	640 
#define MAXY	480 
1991/1109    
#define XPERIOD	800	/* Hsync freq == 31.47 KHZ */ 
#define YPERIOD	525	/* Vsync freq == 59.9 HZ */ 
#define YBORDER 2 
1991/0730    
 
#define SCREENMEM	(0xA0000 | KZERO) 
 
1991/1107/sys/src/9/pc/vga.c:52,601991/1109/sys/src/9/pc/vga.c:55,69
1991/0727    
	 Smmask=	 0x02,		/*  map mask */ 
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
1991/0928    
	 Cvertend=	 0x12,		/*  vertical display end */ 
1991/0727    
	 Cmode=		 0x17,		/*  mode register */ 
1991/1109    
	 Cvt=		 0x06,		/*  vertical total */ 
	 Cvover=	 0x07,		/*  bits that didn't fit elsewhere */ 
1991/0727    
	 Cmsl=		 0x09,		/*  max scan line */ 
1991/1109    
	 Cvrs=		 0x10,		/*  vertical retrace start */ 
	 Cvre=		 0x11,		/*  vertical retrace end */ 
	 Cvde=	 	 0x12,		/*  vertical display end */ 
	 Cvbs=		 0x15,		/*  vertical blank start */ 
	 Cvbe=		 0x16,		/*  vertical blank end */ 
	 Cmode=		 0x17,		/*  mode register */ 
1991/0727    
	ARX=		0x3C0,		/* index to attribute registers */ 
	AR=		0x3C1,		/* attribute registers */ 
	 Amode=		 0x10,		/*  mode register */ 
1991/1107/sys/src/9/pc/vga.c:89,1061991/1109/sys/src/9/pc/vga.c:98,104
1991/0727    
	outb(CRX, reg); 
	outb(CR, val); 
} 
1991/1107    
crdump(void) 
{ 
	uchar x; 
	int i; 
 
	for(i = 0; i < 0x16; i++){ 
		outb(CRX, i); 
		x = inb(CR); 
		print("cr[0x%lux] = %ux\n", i, x); 
	} 
} 
1991/0724    
                 
1991/0723    
/* 
1991/0727    
 *  m is a bit mask of planes to be affected by CPU writes 
1991/0723    
 */ 
1991/1107/sys/src/9/pc/vga.c:118,1641991/1109/sys/src/9/pc/vga.c:116,133
1991/0727    
} 
 
/* 
1991/0928    
 *  2 bit deep display.  the bits are adjacent.  maybe this 
 *  will work 
 *	4 color 
1991/1109    
 *  set up like vga mode 0x12 
 *	16 color (though we only use values 0x0 and 0xf) 
1991/0928    
 *	640x480 
1991/1109    
 * 
 *  we assume the BIOS left the registers in a 
 *  CGA-like mode.  Thus we don't set all the registers. 
1991/0928    
 */ 
vga2(void) 
1991/1109    
vga12(void) 
1991/0928    
{ 
	int i; 
	arout(Acpe, 0x00);	/* disable planes for output */ 
1991/1109    
	int overflow; 
	int msl; 
1991/0928    
 
	gscreen.ldepth = 1; 
	arout(Amode, 0x01);	/* color graphics mode */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x30);	/* 2 bits deep, even bytes are 
				 * planes 0 and 2, odd are planes 
				 * 1 and 3 */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	crout(Cvertend, MAXY);	/* 480 lne display */ 
	srout(Smode, 0x06);	/* extended memory, odd/even */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
	srout(Smmask, 0x0f);	/* enable 2 planes for writing */ 
                 
	arout(Acpe, 0x0f);	/* enable 2 planes for output */ 
	for(i = 0; i < 128*1024;){ 
		((uchar*)SCREENMEM)[i++] = 0x1b; 
		((uchar*)SCREENMEM)[i++] = 0xe4; 
	} 
	for(;;); 
} 
                 
/* 
 *  set up like vga mode 0x11 
 *	2 color 
 *	640x480 
 */ 
vga1(void) 
{ 
	arout(Acpe, 0x00);	/* disable planes for output */ 
 
	gscreen.ldepth = 0; 
1991/1107/sys/src/9/pc/vga.c:167,1761991/1109/sys/src/9/pc/vga.c:136,168
1991/0928    
	grout(Gmode, 0x00);	/* 1 bit deep */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
1991/1109    
 
	msl = overflow = 0; 
1991/0928    
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
1991/1002    
	crout(Cvertend, MAXY-1);	/* 480 lne display */ 
1991/1109    
	/* last scan line displayed (first is 0) */ 
	crout(Cvde, MAXY-1); 
	overflow |= ((MAXY-1)&0x200) ? 0x40 : 0; 
	overflow |= ((MAXY-1)&0x100) ? 0x2 : 0; 
	/* total scan lines (including retrace) - 2 */ 
	crout(Cvt, (YPERIOD-2)); 
	overflow |= ((YPERIOD-2)&0x200) ? 0x20 : 0; 
	overflow |= ((YPERIOD-2)&0x100) ? 0x1 : 0; 
	/* scan lines at which vertcal retrace starts & ends */ 
	crout(Cvrs, (MAXY+10)); 
	overflow |= ((MAXY+10)&0x200) ? 0x80 : 0; 
	overflow |= ((MAXY+10)&0x100) ? 0x4 : 0; 
	crout(Cvre, ((YPERIOD-1)&0xf)|0xa0);	/* also disable vertical interrupts */ 
	/* scan lines at which vertical blanking starts & ends */ 
	crout(Cvbs, (MAXY+YBORDER)); 
	msl |= ((MAXY+YBORDER)&0x200) ? 0x20 : 0; 
	overflow |= ((MAXY+YBORDER)&0x100) ? 0x8 : 0; 
	crout(Cvbe, (YPERIOD-YBORDER)&0x7f); 
	/* pixels per scan line (always 0 for graphics) */ 
	crout(Cmsl, 0x40|msl);	/* also 10th bit of line compare */ 
	/* the overflow bits from the other registers */ 
	crout(Cvover, 0x10|overflow);	/* also 9th bit of line compare */ 
 
1991/0928    
	srout(Smode, 0x06);	/* extended memory, 
				 * odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
1991/1107/sys/src/9/pc/vga.c:186,1921991/1109/sys/src/9/pc/vga.c:178,184
1991/0727    
	int c; 
1991/0730    
	ulong *l; 
1991/0723    
 
1991/0928    
	vga1(); 
1991/1109    
	vga12(); 
1991/0929    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)