~kris/9p

9hist

345fba81e1340ee618b63e59865eb9defc7fe1eb — David du Colombier 34 years ago 0cce6ce
Plan 9 from Bell Labs 1992-09-04
12 files changed, 207 insertions(+), 143 deletions(-)

M pc/dat.h
M pc/devconfig.c
M pc/fns.h
M pc/io.h
M pc/kbd.c
M pc/main.c
M port/stil.c
M ss/fns.h
M ss/io.h
M ss/l.s
M ss/main.c
M ss/screen.c
M pc/dat.h => pc/dat.h +0 -23
@@ 186,26 186,3 @@ extern int	flipD[];	/* for flipping bitblt destination polarity */
 *  bootline passed by boot program
 */
#define BOOTLINE ((char *)0x80000100)

/*
 *  configuration info
 */
enum
{
	/* what kind of power management */
	PMUother=	0,
	PMUnsx20=	1,

	/* what kind of mouse */
	Mouseother=	0,
	Mouseserial=	1,
	MousePS2=	2,

	/* how to reset the processor */
	Resetother=	0,
	Reset8042=	1,
	Resetheadland=	2,
};
extern int mousetype;
extern int pmutype;
extern int resettype;

M pc/devconfig.c => pc/devconfig.c +6 -0
@@ 194,6 194,12 @@ configwrite(Chan *c, void *buf, long n, ulong offset)
			mouseaccelerate(1);
		else if(strncmp("linear", cbuf, 6) == 0)
			mouseaccelerate(0);
		else if(strncmp("serial", cbuf, 6) == 0)
			mouseserial(atoi(cbuf+6));
		else if(strncmp("ps2", cbuf, 3) == 0)
			mouseps2();
		else if(strncmp("resolution", cbuf, 10) == 0)
			mouseres(atoi(cbuf+10));
		return n;
	}
	error(Eperm);

M pc/fns.h => pc/fns.h +4 -0
@@ 37,7 37,11 @@ void	ksetpcinfo(void);
void	mathinit(void);
void	mmuinit(void);
int	modem(int);
void	mouseserial(int);
void	mouseps2(void);
void	mouseaccelerate(int);
void	mouseres(int);
void	mousespeed(int);
void	outb(int, int);
void	outss(int, void*, int);
void	pmubuzz(int, int);

M pc/io.h => pc/io.h +5 -5
@@ 14,13 14,13 @@ enum
	 Kbdvec=	Int0vec+1,	/*  keyboard interrupts */
	 Uart1vec=	Int0vec+3,	/*  modem line */
	 Uart0vec=	Int0vec+4,	/*  serial line */
	 Ethervec=	Int0vec+5,	/*  ethernet interrupt */
	 Floppyvec=	Int0vec+6,	/*  floppy interrupts */
	 Parallelvec=	Int0vec+7,	/*  parallel port interrupts */
	Int1vec=	Int0vec+8,	/* second 8259 */
	 Mousevec=	Int1vec+4,	/*  mouse interrupt */
	 Matherr2vec=	Int1vec+5,	/*  math coprocessor */
	 Hardvec=	Int1vec+6,	/*  hard disk */
	Int1vec=	Int0vec+8,
	 Ethervec=	Int0vec+10,	/*  ethernet interrupt */
	 Mousevec=	Int0vec+12,	/*  mouse interrupt */
	 Matherr2vec=	Int0vec+13,	/*  math coprocessor */
	 Hardvec=	Int0vec+14,	/*  hard disk */

	Syscallvec=	64,
};

M pc/kbd.c => pc/kbd.c +69 -40
@@ 112,6 112,14 @@ static int keybuttons;
 */
static void	kbdintr(Ureg*);

enum
{
	/* what kind of mouse */
	Mouseother=	0,
	Mouseserial=	1,
	MousePS2=	2,
};
static int mousetype;

