~kris/9p

9hist

ff2bbb664f3cd3e0481e4448bd8ea9b21e7eebd4 — David du Colombier 35 years ago 81e0270
Plan 9 from Bell Labs 1991-09-13
8 files changed, 67 insertions(+), 61 deletions(-)

M gnot/disk.c
M pc/devfloppy.c
M pc/fns.h
M pc/l.s
M pc/main.c
M pc/trap.c
M port/devcons.c
M port/devroot.c
M gnot/disk.c => gnot/disk.c +1 -3
@@ 50,8 50,6 @@ void streaminit0(void){
	newqinfo(&asyncinfo);
	newqinfo(&fcallinfo);
}
	/*
	 *  fake cryptfs
	 */
	long kfslen = 0; ulong kfscode[1];
	long cryptfslen = 0; ulong cryptfscode[1];
	#include "cfs.h"

M pc/devfloppy.c => pc/devfloppy.c +0 -2
@@ 420,8 420,6 @@ floppykproc(void *a)
			}
		}
		disp++;
		if(owl(disp&1) < 0)
			print("owl failed\n");
		tsleep(&floppy.kr, return0, 0, 5*1000);
		
	}

M pc/fns.h => pc/fns.h +2 -3
@@ 16,20 16,19 @@ void	fclockinit(void);
#define	flushvirt();
void	fpinit(void);
void	fpoff(void);
void	fpsave(FPsave*);
void	fprestore(FPsave*);
void	fpsave(FPsave*);
ulong	fpstatus(void);
ulong	getcr0(void);
ulong	getcr2(void);
void	idle(void);
int	inb(int);
void	inss(int, void*, int);
void	kbdinit(void);
int	mail(int);
void	mathinit(void);
void	mmuinit(void);
void	outb(int, int);
void	outss(int, void*, int);
int	owl(int);
void	prhex(ulong);
void	procrestore(Proc*, uchar*);
void	procsave(uchar*, int);

M pc/l.s => pc/l.s +4 -0
@@ 322,6 322,10 @@ TEXT	fprestore(SB),$0	/* turn on floating point and restore regs */
	WAIT
	RET

TEXT	fpstatus(SB),$0		/* get floating point status */
	FSTSW	AX
	RET

/*
 *  special traps
 */

M pc/main.c => pc/main.c +53 -36
@@ 222,25 222,44 @@ confinit(void)
	conf.nhard = 1;
}

/*
 *  math coprocessor error
 */
void
matherror1(Ureg *ur)
char *mathmsg[] =
{
print("matherror1\n");
	pexit("Math error", 0);
}
	"invalid",
	"denormalized",
	"div-by-zero",
	"overflow",
	"underflow",
	"precision",
	"stack",
	"error",
};

/*
 *  math coprocessor error
 */
void
matherror2(Ureg *ur)
matherror(Ureg *ur)
{
	outb(0xF0, 0xFF);	/* bad craziness */
print("matherror2\n");
	pexit("Math error", 0);
	ulong status;
	int i;
	char *msg;
	char note[ERRLEN];

	/*
	 *  a write cycle to port 0xF0 clears the interrupt latch attached
	 *  to the error# line from the 387
	 */
	outb(0xF0, 0xFF);

	status = fpstatus() & 0xffff;
	msg = "unknown";
	for(i = 0; i < 8; i++)
		if((1<<i) & status){
			msg = mathmsg[i];
			break;
		}
	sprint(note, "math: %s, status 0x%ux, pc 0x%lux", msg, status, ur->pc);
	postnote(u->p, 1, note, NDebug);
}

/*


@@ 270,15 289,14 @@ mathemu(Ureg *ur)
void
mathover(Ureg *ur)
{
print("mathover\n");
	pexit("Math overrun", 0);
}

void
mathinit(void)
{
	setvec(Matherr1vec, matherror1);
	setvec(Matherr2vec, matherror2);
	setvec(Matherr1vec, matherror);
	setvec(Matherr2vec, matherror);
	setvec(Mathemuvec, mathemu);
	setvec(Mathovervec, mathover);
}


@@ 320,19 338,6 @@ firmware(void)
}

/*
 *  make noise, blink lights
 */
void
buzz(int f, int d)
{
}

void
lights(int val)
{
}

