~kris/9p

9hist

b357cee460ab3ee389bb298a68a459a66c80a8c9 — David du Colombier 24 years ago 4a421ab
Plan 9 from Bell Labs 2001-11-30
M bitsy/devpenmouse.c => bitsy/devpenmouse.c +11 -10
@@ 123,6 123,7 @@ penbutton(int up, int b) {

void
pentrackxy(int x, int y) {

	if (x == -1) {
		/* pen up. associate with button 1 through 5 up */
		mouse.buttons &= ~0x1f;


@@ 339,8 340,8 @@ penmousewrite(Chan *c, void *va, long n, vlong)
	Point pt;
	Cmdbuf *cb;
	Cmdtab *ct;
	char buf[64], *field[5];
	int nf, b;
	char buf[64];
	int b;

	p = va;
	switch((ulong)c->qid.path){


@@ 369,15 370,15 @@ penmousewrite(Chan *c, void *va, long n, vlong)
				calibration.transx = 0;
				calibration.transy = 0;
			} else if (cb->nf == 5) {
				if ((!isdigit(*field[1]) && *field[1] != '-')
				 || (!isdigit(*field[2]) && *field[2] != '-')
				 || (!isdigit(*field[3]) && *field[3] != '-')
				 || (!isdigit(*field[4]) && *field[4] != '-'))
				if ((!isdigit(*cb->f[1]) && *cb->f[1] != '-')
				 || (!isdigit(*cb->f[2]) && *cb->f[2] != '-')
				 || (!isdigit(*cb->f[3]) && *cb->f[3] != '-')
				 || (!isdigit(*cb->f[4]) && *cb->f[4] != '-'))
					error("bad syntax in control file message");
				calibration.scalex = strtol(field[1], nil, 0);
				calibration.scaley = strtol(field[2], nil, 0);
				calibration.transx = strtol(field[3], nil, 0);
				calibration.transy = strtol(field[4], nil, 0);
				calibration.scalex = strtol(cb->f[1], nil, 0);
				calibration.scaley = strtol(cb->f[2], nil, 0);
				calibration.transx = strtol(cb->f[3], nil, 0);
				calibration.transy = strtol(cb->f[4], nil, 0);
			} else
				cmderror(cb, Ecmdargs);
			break;

M bitsy/devµc.c => bitsy/devµc.c +8 -2
@@ 88,6 88,8 @@ Rune bmap[4] =
	Kup, Kright, Kleft, Kdown
};

extern int landscape;

int
µcputc(Queue*, int ch)
{


@@ 162,8 164,12 @@ int
				break;
			touching = 1;
			if(len == 4) {
				if (samseq++ > 10)
					pentrackxy((p[2]<<8)|p[3], (p[0]<<8)|p[1]);
				if (samseq++ > 10){
					if (landscape)
						pentrackxy((p[0]<<8)|p[1], (p[2]<<8)|p[3]);
					else
						pentrackxy((p[2]<<8)|p[3], (p[0]<<8)|p[1]);
				}
			} else {
				samseq = 0;
				pentrackxy(-1, -1);

M bitsy/screen.c => bitsy/screen.c +20 -11
@@ 16,7 16,7 @@

#define	MINX	8

int landscape = 0;	/* orientation of the screen, default is 0: portait */
int landscape = 1;	/* orientation of the screen, default is 0: portait */

enum {
	Wid		= 240,


@@ 116,17 116,17 @@ static Memdata xgdata;

static Memimage xgscreen =
{
	{ 0, 0, Wid, Ht },	/* r */
	{ 0, 0, Wid, Ht },	/* clipr */
	16,					/* depth */
	3,					/* nchan */
	RGB16,				/* chan */
	{ 0, 0, Wid, Ht },		/* r */
	{ 0, 0, Wid, Ht },		/* clipr */
	16,				/* depth */
	3,				/* nchan */
	RGB16,			/* chan */
	nil,				/* cmap */
	&xgdata,			/* data */
	0,					/* zero */
	Wid/2,				/* width */
	0,					/* layer */
	0,					/* flags */
	0,				/* zero */
	Wid/2,			/* width */
	0,				/* layer */
	0,				/* flags */
};

struct{


@@ 180,10 180,12 @@ flipscreen(int ls) {
	if (ls) {
		gscreen->r = Rect(0, 0, Ht, Wid);
		gscreen->clipr = gscreen->r;
		gscreen->width = Ht/2;
		xgdata.bdata = (uchar *)framebuf->pixel;
	} else {
		gscreen->r = Rect(0, 0, Wid, Ht);
		gscreen->clipr = gscreen->r;
		gscreen->width = Wid/2;
		xgdata.bdata = (uchar *)vscreen;
	}
	landscape = ls;


@@ 228,14 230,21 @@ screeninit(void)
	lcdinit();

	gscreen = &xgscreen;

	xgdata.ref = 1;
	i = 0;
	if (landscape) {
		gscreen->r = Rect(0, 0, Ht, Wid);
		gscreen->clipr = gscreen->r;
		gscreen->width = Ht/2;
		xgdata.bdata = (uchar *)framebuf->pixel;
		while (i < Wid*Ht*1/3)	framebuf->pixel[i++] = 0xf800;	/* red */
		while (i < Wid*Ht*2/3)	framebuf->pixel[i++] = 0xffff;	/* white */
		while (i < Wid*Ht*2/3)	framebuf->pixel[i++] = 0xffff;		/* white */
		while (i < Wid*Ht*3/3)	framebuf->pixel[i++] = 0x001f;	/* blue */
	} else {
		gscreen->r = Rect(0, 0, Wid, Ht);
		gscreen->clipr = gscreen->r;
		gscreen->width = Wid/2;
		xgdata.bdata = (uchar *)vscreen;
		while (i < Wid*Ht*1/3)	vscreen[i++] = 0xf800;	/* red */
		while (i < Wid*Ht*2/3)	vscreen[i++] = 0xffff;	/* white */

M boot/bootauth.c => boot/bootauth.c +0 -3
@@ 12,9 12,6 @@ authentication(int cpuflag)
	char *argv[16], **av;
	int ac;

	/* make capabilities available to factotum */
	bind("#¤", "/dev", MAFTER);

	/* start agent */
	ac = 0;
	av = argv;

M pc/apic.c => pc/apic.c +1 -1
@@ 134,7 134,7 @@ lapictimerinit(void)
		wrmsr(0x10, 0);

		do{
			rdmsr(0x10, &tsc);
			rdtsc(&tsc);
			lo = (ulong)tsc;
		}while(lo < v);


M pc/devarch.c => pc/devarch.c +1 -1
@@ 746,7 746,7 @@ cycletimer(uvlong *hz)

	if(hz != nil)
		*hz = fasthz;
	rdmsr(0x10, (vlong*)&tsc);
	rdtsc((vlong*)&tsc);
	m->fastclock = tsc;
	return tsc;
}

M pc/devether.c => pc/devether.c +4 -3
@@ 386,10 386,11 @@ etherreset(void)
				ether->irq = 9;
			snprint(name, sizeof(name), "ether%d", ctlrno);

			/* If ether->irq is less than 0, it is a hack to indicate no interrupt
			 * used for the second logical ethernet for the wavelan card
			/*
			 * If ether->irq is 0, it is a hack to indicate no interrupt
			 * used by ethersink.
			 */
			if(ether->irq >= 0)
			if(ether->irq > 0)
				intrenable(ether->irq, ether->interrupt, ether, ether->tbdf, name);

			i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %lud",

M pc/devusb.c => pc/devusb.c +6 -1
@@ 1149,7 1149,7 @@ cleaniso(Endpt *e, int frnum)
			if ((td->flags & IsoClean) == 0){
				e->buffered -= n;
				if (e->buffered < 0){
					iprint("e->buffered %d?\n", e->buffered);
					print("e->buffered %d?\n", e->buffered);
					e->buffered = 0;
				}
			}


@@ 1682,6 1682,10 @@ usbclose(Chan *c)
	if(c->qid.type == QTDIR || QID(c->qid) < Q3rd)
		return;
	qlock(&usbstate);
	if(waserror()){
		qunlock(&usbstate);
		return;
	}
	d = usbdevice(c);
	if(QID(c->qid) == Qctl)
		d->busy = 0;


@@ 1689,6 1693,7 @@ usbclose(Chan *c)
		XPRINT("usbclose: freedev 0x%p\n", d);
		freedev(d);
	}
	poperror();
	qunlock(&usbstate);
}


M pc/fns.h => pc/fns.h +1 -0
@@ 120,6 120,7 @@ void	procsetup(Proc*);
void	putcr3(ulong);
void	putcr4(ulong);
void	rdmsr(int, vlong*);
void	rdtsc(vlong*);
void	screeninit(void);
int	screenprint(char*, ...);			/* debugging */
void	(*screenputs)(char*, int);

M pc/i8253.c => pc/i8253.c +2 -2
@@ 120,13 120,13 @@ i8253init(int aalcycles, int havecycleclock)
		 */
		outb(Tmode, Latch0);
		if(havecycleclock)
			rdmsr(0x10, &a);
			rdtsc(&a);
		x = inb(T0cntr);
		x |= inb(T0cntr)<<8;
		aamloop(loops);
		outb(Tmode, Latch0);
		if(havecycleclock)
			rdmsr(0x10, &b);
			rdtsc(&b);
		y = inb(T0cntr);
		y |= inb(T0cntr)<<8;
		x -= y;

M pc/l.s => pc/l.s +9 -1
@@ 11,6 11,7 @@
#define CPUID		BYTE $0x0F; BYTE $0xA2	/* CPUID, argument in AX */
#define WRMSR		BYTE $0x0F; BYTE $0x30	/* WRMSR, argument in AX/DX (lo/hi) */
#define RDMSR		BYTE $0x0F; BYTE $0x32	/* RDMSR, result in AX/DX (lo/hi) */
#define RDTSC 		BYTE $0x0F; BYTE $0x31
#define WBINVD		BYTE $0x0F; BYTE $0x09
#define HLT		BYTE $0xF4



@@ 283,11 284,18 @@ TEXT putcr4(SB), $0
	MOVL	AX, CR4
	RET

TEXT rdtsc(SB), $0				/* time stamp counter; cycles since power up */
	RDTSC
	MOVL	vlong+0(FP), CX			/* &vlong */
	MOVL	AX, 0(CX)			/* lo */
	MOVL	DX, 4(CX)			/* hi */
	RET

TEXT rdmsr(SB), $0				/* model-specific register */
	MOVL	index+0(FP), CX
	RDMSR
	MOVL	vlong+4(FP), CX			/* &vlong */
	MOVL	AX, (CX)			/* lo */
	MOVL	AX, 0(CX)			/* lo */
	MOVL	DX, 4(CX)			/* hi */
	RET
	

M pc/screen.c => pc/screen.c +6 -2
@@ 378,6 378,10 @@ blankscreen(int blank)
	VGAscr *scr;

	scr = &vgascreen[0];
	if(hwblank && scr->blank)
		scr->blank(scr, blank);
	if(hwblank){
		if(scr->blank)
			scr->blank(scr, blank);
		else
			vgablank(scr, blank);
	}
}

M pc/trap.c => pc/trap.c +6 -0
@@ 21,6 21,12 @@ intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
	int vno;
	Vctl *v;

	if(f == nil){
		print("intrenable: nil handler for %d, tbdf 0x%uX for %s\n",
			irq, tbdf, name);
		return;
	}

	v = xalloc(sizeof(Vctl));
	v->isintr = 1;
	v->irq = irq;

M pc/vgasavage.c => pc/vgasavage.c +14 -2
@@ 371,8 371,8 @@ savagewaitidle(VGAscr *scr)
	/* case SAVAGEMX: ? */
	/* case SAVAGEIX: ? */
	case SUPERSAVAGEIXC16:
	case SAVAGEMXMV:
	case SAVAGEIXMV:
	case SAVAGEMXMV:
		/* wait for engine idle and FIFO empty */
		statw = (ulong*)((uchar*)scr->mmio+XStatus0);
		mask = CBEMaskA | Ge2IdleA;


@@ 461,12 461,23 @@ savageblank(VGAscr*, int blank)
{
	uchar seqD;

	/*
	 * Will handle DPMS to monitor
	 */
	vgaxo(Seqx, 8, vgaxi(Seqx,8)|0x06);
	seqD = vgaxi(Seqx, 0xD);
	seqD &= 0x03;
	if(blank)
		seqD |= 0x50;
	vgaxo(Seqx, 0xD, seqD);

	/*
	 * Will handle LCD
	 */
	if(blank)
		vgaxo(Seqx, 0x31, vgaxi(Seqx, 0x31) & ~0x10);
	else
		vgaxo(Seqx, 0x31, vgaxi(Seqx, 0x31) | 0x10);
}




@@ 479,9 490,9 @@ savageinit(VGAscr *scr)
	/* if you add chip IDs here be sure to update savagewaitidle */
	switch(scr->id){
	case SAVAGE4:
	case SAVAGEMXMV:
	case SAVAGEIXMV:
	case SUPERSAVAGEIXC16:
	case SAVAGEMXMV:
		break;
	default:
		print("unknown savage %.4lux\n", scr->id);


@@ 547,5 558,6 @@ savageinit(VGAscr *scr)
	scr->fill = savagefill;
	scr->scroll = savagescroll;
	scr->blank = savageblank;
	hwblank = 1;
}


M port/chan.c => port/chan.c +2 -2
@@ 353,8 353,8 @@ cclose(Chan *c)
		return;

	if(waserror()){
//		print("cclose error: type %C; error %s\n", devtab[c->type]->dc, up!=nil? up->errstr : "no user");
		chanfree(c);
		print("cclose error: type %C; error %s\n", devtab[c->type]->dc, up!=nil? up->errstr : "no user");
		/* don't chanfree: better leak than leave a dangling pointer */
		return;
	}