plan 9 kernel history: overview | file list | diff list

1991/1214/gnot/trap.c (diff list | history)

1990/03091/sys/src/9/gnot/trap.c:244,2491990/0312/sys/src/9/gnot/trap.c:244,250 (short | long)
1990/03091    
 
	u->p->insyscall = 1; 
	ur = aur; 
1990/0312    
	u->p->pc = ur->pc; 
1990/03091    
	if(ur->sr & SUPER) 
		panic("recursive system call"); 
#ifdef asdf 
1990/0312/sys/src/9/gnot/trap.c:278,2851990/0315/sys/src/9/gnot/trap.c:278,283 (short | long)
1990/03091    
		ur->r0 = ret; 
		notify(ur); 
	} 
{ulong *arg=(ulong*)(sp+BY2WD); 
if(ret==-1)print("syscall %d(%lux %lux %lux) returns error %d\n", r0, arg[0], arg[1], arg[2], u->error.code);} 
	return ret; 
} 
 
1990/0315/sys/src/9/gnot/trap.c:270,2751990/0321/sys/src/9/gnot/trap.c:270,276 (short | long)
1990/03091    
	ret = -1; 
	if(!waserror()) 
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1990/0321    
else print("syscall %d err %d %d\n", r0, u->error.type, u->error.code); 
1990/03091    
	u->nerrlab = 0; 
	u->p->insyscall = 0; 
	if(r0 == NOTED)	/* ugly hack */ 
1990/0321/sys/src/9/gnot/trap.c:270,2761990/0322/sys/src/9/gnot/trap.c:270,276 (short | long)
1990/03091    
	ret = -1; 
	if(!waserror()) 
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1990/0321    
else print("syscall %d err %d %d\n", r0, u->error.type, u->error.code); 
1990/0322    
/* else print("syscall %d err %d %d\n", r0, u->error.type, u->error.code); /**/ 
1990/03091    
	u->nerrlab = 0; 
	u->p->insyscall = 0; 
	if(r0 == NOTED)	/* ugly hack */ 
1990/0322/sys/src/9/gnot/trap.c:259,2761990/0511/sys/src/9/gnot/trap.c:259,284 (short | long)
1990/03091    
#endif 
	r0 = ur->r0; 
	sp = ur->usp; 
	if(r0 >= sizeof systab/BY2WD) 
		panic("syscall %d\n", r0); 
	if(sp & (BY2WD-1)) 
		panic("syscall odd sp"); 
	if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD)) 
		validaddr(sp, 4*BY2WD, 0); 
 
	u->nerrlab = 0; 
	ret = -1; 
	if(!waserror()) 
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1990/0322    
/* else print("syscall %d err %d %d\n", r0, u->error.type, u->error.code); /**/ 
1990/0511    
	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); 
		ret = (*systab[r1])((ulong*)(sp+2*BY2WD)); 
	} 
1990/03091    
	u->nerrlab = 0; 
	u->p->insyscall = 0; 
	if(r0 == NOTED)	/* ugly hack */ 
1990/0511/sys/src/9/gnot/trap.c:5,101990/0513/sys/src/9/gnot/trap.c:5,11 (short | long)
1990/03091    
#include	"fns.h" 
#include	"ureg.h" 
#include	"io.h" 
1990/0513    
#include	"errno.h" 
1990/03091    
 
void	notify(Ureg*); 
void	noted(Ureg**); 
1990/0511/sys/src/9/gnot/trap.c:241,2461990/0513/sys/src/9/gnot/trap.c:242,248
1990/03091    
	ulong sp; 
	ulong r0; 
	Ureg *ur; 
1990/0513    
	char *msg; 
1990/03091    
 
	u->p->insyscall = 1; 
	ur = aur; 
1990/0511/sys/src/9/gnot/trap.c:263,2701990/0513/sys/src/9/gnot/trap.c:265,272
1990/03091    
	u->nerrlab = 0; 
	ret = -1; 
