Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/ss/faultsparc.c

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


## diffname ss/faultsparc.c 1990/1223
## diff -e /dev/null /n/bootesdump/1990/1223/sys/src/9/sparc/faultsparc.c
0a
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"ureg.h"
#include	"errno.h"

#define	FORMAT(ur)	((((ur)->vo)>>12)&0xF)
#define	OFFSET(ur)	(((ur)->vo)&0xFFF)


struct FFrame
{
	ushort	ireg0;			/* internal register */
	ushort	ssw;			/* special status word */
	ushort	ipsc;			/* instr. pipe stage c */
	ushort	ipsb;			/* instr. pipe stage b */
	ulong	addr;			/* data cycle fault address */
	ushort	ireg1;			/* internal register */
	ushort	ireg2;			/* internal register */
	ulong	dob;			/* data output buffer */
	ushort	ireg3[4];		/* more stuff */
	ulong	baddr;			/* stage b address */
	ushort	ireg4[26];		/* more more stuff */
};

/*
 * SSW bits
 */
#define	RW	0x0040		/* read/write for data cycle */
#define	FC	0x8000		/* fault on stage C of instruction pipe */
#define	FB	0x4000		/* fault on stage B of instruction pipe */
#define	RC	0x2000		/* rerun flag for stage C of instruction pipe */
#define	RB	0x1000		/* rerun flag for stage B of instruction pipe */
#define	DF	0x0100		/* fault/rerun flag for data cycle */
#define	RM	0x0080		/* read-modify-write on data cycle */
#define	READ	0x0040
#define	WRITE	0x0000
#define	SIZ	0x0030		/* size code for data cycle */
#define	FC2	0x0004		/* address space for data cycle */
#define	FC1	0x0002
#define	FC0	0x0001

void
fault68020(Ureg *ur, FFrame *f)
{
	ulong addr, badvaddr;
	int user, read, insyscall;

	if(u == 0){
		dumpregs(ur);
		panic("fault u==0 pc=%lux", ur->pc);
	}
	insyscall = u->p->insyscall;
	u->p->insyscall = 1;
	addr = 0;	/* set */
	if(f->ssw & DF)
		addr = f->addr;
	else if(FORMAT(ur) == 0xA){
		if(f->ssw & FC)
			addr = ur->pc+2;
		else if(f->ssw & FB)
			addr = ur->pc+4;
		else
			panic("prefetch pagefault");
	}else if(FORMAT(ur) == 0xB){
		if(f->ssw & FC)
			addr = f->baddr-2;
		else if(f->ssw & FB)
			addr = f->baddr;
		else
			panic("prefetch pagefault");
	}else
		panic("prefetch format");
	addr &= VAMASK;
	badvaddr = addr;
	addr &= ~(BY2PG-1);
	user = !(ur->sr&SUPER);
	if(f->ssw & DF)
		read = (f->ssw&READ) && !(f->ssw&RM);
	else
		read = f->ssw&(FB|FC);
/* print("fault pc=%lux addr=%lux read %d\n", ur->pc, badvaddr, read); /**/

	if(fault(addr, read) < 0){
		if(user){
			pprint("user %s error addr=0x%lux\n", read? "read" : "write", badvaddr);
			pprint("status=0x%lux pc=0x%lux sp=0x%lux\n", ur->sr, ur->pc, ur->sp);
			pexit("Suicide", 0);
		}
		u->p->state = MMUing;
		dumpregs(ur);
		panic("fault: 0x%lux", badvaddr);
		exit();
	}
	u->p->insyscall = insyscall;
}
.
## diffname ss/faultsparc.c 1990/1226
## diff -e /n/bootesdump/1990/1223/sys/src/9/sparc/faultsparc.c /n/bootesdump/1990/1226/sys/src/9/sparc/faultsparc.c
97a
}

/*
 * called in sysfile.c
 */
