~kris/9p

9hist

c054d30736657f9a69f65d320ab94b47344ec036 — David du Colombier 32 years ago d5b75b1
Plan 9 from Bell Labs 1994-08-17
M carrera/clock.c => carrera/clock.c +1 -1
@@ 93,7 93,7 @@ clock(Ureg *ur)
	checkalarms();
	mouseclock();

	if(up == 0 || (ur->status&IE) == 0 || up->state != Running)
	if(up == 0 || up->state != Running)
		return;

	if(anyready())

M carrera/trap.c => carrera/trap.c +5 -0
@@ 361,12 361,17 @@ intr(Ureg *ur)
	if(cause & INTR7) {
		clock(ur);
		cause &= ~INTR7;
		return;
	}

	if(cause) {
		iprint("cause %lux\n", cause);
		exit(1);
	}

	/* preemptive scheduling */
	if(up && up->state == Running && anyhigher())
		sched();
}

char*

M pc/fns.h => pc/fns.h +2 -0
@@ 87,6 87,8 @@ int	tas(void*);
void	uartclock(void);
void	uartpoll(void);
void	vgainit(void);
void	vgasavecrash(uchar*, int);
void	vgarestorecrash(uchar*, int);
int	x86(void);

#define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))

M pc/main.c => pc/main.c +2 -17
@@ 390,20 390,13 @@ confinit(void)
	}

	/*
	 *  zero and clear all except first 2 meg and crash area.
	 *  put crash area at high end of memory.
	 *  zero and clear all except first 2 meg.
	 */
	x = 0x12345678;
	for(i = MAXMEG; i > 1; i--){
		if(mmap[i] != 'x')
			continue;
		j = MB;
		if(crasharea == 0){
			crasharea = (i+1)*MB - PGROUND(CRASHSIZE);
			crashend = crasharea + CRASHSIZE;
			j = MB - PGROUND(CRASHSIZE);
		}
		if(memclrtest(i, j, x) < 0)
		if(memclrtest(i, MB, x) < 0)
			mmap[i] = ' ';
		x += 0x3141526;
	}


@@ 418,8 411,6 @@ confinit(void)
		;
	conf.npage0 = (i*MB - ktop)/BY2PG;
	conf.topofmem = i*MB;
	if(crasharea < conf.base0 + BY2PG*conf.npage0)
		conf.npage0 -= PGROUND(CRASHSIZE)/BY2PG;

	/*
	 *  bank1 usually goes from the end of BOOTARGS to 640k


@@ 441,15 432,9 @@ confinit(void)
				;
			conf.npage1 = (j - i)*MB/BY2PG;
			conf.topofmem = j*MB;
			if(crasharea < conf.base1 + BY2PG*conf.npage1)
				conf.npage1 -= PGROUND(CRASHSIZE)/BY2PG;
			break;
		}

	/* make crasharea a virtual address */
	crasharea |= KZERO;
	crashend |= KZERO;

	conf.npage = conf.npage0 + conf.npage1;
	conf.ldepth = 0;
	if(pcnt < 10)

M pc/mem.h => pc/mem.h +0 -5
@@ 56,11 56,6 @@
#define	MACHSIZE	4096

/*
 *  an area for storing crash info to be picked up later
 */
#define CRASHSIZE	(KSTACK+BY2PG)

/*
 *  known 80386 segments (in GDT) and their selectors
 */
#define	NULLSEG	0	/* null segment */

M pc/trap.c => pc/trap.c +0 -33
@@ 61,19 61,6 @@ struct
	int	free;
} halloc;

/*
 *  somewhere to drop crash info
 */
typedef struct
{
	ulong	magic;
	void	*kbot;
	void	*ksp;
	char	text[NAMELEN];
	Ureg	ureg;
	uchar	kstack[KSTACK];
} Crashstate;

void
sethvec(int v, void (*r)(void), int type, int pri)
{


@@ 353,7 340,6 @@ dumpregs2(Ureg *ur)
void
dumpregs(Ureg *ur)
{
	Crashstate *cs;
	extern ulong etext;
	ulong *x;



@@ 362,13 348,6 @@ dumpregs(Ureg *ur)
	dumpregs2(ur);
	print("  magic %lux %lux %lux\n", x[0], x[1], x[2]);
	print("  ur %lux up %lux\n", ur, up);

	/* save crash info */
	if(crasharea == 0)
		return;
	print("crasharea 0x%lux\n", crasharea);
	cs = (Crashstate*)crasharea;
	memmove(&cs->ureg, ur, sizeof(Ureg));
}

void


@@ 376,7 355,6 @@ dumpstack(void)
{
	ulong l, v, i;
	extern ulong etext;
	Crashstate *cs;

	if(up == 0)
		return;


@@ 393,17 371,6 @@ dumpstack(void)
			print("\n");
		}
	}

	/* save crash info */
	if(crasharea == 0)
		return;
	print("crasharea 0x%lux\n", crasharea);
	cs = (Crashstate*)crasharea;
	memmove(cs->kstack, up->kstack, KSTACK);
	cs->kbot = up->kstack;
	memmove(cs->text, up->text, NAMELEN);
	cs->magic = 0xdeaddead;
	cs->ksp = &l;
}