1990/0511    
	if(!waserror()){ 
		if(r1 >= sizeof systab/BY2WD){ 
			pprint("bad sys call number %d pc %lux\n", r1, ((Ureg*)UREGADDR)->pc); 
1990/0513    
		if(r0 >= sizeof systab/BY2WD){ 
			pprint("bad sys call number %d pc %lux\n", r0, ((Ureg*)UREGADDR)->pc); 
1990/0511    
			msg = "bad sys call"; 
	    Bad: 
			postnote(u->p, 1, msg, NDebug); 
1990/0511/sys/src/9/gnot/trap.c:277,2831990/0513/sys/src/9/gnot/trap.c:279,285
1990/0511    
		} 
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD)) 
			validaddr(ur->sp, 4*BY2WD, 0); 
		ret = (*systab[r1])((ulong*)(sp+2*BY2WD)); 
1990/0513    
		ret = (*systab[r0])((ulong*)(sp+2*BY2WD)); 
1990/0511    
	} 
1990/03091    
	u->nerrlab = 0; 
	u->p->insyscall = 0; 
1990/0513/sys/src/9/gnot/trap.c:278,2851990/0515/sys/src/9/gnot/trap.c:278,285 (short | long)
1990/0511    
			goto Bad; 
		} 
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD)) 
			validaddr(ur->sp, 4*BY2WD, 0); 
1990/0513    
		ret = (*systab[r0])((ulong*)(sp+2*BY2WD)); 
1990/0515    
			validaddr(sp, 4*BY2WD, 0); 
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1990/0511    
	} 
1990/03091    
	u->nerrlab = 0; 
	u->p->insyscall = 0; 
