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

1997/1101/pc/vgaclgd542x.c (diff list | history)

1995/02021/sys/src/9/pc/vgaclgd542x.c:9,181997/0327/sys/src/9/pc/vgaclgd542x.c:9,22 (short | long)
1995/02021    
#include "screen.h" 
#include "vga.h" 
 
1997/0327    
static Lock clgd542xlock; 
 
1995/02021    
static void 
clgd542xpage(int page) 
{ 
1997/0327    
	lock(&clgd542xlock); 
1995/02021    
	vgaxo(Grx, 0x09, page<<4); 
1997/0327    
	unlock(&clgd542xlock); 
1995/02021    
} 
 
static Vgac clgd542x = { 
1997/0327/sys/src/9/pc/vgaclgd542x.c:9,151997/0716/sys/src/9/pc/vgaclgd542x.c:9,19 (short | long)
1995/02021    
#include "screen.h" 
#include "vga.h" 
 
1997/0716    
extern Bitmap gscreen; 
extern Cursor curcursor; 
 
1997/0327    
static Lock clgd542xlock; 
1997/0716    
static ulong storage; 
1997/0327    
 
1995/02021    
static void 
clgd542xpage(int page) 
1997/0327/sys/src/9/pc/vgaclgd542x.c:19,241997/0716/sys/src/9/pc/vgaclgd542x.c:23,227
1997/0327    
	unlock(&clgd542xlock); 
1995/02021    
} 
 
1997/0716    
static void 
disable(void) 
{ 
	uchar sr12; 
 
	lock(&clgd542xlock); 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
	unlock(&clgd542xlock); 
} 
 
static void 
enable(void) 
{ 
	uchar sr12; 
  
	/* 
	 * Disable the cursor. 
	 */ 
	lock(&clgd542xlock); 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
 
	/* 
	 * Cursor colours.   
	 */ 
	vgaxo(Seqx, 0x12, sr12|0x02); 
	setcolor(0x00, Pwhite<<(32-6), Pwhite<<(32-6), Pwhite<<(32-6)); 
	setcolor(0x0F, Pblack<<(32-6), Pblack<<(32-6), Pblack<<(32-6)); 
	vgaxo(Seqx, 0x12, sr12); 
 
	/* 
	 * Memory size. The BIOS leaves this in Seq0A, bits 4 and 3. 
	 * See Technical Reference Manual Appendix E1, Section 1.3.2. 
	 * 
	 * The storage area for the 64x64 cursors is the last 16Kb of 
	 * display memory. 
	 */ 
	switch((vgaxi(Seqx, 0x0A)>>3) & 0x03){ 
 
	case 0: 
		storage = (256-16)*1024; 
		break; 
 
	case 1: 
		storage = (512-16)*1024; 
		break; 
 
	case 2: 
		storage = (1024-16)*1024; 
		break; 
 
	case 3: 
		storage = (2048-16)*1024; 
		break; 
	} 
  
	/* 
	 * Set the current cursor to index 0 
	 * and turn the 64x64 cursor on. 
	 */ 
	vgaxo(Seqx, 0x13, 0); 
	vgaxo(Seqx, 0x12, sr12|0x05); 
 
	unlock(&clgd542xlock); 
} 
 
static void 
initcursor(Cursor* c, int xo, int yo, int index) 
{ 
	uchar *p; 
	uint p0, p1; 
	int x, y; 
 
	/* 
	 * Is linear addressing turned on? This will determine 
	 * how we access the cursor storage. 
	 */ 
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		p = ((uchar*)gscreen.base) + storage; 
	else { 
		vgaxo(Grx, 0x09, (storage>>16)<<4); 
		p = ((uchar*)gscreen.base) + (storage & 0xFFFF); 
	} 
	p += index*1024; 
 
	for(y = yo; y < 16; y++){ 
		p0 = c->clr[2*y]; 
		p1 = c->clr[2*y+1]; 
		if(xo){ 
			p0 = (p0<<xo)|(p1>>(8-xo)); 
			p1 <<= xo; 
		} 
		*p++ = p0; 
		*p++ = p1; 
 
		for(x = 16; x < 64; x += 8) 
			*p++ = 0x00; 
 
		p0 = c->clr[2*y]|c->set[2*y]; 
		p1 = c->clr[2*y+1]|c->set[2*y+1]; 
		if(xo){ 
			p0 = (p0<<xo)|(p1>>(8-xo)); 
			p1 <<= xo; 
		} 
		*p++ = p0; 
		*p++ = p1; 
 
		for(x = 16; x < 64; x += 8) 
			*p++ = 0x00; 
	} 
	while(y < 64+yo){ 
		for(x = 0; x < 64; x += 8){ 
			*p++ = 0x00; 
			*p++ = 0x00; 
		} 
		y++; 
	} 
} 
 
static void 
load(Cursor* c) 
{ 
	uchar sr12; 
 
	/* 
	 * Lock the display memory so we can update the 
	 * cursor bitmap if necessary. 
	 * Disable the cursor. 
	 * If it's the same as the last cursor loaded, 
	 * just make sure it's enabled and index 0. 
	 */ 
	lock(&clgd542xlock); 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
 
	if(memcmp(c, &curcursor, sizeof(Cursor)) == 0){ 
		vgaxo(Seqx, 0x13, 0); 
		vgaxo(Seqx, 0x12, sr12|0x05); 
		unlock(&clgd542xlock); 
		return; 
	} 
	memmove(&curcursor, c, sizeof(Cursor)); 
	initcursor(c, 0, 0, 0); 
 
	/* 
	 * Enable the cursor. 
	 */ 
	vgaxo(Seqx, 0x13, 0); 
	vgaxo(Seqx, 0x12, sr12|0x05); 
 
	unlock(&clgd542xlock); 
} 
 
