Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/ss/main.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname ss/main.c 1990/1223
## diff -e /dev/null /n/bootesdump/1990/1223/sys/src/9/sparc/main.c
0a
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"ureg.h"
#include	"init.h"

#include	<libg.h>
#include	<gnot.h>

char user[NAMELEN];
char bootline[64];
char bootserver[64];
char bootdevice[64];
int bank[2];

void unloadboot(void);

int
Xprint(char *fmt, ...)
{
	char buf[PRINTSIZE];
	int n;

	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	sccputs(buf);
	return n;
}

void
putx(ulong x)
{
	int i;

	for(i=0; i<8; i++){
		sccputc("0123456789ABCDEF"[x>>28]);
		x <<= 4;
	}
	sccputc('\n');
}

void
main(void)
{
	int a;

	u = 0;
	memset(&edata, 0, (char*)&end-(char*)&edata);

	unloadboot();
	machinit();
#ifdef adsf
	mmuinit();
	confinit();
	kmapinit();
#endif
	sccsetup();
	Xprint("hello world addr %lux pc %lux\n", &a, pc());
	reset();
#ifdef asdf
	print("bank 0: %dM  bank 1: %dM\n", bank[0], bank[1]);
	flushmmu();
	procinit0();
	pgrpinit();
	chaninit();
	alarminit();
	chandevreset();
	streaminit();
/*	serviceinit(); /**/
/*	filsysinit(); /**/
	pageinit();
	kmapinit();
	userinit();
	schedinit();
#endif
}

void
reset(void)
{
	delay(100);
	putb2(0x40000000, 4);
}

void
unloadboot(void)
{
	strncpy(user, "rob", sizeof user);
	memcpy(bootline, "9s", sizeof bootline);
	memcpy(bootserver, "bootes", sizeof bootserver);
	memcpy(bootdevice, "parnfucky", sizeof bootserver);
}

void
machinit(void)
{
	int n;

	n = m->machno;
	memset(m, 0, sizeof(Mach));
	m->machno = n;
	m->mmask = 1<<m->machno;
#ifdef adsf
	m->fpstate = FPinit;
	fprestore(&initfp);
#endif
}

void
mmuinit(void)
{
	ulong l, d, i;

	/*
	 * Invalidate user addresses
	 */
	for(l=0; l<4*1024*1024; l+=BY2PG)
		putmmu(l, INVALIDPTE);
	/*
	 * Four meg of usable memory, with top 256K for screen
	 */
	for(i=1,l=KTZERO; i<(4*1024*1024-256*1024)/BY2PG; l+=BY2PG,i++)
		putkmmu(l, PPN(l)|PTEVALID|PTEKERNEL);
	/*
	 * Screen at top of memory
	 */
	for(i=0,d=DISPLAYRAM; i<256*1024/BY2PG; d+=BY2PG,l+=BY2PG,i++)
		putkmmu(l, PPN(d)|PTEVALID|PTEKERNEL);
}

void
init0(void)
{
	Chan *c;

	u->nerrlab = 0;
	m->proc = u->p;
	u->p->state = Running;
	u->p->mach = m;
	spllo();

	chandevinit();
	
	u->slash = (*devtab[0].attach)(0);
	u->dot = clone(u->slash, 0);
	if(!waserror()){
		c = namec("#e/bootline", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, bootline, 64);
		close(c);
		c = namec("#e/bootserver", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, bootserver, 64);
		close(c);
		c = namec("#e/bootdevice", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, bootdevice, 2);
		close(c);
	}
	poperror();
	touser();
}

FPsave	initfp;

void
userinit(void)
{
	Proc *p;
	Seg *s;
	User *up;
	KMap *k;

	p = newproc();
	p->pgrp = newpgrp();
	strcpy(p->text, "*init*");
	strcpy(p->pgrp->user, user);
	p->fpstate = FPinit;

	/*
	 * Kernel Stack
	 */
	p->sched.pc = (ulong)init0;
	p->sched.sp = USERADDR+BY2PG-20;	/* BUG */
	p->sched.sr = SUPER|SPL(0);
	p->upage = newpage(0, 0, USERADDR|(p->pid&0xFFFF));

	/*
	 * User
	 */
	k = kmap(p->upage);
	up = (User*)VA(k);
	up->p = p;
	kunmap(k);

	/*
	 * User Stack
	 */
	s = &p->seg[SSEG];
	s->proc = p;
	s->o = neworig(USTKTOP-BY2PG, 1, OWRPERM, 0);
	s->minva = USTKTOP-BY2PG;
	s->maxva = USTKTOP;

	/*
	 * Text
	 */
	s = &p->seg[TSEG];
	s->proc = p;
	s->o = neworig(UTZERO, 1, 0, 0);
	s->o->pte[0].page = newpage(0, 0, UTZERO);
	s->o->npage = 1;
	k = kmap(s->o->pte[0].page);
	memcpy((ulong*)VA(k), initcode, sizeof initcode);
	kunmap(k);
	s->minva = UTZERO;
	s->maxva = UTZERO+BY2PG;

	ready(p);
}

void
exit(void)
{
	int i;

	u = 0;
	splhi();
	print("exiting\n");
	for(;;)
		;
}

/*
 * Insert new into list after where
 */
void
insert(List **head, List *where, List *new)
{
	if(where == 0){
		new->next = *head;
		*head = new;
	}else{
		new->next = where->next;
		where->next = new;
	}
		
}

/*
 * Insert new into list at end
 */
void
append(List **head, List *new)
{
	List *where;

	where = *head;
	if(where == 0)
		*head = new;
	else{
		while(where->next)
			where = where->next;
		where->next = new;
	}
	new->next = 0;
}

/*
 * Delete old from list
 */
void
delete0(List **head, List *old)
{
	List *l;

	l = *head;
	if(l == old){
		*head = old->next;
		return;
	}
	while(l->next != old)
		l = l->next;
	l->next = old->next;
}

/*
 * Delete old from list.  where->next is known to be old.
 */
void
delete(List **head, List *where, List *old)
{
	if(where == 0){
		*head = old->next;
		return;
	}
	where->next = old->next;
}

banksize(int base)
{
	ulong va;

	if(&end > (int *)((KZERO|1024L*1024L)-BY2PG))
		return 0;
	va = UZERO;	/* user page 1 is free to play with */
	putmmu(va, PTEVALID|(base+0)*1024L*1024L/BY2PG);
	*(ulong*)va = 0;	/* 0 at 0M */
	putmmu(va, PTEVALID|(base+1)*1024L*1024L/BY2PG);
	*(ulong*)va = 1;	/* 1 at 1M */
	putmmu(va, PTEVALID|(base+4)*1024L*1024L/BY2PG);
	*(ulong*)va = 4;	/* 4 at 4M */
	putmmu(va, PTEVALID|(base+0)*1024L*1024L/BY2PG);
	if(*(ulong*)va == 0)
		return 16;
	putmmu(va, PTEVALID|(base+1)*1024L*1024L/BY2PG);
	if(*(ulong*)va == 1)
		return 4;
	putmmu(va, PTEVALID|(base+0)*1024L*1024L/BY2PG);
	if(*(ulong*)va == 4)
		return 1;
	return 0;
}

Conf	conf;

