Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/power/trap.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname power/trap.c 1990/0227
## diff -e /dev/null /n/bootesdump/1990/0227/sys/src/9/mips/trap.c
0a
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"ureg.h"
#include	"io.h"

/*
 *  vme interrupt routines
 */
void	(*vmevec[256])(int);

void	notify(Ureg*);
void	noted(Ureg**);
void	rfnote(Ureg**);

#define	LSYS	0x01
#define	LUSER	0x02
/*
 * CAUSE register
 */

#define	EXCCODE(c)	((c>>2)&0x0F)
#define	FPEXC		16

char *excname[] =
{
	"external interrupt",
	"TLB modification",
	"TLB miss (load or fetch)",
	"TLB miss (store)",
	"address error (load or fetch)",
	"address error (store)",
	"bus error (fetch)",
	"bus error (data load or store)",
	"system call",
	"breakpoint",
	"reserved instruction",
	"coprocessor unusable",
	"arithmetic overflow",
	"undefined 13",
	"undefined 14",
	"undefined 15",
	/* the following is made up */
	"floating point exception"		/* FPEXC */
};
char	*fpexcname(ulong);

char *regname[]={
	"STATUS",	"PC",
	"SP",		"CAUSE",
	"BADADDR",	"TLBVIRT",
	"HI",		"LO",
	"R31",		"R30",
	"R28",		"R27",
	"R26",		"R25",
	"R24",		"R23",
	"R22",		"R21",
	"R20",		"R19",
	"R18",		"R17",
	"R16",		"R15",
	"R14",		"R13",
	"R12",		"R11",
	"R10",		"R9",
	"R8",		"R7",
	"R6",		"R5",
	"R4",		"R3",
	"R2",		"R1",
};

long	ticks;

void
trap(Ureg *ur)
{
	int ecode;
	int user;
	ulong x;
	char buf[ERRLEN];

	ecode = EXCCODE(ur->cause);
	user = ur->status&KUP;
	if(u)
		u->p->pc = ur->pc;		/* BUG */
	switch(ecode){
	case CINT:
		m->intrp = 0;
		if(u && u->p->state==Running){
			if(u->p->fpstate == FPactive) {
				if(ur->cause & INTR3){	/* FP trap */
					x = clrfpintr();
					ecode = FPEXC;
				}
				savefpregs(&u->fpsave);
				u->p->fpstate = FPinactive;
				ur->status &= ~CU1;
				if(ecode == FPEXC)
					goto Default;
			}
			m->intr = intr;
			m->cause = ur->cause;
			if(ur->cause & INTR2)
				m->intrp = u->p;
			sched();
		}else
			intr(ur->cause);
		break;

	case CTLBM:
	case CTLBL:
	case CTLBS:
		if(u == 0)
			panic("fault");
		if(u->p->fpstate == FPactive) {
			savefpregs(&u->fpsave);
			u->p->fpstate = FPinactive;
			ur->status &= ~CU1;
		}
		spllo();
		x = u->p->insyscall;
		u->p->insyscall = 1;
		fault(ur, user, ecode);
		u->p->insyscall = x;
		break;

	case CCPU:
		if(u->p->fpstate == FPinit) {
			restfpregs(&initfp);
			u->p->fpstate = FPactive;
			ur->status |= CU1;
			break;
		}
		if(u->p->fpstate == FPinactive) {
			restfpregs(&u->fpsave);
			u->p->fpstate = FPactive;
			ur->status |= CU1;
			break;
		}

	default:
	Default:
		/*
		 * This isn't good enough; can still deadlock because we may hold print's locks
		 * in this processor.
		 */
		if(user){
			spllo();
			if(ecode == FPEXC)
				sprint(buf, "fp: %s FCR31 %lux", fpexcname(x), x);
			else
				sprint(buf, "trap: %s", excname[ecode]);
			postnote(u->p, 1, buf, NDebug);
		}else{
			print("%s %s pc=%lux\n", user? "user": "kernel", excname[ecode], ur->pc);
			if(ecode == FPEXC)
				print("fp: %s FCR31 %lux\n", fpexcname(x), x);
			dumpregs(ur);
			if(m->machno == 0)
				spllo();
			exit();
		}
	}
	if(user && u->nnote)
		notify(ur);
	splhi();
	if(user && u && u->p->fpstate == FPinactive) {
		restfpregs(&u->fpsave);
		u->p->fpstate = FPactive;
		ur->status |= CU1;
	}
}

void
intr(ulong cause)
{
	int i, pend;
	long v;

	cause &= INTR5|INTR4|INTR3|INTR2|INTR1;
	if(cause & (INTR2|INTR4)){
		clock(cause);
		cause &= ~(INTR2|INTR4);
	}
	if(cause & INTR1){
		duartintr();
		cause &= ~INTR1;
	}
	if(cause & INTR5){

		if(!(*MPBERR1 & (1<<8))){
/*			print("MP bus error %lux\n", *MPBERR0); /**/
			*MPBERR0 = 0;
			i = *SBEADDR;
		}

		/*
		 *  directions from IO2 manual
		 *  1. clear all IO2 masks
		 */
		*IO2CLRMASK = 0xff;

		/*
		 *  2. wait for interrupt in progress
		 */
		while(!(*INTPENDREG & (1<<5)))
			;

		/*
		 *  3. read pending interrupts
		 */
		pend = SBCCREG->fintpending & 0xff;

		/*
		 *  4. clear pending register
		 */
		i = SBCCREG->flevel;

		/*
		 *  5a. process lance, scsi
		 */
	loop:
		if(pend & 1) {
			v = INTVECREG->i[0].vec;
/* a botch, bit 12 seems to always be on
			if(v & (1<<12))
				print("io2 mp bus error %d\n", 0);
 */
			if(!(v & (1<<2)))
				lanceintr();
			if(!(v & (1<<1)))
				lanceparity();
			if(!(v & (1<<0)))
				print("SCSI interrupt\n");
		}
		/*
		 *  5b. process vme
		 *  i bet i can guess your level
		 */
		pend >>= 1;
		for(i=1; pend; i++) {
			if(pend & 1) {
				v = INTVECREG->i[i].vec;
/* a botch, bit 12 seems to always be on
				if(v & (1<<12))
					print("io2 mp bus error %d\n", i);
 */
				v &= 0xff;
				(*vmevec[v])(v);
			}
			pend >>= 1;
		}
		/*
		 *  6. re-enable interrupts
		 */
		*IO2SETMASK = 0xff;
		cause &= ~INTR5;
	}
	if(cause)
		panic("cause %lux %lux\n", u, cause);
}

char *
fpexcname(ulong x)
{
	static char *str[]={
		"inexact operation",
		"underflow",
		"overflow",
		"division by zero",
		"invalid operation",
		"unimplemented operation",
	};
	int i;

	x >>= 12;
	for(i=0; i<6; i++, x>>=1)
		if(x & 1)
			return str[i];
	return "no floating point exception";
}
void
dumpstack(void)
{
	ulong l, v;
	extern ulong etext;

	if(u)
		for(l=(ulong)&l; l<USERADDR+BY2PG; l+=4){
			v = *(ulong*)l;
			if(KTZERO < v && v < (ulong)&etext)
				print("%lux=%lux\n", l, v);
		}
}

void
dumpregs(Ureg *ur)
{
	int i;
	ulong *l;
	int (*pr)(char*, ...);

	if(u)
		print("registers for %s %d\n", u->p->text, u->p->pid);
	else
		print("registers for kernel\n");
	l = &ur->status;
	for(i=0; i<sizeof regname/sizeof(char*); i+=2, l+=2)
		print("%s\t%.8lux\t%s\t%.8lux\n", regname[i], l[0], regname[i+1], l[1]);
	dumpstack();
}

/*
 * Call user, if necessary, with note
 */
void
notify(Ureg *ur)
{
	ulong sp;

	lock(&u->p->debug);
	if(u->nnote==0){
		unlock(&u->p->debug);
		return;
	}
	if(u->note[0].flag!=NUser && (u->notified || u->notify==0)){
		if(u->note[0].flag == NDebug)
			pprint("suicide: %s\n", u->note[0].msg);
    Die:
		unlock(&u->p->debug);
		pexit(u->note[0].msg, u->note[0].flag!=NDebug);
	}
	if(!u->notified){
		if(!u->notify)
			goto Die;
		sp = ur->sp;
		sp -= sizeof(Ureg);
		u->ureg = (void*)sp;
		memcpy((Ureg*)sp, ur, sizeof(Ureg));
		sp -= ERRLEN;
		memcpy((char*)sp, u->note[0].msg, ERRLEN);
		sp -= 3*BY2WD;
		*(ulong*)(sp+2*BY2WD) = sp+3*BY2WD;	/* arg 2 is string */
		*(ulong*)(sp+1*BY2WD) = (ulong)u->ureg;	/* arg 1 is ureg* */
		*(ulong*)(sp+0*BY2WD) = 0;		/* arg 0 is pc */
		ur->sp = sp;
		ur->pc = (ulong)u->notify;
		u->notified = 1;
		u->nnote--;
		memcpy(&u->note[0], &u->note[1], u->nnote*sizeof(Note));
	}
	unlock(&u->p->debug);
}

/*
 * Return user to state before notify()
 */
void
noted(Ureg **urp)
{
	lock(&u->p->debug);
	u->notified = 0;
	memcpy(*urp, u->ureg, sizeof(Ureg));
	unlock(&u->p->debug);
	splhi();
	rfnote(urp);
}


#undef	CHDIR	/* BUG */
#include "/sys/src/libc/mips9sys/sys.h"

typedef long Syscall(ulong*);
Syscall sysaccess, sysbind, sysbrk_, syschdir, sysclose, syscreate;
Syscall	sysdup, syserrstr, sysexec, sysexits, sysfork, sysforkpgrp;
Syscall	sysfstat, sysfwstat, sysgetpid, syslasterr, sysmount, sysnoted;
Syscall	sysnotify, sysopen, syspipe, sysr1, sysread, sysremove, sysseek;
Syscall syssleep, sysstat, sysuserstr, syswait, syswrite, syswstat;

