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

1990/11211/port/devbit.c (diff list | history)

1990/1012/sys/src/9/port/devbit.c:125,1331990/11211/sys/src/9/port/devbit.c:125,133 (short | long | prev | next)
1990/0324    
}; 
 
Dirtab bitdir[]={ 
	"bitblt",	Qbitblt,	0,			0600, 
1990/0329    
	"mouse",	Qmouse,		0,			0600, 
1990/0709    
	"screen",	Qscreen,	0,			0400, 
1990/11211    
	"bitblt",	{Qbitblt},	0,			0600, 
	"mouse",	{Qmouse},	0,			0600, 
	"screen",	{Qscreen},	0,			0400, 
1990/0324    
}; 
 
#define	NBIT	(sizeof bitdir/sizeof(Dirtab)) 
1990/1012/sys/src/9/port/devbit.c:181,1871990/11211/sys/src/9/port/devbit.c:181,187
1990/0324    
bitclone(Chan *c, Chan *nc) 
{ 
	nc = devclone(c, nc); 
	if(c->qid != CHDIR) 
1990/11211    
	if(c->qid.path != CHDIR) 
1990/0324    
		incref(&bit); 
} 
 
1990/1012/sys/src/9/port/devbit.c:200,2131990/11211/sys/src/9/port/devbit.c:200,213
1990/0324    
Chan * 
bitopen(Chan *c, int omode) 
{ 
	if(c->qid == CHDIR){ 
1990/11211    
	if(c->qid.path == CHDIR){ 
1990/0324    
		if(omode != OREAD) 
			error(0, Eperm); 
1990/0515    
	}else if(c->qid == Qbitblt){ 
1990/11211    
			error(Eperm); 
	}else if(c->qid.path == Qbitblt){ 
1990/0324    
		lock(&bit); 
1990/0515    
		if(bit.ref){ 
1990/0324    
			unlock(&bit); 
			error(0, Einuse); 
1990/11211    
			error(Einuse); 
1990/0324    
		} 
1990/0327    
		bit.lastid = -1; 
1990/0623    
		bit.lastfid = -1; 
1990/1012/sys/src/9/port/devbit.c:227,2451990/11211/sys/src/9/port/devbit.c:227,245
1990/0324    
void 
bitcreate(Chan *c, char *name, int omode, ulong perm) 
{ 
	error(0, Eperm); 
1990/11211    
	error(Eperm); 
1990/0324    
} 
 
void 
bitremove(Chan *c) 
{ 
	error(0, Eperm); 
1990/11211    
	error(Eperm); 
1990/0324    
} 
 
void 
bitwstat(Chan *c, char *db) 
{ 
	error(0, Eperm); 
1990/11211    
	error(Eperm); 
1990/0324    
} 
 
void 
1990/1012/sys/src/9/port/devbit.c:249,2551990/11211/sys/src/9/port/devbit.c:249,255
1990/0902    
	GBitmap *bp; 
	GFont *fp; 
1990/0327    
 
1990/05151    
	if(c->qid!=CHDIR && (c->flag&COPEN)){ 
1990/11211    
	if(c->qid.path!=CHDIR && (c->flag&COPEN)){ 
1990/0329    
		lock(&bit); 
1990/0327    
		if(--bit.ref == 0){ 
			for(i=1,bp=&bit.map[1]; i<conf.nbitmap; i++,bp++) 
1990/1012/sys/src/9/port/devbit.c:284,2931990/11211/sys/src/9/port/devbit.c:284,293
1990/06231    
	Fontchar *i; 
1990/0902    
	GBitmap *src; 
1990/0327    
 
1990/0324    
	if(c->qid & CHDIR) 
1990/11211    
	if(c->qid.path & CHDIR) 
1990/0324    
		return devdirread(c, va, n, bitdir, NBIT, devgen); 
 
1990/0505    
	switch(c->qid){ 
1990/11211    
	switch(c->qid.path){ 
1990/0505    
	case Qmouse: 
1990/0329    
		/* 
1990/0505    
		 * mouse: 
1990/1012/sys/src/9/port/devbit.c:296,3021990/11211/sys/src/9/port/devbit.c:296,302
1990/0505    
		 * 	point		8 
1990/0329    
		 */ 
1990/0505    
		if(n < 10) 
1990/0329    
			error(0, Ebadblt); 
1990/11211    
			error(Ebadblt); 
1990/0505    
	    Again: 
		while(mouse.changed == 0) 
			sleep(&mouse.r, mousechanged, 0); 
1990/1012/sys/src/9/port/devbit.c:331,3371990/11211/sys/src/9/port/devbit.c:331,337
1990/06231    
			 *	fontchars	6*(defont->n+1) 
1990/0505    
			 */ 
			if(n < 18) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0505    
			p[0] = 'I'; 
1990/0912    
			p[1] = gscreen.ldepth; 
			PLONG(p+2, gscreen.r.min.x); 
1990/1012/sys/src/9/port/devbit.c:363,3691990/11211/sys/src/9/port/devbit.c:363,369
1990/0505    
			 *	bitmap id	2 
			 */ 
			if(n < 3) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0505    
			p[0] = 'A'; 
			PSHORT(p+1, bit.lastid); 
			bit.lastid = -1; 
1990/1012/sys/src/9/port/devbit.c:377,3831990/11211/sys/src/9/port/devbit.c:377,383
1990/0623    
			 *	font id		2 
			 */ 
			if(n < 3) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0623    
			p[0] = 'K'; 
			PSHORT(p+1, bit.lastfid); 
			bit.lastfid = -1; 
1990/1012/sys/src/9/port/devbit.c:391,3971990/11211/sys/src/9/port/devbit.c:391,397
1990/0613    
			 */ 
			src = &bit.map[bit.rid]; 
			if(src->ldepth<0) 
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0613    
			off = 0; 
			if(bit.rid == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:398,4041990/11211/sys/src/9/port/devbit.c:398,404
1990/0613    
			miny = bit.rminy; 
			maxy = bit.rmaxy; 
			if(miny>maxy || miny<src->r.min.y || maxy>src->r.max.y) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0613    
			ws = 1<<(3-src->ldepth);	/* pixels per byte */ 
			/* set l to number of bytes of incoming data per scan line */ 
			if(src->r.min.x >= 0) 
1990/1012/sys/src/9/port/devbit.c:409,4151990/11211/sys/src/9/port/devbit.c:409,415
1990/0613    
				l = (t+src->r.max.x+ws-1)/ws; 
			} 
			if(n < l*(maxy-miny)) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0613    
			if(off) 
				cursoroff(1); 
			n = 0; 
1990/1012/sys/src/9/port/devbit.c:426,4371990/11211/sys/src/9/port/devbit.c:426,437
1990/0613    
			bit.rid = -1; 
			break; 
		} 
1990/0505    
		error(0, Ebadblt); 
1990/11211    
		error(Ebadblt); 
1990/0709    
 
	case Qscreen: 
		if(c->offset==0){ 
			if(n < 5*12) 
				error(0, Eio); 
1990/11211    
				error(Eio); 
1990/0709    
			sprint(va, "%11d %11d %11d %11d %11d ", 
1990/0912    
				gscreen.ldepth, gscreen.r.min.x, 
				gscreen.r.min.y, gscreen.r.max.x, 
1990/1012/sys/src/9/port/devbit.c:459,4651990/11211/sys/src/9/port/devbit.c:459,465
1990/0709    
		break; 
1990/0505    
 
	default: 
		error(0, Egreg); 
1990/11211    
		error(Egreg); 
1990/0327    
	} 
 
	return n; 
1990/1012/sys/src/9/port/devbit.c:480,4901990/11211/sys/src/9/port/devbit.c:480,490
1990/0902    
	GBitmap *bp, *src, *dst; 
	GFont *f; 
1990/0324    
 
	if(c->qid == CHDIR) 
		error(0, Eisdir); 
1990/11211    
	if(c->qid.path == CHDIR) 
		error(Eisdir); 
1990/0324    
 
1990/0327    
	if(c->qid != Qbitblt) 
		error(0, Egreg); 
1990/11211    
	if(c->qid.path != Qbitblt) 
		error(Egreg); 
1990/0327    
 
1990/0721    
	isoff = 0; 
	if(waserror()){ 
1990/1012/sys/src/9/port/devbit.c:498,5041990/11211/sys/src/9/port/devbit.c:498,504
1990/0327    
		switch(*p){ 
1990/0329    
		default: 
			pprint("bitblt request 0x%x\n", *p); 
			error(0, Ebadblt); 
1990/11211    
			error(Ebadblt); 
1990/0329    
 
1990/0327    
		case 'a': 
			/* 
1990/1012/sys/src/9/port/devbit.c:509,5211990/11211/sys/src/9/port/devbit.c:509,521
1990/0327    
			 * next read returns allocated bitmap id 
			 */ 
			if(m < 18) 
1990/0324    
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0327    
			v = *(p+1); 
1990/05313    
			if(v!=0 && v!=1)	/* BUG */ 
1990/0327    
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0327    
			ws = 1<<(5-v);	/* pixels per word */ 
			if(bit.free == 0) 
				error(0, Enobitmap); 
1990/11211    
				error(Enobitmap); 
1990/0327    
			rect.min.x = GLONG(p+2); 
			rect.min.y = GLONG(p+6); 
			rect.max.x = GLONG(p+10); 
1990/1012/sys/src/9/port/devbit.c:531,5371990/11211/sys/src/9/port/devbit.c:531,537
1990/05313    
			if(bit.wfree+2+nw > bit.words+bit.nwords){ 
1990/0327    
				bitcompact(); 
1990/05313    
				if(bit.wfree+2+nw > bit.words+bit.nwords) 
1990/0327    
					error(0, Enobitstore); 
1990/11211    
					error(Enobitstore); 
1990/0327    
			} 
			bp = bit.free; 
1990/0902    
			bit.free = (GBitmap*)(bp->base); 
1990/1012/sys/src/9/port/devbit.c:566,5761990/11211/sys/src/9/port/devbit.c:566,576
1990/0327    
			 *	code		2 
			 */ 
			if(m < 31) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0327    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
			if(v<0 || v>=conf.nbitmap || dst->ldepth < 0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0504    
			off = 0; 
			if(v == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:579,5851990/11211/sys/src/9/port/devbit.c:579,585
1990/0327    
			v = GSHORT(p+11); 
			src = &bit.map[v]; 
			if(v<0 || v>=conf.nbitmap || src->ldepth < 0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0504    
			if(v == 0) 
				off = 1; 
1990/0327    
			rect.min.x = GLONG(p+13); 
1990/1012/sys/src/9/port/devbit.c:616,6221990/11211/sys/src/9/port/devbit.c:616,622
1990/05313    
				break; 
			} 
			if(m < 73) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/05313    
			curs.offset.x = GLONG(p+1); 
			curs.offset.y = GLONG(p+5); 
			memcpy(curs.clr, p+9, 2*16); 
1990/1012/sys/src/9/port/devbit.c:637,6471990/11211/sys/src/9/port/devbit.c:637,647
1990/0327    
			 *	id		2 
			 */ 
			if(m < 3) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0327    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0327    
			bitfree(dst); 
			m -= 3; 
			p += 3; 
1990/1012/sys/src/9/port/devbit.c:654,6641990/11211/sys/src/9/port/devbit.c:654,664
1990/0623    
			 *	id		2 
			 */ 
			if(m < 3) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0623    
			v = GSHORT(p+1); 
			f = &bit.font[v]; 
			if(v<0 || v>=conf.nfont || f->bits==0) 
1990/0728    
				error(0, Ebadfont); 
1990/11211    
				error(Ebadfont); 
1990/0623    
			f->bits = 0; 
			m -= 3; 
			p += 3; 
1990/1012/sys/src/9/port/devbit.c:687,7001990/11211/sys/src/9/port/devbit.c:687,700
1990/0623    
			 * next read returns allocated font id 
			 */ 
			if(m < 7) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0623    
			v = GSHORT(p+1); 
			if(v<0 || v>NINFO || m<7+6*(v+1))	/* BUG */ 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0623    
			for(i=1; i<conf.nfont; i++) 
				if(bit.font[i].bits == 0) 
					goto fontfound; 
			error(0, Enofont); 
1990/11211    
			error(Enofont); 
1990/0623    
		fontfound: 
			f = &bit.font[i]; 
			f->n = v; 
1990/1012/sys/src/9/port/devbit.c:703,7091990/11211/sys/src/9/port/devbit.c:703,709
1990/0623    
			v = GSHORT(p+5); 
			dst = &bit.map[v]; 
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0623    
			m -= 7; 
			p += 7; 
			fcp = f->info; 
1990/1012/sys/src/9/port/devbit.c:733,7431990/11211/sys/src/9/port/devbit.c:733,743
1990/06111    
			 *	code		2 
			 */ 
			if(m < 22) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/06111    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
1990/06111    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/06111    
			off = 0; 
			if(v == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:767,7771990/11211/sys/src/9/port/devbit.c:767,777
1990/0722    
			 *	code		2 
			 */ 
			if(m < 14) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0722    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0722    
			off = 0; 
			if(v == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:797,8111990/11211/sys/src/9/port/devbit.c:797,811
1990/0613    
			 *	maxy		4 
			 */ 
			if(m < 11) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0613    
			v = GSHORT(p+1); 
			src = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || src->ldepth<0) 
1990/0613    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0613    
			miny = GLONG(p+3); 
			maxy = GLONG(p+7); 
			if(miny>maxy || miny<src->r.min.y || maxy>src->r.max.y) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0613    
			bit.rid = v; 
			bit.rminy = miny; 
			bit.rmaxy = maxy; 
1990/1012/sys/src/9/port/devbit.c:824,8341990/11211/sys/src/9/port/devbit.c:824,834
1990/0329    
			 * 	string		n (null terminated) 
			 */ 
			if(m < 16) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0329    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0504    
			off = 0; 
			if(v == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:837,8491990/11211/sys/src/9/port/devbit.c:837,849
1990/0329    
			v = GSHORT(p+11); 
1990/0623    
			f = &bit.font[v]; 
			if(v<0 || v>=conf.nfont || f->bits==0 || f->bits->ldepth<0) 
1990/0329    
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0329    
			v = GSHORT(p+13); 
			p += 15; 
			m -= 15; 
			q = memchr(p, 0, m); 
			if(q == 0) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0721    
			if(off && !isoff){ 
1990/0504    
				cursoroff(1); 
1990/0721    
				isoff = 1; 
1990/1012/sys/src/9/port/devbit.c:864,8741990/11211/sys/src/9/port/devbit.c:864,874
1990/0329    
			 *	fcode		2 
			 */ 
			if(m < 23) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0329    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0504    
			off = 0; 
			if(v == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:879,8851990/11211/sys/src/9/port/devbit.c:879,885
1990/0329    
			v = GSHORT(p+19); 
			src = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || src->ldepth<0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0329    
			v = GSHORT(p+21); 
1990/1011    
			x = src->r.min.x; 
			y = src->r.min.y; 
1990/1012/sys/src/9/port/devbit.c:955,9651990/11211/sys/src/9/port/devbit.c:955,965
1990/0329    
			 *	data		bytewidth*(maxy-miny) 
			 */ 
			if(m < 11) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0329    
			v = GSHORT(p+1); 
			dst = &bit.map[v]; 
1990/0623    
			if(v<0 || v>=conf.nbitmap || dst->ldepth<0) 
1990/0329    
				error(0, Ebadbitmap); 
1990/11211    
				error(Ebadbitmap); 
1990/0504    
			off = 0; 
			if(v == 0) 
				off = 1; 
1990/1012/sys/src/9/port/devbit.c:966,9721990/11211/sys/src/9/port/devbit.c:966,972
1990/0329    
			miny = GLONG(p+3); 
			maxy = GLONG(p+7); 
1990/03291    
			if(miny>maxy || miny<dst->r.min.y || maxy>dst->r.max.y) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0329    
			ws = 1<<(3-dst->ldepth);	/* pixels per byte */ 
			/* set l to number of bytes of incoming data per scan line */ 
			if(dst->r.min.x >= 0) 
1990/1012/sys/src/9/port/devbit.c:979,9851990/11211/sys/src/9/port/devbit.c:979,985
1990/0329    
			p += 11; 
			m -= 11; 
			if(m < l*(maxy-miny)) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0721    
			if(off && !isoff){ 
1990/0504    
				cursoroff(1); 
1990/0721    
				isoff = 1; 
1990/1012/sys/src/9/port/devbit.c:1001,10071990/11211/sys/src/9/port/devbit.c:1001,1007
1990/0826    
			 *	pt		8 
			 */ 
			if(m < 9) 
				error(0, Ebadblt); 
1990/11211    
				error(Ebadblt); 
1990/0826    
			pt1.x = GLONG(p+1); 
			pt1.y = GLONG(p+5); 
			mouse.xy = pt1; 
1990/1012/sys/src/9/port/devbit.c:1018,10351990/11211/sys/src/9/port/devbit.c:1018,1023
1990/0324    
} 
 
void 
bituserstr(Error *e, char *buf) 
{ 
	consuserstr(e, buf); 
} 
                 
void 
biterrstr(Error *e, char *buf) 
{ 
	rooterrstr(e, buf); 
1990/0327    
} 
                 
void 
1990/0902    
bitfree(GBitmap *bp) 
1990/0327    
{ 
1990/05313    
	bp->base[-1] = 0; 
1990/1012/sys/src/9/port/devbit.c:1046,10521990/11211/sys/src/9/port/devbit.c:1034,1040
1990/0902    
	GBitmap *bp; 
1990/08101    
	bp = &bit.map[k]; 
	if(k<0 || k>=conf.nbitmap || bp->ldepth < 0) 
		error(0, Ebadbitmap); 
1990/11211    
		error(Ebadbitmap); 
1990/08101    
	return bp; 
} 
 


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