/*
 *  special stuff for 80c51 power management and headland system controller
 */
enum


@@ 443,8 448,8 @@ pmuwrbit(int index, int bit, int pos)
}

/*
 *  control power to the serial line
 *	onoff == 0 means turn power on
 *  power to serial port
 *	onoff == 0 means on
 *	onoff == 1 means off
 */
int


@@ 453,14 458,26 @@ serial(int onoff)
	return pmuwrbit(1, onoff, 6);
}

int
owl(int onoff)
void
buzz(int f, int d)
{
	return pmuwrbit(0, onoff, 4);
	static Rendez br;
	static QLock bl;

	qlock(&bl);
	pmuwrbit(0, 0, 6);
	tsleep(&br, return0, 0, d);
	pmuwrbit(0, 1, 6);
	qunlock(&bl);
}

int
mail(int onoff)
void
lights(int val)
{
	return pmuwrbit(0, onoff, 1);
	static QLock ll;

	qlock(&ll);
	pmuwrbit(0, (val&1), 4);		/* owl */
	pmuwrbit(0, ((val>>1)&1), 1);		/* mail */
	qunlock(&ll);
}

M pc/trap.c => pc/trap.c +4 -2
@@ 119,7 119,7 @@ trapinit(void)
	sethvec(34, intr34, SEGIG, 0);
	sethvec(35, intr35, SEGIG, 0);
	sethvec(36, intr36, SEGIG, 0);
	sethvec(37, intr37, SEGTG, 0);
	sethvec(37, intr37, SEGIG, 0);
	sethvec(38, intr38, SEGIG, 0);
	sethvec(39, intr39, SEGIG, 0);



@@ 194,9 194,11 @@ trap(Ureg *ur)
			uartintr0(ur);
	}

if(v==16) print("vec thru 16\n");
	(*ivec[v])(ur);

	/*
	 *  syscall does it's own notifying
	 */
	if(((ur->cs)&0xffff)!=KESEL && u->nnote && v!=Syscallvec)
		notify(ur);
}

M port/devcons.c => port/devcons.c +2 -0
@@ 626,6 626,8 @@ consread(Chan *c, void *buf, long n, ulong offset)
				conf.nswap-swapalloc.free, conf.nswap);

		return readstr(offset, buf, n, xbuf);
	case Qlights:
		errors("write only");
	default:
		panic("consread %lux\n", c->qid);
		return 0;

M port/devroot.c => port/devroot.c +1 -15
@@ 11,7 11,6 @@ enum{
	Qbin,
	Qboot,
	Qcfs,
	Qcryptfs,
	Qdev,
	Qenv,
	Qkfs,


@@ 22,8 21,6 @@ extern long	cfslen;
extern ulong	cfscode[];
extern long	kfslen;
extern ulong	kfscode[];
extern long	cryptfslen;
extern ulong	cryptfscode[];

Dirtab rootdir[]={
	"bin",		{Qbin|CHDIR},	0,			0700,


@@ 35,7 32,6 @@ Dirtab rootdir[]={
#define	NROOT	(sizeof rootdir/sizeof(Dirtab))
Dirtab rootpdir[]={
	"cfs",		{Qcfs},		0,			0700,
	"cryptfs",	{Qcryptfs},	0,			0700,
	"kfs",		{Qkfs},		0,			0700,
};
Dirtab *rootmap[sizeof rootpdir/sizeof(Dirtab)];


@@ 62,10 58,8 @@ rootreset(void)
	i = 0;
	if(cfslen)
		rootmap[i++] = &rootpdir[0];
	if(cryptfslen)
		rootmap[i++] = &rootpdir[1];
	if(kfslen)
		rootmap[i++] = &rootpdir[2];
		rootmap[i++] = &rootpdir[1];
	nroot = NROOT + i;
}



@@ 152,14 146,6 @@ rootread(Chan *c, void *buf, long n, ulong offset)
		memmove(buf, ((char*)kfscode)+offset, n);
		return n;

	case Qcryptfs:		/* cryptfs */
		if(offset >= cryptfslen)
			return 0;
		if(offset+n > cryptfslen)
			n = cryptfslen - offset;
		memmove(buf, ((char*)cryptfscode)+offset, n);
		return n;

	case Qdev:
		return 0;
	}