~kris/9p

9hist

9df824055306985290f48b453be62dc62b100c63 — David du Colombier 25 years ago 7cde4b9
Plan 9 from Bell Labs 2000-11-06
M alphapc/fns.h => alphapc/fns.h +1 -0
@@ 92,6 92,7 @@ void		trapinit(void);
void		unaligned(void);
ulong	upamalloc(ulong, int, int);
void	upafree(ulong, int);
#define		userureg(ur) ((ur)->status & UMODE)
void		wrent(int, void*);
void		wrvptptr(uvlong);


M bitsy/dat.h => bitsy/dat.h +1 -0
@@ 108,6 108,7 @@ struct Mach
	Label	sched;			/* scheduler wakeup */
	Lock	alarmlock;		/* access to alarm list */
	void*	alarm;			/* alarms bound to this clock */
	int	inclockintr;

	ulong	fairness;		/* for runproc */


M bitsy/devµc.c => bitsy/devµc.c +1 -1
@@ 346,7 346,7 @@ static long
		sendmsgwithack(BLbacklight, data, cmd->nf);
		break;
	case Qcruft:
		lcdtweak(cmd);
//		lcdtweak(cmd);
		break;
	default:
		error(Ebadarg);

M bitsy/fns.h => bitsy/fns.h +2 -1
@@ 3,7 3,7 @@
void	cacheflush(void);
void	cachewb(void);
void	cachewbaddr(void*);
void	cachewbregion(void*, int);
void	cachewbregion(ulong, int);
void	dcacheinvalidate(void);
int	cistrcmp(char*, char*);
int	cistrncmp(char*, char*, int);


@@ 71,6 71,7 @@ int	uartstageoutput(Uart*);
void	uartkick(void*);
void	uartrecv(Uart*, char);
int	unsac(uchar*, uchar*, int, int);
#define	userureg(ur)	(((ur)->psr & PsrMask) == PsrMusr)
void	vectors(void);
void	vtable(void);
void	wbflush(void);

M bitsy/l.s => bitsy/l.s +9 -17
@@ 51,7 51,7 @@ TEXT cacheflush(SB), $-4
	ADD	$(8*1024),R0,R1
_cfloop:
	MOVW.P	32(R0),R2
	CMP	R0,R1
	CMP.S	R0,R1
	BNE	_cfloop
	
	/* drain write buffer and invalidate i&d cache contents */


@@ 68,12 68,13 @@ _cfloop:
/* write back d cache */
TEXT cachewb(SB), $-4
	/* write back any dirty data */
_cachewb:
	MOVW	$0xe0000000,R0
	ADD	$(8*1024),R0,R1
_cwbloop:
	MOVW.P	32(R0),R2
	CMP	R0,R1
	BNE	_cfloop
	CMP.S	R0,R1
	BNE	_cwbloop
	
	/* drain write buffer */
	MCR	CpMMU, 0, R0, C(CpCacheFlush), C(0xa), 4


@@ 88,14 89,15 @@ TEXT cachewbaddr(SB), $-4
/* write back a region of cache lines */
TEXT cachewbregion(SB), $-4
	MOVW	4(FP),R1
	BIC	$31,R0
	CMP.S	$(4*1024),R1
	BGT	_cachewb
	ADD	R0,R1
	ADD	$32,R1
_cfrloop:
	BIC	$31,R0
_cwbrloop:
	MCR	CpMMU, 0, R0, C(CpCacheFlush), C(0xa), 1
	ADD	$32,R0
	CMP.S	R0,R1
	BNE	_cfrloop
	BGT	_cwbrloop
	B	_wbflush

/* invalidate the dcache */


@@ 408,16 410,6 @@ TEXT spsrr(SB), $-4
	MOVW	SPSR, R0
	RET

TEXT aamloop(SB), $-4				/* 3 */
_aamloop:
	MOVW	R0, R0				/* 1 */
	MOVW	R0, R0				/* 1 */
	MOVW	R0, R0				/* 1 */
	SUB	$1, R0				/* 1 */
	CMP	$0, R0				/* 1 */
	BNE	_aamloop			/* 3 */
	RET					/* 3 */

TEXT getcallerpc(SB), $-4
	MOVW	0(R13), R0
	RET

