~kris/9p

9hist

76ff7c4a22a87506651c81471c10e21bcff57898 — David du Colombier 30 years ago 004f5d0
Plan 9 from Bell Labs 1996-03-03
7 files changed, 81 insertions(+), 10 deletions(-)

M carrera/clock.c
M pc/clock.c
M pc/devi82365.c
M port/devproc.c
M port/portdat.h
M port/portfns.h
M port/segment.c
M carrera/clock.c => carrera/clock.c +6 -2
@@ 47,6 47,8 @@ clockinit(void)
void
clock(Ureg *ur)
{
	int l;
	Segment *s;

	wrcompare(rdcount()+(m->speed*1000000)/HZ);



@@ 82,6 84,8 @@ clock(Ureg *ur)
		sched();

	/* user profiling clock */
	if(ur->status & KUSER)
		(*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1);	
	if(ur->status & KUSER) {
		(*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1);
		segclock(ur->pc);
	}
}

M pc/clock.c => pc/clock.c +3 -1
@@ 54,8 54,10 @@ clock(Ureg *ur, void *arg)
			sched();
	
		/* user profiling clock */
		if((ur->cs&0xffff) == UESEL)
		if((ur->cs&0xffff) == UESEL) {
			(*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1);
			segclock(ur->pc);
		}
	}
}


M pc/devi82365.c => pc/devi82365.c +2 -1
@@ 5,7 5,6 @@
#include "fns.h"
#include "../port/error.h"
#include "io.h"
#include "devtab.h"

/*
 *  Support for up to 4 Slot card slots.  Generalizing above that is hard


@@ 189,6 188,8 @@ static int	pcmio(int, ISAConf*);
static long	pcmread(int, int, void*, long, ulong);
static long	pcmwrite(int, int, void*, long, ulong);

void i82365reset(void);

/*
 *  reading and writing card registers
 */

M port/devproc.c => port/devproc.c +45 -6
@@ 6,7 6,6 @@
#include	"../port/error.h"
#include	"ureg.h"


enum
{
	Qctl,


@@ 24,6 23,7 @@ enum
	Qstatus,
	Qtext,
	Qwait,
	Qprofile,
};

#define	STATSIZE	(2*NAMELEN+12+9*12)


@@ 43,6 43,7 @@ Dirtab procdir[] =
	"status",	{Qstatus},	STATSIZE,		0444,
	"text",		{Qtext},	0,			0000,
	"wait",		{Qwait},	0,			0400,
	"profile",	{Qprofile},	0,			0400,
};

/* Segment type from portdat.h */


@@ 76,6 77,7 @@ procgen(Chan *c, Dirtab *tab, int, int s, Dir *dp)
{
	Qid qid;
	Proc *p;
	Segment *q;
	char buf[NAMELEN];
	ulong pid, path, perm, len;



@@ 105,8 107,18 @@ procgen(Chan *c, Dirtab *tab, int, int s, Dir *dp)
		perm = p->procmode;

	len = tab->length;
	if(QID(c->qid) == Qwait)
	switch(QID(c->qid)) {
	case Qwait:
		len = p->nwait * sizeof(Waitmsg);
		break;
	case Qprofile:
		q = p->seg[TSEG];
		if(q && q->profile) {
			len = (q->top-q->base)>>LRESPROF;
			len *= sizeof(*q->profile);
		}
		break;
	}

	qid = (Qid){path|tab->qid.path, c->qid.vers};
	devdir(c, qid, tab->name, len, p->user, perm, dp);


@@ 182,6 194,7 @@ procopen(Chan *c, int omode)
	case Qproc:
	case Qkregs:
	case Qsegment:
	case Qprofile:
		if(omode != OREAD)
			error(Eperm);
		break;


@@ 311,6 324,18 @@ procread(Chan *c, void *va, long n, ulong offset)
			return n;
		}
		error(Ebadarg);
	case Qprofile:
		s = p->seg[TSEG];
		if(s == 0 || s->profile == 0)
			error("profile is off");
		i = (s->top-s->base)>>LRESPROF;
		i *= sizeof(*s->profile);
		if(offset >= i)
			return 0;
		if(offset+n > i)
			n = i - offset;
		memmove(a, ((char*)s->profile)+offset, n);
		return n;

	case Qnote:
		qlock(&p->debug);


