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

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


## diffname carrera/trap.c 1993/0903
## diff -e /dev/null /n/fornaxdump/1993/0903/sys/src/brazil/carrera/trap.c
0a
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"ureg.h"
#include	"io.h"
#include	"../port/error.h"

void	noted(Ureg**, ulong);
void	rfnote(Ureg**);
void	kernfault(Ureg*, int);

char *excname[] =
{
	"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",
	"breakpoint",
	"trap: reserved instruction",
	"trap: coprocessor unusable",
	"trap: arithmetic overflow",
	"trap: TRAP exception",
	"trap: VCE (instruction)",
	"trap: floating-point exception",
	"trap: undefined 16",	/* used as sys call for debugger */
	"trap: undefined 17",
	"trap: undefined 18",
	"trap: undefined 19",
	"trap: undefined 20",
	"trap: undefined 21",
	"trap: undefined 22",
	"trap: WATCH exception",
	"trap: undefined 24",
	"trap: undefined 25",
	"trap: undefined 26",
	"trap: undefined 27",
	"trap: undefined 28",
	"trap: undefined 29",
	"trap: undefined 30",
	"trap: VCE (data)",
};

char *fpcause[] =
{
	"inexact operation",
	"underflow",
	"overflow",
	"division by zero",
	"invalid operation",
};
char	*fpexcname(Ureg*, ulong, char*);
#define FPEXPMASK	(0x3f<<12)		/* Floating exception bits in fcr31 */


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",
};

static char *
ptlb(ulong phys)
{
	static char buf[4][32];
	static int k;
	char *p;

	k = (k+1)&3;
	p = buf[k];
	p += sprint(p, "(0x%ux %d ", (phys<<6) & ~(BY2PG-1), (phys>>3)&7);
	if(phys & 4)
		*p++ = 'd';
	if(phys & 2)
		*p++ = 'v';
	if(phys & 1)
		*p++ = 'g';
	*p++ = ')';
	*p = 0;
	return buf[k];
}

static void
kpteprint(Ureg *ur)
{
	ulong i, tlbstuff[3];
	KMap *k;

	i = (ur->badvaddr & ~(2*BY2PG-1)) | TLBPID(tlbvirt());
	print("tlbvirt=0x%ux\n", i);
	i = gettlbp(i, tlbstuff);
	print("i=%d v=0x%ux p0=%s p1=%s\n",
		i, tlbstuff[0], ptlb(tlbstuff[1]), ptlb(tlbstuff[2]));

	i = (ur->badvaddr & ~KMAPADDR)>>15;
	if(i > KPTESIZE){
		print("kpte index = 0x%ux ?\n", i);
		return;
	}
	k = &kpte[i];
	print("i=%d, &k=0x%ux, k={v=0x%ux, p0=%s, p1=%s, pg=0x%ux}\n",
		i, k, k->virt, ptlb(k->phys0), ptlb(k->phys1), k->pg);
	print("pg={pa=0x%ux, va=0x%ux}\n", k->pg->pa, k->pg->va);
}

void
kvce(Ureg *ur, int ecode)
{
	char c;
	Pte **p;
	Page **pg;
	Segment *s;
	ulong addr, soff;

	c = 'D';
	if(ecode == CVCEI)
		c = 'I';
	print("Trap: VCE%c: addr=0x%ux\n", c, ur->badvaddr);
	if((ur->badvaddr & KSEGM) == KSEG3) {
		kpteprint(ur);
		return;
	}
	if(up && !(ur->badvaddr & KSEGM)) {
		addr = ur->badvaddr;
		s = seg(up, addr, 0);
		if(s == 0){
			print("no s\n");
			for(;;);
		}
		addr &= ~(BY2PG-1);
		soff = addr-s->base;
		p = &s->map[soff/PTEMAPMEM];
		if(*p){
			pg = &(*p)->pages[(soff&(PTEMAPMEM-1))/BY2PG];
			if(*pg) {
				print("pa=0x%ux, va=0x%ux\n",
					(*pg)->pa, (*pg)->va);
			} else
				print("no *pg\n");
		}else
			print("no *p\n");
	}
}

void
trap(Ureg *ur)
{
	int ecode;
	ulong fpfcr31;
	int user, cop, x, fpchk;
	char buf[2*ERRLEN], buf1[ERRLEN], *fpexcep;

	ecode = (ur->cause>>2)&EXCMASK;
	user = ur->status&KUSER;

	fpchk = 0;
	if(user){
		up->dbgreg = ur;
		if(up && up->fpstate == FPactive) {
			if((ur->status&CU1) == 0)		/* Paranoid */
				panic("FPactive but no CU1");
			ur->status &= ~CU1;
			up->fpstate = FPinactive;
			savefpregs(&up->fpsave);
		}
	}

	switch(ecode){
	case CINT:
		intr(ur);
		break;

	case CFPE:
		fptrap(ur);
		clrfpintr();
		fpchk = 1;
		break;

	case CTLBM:
	case CTLBL:
	case CTLBS:
		if(up == 0)
			kernfault(ur, ecode);

		if(!user && (ur->badvaddr & KSEGM) == KSEG3) {
			kfault(ur->badvaddr);
			break;
		}

		x = up->insyscall;
		up->insyscall = 1;
		spllo();
		faultmips(ur, user, ecode);
		up->insyscall = x;
		break;

	case CVCEI:
	case CVCED:
		kvce(ur, ecode);
		goto Default;

	case CCPU:
		cop = (ur->cause>>28)&3;
		if(user && up && cop == 1) {
			if(up->fpstate == FPinit) {
				up->fpstate = FPinactive;
				fpfcr31 = up->fpsave.fpstatus;
				up->fpsave = initfp;
				up->fpsave.fpstatus = fpfcr31;
				break;
			}
			if(up->fpstate == FPinactive)
				break;
		}
		/* Fallthrough */

	Default:
	default:
		if(user) {
			spllo();
			sprint(buf, "sys: %s", excname[ecode]);
			postnote(up, 1, buf, NDebug);
			break;
		}
		print("kernel%d %s pc=%lux\n", m->machno, excname[ecode], ur->pc);
		dumpregs(ur);
		dumpstack();
		if(m->machno == 0)
			spllo();
		exit(1);
	}

	if(fpchk) {
		fpfcr31 = up->fpsave.fpstatus;
		if((fpfcr31>>12) & ((fpfcr31>>7)|0x20) & 0x3f) {
			spllo();
			fpexcep	= fpexcname(ur, fpfcr31, buf1);
			sprint(buf, "sys: fp: %s", fpexcep);
			postnote(up, 1, buf, NDebug);
		}
	}


	splhi();
	if(!user)
		return;

	notify(ur);
	if(up->fpstate == FPinactive) {
		restfpregs(&up->fpsave, up->fpsave.fpstatus&~FPEXPMASK);
		up->fpstate = FPactive;
		ur->status |= CU1;
	}
}