Syscall *systab[]={
	[SYSR1]		sysr1,
	[ACCESS]	sysaccess,
	[BIND]		sysbind,
	[CHDIR]		syschdir,
	[CLOSE]		sysclose,
	[DUP]		sysdup,
	[ERRSTR]	syserrstr,
	[EXEC]		sysexec,
	[EXITS]		sysexits,
	[FORK]		sysfork,
	[FORKPGRP]	sysforkpgrp,
	[FSTAT]		sysfstat,
	[LASTERR]	syslasterr,
	[MOUNT]		sysmount,
	[OPEN]		sysopen,
	[READ]		sysread,
	[SEEK]		sysseek,
	[SLEEP]		syssleep,
	[STAT]		sysstat,
	[WAIT]		syswait,
	[WRITE]		syswrite,
	[PIPE]		syspipe,
	[CREATE]	syscreate,
	[USERSTR]	sysuserstr,
	[BRK_]		sysbrk_,
	[REMOVE]	sysremove,
	[WSTAT]		syswstat,
	[FWSTAT]	sysfwstat,
	[NOTIFY]	sysnotify,
	[NOTED]		sysnoted,
};

long
syscall(Ureg *aur)
{
	long ret;
	ulong sp;
	ulong r1;
	Ureg *ur;

	u->p->insyscall = 1;
	ur = aur;
	/*
	 * since the system call interface does not
	 * guarantee anything about registers,
	 */
	if(u->p->fpstate == FPactive) {
		u->p->fpstate = FPinit;		/* BUG */
		ur->status &= ~CU1;
	}
	spllo();
	r1 = ur->r1;
	sp = ur->sp;
	if(r1 >= sizeof systab/BY2WD)
		panic("syscall %d\n", r1);
	if(sp & (BY2WD-1))
		panic("syscall odd sp");
	if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD))
		validaddr(ur->sp, 4*BY2WD, 0);

	u->nerrlab = 0;
	ret = -1;
	if(!waserror())
		ret = (*systab[r1])((ulong*)(sp+2*BY2WD));
	ur->pc += 4;
	u->nerrlab = 0;
	splhi();
	if(r1 == NOTED)	/* ugly hack */
		noted(&aur);	/* doesn't return */
	if(u->nnote){
		ur->r1 = ret;
		notify(ur);
	}
	u->p->insyscall = 0;
	return ret;
}

void
error(Chan *c, int code)
{
	if(c){
		u->error.type = c->type;
		u->error.dev = c->dev;
	}else{
		u->error.type = 0;
		u->error.dev = 0;
	}
	u->error.code = code;
	nexterror();
}

void
nexterror(void)
{
	gotolabel(&u->errlab[--u->nerrlab]);
}

void
novme(int v)
{
	static count = 0;

	print("vme intr 0x%.2x\n", v);
	count++;
	if(count >= 10)
		panic("too many vme intr");
}

void
setvmevec(int v, void (*f)(int))
{
	void (*g)(int);

	v &= 0xff;
	g = vmevec[v];
	if(g && g != novme)
		print("second setvmevec to 0x%.2x\n", v);
	vmevec[v] = f;
}
.
## diffname power/trap.c 1990/03091
## diff -e /n/bootesdump/1990/0227/sys/src/9/mips/trap.c /n/bootesdump/1990/03091/sys/src/9/mips/trap.c
454d
447a
	u->p->insyscall = 0;
.
281a

.
## diffname power/trap.c 1990/0310
## diff -e /n/bootesdump/1990/03091/sys/src/9/mips/trap.c /n/bootesdump/1990/0310/sys/src/9/mips/trap.c
423a
	u->p->pc = ur->pc;		/* BUG */
.
## diffname power/trap.c 1990/0427
## diff -e /n/bootesdump/1990/0310/sys/src/9/mips/trap.c /n/bootesdump/1990/0427/sys/src/9/mips/trap.c
152c
				sprint(buf, "trap: %s[%d]", excname[ecode], m->machno);
.
## diffname power/trap.c 1990/0511
## diff -e /n/bootesdump/1990/0427/sys/src/9/mips/trap.c /n/bootesdump/1990/0511/sys/src/9/mips/trap.c
446a
	}