void
confinit(void)
{
	int mul;
	conf.nmach = 1;
	if(conf.nmach > MAXMACH)
		panic("confinit");
	bank[0] = banksize(0);
	bank[1] = banksize(16);
	conf.npage0 = (bank[0]*1024*1024)/BY2PG;
	conf.base0 = 0;
	conf.npage1 = (bank[1]*1024*1024)/BY2PG;
	conf.base1 = 16*1024*1024;
	conf.npage = conf.npage0+conf.npage1;
	conf.maxialloc = (4*1024*1024-256*1024-BY2PG);
	mul = 1 + (conf.npage1>0);
	conf.nproc = 50*mul;
	conf.npgrp = 12*mul;
	conf.npte = 700*mul;
	conf.nmod = 400*mul;
	conf.nalarm = 1000;
	conf.norig = 150*mul;
	conf.nchan = 200*mul;
	conf.nenv = 100*mul;
	conf.nenvchar = 8000*mul;
	conf.npgenv = 200*mul;
	conf.nmtab = 50*mul;
	conf.nmount = 80*mul;
	conf.nmntdev = 10*mul;
	conf.nmntbuf = conf.nmntdev+3;
	conf.nmnthdr = 2*conf.nmntdev;
	conf.nstream = 40 + 32*mul;
	conf.nqueue = 5 * conf.nstream;
	conf.nblock = 24 * conf.nstream;
	conf.nsrv = 16*mul;			/* was 32 */
	conf.nbitmap = 300*mul;
	conf.nbitbyte = 300*1024*mul;
	if(*(uchar*)MOUSE & (1<<4))
		conf.nbitbyte *= 2;	/* ldepth 1 */
	conf.nfont = 10*mul;
	conf.nurp = 32;
	conf.nasync = 1;
	conf.npipe = conf.nstream/2;
	conf.nservice = 3*mul;			/* was conf.nproc/5 */
	conf.nfsyschan = 31 + conf.nchan/20;
	conf.copymode = 0;		/* copy on write */
}

/*
 *  set up floating point for a new process
 */
void
procsetup(Proc *p)
{
#ifdef asdf
	long fpnull;

	fpnull = 0;
	splhi();
	m->fpstate = FPinit;
	p->fpstate = FPinit;
	fprestore((FPsave*)&fpnull);
	spllo();
#endif
	panic("procsetup");
}

/*
 * Save the part of the process state.
 */
void
procsave(uchar *state, int len)
{
	panic("procsave");
#ifdef asdf
	Balu *balu;

	if(len < sizeof(Balu))
		panic("save state too small");
	balu = (Balu *)state;
	fpsave(&u->fpsave);
	if(u->fpsave.type){
		if(u->fpsave.size > sizeof u->fpsave.junk)
			panic("fpsize %d max %d\n", u->fpsave.size, sizeof u->fpsave.junk);
		fpregsave(u->fpsave.reg);
		u->p->fpstate = FPactive;
		m->fpstate = FPdirty;
	}
	if(BALU->cr0 != 0xFFFFFFFF)	/* balu busy */
		memcpy(balu, BALU, sizeof(Balu));
	else{
		balu->cr0 = 0xFFFFFFFF;
		BALU->cr0 = 0xFFFFFFFF;
	}
#endif
}

/*
 *  Restore what procsave() saves
 *
 *  Procsave() makes sure that what state points to is long enough
 */
void
procrestore(Proc *p, uchar *state)
{
	panic("procrestore");
#ifdef asdf
	Balu *balu;

	balu = (Balu *)state;
	if(p->fpstate != m->fpstate){
		if(p->fpstate == FPinit){
			u->p->fpstate = FPinit;
			fprestore(&initfp);
			m->fpstate = FPinit;
		}else{
			fpregrestore(u->fpsave.reg);
			fprestore(&u->fpsave);
			m->fpstate = FPdirty;
		}
	}
	if(balu->cr0 != 0xFFFFFFFF)	/* balu busy */
		memcpy(BALU, balu, sizeof balu);
#endif
}
.
## diffname ss/main.c 1990/1226
## diff -e /n/bootesdump/1990/1223/sys/src/9/sparc/main.c /n/bootesdump/1990/1226/sys/src/9/sparc/main.c
447,448d
433,435d
431d
414,419d
401,405d
399d
390d
363,364d
340,341c
	conf.maxialloc = 4*1024*1024;		/* BUG */
	mul = 2;
.
337,338d
333,335c
	conf.npage0 = (8*1024*1024)/BY2PG;	/* BUG */
	conf.npage = conf.npage0;
.
329a

.
299,323d
229,230c
for(;;)
	delay(60*1000);
	reset();
.
184d
160c

	touser(USTKTOP-5*BY2WD);
.
112,133d
93c
	memcpy(bootdevice, "parnfucky", sizeof bootdevice);
.
84c
	putb2(ENAB, ENABRESET);
.
77d
74d
58,64c
	cacheinit();
.
56a
	mmuinit();
	printinit();
	print("sparc plan 9\n");
	trapinit();
.
54,55d
42a
#endif
.
36a
	if(!ok){
		sccsetup();
		ok = 1;
	}
.
26a
	if(!ok){
		sccsetup();
		ok = 1;
	}
.
20a
#ifdef asdf
static int ok;
.
17d
## diffname ss/main.c 1990/1227
## diff -e /n/bootesdump/1990/1226/sys/src/9/sparc/main.c /n/bootesdump/1990/1227/sys/src/9/sparc/main.c
80a
{KMap *k;
k = kmappa(0xF5000000, PTENOCACHE|PTEIO);
print("interrupt %ux\n", *(uchar*)k->va);
kunmap(k);
}
	clockinit();
.
## diffname ss/main.c 1990/1231
## diff -e /n/bootesdump/1990/1227/sys/src/9/sparc/main.c /n/bootesdump/1990/1231/sys/src/9/sparc/main.c
331a
}

/*
 *  set up the lance
 */