void
intr(Ureg *ur)
{
	ulong cause = ur->cause;

	m->intr++;
	cause &= INTR7|INTR6|INTR5|INTR4|INTR3|INTR2|INTR1|INTR0;

	iprint("intr %lux\n", cause);
}

char*
fpexcname(Ureg *ur, ulong fcr31, char *buf)
{
	int i;
	char *s;
	ulong fppc;

	fppc = ur->pc;
	if(ur->cause & (1<<31))	/* branch delay */
		fppc += 4;
	s = 0;
	if(fcr31 & (1<<17))
		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 = fpcause[i];
	}

	if(s == 0)
		return "no floating point exception";

	sprint(buf, "%s fppc=0x%lux", s, fppc);
	return buf;
}

#define KERNPC(x)	(KTZERO<(ulong)(x)&&(ulong)(x)<(ulong)&etext)

void
kernfault(Ureg *ur, int code)
{
	print("panic: kfault %s badvaddr=0x%lux\n", excname[code], ur->badvaddr);
	kpteprint(ur);
	print("u=0x%lux status=0x%lux pc=0x%lux sp=0x%lux\n",
				up, ur->status, ur->pc, ur->sp);
	panic("kfault");
}

void
dumpstack(void)
{
	ulong l, v, top;
	extern ulong etext;

	if(up == 0)
		return;

	top = (ulong)up->kstack + KSTACK;
	for(l=(ulong)&l; l < top; l += BY2WD) {
		v = *(ulong*)l;
		if(KTZERO < v && v < (ulong)&etext) {
			print("%lux=%lux\n", l, v);
			delay(100);
		}
	}
}

void
dumpregs(Ureg *ur)
{
	int i;
	ulong *l;
	if(up)
		print("registers for %s %d\n", up->text, up->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]);
}

int
notify(Ureg *ur)
{
	int l;
	ulong sp;
	Note *n;

	if(up->procctl)
		procctl(up);
	if(up->nnote == 0)
		return 0;

	spllo();
	qlock(&up->debug);
	up->notepending = 0;
	n = &up->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%lux", ur->pc);
	}

	if(n->flag != NUser && (up->notified || up->notify==0)) {
		if(n->flag == NDebug)
			pprint("suicide: %s\n", n->msg);

		qunlock(&up->debug);
		pexit(n->msg, n->flag!=NDebug);
	}

	if(up->notified) {
		qunlock(&up->debug);
		splhi();
		return 0;
	}
		
	if(!up->notify) {
		qunlock(&up->debug);
		pexit(n->msg, n->flag!=NDebug);
	}
	up->svstatus = ur->status;
	sp = ur->usp - sizeof(Ureg);

	if(sp&0x3 || !okaddr((ulong)up->notify, BY2WD, 0)
	|| !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 1)) {
		pprint("suicide: bad address or sp in notify\n");
		qunlock(&up->debug);
		pexit("Suicide", 0);
	}

	up->ureg = (void*)sp;
	memmove((Ureg*)sp, ur, sizeof(Ureg));
	sp -= ERRLEN;
	memmove((char*)sp, up->note[0].msg, ERRLEN);
	sp -= 3*BY2WD;
	*(ulong*)(sp+2*BY2WD) = sp+3*BY2WD;	/* arg 2 is string */
	up->svr1 = ur->r1;			/* save away r1 */
	ur->r1 = (ulong)up->ureg;		/* arg 1 is ureg* */
	*(ulong*)(sp+0*BY2WD) = 0;		/* arg 0 is pc */
	ur->usp = sp;
	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));

	qunlock(&up->debug);
	splhi();
	return 1;
}

/*
 * Return user to state before notify()
 */
void
noted(Ureg **urp, ulong arg0)
{
	Ureg *nur;

	nur = up->ureg;
	if(nur->status!=up->svstatus) {
		pprint("bad noted ureg status %lux\n", nur->status);
		pexit("Suicide", 0);
	}
	qlock(&up->debug);
	if(!up->notified) {
		qunlock(&up->debug);
		pprint("call to noted() when not notified\n");
		pexit("Suicide", 0);
	}
	up->notified = 0;
	memmove(*urp, up->ureg, sizeof(Ureg));
	(*urp)->r1 = up->svr1;
	switch(arg0) {
	case NCONT:
		if(!okaddr(nur->pc, 1, 0) || !okaddr(nur->usp, BY2WD, 0)){
			pprint("suicide: trap in noted\n");
			qunlock(&up->debug);
			pexit("Suicide", 0);
		}
		splhi();
		qunlock(&up->debug);
		rfnote(urp);
		break;

	default:
		pprint("unknown noted arg 0x%lux\n", arg0);
		up->lastnote.flag = NDebug;
		/* fall through */
		
	case NDFLT:
		if(up->lastnote.flag == NDebug)
			pprint("suicide: %s\n", up->lastnote.msg);
		qunlock(&up->debug);
		pexit(up->lastnote.msg, up->lastnote.flag!=NDebug);
	}
}