.
445c
	if(!waserror()){
		if(r1 >= sizeof systab/BY2WD){
			pprint("bad sys call number %d pc %lux\n", r1, ((Ureg*)UREGADDR)->pc);
			msg = "bad sys call";
	    Bad:
			postnote(u->p, 1, msg, NDebug);
			error(0, Ebadarg);
		}
		if(sp & (BY2WD-1)){
			pprint("odd sp in sys call pc %lux sp %lux\n", ((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp);
			msg = "odd stack";
			goto Bad;
		}
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD))
			validaddr(ur->sp, 4*BY2WD, 0);
.
436,442d
420a
	char *msg;
.
7a
#include	"errno.h"
.
## diffname power/trap.c 1990/0515
## diff -e /n/bootesdump/1990/0511/sys/src/9/mips/trap.c /n/bootesdump/1990/0515/sys/src/9/mips/trap.c
454c
			validaddr(sp, 4*BY2WD, 0);
.
## diffname power/trap.c 1990/0619
## diff -e /n/bootesdump/1990/0515/sys/src/9/mips/trap.c /n/bootesdump/1990/0619/sys/src/9/mips/trap.c
363a
	if(!u->notified){
		unlock(&u->p->debug);
		return;
	}
.
## diffname power/trap.c 1990/0722
## diff -e /n/bootesdump/1990/0619/sys/src/9/mips/trap.c /n/bootesdump/1990/0722/sys/src/9/mips/trap.c
436c
		u->p->fpstate = FPinit;
.
142a
		if(u && u->p && u->p->fpstate == FPactive){
			savefpregs(&u->fpsave);
			u->p->fpstate = FPinactive;
			ur->status &= ~CU1;
		}
.
140a
		goto Default;
.
135c
		if(u && u->p && u->p->fpstate == FPinactive) {
.
129c
		if(u && u->p && u->p->fpstate == FPinit) {
.
## diffname power/trap.c 1990/0731
## diff -e /n/bootesdump/1990/0722/sys/src/9/mips/trap.c /n/bootesdump/1990/0731/sys/src/9/mips/trap.c
189c
		clock(cause, pc);
.
182c
intr(ulong cause, ulong pc)
.
108c
			intr(ur->cause, ur->pc);
.
103a
			m->pc = ur->pc;
.
## diffname power/trap.c 1990/0802
## diff -e /n/bootesdump/1990/0731/sys/src/9/mips/trap.c /n/bootesdump/1990/0802/sys/src/9/mips/trap.c
116c
			panic("fault u==0 pc %lux addr %lux", ur->pc, ur->badvaddr);
.
## diffname power/trap.c 1990/0816
## diff -e /n/bootesdump/1990/0802/sys/src/9/mips/trap.c /n/bootesdump/1990/0816/sys/src/9/mips/trap.c
355c
		ur->usp = sp;
.
345c
		sp = ur->usp;
.
## diffname power/trap.c 1990/0826
## diff -e /n/bootesdump/1990/0816/sys/src/9/mips/trap.c /n/bootesdump/1990/0826/sys/src/9/mips/trap.c
395c
	[___ACCESS___]	sysaccess,
.
255d
252,253c
				if(!(v & (1<<12)))
.
236,242c
			switch(ioid){
			case IO2R1:
			case IO2R2:
				if(!(v & (1<<2)))
					lanceintr();
				if(!(v & (1<<1)))
					lanceparity();
				if(!(v & (1<<0)))
					print("SCSI interrupt\n");
				break;
			case IO3R1:
				if(v & (1<<2))
					lance3intr();
				if(v & (1<<1))
					print("SCSI 1 interrupt\n");
				if(v & (1<<0))
					print("SCSI 0 interrupt\n");
				break;
			}
.
233,234c
			if(!(v & (1<<12)))
.
## diffname power/trap.c 1990/0830
## diff -e /n/bootesdump/1990/0826/sys/src/9/mips/trap.c /n/bootesdump/1990/0830/sys/src/9/mips/trap.c
263,264c
				if(!(v & (1<<12))){
					print("io2 mp bus error %d %lux %lux\n", i,
						*MPBERR0, *MPBERR1);
					*MPBERR0 = 0;
				}
.
233,234c
			if(!(v & (1<<12))){
				print("io2 mp bus error %d %lux %lux\n", 0,
					*MPBERR0, *MPBERR1);
				*MPBERR0 = 0;
			}
.
200c
			print("MP bus error %lux %lux\n", *MPBERR0, *MPBERR1); /**/
.
## diffname power/trap.c 1990/0901
## diff -e /n/bootesdump/1990/0830/sys/src/9/mips/trap.c /n/bootesdump/1990/0901/sys/src/9/mips/trap.c
452a
	ur->cause = 15<<2;		/* for debugging: system call is undef 15;
.
45c
	"undefined 15",				/* used as sys call for debugger */
.
## diffname power/trap.c 1990/0905
## diff -e /n/bootesdump/1990/0901/sys/src/9/mips/trap.c /n/bootesdump/1990/0905/sys/src/9/mips/trap.c
279c
		*IO2SETMASK = iomask;
.
266,270c
				if(!(v & (1<<12)))
					mpbuserror();
.
257a
		if(pend & (1<<10)) {
			v = INTVECREG->i[10].vec;
			if(!(v & (1<<12)))
				mpbuserror();
			lance3intr();
		}
		if(pend & (1<<8)) {
			v = INTVECREG->i[10].vec;
			if(!(v & (1<<12)))
				mpbuserror();
			print("SCSI0 interrupt\n");
		}
		if(pend & (1<<9)) {
			v = INTVECREG->i[10].vec;
			if(!(v & (1<<12)))
				mpbuserror();
			print("SCSI1 interrupt\n");
		}
.
233,256c
			if(!(v & (1<<12)))
				mpbuserror();
			if(!(v & (1<<2)))
				lanceintr();
			if(!(v & (1<<1)))
				lanceparity();
			if(!(v & (1<<0)))
				print("SCSI interrupt\n");
.
230d
182a
mpbuserror(void)
{
	print("io2 mp bus error %d %lux %lux\n", 0,
		*MPBERR0, *MPBERR1);
	*MPBERR0 = 0;
}

void
.
## diffname power/trap.c 1990/0907
## diff -e /n/bootesdump/1990/0905/sys/src/9/mips/trap.c /n/bootesdump/1990/0907/sys/src/9/mips/trap.c
285c
		*IO2SETMASK = 0xff;
.
275,276c
				if(!(v & (1<<12))){
					print("io2 mp bus error %d %lux %lux\n", i,
						*MPBERR0, *MPBERR1);
					*MPBERR0 = 0;
				}
.
249,266d
240,247c
			if(!(v & (1<<12))){
				print("io2 mp bus error %d %lux %lux\n", 0,
					*MPBERR0, *MPBERR1);
				*MPBERR0 = 0;
			}
			switch(ioid){
			case IO2R1:
			case IO2R2:
				if(!(v & (1<<2)))
					lanceintr();
				if(!(v & (1<<1)))
					lanceparity();
				if(!(v & (1<<0)))
					print("SCSI interrupt\n");
				break;
			case IO3R1:
				if(v & (1<<2))
					lance3intr();
				if(v & (1<<1))
					print("SCSI 1 interrupt\n");
				if(v & (1<<0))
					print("SCSI 0 interrupt\n");
				break;
			}
.
237a
	loop:
.
208c
			iprint("MP bus error %lux %lux\n", *MPBERR0, *MPBERR1); /**/
.
183,190d
## diffname power/trap.c 1990/0911
## diff -e /n/bootesdump/1990/0907/sys/src/9/mips/trap.c /n/bootesdump/1990/0911/sys/src/9/mips/trap.c
255d
250c
					lanceintr();
.
247,248c
			} else {
.
238,240c
			if(ioid < IO3R1){
.
200c
			print("MP bus error %lux %lux\n", *MPBERR0, *MPBERR1);
.
## diffname power/trap.c 1990/1110
## diff -e /n/bootesdump/1990/0911/sys/src/9/mips/trap.c /n/bootesdump/1990/1110/sys/src/9/mips/trap.c
473c
			msg = "sys: odd stack";
.
466c
			msg = "sys: bad sys call";
.
160c
				sprint(buf, "sys: trap: %s[%d]", excname[ecode], m->machno);
.
158c
				sprint(buf, "sys: fp: %s FCR31 %lux", fpexcname(x), x);
.
## diffname power/trap.c 1990/1113
## diff -e /n/bootesdump/1990/1110/sys/src/9/mips/trap.c /n/bootesdump/1990/1113/sys/src/9/mips/trap.c
387a
	(*urp)->r1 = -1;	/* return error from the interrupted call */
.
## diffname power/trap.c 1990/11211
## diff -e /n/bootesdump/1990/1113/sys/src/9/mips/trap.c /n/bootesdump/1990/11211/sys/src/9/mips/trap.c
497,504c
	strncpy(u->error, errstrtab[code], NAMELEN);
	nexterror();
}

void
errors(char *err)
{
	strncpy(u->error, err, NAMELEN);
.
495c
error(int code)
.
493a
#include "errstr.h"

.
477,478c
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-5*BY2WD))
			validaddr(sp, 5*BY2WD, 0);
.
470c
			error(Ebadarg);
.
429c
	[___USERSTR___]	sysdeath,
.
418c
	[___LASTERR___]	sysdeath,
.
412c
	[___ERRSTR___]	sysdeath,
.
407c
	[ERRSTR]	syserrstr,
.
403c
Syscall syssleep, sysstat, syswait, syswrite, syswstat;
.
401c
Syscall	sysfstat, sysfwstat, sysgetpid, sysmount, sysnoted;
.
399c
Syscall sysbind, sysbrk_, syschdir, sysclose, syscreate, sysdeath;
.
396c
#include "/sys/src/libc/Nmips9sys/sys.h"
.
330d
## diffname power/trap.c 1990/1122
## diff -e /n/bootesdump/1990/11211/sys/src/9/mips/trap.c /n/bootesdump/1990/1122/sys/src/9/mips/trap.c
395c
#include "/sys/src/libc/mips9sys/sys.h"
.
## diffname power/trap.c 1990/1212
## diff -e /n/bootesdump/1990/1122/sys/src/9/mips/trap.c /n/bootesdump/1990/1212/sys/src/9/mips/trap.c
125c
		faultmips(ur, user, ecode);
.
## diffname power/trap.c 1990/1214
## diff -e /n/bootesdump/1990/1212/sys/src/9/mips/trap.c /n/bootesdump/1990/1214/sys/src/9/mips/trap.c
225a
		USED(i);
.
202a
			USED(i);
.
82a
	SET(x);
.
## diffname power/trap.c 1990/1226
## diff -e /n/bootesdump/1990/1214/sys/src/9/mips/trap.c /n/bootesdump/1990/1226/sys/src/9/mips/trap.c
495a
void
execpc(ulong entry)
{
	((Ureg*)UREGADDR)->pc = entry - 4;		/* syscall advances it */
}

.
## diffname power/trap.c 1991/0115
## diff -e /n/bootesdump/1990/1226/sys/src/9/mips/trap.c /n/bootesdump/1991/0115/sys/src/9/mips/trap.c
507c
	strncpy(u->error, errstrtab[code], ERRLEN);
.
## diffname power/trap.c 1991/0209
## diff -e /n/bootesdump/1991/0201/sys/src/9/mips/trap.c /n/bootesdump/1991/0209/sys/src/9/power/trap.c
191c
		clock(ur);
.
189c
	cause = ur->cause&(INTR5|INTR4|INTR3|INTR2|INTR1);
.
187a
	ulong cause;
.
184c
intr(Ureg *ur)
.
103,110c
		}
		intr(ur);
.
90d
15d
## diffname power/trap.c 1991/0212
## diff -e /n/bootesdump/1991/0209/sys/src/9/power/trap.c /n/bootesdump/1991/0212/sys/src/9/power/trap.c
271c
		*IO2SETMASK = 0xff000000;
.
268a
		 *  if nothing else, assume bus error
		 */
		if(!any){
			print("bogus intr lvl 5 pend %lux on %d\n", npend, m->machno);
			delay(100);
		}
		/*
.
266d
264a
				any = 1;
.
259,260c
					print("io2 mp bus error %d %lux %lux\n",
						i, *MPBERR0, *MPBERR1);
.
254,255c
		for(i=1; pend>>=1; i++){
.
252c
		 *  i can guess your level
.
241c
			}else{
				if(v & 7)
					any = 1;
.
234a
				if(!(v & 7))
					any = 1;
.
232a
				any = 1;
.
226d
215c
		npend = pend = SBCCREG->fintpending;
.
204c
		*IO2CLRMASK = 0xff000000;
.
197a
			any = 1;
.
192c
		any = 0;
.
178c
	int i, any;
	uchar pend, npend;
.
## diffname power/trap.c 1991/0219
## diff -e /n/bootesdump/1991/0212/sys/src/9/power/trap.c /n/bootesdump/1991/0219/sys/src/9/power/trap.c
276c
		if(!any && bogies++<100){
.
181a
	static int bogies;
.
## diffname power/trap.c 1991/0314
## diff -e /n/bootesdump/1991/0219/sys/src/9/power/trap.c /n/bootesdump/1991/0314/sys/src/9/power/trap.c
463a
		u->fpsave.fpstatus = fcr31();
.
461c
	 * guarantee anything about registers, we can
	 * smash them.  but we must save fpstatus.
.
169c
		restfpregs(&u->fpsave, u->fpsave.fpstatus);
.
130c
			restfpregs(&u->fpsave, u->fpsave.fpstatus);
.
124c
			restfpregs(&initfp, u->fpsave.fpstatus);
.
## diffname power/trap.c 1991/0316
## diff -e /n/bootesdump/1991/0314/sys/src/9/power/trap.c /n/bootesdump/1991/0316/sys/src/9/power/trap.c
224a

		/*
		 *  4a. attempt to fix problem
		 */
		if(!(*INTPENDREG & (1<<5)))
			print("pause again\n");
		while(!(*INTPENDREG & (1<<5)))
			;
		xxx = SBCCREG->fintpending;
		if(xxx){
			print("new pend %ux\n", xxx);
			npend = pend |= xxx;
			i = SBCCREG->flevel;
		}
.
218c
		pend = SBCCREG->fintpending;
		npend = pend;
.
178a
	uchar xxx;
.
## diffname power/trap.c 1991/0318
## diff -e /n/bootesdump/1991/0316/sys/src/9/power/trap.c /n/bootesdump/1991/0318/sys/src/9/power/trap.c
411c
	memmove(*urp, u->ureg, sizeof(Ureg));
.
394c
		memmove(&u->note[0], &u->note[1], u->nnote*sizeof(Note));
.
385c
		memmove((char*)sp, u->note[0].msg, ERRLEN);
.
383c
		memmove((Ureg*)sp, ur, sizeof(Ureg));
.
## diffname power/trap.c 1991/0322
## diff -e /n/bootesdump/1991/0318/sys/src/9/power/trap.c /n/bootesdump/1991/0322/sys/src/9/power/trap.c
538c
	strncpy(u->error, err, ERRLEN);
.
## diffname power/trap.c 1991/0425
## diff -e /n/bootesdump/1991/0322/sys/src/9/power/trap.c /n/bootesdump/1991/0425/sys/src/9/power/trap.c
470a
	m->syscall++;
.
239a
			USED(i);
.
184a
	m->intr++;
.
153a

.
## diffname power/trap.c 1991/0503
## diff -e /n/bootesdump/1991/0425/sys/src/9/power/trap.c /n/bootesdump/1991/0503/sys/src/9/power/trap.c
407a
	Ureg *nur;

	nur = u->ureg;
	validaddr(nur->pc, 1, 0);
	validaddr(nur->usp, BY2WD, 0);
	if(nur->status!=u->svstatus){
		pprint("bad noted ureg status %ux\n", nur->status);
		pexit("Suicide", 0);
	}
.
382a
		u->svstatus = ur->status;
.
## diffname power/trap.c 1991/0513
## diff -e /n/bootesdump/1991/0503/sys/src/9/power/trap.c /n/bootesdump/1991/0513/sys/src/9/power/trap.c
449c
	[ALARM]		sysalarm,
.
440c
Syscall syssleep, sysstat, syswait, syswrite, syswstat, sysalarm;
.
## diffname power/trap.c 1991/0602
## diff -e /n/bootesdump/1991/0513/sys/src/9/power/trap.c /n/bootesdump/1991/0602/sys/src/9/power/trap.c
413a
	poperror();
.
411a
	if(waserror()){
		pprint("suicide: trap in noted\n");
		pexit("Suicide", 0);
	}
.
## diffname power/trap.c 1991/0606
## diff -e /n/bootesdump/1991/0602/sys/src/9/power/trap.c /n/bootesdump/1991/0606/sys/src/9/power/trap.c
460c
	[LKBRK_]	syslkbrk_,
.
445c
Syscall syssleep, sysstat, syswait, syswrite, syswstat, sysalarm, syslkbrk_;
.
## diffname power/trap.c 1991/0621
## diff -e /n/bootesdump/1991/0606/sys/src/9/power/trap.c /n/bootesdump/1991/0621/sys/src/9/power/trap.c
446c
#define LKBRK_ 12
.
## diffname power/trap.c 1991/0625
## diff -e /n/bootesdump/1991/0621/sys/src/9/power/trap.c /n/bootesdump/1991/0625/sys/src/9/power/trap.c
521a
		if(((ulong*)ur->pc)[-2] != 0x23bdfffc)	/* new calling convention: look for ADD $-4, SP */
			sp -= BY2WD;
.
## diffname power/trap.c 1991/0705
## diff -e /n/bootesdump/1991/0625/sys/src/9/power/trap.c /n/bootesdump/1991/0705/sys/src/9/power/trap.c
537a

.
529a
	
	if(u->p->procctl)
		procctl(u->p);

.
504a

	if(u->p->procctl)
		procctl(u->p);

.
477a
	[SEGATTACH]	syssegattach,
	[SEGDETACH]	syssegdetach,
	[SEGFREE]	syssegfree,
	[SEGFLUSH]	syssegflush,
.
460c
	[SEGBRK]	syssegbrk,
.
445,446c
Syscall syssleep, sysstat, syswait, syswrite, syswstat, sysalarm, syssegbrk;
Syscall syssegattach, syssegdetach, syssegfree, syssegflush;

.
385a
		if(waserror()){
			pprint("suicide: trap in notify\n");
			pexit("Suicide", 0);
		}
		validaddr((ulong)u->notify, 1, 0);
		validaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0);
		poperror();