void
lancesetup(Lance *lp)
{
	KMap *k;
	ushort *sp;
	uchar *cp;
	ulong pa;
	int i;

k = kmappa(0xF8400000, PTEIO|PTENOCACHE);
print("dma reg %lux\n", *(ulong*)k->va);
kunmap(k);

	k = kmappa(ETHER, PTEIO|PTENOCACHE);
	lp->rdp = (void*)(k->va+0);
	lp->rap = (void*)(k->va+2);
	k = kmappa(EEPROM, PTEIO|PTENOCACHE);
	cp = (uchar*)(k->va+0x7da);
	for(i=0; i<6; i++)
		lp->ea[i] = *cp++;
	kunmap(k);

	lp->lognrrb = 1;	/* should be larger */
	lp->logntrb = 1;	/* should be larger */
	lp->nrrb = 1<<lp->lognrrb;
	lp->ntrb = 1<<lp->logntrb;

	lp->sep = 1;

	/*
	 *  allocate area for lance init block and descriptor rings
	 */
	pa = (ulong)ialloc(BY2PG, 1)&~KZERO;	/* one whole page */
	k = kmappa(pa, PTEMAINMEM|PTENOCACHE);
	lp->lanceram = (ushort*)k->va;
	lp->lm = (Lancemem*)k->va;
	print("lm %lux %lux\n", k->va, k->pa);

	/*
	 *  Allocate space in host memory for the io buffers.
	 */
	i = lp->nrrb*sizeof(Etherpkt);
	i = (i+(BY2PG-1))/BY2PG;
	if(i != 1)
		panic("lancesetup");
	pa = (ulong)ialloc(i*BY2PG, 1)&~KZERO;
	k = kmappa(pa, PTEMAINMEM|PTENOCACHE);
	lp->lrp = (Etherpkt*)k->va;
	lp->rp = (Etherpkt*)k->va;
	pa = (ulong)ialloc(i*BY2PG, 1)&~KZERO;
	k = kmappa(pa, PTEMAINMEM|PTENOCACHE);
	lp->ltp = (Etherpkt*)k->va;
	lp->tp = (Etherpkt*)k->va;
.
325a
	conf.nnoifc = 1;
	conf.nnoconv = 32;
.
81,85d
## diffname ss/main.c 1991/0108
## diff -e /n/bootesdump/1990/1231/sys/src/9/sparc/main.c /n/bootesdump/1991/0108/sys/src/9/sparc/main.c
383,386c
	lp->ltp = lp->lrp+lp->nrrb;
	lp->tp = lp->rp+lp->nrrb;
print("rp %lux tp %lux lm %lux\n", lp->rp, lp->tp, lp->lm);
print("*rp %lux *tp %lux *lm %lux\n", *(ulong*)lp->rp, *(ulong*)lp->tp, *(ulong*)lp->lm);
*(ulong*)lp->rp = 0;
	k = kmappa(0xF8400000, PTEIO|PTENOCACHE);
print("dma %lux %lux\n", k->va, *(ulong*)(k->va+4));
	*(ulong*)(k->va+4) = 0;
	kunmap(k);
.
380c
	va = 0;
	for(j=i-1; j>=0; j--){
		k = kmappa(pa+j*BY2PG, PTEMAINMEM|PTENOCACHE);
		if(va){
			if(va != k->va+BY2PG)
				panic("lancesetup va unordered");
			va = k->va;
		}
	}
	/*
	 * k->va is the base of the region
	 */
.
377,378c
print("%d lance buffers\n", i);
.
375c
	i = (lp->nrrb+lp->ntrb)*sizeof(Etherpkt);
.
373c
	 * Allocate space in host memory for the io buffers.
	 * Allocate a block and kmap it page by page.  kmap's are initially
	 * in reverse order so rearrange them.
.
370d
367a
print("init block va %lux\n", k->va);
.
366a
	/* map at LANCESEGM */
.
364c
	 * Allocate area for lance init block and descriptor rings
.
356,357c
	lp->lognrrb = 2;	/* should be larger */
	lp->logntrb = 2;	/* should be larger */
.
343,346d
340,341c
	ulong pa, pte, va;
	int i, j;
.
## diffname ss/main.c 1991/0109
## diff -e /n/bootesdump/1991/0108/sys/src/9/sparc/main.c /n/bootesdump/1991/0109/sys/src/9/sparc/main.c
394,400d
380c
		k = kmappa(pa+j*BY2PG, PTEMAINMEM);
.
364c
	k = kmappa(pa, PTEMAINMEM);
.
357a
	lp->busctl = BSWP | ACON | BCON;
.
356d
352,353c
	lp->lognrrb = 5;
	lp->logntrb = 5;
.
346c
	k = kmappa(EEPROM, PTEIO);
.
343c
	k = kmappa(ETHER, PTEIO);
.
160d
95c
	strncpy(user, "bootes", sizeof user);
.
## diffname ss/main.c 1991/0110
## diff -e /n/bootesdump/1991/0109/sys/src/9/sparc/main.c /n/bootesdump/1991/0110/sys/src/9/sparc/main.c
300,301c
	conf.npte = 1400*mul;
	conf.nmod = 800*mul;
.
292c
	conf.npage0 = (6*1024*1024)/BY2PG;	/* BUG */
.
165c
	p->sched.pc = (((ulong)init0) - 8);	/* 8 because of RETURN in gotolabel */
.
85a
intrinit(void)
{
	KMap *k;

	k = kmappa(INTRREG, PTEIO);
	intrreg = (uchar*)k->va;
}

void
.
70a
	intrinit();
.
17a
uchar *intrreg;

.
## diffname ss/main.c 1991/0111
## diff -e /n/bootesdump/1991/0110/sys/src/9/sparc/main.c /n/bootesdump/1991/0111/sys/src/9/sparc/main.c
323c
	conf.nmntbuf = conf.nmntdev+6;
.
309c
	mul = 1;
	if(conf.npage1 > 0)
		mul = 2;
.
306a
	conf.base1 = 16*1024*1024;
.
304,305c
	conf.npage0 = (4*1024*1024)/BY2PG;	/* BUG */
	conf.npage1 = 0*(4*1024*1024)/BY2PG;	/* BUG */
.
223,224c
	delay(30*1000);
.
71a
	print("sparc plan 9 %lux\n", getb2(ENAB));
.
69c
	print("sparc plan 9 %lux\n", getb2(ENAB));
.
## diffname ss/main.c 1991/0112
## diff -e /n/bootesdump/1991/0111/sys/src/9/sparc/main.c /n/bootesdump/1991/0112/sys/src/9/sparc/main.c
307c
	conf.base1 = 32*1024*1024;
.
144,155d
105,112d
72d
69c
	print("sparc plan 9\n");
.
64d
40,56d
20,38d
14,16d
## diffname ss/main.c 1991/0115
## diff -e /n/bootesdump/1991/0112/sys/src/9/sparc/main.c /n/bootesdump/1991/0115/sys/src/9/sparc/main.c
244c
	conf.npage1 = (4*1024*1024)/BY2PG;	/* BUG */
.
## diffname ss/main.c 1991/01151
## diff -e /n/bootesdump/1991/0115/sys/src/9/sparc/main.c /n/bootesdump/1991/01151/sys/src/9/sparc/main.c
347,405d
111a
	savefpregs(&initfp);
.
76,77d
74d
## diffname ss/main.c 1991/0117
## diff -e /n/bootesdump/1991/01151/sys/src/9/sparc/main.c /n/bootesdump/1991/0117/sys/src/9/sparc/main.c
263c
	conf.nmntbuf = conf.nmntdev+3;
.
## diffname ss/main.c 1991/0318
## diff -e /n/bootesdump/1991/0201/sys/src/9/sparc/main.c /n/bootesdump/1991/0318/sys/src/9/slc/main.c
145c
	memmove((ulong*)VA(k), initcode, sizeof initcode);
.
## diffname ss/main.c 1991/0604
## diff -e /n/bootesdump/1991/0318/sys/src/9/slc/main.c /n/bootesdump/1991/0604/sys/src/9/slc/main.c
344a
}