/*
 *  wait for output no longer busy


@@ 207,46 215,52 @@ kbdinit(void)
		if(c & Inready)
			inb(Data);

	switch(mousetype){
	case MousePS2:
		bigcursor();
		setvec(Mousevec, kbdintr);

		/* enable kbd/mouse xfers and interrupts */
		outb(Cmd, 0x60);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Data, 0x47);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Cmd, 0xA8);
	
		/* make mouse streaming, enabled */
		if(mousecmd(0xEA) < 0
		|| mousecmd(0xF4) < 0)
			print("can't initialize mouse\n");

		/* turn on mouse acceleration */
		mouseaccelerate(0);
		break;
	case Mouseserial:
		/* enable kbd xfers and interrupts */
		outb(Cmd, 0x60);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Data, 0x65);

		/* set up /dev/eia0 as the mouse */
		uartspecial(0, 0, &mouseq, 1200);
		break;
	case Mouseother:
		/* enable kbd xfers and interrupts */
		outb(Cmd, 0x60);
		if(outready() < 0)
			print("kbd init failed\n");
		outb(Data, 0x65);
		break;
	}
	/* enable kbd xfers and interrupts */
	outb(Cmd, 0x60);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Data, 0x65);
}

/*
 *  setup a serial mouse
 */
void
mouseserial(int port)
{
	if(mousetype)
		return;

	/* set up /dev/eia0 as the mouse */
	uartspecial(port, 0, &mouseq, 1200);
	mousetype = Mouseserial;
}

/*
 *  set up a ps2 mouse
 */
void
mouseps2(void)
{
	if(mousetype)
		return;

	bigcursor();
	setvec(Mousevec, kbdintr);

	/* enable kbd/mouse xfers and interrupts */
	outb(Cmd, 0x60);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Data, 0x47);
	if(outready() < 0)
		print("kbd init failed\n");
	outb(Cmd, 0xA8);

	/* make mouse streaming, enabled */
	mousecmd(0xEA);
	mousecmd(0xF4);
	mousetype = MousePS2;
}

/*


@@ 267,6 281,21 @@ mouseaccelerate(int on)
}

/*
 *  set mouse resolution
 */
void
mouseres(int res)
{

	switch(mousetype){
	case MousePS2:
		mousecmd(0xE8);
		mousecmd(res);
		break;
	}
}

/*
 *  mouse message is three bytes
 *
 *	byte 0 -	0 0 SDY SDX 1 M R L

M pc/main.c => pc/main.c +11 -5
@@ 8,7 8,17 @@
#include	"init.h"

/* configuration parameters */
int mousetype;
enum
{
	/* what kind of power management */
	PMUother=	0,
	PMUnsx20=	1,

	/* how to reset the processor */
	Resetother=	0,
	Reset8042=	1,
	Resetheadland=	2,
};
int pmutype;
int resettype;



@@ 54,14 64,10 @@ ident(void)
	char *id = (char*)(ROMBIOS + 0xFF40);

	if(strncmp(id, "AT&TNSX", 7) == 0){
		mousetype = MousePS2;
		pmutype = PMUnsx20;
		resettype = Resetheadland;
	}else if(strncmp(id, "NCRD.0", 6) == 0){
		mousetype = MousePS2;
		resettype = Reset8042;
	}else{
		mousetype = Mouseserial;
	}
}


M port/stil.c => port/stil.c +4 -1
@@ 788,7 788,10 @@ ilbackoff(Ilcb *ic)
static int
notsyncer(void *ic)
{
	return ((Ilcb*)ic)->state != Ilsyncer;
	Ilcb *i;

	i = ic;
	return i->state != Ilsyncer;
}
void
ilstart(Ipconv *ipc, int type, int window)

M ss/fns.h => ss/fns.h +1 -1
@@ 56,7 56,7 @@ void	puttbr(ulong);
void	putw4(ulong, ulong);	/* needed only at boot time */
void	systemreset(void);
void	restfpregs(FPsave*, ulong);
void	screeninit(char*);
void	screeninit(char*, int);
void	screenputc(int);
void	screenputs(char*, int);
void	scsiintr(void);