@@ 408,9 433,10 @@ procread(Chan *c, void *va, long n, ulong offset)
			sg = p->seg[i];
			if(sg == 0)
				continue;
			j += sprint(&statbuf[j], "%-6s %c %.8lux %.8lux %4d\n",
			j += sprint(statbuf+j, "%-6s %c%c %.8lux %.8lux %4d\n",
				sname[sg->type&SG_TYPE],
				sg->type&SG_RONLY ? 'R' : ' ',
				sg->profile ? 'P' : ' ',
				sg->base, sg->top, sg->ref);
		}
		if(offset >= j)


@@ 726,7 752,8 @@ procctlfgrp(Fgrp *f)
void
procctlreq(Proc *p, char *va, int n)
{
	int i;
	Segment *s;
	int i, npc;
	char buf[NAMELEN];

	if(n > NAMELEN)


@@ 778,7 805,7 @@ procctlreq(Proc *p, char *va, int n)
	if(strncmp(buf, "closefgrp", 9) == 0)
		procctlfgrp(p->fgrp);
	else
	if(strncmp(buf, "pri", 3) == 0){
	if(strncmp(buf, "pri", 3) == 0) {
		if(n < 4)
			error(Ebadctl);
		i = atoi(buf+4);


@@ 791,7 818,7 @@ procctlreq(Proc *p, char *va, int n)
		p->basepri = i;
	}
	else
	if(strncmp(buf, "wired", 5) == 0){
	if(strncmp(buf, "wired", 5) == 0) {
		if(n < 6)
			error(Ebadctl);
		i = atoi(buf+6);


@@ 799,6 826,18 @@ procctlreq(Proc *p, char *va, int n)
			procwired(p);
	}
	else
	if(strncmp(buf, "profile", 7) == 0) {
		s = p->seg[TSEG];
		if(s == 0 || (s->type&SG_TYPE) != SG_TEXT)
			error(Ebadctl);
		if(s->profile != 0)
			free(s->profile);
		npc = (s->top-s->base)>>LRESPROF;
		s->profile = malloc(npc*sizeof(*s->profile));
		if(s->profile == 0)
			error(Enomem);
	}
	else
		error(Ebadctl);
}


M port/portdat.h => port/portdat.h +6 -0
@@ 377,6 377,7 @@ struct Segment
	int	flushme;	/* maintain icache for this segment */
	Image	*image;		/* text in file attached to this segment */
	Physseg *pseg;
	ulong*	profile;	/* Tick profile area */
	Pte	*map[SEGMAPSIZE];
};



@@ 700,6 701,11 @@ extern int mouseshifted;
extern int mousetype;
extern int mouseswap;

enum
{
	LRESPROF	= 3,
};

extern int nsyscall;
extern Physseg physseg[];
extern ulong crasharea;

M port/portfns.h => port/portfns.h +1 -0
@@ 257,6 257,7 @@ int		scsitest(Target*, char);
Target*		scsiunit(int, int);
long		seconds(void);
ulong		segattach(Proc*, ulong, char *, ulong, ulong);
void		segclock(ulong);
void		segpage(Segment*, Page*);
int		setcolor(ulong, ulong, ulong, ulong);
void		setkernur(Ureg*, Proc*);

M port/segment.c => port/segment.c +18 -0
@@ 88,6 88,8 @@ putseg(Segment *s)
			freepte(s, *pp);

	qunlock(&s->lk);
	if(s->profile != 0)
		free(s->profile);
	free(s);
}



@@ 542,3 544,19 @@ syssegflush(ulong *arg)
	flushmmu();
	return 0;
}

void
segclock(ulong pc)
{
	Segment *s;

	s = up->seg[TSEG];
	if(s == 0 || s->profile == 0)
		return;

	s->profile[0] += TK2MS(1);
	if(pc >= s->base && pc < s->top) {
		pc -= s->base;
		s->profile[pc>>LRESPROF] += TK2MS(1);
	}
}