static int 
move(Point p) 
{ 
	int index, x, xo, y, yo; 
 
	if(canlock(&clgd542xlock) == 0) 
		return 1; 
 
	index = 0; 
	if((x = p.x+curcursor.offset.x) < 0){ 
		xo = -x; 
		x = 0; 
	} 
	else 
		xo = 0; 
	if((y = p.y+curcursor.offset.y) < 0){ 
		yo = -y; 
		y = 0; 
	} 
	else 
		yo = 0; 
 
	if(xo || yo){ 
		initcursor(&curcursor, xo, yo, 1); 
		index = 1; 
	} 
	vgaxo(Seqx, 0x13, index<<2); 
	 
	vgaxo(Seqx, 0x10|((x & 0x07)<<5), (x>>3) & 0xFF); 
	vgaxo(Seqx, 0x11|((y & 0x07)<<5), (y>>3) & 0xFF); 
 
	unlock(&clgd542xlock); 
	return 0; 
} 
 
static Hwgc clgd542xhwgc = { 
	"clgd542xhwgc", 
	enable, 
	load, 
	move, 
	disable, 
 
	0, 
}; 
 
1995/02021    
static Vgac clgd542x = { 
	"clgd542x", 
	clgd542xpage, 
1997/0327/sys/src/9/pc/vgaclgd542x.c:30,331997/0716/sys/src/9/pc/vgaclgd542x.c:233,237
1995/02021    
vgaclgd542xlink(void) 
{ 
	addvgaclink(&clgd542x); 
1997/0716    
	addhwgclink(&clgd542xhwgc); 
1995/02021    
} 
1997/0716/sys/src/9/pc/vgaclgd542x.c:3,81997/0717/sys/src/9/pc/vgaclgd542x.c:3,9 (short | long)
1995/02021    
#include "mem.h" 
#include "dat.h" 
#include "fns.h" 
1997/0717    
#include "io.h" 
1995/02021    
#include "../port/error.h" 
 
#include <libg.h> 
1997/0716/sys/src/9/pc/vgaclgd542x.c:23,281997/0717/sys/src/9/pc/vgaclgd542x.c:24,67
1997/0327    
	unlock(&clgd542xlock); 
1995/02021    
} 
 
1997/0717    
static int 
clgd542xlinear(ulong* mem, ulong* size, ulong* align) 
{ 
	ulong baseaddr; 
	static Pcidev *p; 
 
	if((*size && *size < 16*MB) || (*align && (*align & (16*MB-1)))) 
		return 0; 
 
	*mem = 0; 
 
	/* 
	 * This obviously isn't good enough on a system with 
	 * more than one PCI card from Cirrus. 
	 */ 
	if(p == 0 && (p = pcimatch(p, 0x1013, 0)) == 0) 
		return 0; 
 
	switch(p->did){ 
 
	case 0xA0: 
	case 0xA8: 
	case 0xAC: 
		break; 
 
	default: 
		return 0; 
	} 
 
	if((baseaddr = upamalloc(0, *size, *align)) == 0) 
		return 0; 
	*mem = baseaddr; 
	baseaddr = PADDR(baseaddr); 
	pcicfgw32(p, PciBAR0, baseaddr); 
 
	return *mem; 
} 
 
