~kris/9p

9hist

8ca921444d5e0578aa6bc28bb1e82e149734bc13 — David du Colombier 23 years ago 1d66c87
Plan 9 from Bell Labs 2002-09-28
10 files changed, 38 insertions(+), 80 deletions(-)

D pc/clock.c
M pc/random.c
M pc/sd53c8xx.c
M port/devcons.c
M port/devmouse.c
M port/devnmouse.c
M port/devuart.c
M port/portclock.c
M port/portfns.h
M port/tod.c
D pc/clock.c => pc/clock.c +0 -60
@@ 1,60 0,0 @@
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "ureg.h"

/*
 *  this is called both by the mp's clock interrupt and
 *  by the clockintr0 for the i8253
 */
void
clockintr(Ureg* ureg, void*)
{
	/* this has to get called every tick or the 8253 timer will overflow */
	fastticks(nil);

	if(m->flushmmu){
		if(up)
			flushmmu();
		m->flushmmu = 0;
	}

	portclock(ureg);
}

void
delay(int millisecs)
{
	millisecs *= m->loopconst;
	if(millisecs <= 0)
		millisecs = 1;
	aamloop(millisecs);
}

void
microdelay(int microsecs)
{
	microsecs *= m->loopconst;
	microsecs /= 1000;
	if(microsecs <= 0)
		microsecs = 1;
	aamloop(microsecs);
}

/*  
 *  performance measurement ticks.  must be low overhead.
 *  doesn't have to count over a second.
 */
ulong
perfticks(void)
{
	uvlong x;

	if(!m->havetsc)
		return ticks;
	rdtsc(&x);
	return x;
}

M pc/random.c => pc/random.c +2 -1
@@ 84,7 84,8 @@ randomclock(void)
void
randominit(void)
{
	addclock0link(randomclock);
	/* Frequency close but not equal to HZ */
	addclock0link(randomclock, 13);
	rb.ep = rb.buf + sizeof(rb.buf);
	rb.rp = rb.wp = rb.buf;
	kproc("genrandom", genrandom, 0);

M pc/sd53c8xx.c => pc/sd53c8xx.c +10 -6
@@ 1004,8 1004,7 @@ calcblockdma(Dsa *d, ulong base, ulong count)
	d->dmaaddr[2] = base >> 16;
	d->dmaaddr[3] = base >> 24;
	setmovedata(&d->data_buf, base + blocks * A_BSIZE, count - blocks * A_BSIZE);
	if (legetl(d->data_buf.dbc) == 0)
		d->flag = 1;
	d->flag = legetl(d->data_buf.dbc) == 0;
}

static ulong


@@ 1337,12 1336,13 @@ sd53c8xxinterrupt(Ureg *ur, void *a)
				/* back up one in the data transfer */
				IPRINT(PRINTPREFIX "%d/%d: ignore wide residue %d, WSR = %d\n",
				    dsa->target, dsa->lun, n->scratcha[1], n->scntl2 & 1);
				if (dsa->dmablks == 0 && dsa->flag)
				if (dsa->flag == 2)
					IPRINT(PRINTPREFIX "%d/%d: transfer over; residue ignored\n",
					    dsa->target, dsa->lun);
				else
				else {
					calcblockdma(dsa, legetl(dsa->dmaaddr) - 1,
					    dsa->dmablks * A_BSIZE + legetl(dsa->data_buf.dbc) + 1);
				}
				cont = -2;
				break;
			case A_SIR_ERROR_NOT_MSG_IN_AFTER_RESELECT:


@@ 1730,10 1730,14 @@ docheck:
	 * adjust datalen
	 */
	r->rlen = r->dlen;
	if (d->dmablks > 0)
	if (DEBUG(0))
		KPRINT(PRINTPREFIX "%d/%d: exec: before rlen adjust: dmablks %d flag %d dbc %lud\n",
		    target, r->lun, d->dmablks, d->flag, legetl(d->data_buf.dbc));
	r->rlen = r->dlen;
	if (d->flag != 2) {
		r->rlen -= d->dmablks * A_BSIZE;
	else if (d->flag == 0)
		r->rlen -= legetl(d->data_buf.dbc);
	}
	if(!r->write)
		dumpreaddata(r->data, r->rlen);
	if (DEBUG(0))