void
firmware(void)
{
	reset();
.
77a
ioinit(void)
{
	KMap *k;

	k = kmappa(KMDUART, PTEIO|PTENOCACHE);
	sccsetup((void*)(k->va));
	sccspecial(0, 0, &kbdq, 2400);		/* scc port 0 is the keyboard */
	kbdq.putc = kbdstate;
	sccspecial(1, 0, &mouseq, 2400);	/* scc port 1 is the mouse */
}

void
.
31a
	ioinit();
.
27a
	screeninit();
.
## diffname ss/main.c 1991/0608
## diff -e /n/bootesdump/1991/0604/sys/src/9/slc/main.c /n/bootesdump/1991/0608/sys/src/9/slc/main.c
293a
	conf.cntrlp = 0;
.
174,175d
172a
	spllo();
	print("cpu %d exiting\n", m->machno);
	while(consactive())
		for(i=0; i<1000; i++)
			;
.
88c

	/* scc port 1 is the mouse */
	sccspecial(1, 0, &mouseq, 2400);
.
86c

	/* scc port 0 is the keyboard */
	sccspecial(0, 0, &kbdq, 2400);
.
83a
	/* tell scc driver it's address */
.
## diffname ss/main.c 1991/0706
## diff -e /n/bootesdump/1991/0608/sys/src/9/slc/main.c /n/bootesdump/1991/0706/sys/src/9/slc/main.c
277d
274,275c
	conf.nseg = conf.nproc*4;
	conf.npagetab = conf.nseg*2;
	conf.nswap = 4096;
	conf.nimage = 50;
.
166,167d
158,163c
	s = newseg(SG_TEXT, UTZERO, 1);
	p->seg[TSEG] = s;
	segpage(s, newpage(1, 0, UTZERO));
	k = kmap(s->map[0]->pages[0]);
.
149,153c
	s = newseg(SG_STACK, USTKTOP-BY2PG, 1);
	p->seg[SSEG] = s;
.
126a
	p->egrp = newegrp();
	p->fgrp = newfgrp();

.
121c
	Segment *s;
.
111a
	kickpager();
.
37c
	initseg();
	grpinit();
.
## diffname ss/main.c 1991/0710
## diff -e /n/bootesdump/1991/0706/sys/src/9/slc/main.c /n/bootesdump/1991/0710/sys/src/9/slc/main.c
185,250d
## diffname ss/main.c 1991/0711
## diff -e /n/bootesdump/1991/0710/sys/src/9/slc/main.c /n/bootesdump/1991/0711/sys/src/9/slc/main.c
140c
	p->sched.sp = USERADDR+BY2PG-(1+MAXSYSARG)*BY2WD;
.
114c
	touser(USTKTOP-(1+MAXSYSARG)*BY2WD);
.
## diffname ss/main.c 1991/0712
## diff -e /n/bootesdump/1991/0711/sys/src/9/slc/main.c /n/bootesdump/1991/0712/sys/src/9/slc/main.c
113c
	kickpager(); /**/
.
## diffname ss/main.c 1991/0717
## diff -e /n/bootesdump/1991/0712/sys/src/9/slc/main.c /n/bootesdump/1991/0717/sys/src/9/slc/main.c
113d
## diffname ss/main.c 1991/0926
## diff -e /n/bootesdump/1991/0717/sys/src/9/slc/main.c /n/bootesdump/1991/0926/sys/src/9/slc/main.c
305c
	systemreset();
.
233a
	conf.ipif = 8;
	conf.ip = 64;
	conf.arp = 32;
	conf.frag = 32;
.
181c
	systemreset();
.
112a
	if(!waserror()){
		c = namec("#e/terminal", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, "sun sparc slc", strlen("sun sparc slc"), 0);
		close(c);
		c = namec("#e/cputype", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, "sparc", strlen("sparc"), 0);
		close(c);
		poperror();
	}

.
61c
systemreset(void)
.
## diffname ss/main.c 1991/0927
## diff -e /n/bootesdump/1991/0926/sys/src/9/slc/main.c /n/bootesdump/1991/0927/sys/src/9/slc/main.c
114,119c
		ksetenv("terminal", "sun sparc slc");
		ksetenv("cputype", "sparc");
.
## diffname ss/main.c 1991/1011
## diff -e /n/bootesdump/1991/0927/sys/src/9/slc/main.c /n/bootesdump/1991/1011/sys/src/9/slc/main.c
137a
	strcpy(p->pgrp->user, "bootes");
.
## diffname ss/main.c 1991/1030
## diff -e /n/bootesdump/1991/1011/sys/src/9/slc/main.c /n/bootesdump/1991/1030/sys/src/9/slc/main.c
269c
	lp->lognrrb = 7;
.
## diffname ss/main.c 1991/1101
## diff -e /n/bootesdump/1991/1030/sys/src/9/slc/main.c /n/bootesdump/1991/1101/sys/src/9/slc/main.c
114c
		ksetenv("terminal", "sun slc");
.
## diffname ss/main.c 1991/1102
## diff -e /n/bootesdump/1991/1101/sys/src/9/slc/main.c /n/bootesdump/1991/1102/sys/src/9/slc/main.c
114c
		ksetterm("sun %s");
.
## diffname ss/main.c 1991/1105
## diff -e /n/bootesdump/1991/1102/sys/src/9/slc/main.c /n/bootesdump/1991/1105/sys/src/9/slc/main.c
138c
	strcpy(p->user, "bootes");
.
## diffname ss/main.c 1991/1106
## diff -e /n/bootesdump/1991/1105/sys/src/9/slc/main.c /n/bootesdump/1991/1106/sys/src/9/slc/main.c
293d
282d
## diffname ss/main.c 1991/1107
## diff -e /n/bootesdump/1991/1106/sys/src/9/slc/main.c /n/bootesdump/1991/1107/sys/src/9/slc/main.c
245a
	conf.dkif = 1;
.
## diffname ss/main.c 1991/1109
## diff -e /n/bootesdump/1991/1107/sys/src/9/slc/main.c /n/bootesdump/1991/1109/sys/src/9/slc/main.c
138c
	strcpy(p->user, eve);
.
13,14d
## diffname ss/main.c 1991/1112
## diff -e /n/bootesdump/1991/1109/sys/src/9/slc/main.c /n/bootesdump/1991/1112/sys/src/9/slc/main.c
133a
	p->procmode = 0640;
.
## diffname ss/main.c 1991/1113
## diff -e /n/bootesdump/1991/1112/sys/src/9/slc/main.c /n/bootesdump/1991/1113/sys/src/9/slc/main.c
23a
	active.exiting = 0;
	active.machs = 1;
.
## diffname ss/main.c 1991/1115
## diff -e /n/bootesdump/1991/1113/sys/src/9/slc/main.c /n/bootesdump/1991/1115/sys/src/9/slc/main.c
43,44d
## diffname ss/main.c 1991/1222
## diff -e /n/bootesdump/1991/1115/sys/src/9/slc/main.c /n/bootesdump/1991/1222/sys/src/9/slc/main.c
146c
	p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF));
.
## diffname ss/main.c 1991/1225
## diff -e /n/bootesdump/1991/1222/sys/src/9/slc/main.c /n/bootesdump/1991/1225/sys/src/9/slc/main.c
85c
	sccsetup((void*)(k->va), KMFREQ);
	k = kmappa(EIADUART, PTEIO|PTENOCACHE);
	sccsetup((void*)(k->va), EIAFREQ);
.
83c
	/* tell scc driver it's addresses */
.
## diffname ss/main.c 1992/0101
## diff -e /n/bootesdump/1991/1225/sys/src/9/slc/main.c /n/bootesdump/1992/0101/sys/src/9/slc/main.c
297c
		k = kmappa(pa+j*BY2PG, PTEMAINMEM|PTENOCACHE);
.
283c
	k = kmappa(pa, PTEMAINMEM|PTENOCACHE);
.
265c
	k = kmappa(EEPROM, PTEIO|PTENOCACHE);
.
262c
	k = kmappa(ETHER, PTEIO|PTENOCACHE);
.
54c
	k = kmappa(INTRREG, PTEIO|PTENOCACHE);
.
## diffname ss/main.c 1992/0120
## diff -e /n/bootesdump/1992/0101/sys/src/9/slc/main.c /n/bootesdump/1992/0120/sys/src/9/slc/main.c
7d
## diffname ss/main.c 1992/0208
## diff -e /n/bootesdump/1992/0120/sys/src/9/slc/main.c /n/bootesdump/1992/0208/sys/src/9/slc/main.c
232c
	conf.nsubfont = 10*mul;
.
## diffname ss/main.c 1992/0209
## diff -e /n/bootesdump/1992/0208/sys/src/9/slc/main.c /n/bootesdump/1992/0209/sys/src/9/slc/main.c
231a
	conf.nfont = 10*mul;
.
9c
#include	<libng.h>
.
## diffname ss/main.c 1992/0211
## diff -e /n/bootesdump/1992/0209/sys/src/9/slc/main.c /n/bootesdump/1992/0211/sys/src/9/slc/main.c
9c
#include	<libg.h>
.
## diffname ss/main.c 1992/0228
## diff -e /n/bootesdump/1992/0211/sys/src/9/slc/main.c /n/bootesdump/1992/0228/sys/src/9/slc/main.c
234,235d
## diffname ss/main.c 1992/0321
## diff -e /n/bootesdump/1992/0228/sys/src/9/slc/main.c /n/bootesdump/1992/0321/sys/src/9/slc/main.c
2c
#include	"../port/lib.h"
.
## diffname ss/main.c 1992/0325
## diff -e /n/bootesdump/1992/0321/sys/src/9/slc/main.c /n/bootesdump/1992/0325/sys/src/9/slc/main.c
20c
	memset(edata, 0, (char*)end-(char*)edata);
.
## diffname ss/main.c 1992/0516
## diff -e /n/bootesdump/1992/0325/sys/src/9/slc/main.c /n/bootesdump/1992/0516/sys/src/9/slc/main.c
110a

	kproc("alarm", alarmkproc, 0);
	chandevinit();
.
106,107d
## diffname ss/main.c 1992/0602
## diff -e /n/bootesdump/1992/0516/sys/src/9/slc/main.c /n/bootesdump/1992/0602/sys/src/9/slc/main.c
39d
## diffname ss/main.c 1992/0610
## diff -e /n/bootesdump/1992/0602/sys/src/9/slc/main.c /n/bootesdump/1992/0610/sys/src/9/slc/main.c
310,315d
## diffname ss/main.c 1992/0619
## diff -e /n/bootesdump/1992/0610/sys/src/9/slc/main.c /n/bootesdump/1992/0619/sys/src/9/slc/main.c
206c

	conf.upages = 1400;

.
200a

.
41d
37d
29c
	pageinit();
.
25a
	xinit();
.
## diffname ss/main.c 1992/0620
## diff -e /n/bootesdump/1992/0619/sys/src/9/slc/main.c /n/bootesdump/1992/0620/sys/src/9/slc/main.c
239,240d
230d
223,227d
218,219d
213,215d
209,211c
	mul = conf.upages/700;