M ss/io.h => ss/io.h +4 -3
@@ 1,6 1,7 @@
#define	FRAMEBUF	0xFE000000
#define	FRAMEBUFID	(FRAMEBUF+0x000000)
#define	DISPLAYRAM	(FRAMEBUF+0x800000)
#define	SBUS(n)		(0xF8000000+(n)*0x2000000)
#define	FRAMEBUF(n)	SBUS(n)
#define	FRAMEBUFID(n)	(SBUS(n)+0x000000)
#define	DISPLAYRAM(n)	(SBUS(n)+0x800000)
#define	EPROM		0xF6000000
#define	CLOCK		0xF3000000
#define	CLOCKFREQ	1000000		/* one microsecond increments */

M ss/l.s => ss/l.s +2 -1
@@ 39,7 39,8 @@ TEXT	startvirt(SB), $-4

	MOVW	$(0x35<<22), R7		/* NVM OFM DZM NS */
	MOVW	R7, fsr+0(SB)
	MOVW	fsr+0(SB), FSR
	MOVW	$fsr+0(SB), R8
	MOVW	(R8), FSR
	FMOVD	$0.5, F26		/* 0.5 -> F26 */
	FSUBD	F26, F26, F24		/* 0.0 -> F24 */
	FADDD	F26, F26, F28		/* 1.0 -> F28 */

M ss/main.c => ss/main.c +45 -36
@@ 17,6 17,7 @@ ulong	romputcxsegm;
ulong	bank[2];
char	mempres[256];
char	fbstr[32];
ulong	fbslot;
Label	catch;
int	NKLUDGE;



@@ 61,7 62,7 @@ main(void)
	mmuinit();
	kmapinit();
	if(conf.monitor)
		screeninit(fbstr);
		screeninit(fbstr, fbslot);
	printinit();
	ioinit();
	if(conf.monitor == 0)


@@ 138,8 139,9 @@ init0(void)

	print("Sun Sparcstation %s\n", sparam->name);
	print("bank 0: %dM  1: %dM\n", bank[0], bank[1]);
	print("frame buffer id %lux %s\n", conf.monitor, fbstr);
	print("frame buffer id %lux slot %ld %s\n", conf.monitor, fbslot, fbstr);
	print("NKLUDGE %d\n", NKLUDGE);
mapcrap();
	if(conf.npage1 != conf.base1)
		print("kernel mem from second bank: reboot and fix!\n");



