~kris/9p

9hist

170d92cabb9c33af04d0200e02822e8ecff98ee6 — David du Colombier 36 years ago 1df06c3
Plan 9 from Bell Labs 1990-09-12
6 files changed, 104 insertions(+), 75 deletions(-)

M gnot/screen.c
M port/devbit.c
M port/devcons.c
M port/devlance.c
M power/dat.h
M power/main.c
M gnot/screen.c => gnot/screen.c +11 -10
@@ 7,6 7,7 @@
#include	"ureg.h"
#include	"errno.h"

#include	<libg.h>
#include	<gnot.h>

#define	MINX	8


@@ 24,7 25,7 @@ void	duartinit(void);
int	duartacr;
int	duartimr;

GBitmap	screen =
GBitmap	gscreen =
{
	(ulong*)((4*1024*1024-256*1024)|KZERO),	/* BUG */
	0,


@@ 42,11 43,11 @@ screeninit(void)
	 * Read HEX switch to set ldepth
	 */
	if(*(uchar*)MOUSE & (1<<4)){
		screen.ldepth = 1;
		gscreen.ldepth = 1;
		defont = &defont1;
	}else
		defont = &defont0;
	gbitblt(&screen, Pt(0, 0), &screen, screen.r, 0);
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0);
	out.pos.x = MINX;
	out.pos.y = 0;
	out.bwid = defont0.info[' '].width;


@@ 61,13 62,13 @@ screenputc(int c)
	if(c == '\n'){
		out.pos.x = MINX;
		out.pos.y += defont0.height;
		if(out.pos.y > screen.r.max.y-defont0.height)
			out.pos.y = screen.r.min.y;
		gbitblt(&screen, Pt(0, out.pos.y), &screen,
		    Rect(0, out.pos.y, screen.r.max.x, out.pos.y+2*defont0.height), 0);
		if(out.pos.y > gscreen.r.max.y-defont0.height)
			out.pos.y = gscreen.r.min.y;
		gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
		    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
	}else if(c == '\t'){
		out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
		if(out.pos.x >= screen.r.max.x)
		if(out.pos.x >= gscreen.r.max.x)
			screenputc('\n');
	}else if(c == '\b'){
		if(out.pos.x >= out.bwid+MINX){


@@ 76,11 77,11 @@ screenputc(int c)
			out.pos.x -= out.bwid;
		}
	}else{
		if(out.pos.x >= screen.r.max.x-out.bwid)
		if(out.pos.x >= gscreen.r.max.x-out.bwid)
			screenputc('\n');
		buf[0] = c&0x7F;
		buf[1] = 0;
		out.pos = gstring(&screen, out.pos, defont, buf, S);
		out.pos = gstring(&gscreen, out.pos, defont, buf, S);
	}
}


M port/devbit.c => port/devbit.c +33 -32
@@ 7,6 7,7 @@

#include	"devtab.h"

#include	<libg.h>
#include	<gnot.h>

extern GFont	*defont;


@@ 44,7 45,7 @@ struct
#define	FREE	0x80000000
void	bitcompact(void);
void	bitfree(GBitmap*);
extern	GBitmap	screen;
extern	GBitmap	gscreen;