1990/0515/sys/src/9/gnot/trap.c:186,1911990/0619/sys/src/9/gnot/trap.c:186,195 (short | long)
1990/03091    
{ 
	#ifdef asdfasdf 
	lock(&u->p->debug); 
1990/0619    
	if(!u->notified){ 
		unlock(&u->p->debug); 
		return; 
	} 
1990/03091    
	u->notified = 0; 
	memcpy(*urp, u->ureg, sizeof(Ureg)); 
	unlock(&u->p->debug); 
1990/0619/sys/src/9/gnot/trap.c:206,2121990/08141/sys/src/9/gnot/trap.c:206,212 (short | long)
1990/03091    
Syscall	sysr1, sysfork, sysexec, sysgetpid, syssleep, sysexits, syslasterr, syswait; 
Syscall	sysopen, sysclose, sysread, syswrite, sysseek, syserrstr, sysaccess, sysstat, sysfstat; 
Syscall sysdup, syschdir, sysforkpgrp, sysbind, sysmount, syspipe, syscreate, sysuserstr; 
Syscall	sysbrk_, sysremove, syswstat, sysfwstat; 
1990/08141    
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted; 
1990/03091    
 
Syscall *systab[]={ 
	sysr1, 
1990/0619/sys/src/9/gnot/trap.c:237,2421990/08141/sys/src/9/gnot/trap.c:237,244
1990/03091    
	sysremove, 
	syswstat, 
	sysfwstat, 
1990/08141    
	sysnotify, 
	sysnoted, 
1990/03091    
}; 
 
long 
1990/08141/sys/src/9/gnot/trap.c:156,1631990/0816/sys/src/9/gnot/trap.c:156,162 (short | long)
1990/03091    
	if(!u->notified){ 
		if(!u->notify) 
			goto Die; 
		#ifdef asdfasdf 
		sp = ur->sp; 
1990/0816    
		sp = ur->usp; 
1990/03091    
		sp -= sizeof(Ureg); 
		u->ureg = (void*)sp; 
		memcpy((Ureg*)sp, ur, sizeof(Ureg)); 
1990/08141/sys/src/9/gnot/trap.c:167,1791990/0816/sys/src/9/gnot/trap.c:166,176
1990/03091    
		*(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; 
1990/0816    
		ur->usp = sp; 
1990/03091    
		ur->pc = (ulong)u->notify; 
		u->notified = 1; 
		u->nnote--; 
		memcpy(&u->note[0], &u->note[1], u->nnote*sizeof(Note)); 
		#endif 
		panic("notify"); 
	} 
	unlock(&u->p->debug); 
} 
1990/08141/sys/src/9/gnot/trap.c:184,1901990/0816/sys/src/9/gnot/trap.c:181,186
1990/03091    
void 
noted(Ureg **urp) 
{ 
	#ifdef asdfasdf 
	lock(&u->p->debug); 
1990/0619    
	if(!u->notified){ 
		unlock(&u->p->debug); 
1990/08141/sys/src/9/gnot/trap.c:195,2021990/0816/sys/src/9/gnot/trap.c:191,196
1990/03091    
	unlock(&u->p->debug); 
	splhi(); 
	rfnote(urp); 
	#endif 
	panic("noted"); 
} 
 
#undef	CHDIR	/* BUG */ 
1990/0816/sys/src/9/gnot/trap.c:243,2481990/08163/sys/src/9/gnot/trap.c:243,249 (short | long)
1990/03091    
	ulong r0; 
	Ureg *ur; 
1990/0513    
	char *msg; 
1990/08163    
	long fpnull = 0; 
1990/03091    
 
	u->p->insyscall = 1; 
	ur = aur; 
1990/0816/sys/src/9/gnot/trap.c:249,2641990/08163/sys/src/9/gnot/trap.c:250,268
1990/0312    
	u->p->pc = ur->pc; 
1990/03091    
	if(ur->sr & SUPER) 
		panic("recursive system call"); 
#ifdef asdf 
	/* 
	 * since the system call interface does not 
	 * guarantee anything about registers 
1990/08163    
	 * guarantee anything about registers, but the fpcr is more than 
	 * just a register...  BUG 
1990/03091    
	 */ 
	if(u->p->fpstate == FPactive) { 
		u->p->fpstate = FPinit;		/* BUG */ 
		ur->status &= ~CU1; 
1990/08163    
	splhi(); 
	fpsave(&u->fpsave); 
	if(u->p->fpstate==FPactive || u->fpsave.type){ 
		fprestore((FPsave*)&fpnull); 
		u->p->fpstate = FPinit; 
		m->fpstate = FPinit; 
1990/03091    
	} 
#endif 
1990/08163    
	spllo(); 
1990/03091    
	r0 = ur->r0; 
	sp = ur->usp; 
 
1990/08163/sys/src/9/gnot/trap.c:94,1001990/0905/sys/src/9/gnot/trap.c:94,100 (short | long)
1990/03091    
		sprint(buf, "pc=%lux trap: %s", ur->pc, excname(ur->vo)); 
		postnote(u->p, 1, buf, NDebug); 
	}else{ 
		print("kernel trap vo=%ux pc=%lux\n", ur->vo, ur->pc); 
1990/0905    
		print("kernel trap vo=0x%ux pc=%lux\n", ur->vo, ur->pc); 
1990/03091    
		dumpregs(ur); 
		exit(); 
	} 
1990/08163/sys/src/9/gnot/trap.c:243,2491990/0905/sys/src/9/gnot/trap.c:243,248
1990/03091    
	ulong r0; 
	Ureg *ur; 
1990/0513    
	char *msg; 
1990/08163    
	long fpnull = 0; 
1990/03091    
 
	u->p->insyscall = 1; 
	ur = aur; 
1990/08163/sys/src/9/gnot/trap.c:258,2641990/0905/sys/src/9/gnot/trap.c:257,263
1990/08163    
	splhi(); 
	fpsave(&u->fpsave); 
	if(u->p->fpstate==FPactive || u->fpsave.type){ 
		fprestore((FPsave*)&fpnull); 
1990/0905    
		fprestore(&initfp); 
1990/08163    
		u->p->fpstate = FPinit; 
		m->fpstate = FPinit; 
1990/03091    
	} 
1990/0905/sys/src/9/gnot/trap.c:200,2061990/1104/sys/src/9/gnot/trap.c:200,206 (short | long)
1990/03091    
Syscall	sysr1, sysfork, sysexec, sysgetpid, syssleep, sysexits, syslasterr, syswait; 
Syscall	sysopen, sysclose, sysread, syswrite, sysseek, syserrstr, sysaccess, sysstat, sysfstat; 
Syscall sysdup, syschdir, sysforkpgrp, sysbind, sysmount, syspipe, syscreate, sysuserstr; 
1990/08141    
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted; 
1990/1104    
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted, sysfilsys; 
1990/03091    
 
Syscall *systab[]={ 
	sysr1, 
1990/0905/sys/src/9/gnot/trap.c:233,2381990/1104/sys/src/9/gnot/trap.c:233,239
1990/03091    
	sysfwstat, 
1990/08141    
	sysnotify, 
	sysnoted, 
1990/1104    
	sysfilsys, 
1990/03091    
}; 
 
long 
1990/1104/sys/src/9/gnot/trap.c:91,971990/1110/sys/src/9/gnot/trap.c:91,97 (short | long)
1990/03091    
	if(u) 
		u->p->pc = ur->pc;		/* BUG */ 
	if(user){ 
		sprint(buf, "pc=%lux trap: %s", ur->pc, excname(ur->vo)); 
1990/1110    
		sprint(buf, "sys: trap: %s", ur->pc, excname(ur->vo)); 
1990/03091    
		postnote(u->p, 1, buf, NDebug); 
	}else{ 
1990/0905    
		print("kernel trap vo=0x%ux pc=%lux\n", ur->vo, ur->pc); 
1990/1104/sys/src/9/gnot/trap.c:271,2771990/1110/sys/src/9/gnot/trap.c:271,277
1990/0511    
	if(!waserror()){ 
1990/0513    
		if(r0 >= sizeof systab/BY2WD){ 
			pprint("bad sys call number %d pc %lux\n", r0, ((Ureg*)UREGADDR)->pc); 
1990/0511    
			msg = "bad sys call"; 
1990/1110    
			msg = "sys: bad sys call"; 
1990/0511    
	    Bad: 
			postnote(u->p, 1, msg, NDebug); 
			error(0, Ebadarg); 
1990/1104/sys/src/9/gnot/trap.c:278,2841990/1110/sys/src/9/gnot/trap.c:278,284
1990/0511    
		} 
		if(sp & (BY2WD-1)){ 
			pprint("odd sp in sys call pc %lux sp %lux\n", ((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp); 
			msg = "odd stack"; 
1990/1110    
			msg = "sys: odd stack"; 
1990/0511    
			goto Bad; 
		} 
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD)) 
1990/1110/sys/src/9/gnot/trap.c:197,2211990/11211/sys/src/9/gnot/trap.c:197,221 (short | long)
1990/03091    
#include "/sys/src/libc/680209sys/sys.h" 
 
typedef long Syscall(ulong*); 
Syscall	sysr1, sysfork, sysexec, sysgetpid, syssleep, sysexits, syslasterr, syswait; 
1990/11211    
Syscall	sysr1, sysfork, sysexec, sysgetpid, syssleep, sysexits, sysdeath, syswait; 
1990/03091    
Syscall	sysopen, sysclose, sysread, syswrite, sysseek, syserrstr, sysaccess, sysstat, sysfstat; 
Syscall sysdup, syschdir, sysforkpgrp, sysbind, sysmount, syspipe, syscreate, sysuserstr; 
1990/1104    
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted, sysfilsys; 
1990/11211    
Syscall sysdup, syschdir, sysforkpgrp, sysbind, sysmount, syspipe, syscreate; 
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted; 
1990/03091    
 
Syscall *systab[]={ 
	sysr1, 
	sysaccess, 
1990/11211    
	syserrstr, 
1990/03091    
	sysbind, 
	syschdir, 
	sysclose, 
	sysdup, 
	syserrstr, 
1990/11211    
	sysdeath, 
1990/03091    
	sysexec, 
	sysexits, 
	sysfork, 
	sysforkpgrp, 
	sysfstat, 
	syslasterr, 
1990/11211    
	sysdeath, 
1990/03091    
	sysmount, 
	sysopen, 
	sysread, 
1990/1110/sys/src/9/gnot/trap.c:226,2321990/11211/sys/src/9/gnot/trap.c:226,232
1990/03091    
	syswrite, 
	syspipe, 
	syscreate, 
	sysuserstr, 
1990/11211    
	sysdeath, 
1990/03091    
	sysbrk_, 
	sysremove, 
	syswstat, 
1990/1110/sys/src/9/gnot/trap.c:233,2391990/11211/sys/src/9/gnot/trap.c:233,239
1990/03091    
	sysfwstat, 
1990/08141    
	sysnotify, 
	sysnoted, 
1990/1104    
	sysfilsys, 
1990/11211    
	sysdeath,	/* sysfilsys */ 
1990/03091    
}; 
 
long 
1990/1110/sys/src/9/gnot/trap.c:274,2801990/11211/sys/src/9/gnot/trap.c:274,280
1990/1110    
			msg = "sys: bad sys call"; 
1990/0511    
	    Bad: 
			postnote(u->p, 1, msg, NDebug); 
			error(0, Ebadarg); 
1990/11211    
			error(Ebadarg); 
1990/0511    
		} 
		if(sp & (BY2WD-1)){ 
			pprint("odd sp in sys call pc %lux sp %lux\n", ((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp); 
1990/1110/sys/src/9/gnot/trap.c:281,2881990/11211/sys/src/9/gnot/trap.c:281,288
1990/1110    
			msg = "sys: odd stack"; 
1990/0511    
			goto Bad; 
		} 
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-4*BY2WD)) 
1990/0515    
			validaddr(sp, 4*BY2WD, 0); 
1990/11211    
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-5*BY2WD)) 
			validaddr(sp, 5*BY2WD, 0); 
1990/0515    
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1990/0511    
	} 