@@ 278,7 280,7 @@ void
confinit(void)
{
	int mul;
	ulong i, j;
	ulong i, j, f;
	ulong ktop, va, mbytes, npg, v;

	conf.nmach = 1;


@@ 310,48 312,55 @@ confinit(void)
	case 0x52:	/* IPC */
	case 0x54:	/* SLC */
		conf.monitor = 1;
		fbslot = 3;
		strcpy(fbstr, "bwtwo");
		break;
	case 0x57:	/* IPX */
		conf.monitor = 1;
		fbslot = 3;
		strcpy(fbstr, "cgsix");
		break;
	default:
		/* map frame buffer id in SBUS slot 3 */
		putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEPROBEIO);
		conf.monitor = 0;
		/* if frame buffer not present, we will trap, so prepare to catch it */
		if(setlabel(&catch) == 0){
			conf.monitor = *(ulong*)va;
			switch(conf.monitor){
			case 0xFE010101:
				strcpy(fbstr, "cgthree");
				break;
			case 0xFE010104:
				strcpy(fbstr, "bwtwo");
				break;
			}
			if(fbstr[0] == 0){
				j = *(ulong*)(va+4);
				if(j > BY2PG-8)
					j = BY2PG - 8;	/* -8 for safety */
				for(i=0; i<j && fbstr[0]==0; i++)
					switch(*(uchar*)(va+i)){
					case 'b':
						if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
							strcpy(fbstr, "bwtwo");
						break;
					case 'c':
						if(strncmp((char*)(va+i), "cgthree", 7) == 0)
							strcpy(fbstr, "cgthree");
						if(strncmp((char*)(va+i), "cgsix", 5) == 0)
							strcpy(fbstr, "cgsix");
						break;
					}
		/* map frame buffer id in SBUS slots 0..3 */
		for(f=0; f<=3 && fbstr[0]==0; f++){
			putw4(va, ((FRAMEBUFID(f)>>PGSHIFT)&0xFFFF)|PTEPROBEIO);
			conf.monitor = 0;
			/* if frame buffer not present, we will trap, so prepare to catch it */
			if(setlabel(&catch) == 0){
				conf.monitor = *(ulong*)va;
				switch(conf.monitor & 0xF0FFFFFF){
				case 0xF0010101:
					strcpy(fbstr, "cgthree");
					break;
				case 0xF0010104:
					strcpy(fbstr, "bwtwo");
					break;
				}
				if(fbstr[0] == 0){
					j = *(ulong*)(va+4);
					if(j > BY2PG-8)
						j = BY2PG - 8;	/* -8 for safety */
					for(i=0; i<j && fbstr[0]==0; i++)
						switch(*(uchar*)(va+i)){
						case 'b':
							if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
								strcpy(fbstr, "bwtwo");
							break;
						case 'c':
							if(strncmp((char*)(va+i), "cgthree", 7) == 0)
								strcpy(fbstr, "cgthree");
							if(strncmp((char*)(va+i), "cgsix", 5) == 0)
								strcpy(fbstr, "cgsix");
							break;
						}
				}
			}
			catch.pc = 0;
			putw4(va, INVALIDPTE);
			if(fbstr[0])
				fbslot = f;
		}
		catch.pc = 0;
		putw4(va, INVALIDPTE);
		break;
	}

	for(sparam = sysparam; sparam->id; sparam++)

M ss/screen.c => ss/screen.c +56 -28
@@ 23,10 23,10 @@ struct{
static ulong	rep(ulong, int);
void		(*kprofp)(ulong);

/* Brooktree 458/451 */
typedef struct	DAC DAC;
struct DAC
typedef struct	Video Video;
struct Video
{
	/* Brooktree 458/451 */
	uchar	addr;		/* address register */
	uchar	pad0[3];
	uchar	color;		/* color palette */


@@ 35,7 35,24 @@ struct DAC
	uchar	pad2[3];
	uchar	ovrl;		/* overlay palette */
	uchar	pad3[3];
}*dac;
	/* Sun-4 video chip */
	uchar	mcr;		/* master control register */
	uchar	sr;		/* status register */
	uchar	csa;		/* cursor start address */
	uchar	cea;		/* cursor end address */
	uchar	hbs;		/* horizontal blank set */
	uchar	hbc;		/* horizontal blank clear */
	uchar	hss;		/* horizontal sync set */
	uchar	hsc;		/* horizontal sync clear */
	uchar	csc;		/* composite sync clear */
	uchar	vbsh;		/* vertical blank set high byte */
	uchar	vbsl;		/* vertical blank set low byte */
	uchar	vbc;		/* vertical blank clear */
	uchar	vss;		/* vertical sync set */
	uchar	vsc;		/* vertical sync clear */
	uchar	xcs;		/* transfer cycle hold off set */
	uchar	xcc;		/* transfer cycle hold off clear */
}*vid;

GBitmap gscreen;



@@ 45,7 62,7 @@ struct screens
	int	x;
	int	y;
	int	ld;
	ulong	dacaddr;
	ulong	vidaddr;
}screens[] = {
	{ "bwtwo", 1152, 900, 0, 0x400000 },
	{ "cgsix", 1152, 900, 3, 0x200000 },


@@ 56,7 73,7 @@ struct screens
Lock screenlock;

void
screeninit(char *str)
screeninit(char *str, int slot)
{
	struct screens *s;
	ulong n, r, g, b;


@@ 78,7 95,7 @@ screeninit(char *str)
	gscreen.zero = 0;
	gscreen.width = (s->x<<s->ld)/(8*sizeof(ulong));
	n = sizeof(ulong) * gscreen.width * s->y;
	gscreen.base = (ulong*)kmapregion(DISPLAYRAM, n, PTENOCACHE|PTEIO);
	gscreen.base = (ulong*)kmapregion(DISPLAYRAM(slot), n, PTENOCACHE|PTEIO);
	gscreen.ldepth = s->ld;
	gscreen.r = Rect(0, 0, s->x, s->y);
	gscreen.clipr = gscreen.r;


@@ 88,16 105,16 @@ screeninit(char *str)
	out.pos.x = MINX;
	out.pos.y = 0;
	out.bwid = defont0.info[' '].width;
	dac = (DAC*)(kmappa(FRAMEBUF+s->dacaddr, PTENOCACHE|PTEIO)->va);
	vid = (Video*)(kmappa(FRAMEBUF(slot)+s->vidaddr, PTENOCACHE|PTEIO)->va);
	if(gscreen.ldepth == 3){
		dac->addr = 4;
		dac->cntrl = 0xFF;	/* enable all planes */
		dac->addr = 5;
		dac->cntrl = 0x00;	/* no blinking */
		dac->addr = 6;
		dac->cntrl = 0x43;	/* enable palette ram and display */
		dac->addr = 7;
		dac->cntrl = 0x00;	/* no tests */
		vid->addr = 4;
		vid->cntrl = 0xFF;	/* enable all planes */
		vid->addr = 5;
		vid->cntrl = 0x00;	/* no blinking */
		vid->addr = 6;
		vid->cntrl = 0x43;	/* enable palette ram and display */
		vid->addr = 7;
		vid->cntrl = 0x00;	/* no tests */
		havecol = 0;	
		if(havecol) {
		/*


@@ 116,17 133,28 @@ screeninit(char *str)
			setcolor(85, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA);
			setcolor(170, 0x55555555, 0x55555555, 0x55555555);
		} else {
			dac->addr = 0;
			vid->addr = 0;
			for(i=255; i>=0; i--){
				dac->color = i;
				dac->color = i;
				dac->color = i;
				vid->color = i;
				vid->color = i;
				vid->color = i;
			}
		}
	}
}

void
mapcrap(void)
{
	uchar *v;
	int i;

	v = &vid->mcr;
	for(i=0; i<16; i++,v++)
		print("%lux %.2ux\n", v, *v);
}

void
screenputnl(void)
{
	if(!conf.monitor)


@@ 461,10 489,10 @@ getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb)
			ans = 0;
		*pr = *pg = *pb = ans;
	} else {
		*(uchar *)&dac->addr = p & 0xFF;
		r = dac->color;
		g = dac->color;
		b = dac->color;
		*(uchar *)&vid->addr = p & 0xFF;
		r = vid->color;
		g = vid->color;
		b = vid->color;
		*pr = (r<<24) | (r<<16) | (r<<8) | r;
		*pg = (g<<24) | (g<<16) | (g<<8) | g;
		*pb = (b<<24) | (b<<16) | (b<<8) | b;


@@ 478,10 506,10 @@ setcolor(ulong p, ulong r, ulong g, ulong b)
	if(gscreen.ldepth == 0)
		return 0;	/* can't change mono screen colormap */
	else{
		dac->addr = p & 0xFF;
		dac->color = r >> 24;
		dac->color = g >> 24;
		dac->color = b >> 24;
		vid->addr = p & 0xFF;
		vid->color = r >> 24;
		vid->color = g >> 24;
		vid->color = b >> 24;
		return 1;
	}
}