#include "../port/systab.h"

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

	m->syscall++;
	up->insyscall = 1;
	ur = aur;
	up->pc = ur->pc;
	up->dbgreg = aur;
	ur->cause = 16<<2;	/* for debugging: system call is undef 16 */

	if(up->fpstate == FPactive) {
		if((ur->status&CU1) == 0)
			panic("syscall: FPactive but no CU1");
		up->fpsave.fpstatus = fcr31();
		up->fpstate = FPinit;
		ur->status &= ~CU1;
	}
	spllo();

	if(up->procctl)
		procctl(up);

	up->scallnr = ur->r1;
	up->nerrlab = 0;
	sp = ur->sp;
	ret = -1;
	if(!waserror()) {
		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);
			error(Ebadarg);
		}

		if(sp & (BY2WD-1)){
			pprint("odd sp in sys call pc %lux sp %lux\n", ur->pc, ur->sp);
			postnote(up, 1, "sys: odd stack", NDebug);
			error(Ebadarg);
		}

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

		up->s = *((Sargs*)(sp+BY2WD));
		up->psstate = sysctab[up->scallnr];
		ret = (*systab[up->scallnr])(up->s.args);
		poperror();
	}
	ur->pc += 4;
	up->nerrlab = 0;
	up->psstate = 0;
	up->insyscall = 0;
	if(up->scallnr == NOTED)			/* ugly hack */
		noted(&aur, *(ulong*)(sp+BY2WD));	/* doesn't return */

	splhi();
	if(up->scallnr!=RFORK && (up->procctl || up->nnote)){
		ur->r1 = ret;			/* load up for noted() */
		if(notify(ur))
			return ur->r1;
	}
	return ret;
}

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;
}

long
execregs(ulong entry, ulong ssize, ulong nargs)
{
	Ureg *ur;
	ulong *sp;

	sp = (ulong*)(USTKTOP - ssize);
	*--sp = nargs;

	ur = (Ureg*)up->dbgreg;
	ur->usp = (ulong)sp;
	ur->pc = entry - 4;		/* syscall advances it */
	up->fpsave.fpstatus = initfp.fpstatus;
	return USTKTOP-BY2WD;		/* address of user-level clock */
}

ulong
userpc(void)
{
	Ureg *ur;

	ur = (Ureg*)up->dbgreg;
	return ur->pc;
}

/* 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
 */
void
setregisters(Ureg *xp, char *pureg, char *uva, int n)
{
	ulong status;

	status = xp->status;
	memmove(pureg, uva, n);
	xp->status = status;
}
.
## diffname carrera/trap.c 1993/0904
## diff -e /n/fornaxdump/1993/0903/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0904/sys/src/brazil/carrera/trap.c
535a

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

	up->s = *((Sargs*)(sp+BY2WD));
	up->psstate = sysctab[up->scallnr];

	ret = (*systab[up->scallnr])(up->s.args);
	poperror();