void
evenaddr(ulong addr)
{
	if(addr & 3){
panic("evenaddr");
		postnote(u->p, 1, "sys: odd address", NDebug);
		error(Ebadarg);
	}
.
89c
			pprint("psr=0x%lux pc=0x%lux sp=0x%lux\n", ur->psr, ur->pc, ur->sp);
.
79,84c
	user = !(ur->psr&PSRSUPER);
.
57,76c
/*	addr &= VAMASK; /**/
.
54a
	if(getw2(SER) & 0x8000)
		read = 0;
	else
		read = 1;
.
50a
	tbr = ur->tbr&0xFFF;
	addr = ur->pc;			/* assume instr. exception */
	if(tbr == (9<<4))		/* data access exception */
		addr = getw2(SEVAR);
	else if(tbr != (1<<4)){		/* should be instruction access exception */
		trap(ur);
		panic("trap returns");
	}
	spllo();
print("fault: %s pc=0x%lux addr %lux\n", excname(ur->tbr), ur->pc, addr);
.
49a
	ulong tbr;
.
46c
faultsparc(Ureg *ur)
.
12,44d
9,10d
## diffname ss/faultsparc.c 1990/1227
## diff -e /n/bootesdump/1990/1226/sys/src/9/sparc/faultsparc.c /n/bootesdump/1990/1227/sys/src/9/sparc/faultsparc.c
26c
print("fault: %s pc=0x%lux addr %lux\n", excname(tbr), ur->pc, addr);
.
23c
		return;
.
21c
	else if(tbr != 1){		/* should be instruction access exception */
.
19c
	if(tbr == 9)			/* data access exception */
.
17c
	tbr = (ur->tbr&0xFFF)>>4;
.
## diffname ss/faultsparc.c 1990/1231
## diff -e /n/bootesdump/1990/1227/sys/src/9/sparc/faultsparc.c /n/bootesdump/1990/1231/sys/src/9/sparc/faultsparc.c
40c
	user = !(ur->psr&PSRPSUPER);
.
31,34d
26c
/* print("fault: %s pc=0x%lux addr %lux %d\n", excname(tbr), ur->pc, addr, read); /**/
.
21c
		if(getw2(SER) & 0x8000)
			read = 0;
	}else if(tbr != 1){		/* should be instr. access exception */
.
19c
	read = 1;
	if(tbr == 9){			/* data access exception */
		/*
		 * According to the book, this isn't good enough.  We'll see.
		 */
.
9d
## diffname ss/faultsparc.c 1991/0110
## diff -e /n/bootesdump/1990/1231/sys/src/9/sparc/faultsparc.c /n/bootesdump/1991/0110/sys/src/9/sparc/faultsparc.c
54a
ck("faultsparc return");
}

void
faultasync(Ureg *ur)
{
	int user;

	print("interrupt 15 ASER %lux ASEVAR %lux SER %lux\n", getw2(ASER), getw2(ASEVAR), getw2(SER));
	dumpregs(ur);
	/*
	 * Clear interrupt by toggling low bit of interrupt register
	 */
	*intrreg &= ~1;
	*intrreg |= 1;
	user = !(ur->psr&PSRPSUPER);
	if(user)
		pexit("Suicide", 0);
	panic("interrupt 15");
.
43a
print("death read %lux %d sizes %lux-%lux %lux-%lux, %lux-%lux %lux-%lux\n", addr, read,
u->p->seg[SSEG].minva, u->p->seg[SSEG].maxva, 
u->p->seg[TSEG].minva, u->p->seg[TSEG].maxva, 
u->p->seg[DSEG].minva, u->p->seg[DSEG].maxva, 
u->p->seg[BSEG].minva, u->p->seg[BSEG].maxva); 
.
31c
print("fault: %s pc=0x%lux addr %lux %d\n", excname(tbr), ur->pc, addr, read); /**/
ck("faultsparc");
.
8a
ck(char *s)
{
	if(u->p->seg[SSEG].o->flag == 0)
		panic(s);
}

.
## diffname ss/faultsparc.c 1991/0111
## diff -e /n/bootesdump/1991/0110/sys/src/9/sparc/faultsparc.c /n/bootesdump/1991/0111/sys/src/9/sparc/faultsparc.c
67d
51,55d
37,38c
/* print("fault: %s pc=0x%lux addr %lux %d\n", excname(tbr), ur->pc, addr, read); /**/
.
9,14d
## diffname ss/faultsparc.c 1991/0115
## diff -e /n/bootesdump/1991/0111/sys/src/9/sparc/faultsparc.c /n/bootesdump/1991/0115/sys/src/9/sparc/faultsparc.c
82d
## diffname ss/faultsparc.c 1991/01151
## diff -e /n/bootesdump/1991/0115/sys/src/9/sparc/faultsparc.c /n/bootesdump/1991/01151/sys/src/9/sparc/faultsparc.c
54c
	splhi();
.
36,37d
34c
		panic("fault u==0 pc=%lux addr=%lux", ur->pc, addr);
.
26,28d
13c
	int user, read;
.
## diffname ss/faultsparc.c 1991/0503
## diff -e /n/bootesdump/1991/0201/sys/src/9/sparc/faultsparc.c /n/bootesdump/1991/0503/sys/src/9/slc/faultsparc.c
28c
print("fault: %s pc=0x%lux addr %lux %d\n", excname(tbr), ur->pc, addr, read); /**/
.
## diffname ss/faultsparc.c 1991/0504
## diff -e /n/bootesdump/1991/0503/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/0504/sys/src/9/slc/faultsparc.c
28d
## diffname ss/faultsparc.c 1991/0711
## diff -e /n/bootesdump/1991/0504/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/0711/sys/src/9/slc/faultsparc.c
27a
print("fault %lux %lux %d\n", ur->pc, addr, read);
.
## diffname ss/faultsparc.c 1991/0712
## diff -e /n/bootesdump/1991/0711/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/0712/sys/src/9/slc/faultsparc.c
28d
## diffname ss/faultsparc.c 1991/0717
## diff -e /n/bootesdump/1991/0712/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/0717/sys/src/9/slc/faultsparc.c
39,41c
			sprint(buf, "sys: fault %s pc=0x%lux addr=0x%lux",
				read? "read" : "write", ur->pc, badvaddr);
			postnote(u->p, 1, buf, NDebug);
			notify(ur);
			return;
.
12a
	char buf[ERRLEN];
.
## diffname ss/faultsparc.c 1991/0926
## diff -e /n/bootesdump/1991/0717/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/0926/sys/src/9/slc/faultsparc.c
46d
## diffname ss/faultsparc.c 1991/1108
## diff -e /n/bootesdump/1991/0926/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/1108/sys/src/9/slc/faultsparc.c
43d
## diffname ss/faultsparc.c 1991/1218
## diff -e /n/bootesdump/1991/1108/sys/src/9/slc/faultsparc.c /n/bootesdump/1991/1218/sys/src/9/slc/faultsparc.c
40,41c
			sprint(buf, "sys: trap: fault %s addr=0x%lux",
				read? "read" : "write", badvaddr);
.
## diffname ss/faultsparc.c 1992/0111
## diff -e /n/bootesdump/1991/1218/sys/src/9/slc/faultsparc.c /n/bootesdump/1992/0111/sys/src/9/slc/faultsparc.c
7c
#include	"../port/error.h"
.
## diffname ss/faultsparc.c 1992/0321
## diff -e /n/bootesdump/1992/0111/sys/src/9/slc/faultsparc.c /n/bootesdump/1992/0321/sys/src/9/slc/faultsparc.c
2c
#include	"../port/lib.h"
.
## diffname ss/faultsparc.c 1992/0704
## diff -e /n/bootesdump/1992/0321/sys/src/9/slc/faultsparc.c /n/bootesdump/1992/0704/sys/src/9/slc/faultsparc.c
25c
		ser = getw2(SER);
		if(ser&(SE_WRITE|SE_PROT))
.
15c
	ulong tbr, ser;
.
8a
enum
{
	SE_WRITE	= 0x8000,
	SE_INV		= 0x0080,
	SE_PROT		= 0x0040,
};

.
## diffname ss/faultsparc.c 1992/0806
## diff -e /n/bootesdump/1992/0704/sys/src/9/slc/faultsparc.c /n/bootesdump/1992/0806/sys/src/9/slc/faultsparc.c
65c
	print("interrupt 15 ASER %lux ASEVAR %lux SER %lux\n", getsysspace(ASER), getsysspace(ASEVAR), getsysspace(SER));
.
31,32c
		addr = getsysspace(SEVAR);
		ser = getsysspace(SER);
.
## diffname ss/faultsparc.c 1992/0812
## diff -e /n/bootesdump/1992/0807/sys/src/9/slc/faultsparc.c /n/bootesdump/1992/0812/sys/src/9/ss/faultsparc.c
55d
## diffname ss/faultsparc.c 1992/0813
## diff -e /n/bootesdump/1992/0812/sys/src/9/ss/faultsparc.c /n/bootesdump/1992/0813/sys/src/9/ss/faultsparc.c
40a

.
## diffname ss/faultsparc.c 1992/0911
## diff -e /n/bootesdump/1992/0813/sys/src/9/ss/faultsparc.c /n/bootesdump/1992/0911/sys/src/9/ss/faultsparc.c
35a
if(u && strcmp(u->p->text, "rc") == 0)
print("fault pc=%lux addr=%lux %d\n", ur->pc, addr, read);/**/
.
## diffname ss/faultsparc.c 1992/0912
## diff -e /n/bootesdump/1992/0911/sys/src/9/ss/faultsparc.c /n/bootesdump/1992/0912/sys/src/9/ss/faultsparc.c
36c
/*if(u && strcmp(u->p->text, "rc") == 0)
.
## diffname ss/faultsparc.c 1992/0913
## diff -e /n/bootesdump/1992/0912/sys/src/9/ss/faultsparc.c /n/bootesdump/1992/0913/sys/src/9/ss/faultsparc.c
44d
36,37c

.
## diffname ss/faultsparc.c 1993/0501 # deleted
## diff -e /n/bootesdump/1992/0913/sys/src/9/ss/faultsparc.c /n/fornaxdump/1993/0501/sys/src/brazil/ss/faultsparc.c
1,88d

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.