.
166,167c

	if(user) {
		if(u->p->procctl)
			procctl(u->p);
		if(u->nnote)
			notify(ur);
	}

.
153c
				sprint(buf, "sys: %s pc=0x%lux", excname[ecode], ur->pc);
.
145,146c
		 * This isn't good enough; can still deadlock because we may 
		 * hold print's locks in this processor.
.
86a

.
## diffname power/trap.c 1991/0709
## diff -e /n/bootesdump/1991/0705/sys/src/9/power/trap.c /n/bootesdump/1991/0709/sys/src/9/power/trap.c
553d
## diffname power/trap.c 1991/0710
## diff -e /n/bootesdump/1991/0709/sys/src/9/power/trap.c /n/bootesdump/1991/0710/sys/src/9/power/trap.c
572,593d
545,549c
		if(((ulong*)ur->pc)[-2] == 0x23bdfffc){	/* old calling convention: look for ADD $-4, SP */
			pprint("old system call linkage; recompile\n");
			sp += BY2WD;
		}
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-6*BY2WD))
			validaddr(sp, 6*BY2WD, 0);
		ret = (*systab[r1])((ulong*)(sp+BY2WD));
.
452c
#include "/sys/src/libc/9syscall/sys.h"
.
## diffname power/trap.c 1991/0711
## diff -e /n/bootesdump/1991/0710/sys/src/9/power/trap.c /n/bootesdump/1991/0711/sys/src/9/power/trap.c
549,550c
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(1+MAXSYSARG)*BY2WD))
			validaddr(sp, (1+MAXSYSARG)*BY2WD, 0);
.
## diffname power/trap.c 1991/0717
## diff -e /n/bootesdump/1991/0711/sys/src/9/power/trap.c /n/bootesdump/1991/0717/sys/src/9/power/trap.c
561c
		noted(&aur, *(ulong*)(sp+BY2WD));	/* doesn't return */
.
445,447c
	switch(arg0){
	case NCONT:
		splhi();
		unlock(&u->p->debug);
		rfnote(urp);
		break;
		/* never returns */

	default:
		pprint("unknown noted arg 0x%lux\n", arg0);
		u->lastnote.flag = NDebug;
		/* fall through */
		
	case NTERM:
		if(u->lastnote.flag == NDebug)
			pprint("suicide: %s\n", u->lastnote.msg);
		unlock(&u->p->debug);
		pexit(u->lastnote.msg, u->lastnote.flag!=NDebug);
	}
.
434c
		pprint("bad noted ureg status %lux\n", nur->status);
.
432d
426,429d
421c
noted(Ureg **urp, ulong arg0)
.
411a
		memmove(&u->lastnote, &u->note[0], sizeof(Note));
.
15c
void	noted(Ureg**, ulong);
.
## diffname power/trap.c 1991/0718
## diff -e /n/bootesdump/1991/0717/sys/src/9/power/trap.c /n/bootesdump/1991/0718/sys/src/9/power/trap.c
454c
	case NDFLT:
.
## diffname power/trap.c 1991/0722
## diff -e /n/bootesdump/1991/0718/sys/src/9/power/trap.c /n/bootesdump/1991/0722/sys/src/9/power/trap.c
394a
			unlock(&u->p->debug);
