~kris/9p

9hist

e2c4e81b5e375f9c9ca2ee2806ad3adc3dbb1e6c — David du Colombier 34 years ago ad3bbb3
Plan 9 from Bell Labs 1992-08-11
12 files changed, 73 insertions(+), 31 deletions(-)

M pc/kbd.c
M port/chan.c
M port/devbit.c
M port/portdat.h
M ss/clock.c
M ss/devrtc.c
M ss/fptrap.c
M ss/l.s
M ss/main.c
M ss/screen.c
M ss/scsi.c
M ss/trap.c
M pc/kbd.c => pc/kbd.c +35 -9
@@ 105,7 105,7 @@ uchar kbtabesc1[] =
KIOQ	kbdq;

static int mousebuttons;
static int middlebutton;
static int keybuttons;

/*
 *  predeclared


@@ 212,6 212,9 @@ kbdinit(void)
		if(mousecmd(0xEA) < 0
		|| mousecmd(0xF4) < 0)
			print("can't initialize mouse\n");

		/* turn on mouse acceleration */
		mousecmd(0xE7);
		break;
	case At:
		/* enable kbd xfers and interrupts */


@@ 257,7 260,7 @@ mymouseputc(int c)
			msg[2] |= 0xFF00;

		mousebuttons = b[msg[0]&7];
		mouse.newbuttons = mousebuttons | middlebutton;
		mouse.newbuttons = mousebuttons | keybuttons;
		mouse.dx = msg[1];
		mouse.dy = -msg[2];
		mouse.track = 1;


@@ 270,10 273,21 @@ mymouseputc(int c)
 *  Ctrl key used as middle button pressed
 */
static void
middle(int newval)
mbon(int val)
{
	middlebutton = newval;
	mouse.newbuttons = mousebuttons | middlebutton;
	keybuttons |= val;
	mouse.newbuttons = mousebuttons | keybuttons;
	mouse.dx = 0;
	mouse.dy = 0;
	mouse.track = 1;
	spllo();		/* mouse tracking kills uart0 */
	mouseclock();
}
static void
mboff(int val)
{
	keybuttons &= ~val;
	mouse.newbuttons = mousebuttons | keybuttons;
	mouse.dx = 0;
	mouse.dy = 0;
	mouse.track = 1;


@@ 360,8 374,14 @@ kbdintr0(void)
		case Ctrl:
			ctl = 0;
			break;
		case Middle:
			middle(0);
		case KF|1:
			mboff(4);
			break;
		case KF|2:
			mboff(2);
			break;
		case KF|3:
			mboff(1);
			break;
		}
		return 0;


@@ 424,8 444,14 @@ kbdintr0(void)
		case Ctrl:
			ctl = 1;
			return 0;
		case Middle:
			middle(2);
		case KF|1:
			mbon(4);
			return 0;
		case KF|2:
			mbon(2);
			return 0;
		case KF|3:
			mbon(1);
			return 0;
		}
	}

M port/chan.c => port/chan.c +2 -0
@@ 544,6 544,8 @@ namec(char *name, int amode, int omode, ulong perm)
		c = (*devtab[c->type].open)(c, omode);
		if(omode & OCEXEC)
			c->flag |= CCEXEC;
		if(omode & ORCLOSE)
			c->flag |= CRCLOSE;
		break;

	case Amount:

M port/devbit.c => port/devbit.c +1 -1
@@ 616,7 616,7 @@ bitread(Chan *c, void *va, long n, ulong offset)
		n = 3;
	}else if(bit.cacheid >= 0){
		/*
		 * allocate subfont:
		 * check cache for subfont:
		 *	'J'		1
		 *	subfont id	2
		 *	font info	3*12

M port/portdat.h => port/portdat.h +1 -0
@@ 145,6 145,7 @@ enum
#define	CCREATE	4			/* permits creation if c->mnt */
#define	CCEXEC	8			/* close on exec */
#define	CFREE	16			/* not in use */
#define	CRCLOSE	32			/* remove on close */

struct Chan
{

M ss/clock.c => ss/clock.c +1 -4
@@ 70,10 70,7 @@ clock(Ureg *ur)
			else
				sched();
		}
		if((ur->psr&PSRPSUPER) == 0){
			spllo();				/* Low because we may fault */
		if((ur->psr&PSRPSUPER) == 0)
			*(ulong*)(USTKTOP-BY2WD) += TK2MS(1);
			splhi();				/* return hi for restore */
		}
	}
}

M ss/devrtc.c => ss/devrtc.c +0 -1
@@ 32,7 32,6 @@ static struct
	RTCdev	*rtc;
}nvr;