1997/0716    
static void 
disable(void) 
{ 
1997/0716/sys/src/9/pc/vgaclgd542x.c:38,431997/0717/sys/src/9/pc/vgaclgd542x.c:77,83
1997/0716    
enable(void) 
{ 
	uchar sr12; 
1997/0717    
	int mem, x; 
1997/0716    
  
	/* 
	 * Disable the cursor. 
1997/0716/sys/src/9/pc/vgaclgd542x.c:54,851997/0717/sys/src/9/pc/vgaclgd542x.c:94,138
1997/0716    
	setcolor(0x0F, Pblack<<(32-6), Pblack<<(32-6), Pblack<<(32-6)); 
	vgaxo(Seqx, 0x12, sr12); 
 
	/* 
	 * Memory size. The BIOS leaves this in Seq0A, bits 4 and 3. 
	 * See Technical Reference Manual Appendix E1, Section 1.3.2. 
	 * 
	 * The storage area for the 64x64 cursors is the last 16Kb of 
	 * display memory. 
	 */ 
	switch((vgaxi(Seqx, 0x0A)>>3) & 0x03){ 
1997/0717    
	mem = 0; 
	switch(vgaxi(Crtx, 0x27) & ~0x03){ 
1997/0716    
 
	case 0: 
		storage = (256-16)*1024; 
1997/0717    
	case 0x88:				/* CL-GD5420 */ 
	case 0x8C:				/* CL-GD5422 */ 
	case 0x94:				/* CL-GD5424 */ 
	case 0x80:				/* CL-GD5425 */ 
	case 0x90:				/* CL-GD5426 */ 
	case 0x98:				/* CL-GD5427 */ 
	case 0x9C:				/* CL-GD5429 */ 
		/* 
		 * The BIOS leaves the memory size in Seq0A, bits 4 and 3. 
		 * See Technical Reference Manual Appendix E1, Section 1.3.2. 
		 * 
		 * The storage area for the 64x64 cursors is the last 16Kb of 
		 * display memory. 
		 */ 
		mem = (vgaxi(Seqx, 0x0A)>>3) & 0x03; 
1997/0716    
		break; 
 
	case 1: 
		storage = (512-16)*1024; 
1997/0717    
	case 0xA0:				/* CL-GD5430 */ 
	case 0xA8:				/* CL-GD5434 */ 
	case 0xAC:				/* CL-GD5436 */ 
		/* 
		 * Attempt to intuit the memory size from the DRAM control 
		 * register. Minimum is 512KB. 
		 * If DRAM bank switching is on then there's double. 
		 */ 
		x = vgaxi(Seqx, 0x0F); 
		mem = (x>>3) & 0x03; 
		if(x & 0x80) 
			mem++; 
1997/0716    
		break; 
 
	case 2: 
		storage = (1024-16)*1024; 
1997/0717    
	default:				/* uh, ah dunno */ 
1997/0716    
		break; 
                 
	case 3: 
		storage = (2048-16)*1024; 
		break; 
	} 
                  
1997/0717    
	storage = ((256<<mem)-16)*1024; 
 
1997/0716    
	/* 
	 * Set the current cursor to index 0 
	 * and turn the 64x64 cursor on. 
1997/0716/sys/src/9/pc/vgaclgd542x.c:107,1131997/0717/sys/src/9/pc/vgaclgd542x.c:160,168
1997/0716    
		vgaxo(Grx, 0x09, (storage>>16)<<4); 
		p = ((uchar*)gscreen.base) + (storage & 0xFFFF); 
	} 
	p += index*1024; 
1997/0717    
//	p += index*1024; 
memset(p, 0xFF, 16*1024); 
return; 
1997/0716    
 
	for(y = yo; y < 16; y++){ 
		p0 = c->clr[2*y]; 
1997/0716/sys/src/9/pc/vgaclgd542x.c:225,2301997/0717/sys/src/9/pc/vgaclgd542x.c:280,286
1995/02021    
static Vgac clgd542x = { 
	"clgd542x", 
	clgd542xpage, 
1997/0717    
	clgd542xlinear, 
1995/02021    
 
	0, 
}; 
1997/0717/sys/src/9/pc/vgaclgd542x.c:17,261997/0718/sys/src/9/pc/vgaclgd542x.c:17,37 (short | long)
1997/0716    
static ulong storage; 
1997/0327    
 
1995/02021    
static void 
1997/0718    
setclgd542xpage(int page) 
{ 
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		page = 0; 
	if(vgaxi(Seqx, 0x0B) & 0x20) 
		vgaxo(Grx, 0x09, page<<2); 
	else 
		vgaxo(Grx, 0x09, page<<4); 
} 
 
static void 
1995/02021    
clgd542xpage(int page) 
{ 
1997/0327    
	lock(&clgd542xlock); 
1995/02021    
	vgaxo(Grx, 0x09, page<<4); 
1997/0718    
	setclgd542xpage(page); 
1997/0327    
	unlock(&clgd542xlock); 
1995/02021    
} 
 
1997/0717/sys/src/9/pc/vgaclgd542x.c:30,371997/0718/sys/src/9/pc/vgaclgd542x.c:41,52
1997/0717    
	ulong baseaddr; 
	static Pcidev *p; 
 
	if((*size && *size < 16*MB) || (*align && (*align & (16*MB-1)))) 
1997/0718    
	if(*size != 16*MB) 
1997/0717    
		return 0; 
1997/0718    
	if(*align == 0) 
		*align = 16*MB; 
	else if(*align & (16*MB-1)) 
		return 0; 
1997/0717    
 
	*mem = 0; 
 
1997/0717/sys/src/9/pc/vgaclgd542x.c:53,581997/0718/sys/src/9/pc/vgaclgd542x.c:68,77
1997/0717    
		return 0; 
	} 
 
1997/0718    
	/* 
	 * This doesn't work if the card is on the other side of a 
	 * a bridge. Need to coordinate with PCI support. 
	 */ 
1997/0717    
	if((baseaddr = upamalloc(0, *size, *align)) == 0) 
		return 0; 
	*mem = baseaddr; 
1997/0717/sys/src/9/pc/vgaclgd542x.c:157,1681997/0718/sys/src/9/pc/vgaclgd542x.c:176,185
1997/0716    
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		p = ((uchar*)gscreen.base) + storage; 
	else { 
		vgaxo(Grx, 0x09, (storage>>16)<<4); 
1997/0718    
		setclgd542xpage(storage>>16); 
1997/0716    
		p = ((uchar*)gscreen.base) + (storage & 0xFFFF); 
	} 
1997/0717    
//	p += index*1024; 
memset(p, 0xFF, 16*1024); 
return; 
1997/0718    
	p += index*1024; 
1997/0716    
 
	for(y = yo; y < 16; y++){ 
		p0 = c->clr[2*y]; 
1997/0717/sys/src/9/pc/vgaclgd542x.c:228,2331997/0718/sys/src/9/pc/vgaclgd542x.c:245,254
1997/0716    
	 */ 
	vgaxo(Seqx, 0x13, 0); 
	vgaxo(Seqx, 0x12, sr12|0x05); 
1997/0718    
{ 
for(storage = 0; storage < (2048-32)*1024; storage += 16*1024) 
    initcursor(c, 0, 0, 0); 
} 
1997/0716    
 
	unlock(&clgd542xlock); 
} 
1997/0718/sys/src/9/pc/vgaclgd542x.c:16,301997/1004/sys/src/9/pc/vgaclgd542x.c:16,41 (short | long)
1997/0327    
static Lock clgd542xlock; 
1997/0716    
static ulong storage; 
1997/0327    
 
1995/02021    
static void 
1997/1004    
static int 
1997/0718    
setclgd542xpage(int page) 
{ 
1997/1004    
	uchar gr9, grB; 
	int opage; 
 
1997/0718    
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		page = 0; 
	if(vgaxi(Seqx, 0x0B) & 0x20) 
1997/1004    
	gr9 = vgaxi(Grx, 0x09); 
	grB = vgaxi(Grx, 0x0B); 
	if(grB & 0x20){ 
1997/0718    
		vgaxo(Grx, 0x09, page<<2); 
	else 
1997/1004    
		opage = gr9>>2; 
	} 
	else{ 
1997/0718    
		vgaxo(Grx, 0x09, page<<4); 
1997/1004    
		opage = gr9>>4; 
	} 
 
	return opage; 
1997/0718    
} 
 
static void 
1997/0718/sys/src/9/pc/vgaclgd542x.c:162,1831997/1004/sys/src/9/pc/vgaclgd542x.c:173,224
1997/0716    
	unlock(&clgd542xlock); 
} 
 
1997/1004    
static uchar* 
buggery(int on) 
{ 
	static uchar gr9, grA, grB; 
	uchar *p; 
 
	p = 0; 
	if(on){ 
		gr9 = vgaxi(Grx, 0x09); 
		grA = vgaxi(Grx, 0x0A); 
		grB = vgaxi(Grx, 0x0B); 
 
		vgaxo(Grx, 0x0B, 0x21|grB); 
		vgaxo(Grx, 0x09, storage>>14); 
		p = ((uchar*)gscreen.base) + (storage & 0x3FFF); 
	} 
	else{ 
		vgaxo(Grx, 0x09, gr9); 
		vgaxo(Grx, 0x0A, grA); 
		vgaxo(Grx, 0x0B, grB); 
	} 
 
	return p; 
} 
 
1997/0716    
static void 
initcursor(Cursor* c, int xo, int yo, int index) 
{ 
	uchar *p; 
	uint p0, p1; 
	int x, y; 
1997/1004    
	int opage, x, y; 
1997/0716    
 
	/* 
	 * Is linear addressing turned on? This will determine 
	 * how we access the cursor storage. 
	 */ 
1997/1004    
	opage = 0; 
1997/0716    
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		p = ((uchar*)gscreen.base) + storage; 
	else { 
1997/0718    
		setclgd542xpage(storage>>16); 
1997/1004    
	else{ 
#ifdef notdef 
		p = buggery(1); 
#else 
		opage = setclgd542xpage(storage>>16); 
1997/0716    
		p = ((uchar*)gscreen.base) + (storage & 0xFFFF); 
1997/1004    
#endif /* notdef */ 
1997/0716    
	} 
1997/0718    
	p += index*1024; 
1997/0716    
 
1997/0718/sys/src/9/pc/vgaclgd542x.c:213,2181997/1004/sys/src/9/pc/vgaclgd542x.c:254,266
1997/0716    
		} 
		y++; 
	} 
1997/1004    
 
#ifdef notdef 
	buggery(0); 
#endif /* notdef */ 
 
	if(!(vgaxi(Seqx, 0x07) & 0xF0)) 
		setclgd542xpage(opage); 
1997/0716    
} 
 
static void 
1997/0718/sys/src/9/pc/vgaclgd542x.c:245,2541997/1004/sys/src/9/pc/vgaclgd542x.c:293,298
1997/0716    
	 */ 
	vgaxo(Seqx, 0x13, 0); 
	vgaxo(Seqx, 0x12, sr12|0x05); 
1997/0718    
{ 
for(storage = 0; storage < (2048-32)*1024; storage += 16*1024) 
    initcursor(c, 0, 0, 0); 
} 
1997/0716    
 
	unlock(&clgd542xlock); 
} 
1997/1004/sys/src/9/pc/vgaclgd542x.c:19,321997/1007/sys/src/9/pc/vgaclgd542x.c:19,31 (short | long)
1997/1004    
static int 
1997/0718    
setclgd542xpage(int page) 
{ 
1997/1004    
	uchar gr9, grB; 
1997/1007    
	uchar gr9; 
1997/1004    
	int opage; 
 
1997/0718    
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		page = 0; 
1997/1004    
	gr9 = vgaxi(Grx, 0x09); 
	grB = vgaxi(Grx, 0x0B); 
	if(grB & 0x20){ 
1997/1007    
	if(vgaxi(Grx, 0x0B) & 0x20){ 
1997/0718    
		vgaxo(Grx, 0x09, page<<2); 
1997/1004    
		opage = gr9>>2; 
	} 
1997/1004/sys/src/9/pc/vgaclgd542x.c:46,971997/1007/sys/src/9/pc/vgaclgd542x.c:45,50
1997/0327    
	unlock(&clgd542xlock); 
1995/02021    
} 
 
1997/0717    
static int 
clgd542xlinear(ulong* mem, ulong* size, ulong* align) 
{ 
	ulong baseaddr; 
	static Pcidev *p; 
                 
1997/0718    
	if(*size != 16*MB) 
1997/0717    
		return 0; 
1997/0718    
	if(*align == 0) 
		*align = 16*MB; 
	else if(*align & (16*MB-1)) 
		return 0; 
1997/0717    
                 
	*mem = 0; 
                 
	/* 
	 * This obviously isn't good enough on a system with 
	 * more than one PCI card from Cirrus. 
	 */ 
	if(p == 0 && (p = pcimatch(p, 0x1013, 0)) == 0) 
		return 0; 
                 
	switch(p->did){ 
                 
	case 0xA0: 
	case 0xA8: 
	case 0xAC: 
		break; 
                 
	default: 
		return 0; 
	} 
                 
1997/0718    
	/* 
	 * This doesn't work if the card is on the other side of a 
	 * a bridge. Need to coordinate with PCI support. 
	 */ 
1997/0717    
	if((baseaddr = upamalloc(0, *size, *align)) == 0) 
		return 0; 
	*mem = baseaddr; 
	baseaddr = PADDR(baseaddr); 
	pcicfgw32(p, PciBAR0, baseaddr); 
                 
	return *mem; 
} 
                 
1997/0716    
static void 
disable(void) 
{ 
1997/1004/sys/src/9/pc/vgaclgd542x.c:120,1271997/1007/sys/src/9/pc/vgaclgd542x.c:73,80
1997/0716    
	 * Cursor colours.   
	 */ 
	vgaxo(Seqx, 0x12, sr12|0x02); 
	setcolor(0x00, Pwhite<<(32-6), Pwhite<<(32-6), Pwhite<<(32-6)); 
	setcolor(0x0F, Pblack<<(32-6), Pblack<<(32-6), Pblack<<(32-6)); 
1997/1007    
	setcolor(0x00, Pblack<<(32-6), Pblack<<(32-6), Pblack<<(32-6)); 
	setcolor(0x0F, Pwhite<<(32-6), Pwhite<<(32-6), Pwhite<<(32-6)); 
1997/0716    
	vgaxo(Seqx, 0x12, sr12); 
 
1997/0717    
	mem = 0; 
1997/1004/sys/src/9/pc/vgaclgd542x.c:173,2071997/1007/sys/src/9/pc/vgaclgd542x.c:126,135
1997/0716    
	unlock(&clgd542xlock); 
} 
 
1997/1004    
static uchar* 
buggery(int on) 
{ 
	static uchar gr9, grA, grB; 
	uchar *p; 
                 
	p = 0; 
	if(on){ 
		gr9 = vgaxi(Grx, 0x09); 
		grA = vgaxi(Grx, 0x0A); 
		grB = vgaxi(Grx, 0x0B); 
                 
		vgaxo(Grx, 0x0B, 0x21|grB); 
		vgaxo(Grx, 0x09, storage>>14); 
		p = ((uchar*)gscreen.base) + (storage & 0x3FFF); 
	} 
	else{ 
		vgaxo(Grx, 0x09, gr9); 
		vgaxo(Grx, 0x0A, grA); 
		vgaxo(Grx, 0x0B, grB); 
	} 
                 
	return p; 
} 
                 
1997/0716    
static void 
initcursor(Cursor* c, int xo, int yo, int index) 
{ 
	uchar *p; 
1997/1007    
	uchar *p, seq07; 
1997/0716    
	uint p0, p1; 
1997/1004    
	int opage, x, y; 
1997/0716    
 
1997/1004/sys/src/9/pc/vgaclgd542x.c:209,2301997/1007/sys/src/9/pc/vgaclgd542x.c:137,156
1997/0716    
	 * Is linear addressing turned on? This will determine 
	 * how we access the cursor storage. 
	 */ 
1997/1007    
	seq07 = vgaxi(Seqx, 0x07); 
1997/1004    
	opage = 0; 
1997/0716    
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		p = ((uchar*)gscreen.base) + storage; 
1997/1004    
	else{ 
#ifdef notdef 
		p = buggery(1); 
#else 
1997/1007    
	p = ((uchar*)gscreen.base); 
	if(!(seq07 & 0xF0)){ 
1997/1004    
		opage = setclgd542xpage(storage>>16); 
1997/0716    
		p = ((uchar*)gscreen.base) + (storage & 0xFFFF); 
1997/1004    
#endif /* notdef */ 
1997/1007    
		p += (storage & 0xFFFF); 
1997/0716    
	} 
1997/1007    
	else 
		p += storage; 
1997/0718    
	p += index*1024; 
1997/0716    
 
	for(y = yo; y < 16; y++){ 
		p0 = c->clr[2*y]; 
		p1 = c->clr[2*y+1]; 
1997/1007    
		p0 = c->set[2*y]; 
		p1 = c->set[2*y+1]; 
1997/0716    
		if(xo){ 
			p0 = (p0<<xo)|(p1>>(8-xo)); 
			p1 <<= xo; 
1997/1004/sys/src/9/pc/vgaclgd542x.c:255,2651997/1007/sys/src/9/pc/vgaclgd542x.c:181,187
1997/0716    
		y++; 
	} 
1997/1004    
 
#ifdef notdef 
	buggery(0); 
#endif /* notdef */ 
                 
	if(!(vgaxi(Seqx, 0x07) & 0xF0)) 
1997/1007    
	if(!(seq07 & 0xF0)) 
1997/1004    
		setclgd542xpage(opage); 
1997/0716    
} 
 
1997/1004/sys/src/9/pc/vgaclgd542x.c:345,3511997/1007/sys/src/9/pc/vgaclgd542x.c:267,273
1995/02021    
static Vgac clgd542x = { 
	"clgd542x", 
	clgd542xpage, 
1997/0717    
	clgd542xlinear, 
1997/1007    
	0, 
1995/02021    
 
	0, 
}; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:6,371997/1101/sys/src/9/pc/vgaclgd542x.c:6,32 (short | long)
1997/0717    
#include "io.h" 
1995/02021    
#include "../port/error.h" 
 
#include <libg.h> 
1997/1101    
#define	Image	IMAGE 
#include <draw.h> 
#include <memdraw.h> 
1995/02021    
#include "screen.h" 
#include "vga.h" 
 
1997/0716    
extern Bitmap gscreen; 
extern Cursor curcursor; 
                 
1997/0327    
static Lock clgd542xlock; 
1997/0716    
static ulong storage; 
1997/0327    
                 
1997/1004    
static int 
1997/0718    
setclgd542xpage(int page) 
1997/1101    
clgd542xpageset(VGAscr*, int page) 
1997/0718    
{ 
1997/1007    
	uchar gr9; 
1997/1101    
	uchar gr09; 
1997/1004    
	int opage; 
                 
1997/1101    
	 
1997/0718    
	if(vgaxi(Seqx, 0x07) & 0xF0) 
		page = 0; 
1997/1004    
	gr9 = vgaxi(Grx, 0x09); 
1997/1101    
	gr09 = vgaxi(Grx, 0x09); 
1997/1007    
	if(vgaxi(Grx, 0x0B) & 0x20){ 
1997/0718    
		vgaxo(Grx, 0x09, page<<2); 
1997/1004    
		opage = gr9>>2; 
1997/1101    
		opage = gr09>>2; 
1997/1004    
	} 
	else{ 
1997/0718    
		vgaxo(Grx, 0x09, page<<4); 
1997/1004    
		opage = gr9>>4; 
1997/1101    
		opage = gr09>>4; 
1997/1004    
	} 
 
	return opage; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:38,631997/1101/sys/src/9/pc/vgaclgd542x.c:33,56
1997/0718    
} 
 
static void 
1995/02021    
clgd542xpage(int page) 
1997/1101    
clgd542xpage(VGAscr* scr, int page) 
1995/02021    
{ 
1997/0327    
	lock(&clgd542xlock); 
1997/0718    
	setclgd542xpage(page); 
1997/0327    
	unlock(&clgd542xlock); 
1997/1101    
	lock(&scr->devlock); 
	clgd542xpageset(scr, page); 
	unlock(&scr->devlock); 
1995/02021    
} 
 
1997/0716    
static void 
disable(void) 
1997/1101    
clgd542xdisable(VGAscr*) 
1997/0716    
{ 
	uchar sr12; 
 
	lock(&clgd542xlock); 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
	unlock(&clgd542xlock); 
} 
 
static void 
enable(void) 
1997/1101    
clgd542xenable(VGAscr* scr) 
1997/0716    
{ 
	uchar sr12; 
1997/0717    
	int mem, x; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:65,801997/1101/sys/src/9/pc/vgaclgd542x.c:58,79
1997/0716    
	/* 
	 * Disable the cursor. 
	 */ 
	lock(&clgd542xlock); 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
 
	/* 
	 * Cursor colours.   
1997/1101    
	 * Cursor colours. 
	 * Can't call setcolor here as cursor is already locked. 
1997/0716    
	 */ 
	vgaxo(Seqx, 0x12, sr12|0x02); 
1997/1007    
	setcolor(0x00, Pblack<<(32-6), Pblack<<(32-6), Pblack<<(32-6)); 
	setcolor(0x0F, Pwhite<<(32-6), Pwhite<<(32-6), Pwhite<<(32-6)); 
1997/1101    
	vgao(PaddrW, 0x00); 
	vgao(Pdata, Pwhite); 
	vgao(Pdata, Pwhite); 
	vgao(Pdata, Pwhite); 
	vgao(PaddrW, 0x0F); 
	vgao(Pdata, Pblack); 
	vgao(Pdata, Pblack); 
	vgao(Pdata, Pblack); 
1997/0716    
	vgaxo(Seqx, 0x12, sr12); 
 
1997/0717    
	mem = 0; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:114,1201997/1101/sys/src/9/pc/vgaclgd542x.c:113,119
1997/0717    
	default:				/* uh, ah dunno */ 
1997/0716    
		break; 
	} 
1997/0717    
	storage = ((256<<mem)-16)*1024; 
1997/1101    
	scr->storage = ((256<<mem)-16)*1024; 
1997/0717    
 
1997/0716    
	/* 
	 * Set the current cursor to index 0 
1997/1007/sys/src/9/pc/vgaclgd542x.c:122,1331997/1101/sys/src/9/pc/vgaclgd542x.c:121,130
1997/0716    
	 */ 
	vgaxo(Seqx, 0x13, 0); 
	vgaxo(Seqx, 0x12, sr12|0x05); 
                 
	unlock(&clgd542xlock); 
} 
 
static void 
initcursor(Cursor* c, int xo, int yo, int index) 
1997/1101    
clgd542xinitcursor(VGAscr* scr, int xo, int yo, int index) 
1997/0716    
{ 
1997/1007    
	uchar *p, seq07; 
1997/0716    
	uint p0, p1; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:139,1561997/1101/sys/src/9/pc/vgaclgd542x.c:136,154
1997/0716    
	 */ 
1997/1007    
	seq07 = vgaxi(Seqx, 0x07); 
1997/1004    
	opage = 0; 
1997/1007    
	p = ((uchar*)gscreen.base); 
1997/1101    
	p = KADDR(scr->aperture); 
1997/1007    
	if(!(seq07 & 0xF0)){ 
1997/1004    
		opage = setclgd542xpage(storage>>16); 
1997/1007    
		p += (storage & 0xFFFF); 
1997/1101    
		lock(&scr->devlock); 
		opage = clgd542xpageset(scr, scr->storage>>16); 
		p += (scr->storage & 0xFFFF); 
1997/0716    
	} 
1997/1007    
	else 
		p += storage; 
1997/1101    
		p += scr->storage; 
1997/0718    
	p += index*1024; 
1997/0716    
 
	for(y = yo; y < 16; y++){ 
1997/1007    
		p0 = c->set[2*y]; 
		p1 = c->set[2*y+1]; 
1997/1101    
		p0 = scr->set[2*y]; 
		p1 = scr->set[2*y+1]; 
1997/0716    
		if(xo){ 
			p0 = (p0<<xo)|(p1>>(8-xo)); 
			p1 <<= xo; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:161,1681997/1101/sys/src/9/pc/vgaclgd542x.c:159,166
1997/0716    
		for(x = 16; x < 64; x += 8) 
			*p++ = 0x00; 
 
		p0 = c->clr[2*y]|c->set[2*y]; 
		p1 = c->clr[2*y+1]|c->set[2*y+1]; 
1997/1101    
		p0 = scr->clr[2*y]|scr->set[2*y]; 
		p1 = scr->clr[2*y+1]|scr->set[2*y+1]; 
1997/0716    
		if(xo){ 
			p0 = (p0<<xo)|(p1>>(8-xo)); 
			p1 <<= xo; 
1997/1007/sys/src/9/pc/vgaclgd542x.c:181,2141997/1101/sys/src/9/pc/vgaclgd542x.c:179,203
1997/0716    
		y++; 
	} 
1997/1004    
 
1997/1007    
	if(!(seq07 & 0xF0)) 
1997/1004    
		setclgd542xpage(opage); 
1997/1101    
	if(!(seq07 & 0xF0)){ 
		clgd542xpageset(scr, opage); 
		unlock(&scr->devlock); 
	} 
1997/0716    
} 
 
static void 
load(Cursor* c) 
1997/1101    
clgd542xload(VGAscr* scr, Cursor* curs) 
1997/0716    
{ 
	uchar sr12; 
 
	/* 
	 * Lock the display memory so we can update the 
	 * cursor bitmap if necessary. 
	 * Disable the cursor. 
	 * If it's the same as the last cursor loaded, 
	 * just make sure it's enabled and index 0. 
	 */ 
	lock(&clgd542xlock); 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
 
	if(memcmp(c, &curcursor, sizeof(Cursor)) == 0){ 
		vgaxo(Seqx, 0x13, 0); 
		vgaxo(Seqx, 0x12, sr12|0x05); 
		unlock(&clgd542xlock); 
		return; 
	} 
	memmove(&curcursor, c, sizeof(Cursor)); 
	initcursor(c, 0, 0, 0); 
1997/1101    
	memmove(&scr->Cursor, curs, sizeof(Cursor)); 
	clgd542xinitcursor(scr, 0, 0, 0); 
1997/0716    
 
	/* 
	 * Enable the cursor. 
1997/1007/sys/src/9/pc/vgaclgd542x.c:215,2401997/1101/sys/src/9/pc/vgaclgd542x.c:204,224
1997/0716    
	 */ 
	vgaxo(Seqx, 0x13, 0); 
	vgaxo(Seqx, 0x12, sr12|0x05); 
                 
	unlock(&clgd542xlock); 
} 
 
static int 
move(Point p) 
1997/1101    
clgd542xmove(VGAscr* scr, Point p) 
1997/0716    
{ 
	int index, x, xo, y, yo; 
 
	if(canlock(&clgd542xlock) == 0) 
		return 1; 
                 
	index = 0; 
	if((x = p.x+curcursor.offset.x) < 0){ 
1997/1101    
	if((x = p.x+scr->offset.x) < 0){ 
1997/0716    
		xo = -x; 
		x = 0; 
	} 
	else 
		xo = 0; 
	if((y = p.y+curcursor.offset.y) < 0){ 
1997/1101    
	if((y = p.y+scr->offset.y) < 0){ 
1997/0716    
		yo = -y; 
		y = 0; 
	} 
1997/1007/sys/src/9/pc/vgaclgd542x.c:242,2481997/1101/sys/src/9/pc/vgaclgd542x.c:226,232
1997/0716    
		yo = 0; 
 
	if(xo || yo){ 
		initcursor(&curcursor, xo, yo, 1); 
1997/1101    
		clgd542xinitcursor(scr, xo, yo, 1); 
1997/0716    
		index = 1; 
	} 
	vgaxo(Seqx, 0x13, index<<2); 
1997/1007/sys/src/9/pc/vgaclgd542x.c:250,2801997/1101/sys/src/9/pc/vgaclgd542x.c:234,256
1997/0716    
	vgaxo(Seqx, 0x10|((x & 0x07)<<5), (x>>3) & 0xFF); 
	vgaxo(Seqx, 0x11|((y & 0x07)<<5), (y>>3) & 0xFF); 
 
	unlock(&clgd542xlock); 
	return 0; 
} 
 
static Hwgc clgd542xhwgc = { 
	"clgd542xhwgc", 
	enable, 
	load, 
	move, 
	disable, 
1997/1101    
VGAdev vgaclgd542xdev = { 
	"clgd542x", 
1997/0716    
 
	0, 
}; 
                 
1995/02021    
static Vgac clgd542x = { 
	"clgd542x", 
1997/1101    
	0, 
1995/02021    
	clgd542xpage, 
1997/1007    
	0, 
1995/02021    
                 
	0, 
}; 
 
void 
vgaclgd542xlink(void) 
{ 
	addvgaclink(&clgd542x); 
1997/0716    
	addhwgclink(&clgd542xhwgc); 
1995/02021    
} 
1997/1101    
VGAcur vgaclgd542xcur = { 
	"clgd542xhwgc", 
 
	clgd542xenable, 
	clgd542xdisable, 
	clgd542xload, 
	clgd542xmove, 
}; 
1997/1101/sys/src/9/pc/vgaclgd542x.c:99,1041998/0106/sys/src/9/pc/vgaclgd542x.c:99,105 (short | long)
1997/0717    
	case 0xA0:				/* CL-GD5430 */ 
	case 0xA8:				/* CL-GD5434 */ 
	case 0xAC:				/* CL-GD5436 */ 
1998/0106    
	case 0xB8:				/* CL-GD5446 */ 
1997/0717    
		/* 
		 * Attempt to intuit the memory size from the DRAM control 
		 * register. Minimum is 512KB. 
1998/0106/sys/src/9/pc/vgaclgd542x.c:58,651998/0308/sys/src/9/pc/vgaclgd542x.c:58,65 (short | long)
1997/0716    
	/* 
	 * Disable the cursor. 
	 */ 
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
1998/0308    
	sr12 = vgaxi(Seqx, 0x12) & ~0x01; 
	vgaxo(Seqx, 0x12, sr12); 
1997/0716    
 
	/* 
1997/1101    
	 * Cursor colours. 
1998/0308/sys/src/9/pc/vgaclgd542x.c:58,651998/0312/sys/src/9/pc/vgaclgd542x.c:58,65 (short | long)
1997/0716    
	/* 
	 * Disable the cursor. 
	 */ 
1998/0308    
	sr12 = vgaxi(Seqx, 0x12) & ~0x01; 
	vgaxo(Seqx, 0x12, sr12); 
1998/0312    
	sr12 = vgaxi(Seqx, 0x12); 
	vgaxo(Seqx, 0x12, sr12 & ~0x01); 
1997/0716    
 
	/* 
1997/1101    
	 * Cursor colours. 
1998/0312/sys/src/9/pc/vgaclgd542x.c:40,451998/0512/sys/src/9/pc/vgaclgd542x.c:40,77 (short | long)
Add linear mode for 0x1013 card.
rsc Fri Mar 4 12:44:25 2005
1997/1101    
	unlock(&scr->devlock); 
1995/02021    
} 
 
1998/0512    
static ulong 
clgd542xlinear(VGAscr* scr, int* size, int* align) 
{ 
	ulong aperture, oaperture; 
	int oapsize, wasupamem; 
	Pcidev *p; 
 
	oaperture = scr->aperture; 
	oapsize = scr->apsize; 
	wasupamem = scr->isupamem; 
	if(wasupamem) 
		upafree(oaperture, oapsize); 
	scr->isupamem = 0; 
 
	if(p = pcimatch(nil, 0x1013, 0)){ 
		aperture = p->mem[0].bar & ~0x0F; 
		*size = p->mem[0].size; 
	} 
	else 
		aperture = 0; 
 
	aperture = upamalloc(aperture, *size, *align); 
	if(aperture == 0){ 
		if(wasupamem && upamalloc(oaperture, oapsize, 0)) 
			scr->isupamem = 1; 
	} 
	else 
		scr->isupamem = 1; 
 
	return aperture; 
} 
 
1997/0716    
static void 
1997/1101    
clgd542xdisable(VGAscr*) 
1997/0716    
{ 
1998/0312/sys/src/9/pc/vgaclgd542x.c:244,2501998/0512/sys/src/9/pc/vgaclgd542x.c:276,282
1997/0716    
	0, 
1997/1101    
	0, 
1995/02021    
	clgd542xpage, 
1997/1007    
	0, 
1998/0512    
	clgd542xlinear, 
1995/02021    
}; 
 
1997/1101    
VGAcur vgaclgd542xcur = { 
1998/0512/sys/src/9/pc/vgaclgd542x.c:9,141999/0119/sys/src/9/pc/vgaclgd542x.c:9,15 (short | long)
1997/1101    
#define	Image	IMAGE 
#include <draw.h> 
#include <memdraw.h> 
1999/0119    
#include <cursor.h> 
1995/02021    
#include "screen.h" 
 
1997/1004    
static int 
1999/0119/sys/src/9/pc/vgaclgd542x.c:133,1382000/0927/sys/src/9/pc/vgaclgd542x.c:133,139 (short | long)
1997/0717    
	case 0xA8:				/* CL-GD5434 */ 
	case 0xAC:				/* CL-GD5436 */ 
1998/0106    
	case 0xB8:				/* CL-GD5446 */ 
2000/0927    
	case 0x30:				/* CL-GD7543 */ 
1997/0717    
		/* 
		 * Attempt to intuit the memory size from the DRAM control 
		 * register. Minimum is 512KB. 


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