.
38d
## diffname ss/main.c 1992/0621
## diff -e /n/bootesdump/1992/0620/sys/src/9/slc/main.c /n/bootesdump/1992/0621/sys/src/9/slc/main.c
266c
	pa = (ulong)xspanalloc(BY2PG, BY2PG, 0);

.
225d
## diffname ss/main.c 1992/0622
## diff -e /n/bootesdump/1992/0621/sys/src/9/slc/main.c /n/bootesdump/1992/0622/sys/src/9/slc/main.c
279c
	pa = (ulong)xspanalloc(i*BY2PG, BY2PG, 0)&~KZERO;
.
218,222d
## diffname ss/main.c 1992/0623
## diff -e /n/bootesdump/1992/0622/sys/src/9/slc/main.c /n/bootesdump/1992/0623/sys/src/9/slc/main.c
213,219d
131,132c
	p->egrp = smalloc(sizeof(Egrp));
	p->egrp->ref = 1;
	p->fgrp = smalloc(sizeof(Fgrp));
	p->fgrp->ref = 1;
.
## diffname ss/main.c 1992/0625
## diff -e /n/bootesdump/1992/0623/sys/src/9/slc/main.c /n/bootesdump/1992/0625/sys/src/9/slc/main.c
221d
## diffname ss/main.c 1992/0711
## diff -e /n/bootesdump/1992/0625/sys/src/9/slc/main.c /n/bootesdump/1992/0711/sys/src/9/slc/main.c
232c
	ulong pa, va;
.
230d
96,97d
17,18d
## diffname ss/main.c 1992/0715
## diff -e /n/bootesdump/1992/0711/sys/src/9/slc/main.c /n/bootesdump/1992/0715/sys/src/9/slc/main.c
204a

	ktop = PGROUND((ulong)end);
	ktop = PADDR(ktop);
	conf.npage0 -= ktop/BY2PG;
	conf.base0 += ktop;
.
192a
	ulong ktop;
.
## diffname ss/main.c 1992/0720
## diff -e /n/bootesdump/1992/0715/sys/src/9/slc/main.c /n/bootesdump/1992/0720/sys/src/9/slc/main.c
135a
/*	initfp.fsr |= 0x1E << 23;	/* trap on all but INEXACT */
.
## diffname ss/main.c 1992/0722
## diff -e /n/bootesdump/1992/0720/sys/src/9/slc/main.c /n/bootesdump/1992/0722/sys/src/9/slc/main.c
104a
print("alarmkp:\n"); prflush();
.
99c
print("init0:\n"); prflush();

.
77c
	/* tell scc driver its addresses */
.
## diffname ss/main.c 1992/0724
## diff -e /n/bootesdump/1992/0722/sys/src/9/slc/main.c /n/bootesdump/1992/0724/sys/src/9/slc/main.c
106d
99d
## diffname ss/main.c 1992/0725
## diff -e /n/bootesdump/1992/0724/sys/src/9/slc/main.c /n/bootesdump/1992/0725/sys/src/9/slc/main.c
223d
## diffname ss/main.c 1992/0727
## diff -e /n/bootesdump/1992/0725/sys/src/9/slc/main.c /n/bootesdump/1992/0727/sys/src/9/slc/main.c
135,136c
	/* must align initfpp to an ODD word boundary */
	l = (ulong)initfpa;
	l += 3;
	l &= ~7;
	l += 4;
	initfpp = (FPsave*)l;
	savefpregs(initfpp);
.
123a
	ulong l;
.
115c
FPsave	*initfpp;
uchar	initfpa[sizeof(FPsave)+7];
.
37a
	swapinit();
.
## diffname ss/main.c 1992/0801
## diff -e /n/bootesdump/1992/0727/sys/src/9/slc/main.c /n/bootesdump/1992/0801/sys/src/9/slc/main.c
207a
	conf.ss2 = 0;
.
## diffname ss/main.c 1992/0802
## diff -e /n/bootesdump/1992/0801/sys/src/9/slc/main.c /n/bootesdump/1992/0802/sys/src/9/slc/main.c
151a
	p->sched.sp &= ~7;		/* SP must be 8-byte aligned */
.
## diffname ss/main.c 1992/0807
## diff -e /n/bootesdump/1992/0807/sys/src/9/slc/main.c /n/bootesdump/1992/0807/sys/src/9/ss/main.c
232a
	if(cpuserver)
		conf.nproc = 500;
.
226c
	if(cpuserver)
		conf.nswap = conf.npage*2;
	else
		conf.nswap = 4096;
.
223c
	mbytes = (conf.npage*BY2PG)>>20;
	mul = 1 + (mbytes+11)/12;
	if(mul > 2)
		mul = 2;
.
217a
	case 0x55:		/* sparcstation 2 */
		conf.ss2 = 1;
		conf.vacsize = 65536;
		conf.vaclinesize = 32;
		conf.ncontext = 16;
		conf.npmeg = 256;
		conf.ss2cachebug = 1;
		conf.monitor = 0;		/* BUG */
		conf.base0 = 0;
		conf.base1 = 16*MB;
		break;
	}

	bank[0] = banksize(conf.base0, 16*MB);
	bank[1] = banksize(conf.base1, 16*MB);
	conf.npage0 = (bank[0]*MB)/BY2PG;
	conf.npage1 = (bank[1]*MB)/BY2PG;

	romputcxsegm = *(ulong*)(romvec+260);

	conf.npage = conf.npage0+conf.npage1;
	conf.upages = (conf.npage*70)/100;
	if(cpuserver){
		i = conf.npage-conf.upages;
		if(i > (6*MB)/BY2PG)
			conf.upages +=  i - ((6*MB)/BY2PG);
	}