M bitsy/mmu.c => bitsy/mmu.c +2 -2
@@ 318,7 318,7 @@ mmurelease(Proc* p)
	p->mmufree = nil;

	memset(l1table, 0, sizeof(p->l1table));
	cachewbregion(l1table, sizeof(p->l1table));
	cachewbregion((ulong)l1table, sizeof(p->l1table));
}

void


@@ 340,7 340,7 @@ mmuswitch(Proc *p)
	memmove(l1table, p->l1table, sizeof(p->l1table));

	/* make sure map is in memory */
	cachewbregion(l1table, sizeof(p->l1table));
	cachewbregion((ulong)l1table, sizeof(p->l1table));

	/* lose any possible stale tlb entries */
	mmuinvalidate();

M bitsy/sa1110uart.c => bitsy/sa1110uart.c +1 -7
@@ 316,13 316,7 @@ sa1100_uartkick(Uart *p)
	if(p->cts == 0 || p->blocked)
		return;

	/*
	 *  128 here is an arbitrary limit to make sure
	 *  we don't stay in this loop too long.  If the
	 *  chips output queue is longer than 128, too
	 *  bad -- presotto
	 */
	for(i = 0; i < 128; i++){
	for(i = 0; i < 1024; i++){
		if(!(R(p)->status[1] & Tnotfull)){
			R(p)->ctl[3] |= Tintena;
			break;

M bitsy/screen.c => bitsy/screen.c +17 -7
@@ 15,7 15,7 @@

#define	MINX	8

int landscape;	/* orientation of the screen, default is 0: portait */
int landscape = 0;	/* orientation of the screen, default is 0: portait */

enum {
	Wid		= 240,


@@ 164,6 164,7 @@ lcdstop(void) {
static void
lcdinit(void)
{
	/* the following line works because main memory is direct mapped */
	lcd->dbar1 = framebuf->palette;
	lcd->lccr3 = pcd<<PCD | 0<<ACB | 0<<API | 1<<VSP | 1<<HSP | 0<<PCP | 0<<OEP;
	lcd->lccr2 = (Wid-1)<<LPP | vsw<<VSW | efw<<EFW | bfw<<BFW;


@@ 213,7 214,6 @@ screeninit(void)
	lcd = (struct sa1110regs*)mapspecial(LCDREGS, sizeof(struct sa1110regs));;

	framebuf = xspanalloc(sizeof *framebuf, 0x100, 0);
	/* the following works because main memory is direct mapped */

	vscreen = xalloc(sizeof(ushort)*Wid*Ht);



@@ 251,12 251,23 @@ void
flushmemscreen(Rectangle r)
{
	int x, y;
	ulong start, end;

	if (landscape == 0)
	if (landscape == 0) {
		if (r.min.x <   0) r.min.x = 0;
		if (r.max.x > Wid) r.max.x = Wid;
		if (r.min.y <   0) r.min.y = 0;
		if (r.max.y >  Ht) r.max.y = Ht;
		for (x = r.min.x; x < r.max.x; x++)
			for (y = r.min.y; y < r.max.y; y++)
				framebuf->pixel[(x+1)*Ht-y-1] = vscreen[y*Wid+x];
	cachewb();
				framebuf->pixel[(x+1)*Ht-1-y] = vscreen[y*Wid+x];
		start = (ulong)&framebuf->pixel[(r.min.x+1)*Ht-1-(r.max.y-1)];
		end = (ulong)&framebuf->pixel[(r.max.x-1+1)*Ht-1-(r.min.y)];
	} else {
		start = (ulong)&framebuf->pixel[r.min.y*Ht + r.min.x];
		end = (ulong)&framebuf->pixel[(r.max.y-1)*Ht + r.max.x - 1];
	}
	cachewbregion(start, end-start);
}

/*


@@ 269,7 280,7 @@ attachscreen(Rectangle *r, ulong *chan, int* d, int *width, int *softscreen)
	*d = gscreen->depth;
	*chan = gscreen->chan;
	*width = gscreen->width;
	*softscreen = landscape == 0;
	*softscreen = (landscape == 0);

	return (uchar*)gscreen->data->bdata;
}


@@ 337,7 348,6 @@ screenwin(void)
	back = memwhite;
	conscol = memblack;

	/* a lot of work to get a orange color */
	orange = allocmemimage(Rect(0,0,1,1), RGB16);
	orange->flags |= Frepl;
	orange->clipr = gscreen->r;

M carrera/fns.h => carrera/fns.h +1 -0
@@ 61,6 61,7 @@ int		tas(ulong*);
void		tlbinit(void);
ulong		tlbvirt(void);
void		touser(void*);
#define userureg(ur) ((ur)->status & KUSER)
void		vecinit(void);
void		vector0(void);
void		vector100(void);

M mpc/fns.h => mpc/fns.h +1 -0
@@ 103,6 103,7 @@ void	tlbflushall(void);
void	uartinstall(void);
void	uartwait(void);	/* debugging */
int unsac(uchar *dst, uchar *src, int n, int nsrc);
#define	userureg(ur) ((ur)->status & KUSER)
void	wbflush(void);

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

M pc/clock.c => pc/clock.c +1 -58
@@ 6,60 6,12 @@
#include "io.h"
#include "ureg.h"

void (*kproftimer)(ulong);

typedef struct Clock0link Clock0link;
typedef struct Clock0link {
	void		(*clock)(void);
	Clock0link*	link;
} Clock0link;

static Clock0link *clock0link;
static Lock clock0lock;

void
addclock0link(void (*clock)(void))
{
	Clock0link *lp;

	if((lp = malloc(sizeof(Clock0link))) == 0){
		print("addclock0link: too many links\n");
		return;
	}
	ilock(&clock0lock);
	lp->clock = clock;
	lp->link = clock0link;
	clock0link = lp;
	iunlock(&clock0lock);
}

void
clockintr(Ureg* ureg, void*)
{
	Clock0link *lp;

	// this needs to be here for synchronizing mp clocks
	// see mp.c's squidboy()
	fastticks(nil);
	m->ticks++;
	if(m->proc)
		m->proc->pc = ureg->pc;

	accounttime();
	if(kproftimer != nil)
		kproftimer(ureg->pc);
	if((active.machs & (1<<m->machno)) == 0)
		return;
	if(active.exiting && (active.machs & (1<<m->machno)))
		exit(0);

	checkalarms();
	if(m->machno == 0){
		ilock(&clock0lock);
		for(lp = clock0link; lp; lp = lp->link)
			lp->clock();
		iunlock(&clock0lock);
	}

	if(m->flushmmu){
		if(up)


@@ 67,16 19,7 @@ clockintr(Ureg* ureg, void*)
		m->flushmmu = 0;
	}

	if(up == 0 || up->state != Running)
		return;

	if(anyready())
		sched();
	
	if((ureg->cs & 0xFFFF) == UESEL) {
		(*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1);
		segclock(ureg->pc);
	}
	portclock(ureg);
}

void

M pc/dat.h => pc/dat.h +1 -0
@@ 160,6 160,7 @@ struct Mach
	Label	sched;			/* scheduler wakeup */
	Lock	alarmlock;		/* access to alarm list */
	void*	alarm;			/* alarms bound to this clock */
	int	inclockintr;

	ulong	fairness;		/* for runproc */


M pc/devi82365.c => pc/devi82365.c +4 -0
@@ 441,21 441,25 @@ pcmspecial(char *idstr, ISAConf *isa)
	static int resetdone;

	i82365reset();
print("pcmcia: looking for %s: ", idstr);
	for(pp = slot; pp < lastslot; pp++){
		if(pp->special)
			continue;	/* already taken */
		increfp(pp);

		if(pp->occupied) {
print("[%8.8s]", pp->verstr);
			if(strstr(pp->verstr, idstr))
			if(isa == 0 || pcmio(pp->slotno, isa) == 0){
				pp->special = 1;
print(" - found\n");
				return pp->slotno;
			}
		} else
			pp->special = 1;
		decrefp(pp);
	}
print("\n");
	return -1;
}


M pc/fns.h => pc/fns.h +1 -0
@@ 120,6 120,7 @@ ulong	umbrwmalloc(ulong, int, int);
void	umbrwfree(ulong, int);
ulong	upamalloc(ulong, int, int);
void	upafree(ulong, int);
#define	userureg(ur) (((ur)->cs & 0xFFFF) == UESEL)
void	vectortable(void);
void	wrmsr(int, vlong);
void	wbflush(void);

M port/devcons.c => port/devcons.c +3 -4
@@ 365,10 365,9 @@ echo(char *buf, int n)
			consdebug();
			return;
		case 'p':
			//x = spllo();
			//procdump();
			//splx(x);
print("procdump temporarily disabled\n");
			x = spllo();
			procdump();
			splx(x);
			return;
		case 'q':
			scheddump();

A port/portclock.c => port/portclock.c +85 -0
@@ 0,0 1,85 @@
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "ureg.h"

void (*kproftimer)(ulong);

typedef struct Clock0link Clock0link;
typedef struct Clock0link {
	void		(*clock)(void);
	Clock0link*	link;
} Clock0link;

static Clock0link *clock0link;
static Lock clock0lock;

void
addclock0link(void (*clock)(void))
{
	Clock0link *lp;

	if((lp = malloc(sizeof(Clock0link))) == 0){
		print("addclock0link: too many links\n");
		return;
	}
	ilock(&clock0lock);
	lp->clock = clock;
	lp->link = clock0link;
	clock0link = lp;
	iunlock(&clock0lock);
}

void
portclock(Ureg *ur)
{
	Clock0link *lp;

	m->ticks++;
	if(m->proc)
		m->proc->pc = ur->pc;

	if(m->inclockintr)
		return;		/* interrupted ourself */
	m->inclockintr = 1;

	accounttime();

	if(kproftimer != nil)
		kproftimer(ur->pc);

	if((active.machs&(1<<m->machno)) == 0)
		return;

	if(active.exiting && (active.machs & (1<<m->machno))) {
		print("someone's exiting\n");
		exit(0);
	}

	checkalarms();
	if(m->machno == 0){
		ilock(&clock0lock);
		for(lp = clock0link; lp; lp = lp->link){
			lp->clock();
			splhi();
		}
		iunlock(&clock0lock);
	}

	m->inclockintr = 0;

	if(up == 0 || up->state != Running)
		return;

	if(anyready())
		sched();

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

M port/portfns.h => port/portfns.h +2 -0
@@ 200,8 200,10 @@ void		pgrpnote(ulong, char*, long, int);
Pgrp*		pgrptab(int);
void		pio(Segment *, ulong, ulong, Page **);
#define		poperror()		up->nerrlab--
void		portclock(Ureg*);
int		postnote(Proc*, int, char*, int);
int		pprint(char*, ...);
void		prflush(void);
void		printinit(void);
ulong		procalarm(ulong);
int		proccounter(char *name);

M port/proc.c => port/proc.c +1 -1
@@ 938,7 938,7 @@ procdump(void)
			continue;

		dumpaproc(p);
		delay(150);
		prflush();
	}
}


M port/taslock.c => port/taslock.c +16 -10
@@ 11,22 11,25 @@ struct {
	ulong	inglare;
} lockstats;

static void
dumplockmem(char *tag, Lock *l)
{
	uchar *cp;
	int i;

	iprint("%s: ", tag);
	cp = (uchar*)l;
	for(i = 0; i < 64; i++)
		iprint("%2.2ux ", cp[i]);
	iprint("\n");
}

void
lockloop(Lock *l, ulong pc)
{
	Proc *p;

	p = l->p;
{
ulong x = (ulong)p;
uchar *cp;
int i;
if(x < KTZERO) {
	cp = (uchar*)l;
	for(i = 0; i < 64; i++) print("%2.2ux ", cp[i]);
	print("\n");
}
}
	print("lock loop key 0x%lux pc 0x%lux held by pc 0x%lux proc %lud\n",
		l->key, pc, l->pc, p ? p->pid : 0);
	dumpaproc(up);


@@ 120,7 123,10 @@ ilock(Lock *l)
	} else
		oldpri = 0;
	if(conf.nmach < 2)
{
dumplockmem("ilock:", l);
		panic("ilock: no way out: pc %uX\n", pc);
}

	for(;;){
		lockstats.inglare++;