1990/03091    
	u->nerrlab = 0; 
1990/1110/sys/src/9/gnot/trap.c:296,3141990/11211/sys/src/9/gnot/trap.c:296,317
1990/03091    
	return ret; 
} 
 
1990/11211    
#include "errstr.h" 
 
1990/03091    
void 
error(Chan *c, int code) 
1990/11211    
error(int code) 
1990/03091    
{ 
	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; 
1990/11211    
	strncpy(u->error, errstrtab[code], NAMELEN); 
1990/03091    
	nexterror(); 
} 
1990/11211    
 
void 
errors(char *err) 
{ 
	strncpy(u->error, err, NAMELEN); 
	nexterror(); 
} 
 
1990/03091    
 
void 
nexterror(void) 
1990/11211/sys/src/9/gnot/trap.c:91,1001990/1127/sys/src/9/gnot/trap.c:91,100 (short | long)
1990/03091    
	if(u) 
		u->p->pc = ur->pc;		/* BUG */ 
	if(user){ 
1990/1110    
		sprint(buf, "sys: trap: %s", ur->pc, excname(ur->vo)); 
1990/1127    
		sprint(buf, "sys: trap: pc=0x%lux %s", ur->pc, excname(ur->vo)); 
1990/03091    
		postnote(u->p, 1, buf, NDebug); 
	}else{ 
1990/0905    
		print("kernel trap vo=0x%ux pc=%lux\n", ur->vo, ur->pc); 
1990/1127    
		print("kernel trap vo=0x%ux pc=0x%lux\n", ur->vo, ur->pc); 
1990/03091    
		dumpregs(ur); 
		exit(); 
	} 