.
## diffname power/trap.c 1991/0725
## diff -e /n/bootesdump/1991/0722/sys/src/9/power/trap.c /n/bootesdump/1991/0725/sys/src/9/power/trap.c
575c
	if(u->nnote && r1!=FORK){
.
441d
## diffname power/trap.c 1991/0727
## diff -e /n/bootesdump/1991/0725/sys/src/9/power/trap.c /n/bootesdump/1991/0727/sys/src/9/power/trap.c
379a
	u->p->notepending = 0;
.
## diffname power/trap.c 1991/0731
## diff -e /n/bootesdump/1991/0727/sys/src/9/power/trap.c /n/bootesdump/1991/0731/sys/src/9/power/trap.c
546c
		if(r1 >= sizeof systab/sizeof systab[0]){
.
467,511d
464,465c
#include "../port/systab.h"
.
## diffname power/trap.c 1991/0814
## diff -e /n/bootesdump/1991/0731/sys/src/9/power/trap.c /n/bootesdump/1991/0814/sys/src/9/power/trap.c
443a
		if(waserror()){
			pprint("suicide: trap in noted\n");
			unlock(&u->p->debug);
			goto Die;
		}
		validaddr(nur->pc, 1, 0);
		validaddr(nur->usp, BY2WD, 0);
		poperror();
.
438c
		pprint("call to noted() when not notified\n");
		goto Die;
.
432a
    Die:
.
429,430d
## diffname power/trap.c 1991/0926
## diff -e /n/bootesdump/1991/0814/sys/src/9/power/trap.c /n/bootesdump/1991/0926/sys/src/9/power/trap.c
535c
	if(r1 == NOTED)					/* ugly hack */
.
533a
	u->p->psstate = 0;
.
525a
		u->p->psstate = sysctab[r1];
.
## diffname power/trap.c 1991/1031
## diff -e /n/bootesdump/1991/0926/sys/src/9/power/trap.c /n/bootesdump/1991/1031/sys/src/9/power/trap.c
303c
		if(!any && bogies++<10){
.
301c
		 *  if nothing else, what the hell?
.
## diffname power/trap.c 1991/1102
## diff -e /n/bootesdump/1991/1031/sys/src/9/power/trap.c /n/bootesdump/1991/1102/sys/src/9/power/trap.c
304c
/*			print("bogus intr lvl 5 pend %lux on %d\n", npend, m->machno);/**/
.
## diffname power/trap.c 1991/1105
## diff -e /n/bootesdump/1991/1102/sys/src/9/power/trap.c /n/bootesdump/1991/1105/sys/src/9/power/trap.c
304c
			print("bogus intr lvl 5 pend %lux on %d\n", npend, m->machno);/**/
.
## diffname power/trap.c 1991/1110
## diff -e /n/bootesdump/1991/1105/sys/src/9/power/trap.c /n/bootesdump/1991/1110/sys/src/9/power/trap.c
573a
}

/* This routine must save the values of registers the user is not permitted to write from devproc 
 * and the restore them before returning
 */
void
setregisters(Ureg *xp, char *pureg, char *uva, int n)
{
	ulong status;

	status = xp->status;
	memmove(pureg, uva, n);
	xp->status = status;
.
539c
	if(u->p->procctl || (u->nnote && r1!=FORK)){
.
531,532d
500,502d
486a
	u->dbgreg = aur;
.
379c
	lock(&u->p->debug);
.
375,377c
	if(u->p->procctl)
		procctl(u->p);
	if(u->nnote == 0)
.
168,173c
	if(user)
		notify(ur);
.
87c
		u->dbgreg = ur;
	}
.
85c
	if(u) {
.
## diffname power/trap.c 1991/1111
## diff -e /n/bootesdump/1991/1110/sys/src/9/power/trap.c /n/bootesdump/1991/1111/sys/src/9/power/trap.c
569,570c
/* This routine must save the values of registers the user is not permitted to write
 * from devproc and the restore the saved values before returning
.
## diffname power/trap.c 1991/1114
## diff -e /n/bootesdump/1991/1111/sys/src/9/power/trap.c /n/bootesdump/1991/1114/sys/src/9/power/trap.c
532c
	splhi();
	if(r1!=FORK && (u->p->procctl || u->nnote)){
.
527d
414a
	splx(s);
.
375a

	s = spllo();
.
370c
	ulong s, sp;
.
173,176c
	if(user) {
		notify(ur);
		if(u->p->fpstate == FPinactive) {
			restfpregs(&u->fpsave, u->fpsave.fpstatus);
			u->p->fpstate = FPactive;
			ur->status |= CU1;
		}
.
169,171d
## diffname power/trap.c 1991/1214
## diff -e /n/bootesdump/1991/1114/sys/src/9/power/trap.c /n/bootesdump/1991/1214/sys/src/9/power/trap.c
546c
	ulong *sp;

	sp = (ulong*)(USTKTOP - ssize);
	*--sp = nargs;
	((Ureg*)UREGADDR)->usp = (ulong)sp;
	((Ureg*)UREGADDR)->pc = entry - 4;	/* syscall advances it */
	return USTKTOP-BY2WD;			/* address of user-level clock */
.
543,544c
long
execregs(ulong entry, ulong ssize, ulong nargs)
.
## diffname power/trap.c 1991/1216
## diff -e /n/bootesdump/1991/1214/sys/src/9/power/trap.c /n/bootesdump/1991/1216/sys/src/9/power/trap.c
466c
		qunlock(&u->p->debug);
.
453c
		qunlock(&u->p->debug);
.
446c
			qunlock(&u->p->debug);
.
436c
		qunlock(&u->p->debug);
.
434c
	qlock(&u->p->debug);
.
416c
	qunlock(&u->p->debug);
.
395c
			qunlock(&u->p->debug);
.
384c
		qunlock(&u->p->debug);
.
378c
	qlock(&u->p->debug);
.
## diffname power/trap.c 1991/1218
## diff -e /n/bootesdump/1991/1216/sys/src/9/power/trap.c /n/bootesdump/1991/1218/sys/src/9/power/trap.c
385c
		pexit(n->msg, n->flag!=NDebug);
.
382c
			pprint("suicide: %s\n", n->msg);
.
380c
	n = &u->note[0];
	if(strncmp(n->msg, "sys:", 4) == 0){
		l = strlen(n->msg);
		if(l > ERRLEN-15)	/* " pc=0x12345678\0" */
			l = ERRLEN-15;
		sprint(n->msg+l, " pc=0x%.8lux", ur->pc);
	}
	if(n->flag!=NUser && (u->notified || u->notify==0)){
.
374c
	if(u->nnote==0)
.
370a
	Note *n;
.
369a
	int l;
.
155c
				sprint(buf, "sys: trap: %s", excname[ecode]);
.
## diffname power/trap.c 1991/1230
## diff -e /n/bootesdump/1991/1218/sys/src/9/power/trap.c /n/bootesdump/1991/1230/sys/src/9/power/trap.c
376c
	if(u->nnote == 0)
.
## diffname power/trap.c 1992/0102
## diff -e /n/bootesdump/1991/1230/sys/src/9/power/trap.c /n/bootesdump/1992/0102/sys/src/9/power/trap.c
546a
		return ur->r1;
.
545c
		u->svr1 = ret;
.
450a
	(*urp)->r1 = u->svr1;
.
416c
		ur->r1 = (ulong)u->ureg;		/* arg 1 is ureg* */
.
155c
				sprint(buf, "sys: %s", excname[ecode]);
.
46c
	"trap: floating point exception"		/* FPEXC */
.
39,44c
	"trap: reserved instruction",
	"trap: coprocessor unusable",
	"trap: arithmetic overflow",
	"trap: undefined 13",
	"trap: undefined 14",
	"trap: undefined 15",				/* used as sys call for debugger */
.
29,37c
	"trap: external interrupt",
	"trap: TLB modification",
	"trap: TLB miss (load or fetch)",
	"trap: TLB miss (store)",
	"trap: address error (load or fetch)",
	"trap: address error (store)",
	"trap: bus error (fetch)",
	"trap: bus error (data load or store)",
	"trap: system call",
.
## diffname power/trap.c 1992/0108
## diff -e /n/bootesdump/1992/0102/sys/src/9/power/trap.c /n/bootesdump/1992/0108/sys/src/9/power/trap.c
547,548c
		if(notify(ur))
			return ur->r1;
.
426a
	return 1;
.
377c
		return 0;
.
367c
int
.
## diffname power/trap.c 1992/0111
## diff -e /n/bootesdump/1992/0108/sys/src/9/power/trap.c /n/bootesdump/1992/0111/sys/src/9/power/trap.c
8c
#include	"../port/error.h"
.
## diffname power/trap.c 1992/0120
## diff -e /n/bootesdump/1992/0111/sys/src/9/power/trap.c /n/bootesdump/1992/0120/sys/src/9/power/trap.c
566a
ulong
userpc(void)
{
	return ((Ureg*)UREGADDR)->pc;
}

.
## diffname power/trap.c 1992/0124
## diff -e /n/bootesdump/1992/0120/sys/src/9/power/trap.c /n/bootesdump/1992/0124/sys/src/9/power/trap.c
427c
	return sent;
.
398a
		sent = 1;
.
395a
	sent = 0;
.
370c
	int l, sent;
.
## diffname power/trap.c 1992/0319
## diff -e /n/bootesdump/1992/0124/sys/src/9/power/trap.c /n/bootesdump/1992/0319/sys/src/9/power/trap.c
361a
		prflush();
	}
.
360c
	for(i=0; i<sizeof regname/sizeof(char*); i+=2, l+=2){
.
344a
				prflush();
				delay(250);
			}
.
343c
			if(KTZERO < v && v < (ulong)&etext){
.
## diffname power/trap.c 1992/0320
## diff -e /n/bootesdump/1992/0319/sys/src/9/power/trap.c /n/bootesdump/1992/0320/sys/src/9/power/trap.c
345,346c
				delay(100);
.
## diffname power/trap.c 1992/0321
## diff -e /n/bootesdump/1992/0320/sys/src/9/power/trap.c /n/bootesdump/1992/0321/sys/src/9/power/trap.c
2c
#include	"../port/lib.h"
.
## diffname power/trap.c 1992/0325
## diff -e /n/bootesdump/1992/0321/sys/src/9/power/trap.c /n/bootesdump/1992/0325/sys/src/9/power/trap.c
301c
			if(0)
			print("bogus intr lvl 5 pend %lux on %d\n", npend, m->machno);
			USED(npend);
.
## diffname power/trap.c 1992/0407
## diff -e /n/bootesdump/1992/0325/sys/src/9/power/trap.c /n/bootesdump/1992/0407/sys/src/9/power/trap.c
554c
	if(r1!=FORK && (u->nnote || p->procctl)){
.
549,550c
	p->psstate = 0;
	p->insyscall = 0;
.
543c
		p->psstate = sysctab[r1];
.
537,540d
529c
			postnote(p, 1, msg, NDebug);
.
515c
		p->fpstate = FPinit;
.
513c
	if(p->fpstate == FPactive) {
.
505c
	p->pc = ur->pc;		/* BUG */
.
503c
	p = u->p;
	p->insyscall = 1;
.
500a
	Proc *p;
.
## diffname power/trap.c 1992/0409
## diff -e /n/bootesdump/1992/0407/sys/src/9/power/trap.c /n/bootesdump/1992/0409/sys/src/9/power/trap.c
553c
		ur->r1 = ret;				/* load up for noted() */
.
423a
		u->svr1 = ur->r1;			/* save away r1 */
.
## diffname power/trap.c 1992/0430
## diff -e /n/bootesdump/1992/0409/sys/src/9/power/trap.c /n/bootesdump/1992/0430/sys/src/9/power/trap.c
553c
	if(r1!=RFORK && (p->procctl || u->nnote)){
.
## diffname power/trap.c 1992/0508
## diff -e /n/bootesdump/1992/0430/sys/src/9/power/trap.c /n/bootesdump/1992/0508/sys/src/9/power/trap.c
193a
		LEDOFF(LEDclock);
.
192a
		LEDON(LEDclock);
.
## diffname power/trap.c 1992/0527
## diff -e /n/bootesdump/1992/0508/sys/src/9/power/trap.c /n/bootesdump/1992/0527/sys/src/9/power/trap.c
177a
	LEDOFF(ecode);
.
83a
	LEDON(ecode);
.
## diffname power/trap.c 1992/0612
## diff -e /n/bootesdump/1992/0527/sys/src/9/power/trap.c /n/bootesdump/1992/0612/sys/src/9/power/trap.c
602c
	if(g && g != novme && g != f)
.
## diffname power/trap.c 1992/0616
## diff -e /n/bootesdump/1992/0612/sys/src/9/power/trap.c /n/bootesdump/1992/0616/sys/src/9/power/trap.c
473,475d
468c
		if(!okaddr(nur->pc, 1, 0) || !okaddr(nur->usp, BY2WD, 0)){
.
419,421d
414,415c
		if(!okaddr((ulong)u->notify, 1, 0)
		|| !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0)){
			pprint("suicide: bad address in notify\n");
.
## diffname power/trap.c 1992/0625
## diff -e /n/bootesdump/1992/0616/sys/src/9/power/trap.c /n/bootesdump/1992/0625/sys/src/9/power/trap.c
542c

		ret = (*systab[r1])(u->s.args);
.
539,540c

		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs)))
			validaddr(sp, sizeof(Sargs), 0);

		u->s = *((Sargs*)(sp+BY2WD));
.
535,537c
			pprint("odd sp in sys call pc %lux sp %lux\n", ur->pc, ur->sp);
			postnote(p, 1, "sys: odd stack", NDebug);
			error(Ebadarg);
.
533a

.
527,531c
		if(r1 >= sizeof systab/sizeof systab[0]) {
			pprint("bad sys call number %d pc %lux\n", r1, ur->pc);
			postnote(p, 1, "sys: bad sys call", NDebug);
.
500d
## diffname power/trap.c 1992/06271
## diff -e /n/bootesdump/1992/0625/sys/src/9/power/trap.c /n/bootesdump/1992/06271/sys/src/9/power/trap.c
554c
	if(u->scallnr!=RFORK && (p->procctl || u->nnote)){
.
551c
	if(u->scallnr == NOTED)					/* ugly hack */
.
544c
		ret = (*systab[u->scallnr])(u->s.args);
.
542c
		p->psstate = sysctab[u->scallnr];
.
526,527c
		if(u->scallnr >= sizeof systab/sizeof systab[0]) {
			pprint("bad sys call number %d pc %lux\n", u->scallnr, ur->pc);
.
521c
	u->scallnr = ur->r1;
.
498d
## diffname power/trap.c 1992/0711
## diff -e /n/bootesdump/1992/06271/sys/src/9/power/trap.c /n/bootesdump/1992/0711/sys/src/9/power/trap.c
361d
## diffname power/trap.c 1992/0714
## diff -e /n/bootesdump/1992/0711/sys/src/9/power/trap.c /n/bootesdump/1992/0714/sys/src/9/power/trap.c
399c
		if(n->flag == NDebug)
.
## diffname power/trap.c 1992/0802
## diff -e /n/bootesdump/1992/0714/sys/src/9/power/trap.c /n/bootesdump/1992/0802/sys/src/9/power/trap.c
603c
 * from devproc and then restore the saved values before returning
.
170a
    Return:
.
162c
				print("fp: %s FCR31 %lux\n", fpexcname(fcr31), fcr31);
.
154c
				sprint(buf, "sys: fp: %s FCR31 %lux", fpexcname(fcr31), fcr31);
.
101,102d
96a
					goto Default;
.
95c
					fcr31 = clrfpintr();
					if(user && fptrap(ur, fcr31))
						goto Return;
.
82c
	SET(fcr31);
.
78,79c
	int user, x;
	ulong fcr31;
.
## diffname power/trap.c 1992/0803
## diff -e /n/bootesdump/1992/0802/sys/src/9/power/trap.c /n/bootesdump/1992/0803/sys/src/9/power/trap.c
551c
	if(u->scallnr == NOTED)				/* ugly hack */
.
548d
544a
		poperror();
.
520a
	if(p->procctl)
		procctl(p);

.
335,337c
	if(fcr31 & (1<<17))
		return "unimplemented operation";
	fcr31 >>= 7;		/* trap enable bits */
	fcr31 &= (fcr31>>5);	/* anded with exceptions */
	for(i=0; i<5; i++)
		if(fcr31 & (1<<i))
.
331d
322,323c
char*
fpexcname(ulong fcr31)
.
149c
		 * This isn't good enough; can still deadlock because we may
.
46c
	"trap: floating point exception"	/* FPEXC */
.
44c
	"trap: undefined 15",			/* used as sys call for debugger */
.
## diffname power/trap.c 1992/0805
## diff -e /n/bootesdump/1992/0803/sys/src/9/power/trap.c /n/bootesdump/1992/0805/sys/src/9/power/trap.c
576a
	u->fpsave.fpstatus = initfp.fpstatus;
.
508c
	p->pc = ur->pc;
.
89c

.
86,87c
	if(u)
.
## diffname power/trap.c 1992/0806
## diff -e /n/bootesdump/1992/0805/sys/src/9/power/trap.c /n/bootesdump/1992/0806/sys/src/9/power/trap.c
399c
		sprint(n->msg+l, " pc=0x%lux", ur->pc);
.
334,340c
		s = "unimplemented operation";
	else{
		fcr31 >>= 7;		/* trap enable bits */
		fcr31 &= (fcr31>>5);	/* anded with exceptions */
		for(i=0; i<5; i++)
			if(fcr31 & (1<<i))
				s = str[i];
	}
	if(s == 0)
		return "no floating point exception";
	sprint(buf, "%s fppc=0x%lux", s, fppc);
	return buf;
.
332a
	fppc = ur->pc;
	if(ur->cause & (1<<31))	/* branch delay */
		fppc += 4;
	s = 0;
.
331a
	char *s;
	ulong fppc;
.
322c
fpexcname(Ureg *ur, ulong fcr31, char *buf)
.
162c
				print("fp: %s\n", fpexcname(ur, fcr31, buf1));
.
154c
				sprint(buf, "sys: fp: %s", fpexcname(ur, fcr31, buf1));
.
80c
	char buf[2*ERRLEN], buf1[ERRLEN];
.
48c
char	*fpexcname(Ureg*, ulong, char*);
.
## diffname power/trap.c 1992/0813
## diff -e /n/bootesdump/1992/0806/sys/src/9/power/trap.c /n/bootesdump/1992/0813/sys/src/9/power/trap.c
166c
			exit(1);
.
163a
			dumpstack();
.
## diffname power/trap.c 1992/1105
## diff -e /n/bootesdump/1992/0813/sys/src/9/power/trap.c /n/bootesdump/1992/1105/sys/src/9/power/trap.c
383,384c
		iprint("%s\t%.8lux\t%s\t%.8lux\n", regname[i], l[0], regname[i+1], l[1]);
/*		prflush();/**/
.
380c
		iprint("registers for kernel\n");
.
378c
		iprint("registers for %s %d\n", u->p->text, u->p->pid);
.
## diffname power/trap.c 1992/1124
## diff -e /n/bootesdump/1992/1105/sys/src/9/power/trap.c /n/bootesdump/1992/1124/sys/src/9/power/trap.c
383,384c
		print("%s\t%.8lux\t%s\t%.8lux\n", regname[i], l[0], regname[i+1], l[1]);
		prflush();
.
380c
		print("registers for kernel\n");
.
378c
		print("registers for %s %d\n", u->p->text, u->p->pid);
.
## diffname power/trap.c 1992/1128
## diff -e /n/bootesdump/1992/1124/sys/src/9/power/trap.c /n/bootesdump/1992/1128/sys/src/9/power/trap.c
571c
		ur->r1 = ret;			/* load up for noted() */
.
452c
	return 1;
.
449a
		
	if(!u->notify) {
		qunlock(&u->p->debug);
		pexit(n->msg, n->flag!=NDebug);
	}
	u->svstatus = ur->status;
	sp = ur->usp;
	sp -= sizeof(Ureg);

	if(sp&0x3 || !okaddr((ulong)u->notify, 1, 0)
	|| !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0)){
		pprint("suicide: bad address or sp in notify\n");
		qunlock(&u->p->debug);
		pexit("Suicide", 0);
	}
	u->ureg = (void*)sp;
	memmove((Ureg*)sp, ur, sizeof(Ureg));
	sp -= ERRLEN;
	memmove((char*)sp, u->note[0].msg, ERRLEN);
	sp -= 3*BY2WD;
	*(ulong*)(sp+2*BY2WD) = sp+3*BY2WD;	/* arg 2 is string */
	u->svr1 = ur->r1;			/* save away r1 */
	ur->r1 = (ulong)u->ureg;		/* arg 1 is ureg* */
	*(ulong*)(sp+0*BY2WD) = 0;		/* arg 0 is pc */
	ur->usp = sp;
	ur->pc = (ulong)u->notify;
	u->notified = 1;
	u->nnote--;
	memmove(&u->lastnote, &u->note[0], sizeof(Note));
	memmove(&u->note[0], &u->note[1], u->nnote*sizeof(Note));

.
420,448c

	if(u->notified) {
		qunlock(&u->p->debug);
		splx(s);
		return 0;
.
416c

.
412a

.
410a

.
317a

	if(cause & (INTR2|INTR4)){
		LEDON(LEDclock);
		clock(ur);
		LEDOFF(LEDclock);
		cause &= ~(INTR2|INTR4);
	}

.
261,262c
				print("ioberr %lux %lux\n", *MPBERR0, *MPBERR1);
				print("PC %lux R31 %lux\n", ur->pc, ur->r31);
.
209a
			print("PC %lux R31 %lux\n", ur->pc, ur->r31);
.
205a

.
196,201c

.
180a
*LED=~0;
.
179a
*LED=~17;
.
174a
*LED=~16;
.
173a
*LED=~15;
.
172d
169a
*LED=~14;
.
168a
		print("kernel %s pc=%lux\n", excname[ecode], ur->pc);
		dumpregs(ur);
		dumpstack();
		if(m->machno == 0)
			spllo();
		exit(1);
.
159,167c
			break;
.
153,157c
			sprint(buf, "sys: %s", excname[ecode]);
.
141,151c
		if(user) {
.
132,138c
*LED=~13;
		/* Fallthrough */
.
126,130c
*LED=~12;
		cop = (ur->cause>>28)&3;
		if(u && cop == 1) {
			if(u->p->fpstate == FPinit) {
				restfpregs(&initfp, u->fpsave.fpstatus);
				u->p->fpstate = FPactive;
				ur->status |= CU1;
				break;
			}
			if(u->p->fpstate == FPinactive) {
				restfpregs(&u->fpsave, u->fpsave.fpstatus);
				u->p->fpstate = FPactive;
				ur->status |= CU1;
				break;
			}
.
122a
*LED=~11;
.
113,117c
*LED=~10;
.
110a
*LED=~9;
.
105a
*LED=~8;
.
103a
*LED=~7;
.
91,102c
*LED=~4;
		if(ur->cause&INTR3) {			/* FP trap */
*LED=~5;
			if(u == 0 || u->p->fpstate != FPinactive)
				panic("fp intr3 no u or not inactive pc=%lux", ur->pc);

			fcr31 = clrfpintr();
			if(user == 0)
				panic("kernel floating point trap pc=%lux", ur->pc);
*LED=~6;

			ur->cause &= ~INTR3;
			if(!fptrap(ur, fcr31)) {
				intr(ur);
				spllo();
				fpexcep	= fpexcname(ur, fcr31, buf1);
				sprint(buf, "sys: fp: %s", fpexcep);
				postnote(u->p, 1, buf, NDebug);
				break;
.
88a
	if(u && u->p->fpstate == FPactive) {
		savefpregs(&u->fpsave);
		u->p->fpstate = FPinactive;
		ur->status &= ~CU1;
	}
*LED=~3;

.
87a
*LED=~2;
.
80,82c
	char buf[2*ERRLEN], buf1[ERRLEN], *fpexcep;
*LED=~1;
.
78c
	int user, cop, x;
.
## diffname power/trap.c 1992/1129
## diff -e /n/bootesdump/1992/1128/sys/src/9/power/trap.c /n/bootesdump/1992/1129/sys/src/9/power/trap.c
589a

.
552a

.
548a
		if((ur->status&CU1) == 0)
			panic("syscall: FPactive but no CU1");
.
510d
504c
			pexit("Suicide", 0);
.
499c
	switch(arg0) {
.
494c
		pexit("Suicide", 0);
.
491c
	if(!u->notified) {
.
487d
485c
	if(nur->status!=u->svstatus) {
.
472c
	splhi();
.
454a

.
449,450c
	if(sp&0x3 || !okaddr((ulong)u->notify, BY2WD, 0)
	|| !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 1)) {
.
446,447c
	sp = ur->usp - sizeof(Ureg);
.
437c
		splhi();
.
427c
	if(n->flag != NUser && (u->notified || u->notify==0)) {
.
419c
	if(strncmp(n->msg, "sys:", 4) == 0) {
.
415c
	spllo();
.
406,407c
	int l;
	ulong sp;
.
400,402d
392a

.
380a
	}
.
373,379c
	if(u == 0)
		return;

	for(l=(ulong)&l; l<USERADDR+BY2PG; l+=4){
		v = *(ulong*)l;
		if(KTZERO < v && v < (ulong)&etext){
			print("%lux=%lux\n", l, v);
			delay(100);
.
362a

.
359c
				s = fpcause[i];
.
337,343d
323c
	if(cause & (INTR2|INTR4)) {
.
187,188c

	splhi();
	if(!user)
		return;

	notify(ur);
	if(u->p->fpstate == FPinactive) {
		restfpregs(&u->fpsave, u->fpsave.fpstatus&~FPEXPMASK);
		u->p->fpstate = FPactive;
		ur->status |= CU1;
	}
.
185d
175,183c
	if(fpchk) {
		fcr31 = u->fpsave.fpstatus;
		if((fcr31>>12) & ((fcr31>>7)|0x20) & 0x3f) {
			spllo();
			fpexcep	= fpexcname(ur, fcr31, buf1);
			sprint(buf, "sys: fp: %s", fpexcep);
			postnote(u->p, 1, buf, NDebug);
.
173d
156d
154d
149,152c
			if(u->p->fpstate == FPinactive)
.
144,146c
				u->p->fpstate = FPinactive;
				fcr31 = u->fpsave.fpstatus;
				u->fpsave = initfp;
				u->fpsave.fpstatus = fcr31;
.
142c
		if(user && u && cop == 1) {
.
140d
136d
130c

.
127d
121d
110,118d
100,108c
			clrfpintr();
.
98d
94d
92a
		savefpregs(&u->fpsave);
		fptrap(ur);
		fpchk = 1;
.
90c
		if((ur->status&CU1) == 0)		/* Paranoid */
			panic("FPactive but no CU1");
.
88a
	fpchk = 0;
.
87d
85c
	if(user)
.
81,83c

	ecode = (ur->cause>>2)&0xf;
.
79a
	int user, cop, x, fpchk;
.
78d
72,73d
48a
#define FPEXPMASK	(0x3f<<12)		/* Floating exception bits in fcr31 */
.
47a

char *fpcause[] =
{
	"inexact operation",
	"underflow",
	"overflow",
	"division by zero",
	"invalid operation",
};
.
45,46d
18,26d
14d
10,12d
## diffname power/trap.c 1992/1130
## diff -e /n/bootesdump/1992/1129/sys/src/9/power/trap.c /n/bootesdump/1992/1130/sys/src/9/power/trap.c
529a
	sp = ur->sp;
.
528d
508,513c
	ur->cause = 15<<2;		/* for debugging: system call is undef 15; */

.
453c
	if(nur->status != u->svstatus) {
.
173a
	uchar pend, npend, xxx;
.
171a
	int i, any;
.
168,170d
108a

		spllo();
.
106d
## diffname power/trap.c 1992/1201
## diff -e /n/bootesdump/1992/1130/sys/src/9/power/trap.c /n/bootesdump/1992/1201/sys/src/9/power/trap.c
285d
## diffname power/trap.c 1992/1202
## diff -e /n/bootesdump/1992/1201/sys/src/9/power/trap.c /n/bootesdump/1992/1202/sys/src/9/power/trap.c
74a
m->ur = ur;

.
## diffname power/trap.c 1992/1208
## diff -e /n/bootesdump/1992/1202/sys/src/9/power/trap.c /n/bootesdump/1992/1208/sys/src/9/power/trap.c
418c
	|| !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN+3*BY2WD, 1)) {
.
263c
					scsiintr(0);
.
261c
					scsiintr(1);
.
## diffname power/trap.c 1992/1209
## diff -e /n/bootesdump/1992/1208/sys/src/9/power/trap.c /n/bootesdump/1992/1209/sys/src/9/power/trap.c
295c
		if(any == 0)
			cause &= ~INTR5;
.
284,291d
185c
	while(cause & INTR5) {
.
## diffname power/trap.c 1992/1217
## diff -e /n/bootesdump/1992/1209/sys/src/9/power/trap.c /n/bootesdump/1992/1217/sys/src/9/power/trap.c
230d
212d
175c
	uchar pend, xxx;
.
## diffname power/trap.c 1993/0106
## diff -e /n/bootesdump/1992/1217/sys/src/9/power/trap.c /n/bootesdump/1993/0106/sys/src/9/power/trap.c
118c
		if(user && cop == 1) {
.
83,90c
	if(user) {
		u->dbgreg = ur;
		if(u->p->fpstate == FPactive) {
			if((ur->status&CU1) == 0)		/* Paranoid */
				panic("FPactive but no CU1");
			u->p->fpstate = FPinactive;
			ur->status &= ~CU1;
			savefpregs(&u->fpsave);
			fptrap(ur);
			fpchk = 1;
		}
.
79,81d
## diffname power/trap.c 1993/0107
## diff -e /n/bootesdump/1993/0106/sys/src/9/power/trap.c /n/bootesdump/1993/0107/sys/src/9/power/trap.c
162c
		restfpregs(&u->fpsave, u->fpsave.fpstatus);
.
## diffname power/trap.c 1993/0211
## diff -e /n/bootesdump/1993/0107/sys/src/9/power/trap.c /n/bootesdump/1993/0211/sys/src/9/power/trap.c
292d
290d
287a
	if(limit == 0) {
		print("intr: unable to identify and clear level5\n");
		cause &= ~INTR5;
	}
.
185c
	for(limit = 50; (cause&INTR5) && limit; limit--) {
.
172c
	int i, any, limit;
.
## diffname power/trap.c 1993/0212
## diff -e /n/bootesdump/1993/0211/sys/src/9/power/trap.c /n/bootesdump/1993/0212/sys/src/9/power/trap.c
290a
		LEDOFF(LED5);
.
288a
		LEDON(LED5);
.
## diffname power/trap.c 1993/0225
## diff -e /n/bootesdump/1993/0212/sys/src/9/power/trap.c /n/bootesdump/1993/0225/sys/src/9/power/trap.c
426c
	ur->r1 = (ulong)u->ureg;		/* arg 1 (R1) is ureg* */
	*(ulong*)(sp+1*BY2WD) = (ulong)u->ureg;	/* arg 1 0(FP) is ureg* */
.
## diffname power/trap.c 1993/0501
## diff -e /n/bootesdump/1993/0225/sys/src/9/power/trap.c /n/fornaxdump/1993/0501/sys/src/brazil/power/trap.c
605,606c
/* This routine must save the values of registers the user is not permitted to
 * write from devproc and then restore the saved values before returning
.
579c
	Ureg *ur;

	ur = (Ureg*)up->dbgreg;
	return ur->pc;
.
570,572c

	ur = (Ureg*)up->dbgreg;
	ur->usp = (ulong)sp;
	ur->pc = entry - 4;			/* syscall advances it */
	up->fpsave.fpstatus = initfp.fpstatus;
.
565a
	Ureg *ur;
.
562a
void
forkchild(Proc *p, Ureg *ur)
{
	Ureg *cur;

	p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Ureg)+2*BY2WD);
	p->sched.pc = (ulong)forkret;

	cur = (Ureg*)(p->sched.sp+2*BY2WD);
	memmove(cur, ur, sizeof(Ureg));

	cur->pc += 4;

	/* Things from bottom of syscall we never got to execute */
	p->psstate = 0;
	p->insyscall = 0;
}

static
void
linkproc(void)
{
	spllo();
	(*up->kpfun)(up->kparg);
}

void
kprocchild(Proc *p, void (*func)(void*), void *arg)
{
	p->sched.pc = (ulong)linkproc;
	p->sched.sp = (ulong)p->kstack+KSTACK;

	p->kpfun = func;
	p->kparg = arg;
}

.
554c
	if(up->scallnr!=RFORK && (up->procctl || up->nnote)){
.
547,550c
	up->nerrlab = 0;
	up->psstate = 0;
	up->insyscall = 0;
	if(up->scallnr == NOTED)			/* ugly hack */
.
543c
		ret = (*systab[up->scallnr])(up->s.args);
.
540,541c
		up->s = *((Sargs*)(sp+BY2WD));
		up->psstate = sysctab[up->scallnr];
.
537c
		if(sp < (USTKTOP-BY2PG) || sp > (USTKTOP-sizeof(Sargs)))
.
533c
			postnote(up, 1, "sys: odd stack", NDebug);
.
525,527c
		if(up->scallnr >= sizeof systab/sizeof systab[0]) {
			pprint("bad sys call number %d pc %lux\n",
						up->scallnr, ur->pc);
			postnote(up, 1, "sys: bad sys call", NDebug);
.
520,521c
	up->scallnr = ur->r1;
	up->nerrlab = 0;
.
517,518c
	if(up->procctl)
		procctl(up);
.
510,511c
		up->fpsave.fpstatus = fcr31();
		up->fpstate = FPinit;
.
507c
	if(up->fpstate == FPactive) {
.
503,505c
	up->pc = ur->pc;
	up->dbgreg = aur;
	ur->cause = 15<<2;	/* for debugging: system call is undef 15; */
.
500,501c
	up->insyscall = 1;
.
497d
481,484c
		if(up->lastnote.flag == NDebug)
			pprint("suicide: %s\n", up->lastnote.msg);
		qunlock(&up->debug);
		pexit(up->lastnote.msg, up->lastnote.flag != NDebug);
.
477c
		up->lastnote.flag = NDebug;
.
471c
		qunlock(&up->debug);
.
467c
			qunlock(&up->debug);
.
460,462c
	up->notified = 0;
	memmove(*urp, up->ureg, sizeof(Ureg));
	(*urp)->r1 = up->svr1;
.
454,456c
	qlock(&up->debug);
	if(!up->notified) {
		qunlock(&up->debug);
.
449,450c
	nur = up->ureg;
	if(nur->status != up->svstatus) {
.
436c
	qunlock(&up->debug);
.
430,434c
	ur->pc = (ulong)up->notify;
	up->notified = 1;
	up->nnote--;
	memmove(&up->lastnote, &up->note[0], sizeof(Note));
	memmove(&up->note[0], &up->note[1], up->nnote*sizeof(Note));
.
425,427c
	up->svr1 = ur->r1;			/* save away r1 */
	ur->r1 = (ulong)up->ureg;		/* arg 1 is ureg* */
.
422c
	memmove((char*)sp, up->note[0].msg, ERRLEN);
.
419c
	up->ureg = (void*)sp;
.
415c
		qunlock(&up->debug);
.
412c
	if(sp&0x3 || !okaddr((ulong)up->notify, BY2WD, 0)
.
409c
	up->svstatus = ur->status;
.
405,406c
	if(!up->notify) {
		qunlock(&up->debug);
.
399,400c
	if(up->notified) {
		qunlock(&up->debug);
.
395c
		qunlock(&up->debug);
.
391c
	if(n->flag != NUser && (up->notified || up->notify==0)) {
.
380,382c
	qlock(&up->debug);
	up->notepending = 0;
	n = &up->note[0];
.
374,376c
	if(up->procctl)
		procctl(up);
	if(up->nnote == 0)
.
361,362c
	for(i=0; i<sizeof regname/sizeof(char*); i+=2) {
		print("%s\t%.8lux\t%s\t%.8lux\n",
			regname[i], l[0], regname[i+1], l[1]);
		l += 2;
.
355,356c
	if(up)
		print("registers for %s %d\n", up->text, up->pid);
.
342c
		if(KTZERO < v && v < (ulong)&etext) {
.
340c
	top = (ulong)up->kstack + KSTACK;
	for(l=(ulong)&l; l < top; l += BY2WD) {
.
337c
	if(up == 0)
.
334c
	ulong l, v, top;
.
301c
		panic("cause %lux %lux\n", up, cause);
.
296a
		LEDOFF(LEDclock);
.
295a
		LEDON(LEDclock);
.
288,293d
185c
	while(cause & INTR5) {
.
172c
	int i, any;
.
161,163c
	if(up->fpstate == FPinactive) {
		restfpregs(&up->fpsave, up->fpsave.fpstatus);
		up->fpstate = FPactive;
.
152c
			postnote(up, 1, buf, NDebug);
.
147c
		fcr31 = up->fpsave.fpstatus;
.
135c
			postnote(up, 1, buf, NDebug);
.
126c
			if(up->fpstate == FPinactive)
.
119,123c
			if(up->fpstate == FPinit) {
				up->fpstate = FPinactive;
				fcr31 = up->fpsave.fpstatus;
				up->fpsave = initfp;
				up->fpsave.fpstatus = fcr31;
.
113c
		up->insyscall = x;
.
108,109c
		x = up->insyscall;
		up->insyscall = 1;
.
105,106c
		if(up == 0)
			panic("kfault pc %lux addr %lux", ur->pc, ur->badvaddr);
.
92d
87c
			savefpregs(&up->fpsave);
.
85c
			up->fpstate = FPinactive;
.
81,82c
		up->dbgreg = ur;
		if(up->fpstate == FPactive) {
.
78a
	ecode = (ur->cause>>2)&0xf;

.
75,77d
72c
	int user, cop, x, fpchk, ecode;
.
70d
45,64c
char*
regname[]=
{
	"STATUS", "PC",	"SP", "CAUSE",
	"BADADDR", "TLBVIRT", "HI", "LO",
	"R31",	"R30",	"R28",	"R27",
	"R26",	"R25",	"R24",	"R23",
	"R22",	"R21",	"R20",	"R19",
	"R18",	"R17",	"R16",	"R15",
	"R14",	"R13",	"R12",	"R11",
	"R10",	"R9",	"R8",	"R7",
	"R6",	"R5",	"R4",	"R3",
	"R2",	"R1"
.
43c
#define FPEXPMASK	(0x3f<<12)	/* Floating exception bits in fcr31 */
.
31c
	"trap: undefined 15",		/* used as sys call for debugger */
.
## diffname power/trap.c 1993/0806
## diff -e /n/fornaxdump/1993/0501/sys/src/brazil/power/trap.c /n/fornaxdump/1993/0806/sys/src/brazil/power/trap.c
251a
*/
.
247a
/*
.
## diffname power/trap.c 1993/0818
## diff -e /n/fornaxdump/1993/0806/sys/src/brazil/power/trap.c /n/fornaxdump/1993/0818/sys/src/brazil/power/trap.c
82a

.
## diffname power/trap.c 1993/1008
## diff -e /n/fornaxdump/1993/0818/sys/src/brazil/power/trap.c /n/fornaxdump/1993/1008/sys/src/brazil/power/trap.c
418a
	*(ulong*)(sp+1*BY2WD) = (ulong)up->ureg;/* arg 1 0(FP) is ureg* (for Alef) */
.
## diffname power/trap.c 1993/1022
## diff -e /n/fornaxdump/1993/1008/sys/src/brazil/power/trap.c /n/fornaxdump/1993/1022/sys/src/brazil/power/trap.c
649a

/* Give enough context in the ureg to produce a kernel stack for
 * a sleeping process
 */
void
setkernur(Ureg *xp, Proc *p)
{
	xp->pc = p->sched.pc;
	xp->sp = p->sched.sp;
	xp->r31 = (ulong)sched;
}
.
## diffname power/trap.c 1993/1201
## diff -e /n/fornaxdump/1993/1022/sys/src/brazil/power/trap.c /n/fornaxdump/1993/1201/sys/src/brazil/power/trap.c
520a
		up->syscall[up->scallnr]++;
.
## diffname power/trap.c 1994/0407
## diff -e /n/fornaxdump/1993/1201/sys/src/brazil/power/trap.c /n/fornaxdump/1994/0407/sys/src/brazil/power/trap.c
515c
		if(up->scallnr >= nsyscall) {
.
## diffname power/trap.c 1994/0513
## diff -e /n/fornaxdump/1994/0407/sys/src/brazil/power/trap.c /n/fornaxdump/1994/0513/sys/src/brazil/power/trap.c
452a

	nur = up->ureg;
	if(nur->status != up->svstatus) {
		qunlock(&up->debug);
		pprint("bad noted ureg status %lux\n", nur->status);
		pexit("Suicide", 0);
	}

.
441,445d
## diffname power/trap.c 1995/0108
## diff -e /n/fornaxdump/1994/0513/sys/src/brazil/power/trap.c /n/fornaxdump/1995/0108/sys/src/brazil/power/trap.c
524d
## diffname power/trap.c 1995/02021
## diff -e /n/fornaxdump/1995/0108/sys/src/brazil/power/trap.c /n/fornaxdump/1995/02021/sys/src/brazil/power/trap.c
545c
		noted(ur, &aur, *(ulong*)(sp+BY2WD));	/* doesn't return */
.
469a
	case NSAVE:
		if(!okaddr(nur->pc, BY2WD, 0) || !okaddr(nur->usp, BY2WD, 0)){
			pprint("suicide: trap in noted\n");
			qunlock(&up->debug);
			pexit("Suicide", 0);
		}
		qunlock(&up->debug);
		sp = oureg-4*BY2WD-ERRLEN;
		splhi();
		(*urp)->sp = sp;
		((ulong*)sp)[1] = oureg;	/* arg 1 0(FP) is ureg* */
		((ulong*)sp)[0] = 0;			/* arg 0 is pc */
		(*urp)->r1 = oureg;		/* arg 1 is ureg* */
		rfnote(urp);
		break;

.
459a
	case NRSTR:
.
457d
451a
		pexit("Suicide", 0);
	}

	if(!validstatus(kur->status, nur->status)) {
		qunlock(&up->debug);
.
450c

	oureg = (ulong)nur;
	if((oureg & (BY2WD-1))
	|| !okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
		pprint("bad ureg in noted or call to noted() when not notified\n");
.
442c
	if(arg0!=NRSTR && !up->notified) {
.
439a
	ulong oureg, sp;
.
437c
noted(Ureg *kur, Ureg **urp, ulong arg0)
.
433a
 * Check that status is OK to return from note.
 */
int
validstatus(ulong kstatus, ulong ustatus)
{
	if((kstatus & INTMASK) != (ustatus & INTMASK))
		return 0;
	if((ustatus&(KUO|IEO|KUP|IEP|KUC|IE)) != (KUP|IEP))
		return 0;
	if(ustatus & (0xFFFF0000&~(CU1|CM|PE)))	/* no CU3, CU2, CU0, BEV, TS, PZ, SWC, ISC */
		return 0;
	return 1;
}

/*
.
417d
413c
	*(Ureg**)(sp-BY2WD) = up->ureg;	/* word under Ureg is old up->ureg */
	up->ureg = (void*)sp;
	sp -= BY2WD+ERRLEN;
.
411d
404,405c
	if(sp&(BY2WD-1) || !okaddr((ulong)up->notify, BY2WD, 0)
	|| !okaddr(sp-ERRLEN-4*BY2WD, sizeof(Ureg)+ERRLEN+4*BY2WD, 1)) {
.
401d
11c
void	noted(Ureg*, Ureg**, ulong);
.
## diffname power/trap.c 1995/1024
## diff -e /n/fornaxdump/1995/02021/sys/src/brazil/power/trap.c /n/fornaxdump/1995/1024/sys/src/brazil/power/trap.c
703a

ulong
dbgpc(Proc *p)
{
	Ureg *ur;

	ur = p->dbgreg;
	if(ur == 0)
		return 0;

	return ur->pc;
}
.
## diffname power/trap.c 1997/0327 # deleted
## diff -e /n/fornaxdump/1995/1024/sys/src/brazil/power/trap.c /n/emeliedump/1997/0327/sys/src/brazil/power/trap.c
1,715d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.