/*

M port/cache.c => port/cache.c +2 -0
@@ 67,6 67,8 @@ cinit(void)
	cache.tail = m;
	cache.tail->next = 0;
	cache.head->prev = 0;

	fscache.notext = 1;
}

void

M port/devproc.c => port/devproc.c +10 -10
@@ 49,10 49,6 @@ Dirtab procdir[] =
/* Segment type from portdat.h */
char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", "Shdata" };

/* where to put crash information when memory isn't wiped */
ulong crasharea;
ulong crashend;

/*
 * Qids are, in path:
 *	 4 bits of file type (qids above)


@@ 318,12 314,6 @@ procread(Chan *c, void *va, long n, ulong offset)
			memmove(a, (char*)offset, n);
			return n;
		}
		if(offset >= crasharea && offset < crashend){
			if(offset+n > crashend)
				n = crashend - offset;
			memmove(a, (char*)offset, n);
			return n;
		}
		error(Ebadarg);

	case Qnote:


@@ 697,6 687,7 @@ void
procctlreq(Proc *p, char *va, int n)
{
	char buf[NAMELEN];
	int i;

	if(n > NAMELEN)
		n = NAMELEN;


@@ 744,6 735,15 @@ procctlreq(Proc *p, char *va, int n)
		ready(p);
	}
	else
	if(strncmp(buf, "pri", 3) == 0){
		if(n < 4)
			error(Ebadarg);
		i = atoi(buf+4);
		if(i < 0 || i >= Nrq)
			error(Ebadarg);
		p->basepri = i;
	}
	else
		error(Ebadctl);
}


M port/page.c => port/page.c +3 -5
@@ 250,11 250,9 @@ duppage(Page *p)				/* Always call with p locked */
	Page *np;
	int color;

	/* No dup for swap pages */
	if(p->image == &swapimage) {
		uncachepage(p);	
	/* No dup for swap/cache pages */
	if(p->image->notext)
		return;
	}

	lock(&palloc);
	/* No freelist cache when memory is very low */


@@ 333,7 331,7 @@ uncachepage(Page *p)			/* Always called with a locked page */
{
	Page **l, *f;

	if(p->image == 0)
	if(p->image == 0 || p->image->notext)
		return;

	lock(&palloc.hashlock);

M port/portdat.h => port/portdat.h +4 -1
@@ 315,6 315,7 @@ struct Image
	Segment *s;			/* TEXT segment for image if running */
	Image	*hash;			/* Qid hash chains */
	Image	*next;			/* Free list */
	int	notext;			/* no file associated */
};

struct Pte


@@ 500,7 501,9 @@ enum
	NERR = 15,
	NNOTE = 5,

	Nrq	= 5,
	Nrq		= 20,
	PriNormal	= 10,
	PriRoot		= 5,
};

struct Proc

M port/portfns.h => port/portfns.h +1 -1
@@ 1,8 1,8 @@
void		addrootfile(char*, uchar*, ulong);
void		alarmkproc(void*);
Block*		allocb(int);
int		anyhigher(void);
int		anyready(void);
int		anyready0(void);
Image*		attachimage(int, Chan*, ulong, ulong);
long		authcheck(Chan*, char*, int);
void		authclose(Chan*);

M port/proc.c => port/proc.c +9 -2
@@ 23,6 23,7 @@ struct


int	nrdy;
int	lastreadied;
Schedq	runq[Nrq];

char *statename[] =


@@ 107,9 108,13 @@ anyready(void)
}

int
anyready0(void)
anyhigher(void)
{
	return runq->head != 0;
	int x;

	x = lastreadied;
	lastreadied = Nrq;
	return nrdy && x <= up->priority;
}

void


@@ 138,6 143,8 @@ ready(Proc *p)
	nrdy++;
	p->readyticks = m->ticks;
	p->state = Ready;
	if(lastreadied > p->priority)
		lastreadied = p->priority;
	unlock(runq);
	splx(s);
}

M port/segment.c => port/segment.c +2 -2
@@ 274,7 274,7 @@ imagereclaim(void)
	lock(&palloc);
	for(p = palloc.head; p; p = p->next) {
		if(p->ref == 0 && p->image && canlock(p)) {
			if(p->ref == 0 && p->image != &swapimage)
			if(p->ref == 0)
				uncachepage(p);
			unlock(p);
		}


@@ 289,7 289,7 @@ putimage(Image *i)
	Chan *c;
	Image *f, **l;

	if(i == &swapimage)
	if(i->notext)
		return;

	lock(i);

M port/swap.c => port/swap.c +2 -0
@@ 33,6 33,8 @@ swapinit(void)
	iolist = xalloc(Maxpages*sizeof(Page*));
	if(swapalloc.swmap == 0 || iolist == 0)
		panic("swapinit: not enough memory");

	swapimage.notext = 1;
}

ulong

M port/sysproc.c => port/sysproc.c +2 -2
@@ 397,9 397,9 @@ sysexec(ulong *arg)
	 *  '/' processes are high priority (hack to make /ip more responsive)
	 */
	if(devchar[tc->type] == L'/')
		up->basepri = 0;
		up->basepri = PriRoot;
	else
		up->basepri = 1;
		up->basepri = PriNormal;
	up->priority = up->basepri;
	poperror();
	close(tc);