.
216c
	switch(idprom[1]){
	case 0x51:		/* sparcstation 1 */
	case 0x54:		/* slc */
	default:
		conf.ss2 = 0;
		conf.vacsize = 65536;
		conf.vaclinesize = 16;
		conf.ncontext = 8;
		conf.npmeg = 128;
		conf.ss2cachebug = 0;
		conf.monitor = 1;		/* BUG */
		conf.base0 = 0;
		conf.base1 = 32*MB;
		break;
.
209,214c
	/* map id prom */
	va = 1*MB-BY2PG;
	putw4(va, PPN(EEPROM)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
	memmove(idprom, (char*)(va+0x7d8), 32);
	if(idprom[0]!=1 || (idprom[1]&0xF0)!=0x50)
		*(ulong*)va = 0;
	putw4(va, INVALIDPTE);
.
203c
	ulong i;
	ulong ktop, va, mbytes;
.
196a
int
banksize(ulong addr, ulong nbytes)
{
	int i;
	ulong min, max, t;
	ulong va, pa;
	ulong nmeg;

	nmeg = nbytes/MB;
	va = 1*MB-2*BY2PG;
	for(i=0; i<nmeg; i++){
		pa = addr+i*MB;
		putw4(va, PPN(pa)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEWRITE|PTEMAINMEM);
		*(ulong*)va = pa;
	}
	min = ~0;
	max = 0;
	for(i=0; i<nmeg; i++){
		pa = addr+i*MB;
		putw4(va, PPN(pa)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEWRITE|PTEMAINMEM);
		t = *(ulong*)va;
		if(min > t)
			min = t;
		if(max < t)
			max = t;
	}
	putw4(va, INVALIDPTE);
	return (max-min)/MB+1;
}

.
100a
	print("bank 0: %dM  1: %dM\n", bank[0], bank[1]);
.
57c
	putenab(ENABRESET);
.
31a
	if(!conf.monitor)
		sccspecial(2, &printq, &kbdq, 9600);
	pageinit();
.
28d
26c
	if(conf.monitor)
		screeninit();
.
12c
uchar	*intrreg;
int	model;
uchar	idprom[32];
ulong	romvec;		/* open boot rom vector */
int	cpuserver;
ulong	romputcxsegm;
ulong	bank[2];
.
## diffname ss/main.c 1992/0808
## diff -e /n/bootesdump/1992/0807/sys/src/9/ss/main.c /n/bootesdump/1992/0808/sys/src/9/ss/main.c
299a

	romputcxsegm = rom->putcxsegm;
.
291,292c
	bank[0] = conf.npage0*BY2PG/MB;
	bank[1] = conf.npage1*BY2PG/MB;
	
.
286,289c
	scanmem(mempres, nmeg);
	for(i=0; i<nmeg; i++)
		if(mempres[i]){
			v = mempres[i];
			for(j=i+1; j<nmeg && mempres[j]>v; j++)
				v = mempres[j];
			npg = ((v+1)-mempres[i])*MB/BY2PG;
			if(conf.npage0 == 0){
				conf.base0 = i*MB;
				conf.npage0 = npg;
			}else if(conf.npage1 < npg){
				conf.base1 = i*MB;
				conf.npage1 = npg;
			}
			i = v-'0';
		}
.
281,282c
		nmeg = 64;
.
273c
	/* sparcstation 2 */
	case 0x55:		/* sparcstation 2 4/75 */
	case 0x56:		/* ELC 4/25 */
	case 0x57:		/* IPX 4/50 */
.
269,270c
		nmeg = 64;
.
259,260c

	/* sparcstation 1+ BUG: unknown! */
	case 0x52:		/* IPC 4/40 */
	case 0x53:		/* sparcstation 1+ 4/65 */
		/* fall through */
	/* sparcstation 1 */
	case 0x51:		/* sparcstation 1 4/60 */
	case 0x54:		/* slc 4/20 */
.
243,244c
	ulong i, j;
	ulong ktop, va, mbytes, nmeg, npg, v;
.
236a
void
romwalk(ulong d, char* namep)
{
	char *endp;

	*namep++ = '/';
	*namep = 0;
	while(d){
		romprops(d, namep, call(rom->conf->nextprop, d, 0));
		endp = namep+strlen(namep);
		romwalk(call(rom->conf->child, d), endp);
		*endp = 0;
		d = call(rom->conf->next, d);
	}
}

void
fuck(void)
{
	name[0] = 0;
	romwalk(call(rom->conf->next, 0), name);
}

.
233,234d
222,231c
	for(i=0; i<n; i++)
		if(mempres[i]){
			addr = i*MB;
			putw4(va, PPN(addr)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEWRITE|PTEMAINMEM);
			mempres[i] = *(ulong*)va;
		}else
			mempres[i] = 0;
}

char name[1024];

void
romprops(ulong d, char *namep, ulong p)
{
	static ulong romp;
	uchar buf[128];
	int i, n;

	romp += sprint(rombuf+romp, "romprops %lux %lux\n", d, p);
	while(p && *(char*)p){
		n = call(rom->conf->getproplen, d, p);
		if(n>=0 && n<sizeof buf){
			call(rom->conf->getprop, d, p, buf);
			if(strcmp((char*)p, "name")==0){
				strcpy(namep, (char*)buf);
				romp += sprint(rombuf+romp, "`%s'\n", name);
			}else{
				romp += sprint(rombuf+romp, "%lux: %s: ", d, p);
				for(i=0; i<n; i++)
					romp += sprint(rombuf+romp, "%.2ux ", buf[i]);
				romp += sprint(rombuf+romp, "\n");
			}
		}else
			romp += sprint(rombuf+romp, "%lux: %s(%d)\n", d, p, n);
		p = call(rom->conf->nextprop, d, p);
.
217,220c
	for(i=0; i<n; i++){
		mempres[i] = 0;
		addr = i*MB;
		putw4(va, PPN(addr)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEWRITE|PTEMAINMEM);
		*(ulong*)va = addr;
		if(*(ulong*)va == addr){
			addr = ~addr;
			*(ulong*)va = addr;
			if(*(ulong*)va == addr){
				mempres[i] = 1;
				*(ulong*)va = i + '0';
			}
		}
.
215d
211,213c
	ulong va, addr;
.
207,208c
void
scanmem(char *mempres, int n)
.
116a

.
18a
char	rombuf[20000];
char	mempres[256];
.
17c
void	(*romputcxsegm)(int, ulong, int);
.
15c
ROM	*rom;		/* open boot rom vector */
.
7a
#include	"rom.h"
.
## diffname ss/main.c 1992/0809
## diff -e /n/bootesdump/1992/0808/sys/src/9/ss/main.c /n/bootesdump/1992/0809/sys/src/9/ss/main.c
353c
			for(j=i+1; j<sparam->memscan && mempres[j]>v; j++)
.
349,350c
	/* Chart memory */
	scanmem(mempres, sparam->memscan);

	/* Find mirrors and allocate banks */
	for(i=0; i<sparam->memscan; i++)
.
334,347c
	conf.ss2 = sparam->ss2;
	conf.vacsize = sparam->vacsize;
	conf.vaclinesize = sparam->vacline;
	conf.ncontext = sparam->ncontext;
	conf.npmeg = sparam->npmeg;
	conf.ss2cachebug = sparam->cachebug;
	conf.monitor = sparam->monitor;		/* BUG */
.
316,332c
	/* First entry in the table is the default */
	if(sparam->id == 0)
		sparam = sysparam;
.
314c
	for(sparam = sysparam; sparam->id; sparam++)
		if(sparam->id == idprom[1])
			break;
.
300c
	ulong ktop, va, mbytes, npg, v;
.
241,292d
235c
			putw4(va, PPN(addr)|PTEPROBEMEM);
.
221c
		putw4(va, PPN(addr)|PTEPROBEMEM);
.
113a

.
112a
	print("Sun Sparcstation %s\n", sparam->name);
.
22a
typedef struct Sysparam Sysparam;
struct Sysparam
{
	int	id;		/* Model type from id prom */
	char	*name;		/* System name */
	char	ss2;		/* Is sparcstation 2 ? */
	int	vacsize;	/* Cache size */
	int	vacline;	/* Cache line size */
	int	ncontext;	/* Number of MMU contexts */
	int	npmeg;		/* Number of process maps */
	char	cachebug;	/* Machine needs cache bug work around */
	char	monitor;	/* Needs to be computed */
	int	memscan;	/* Number of Meg to scan looking for memory */
}
sysparam[] =
{
	{ 0x51, "1 4/60",   0, 65536, 16,  8, 128, 0, 1, 64 },
	{ 0x52, "IPC 4/40", 0, 65536, 16,  8, 128, 0, 1, 64 },
	{ 0x53, "1+ 4/65",  0, 65536, 16,  8, 128, 0, 1, 64 },
	{ 0x54, "SLC 4/20", 0, 65536, 16,  8, 128, 0, 1, 64 },
	{ 0x55, "2 4/75",   1, 65536, 32, 16, 256, 1, 0, 64 },
	{ 0x56, "ELC 4/25", 1, 65536, 32, 16, 256, 1, 0, 64 },
	{ 0x57, "IPX 4/50", 1, 65536, 32, 16, 256, 1, 0, 64 },
	{ 0 }
};
Sysparam *sparam;

.
20d
14d
## diffname ss/main.c 1992/0810
## diff -e /n/bootesdump/1992/0809/sys/src/9/ss/main.c /n/bootesdump/1992/0810/sys/src/9/ss/main.c
336c
	romputcxsegm = *(ulong*)(rom+260);
.
303d
288a
	/* map frame buffer id */
	putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
	i = getpsr();
	conf.monitor = 0;
	/* if frame buffer not present, we will trap, so prepare to catch it */
	if(setlabel(&catch) == 0){
		setpsr(i|PSRET|(0xF<<8));	/* enable traps, not interrupts */
		conf.monitor = *(ulong*)va;
	}
	setpsr(i);
	catch.pc = 0;
	putw4(va, INVALIDPTE);

.
139a
	print("frame buffer id %lux\n", conf.monitor);
.
93c
	delay(200);
.
66c
	if(conf.monitor == 0)
.
63d
60,61c
	screeninit();
.
56a
	trapinit();
.
37,43c
	{ 0x51, "1 4/60",   0, 65536, 16,  8, 128, 0, 64 },
	{ 0x52, "IPC 4/40", 0, 65536, 16,  8, 128, 0, 64 },
	{ 0x53, "1+ 4/65",  0, 65536, 16,  8, 128, 0, 64 },
	{ 0x54, "SLC 4/20", 0, 65536, 16,  8, 128, 0, 64 },
	{ 0x55, "2 4/75",   1, 65536, 32, 16, 256, 1, 64 },
	{ 0x56, "ELC 4/25", 1, 65536, 32, 16, 256, 1, 64 },
	{ 0x57, "IPX 4/50", 1, 65536, 32, 16, 256, 1, 64 },
.
32d
19a
Label	catch;
.
17c
ulong	romputcxsegm;
.
15c
ulong	rom;		/* open boot rom vector */
.
8d
## diffname ss/main.c 1992/0811
## diff -e /n/bootesdump/1992/0810/sys/src/9/ss/main.c /n/bootesdump/1992/0811/sys/src/9/ss/main.c
297d
295a
putw4(va, (((FRAMEBUFID+BY2PG)>>PGSHIFT)&0xFFFF)|PTEVALID|PTEKERNEL|PTENOCACHE|PTEIO);
memmove(fbcrap, (void*)va, BY2PG);
		j = *(ulong*)(va+4);
		fbsz = j;
		j = BY2PG - 8;	/* for safety */
		for(i=0; i<j && fbstr[0]==0; i++)
			switch(*(uchar*)(va+i)){
			case 'b':
				if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
					strcpy(fbstr, "bwtwo");
				break;
			case 'c':
				if(strncmp((char*)(va+i), "cgthree", 7) == 0)
					strcpy(fbstr, "cgthree");
				if(strncmp((char*)(va+i), "cgsix", 5) == 0)
					strcpy(fbstr, "cgsix");
				break;
			}
.
294d
290d
288c
	/* map frame buffer id; we expect it to be in SBUS slot 3 */
.
138c
	print("frame buffer id %lux %lux %s\n", conf.monitor, fbsz, fbstr);
.
18a
ulong	fbsz;
char	fbstr[32];
char	fbcrap[BY2PG];
.
## diffname ss/main.c 1992/0812
## diff -e /n/bootesdump/1992/0811/sys/src/9/ss/main.c /n/bootesdump/1992/0812/sys/src/9/ss/main.c
356c

	if(bank[1] == 0){
		/*
		 * This split of memory into 2 banks fools the allocator into
		 * allocating low memory pages from bank 0 for the ethernet since
		 * it has only a 24bit address counter.
		 * NB. Suns must have at LEAST 8Mbytes.
		 */
		conf.npage1 = conf.npage0 - (4*MB)/BY2PG;
		conf.base1 = 4*MB;
		conf.npage0 = (4*MB)/BY2PG;
		conf.base0 = 0;
		bank[1] = bank[0]-4;
		bank[0] = 4;
	}

.
330a
	if(conf.ncontext > 8)
		conf.ncontext = 8;	/* BUG to enlarge NKLUDGE */
.
297,314c
		switch(conf.monitor){
		case 0xFE010101:
			strcpy(fbstr, "cgthree");
			break;
		case 0xFE010104:
			strcpy(fbstr, "bwtwo");
			break;
		}
		if(fbstr[0] == 0){
			j = *(ulong*)(va+4);
			if(j > BY2PG-8)
				j = BY2PG - 8;	/* -8 for safety */
			for(i=0; i<j && fbstr[0]==0; i++)
				switch(*(uchar*)(va+i)){
				case 'b':
					if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
						strcpy(fbstr, "bwtwo");
					break;
				case 'c':
					if(strncmp((char*)(va+i), "cgthree", 7) == 0)
						strcpy(fbstr, "cgthree");
					if(strncmp((char*)(va+i), "cgsix", 5) == 0)
						strcpy(fbstr, "cgsix");
					break;
				}
		}
.
292c
	putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEPROBEIO);
.
285c
	putw4(va, PPN(EEPROM)|PTEPROBEIO);
.
236a
	if(ispanic)
		for(;;);
.
226c
exit(int ispanic)
.
141c
	print("frame buffer id %lux %s\n", conf.monitor, fbstr);
	print("NKLUDGE %d\n", NKLUDGE);
.
65a
	if(conf.monitor)
		screeninit(fbstr);
	printinit();
.
63,64d
33c
	int	npmeg;		/* Number of page map entry groups */
.
29c
	char	ss2;		/* Is Sparcstation 2? */
.
22a
int	NKLUDGE;
.
21d
19d
## diffname ss/main.c 1992/0813
## diff -e /n/bootesdump/1992/0812/sys/src/9/ss/main.c /n/bootesdump/1992/0813/sys/src/9/ss/main.c
327,328d
308,325c
		catch.pc = 0;
		putw4(va, INVALIDPTE);
.
294,306c
	/*
	 * Look for a frame buffer.  This isn't done the way the
	 * ROM does it.  Instead we ask if we know the machine type
	 * and just use the builtin frame buffer if we can.  Otherwise
	 * we just look in slot 3 which is where it usually is.
	 * The ROM scans the slots in a specified order and uses
	 * the first one it finds.  Too much bother.
	 *
	 * If we find a frame buffer, we always use it as a console
	 * rather than the attached terminal, if any.  This means
	 * if you have a frame buffer you'd better have a builtin
	 * keyboard, too.
	 */
	switch(idprom[1]){
	case 0x52:	/* IPC */
	case 0x54:	/* SLC */
		conf.monitor = 1;
		strcpy(fbstr, "bwtwo");
		break;
	case 0x57:	/* IPX */
		conf.monitor = 1;
		strcpy(fbstr, "cgsix");
		break;
	default:
		/* map frame buffer id in SBUS slot 3 */
		putw4(va, ((FRAMEBUFID>>PGSHIFT)&0xFFFF)|PTEPROBEIO);
		conf.monitor = 0;
		/* if frame buffer not present, we will trap, so prepare to catch it */
		if(setlabel(&catch) == 0){
			conf.monitor = *(ulong*)va;
			switch(conf.monitor){
			case 0xFE010101:
				strcpy(fbstr, "cgthree");
				break;
			case 0xFE010104:
				strcpy(fbstr, "bwtwo");
				break;
			}
			if(fbstr[0] == 0){
				j = *(ulong*)(va+4);
				if(j > BY2PG-8)
					j = BY2PG - 8;	/* -8 for safety */
				for(i=0; i<j && fbstr[0]==0; i++)
					switch(*(uchar*)(va+i)){
					case 'b':
						if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
							strcpy(fbstr, "bwtwo");
						break;
					case 'c':
						if(strncmp((char*)(va+i), "cgthree", 7) == 0)
							strcpy(fbstr, "cgthree");
						if(strncmp((char*)(va+i), "cgsix", 5) == 0)
							strcpy(fbstr, "cgsix");
						break;
					}
			}
.
291c
		*(ulong*)va = 0;	/* not a sparcstation; die! */
.
142a
mapdump();
.
## diffname ss/main.c 1992/0815
## diff -e /n/bootesdump/1992/0813/sys/src/9/ss/main.c /n/bootesdump/1992/0815/sys/src/9/ss/main.c
143d
## diffname ss/main.c 1992/0817
## diff -e /n/bootesdump/1992/0815/sys/src/9/ss/main.c /n/bootesdump/1992/0817/sys/src/9/ss/main.c
143a
mapdump();

.
## diffname ss/main.c 1992/0818
## diff -e /n/bootesdump/1992/0817/sys/src/9/ss/main.c /n/bootesdump/1992/0818/sys/src/9/ss/main.c
43,44c
	{ 0x56, "ELC 4/25", 1, 65536, 32,  8, 128, 1, 64 },
	{ 0x57, "IPX 4/50", 1, 65536, 32,  8, 256, 1, 64 },
.
## diffname ss/main.c 1992/0820
## diff -e /n/bootesdump/1992/0818/sys/src/9/ss/main.c /n/bootesdump/1992/0820/sys/src/9/ss/main.c
408,409c
		bank[1] = bank[0]-8;
		bank[0] = 8;
.
404,406c
		conf.npage1 = conf.npage0 - (8*MB)/BY2PG;
		conf.base1 = 8*MB;
		conf.npage0 = (8*MB)/BY2PG;
.
144,145d
142a
	if(conf.npage1 != conf.base1)
		print("kernel mem from second bank: reboot and fix!\n");
.
## diffname ss/main.c 1992/0904
## diff -e /n/bootesdump/1992/0820/sys/src/9/ss/main.c /n/bootesdump/1992/0904/sys/src/9/ss/main.c
353,354c
		break;
.
334,351c
			catch.pc = 0;
			putw4(va, INVALIDPTE);
			if(fbstr[0])
				fbslot = f;
.
320,332c
		/* map frame buffer id in SBUS slots 0..3 */
		for(f=0; f<=3 && fbstr[0]==0; f++){
			putw4(va, ((FRAMEBUFID(f)>>PGSHIFT)&0xFFFF)|PTEPROBEIO);
			conf.monitor = 0;
			/* if frame buffer not present, we will trap, so prepare to catch it */
			if(setlabel(&catch) == 0){
				conf.monitor = *(ulong*)va;
				switch(conf.monitor & 0xF0FFFFFF){
				case 0xF0010101:
					strcpy(fbstr, "cgthree");
					break;
				case 0xF0010104:
					strcpy(fbstr, "bwtwo");
					break;
				}
				if(fbstr[0] == 0){
					j = *(ulong*)(va+4);
					if(j > BY2PG-8)
						j = BY2PG - 8;	/* -8 for safety */
					for(i=0; i<j && fbstr[0]==0; i++)
						switch(*(uchar*)(va+i)){
						case 'b':
							if(strncmp((char*)(va+i), "bwtwo", 5) == 0)
								strcpy(fbstr, "bwtwo");
							break;
						case 'c':
							if(strncmp((char*)(va+i), "cgthree", 7) == 0)
								strcpy(fbstr, "cgthree");
							if(strncmp((char*)(va+i), "cgsix", 5) == 0)
								strcpy(fbstr, "cgsix");
							break;
						}
				}
.
316a
		fbslot = 3;
.
312a
		fbslot = 3;
.
281c
	ulong i, j, f;
.
142a
mapcrap();
.
141c
	print("frame buffer id %lux slot %ld %s\n", conf.monitor, fbslot, fbstr);
.
64c
		screeninit(fbstr, fbslot);
.
19a
ulong	fbslot;
.
## diffname ss/main.c 1992/0905
## diff -e /n/bootesdump/1992/0904/sys/src/9/ss/main.c /n/bootesdump/1992/0905/sys/src/9/ss/main.c
144d
## diffname ss/main.c 1992/0908
## diff -e /n/bootesdump/1992/0905/sys/src/9/ss/main.c /n/bootesdump/1992/0908/sys/src/9/ss/main.c
500,513c
	va = kmapregion(pa, i*BY2PG, PTEMAINMEM|PTENOCACHE);

	lp->lrp = (Etherpkt*)va;
	lp->rp = (Etherpkt*)va;
.
464c
	int i;
.
## diffname ss/main.c 1992/0910
## diff -e /n/bootesdump/1992/0908/sys/src/9/ss/main.c /n/bootesdump/1992/0910/sys/src/9/ss/main.c
452a

	conf.monitor = 0;
.
## diffname ss/main.c 1992/0911
## diff -e /n/bootesdump/1992/0910/sys/src/9/ss/main.c /n/bootesdump/1992/0911/sys/src/9/ss/main.c
377,378d
143d
60a
conf.monitor = 0;
.
22d
## diffname ss/main.c 1992/0912
## diff -e /n/bootesdump/1992/0911/sys/src/9/ss/main.c /n/bootesdump/1992/0912/sys/src/9/ss/main.c
450,451d
143,144d
60d
## diffname ss/main.c 1992/0913
## diff -e /n/bootesdump/1992/0912/sys/src/9/ss/main.c /n/bootesdump/1992/0913/sys/src/9/ss/main.c
418,419c
		if(i > (12*MB)/BY2PG)
			conf.upages +=  i - ((12*MB)/BY2PG);
.
## diffname ss/main.c 1992/0914
## diff -e /n/bootesdump/1992/0913/sys/src/9/ss/main.c /n/bootesdump/1992/0914/sys/src/9/ss/main.c
294,299c
	 * Look for a frame buffer.  Do it the way the
	 * ROM does it: scan the slots in a specified order and use
	 * the first one it finds.
.
149d
## diffname ss/main.c 1992/0922
## diff -e /n/bootesdump/1992/0914/sys/src/9/ss/main.c /n/bootesdump/1992/0922/sys/src/9/ss/main.c
120c
	sccsetup((void*)(k->va), EIAFREQ, 1);
.
118c
	sccsetup((void*)(k->va), KMFREQ, 1);
.
## diffname ss/main.c 1992/1002
## diff -e /n/bootesdump/1992/0922/sys/src/9/ss/main.c /n/bootesdump/1992/1002/sys/src/9/ss/main.c
303d
## diffname ss/main.c 1992/1020
## diff -e /n/bootesdump/1992/1002/sys/src/9/ss/main.c /n/bootesdump/1992/1020/sys/src/9/ss/main.c
221a
}

uchar *
pusharg(char *p)
{
	int n;

	n = strlen(p)+1;
	sp -= n;
	memmove(sp, p, n);
	return sp;
}

void
bootargs(ulong base)
{
 	int i, ac;
	uchar *av[32];
	uchar **lsp;

	sp = (uchar*)base + BY2PG - MAXSYSARG*BY2WD;

	ac = 0;
	av[ac++] = pusharg("/sparc/9ss");
	av[ac++] = pusharg("-p");

	/* 4 byte word align stack */
	sp = (uchar*)((ulong)sp & ~3);

	/* build argc, argv on stack */
	sp -= (ac+1)*sizeof(sp);
	lsp = (uchar**)sp;
	for(i = 0; i < ac; i++)
		*lsp++ = av[i] + ((USTKTOP - BY2PG) - base);
	*lsp = 0;
	sp += (USTKTOP - BY2PG) - base - sizeof(sp);
.
209a
	pg = newpage(1, 0, USTKTOP-BY2PG);
	segpage(s, pg);
	k = kmap(pg);
	bootargs(VA(k));
	kunmap(k);
.
168a
	Page *pg;
.
155c
	touser((long)sp);
.
21a
uchar	*sp;
.
## diffname ss/main.c 1992/1029
## diff -e /n/bootesdump/1992/1020/sys/src/9/ss/main.c /n/bootesdump/1992/1029/sys/src/9/ss/main.c
423c
			npg = (j-i)*MB/BY2PG;
.
## diffname ss/main.c 1992/1105
## diff -e /n/bootesdump/1992/1029/sys/src/9/ss/main.c /n/bootesdump/1992/1105/sys/src/9/ss/main.c
476c
		conf.nswap = 16*MB/BY2PG;
.
453c
	i = screenbits()-1;		/* Calculate % of memory for page pool */
	i = 70 - (i*10);
	conf.upages = (conf.npage*i)/100;
.
451d
## diffname ss/main.c 1993/0206
## diff -e /n/bootesdump/1992/1105/sys/src/9/ss/main.c /n/bootesdump/1993/0206/sys/src/9/ss/main.c
480,483d
## diffname ss/main.c 1993/0416
## diff -e /n/bootesdump/1993/0206/sys/src/9/ss/main.c /n/bootesdump/1993/0416/sys/src/9/ss/main.c
447d
445c
		conf.base1 = conf.base0 + 8*MB;
.
420a
			i = v-'0';
.
345a
	case 0x52:	/* IPC */
.
## diffname ss/main.c 1993/0501 # deleted
## diff -e /n/bootesdump/1993/0416/sys/src/9/ss/main.c /n/fornaxdump/1993/0501/sys/src/brazil/ss/main.c
1,536d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].