~kris/9p

9hist

9dddf4b3142fc2e2ae683e1cb7c0f2b503ef96ed — David du Colombier 35 years ago c1220b0
Plan 9 from Bell Labs 1990-12-27
M gnot/clock.c => gnot/clock.c +2 -1
@@ 35,7 35,8 @@ clock(Ureg *ur)
	kbdclock();
	mouseclock();
	if((ur->sr&SPL(7)) == 0 && p && p->state==Running){
		sched();
		if(anyready())
			sched();
		if(u->nnote && (ur->sr&SUPER)==0)
			notify(ur);
	}

M gnot/fns.h => gnot/fns.h +1 -0
@@ 1,6 1,7 @@
Alarm	*alarm(int, void (*)(Alarm*), void*);
void	alarminit(void);
Block	*allocb(ulong);
int	anyready(void);
void	append(List**, List*);
void	cancel(Alarm*);
int	canlock(Lock*);

M port/proc.c => port/proc.c +6 -0
@@ 105,6 105,12 @@ sched(void)
	gotolabel(&p->sched);
}

int
anyready(void)
{
	return runq.head != 0;
}

void
ready(Proc *p)
{

A port/queue.c => port/queue.c +80 -0
@@ 0,0 1,80 @@
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"errno.h"

void
initq(IOQ *q)
{
	q->in = q->out = q->buf;
	q->puts = puts;
	q->putc = putc;
}

int
putc(IOQ *q, int c)
{
	uchar *nextin;
	if(q->in >= &q->buf[sizeof(q->buf)-1])
		nextin = q->buf;
	else
		nextin = q->in+1;
	if(nextin == q->out)
		return -1;
	*q->in = c;
	q->in = nextin;
	return 0;
}

int
getc(IOQ *q)
{
	int c;

	if(q->in == q->out)
		return -1;
	c = *q->out++;
	if(q->out == q->buf+sizeof(q->buf))
		q->out = q->buf;
	return c;
}

void
puts(IOQ *q, char *s, int n)
{
	int m;

	while(n){
		if(q->out > q->in)
			m = q->out - q->in - 1;
		else
			m = &q->buf[NQ] - q->in;
		if(m > n)
			m = n;
		memcpy(q->in, s, m);
		n -= m;
		q->in += m;
		if(q->in >= &q->buf[NQ])
			q->in = q->buf;
	}
}

int
cangetc(void *arg)
{
	IOQ *q = (IOQ *)arg;
	int n = q->in - q->out;
	if (n < 0)
		n += sizeof(q->buf);
	return n;
}

int
canputc(void *arg)
{
	IOQ *q = (IOQ *)arg;
	return sizeof(q->buf)-cangetc(q)-1;
}

M port/sysproc.c => port/sysproc.c +1 -2
@@ 126,6 126,7 @@ sysfork(ulong *arg)
	p->parent = u->p;
	p->parentpid = u->p->pid;
	p->pgrp = u->p->pgrp;
	p->bssend = u->p->bssend;
	incref(p->pgrp);
	u->p->nchild++;
	pid = p->pid;


@@ 495,13 496,11 @@ sysbrk_(ulong *arg)
	Seg *s;

	addr = arg[0];
#ifdef WHYROB
	if(addr < u->p->bssend){
		pprint("addr below bss\n");
		pexit("Suicide", 0);
		error(Esegaddr);
	}
#endif WHYROB
	if(addr <= ((u->p->bssend+(BY2PG-1))&~(BY2PG-1)))	/* still in DSEG */
		goto Return;
	if(segaddr(&u->p->seg[BSEG], u->p->seg[BSEG].minva, arg[0]) == 0){

M ss/boot.c => ss/boot.c +4 -0
@@ 24,7 24,11 @@ main(int argc, char *argv[])
write(1, "hello from boot\n", 16);
bind("#c", "/dev", MREPL);
binit(0, 0);
if(fork()==0)
bitblt(&screen, Pt(100, 100), &screen, Rect(100, 100, 300, 200), 0xF);
else
bitblt(&screen, Pt(500, 500), &screen, Rect(100, 100, 300, 200), 0xF);


	fd = open("#e/bootline", OREAD);
	if(fd >= 0){

M ss/boot.h => ss/boot.h +159 -139
@@ 1,6 1,6 @@
ulong bootcode[]={
	0x0000002ab,
	0x000007b70,
	0x000007bc0,
	0x000000750,
	0x000002168,
	0x000000000,


@@ 18,7 18,7 @@ ulong bootcode[]={
	0x040000007,
	0x001000000,
	0x0ce206004,
	0x040000a3c,
	0x040000a51,
	0x001000000,
	0x010bffffd,
	0x001000000,


@@ 27,19 27,19 @@ ulong bootcode[]={
	0x09000b216,
	0x0d0206004,
	0x0c0206008,
	0x040001642,
	0x040001657,
	0x001000000,
	0x09200b21e,
	0x0d2206004,
	0x090002001,
	0x0d0206008,
	0x04000163c,
	0x040001651,
	0x001000000,
	0x09200b226,
	0x0d2206004,
	0x090002001,
	0x0d0206008,
	0x040001636,
	0x04000164b,
	0x001000000,
	0x092002001,
	0x0d2206004,


@@ 47,41 47,49 @@ ulong bootcode[]={
	0x0d0206008,
	0x092002010,
	0x0d220600c,
	0x040001640,
	0x040001655,
	0x001000000,
	0x09000b23f,
	0x0d0206004,
	0x09200b242,
	0x0d2206008,
	0x0c020600c,
	0x0400015fd,
	0x040001612,
	0x001000000,
	0x096100000,
	0x0c0206004,
	0x0c0206008,
	0x0400003cc,
	0x0400003e1,
	0x001000000,
	0x040001629,
	0x001000000,
	0x0a200212c,
	0x0a00020c8,
	0x09a00200f,
	0x0980021f4,
	0x096002064,
	0x09000b022,
	0x0d0206004,
	0x080a1c000,
	0x0128002f6,
	0x001000000,
	0x09200b022,
	0x0d2206004,
	0x0d6206008,
	0x0d620600c,
	0x09200b022,
	0x0d2206010,
	0x09000b022,
	0x0d0206010,
	0x0d6206014,
	0x0d6206018,
	0x09000212c,
	0x0d020601c,
	0x0920020c8,
	0x0d2206020,
	0x09000200f,
	0x0d0206024,
	0x040000596,
	0x0e220601c,
	0x090100010,
	0x0e0206020,
	0x09210000d,
	0x0da206024,
	0x0400005a3,
	0x001000000,
	0x09000b247,
	0x0d0206004,
	0x0c0206008,
	0x04000160c,
	0x040001619,
	0x001000000,
	0x092100007,
	0x096100007,


@@ 94,16 102,16 @@ ulong bootcode[]={
	0x0d0206008,
	0x092002040,
	0x0d220600c,
	0x040001605,
	0x040001612,
	0x001000000,
	0x0d0006140,
	0x0d0206004,
	0x0400015d7,
	0x0400015e4,
	0x001000000,
	0x09000b253,
	0x0d0206004,
	0x0c0206008,
	0x0400015f6,
	0x040001603,
	0x001000000,
	0x092100007,
	0x096100007,


@@ 116,21 124,21 @@ ulong bootcode[]={
	0x0d0206008,
	0x092002001,
	0x0d220600c,
	0x0400015ef,
	0x0400015fc,
	0x001000000,
	0x0d0006140,
	0x0d0206004,
	0x0400015c1,
	0x0400015ce,
	0x001000000,
	0x09000b261,
	0x0d0206004,
	0x0c0206008,
	0x0400015e0,
	0x0400015ed,
	0x001000000,
	0x09800b046,
	0x096100007,
	0x080a1c000,
	0x0068002ac,
	0x0068002a8,
	0x001000000,
	0x0d6206140,
	0x0d6206004,


@@ 138,29 146,27 @@ ulong bootcode[]={
	0x0d8206008,
	0x092002040,
	0x0d220600c,
	0x0400015d9,
	0x0400015e6,
	0x001000000,
	0x0d0006140,
	0x0d0206004,
	0x0400015ab,
	0x0400015b8,
	0x001000000,
	0x096002002,
	0x0d048b002,
	0x0912a2018,
	0x0913a2018,
	0x0921a2041,
	0x080a24000,
	0x002800279,
	0x080a22041,
	0x002800276,
	0x001000000,
	0x0921a2061,
	0x080a24000,
	0x002800256,
	0x080a22061,
	0x002800254,
	0x001000000,
	0x09000b2d6,
	0x0d0206004,
	0x09410000b,
	0x0d6206008,
	0x0400015bd,
	0x0400015cc,
	0x001000000,
	0x0ce206144,
	0x0d0006144,


@@ 169,41 175,39 @@ ulong bootcode[]={
	0x001000000,
	0x09200b2dd,
	0x0d2206004,
	0x0400002ab,
	0x0400002ba,
	0x001000000,
	0x0d0006144,
	0x0d0206004,
	0x09200b2ec,
	0x0d2206008,
	0x040000288,
	0x040000297,
	0x001000000,
	0x0d0006144,
	0x0d0206004,
	0x09200b2f7,
	0x0d2206008,
	0x040000282,
	0x040000291,
	0x001000000,
	0x04000159a,
	0x0400015a9,
	0x001000000,
	0x090100007,
	0x09221ffff,
	0x080a24000,
	0x00280000a,
	0x080a1ffff,
	0x002800009,
	0x001000000,
	0x09219c000,
	0x080a24000,
	0x080a1c000,
	0x002800229,
	0x001000000,
	0x0d2006144,
	0x0d2206004,
	0x040001575,
	0x040001586,
	0x001000000,
	0x0c0206130,
	0x09000b30d,
	0x0d0206004,
	0x094002002,
	0x0d4206008,
	0x040001592,
	0x0400015a3,
	0x001000000,
	0x096100007,
	0x090100007,


@@ 213,13 217,13 @@ ulong bootcode[]={
	0x001000000,
	0x09200b317,
	0x0d2206004,
	0x04000027f,
	0x040000290,
	0x001000000,
	0x09200b329,
	0x0d2206004,
	0x094002002,
	0x0d4206008,
	0x040001582,
	0x040001593,
	0x001000000,
	0x096100007,
	0x092100007,


@@ 229,7 233,7 @@ ulong bootcode[]={
	0x001000000,
	0x09000b332,
	0x0d0206004,
	0x04000026f,
	0x040000280,
	0x001000000,
	0x092006030,
	0x0d2206004,


@@ 237,11 241,11 @@ ulong bootcode[]={
	0x0d0206008,
	0x09200b046,
	0x0d220600c,
	0x0400012f6,
	0x040001307,
	0x001000000,
	0x092006030,
	0x0d2206004,
	0x04000135d,
	0x04000136e,
	0x001000000,
	0x096100007,
	0x0d0006144,


@@ 251,7 255,7 @@ ulong bootcode[]={
	0x090100007,
	0x0ce20613c,
	0x0ce20600c,
	0x040001574,
	0x040001585,
	0x001000000,
	0x092100007,
	0x0d400613c,


@@ 262,15 266,15 @@ ulong bootcode[]={
	0x0d2206004,
	0x09000b046,
	0x0d0206008,
	0x04000126d,
	0x04000127e,
	0x001000000,
	0x0d2006144,
	0x0d2206004,
	0x04000152f,
	0x040001540,
	0x001000000,
	0x09000b384,
	0x0d0206004,
	0x040001265,
	0x040001276,
	0x001000000,
	0x092002032,
	0x01d000006,


@@ 285,7 289,7 @@ ulong bootcode[]={
	0x0d0206004,
	0x094006030,
	0x0d4206008,
	0x040001592,
	0x0400015a3,
	0x001000000,
	0x096100007,
	0x0d2006140,


@@ 295,7 299,7 @@ ulong bootcode[]={
	0x092100007,
	0x0ce20613c,
	0x0ce20600c,
	0x040001548,
	0x040001559,
	0x001000000,
	0x0d400613c,
	0x080a1c00a,


@@ 303,7 307,7 @@ ulong bootcode[]={
	0x001000000,
	0x09000b38b,
	0x0d0206004,
	0x040000225,
	0x040000236,
	0x001000000,
	0x0d0006140,
	0x0d0206004,


@@ 311,7 315,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x090002100,
	0x0d020600c,
	0x04000152c,
	0x04000153d,
	0x001000000,
	0x096100007,
	0x080a1e002,


@@ 328,7 332,7 @@ ulong bootcode[]={
	0x001000000,
	0x09200b395,
	0x0d2206004,
	0x04000020c,
	0x04000021d,
	0x001000000,
	0x0d600613c,
	0x092006030,


@@ 338,7 342,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x09210000b,
	0x0d620600c,
	0x040001914,
	0x040001925,
	0x001000000,
	0x090100007,
	0x080a1c000,


@@ 364,11 368,11 @@ ulong bootcode[]={
	0x0932a6018,
	0x0933a6018,
	0x0d2206018,
	0x040001207,
	0x040001218,
	0x001000000,
	0x09000b3c1,
	0x0d0206004,
	0x0400001e4,
	0x0400001f5,
	0x001000000,
	0x01d000006,
	0x09c038002,


@@ 378,11 382,11 @@ ulong bootcode[]={
	0x001000000,
	0x09000b3cc,
	0x0d0206004,
	0x0400001da,
	0x0400001eb,
	0x001000000,
	0x09200b3d5,
	0x0d2206004,
	0x0400011f5,
	0x040001206,
	0x001000000,
	0x090002034,
	0x01d000006,


@@ 397,7 401,7 @@ ulong bootcode[]={
	0x0d2206004,
	0x094006030,
	0x0d4206008,
	0x040001522,
	0x040001533,
	0x001000000,
	0x096100007,
	0x0d0006140,


@@ 407,7 411,7 @@ ulong bootcode[]={
	0x090100007,
	0x0ce20613c,
	0x0ce20600c,
	0x0400014d8,
	0x0400014e9,
	0x001000000,
	0x092100007,
	0x0d400613c,


@@ 416,7 420,7 @@ ulong bootcode[]={
	0x001000000,
	0x09000b3e0,
	0x0d0206004,
	0x0400001b4,
	0x0400001c5,
	0x001000000,
	0x0d0006140,
	0x0d0206004,


@@ 424,7 428,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x090002100,
	0x0d020600c,
	0x0400014bb,
	0x0400014cc,
	0x001000000,
	0x096100007,
	0x090100007,


@@ 434,7 438,7 @@ ulong bootcode[]={
	0x001000000,
	0x09200b3ee,
	0x0d2206004,
	0x0400001a2,
	0x0400001b3,
	0x001000000,
	0x0d600613c,
	0x092006030,


@@ 444,7 448,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x09210000b,
	0x0d620600c,
	0x0400018aa,
	0x0400018bb,
	0x001000000,
	0x090100007,
	0x080a1c000,


@@ 452,7 456,7 @@ ulong bootcode[]={
	0x001000000,
	0x09000b3fb,
	0x0d0206004,
	0x040000190,
	0x0400001a1,
	0x001000000,
	0x01d000006,
	0x09c038002,


@@ 466,13 470,13 @@ ulong bootcode[]={
	0x09203a038,
	0x092026008,
	0x0d2206008,
	0x0400011a1,
	0x0400011b2,
	0x001000000,
	0x01d00002e,
	0x09003a038,
	0x090022008,
	0x0d0206004,
	0x04000017c,
	0x04000018d,
	0x001000000,
	0x01d000006,
	0x09c038002,


@@ 482,11 486,11 @@ ulong bootcode[]={
	0x001000000,
	0x09000b414,
	0x0d0206004,
	0x040000172,
	0x040000183,
	0x001000000,
	0x09200b421,
	0x0d2206004,
	0x04000118d,
	0x04000119e,
	0x001000000,
	0x090006030,
	0x0d0206004,


@@ 494,7 498,7 @@ ulong bootcode[]={
	0x0d2206008,
	0x09000b42f,
	0x0d020600c,
	0x0400011f5,
	0x040001206,
	0x001000000,
	0x090006030,
	0x0d0206004,


@@ 502,7 506,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x0900021b6,
	0x0d020600c,
	0x040001449,
	0x04000145a,
	0x001000000,
	0x096100007,
	0x090100007,


@@ 512,7 516,7 @@ ulong bootcode[]={
	0x001000000,
	0x09200b436,
	0x0d2206004,
	0x040000154,
	0x040000165,
	0x001000000,
	0x090006030,
	0x0d0206004,


@@ 520,16 524,16 @@ ulong bootcode[]={
	0x0d2206008,
	0x0d0006140,
	0x0d020600c,
	0x0400011db,
	0x0400011ec,
	0x001000000,
	0x092006030,
	0x0d2206004,
	0x040001242,
	0x040001253,
	0x001000000,
	0x0ce206024,
	0x094006030,
	0x0d4206004,
	0x04000123d,
	0x04000124e,
	0x001000000,
	0x0ce206020,
	0x0d4006134,


@@ 538,7 542,7 @@ ulong bootcode[]={
	0x0d2206008,
	0x0d4006020,
	0x0d420600c,
	0x040001455,
	0x040001466,
	0x001000000,
	0x090100007,
	0x0d2006024,


@@ 547,11 551,11 @@ ulong bootcode[]={
	0x001000000,
	0x09000b440,
	0x0d0206004,
	0x040000131,
	0x040000142,
	0x001000000,
	0x0d2006134,
	0x0d2206004,
	0x040001412,
	0x040001423,
	0x001000000,
	0x090006030,
	0x0d0206004,


@@ 559,7 563,7 @@ ulong bootcode[]={
	0x0d2206008,
	0x09000b44c,
	0x0d020600c,
	0x0400011b4,
	0x0400011c5,
	0x001000000,
	0x09000b453,
	0x0d0206004,


@@ 567,7 571,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x0900021b6,
	0x0d020600c,
	0x040001408,
	0x040001419,
	0x001000000,
	0x096100007,
	0x090100007,


@@ 577,7 581,7 @@ ulong bootcode[]={
	0x001000000,
	0x09200b45b,
	0x0d2206004,
	0x040000113,
	0x040000124,
	0x001000000,
	0x090006030,
	0x0d0206004,


@@ 585,16 589,16 @@ ulong bootcode[]={
	0x0d2206008,
	0x0d0006140,
	0x0d020600c,
	0x04000119a,
	0x0400011ab,
	0x001000000,
	0x092006030,
	0x0d2206004,
	0x040001201,
	0x040001212,
	0x001000000,
	0x0ce206024,
	0x094006030,
	0x0d4206004,
	0x0400011fc,
	0x04000120d,
	0x001000000,
	0x0ce206020,
	0x0d4006134,


@@ 603,7 607,7 @@ ulong bootcode[]={
	0x0d2206008,
	0x0d4006020,
	0x0d420600c,
	0x040001414,
	0x040001425,
	0x001000000,
	0x090100007,
	0x0d2006024,


@@ 612,22 616,22 @@ ulong bootcode[]={
	0x001000000,
	0x09000b465,
	0x0d0206004,
	0x0400000f0,
	0x040000101,
	0x001000000,
	0x0d2006134,
	0x0d2206004,
	0x0400013d1,
	0x0400013e2,
	0x001000000,
	0x09000b46b,
	0x0d0206004,
	0x040001107,
	0x040001118,
	0x001000000,
	0x09000b474,
	0x0d0206004,
	0x09400b476,
	0x0d4206008,
	0x0c020600c,
	0x0400013c0,
	0x0400013d1,
	0x001000000,
	0x092100007,
	0x080a1c000,


@@ 635,7 639,7 @@ ulong bootcode[]={
	0x001000000,
	0x09000b478,
	0x0d0206004,
	0x0400000d9,
	0x0400000ea,
	0x001000000,
	0x0d0006140,
	0x0d0206004,


@@ 647,7 651,7 @@ ulong bootcode[]={
	0x0d4206010,
	0x09000b480,
	0x0d0206014,
	0x0400013d0,
	0x0400013e1,
	0x001000000,
	0x092100007,
	0x080a1c000,


@@ 655,17 659,17 @@ ulong bootcode[]={
	0x001000000,
	0x09200b481,
	0x0d2206004,
	0x0400000c5,
	0x0400000d6,
	0x001000000,
	0x09000b487,
	0x0d0206004,
	0x0400010e0,
	0x0400010f1,
	0x001000000,
	0x09000b102,
	0x0d0206004,
	0x094002020,
	0x0d4206008,
	0x040001164,
	0x040001175,
	0x001000000,
	0x096100000,
	0x080a1c000,


@@ 678,11 682,11 @@ ulong bootcode[]={
	0x09000b4a1,
	0x0d020600c,
	0x0d6206010,
	0x040000e22,
	0x040000e33,
	0x001000000,
	0x09200b4b5,
	0x0d2206004,
	0x0400000aa,
	0x0400000bb,
	0x001000000,
	0x0d0006000,
	0x082006148,


@@ 693,11 697,11 @@ ulong bootcode[]={
	0x09000b4b0,
	0x0d0206008,
	0x0c020600c,
	0x040000e13,
	0x040000e24,
	0x001000000,
	0x09200b4b5,
	0x0d2206004,
	0x04000009b,
	0x0400000ac,
	0x001000000,
	0x0d0006000,
	0x082006148,


@@ 715,7 719,7 @@ ulong bootcode[]={
	0x0d4206008,
	0x090002100,
	0x0d020600c,
	0x040001398,
	0x0400013a9,
	0x001000000,
	0x096100007,
	0x010bffe73,


@@ 726,19 730,19 @@ ulong bootcode[]={
	0x001000000,
	0x09200b34e,
	0x0d2206004,
	0x04000007e,
	0x04000008f,
	0x001000000,
	0x09000b356,
	0x0d0206004,
	0x040001099,
	0x0400010aa,
	0x001000000,
	0x0d2006140,
	0x0d2206004,
	0x04000135b,
	0x04000136c,
	0x001000000,
	0x0d0006144,
	0x0d0206004,
	0x040001357,
	0x040001368,
	0x001000000,
	0x0d0006130,
	0x090022001,


@@ 748,7 752,7 @@ ulong bootcode[]={
	0x01d00003a,
	0x09003a260,
	0x0d0206004,
	0x04000137d,
	0x04000138e,
	0x001000000,
	0x010bffffb,
	0x001000000,


@@ 756,7 760,7 @@ ulong bootcode[]={
	0x0d2206004,
	0x09410000b,
	0x0d6206008,
	0x040001369,
	0x04000137a,
	0x001000000,
	0x096100007,
	0x092100007,


@@ 766,28 770,28 @@ ulong bootcode[]={
	0x001000000,
	0x09000b2b0,
	0x0d0206004,
	0x040000056,
	0x040000067,
	0x001000000,
	0x0d6006144,
	0x09210000b,
	0x0d6206004,
	0x09000b2c4,
	0x0d0206008,
	0x040000032,
	0x040000043,
	0x001000000,
	0x0d2006144,
	0x0d2206004,
	0x09000b2cb,
	0x0d0206008,
	0x04000002c,
	0x04000003d,
	0x001000000,
	0x010bffd9e,
	0x010bffda0,
	0x001000000,
	0x09000b273,
	0x0d0206004,
	0x09410000b,
	0x0d6206008,
	0x04000134a,
	0x04000135b,
	0x001000000,
	0x096100007,
	0x090100007,


@@ 797,31 801,48 @@ ulong bootcode[]={
	0x001000000,
	0x09200b27f,
	0x0d2206004,
	0x040000037,
	0x040000048,
	0x001000000,
	0x0d6006144,
	0x09010000b,
	0x0d6206004,
	0x09200b293,
	0x0d2206008,
	0x040000013,
	0x040000024,
	0x001000000,
	0x0d0006144,
	0x0d0206004,
	0x09200b299,
	0x0d2206008,
	0x04000000d,
	0x04000001e,
	0x001000000,
	0x010bffd7f,
	0x010bffd81,
	0x001000000,
	0x09210000c,
	0x0d8206004,
	0x09000b26f,
	0x0d0206008,
	0x0400010f8,
	0x040001109,
	0x001000000,
	0x096002002,
	0x010bffd5c,
	0x010bffd60,
	0x001000000,
	0x09000b022,
	0x0d0206004,
	0x0d8206008,
	0x0d820600c,
	0x09200b022,
	0x0d2206010,
	0x0d6206014,
	0x0d6206018,
	0x0e220601c,
	0x092100010,
	0x0e0206020,
	0x09010000d,
	0x0da206024,
	0x0400002af,
	0x001000000,
	0x010bffd0c,
	0x001000000,
	0x082206014,
	0x0de206000,


@@ 1204,15 1225,15 @@ ulong bootcode[]={
	0x0c020b03a,
	0x092002050,
	0x0d2206004,
	0x01d000007,
	0x09003a3b8,
	0x01d000008,
	0x09003a00c,
	0x0d0206008,
	0x040000683,
	0x001000000,
	0x092002052,
	0x0d2206004,
	0x01d000007,
	0x09003a334,
	0x09003a388,
	0x0d0206008,
	0x04000067c,
	0x001000000,


@@ 1293,7 1314,7 @@ ulong bootcode[]={
	0x04000112f,
	0x001000000,
	0x01d000007,
	0x09203a270,
	0x09203a2c4,
	0x0d2206004,
	0x040000503,
	0x001000000,


@@ 1439,7 1460,7 @@ ulong bootcode[]={
	0x040000c50,
	0x001000000,
	0x01d000007,
	0x09203a270,
	0x09203a2c4,
	0x0d2206004,
	0x040000471,
	0x001000000,


@@ 7908,7 7929,6 @@ ulong bootcode[]={
	0x001000000,
	0x000000000,
	0x000000000,
	0x000000000,
	0x06e6f6e2d,
	0x07a65726f,
	0x020657869,


@@ 8274,13 8294,13 @@ ulong bootcode[]={
	0x065207265,
	0x061640000,
	0x000000000,
	0x000004808,
	0x00000492c,
	0x00000411c,
	0x000004a44,
	0x000004858,
	0x0000048a4,
	0x0000048ec,
	0x00000485c,
	0x000004980,
	0x000004170,
	0x000004a98,
	0x0000048ac,
	0x0000048f8,
	0x000004940,
	0x000000000,
	0x000000000,
	0x000000000,


@@ 8375,8 8395,8 @@ ulong bootcode[]={
	0x00a000000,
	0x000000000,
	0x000000000,
	0x000082e0,
	0x00008330,
	0x0,
	0x000082e0,
	0x00008330,
	0x0,
};

M ss/clock.c => ss/clock.c +27 -4
@@ 18,12 18,34 @@ delay(int ms)
		;
}

typedef struct Ctr Ctr;
struct Ctr
{
	ulong	ctr0;
	ulong	lim0;
	ulong	ctr1;
	ulong	lim1;
};
Ctr	*ctr;

void
clockinit(void)
{
	KMap *k;

	k = kmappa(CLOCK, PTENOCACHE|PTEIO);
	ctr = (Ctr*)k->va;
	ctr->lim1 = (CLOCKFREQ/HZ)<<10;
}

void
clock(Ureg *ur)
{
	Proc *p;
	ulong i;

	SYNCREG[1] = 0x5F;	/* clear interrupt */
	i = ctr->lim1;	/* clear interrupt */
	USED(i);
	m->ticks++;
	p = m->proc;
	if(p){


@@ 34,9 56,10 @@ clock(Ureg *ur)
	checkalarms();
	kbdclock();
	mouseclock();
	if((ur->psr&SPL(7)) == 0 && p && p->state==Running){
		sched();
		if(u->nnote && (ur->psr&PSRSUPER)==0)
	if((ur->psr&SPL(0xF))==0 && p && p->state==Running){
		if(anyready())
			sched();
		if(u->nnote && (ur->psr&PSRPSUPER)==0)
			notify(ur);
	}
}

M ss/faultsparc.c => ss/faultsparc.c +5 -5
@@ 14,16 14,16 @@ faultsparc(Ureg *ur)
	int user, read, insyscall;
	ulong tbr;

	tbr = ur->tbr&0xFFF;
	tbr = (ur->tbr&0xFFF)>>4;
	addr = ur->pc;			/* assume instr. exception */
	if(tbr == (9<<4))		/* data access exception */
	if(tbr == 9)			/* data access exception */
		addr = getw2(SEVAR);
	else if(tbr != (1<<4)){		/* should be instruction access exception */
	else if(tbr != 1){		/* should be instruction access exception */
		trap(ur);
		panic("trap returns");
		return;
	}
	spllo();
print("fault: %s pc=0x%lux addr %lux\n", excname(ur->tbr), ur->pc, addr);
print("fault: %s pc=0x%lux addr %lux\n", excname(tbr), ur->pc, addr);
	if(u == 0){
		dumpregs(ur);
		panic("fault u==0 pc=%lux", ur->pc);

M ss/fns.h => ss/fns.h +5 -0
@@ 1,6 1,7 @@
Alarm	*alarm(int, void (*)(Alarm*), void*);
void	alarminit(void);
Block	*allocb(ulong);
int	anyready(void);
void	append(List**, List*);
void	cacheinit(void);
void	cancel(Alarm*);


@@ 12,6 13,7 @@ void	chandevinit(void);
void	checkalarms(void);
#define	clearmmucache()
void	clock(Ureg*);
void	clockinit(void);
Chan	*clone(Chan*, Chan*);
void	close(Chan*);
void	closemount(Mount*);


@@ 94,6 96,7 @@ void	kbdrepeat(int);
void	kbdclock(void);
void	kmapinit(void);
KMap	*kmap(Page*);
KMap	*kmappa(ulong, ulong);
int	kprint(char*, ...);
void	kproc(char*, void(*)(void*), void*);
void	kunmap(KMap*);


@@ 151,6 154,8 @@ void	putstr(char*);
void	putstrn(char*, long);
void	puttbr(ulong);
void	putw2(ulong, ulong);
void	putw4(ulong, ulong);
void	putwC(ulong, ulong);
void	putwD(ulong, ulong);
void	putwE(ulong, ulong);
ulong	pwait(Waitmsg*);

M ss/io.h => ss/io.h +2 -0
@@ 3,6 3,8 @@ typedef struct	Duart	Duart;
#define	SYNCREG		((char*)0x40400000)
#define	DISPLAYRAM	0x1E800000
#define	EPROM		0xF6000000
#define	CLOCK		0xF3000000
#define	CLOCKFREQ	1000000		/* one microsecond increments */
#define	DUARTREG	((Duart*)0x40100000)
#define	PORT		((uchar *)0x40300000)


M ss/l.s => ss/l.s +17 -10
@@ 1,6 1,6 @@
#include "mem.h"

#define	SYSPSR	(PSREF|SPL(0xF)|PSRSUPER)
#define	SYSPSR	(PSREF|SPL(0x0)|PSRSUPER)

TEXT	start(SB), $-4



@@ 319,11 319,11 @@ TEXT	setlabel(SB), $0

TEXT	gotolabel(SB), $0

	MOVW	r+4(FP), R7
	MOVW	b+0(FP), R8
	MOVW	(R8), R1
	MOVW	4(R8), R15
	MOVW	R15, 0(R1)
	MOVW	$1, R7
	RETURN

TEXT	putcxsegm(SB), $0


@@ 368,32 368,39 @@ TEXT	putw2(SB), $0
	MOVW	R8, (R7, 2)
	RETURN

TEXT	putwE(SB), $0
TEXT	putw4(SB), $0

	MOVW	0(FP), R7
	MOVW	4(FP), R8
	MOVW	R8, (R7, 0xE)
	MOVW	R8, (R7, 4)
	RETURN

TEXT	putsegm(SB), $0
TEXT	putwC(SB), $0

	MOVW	0(FP), R7
	MOVW	4(FP), R8
	MOVW	R8, (R7, 3)
	MOVW	R8, (R7, 0xC)
	RETURN

TEXT	putpmeg(SB), $0
TEXT	putwD(SB), $0

	MOVW	0(FP), R7
	MOVW	4(FP), R8
	MOVW	R8, (R7, 4)
	MOVW	R8, (R7, 0xD)
	RETURN

TEXT	putwE(SB), $0

	MOVW	0(FP), R7
	MOVW	4(FP), R8
	MOVW	R8, (R7, 0xE)
	RETURN

TEXT	putwd(SB), $0
TEXT	putsegm(SB), $0

	MOVW	0(FP), R7
	MOVW	4(FP), R8
	MOVW	R8, (R7, 0xD)
	MOVW	R8, (R7, 3)
	RETURN

GLOBL	mach0+0(SB), $MACHSIZE

M ss/main.c => ss/main.c +6 -0
@@ 78,6 78,12 @@ main(void)
/*	filsysinit(); /**/
	pageinit();
	userinit();
{KMap *k;
k = kmappa(0xF5000000, PTENOCACHE|PTEIO);
print("interrupt %ux\n", *(uchar*)k->va);
kunmap(k);
}
	clockinit();
	schedinit();
}


M ss/mem.h => ss/mem.h +2 -2
@@ 18,7 18,7 @@
/*
 * Time
 */
#define	HZ		(60)			/* clock frequency */
#define	HZ		20			/* clock frequency */
#define	MS2HZ		(1000/HZ)		/* millisec per clock tick */
#define	TK2SEC(t)	((t)/HZ)		/* ticks to seconds */
#define	TK2MS(t)	((((ulong)(t))*1000)/HZ)	/* ticks to milliseconds */


@@ 54,7 54,7 @@
 * MMU
 */

#define	VAMASK		0x1FFFFFFF
#define	VAMASK		0x3FFFFFFF
#define	NPMEG		(1<<12)
#define	BY2SEGM		(1<<18)
#define	PG2SEGM		(1<<6)

M ss/mmu.c => ss/mmu.c +28 -12
@@ 40,6 40,11 @@ mapstack(Proc *p)
	/* don't set m->pidhere[*tp] because we're only writing U entry */
	tlbphys = PPN(p->upage->pa)|PTEVALID|PTEWRITE|PTEKERNEL|PTEMAINMEM;
	putcontext(tp-1);
	/*
	 * putw4(USERADDR, tlbphys) might be good enough but
	 * there is that fuss in pexit/pwait() copying between
	 * u areas and that might surprise any cache entries
	 */
	putpmeg(USERADDR, tlbphys);
	u = (User*)USERADDR;
}


@@ 64,6 69,7 @@ newpid(Proc *p)
	m->pidproc[i] = p;
	m->lastpid = i;
print("new context %d\n", i);
	putcontext(i-1);
	/*
	 * kludge: each context is allowed 2 pmegs, one for text and one for stack
	 */


@@ 128,11 134,10 @@ mmuinit(void)
		/*
		 * Invalidate user addresses
		 */
/*
		for(l=UZERO; l<KZERO; l+=BY2SEGM)

		for(l=UZERO; l<(KZERO&VAMASK); l+=BY2SEGM)
			putsegm(l, INVALIDPMEG);
*/
putsegm(0x0000, INVALIDPMEG);

		/*
		 * One segment for screen
		 */


@@ 168,9 173,6 @@ putsegm(0x0000, INVALIDPMEG);
	putcontext(0);
}




void
putmmu(ulong tlbvirt, ulong tlbphys)
{


@@ 200,6 202,21 @@ putmmu(ulong tlbvirt, ulong tlbphys)
}

void
putpmeg(ulong virt, ulong phys)
{
	int i;

	virt &= VAMASK;
	virt &= ~(BY2PG-1);
	/*
	 * Flush old entries from cache
	 */
	for(i=0; i<0x100; i++)
		putwD(virt+(i<<4), 0);
	putw4(virt, phys);
}

void
flushmmu(void)
{
	splhi();


@@ 233,7 250,6 @@ kmapinit(void)
	KMap *k;
	int i;

print("low pmeg %d\n", kmapalloc.lowpmeg);
	kmapalloc.free = 0;
	k = kmapalloc.arena;
	for(i=0; i<(IOEND-IOSEGM)/BY2PG; i++,k++){


@@ 243,7 259,7 @@ print("low pmeg %d\n", kmapalloc.lowpmeg);
}

KMap*
kmap1(Page *pg, ulong flag)
kmappa(ulong pa, ulong flag)
{
	KMap *k;



@@ 255,20 271,20 @@ kmap1(Page *pg, ulong flag)
	}
	kmapalloc.free = k->next;
	unlock(&kmapalloc);
	k->pa = pg->pa;
	k->pa = pa;
	/*
	 * Cache is virtual and a pain to deal with.
	 * Must avoid having the same entry in the cache twice, so
	 * must use NOCACHE or else extreme cleverness elsewhere.
	 */
	putpmeg(k->va, PPN(k->pa)|PTEVALID|PTEKERNEL|PTEWRITE|PTENOCACHE|flag);
	putpmeg(k->va, PPN(pa)|PTEVALID|PTEKERNEL|PTEWRITE|PTENOCACHE|flag);
	return k;
}

KMap*
kmap(Page *pg)
{
	return kmap1(pg, PTEMAINMEM);
	return kmappa(pg->pa, PTEMAINMEM);
}

void

M ss/trap.c => ss/trap.c +10 -5
@@ 35,8 35,6 @@ excname(ulong tbr)
{
	static char buf[32];	/* BUG: not reentrant! */

	tbr &= 0xFFF;
	tbr >>= 4;
	if(tbr < sizeof trapname/sizeof(char*))
		return trapname[tbr];
	if(tbr == 36)


@@ 57,19 55,26 @@ trap(Ureg *ur)
{
	int user;
	char buf[64];
	ulong tbr;

	tbr = (ur->tbr&0xFFF)>>4;
	if(tbr == 30){				/* interrupt 14: counter 1 */
		clock(ur);
		return;
	}

	user = !(ur->psr&PSRPSUPER);

/*	if(u)
		u->p->pc = ur->pc;		/* BUG */
	if(user){
		print("user trap: %s pc=0x%lux\n", excname(ur->tbr), ur->pc);
		print("user trap: %s pc=0x%lux\n", excname(tbr), ur->pc);
dumpregs(ur);
for(;;);
		sprint(buf, "sys: trap: pc=0x%lux %s", ur->pc, excname(ur->tbr));
		sprint(buf, "sys: trap: pc=0x%lux %s", ur->pc, excname(tbr));
		postnote(u->p, 1, buf, NDebug);
	}else{
		print("kernel trap: %s pc=0x%lux\n", excname(ur->tbr), ur->pc);
		print("kernel trap: %s pc=0x%lux\n", excname(tbr), ur->pc);
		dumpregs(ur);
for(;;);
		exit();