enum{
	Qrtc = 1,
	Qnvram,

M ss/fptrap.c => ss/fptrap.c +1 -4
@@ 216,7 216,7 @@ fixq(FPsave *f, int n)
 * traps if you touch it when an exception is pending, and because if you
 * trap with ET==0 you halt, this routine sets some global flags to enable
 * the rest of the system to handle the trap that might occur here without
 * upsetting the kernel.
 * upsetting the kernel.  Shouldn't be necessary, but safety first.
 */
int
fpquiet(void)


@@ 231,12 231,9 @@ fpquiet(void)
	u->p->fpstate = FPinactive;
	for(;;){
		m->fptrap = 0;
		spllo();
		fsr = getfsr();
		splhi();
		if(m->fptrap){
			/* trap occurred and u->fpsave contains state */
			spllo();
			sprint(buf, "sys: %s", excname(8));
			postnote(u->p, 1, buf, NDebug);
			notrap = 0;

M ss/l.s => ss/l.s +4 -4
@@ 1,6 1,6 @@
#include "mem.h"

#define	SYSPSR	(SPL(0x0)|PSREF|PSRSUPER|0)
#define	SYSPSR	(SPL(0x0)|PSREF|PSRET|PSRSUPER|SPL(15)|0)
#define	NOOP	ORN R0, R0; ORN R0, R0; ORN R0, R0

TEXT	start(SB), $-4


@@ 90,7 90,7 @@ TEXT	spllo(SB), $0

	MOVW	PSR, R7
	MOVW	R7, R10
	OR	$PSRET, R10
	ANDN	$SPL(15), R10
	MOVW	R10, PSR
	NOOP
	RETURN


@@ 100,7 100,7 @@ TEXT	splhi(SB), $0
	MOVW	R15, 4(R(MACH))	/* save PC in m->splpc */
	MOVW	PSR, R7
	MOVW	R7, R10
	AND	$~PSRET, R10	/* BUG: book says this is buggy */
	OR	$SPL(15), R10
	MOVW	R10, PSR
	NOOP
	RETURN


@@ 117,7 117,7 @@ TEXT	spldone(SB), $0
	RETURN

TEXT	touser(SB), $0
	MOVW	$(SYSPSR&~PSREF), R8
	MOVW	$(SYSPSR&~(PSREF|PSRET|SPL(15))), R8
	MOVW	R8, PSR
	NOOP


M ss/main.c => ss/main.c +23 -5
@@ 16,6 16,9 @@ int	cpuserver;
ulong	romputcxsegm;
ulong	bank[2];
char	mempres[256];
ulong	fbsz;
char	fbstr[32];
char	fbcrap[BY2PG];
Label	catch;

typedef struct Sysparam Sysparam;


@@ 135,7 138,7 @@ 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\n", conf.monitor);
	print("frame buffer id %lux %lux %s\n", conf.monitor, fbsz, fbstr);

	u->slash = (*devtab[0].attach)(0);
	u->dot = clone(u->slash, 0);


@@ 285,16 288,31 @@ confinit(void)
		*(ulong*)va = 0;
	putw4(va, INVALIDPTE);

	/* map frame buffer id */
	/* map frame buffer id; we expect it to be in SBUS slot 3 */
	putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
	i = getpsr();
	conf.monitor = 0;
	/* if frame buffer not present, we will trap, so prepare to catch it */
	if(setlabel(&catch) == 0){
		setpsr(i|PSRET|(0xF<<8));	/* enable traps, not interrupts */
		conf.monitor = *(ulong*)va;
putw4(va, (((FRAMEBUFID+BY2PG)>>PGSHIFT)&0xFFFF)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
memmove(fbcrap, (void*)va, BY2PG);
		j = *(ulong*)(va+4);
		fbsz = j;
		j = BY2PG - 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;
			}
	}
	setpsr(i);
	catch.pc = 0;
	putw4(va, INVALIDPTE);


M ss/screen.c => ss/screen.c +1 -1
@@ 49,7 49,7 @@ screeninit(void)
	if(conf.monitor){
		s = screens;
		goto found;
	]
	}
	conf.monitor = 0;
	return;


M ss/scsi.c => ss/scsi.c +2 -1
@@ 7,7 7,7 @@
#include	"devtab.h"
#include	"io.h"

int	scsiownid = 7;
uchar	scsiownid = 7;
int	scsidebugs[8];

static int	dmatype;


@@ 106,6 106,7 @@ resetscsi(void)
	dmatype = (dma->csr>>28) & 0xF;

	putenab(getenab()|ENABDMA); /**/
print("scsi config #%2.2ux\n", dev->config);
}

void

M ss/trap.c => ss/trap.c +2 -1
@@ 108,7 108,7 @@ trap(Ureg *ur)
	 * Hack to catch bootstrap fault during probe
	 */
	if(catch.pc)
		longjmp(&catch, 1);
		gotolabel(&catch);

	if(u)
		u->dbgreg = ur;


@@ 245,6 245,7 @@ trapinit(void)
	*(ulong*)t = a;			/* CALL syscall(SB) */
	*(ulong*)(t+4) = 0xa7480000;	/* MOVW PSR, R19 */
	puttbr(TRAPS);
	setpsr(getpsr()|PSRET|SPL(15));	/* enable traps, not interrupts */
}

void