1990/1127/sys/src/9/gnot/trap.c:296,3011990/1226/sys/src/9/gnot/trap.c:296,307 (short | long)
1990/03091    
	return ret; 
} 
 
1990/1226    
void 
execpc(ulong entry) 
{ 
	((Ureg*)UREGADDR)->pc = entry; 
} 
 
1990/11211    
#include "errstr.h" 
 
1990/03091    
void 
1990/1226/sys/src/9/gnot/trap.c:307,3131991/0115/sys/src/9/gnot/trap.c:307,313 (short | long)
1990/03091    
void 
1990/11211    
error(int code) 
1990/03091    
{ 
1990/11211    
	strncpy(u->error, errstrtab[code], NAMELEN); 
1991/0115    
	strncpy(u->error, errstrtab[code], ERRLEN); 
1990/03091    
	nexterror(); 
} 
1990/11211    
 
1991/0115/sys/src/9/gnot/trap.c:159,1671991/0318/sys/src/9/gnot/trap.c:159,167 (short | long)
1990/0816    
		sp = ur->usp; 
1990/03091    
		sp -= sizeof(Ureg); 
		u->ureg = (void*)sp; 
		memcpy((Ureg*)sp, ur, sizeof(Ureg)); 
1991/0318    
		memmove((Ureg*)sp, ur, sizeof(Ureg)); 