M port/devcons.c => port/devcons.c +6 -2
@@ 33,7 33,7 @@ static struct

	/* a place to save up characters at interrupt time before dumping them in the queue */
	Lock	lockputc;
	char	istage[512];
	char	istage[1024];
	char	*iw;
	char	*ir;
	char	*ie;


@@ 564,7 564,11 @@ consinit(void)
{
	todinit();
	randominit();
	addclock0link(kbdputcclock);
	/*
	 * at 115200 baud, the 1024 char buffer takes 56 ms to process,
	 * processing it every 22 ms should be fine
	 */
	addclock0link(kbdputcclock, 22);
}

static Chan*

M port/devmouse.c => port/devmouse.c +2 -1
@@ 97,7 97,8 @@ mousereset(void)

	curs = arrow;
	Cursortocursor(&arrow);
	addclock0link(mouseclock);
	/* redraw cursor about 30 times per second */
	addclock0link(mouseclock, 33);
}

static void

M port/devnmouse.c => port/devnmouse.c +2 -1
@@ 50,7 50,8 @@ mousereset(void)

	curs = arrow;
	Cursortocursor(&arrow);
	addclock0link(mouseclock);
	/* redraw cursor about 30 times per second */
	addclock0link(mouseclock, 33);
}

static void

M port/devuart.c => port/devuart.c +5 -1
@@ 212,7 212,11 @@ uartreset(void)
	}

	if(uartnuart){
		addclock0link(uartclock);
		/*
		 * at 115200 baud, the 1024 char buffer takes 56 ms to process,
		 * processing it every 22 ms should be fine
		 */
		addclock0link(uartclock, 22);
	}
}


M port/portclock.c => port/portclock.c +8 -5
@@ 27,11 27,14 @@ tadd(Timers *tt, Timer *nt)
	pt = nil;
	for(last = &tt->head; t = *last; last = &t->next){
		if(t == nt){
			/* timer's changing, remove it before putting it back on */
			*last = t->next;
			break;
		}
		if (t->period == nt->period)
		if (t->period == nt->period){
			/* look for another timer at same frequency for combining */
			pt = t;
		}
	}

	if(nt->when == 0){


@@ 195,16 198,16 @@ timersinit(void)
}

void
addclock0link(void (*f)(void))
addclock0link(void (*f)(void), int ms)
{
	Timer *nt;

	/* Synchronize this to hztimer: reduces # of interrupts */
	nt = malloc(sizeof(Timer));
	nt->when = 0;
	if (hzperiod == 0)
		hzperiod = ms2fastticks(1000/HZ);
	nt->period = hzperiod;
	if (ms == 0)
		ms = 1000/HZ;
	nt->period = ms2fastticks(ms);
	nt->f = (void (*)(Ureg*, Timer*))f;

	ilock(&timers[0]);

M port/portfns.h => port/portfns.h +1 -1
@@ 1,5 1,5 @@
void		accounttime(void);
void		addclock0link(void (*)(void));
void		addclock0link(void (*)(void), int);
int		addphysseg(Physseg*);
void		addrootfile(char*, uchar*, ulong);
Block*		adjustblock(Block*, int);

M port/tod.c => port/tod.c +2 -2
@@ 50,7 50,7 @@ todinit(void)
	tod.last = fastticks((uvlong*)&tod.hz);
	iunlock(&tod);
	todsetfreq(tod.hz);
	addclock0link(todfix);
	addclock0link(todfix, 100);
}

//


@@ 145,7 145,7 @@ todget(vlong *ticksp)
}

//
//  called every clock tick to avoid calculation overflows
//  called regularly to avoid calculation overflows
//
void
todfix(void)