struct{
	/*


@@ 145,7 146,7 @@ bitreset(void)
	}
	bp--;
	bp->base = 0;
	bit.map[0] = screen;	/* bitmap 0 is screen */
	bit.map[0] = gscreen;	/* bitmap 0 is screen */
	bit.free = bit.map+1;
	bit.lastid = -1;
	bit.lastfid = -1;


@@ 164,9 165,9 @@ bitinit(void)
{
	lock(&bit);
	unlock(&bit);
	if(screen.ldepth > 1)
	if(gscreen.ldepth > 1)
		panic("bitinit ldepth>1");
	cursorback.ldepth = screen.ldepth;
	cursorback.ldepth = gscreen.ldepth;
	cursoron(1);
}



@@ 332,11 333,11 @@ bitread(Chan *c, void *va, long n)
			if(n < 18)
				error(0, Ebadblt);
			p[0] = 'I';
			p[1] = screen.ldepth;
			PLONG(p+2, screen.r.min.x);
			PLONG(p+6, screen.r.min.y);
			PLONG(p+10, screen.r.max.x);
			PLONG(p+14, screen.r.max.y);
			p[1] = gscreen.ldepth;
			PLONG(p+2, gscreen.r.min.x);
			PLONG(p+6, gscreen.r.min.y);
			PLONG(p+10, gscreen.r.max.x);
			PLONG(p+14, gscreen.r.max.y);
			if(n >= 18+3*12+6*(defont->n+1)){
				p += 18;
				sprint((char*)p, "%11d %11d %11d ", defont->n,


@@ 414,7 415,7 @@ bitread(Chan *c, void *va, long n)
			n = 0;
			p = va;
			for(y=miny; y<maxy; y++){
				q = (uchar*)addr(src, Pt(src->r.min.x, y));
				q = (uchar*)gaddr(src, Pt(src->r.min.x, y));
				q += (src->r.min.x&((sizeof(ulong))*ws-1))/ws;
				for(x=0; x<l; x++)
					*p++ = K2U(*q++);


@@ 432,25 433,25 @@ bitread(Chan *c, void *va, long n)
			if(n < 5*12)
				error(0, Eio);
			sprint(va, "%11d %11d %11d %11d %11d ",
				screen.ldepth, screen.r.min.x,
				screen.r.min.y, screen.r.max.x,
				screen.r.max.y);
				gscreen.ldepth, gscreen.r.min.x,
				gscreen.r.min.y, gscreen.r.max.x,
				gscreen.r.max.y);
			n = 5*12;
			break;
		}
		ws = 1<<(3-screen.ldepth);	/* pixels per byte */
		l = (screen.r.max.x+ws-1)/ws - screen.r.min.x/ws;
		ws = 1<<(3-gscreen.ldepth);	/* pixels per byte */
		l = (gscreen.r.max.x+ws-1)/ws - gscreen.r.min.x/ws;
		t = c->offset-5*12;
		miny = t/l;
		maxy = (t+n)/l;
		if(miny >= screen.r.max.y)
		if(miny >= gscreen.r.max.y)
			return 0;
		if(maxy >= screen.r.max.y)
			maxy = screen.r.max.y;
		if(maxy >= gscreen.r.max.y)
			maxy = gscreen.r.max.y;
		n = 0;
		p = va;
		for(y=miny; y<maxy; y++){
			q = (uchar*)addr(&screen, Pt(0, y));
			q = (uchar*)gaddr(&gscreen, Pt(0, y));
			for(x=0; x<l; x++)
				*p++ = K2U(*q++);
			n += l;


@@ 938,7 939,7 @@ bitwrite(Chan *c, void *va, long n)
				isoff = 1;
			}
			for(y=miny; y<maxy; y++){
				q = (uchar*)addr(dst, Pt(dst->r.min.x, y));
				q = (uchar*)gaddr(dst, Pt(dst->r.min.x, y));
				q += (dst->r.min.x&((sizeof(ulong))*ws-1))/ws;
				for(x=0; x<l; x++)
					*q++ = U2K(*p++);


@@ 1049,10 1050,10 @@ cursoron(int dolock)
		cursor.r.min = mouse.xy;
		cursor.r.max = add(mouse.xy, Pt(16, 16));
		cursor.r = raddp(cursor.r, cursor.offset);
		gbitblt(&cursorback, Pt(0, 0), &screen, cursor.r, S);
		gbitblt(&screen, add(mouse.xy, cursor.offset),
		gbitblt(&cursorback, Pt(0, 0), &gscreen, cursor.r, S);
		gbitblt(&gscreen, add(mouse.xy, cursor.offset),
			&clr, Rect(0, 0, 16, 16), D&~S);
		gbitblt(&screen, add(mouse.xy, cursor.offset),
		gbitblt(&gscreen, add(mouse.xy, cursor.offset),
			&set, Rect(0, 0, 16, 16), S|D);
	}
	if(dolock)


@@ 1065,7 1066,7 @@ cursoroff(int dolock)
	if(dolock)
		lock(&cursor);
	if(--cursor.visible == 0)
		gbitblt(&screen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S);
		gbitblt(&gscreen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S);
	if(dolock)
		unlock(&cursor);
}


@@ 1089,15 1090,15 @@ mouseclock(void)	/* called spl6 */
	int x, y;
	if(mouse.track && canlock(&cursor)){
		x = mouse.xy.x + mouse.dx;
		if(x < screen.r.min.x)
			x = screen.r.min.x;
		if(x >= screen.r.max.x)
			x = screen.r.max.x;
		if(x < gscreen.r.min.x)
			x = gscreen.r.min.x;
		if(x >= gscreen.r.max.x)
			x = gscreen.r.max.x;
		y = mouse.xy.y + mouse.dy;
		if(y < screen.r.min.y)
			y = screen.r.min.y;
		if(y >= screen.r.max.y)
			y = screen.r.max.y;
		if(y < gscreen.r.min.y)
			y = gscreen.r.min.y;
		if(y >= gscreen.r.max.y)
			y = gscreen.r.max.y;
		cursoroff(0);
		mouse.xy = Pt(x, y);
		cursoron(0);

M port/devcons.c => port/devcons.c +40 -15
@@ 303,7 303,7 @@ enum{
Dirtab consdir[]={
	"cons",		Qcons,		0,	0600,
	"cputime",	Qcputime,	72,	0600,
	"log",		Qlog,		sizeof(SYSLOG->buf),	0600,
	"log",		Qlog,		BY2PG-8,	0600,
	"null",		Qnull,		0,	0600,
	"pgrpid",	Qpgrpid,	12,	0600,
	"pid",		Qpid,		12,	0600,


@@ 596,8 596,19 @@ consuserstr(Error *e, char *buf)
}

/*
 *  crash info
 *  kernel based system log, passed between crashes
 */
#define SYSLOGMAGIC	0x23456789
#define SYSLOG		((Syslog *)(UNCACHED | KZERO | 0x1B00))
typedef struct Syslog	Syslog;
struct Syslog
{
	ulong	magic;
	char	*start;
	char	*next;
	char	buf[BY2PG - 3*BY2WD];
};

void
sysloginit(void)
{


@@ 606,7 617,8 @@ sysloginit(void)

	s = SYSLOG;
	if(s->magic!=SYSLOGMAGIC || s->next>=&s->buf[sizeof(s->buf)]
	|| s->next<s->buf){
	|| s->start>=&s->buf[sizeof(s->buf)] || s->next<s->buf){
		s->start = s->buf;
		s->next = s->buf;
		s->magic = SYSLOGMAGIC;
	}


@@ 615,26 627,35 @@ sysloginit(void)
void
syslog(char *p, int n)
{
	int i;
	int restart;
	Syslog *s;
	char *end;

	s = SYSLOG;
	end = &s->buf[sizeof(s->buf)];
	restart = 0;
	while(n-- > 0){
		*s->next++ = *p++;
		if(s->next >= end)
			s->next = s->buf;
		if(s->next == s->start)
			restart = 1;
	}
	if(restart){
		s->start = s->next + 1;
		if(s->start >= end)
			s->start = s->buf;
	}
	wbflush();
}

long
readlog(ulong off, char *buf, ulong n)
{
	Syslog *s;
	int i;
	char *p;
	char *end;
	char *a = buf;

	s = SYSLOG;



@@ 642,20 663,24 @@ readlog(ulong off, char *buf, ulong n)
	if(off >= sizeof(s->buf))
		return 0;

	/* trim length */
	if(off + n >= sizeof(s->buf))
		n = sizeof(s->buf) - off;

	/* point to start of area to be read */
	end = &s->buf[sizeof(s->buf)];
	p = s->next + off;
	if(p > end)
		p -= sizeof(s->buf);
	p = s->start;

	/* skip offset */
	while(off-- > 0){
		if(p == s->next)
			return 0;
		p++;
	}

	for(i = 0; i < n; i++){
		*buf++ = *p++;
	/* copy out */
	while(n-- > 0){
		if(p == s->next)
			break;
		*a++ = *p++;
		if(p >= end)
			p = s->buf;
	}
	return n;
	return a-buf;
}

M port/devlance.c => port/devlance.c +3 -0
@@ 467,6 467,9 @@ lancereset(void)
				l.rpa[i] = (uchar *)&l.lm->rp[i];
			for(i = 0; i < Ntrb; i++)
				l.tpa[i] = (uchar *)&l.lm->tp[i];

			l.rp = ((Lancemem *)LANCERAM)->rp;
			l.tp = ((Lancemem *)LANCERAM)->tp;
		} else {
			/*
			 *  toggle lance's reset line

M power/dat.h => power/dat.h +0 -12
@@ 37,7 37,6 @@ typedef struct Seg	Seg;
typedef struct Stream	Stream;
typedef struct Ureg	Ureg;
typedef struct User	User;
typedef struct Syslog	Syslog;

typedef int Devgen(Chan*, Dirtab*, int, int, Dir*);



@@ 697,14 696,3 @@ extern	Dev	devtab[];
extern	char	devchar[];
extern	FPsave	initfp;

/*
 *  kernel based system log, passed between crashes
 */
#define SYSLOG		((Syslog *)(0xa0001B00))
#define SYSLOGMAGIC	0x87654321
struct Syslog
{
	ulong	magic;
	char	*next;
	char	buf[8*1024];
};

M power/main.c => power/main.c +17 -6
@@ 47,6 47,7 @@ main(void)
	active.machs = 1;
	confinit();
	arginit();
	sysloginit();
	lockinit();
	printinit();
	tlbinit();


@@ 59,7 60,6 @@ main(void)
	ioboardinit();
	chandevreset();
	streaminit();
	sysloginit();
	pageinit();
	userinit();
	launchinit();


@@ 112,12 112,16 @@ ioboardinit(void)
{
	long i;
	int noforce;
	int maxlevel;

	ioid = *IOID;
	if(ioid >= IO3R1)
	if(ioid >= IO3R1){
		maxlevel = 11;
		noforce = 1;
	else
	} else {
		maxlevel = 8;
		noforce = 0;
	}


	/*


@@ 138,7 142,7 @@ ioboardinit(void)
	/*
	 *  tell IO2 to sent all interrupts to CPU 0's SBCC
	 */
	for(i=0; i<8; i++)
	for(i=0; i<maxlevel; i++)
		INTVECREG->i[i].vec = 0<<8;

	/*


@@ 302,11 306,18 @@ void
launch(int n)
{
	Beef *p;
	long i;
	long i, s;
	ulong *ptr;

	p = (Beef*) 0xb0000500 + n;
	p->launch = newstart;
	p->sum -= (long)newstart;
	p->sum = 0;
	s = 0;
	ptr = (ulong*)p;
	for (i = 0; i < sizeof(Beef)/sizeof(ulong); i++)
		s += *ptr++;
	p->sum = -(s+1);

	for(i=0; i<3000000; i++)
		if(p->launch == 0)
			break;