1990/03091    
		sp -= ERRLEN; 
		memcpy((char*)sp, u->note[0].msg, ERRLEN); 
1991/0318    
		memmove((char*)sp, u->note[0].msg, ERRLEN); 
1990/03091    
		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* */ 
1991/0115/sys/src/9/gnot/trap.c:170,1761991/0318/sys/src/9/gnot/trap.c:170,176
1990/03091    
		ur->pc = (ulong)u->notify; 
		u->notified = 1; 
		u->nnote--; 
		memcpy(&u->note[0], &u->note[1], u->nnote*sizeof(Note)); 
1991/0318    
		memmove(&u->note[0], &u->note[1], u->nnote*sizeof(Note)); 
1990/03091    
	} 
	unlock(&u->p->debug); 
} 
1991/0115/sys/src/9/gnot/trap.c:187,1931991/0318/sys/src/9/gnot/trap.c:187,193
1990/0619    
		return; 
	} 
1990/03091    
	u->notified = 0; 
	memcpy(*urp, u->ureg, sizeof(Ureg)); 
1991/0318    
	memmove(*urp, u->ureg, sizeof(Ureg)); 
1990/03091    
	unlock(&u->p->debug); 
	splhi(); 
	rfnote(urp); 
1991/0318/sys/src/9/gnot/trap.c:314,3201991/0322/sys/src/9/gnot/trap.c:314,320 (short | long)
1990/11211    
void 
errors(char *err) 
{ 
	strncpy(u->error, err, NAMELEN); 
1991/0322    
	strncpy(u->error, err, ERRLEN); 
1990/11211    
	nexterror(); 
} 
 
1991/0322/sys/src/9/gnot/trap.c:8,151991/0503/sys/src/9/gnot/trap.c:8,15 (short | long)
1990/0513    
#include	"errno.h" 
1990/03091    
 
void	notify(Ureg*); 
void	noted(Ureg**); 
void	rfnote(Ureg**); 
1991/0503    
void	noted(Ureg*); 
void	rfnote(Ureg*); 
1990/03091    
 