error:
.
528,534c
	if(sp & (BY2WD-1)){
		pprint("odd sp in sys call pc %lux sp %lux\n", ur->pc, ur->sp);
		postnote(up, 1, "sys: odd stack", NDebug);
		error(Ebadarg);
.
522,526c
	if(up->scallnr >= sizeof systab/sizeof systab[0]){
		pprint("bad sys call %d pc %lux\n", up->scallnr, ur->pc);
		postnote(up, 1, "sys: bad sys call", NDebug);
		error(Ebadarg);
	}
.
515,520c
	if(waserror())
		goto error;
.
286c
	if(cause & INTR3) {
		devint = *(uchar*)Intcause;
		switch(devint) {
		default:
			panic("unknown devint=#%lux", devint);

		case 0x28:		/* Serial 1 */
			NS16552intr(0);
			break;
		case 0x24:		/* Serial 2 */
			NS16552intr(1);
			break;
		case 0x14:
			etherintr();
			break;
		}
		cause &= ~INTR3;
	}

	if(cause & INTR4) {
		devint = *(uchar*)I386ack;
		iprint("i386ack=#%lux\n", devint);
		cause &= ~INTR4;
	}

	if(cause & INTR7) {
		clock(ur);
		cause &= ~INTR7;
	}

	if(cause) {
		iprint("cause %lux\n", cause);
		exit(1);
	}
.
280a
	uchar devint;
.
## diffname carrera/trap.c 1993/0905
## diff -e /n/fornaxdump/1993/0904/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0905/sys/src/brazil/carrera/trap.c
307c
		devint = IO(uchar, I386ack);
.
288c
		devint = IO(uchar, Intcause);
.
207a
iprint("kf %lux %lux\n", ur->pc, ur->r31);
.
## diffname carrera/trap.c 1993/0906
## diff -e /n/fornaxdump/1993/0905/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0906/sys/src/brazil/carrera/trap.c
395c
		print("%s\t0x%.8lux\t%s\t0x%.8lux\n", regname[i], l[0], regname[i+1], l[1]);
.
207,208c
		if(!user && (ur->badvaddr & KMAPMASK) == KMAPADDR) {
.
## diffname carrera/trap.c 1993/0907
## diff -e /n/fornaxdump/1993/0906/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0907/sys/src/brazil/carrera/trap.c
293,301c
			case 0x28:		/* Serial 1 */
				NS16552intr(0);
				break;
			case 0x24:		/* Serial 2 */
				NS16552intr(1);
				break;
			case 0x14:
				etherintr();
				break;
			case 0x1C:
				kbdintr();
				break;
			}
.
288,291c
		for(;;) {
			devint = IO(uchar, Intcause);
			if(devint == 0)
				break;
			switch(devint) {
			default:
				panic("unknown devint=#%lux", devint);
.
247c
		print("kernel %s pc=%lux\n", excname[ecode], ur->pc);
.
## diffname carrera/trap.c 1993/0908
## diff -e /n/fornaxdump/1993/0907/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0908/sys/src/brazil/carrera/trap.c
312c
	if(cause & INTR2) {
		iprint("R4030 Interrupt\n");
		iprint(" ISR #%lux\n", IO(ulong, R4030Isr));
		iprint(" ET  #%lux\n", IO(ulong, R4030Et));
		iprint(" RFA #%lux\n", IO(ulong, R4030Rfa));
		iprint(" MFA #%lux\n", IO(ulong, R4030Mfa));
		cause &= ~INTR2;
	}
.
## diffname carrera/trap.c 1993/0918
## diff -e /n/fornaxdump/1993/0908/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0918/sys/src/brazil/carrera/trap.c
373a
	kpteprint(ur);
.
371d
## diffname carrera/trap.c 1993/0930
## diff -e /n/fornaxdump/1993/0918/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/0930/sys/src/brazil/carrera/trap.c
615a
	cur->status |= CU0;
.
## diffname carrera/trap.c 1993/1001
## diff -e /n/fornaxdump/1993/0930/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1001/sys/src/brazil/carrera/trap.c
307a
			case 0x20:
				mouseintr();
				break;
.
## diffname carrera/trap.c 1993/1005
## diff -e /n/fornaxdump/1993/1001/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1005/sys/src/brazil/carrera/trap.c
473a
	*(ulong*)(sp+1*BY2WD) = (ulong)u->ureg;	/* arg 1 0(FP) is ureg* */
.
373,375c
	print("kfault %s badvaddr=0x%lux\n", excname[code], ur->badvaddr);
	print("UP=0x%lux SR=0x%lux PC=0x%lux R31=%lux SP=0x%lux\n",
				up, ur->status, ur->pc, ur->r31, ur->sp);
.
## diffname carrera/trap.c 1993/1006
## diff -e /n/fornaxdump/1993/1005/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1006/sys/src/brazil/carrera/trap.c
474c
	*(ulong*)(sp+1*BY2WD) = (ulong)up->ureg;	/* arg 1 0(FP) is ureg* */
.
## diffname carrera/trap.c 1993/1013
## diff -e /n/fornaxdump/1993/1006/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1013/sys/src/brazil/carrera/trap.c
208c
			kfault(ur);
.
## diffname carrera/trap.c 1993/1015
## diff -e /n/fornaxdump/1993/1013/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1015/sys/src/brazil/carrera/trap.c
408a

.
## diffname carrera/trap.c 1993/1022
## diff -e /n/fornaxdump/1993/1015/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1022/sys/src/brazil/carrera/trap.c
683a

/* 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 carrera/trap.c 1993/1209
## diff -e /n/fornaxdump/1993/1022/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1209/sys/src/brazil/carrera/trap.c
203a
{
((ulong*)0xA0090000)[0] = ur->pc;
((ulong*)0xA0090000)[1] = ur->badvaddr;
((ulong*)0xA0090000)[2] = ur->cause;
((ulong*)0xA0090000)[3] = 0x12345678;
((ulong*)0xA0090000)[4] = 0x87654321;
}
.
## diffname carrera/trap.c 1993/1212
## diff -e /n/fornaxdump/1993/1209/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1212/sys/src/brazil/carrera/trap.c
332c
		iprint("i386ACK #%lux\n", devint);
.
302d
204,210d
## diffname carrera/trap.c 1993/1217
## diff -e /n/fornaxdump/1993/1212/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1217/sys/src/brazil/carrera/trap.c
620d
## diffname carrera/trap.c 1993/1219
## diff -e /n/fornaxdump/1993/1217/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1219/sys/src/brazil/carrera/trap.c
288,310c
		devint = IO(uchar, Intcause);
		switch(devint) {
		default:
			panic("unknown devint=#%lux", devint);
		case 0x28:		/* Serial 1 */
			NS16552intr(0);
			break;
		case 0x24:		/* Serial 2 */
			NS16552intr(1);
			break;
		case 0x14:
			etherintr();
			break;
		case 0x1C:
			kbdintr();
			break;
		case 0x20:
			mouseintr();
			break;
.
281c
	static uchar devint;
.
240a
		((ulong*)0xA0020000)[7] = 0x87654321;
		((void(*)(void))0xA001C020)();

.
## diffname carrera/trap.c 1993/1220
## diff -e /n/fornaxdump/1993/1219/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1220/sys/src/brazil/carrera/trap.c
241c
		((ulong*)0x80020000)[7] = 0x87654321;
.
## diffname carrera/trap.c 1993/1222
## diff -e /n/fornaxdump/1993/1220/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1222/sys/src/brazil/carrera/trap.c
241,243d
## diffname carrera/trap.c 1993/1229
## diff -e /n/fornaxdump/1993/1222/sys/src/brazil/carrera/trap.c /n/fornaxdump/1993/1229/sys/src/brazil/carrera/trap.c
174a
	/*
	 * Retry failed probes of legal addresses from tstbadvaddr
	 * workaround for the R4400 >2.3
	 */
	if(m->vaddrtst) {
		m->vaddrtst = 0;
		return;
	}

.
## diffname carrera/trap.c 1994/0115
## diff -e /n/fornaxdump/1993/1229/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0115/sys/src/brazil/carrera/trap.c
332d
## diffname carrera/trap.c 1994/0209
## diff -e /n/fornaxdump/1994/0115/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0209/sys/src/brazil/carrera/trap.c
617c
	p->sched.sp = (ulong)p->kstack+KSTACK-UREGSIZE;
.
## diffname carrera/trap.c 1994/0210
## diff -e /n/fornaxdump/1994/0209/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0210/sys/src/brazil/carrera/trap.c
415a
*/
		print("%s 0x%.8lux %s 0x%.8lux ", regname[i], l[0], regname[i+1], l[1]);

.
414a
/*
.
## diffname carrera/trap.c 1994/0220
## diff -e /n/fornaxdump/1994/0210/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0220/sys/src/brazil/carrera/trap.c
320,324c
		isr = IO(ulong, R4030Isr);
		if(isr & (1<<5)) {
			audiointr();
			isr &= ~(1<<5);
		}
		if(isr) {
			iprint("R4030 Interrupt\n");
			iprint(" ISR #%lux\n", IO(ulong, R4030Isr));
			iprint(" ET  #%lux\n", IO(ulong, R4030Et));
			iprint(" RFA #%lux\n", IO(ulong, R4030Rfa));
			iprint(" MFA #%lux\n", IO(ulong, R4030Mfa));
		}
.
291a
	ulong isr;
.
## diffname carrera/trap.c 1994/0225
## diff -e /n/fornaxdump/1994/0220/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0225/sys/src/brazil/carrera/trap.c
337c
		vec = devint&~0x7;

		/* reenable the 8259 interrupt */
		if(vec == Int0vec || vec == Int1vec){
			EISAOUTB(Int0ctl, EOI);
			if(vec == Int1vec)
				EISAOUTB(Int1ctl, EOI);
		}
		switch(devint) {
		default:
			iprint("i386ACK #%lux\n", devint);
			break;
		case 5:
			audiosbintr();
			break;
		}
.
323c
			audiodmaintr();
.
321a

.
292c
	ulong isr, vec;
.
## diffname carrera/trap.c 1994/0305
## diff -e /n/fornaxdump/1994/0225/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0305/sys/src/brazil/carrera/trap.c
322d
## diffname carrera/trap.c 1994/0307
## diff -e /n/fornaxdump/1994/0305/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0307/sys/src/brazil/carrera/trap.c
350a
			break;
		case 13:
			audiodmaintr();
.
349c
		case 7:
.
322,325d
307a
		case 0x10:
			fiberint(0);
			break;
.
## diffname carrera/trap.c 1994/0308
## diff -e /n/fornaxdump/1994/0307/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0308/sys/src/brazil/carrera/trap.c
440,444c
		print("%s\t0x%.8lux\t%s\t0x%.8lux\n",
				regname[i], l[0], regname[i+1], l[1]);
.
437d
431a

.
343a

.
## diffname carrera/trap.c 1994/0311
## diff -e /n/fornaxdump/1994/0308/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0311/sys/src/brazil/carrera/trap.c
405c

	dumpregs(ur);
	splhi();
	for(;;);
.
## diffname carrera/trap.c 1994/0322
## diff -e /n/fornaxdump/1994/0311/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0322/sys/src/brazil/carrera/trap.c
366a
XDBG[0] = 6;
.
362c
XDBG[0] = 5;
.
357a
XDBG[0] = 4;
.
333a
XDBG[0] = 3;
.
322a
XDBG[0] = 2;
.
296a
XDBG[0] = 1;
.
293a
XDBG[0] = 0;
.
284a
XDBG[0] = 10;
.
279a
XDBG[0] = 9;
.
277a
XDBG[0] = 8;
.
274c
XDBG[0] = 7;
.
104a
ulong *XDBG = (ulong*)0x80020018;

.
## diffname carrera/trap.c 1994/0326
## diff -e /n/fornaxdump/1994/0322/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0326/sys/src/brazil/carrera/trap.c
377d
372c

.
367c

.
342c

.
330c

.
303d
299d
289d
283d
280d
276d
105,106d
## diffname carrera/trap.c 1994/0407
## diff -e /n/fornaxdump/1994/0326/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0407/sys/src/brazil/carrera/trap.c
606c
	if(up->scallnr >= nsyscall){
.
## diffname carrera/trap.c 1994/0513
## diff -e /n/fornaxdump/1994/0407/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0513/sys/src/brazil/carrera/trap.c
543a

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

.
532,536d
## diffname carrera/trap.c 1994/0609
## diff -e /n/fornaxdump/1994/0513/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0609/sys/src/brazil/carrera/trap.c
616c
		pprint("odd sp in sys call pc %llux sp %llux\n", ur->pc, ur->sp);
.
610c
		pprint("bad sys call %d pc %llux\n", up->scallnr, ur->pc);
.
510,511c
	((ulong*)sp)[1] = (ulong)up->ureg;	/* arg 1 0(FP) is ureg* */
	((ulong*)sp)[0] = 0;			/* arg 0 is pc */
.
495,496c
	if(!okaddr((ulong)up->notify, BY2WD, 0) ||
	   !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 1)) {
.
493c
	sp = ur->usp & ~(BY2V-1);
	sp -= sizeof(Ureg);
.
471c
		sprint(n->msg+l, " pc=0x%llux", ur->pc);
.
468,469c
		if(l > ERRLEN-23)	/* " pc=0x12345678\0" */
			l = ERRLEN-23;
.
405c
	print("UP=0x%lux SR=0x%lux PC=0x%llux R31=%llux SP=0x%llux\n",
.
395c
	sprint(buf, "%s fppc=0x%llux", s, fppc);
.
376c
	uvlong fppc;
.
256c
		print("kernel %s pc=%llux\n", excname[ecode], ur->pc);
.
## diffname carrera/trap.c 1994/0611
## diff -e /n/fornaxdump/1994/0609/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0611/sys/src/brazil/carrera/trap.c
357a
sisr.state = 9;
.
354a
sisr.state = 8;
.
353a
sisr.state = 7;
.
351a
sisr.state = 6;
.
350a
sisr.state = 5;
.
338c
sisr.devint4 = devint;
sisr.state = 4;
.
332a
sisr.state = 3;
.
323a
sisr.state = 2;
.
320a
sisr.state = 1;
.
297a
sisr.devint3 = devint;
sisr.state = 0;
.
295c
sisr.cause = cause;
.
285a
struct
{
	ulong cause;
	ulong devint3;
	ulong devint4;
	ulong state;
}sisr;

.
## diffname carrera/trap.c 1994/0612
## diff -e /n/fornaxdump/1994/0611/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0612/sys/src/brazil/carrera/trap.c
636c
		pprint("odd sp in sys call pc %lux sp %lux\n", ur->pc, ur->sp);
.
630c
		pprint("bad sys call %d pc %lux\n", up->scallnr, ur->pc);
.
568a
	(*urp)->hr1 = up->svhr1;
.
529c
	up->svhr1 = ur->hr1;			/* save away r1 */
	ur->r1 = (long)up->ureg;		/* arg 1 is ureg* */
	ur->hr1 = 0;
	if(ur->r1 < 0)
		ur->hr1 = ~0;
.
490c
		sprint(n->msg+l, " pc=0x%lux", ur->pc);
.
424c
	print("UP=0x%lux SR=0x%lux PC=0x%lux R31=%lux SP=0x%lux\n",
.
414c
	sprint(buf, "%s fppc=0x%lux", s, fppc);
.
395c
	ulong fppc;
.
256c
		print("kernel %s pc=%lux\n", excname[ecode], ur->pc);
.
## diffname carrera/trap.c 1994/0614
## diff -e /n/fornaxdump/1994/0612/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0614/sys/src/brazil/carrera/trap.c
641c
		pprint("odd sp in sys call pc %llux sp %llux\n", ur->pc, ur->sp);
.
635c
		pprint("bad sys call %d pc %llux\n", up->scallnr, ur->pc);
.
573d
529,533c
	ur->r1 = (ulong)up->ureg;		/* arg 1 is ureg* */
.
490c
		sprint(n->msg+l, " pc=0x%llux", ur->pc);
.
424c
	print("UP=0x%lux SR=0x%lux PC=0x%llux R31=%llux SP=0x%llux\n",
.
414c
	sprint(buf, "%s fppc=0x%llux", s, fppc);
.
395c
	uvlong fppc;
.
256c
		print("kernel %s pc=%llux\n", excname[ecode], ur->pc);
.
## diffname carrera/trap.c 1994/0617
## diff -e /n/fornaxdump/1994/0614/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0617/sys/src/brazil/carrera/trap.c
636c
		pprint("odd sp in sys call pc %lux sp %lux\n", ur->pc, ur->sp);
.
630c
		pprint("bad sys call %d pc %lux\n", up->scallnr, ur->pc);
.
530,531c
	*(ulong*)(sp+1*BY2WD) = (ulong)up->ureg;	/* arg 1 0(FP) is ureg* */
	*(ulong*)(sp+0*BY2WD) = 0;		/* arg 0 is pc */
.
515,516c
	if(sp&0x3 || !okaddr((ulong)up->notify, BY2WD, 0)
	|| !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 1)) {
.
512,513c
	sp = ur->usp - sizeof(Ureg);
.
490c
		sprint(n->msg+l, " pc=0x%lux", ur->pc);
.
487,488c
		if(l > ERRLEN-15)	/* " pc=0x12345678\0" */
			l = ERRLEN-15;
.
424c
	print("UP=0x%lux SR=0x%lux PC=0x%lux R31=%lux SP=0x%lux\n",
.
414c
	sprint(buf, "%s fppc=0x%lux", s, fppc);
.
395c
	ulong fppc;
.
376d
372d
370d
367d
365d
351,352c

.
345d
335d
331d
306,307d
303c

.
286,293d
256c
		print("kernel %s pc=%lux\n", excname[ecode], ur->pc);
.
## diffname carrera/trap.c 1994/0619
## diff -e /n/fornaxdump/1994/0617/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0619/sys/src/brazil/carrera/trap.c
640a
		ur->hr1 = 0;
		if(ur->r1 < 0)
			ur->hr1 = ~0;
.
548a
	(*urp)->hr1 = up->svhr1;
.
509,511c
	up->svhr1 = ur->hr1;			/* save away r1 */
	ur->r1 = (long)up->ureg;		/* arg 1 is ureg* */
	ur->hr1 = 0;
	if(ur->r1 < 0)
		ur->hr1 = ~0;
	((ulong*)sp)[1] = (ulong)up->ureg;	/* arg 1 0(FP) is ureg* */
	((ulong*)sp)[0] = 0;			/* arg 0 is pc */
.
495,496c
	if(!okaddr((ulong)up->notify, BY2WD, 0) ||
	   !okaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 1)) {
.
493c
	sp = ur->usp & ~(BY2V-1);
	sp -= sizeof(Ureg);
.
357a
sisr.state = 9;
.
354a
sisr.state = 8;
.
353a
sisr.state = 7;
.
351a
sisr.state = 6;
.
350a
sisr.state = 5;
.
338c
sisr.devint4 = devint;
sisr.state = 4;
.
332a
sisr.state = 3;
.
323a
sisr.state = 2;
.
320a
sisr.state = 1;
.
297a
sisr.devint3 = devint;
sisr.state = 0;
.
295c
sisr.cause = cause;
.
285a
struct
{
	ulong cause;
	ulong devint3;
	ulong devint4;
	ulong state;
}sisr;

.
## diffname carrera/trap.c 1994/0706
## diff -e /n/fornaxdump/1994/0619/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0706/sys/src/brazil/carrera/trap.c
376d
372d
370d
367d
365d
351,352d
345d
335d
333a
	if(cause & INTR5)
		panic("EISA NMI\n");

.
331d
306,307d
303d
286,293d
## diffname carrera/trap.c 1994/0817
## diff -e /n/fornaxdump/1994/0706/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0817/sys/src/brazil/carrera/trap.c
369a

	/* preemptive scheduling */
	if(up && up->state == Running && anyhigher())
		sched();
.
363a
		return;
.
## diffname carrera/trap.c 1994/0818
## diff -e /n/fornaxdump/1994/0817/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0818/sys/src/brazil/carrera/trap.c
363d
## diffname carrera/trap.c 1994/0902
## diff -e /n/fornaxdump/1994/0818/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/0902/sys/src/brazil/carrera/trap.c
304c
			ns16552intr(1);
.
301c
			ns16552intr(0);
.
## diffname carrera/trap.c 1994/1025
## diff -e /n/fornaxdump/1994/0902/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/1025/sys/src/brazil/carrera/trap.c
355c
			isr = EISAINB(Eisadmaintr) & ~(1<<4);
			for(i = 0; i < 8; i++) {
				if(isr & 1)
					eisadma[i]();
				isr >>= 1;
			}
.
353a
		case 10:
			mpegintr();
			break;
.
288a
	int i;
.
286a
seteisadma(int ch, void (*func)(void))
{
	if(ch < 0 || ch > 7)
		panic("seteisadma");
	if(eisadma[ch] != 0)
		print("EISA dma%d: intr used twice");

	eisadma[ch] = func;
}

void
.
59a
void (*eisadma[8])(void);			/* Eisa dma chain vectors */
.
## diffname carrera/trap.c 1994/1026
## diff -e /n/fornaxdump/1994/1025/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/1026/sys/src/brazil/carrera/trap.c
371,376c
			eisadmaintr();
.
301a
	uchar isr;
	void (*f)(void);

	isr = EISAINB(Eisadmaintr) & ~(1<<4);
	for(i = 0; i < 8; i++) {
		if(isr & 1) {
			f = eisadma[i];
			if(f == 0)
				print("EISAdma%d: stray intr %.2ux\n", i, isr);
			else
				f();
		}
		isr >>= 1;
	}
}

void
intr(Ureg *ur)
{
.
299c
eisadmaintr(void)
.
## diffname carrera/trap.c 1994/1029
## diff -e /n/fornaxdump/1994/1026/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/1029/sys/src/brazil/carrera/trap.c
391a
		}
		/* reenable the 8259 interrupt */
		vec = devint&~0x7;
		if(vec == Int0vec || vec == Int1vec){
			EISAOUTB(Int0ctl, EOI);
			if(vec == Int1vec)
				EISAOUTB(Int1ctl, EOI);
.
371,378d
## diffname carrera/trap.c 1994/1102
## diff -e /n/fornaxdump/1994/1029/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/1102/sys/src/brazil/carrera/trap.c
385,391c
		EISAOUTB(Int0ctl, EOI);
		if(devint > 7)
			EISAOUTB(Int1ctl, EOI);
.
## diffname carrera/trap.c 1994/1121
## diff -e /n/fornaxdump/1994/1102/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/1121/sys/src/brazil/carrera/trap.c
465a
	print("\n");
.
462,463c
			print("%.8lux=%.8lux ", l, v);
			if((++i%4) == 0){
				print("\n");
				delay(200);
			}
.
458a
	i = 0;
.
452c
	ulong l, v, top, i;
.
## diffname carrera/trap.c 1994/1201
## diff -e /n/fornaxdump/1994/1121/sys/src/brazil/carrera/trap.c /n/fornaxdump/1994/1201/sys/src/brazil/carrera/trap.c
367a

	if(cause & INTR5)
		panic("EISA NMI\n");

.
360,364c
			print("R4030 Interrupt PC %lux R31 %lux\n", ur->pc, ur->r31);
			print(" ISR #%lux\n", IO(ulong, R4030Isr));
			print(" ET  #%lux\n", IO(ulong, R4030Et));
			print(" RFA #%lux\n", IO(ulong, R4030Rfa));
			print(" MFA #%lux\n", IO(ulong, R4030Mfa));
.
354,356d
323c
	ulong isr;
.
## diffname carrera/trap.c 1995/0104
## diff -e /n/fornaxdump/1994/1201/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0104/sys/src/brazil/carrera/trap.c
604a
		splhi();
.
603d
## diffname carrera/trap.c 1995/0108
## diff -e /n/fornaxdump/1995/0104/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0108/sys/src/brazil/carrera/trap.c
403c
	if(up && up->state == Running && anyhigher() && up->inlock == 0)
.
379,381d
## diffname carrera/trap.c 1995/0109
## diff -e /n/fornaxdump/1995/0108/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0109/sys/src/brazil/carrera/trap.c
400c
	if(up && up->state == Running && anyhigher() && !up->inlock)
.
## diffname carrera/trap.c 1995/0110
## diff -e /n/fornaxdump/1995/0109/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0110/sys/src/brazil/carrera/trap.c
400c
	if(up && up->state == Running && anyhigher())
.
## diffname carrera/trap.c 1995/0113
## diff -e /n/fornaxdump/1995/0110/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0113/sys/src/brazil/carrera/trap.c
591,592d
547,548d
## diffname carrera/trap.c 1995/0115
## diff -e /n/fornaxdump/1995/0113/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0115/sys/src/brazil/carrera/trap.c
675,676c
	if(up->scallnr == NOTED)		/* ugly hack */
		noted(ur, &aur, *(ulong*)(sp+BY2WD));	/* doesn't return */
.
600a
	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] = (ulong)up->ureg;	/* arg 1 0(FP) is ureg* */
		((ulong*)sp)[0] = 0;			/* arg 0 is pc */
		(*urp)->r1 = oureg;		/* arg 1 is ureg* */
		(*urp)->hr1 = 0;
		if(oureg < 0)
			(*urp)->hr1 = ~0;
		rfnote(urp);
		break;

.
595a
		up->ureg = (Ureg*)(*(ulong*)(oureg-BY2WD));
.
591c
	case NRSTR:
		if(!okaddr(nur->pc, BY2WD, 0) || !okaddr(nur->usp, BY2WD, 0)){
.
587a
	oureg = (ulong)up->ureg;
	if(oureg){
		if(oureg>=USTKTOP || oureg<USTKTOP-USTKSIZE
		|| (oureg & (BY2V-1))
		|| !okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
			pprint("suicide: bad up->ureg in noted\n");
			qunlock(&up->debug);
			pexit("Suicide", 0);
		}
	}

.
582c
	if(!validstatus(kur->status, nur->status)) {
.
574c
	if(arg0!=NRSTR && !up->notified) {
.
571a
	ulong oureg, sp;
.
569c
noted(Ureg *kur, Ureg **urp, ulong arg0)
.
565a
 * Check that status is OK to return from note.
 */
int
validstatus(ulong kstatus, ulong ustatus)
{
	if((kstatus & (INTMASK|KX|SX|UX)) != (ustatus & (INTMASK|KX|SX|UX)))
		return 0;
	if((ustatus&(KSU|ERL|EXL|IE)) != (KUSER|EXL|IE))
		return 0;
	if(ustatus & (0xFFFF0000&~CU1))	/* no CU3, CU2, CU0, RP, FR, RE, DS */
		return 0;
	return 1;
}

/*
.
543c
	*(Ureg**)(sp-BY2WD) = up->ureg;	/* word under Ureg is old up->ureg */
	up->ureg = (void*)sp;
	sp -= BY2WD+ERRLEN;
.
541d
535c
	   !okaddr(sp-ERRLEN-4*BY2WD, sizeof(Ureg)+ERRLEN-4*BY2WD, 1)) {
.
530d
10c
void	noted(Ureg*, Ureg**, ulong);
.
## diffname carrera/trap.c 1995/0128
## diff -e /n/fornaxdump/1995/0115/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0128/sys/src/brazil/carrera/trap.c
640c
		((ulong*)sp)[1] = oureg;	/* arg 1 0(FP) is ureg* */
.
604c
	oureg = (ulong)nur;
.
534c
	   !okaddr(sp-ERRLEN-4*BY2WD, sizeof(Ureg)+ERRLEN+4*BY2WD, 1)) {
.
515d
## diffname carrera/trap.c 1995/0131
## diff -e /n/fornaxdump/1995/0128/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0131/sys/src/brazil/carrera/trap.c
395c
		print("cause %lux\n", cause);
.
374c
			print("i386ACK #%lux\n", devint);
.
## diffname carrera/trap.c 1995/0202
## diff -e /n/fornaxdump/1995/0131/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/0202/sys/src/brazil/carrera/trap.c
603,611c
	if(!validstatus(kur->status, nur->status)) {
		qunlock(&up->debug);
		pprint("bad noted ureg status %lux\n", nur->status);
		pexit("Suicide", 0);
.
599d
597c

	oureg = (ulong)nur;
	if(oureg>=USTKTOP || oureg<USTKTOP-USTKSIZE
	|| (oureg & (BY2V-1))
	|| !okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
		pprint("bad ureg in noted or call to noted() when not notified\n");
.
## diffname carrera/trap.c 1995/02021
## diff -e /n/fornaxdump/1995/0202/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/02021/sys/src/brazil/carrera/trap.c
599,600c
	if((oureg & (BY2V-1))
.
## diffname carrera/trap.c 1995/1024
## diff -e /n/fornaxdump/1995/02021/sys/src/brazil/carrera/trap.c /n/fornaxdump/1995/1024/sys/src/brazil/carrera/trap.c
819a

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

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

	return ur->pc;
}
.
## diffname carrera/trap.c 1997/0117
## diff -e /n/fornaxdump/1995/1024/sys/src/brazil/carrera/trap.c /n/fornaxdump/1997/0117/sys/src/brazil/carrera/trap.c
340a
 */
.
337a
/*
.
## diffname carrera/trap.c 1997/0327
## diff -e /n/fornaxdump/1997/0117/sys/src/brazil/carrera/trap.c /n/emeliedump/1997/0327/sys/src/brazil/carrera/trap.c
760c
	up->kpfun(up->kparg);
.
714c
	ret = systab[up->scallnr](up->s.args);
.
485c
	for(i=0; i<nelem(regname); i+=2, l+=2)
.
## diffname carrera/trap.c 1997/1101
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/carrera/trap.c /n/emeliedump/1997/1101/sys/src/brazil/carrera/trap.c
487c
				regname[i].name, R(ur, i),
				regname[i+1].name, R(ur, i+1));
.
484,485c
	for(i=0; i<nelem(regname); i+=2)
.
477d
472a
ulong
R(Ureg *ur, int i)
{
	uchar *s;

	s = (uchar*)ur;
	return *(ulong*)(s+regname[i].off-Uoffset);
}

.
63,82c
struct
{
	char	*name;
	int	off;
} regname[]={
	"STATUS",	Ureg_status,
	"PC",		Ureg_pc,
	"SP",		Ureg_sp,
	"CAUSE",	Ureg_cause,
	"BADADDR",	Ureg_badvaddr,
	"TLBVIRT",	Ureg_tlbvirt,
	"HI",		Ureg_hi,
	"LO",		Ureg_lo,
	"R31",		Ureg_r31,
	"R30",		Ureg_r30,
	"R28",		Ureg_r28,
	"R27",		Ureg_r27,
	"R26",		Ureg_r26,
	"R25",		Ureg_r25,
	"R24",		Ureg_r24,
	"R23",		Ureg_r23,
	"R22",		Ureg_r22,
	"R21",		Ureg_r21,
	"R20",		Ureg_r20,
	"R19",		Ureg_r19,
	"R18",		Ureg_r18,
	"R17",		Ureg_r17,
	"R16",		Ureg_r16,
	"R15",		Ureg_r15,
	"R14",		Ureg_r14,
	"R13",		Ureg_r13,
	"R12",		Ureg_r12,
	"R11",		Ureg_r11,
	"R10",		Ureg_r10,	
	"R9",		Ureg_r9,
	"R8",		Ureg_r8,
	"R7",		Ureg_r7,
	"R6",		Ureg_r6,
	"R5",		Ureg_r5,
	"R4",		Ureg_r4,
	"R3",		Ureg_r3,
	"R2",		Ureg_r2,
	"R1",		Ureg_r1,
.
## diffname carrera/trap.c 1999/0629
## diff -e /n/emeliedump/1997/1101/sys/src/brazil/carrera/trap.c /n/emeliedump/1999/0629/sys/src/brazil/carrera/trap.c
511c
		print("registers for %s %ld\n", up->text, up->pid);
.
399c
			print("i386ACK #%ux\n", devint);
.
316c
		print("EISA dma%d: intr used twice", ch);
.
182c
				print("pa=0x%lux, va=0x%lux\n",
.
164c
	print("Trap: VCE%c: addr=0x%lux\n", c, ur->badvaddr);
.
149c
	print("pg={pa=0x%lux, va=0x%lux}\n", k->pg->pa, k->pg->va);
.
147c
	print("i=%ld, &k=0x%lux, k={v=0x%lux, p0=%s, p1=%s, pg=0x%lux}\n",
.
143c
		print("kpte index = 0x%lux ?\n", i);
.
138c
	print("i=%ld v=0x%lux p0=%s p1=%s\n",
.
136c
	print("tlbvirt=0x%lux\n", i);
.
117c
	p += sprint(p, "(0x%lux %ld ", (phys<<6) & ~(BY2PG-1), (phys>>3)&7);
.
## diffname carrera/trap.c 1999/0701
## diff -e /n/emeliedump/1999/0629/sys/src/brazil/carrera/trap.c /n/emeliedump/1999/0701/sys/src/brazil/carrera/trap.c
198a
	m->intrts = fastticks(nil);

.
## diffname carrera/trap.c 1999/0720
## diff -e /n/emeliedump/1999/0701/sys/src/brazil/carrera/trap.c /n/emeliedump/1999/0720/sys/src/brazil/carrera/trap.c
495a
}

void
dumpstack(void)
{
	_dumpstack(0);
.
482a
	getpcsp(&pc, &sp);
	link = getcallerpc(&dummy);

	print("ktrace /kernel/path %.8lux %.8lux %.8lux\n", pc, sp, r31);
.
477c
	*pc = getcallerpc(&pc);
	sp = (ulong)&pc-4;
}

static void
_dumpstack(ulong dummy)
{
	ulong pc, sp, link, l, v, top, i;
.
475c
getpcsp(ulong *pc, ulong *sp)
.
473a
note rsc_wrote_this_but_has_not_checked_it yet;
.
469,470d
## diffname carrera/trap.c 1999/0721
## diff -e /n/emeliedump/1999/0720/sys/src/brazil/carrera/trap.c /n/emeliedump/1999/0721/sys/src/brazil/carrera/trap.c
511c
	callwithureg(_dumpstack);
.
495c
	for(l=ureg->sp; l < top; l += BY2WD) {
.
489,492c
	print("ktrace /kernel/path %.8lux %.8lux %.8lux\n", ureg->pc, ureg->sp, ureg->r31);
.
483c
	ulong l, v, top, i;
.
481c
_dumpstack(Ureg *ureg)
.
479a
void
callwithureg(void (*fn)(Ureg*))
{
	Ureg ureg;

	getpcsp((ulong*)&ureg.pc, (ulong*)&ureg.sp);
	ureg.r31 = getcallerpc(&fn);
	fn(&ureg);
}

.
477c
	*sp = (ulong)&pc-4;
.
472,473c
static void
.
## diffname carrera/trap.c 2001/0527 # deleted
## diff -e /n/emeliedump/1999/0721/sys/src/brazil/carrera/trap.c /n/emeliedump/2001/0527/sys/src/9/carrera/trap.c
1,888d

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.