char *regname[]={ 
	"R0", 
1991/0322/sys/src/9/gnot/trap.c:156,1611991/0503/sys/src/9/gnot/trap.c:156,163
1990/03091    
	if(!u->notified){ 
		if(!u->notify) 
			goto Die; 
1991/0503    
		u->svvo = ur->vo; 
		u->svsr = ur->sr; 
1990/0816    
		sp = ur->usp; 
1990/03091    
		sp -= sizeof(Ureg); 
		u->ureg = (void*)sp; 
1991/0322/sys/src/9/gnot/trap.c:179,1861991/0503/sys/src/9/gnot/trap.c:181,197
1990/03091    
 * Return user to state before notify() 
 */ 
void 
noted(Ureg **urp) 
1991/0503    
noted(Ureg *ur) 
1990/03091    
{ 
1991/0503    
	Ureg *nur; 
 
	nur = u->ureg; 
	validaddr(nur->pc, 1, 0); 
	validaddr(nur->usp, BY2WD, 0); 
	if(nur->sr!=u->svsr || nur->vo!=u->svvo){ 
		pprint("bad noted ureg sr %ux vo %ux\n", nur->sr, nur->vo); 
		pexit("Suicide", 0); 
	} 
1990/03091    
	lock(&u->p->debug); 
1990/0619    
	if(!u->notified){ 
		unlock(&u->p->debug); 
1991/0322/sys/src/9/gnot/trap.c:187,1961991/0503/sys/src/9/gnot/trap.c:198,207
1990/0619    
		return; 
	} 
1990/03091    
	u->notified = 0; 
1991/0318    
	memmove(*urp, u->ureg, sizeof(Ureg)); 
1991/0503    
	memmove(ur, u->ureg, sizeof(Ureg)); 
1990/03091    
	unlock(&u->p->debug); 
	splhi(); 
	rfnote(urp); 
1991/0503    
	rfnote(ur); 
1990/03091    
} 
 
#undef	CHDIR	/* BUG */ 
1991/0322/sys/src/9/gnot/trap.c:288,2941991/0503/sys/src/9/gnot/trap.c:299,305
1990/03091    
	u->nerrlab = 0; 
	u->p->insyscall = 0; 
	if(r0 == NOTED)	/* ugly hack */ 
		noted(&aur);	/* doesn't return */ 
1991/0503    
		noted(aur);	/* doesn't return */ 
1990/03091    
	if(u->nnote){ 
		ur->r0 = ret; 
		notify(ur); 
1991/0503/sys/src/9/gnot/trap.c:211,2171991/0513/sys/src/9/gnot/trap.c:211,217 (short | long)
1990/11211    
Syscall	sysr1, sysfork, sysexec, sysgetpid, syssleep, sysexits, sysdeath, syswait; 
1990/03091    
Syscall	sysopen, sysclose, sysread, syswrite, sysseek, syserrstr, sysaccess, sysstat, sysfstat; 
1990/11211    
Syscall sysdup, syschdir, sysforkpgrp, sysbind, sysmount, syspipe, syscreate; 
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted; 
1991/0513    
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted, sysalarm; 
1990/03091    
 
Syscall *systab[]={ 
	sysr1, 
1991/0503/sys/src/9/gnot/trap.c:220,2261991/0513/sys/src/9/gnot/trap.c:220,226
1990/03091    
	syschdir, 
	sysclose, 
	sysdup, 
1990/11211    
	sysdeath, 
1991/0513    
	sysalarm, 
1990/03091    
	sysexec, 
	sysexits, 
	sysfork, 
1991/0513/sys/src/9/gnot/trap.c:250,2551991/0614/sys/src/9/gnot/trap.c:250,256 (short | long)
1990/03091    
long 
syscall(Ureg *aur) 
{ 
1991/0614    
	int i; 
1990/03091    
	long ret; 
	ulong sp; 
	ulong r0; 
1991/0513/sys/src/9/gnot/trap.c:292,3021991/0614/sys/src/9/gnot/trap.c:293,309
1990/1110    
			msg = "sys: odd stack"; 
1990/0511    
			goto Bad; 
		} 
1990/11211    
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-5*BY2WD)) 
			validaddr(sp, 5*BY2WD, 0); 
1991/0614    
		if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(1+MAXSYSARG)*BY2WD)) 
			validaddr(sp, (1+MAXSYSARG)*BY2WD, 0); 
1990/0515    
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1991/0614    
		poperror(); 
1990/0511    
	} 
1990/03091    
	u->nerrlab = 0; 
1991/0614    
	if(u->nerrlab){ 
		print("unbalanced error stack: %d extra\n", u->nerrlab); 
		for(i = 0; i < NERR; i++) 
			print("sp=%lux pc=%lux\n", u->errlab[i].sp, u->errlab[i].pc); 
		panic("bad rob"); 
	} 
1990/03091    
	u->p->insyscall = 0; 
	if(r0 == NOTED)	/* ugly hack */ 
1991/0503    
		noted(aur);	/* doesn't return */ 
1991/0614/sys/src/9/gnot/trap.c:91,971991/0705/sys/src/9/gnot/trap.c:91,97 (short | long)
1990/03091    
	if(u) 
		u->p->pc = ur->pc;		/* BUG */ 
	if(user){ 
1990/1127    
		sprint(buf, "sys: trap: pc=0x%lux %s", ur->pc, excname(ur->vo)); 
1991/0705    
		sprint(buf, "sys: %s pc=0x%lux", excname(ur->vo), ur->pc); 
1990/03091    
		postnote(u->p, 1, buf, NDebug); 
	}else{ 
1990/1127    
		print("kernel trap vo=0x%ux pc=0x%lux\n", ur->vo, ur->pc); 
1991/0614/sys/src/9/gnot/trap.c:98,1031991/0705/sys/src/9/gnot/trap.c:98,104
1990/03091    
		dumpregs(ur); 
		exit(); 
	} 
1991/0705    
 
1990/03091    
	if(user && u->nnote) 
		notify(ur); 
} 
1991/0614/sys/src/9/gnot/trap.c:130,1351991/0705/sys/src/9/gnot/trap.c:131,137
1990/03091    
	l = &ur->r0; 
	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]); 
1991/0705    
	for(;;); 
1990/03091    
	dumpstack(); 
} 
 
1991/0614/sys/src/9/gnot/trap.c:212,2171991/0705/sys/src/9/gnot/trap.c:214,220
1990/03091    
Syscall	sysopen, sysclose, sysread, syswrite, sysseek, syserrstr, sysaccess, sysstat, sysfstat; 
1990/11211    
Syscall sysdup, syschdir, sysforkpgrp, sysbind, sysmount, syspipe, syscreate; 
1991/0513    
Syscall	sysbrk_, sysremove, syswstat, sysfwstat, sysnotify, sysnoted, sysalarm; 
1991/0705    
Syscall syssegattach, syssegdetach, syssegfree, syssegflush, syssegbrk; 
1990/03091    
 
Syscall *systab[]={ 
	sysr1, 
1991/0614/sys/src/9/gnot/trap.c:226,2321991/0705/sys/src/9/gnot/trap.c:229,235
1990/03091    
	sysfork, 
	sysforkpgrp, 
	sysfstat, 
1990/11211    
	sysdeath, 
1991/0705    
	syssegbrk, 
1990/03091    
	sysmount, 
	sysopen, 
	sysread, 
1991/0614/sys/src/9/gnot/trap.c:244,2501991/0705/sys/src/9/gnot/trap.c:247,256
1990/03091    
	sysfwstat, 
1990/08141    
	sysnotify, 
	sysnoted, 
1990/11211    
	sysdeath,	/* sysfilsys */ 
1991/0705    
	syssegattach, 
	syssegdetach, 
	syssegfree, 
	syssegflush, 
1990/03091    
}; 
 
long 
1991/0614/sys/src/9/gnot/trap.c:289,2951991/0705/sys/src/9/gnot/trap.c:295,302
1990/11211    
			error(Ebadarg); 
1990/0511    
		} 
		if(sp & (BY2WD-1)){ 
			pprint("odd sp in sys call pc %lux sp %lux\n", ((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp); 
1991/0705    
			pprint("odd sp in sys call pc %lux sp %lux\n",  
				((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp); 
1990/1110    
			msg = "sys: odd stack"; 
1990/0511    
			goto Bad; 
		} 
1991/0614/sys/src/9/gnot/trap.c:298,3111991/0705/sys/src/9/gnot/trap.c:305,323
1990/0515    
		ret = (*systab[r0])((ulong*)(sp+BY2WD)); 
1991/0614    
		poperror(); 
1990/0511    
	} 
1991/0705    
 
#ifdef Check 
1991/0614    
	if(u->nerrlab){ 
		print("unbalanced error stack: %d extra\n", u->nerrlab); 
1991/0705    
		print("bad errstack [%d]: %d extra\n", r0, u->nerrlab); 
1991/0614    
		for(i = 0; i < NERR; i++) 
			print("sp=%lux pc=%lux\n", u->errlab[i].sp, u->errlab[i].pc); 
		panic("bad rob"); 
	} 
1991/0705    
#endif 
 
1990/03091    
	u->p->insyscall = 0; 
	if(r0 == NOTED)	/* ugly hack */ 
1991/0705    
 
	if(r0 == NOTED)		/* ugly hack */ 
1991/0503    
		noted(aur);	/* doesn't return */ 
1990/03091    
	if(u->nnote){ 
		ur->r0 = ret; 
1991/0705/sys/src/9/gnot/trap.c:306,3191991/0709/sys/src/9/gnot/trap.c:306,317 (short | long)
1991/0614    
		poperror(); 
1990/0511    
	} 
1991/0705    
 
#ifdef Check 
1991/0614    
	if(u->nerrlab){ 
1991/0705    
		print("bad errstack [%d]: %d extra\n", r0, u->nerrlab); 
1991/0614    
		for(i = 0; i < NERR; i++) 
			print("sp=%lux pc=%lux\n", u->errlab[i].sp, u->errlab[i].pc); 
		panic("bad rob"); 
1991/0709    
		panic("error stack"); 
1991/0614    
	} 
1991/0705    
#endif 
 
1990/03091    
	u->p->insyscall = 0; 
1991/0705    
 
Too many diffs (26 > 25). Stopping.


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)