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

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


## diffname pc/main.c 1991/0625
## diff -e /dev/null /n/bootesdump/1991/0625/sys/src/9/safari/main.c
0a
main(void)
{
}

trap(void)
{
}

edata(void)
{
}

end(void)
{
}
.
## diffname pc/main.c 1991/0629
## diff -e /n/bootesdump/1991/0625/sys/src/9/safari/main.c /n/bootesdump/1991/0629/sys/src/9/safari/main.c
15a

main(void)
{
	prstr("hello world\n");
}

.
14a
	ulong y;

	if(x <= 0xF){
		prdig(x);
	} else {
		y = x&0xF;
		prhex(x>>4);
		prdig(y);
	}
.
13c
void
prhex(ulong x)
.
10a
	if(x < 0xA)
		prchar('0' + x);
	else
		prchar('A' + x);
.
9c
void
prdig(ulong x)
.
6a
	while(*s)
		prchar(*s++);
.
5c
void
prstr(char *s)
.
2a
	if(x == '\n'){
		pos = pos/WIDTH;
		pos = (pos+1)*WIDTH;
	} else {
		SCREEN[pos++] = x;
		SCREEN[pos++] = 0x43;
	}
	if(pos >= WIDTH*HEIGHT)
		pos = 0;
.
1c
#include <u.h>

#define	WIDTH	80
#define	HEIGHT	22
#define SCREEN	((char *)0xB8000)
int pos;

void
prchar(int x)
.
## diffname pc/main.c 1991/0702
## diff -e /n/bootesdump/1991/0629/sys/src/9/safari/main.c /n/bootesdump/1991/0702/sys/src/9/safari/main.c
56a
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	screenputs(buf, n);
	return n;
}
.
54,55c
	char buf[PRINTSIZE];
	int n;
.
52c
int
print(char *fmt, ...)
.
41,49c
	return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s;
.
38,39c
int
sprint(char *s, char *fmt, ...)
.
29,35c
	while(--l){
		for(i=0; i < 10000; i++)
			;
	}
.
25,27c
	int i;
.
23c
delay(int l)
.
18,19d
11,16c
	for(;;){
		print("%x ", kbdc());
.
3,9c
main(void)
.
1c
#include	"u.h"
#include	"lib.h"
#include	"dat.h"
#include	"fns.h"
.
## diffname pc/main.c 1991/0703
## diff -e /n/bootesdump/1991/0702/sys/src/9/safari/main.c /n/bootesdump/1991/0703/sys/src/9/safari/main.c
38a
}

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

	screenputs("panic: ", 7);
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	screenputs(buf, n);
	for(;;);
.
8,10c
	screeninit();
	print("screen inited\n");
	trapinit();
	print("traps inited\n");
	kbdinit();
	print("kbd inited\n");
	sti();
	for(;;);
.
## diffname pc/main.c 1991/0705
## diff -e /n/bootesdump/1991/0703/sys/src/9/safari/main.c /n/bootesdump/1991/0705/sys/src/9/safari/main.c
55a
}

void
sched(void)
{
.
14c
	spllo();
.
## diffname pc/main.c 1991/0706
## diff -e /n/bootesdump/1991/0705/sys/src/9/safari/main.c /n/bootesdump/1991/0706/sys/src/9/safari/main.c
55c
	screenputs("\n", 1);
	INT0ENABLE;
	spllo();
	for(;;)
		idle();
.
24c
		for(i=0; i < 100; i++)
.
15c
	for(;;){
		int c;

		c = getc(&kbdq);
		if(c!=-1)
			screenputc(c);
		idle();
	}
.
13c
	clockinit();
	mmuinit();
	floppyinit();
.
11d
9d
4a
#include	"io.h"
.
2a
#include	"mem.h"
.
## diffname pc/main.c 1991/0709
## diff -e /n/bootesdump/1991/0706/sys/src/9/safari/main.c /n/bootesdump/1991/0709/sys/src/9/safari/main.c
65d
23a
		if((TK2SEC(m->ticks)%5)==0)
			if((TK2SEC(m->ticks)%10)==0)
				floppystop(0);
			else
				floppystart(0);
.
16a
	floppystart(0);
.
## diffname pc/main.c 1991/0711
## diff -e /n/bootesdump/1991/0709/sys/src/9/safari/main.c /n/bootesdump/1991/0711/sys/src/9/safari/main.c
78a
	panic("postnote");
.
77a
{ }

void
ready(Proc*p)
{ }

int
postnote(Proc*p, int x, char* y, int z)
.
75a
int
kbdputc(IOQ* q, int c)
{
	if(c==0x10)
		panic("^p");
	putc(q, c);
}

struct Palloc palloc;

void*
ialloc(ulong n, int align)
{
	ulong p;

	if(palloc.active && n!=0)
		print("ialloc bad\n");
	if(palloc.addr == 0)
		palloc.addr = ((ulong)&end)&~KZERO;
	if(align)
		palloc.addr = PGROUND(palloc.addr);

	memset((void*)(palloc.addr|KZERO), 0, n);
	p = palloc.addr;
	palloc.addr += n;
	if(align)
		palloc.addr = PGROUND(palloc.addr);

	if(palloc.addr >= conf.maxialloc)
		panic("keep bill joy away");

	return (void*)(p|KZERO);
}

.
43a
void
confinit(void)
{
	long x, i, j, *l;
	int mul;

	/*
	 *  size memory
	 */
	x = 0x12345678;
	for(i=1; i<16; i++){
		/*
		 *  write the word
		 */
		l = (long*)(KZERO|(i*1024L*1024L));
		*l = x;
		/*
		 *  take care of wraps
		 */
		for(j = 0; j < i; j++){
			l = (long*)(KZERO|(j*1024L*1024L));
			*l = 0;
		}
		/*
		 *  check
		 */
		l = (long*)(KZERO|(i*1024L*1024L));
		if(*l != x)
			break;
		x += 0x3141526;
	}

	/*
	 *  the first 640k is the standard useful memory
	 */
	conf.npage0 = 640/4;
	conf.base0 = 0;

	/*
	 *  the last 128k belongs to the roms
	 */
	conf.npage1 = (i)*1024/4;
	conf.base1 = 1024/4;

	conf.npage = conf.npage0 + conf.npage1;
	conf.maxialloc = (640*1024-256*1024-BY2PG);

	mul = 1;
	conf.nproc = 20 + 50*mul;
	conf.npgrp = conf.nproc/2;
	conf.nseg = conf.nproc*3;
	conf.npagetab = (conf.nseg*14)/10;
	conf.nswap = conf.nproc*80;
	conf.nimage = 50;
	conf.nalarm = 1000;
	conf.nchan = 4*conf.nproc;
	conf.nenv = 4*conf.nproc;
	conf.nenvchar = 8000*mul;
	conf.npgenv = 200*mul;
	conf.nmtab = 50*mul;
	conf.nmount = 80*mul;
	conf.nmntdev = 15*mul;
	conf.nmntbuf = conf.nmntdev+3;
	conf.nmnthdr = 2*conf.nmntdev;
	conf.nsrv = 16*mul;			/* was 32 */
	conf.nbitmap = 512*mul;
	conf.nbitbyte = conf.nbitmap*1024*screenbits();
	conf.nfont = 10*mul;
	conf.nnoifc = 1;
	conf.nnoconv = 32;
	conf.nurp = 32;
	conf.nasync = 1;
	conf.nstream = (conf.nproc*3)/2;
	conf.nqueue = 5 * conf.nstream;
	conf.nblock = 24 * conf.nstream;
	conf.npipe = conf.nstream/2;
	conf.copymode = 0;			/* copy on write */
	conf.ipif = 8;
	conf.ip = 64;
	conf.arp = 32;
	conf.frag = 32;
	conf.cntrlp = 0;
}

.
39c
		for(i=0; i < 404; i++)
.
33a
machinit(void)
{
	int n;

	n = m->machno;
	memset(m, 0, sizeof(Mach));
	m->machno = n;
	m->mmask = 1<<m->machno;
	active.machs = 1;
}

void
.
30a
	for(;;);
.
25,29c
		floppyseek(0, 0);
		floppyseek(0, 18*512*20);
.
17,18c

	for(i=0; i<100; i++){
.
14d
11a
	mmuinit();
	clockinit();
	alarminit();
.
10a
	print("%d pages in bank0, %d pages in bank1\n", conf.npage0, conf.npage1);
	print("edata == %lux, end == %lux\n", &edata, &end);
.
9a
	int i;

	machinit();
	confinit();
.
7a

char sysname[NAMELEN];
Conf	conf;
char	user[NAMELEN] = "bootes";

extern ulong edata;

.
## diffname pc/main.c 1991/0712
## diff -e /n/bootesdump/1991/0711/sys/src/9/safari/main.c /n/bootesdump/1991/0712/sys/src/9/safari/main.c
230a
}


/*
 *  boot from hard disk
 */
int
hdboot(void)
{
	print("hdboot unimplemented\n");
	return -1;
}

/*
 *  boot from the duart
 */
int
duartboot(void)
{
	print("duartboot unimplemented\n");
	return -1;
}

#include "dosfs.h"

/*
 *  boot from the floppy
 */
int
fdboot(void)
{
	Dosbpb b;
	extern int dosboot(Dosbpb*);

	print("booting from floppy 0\n");
	b.seek = floppyseek;
	b.read = floppyread;
	b.dev = 0;
	return dosboot(&b);
.
218a
/*
 *  some dummy's so we can use kernel code
 */
.
45a
/*
 *  read a line from the keyboard.
 */
int
getline(int quiet)
{
	int c, i=0;
	long start;

	for (start=m->ticks;;) {
	    	do{
			if(TK2SEC(m->ticks - start) > 60)
				return -2;
			c = getc(&kbdq);
		} while(c==-1);
		if(c == '\r')
			c = '\n'; /* turn carriage return into newline */
		if(c == '\177')
			c = '\010';	/* turn delete into backspace */
		if(!quiet){
			if(c == '\033'){
				menu();
				return -1;
			}
			if(c == '\025')
				screenputc('\n');	/* echo ^U as a newline */
			else
				screenputc(c);
		}
		if(c == '\010'){
			if(i > 0)
				i--; /* bs deletes last character */
			continue;
		}
		/* a newline ends a line */
		if (c == '\n')
			break;
		/* ^U wipes out the line */
		if (c =='\025')
			return -1;
		linebuf[i++] = c;
	}
	linebuf[i] = 0;
	return i;
}

/*
 *  prompt for a string from the keyboard.  <cr> returns the default.
 */
int
getstr(char *prompt, char *buf, int size, char *def, int quiet)
{
	int len;
	char *cp;

	for (;;) {
		if(def)
			print("%s[default==%s]: ", prompt, def);
		else
			print("%s: ", prompt);
		len = getline(quiet);
		switch(len){
		case -1:
			/* ^U typed */
			continue;
		case -2:
			/* timeout */
			return -1;
		default:
			break;
		}
		if(len >= size){
			print("line too long\n");
			continue;
		}
		break;
	}
	if(*linebuf==0 && def)
		strcpy(buf, def);
	else
		strcpy(buf, linebuf);
	return 0;
}

int
menu(void)
{
}

.
43c

	return -1;
.
36,41c
/*
 *  parse the server line.  return 0 if OK, -1 if bullshit
 */
int
parse(char *line)
{
	char *def[3];
	char **d;
	char *s;
	int i;

	def[0] = booter[bootdev].name;
	def[1] = booter[bootdev].srv;
	def[2] = "/9.com";

	d = &def[2];
	s = line + strlen(line);
	while((*d = s) > line)
		if(*--s == '!'){
			if(d-- == def)
				return -1;
			*s = '\0';
		}

	for(i = 0; i < strlen(bootchars); i++){
		if(strcmp(def[0], booter[i].name)==0){
			strcpy(server, def[1]);
			strcpy(file, def[2]);
			bootdev = i;
			return 0;
		}
.
33,34c
	for(;;){
		sprint(def, "%s!%s!/%s", booter[bootdev].name, booter[bootdev].srv,
			usecache ? "9.cache" : "9.com");
		if(getstr("server", element, sizeof element, def, 0)<0)
			continue;
		if(parse(element) < 0)
			continue;
		if(getstr("user", user, sizeof user, 0, 0)<0)
			continue;
		if(*user==0)
			continue;
		if((*booter[bootdev].func)() < 0)
			continue;
		print("success\n");
	}
}
.
17c
	char	*path;			/* file path */
	char	element[2*NAMELEN];	/* next element in a file path */
	char	def[2*NAMELEN];
.
14a
typedef	struct Booter	Booter;
struct Booter
{
	char	*name;
	char	*srv;
	int	(*func)(void);
};
Booter	booter[] = {
	{ "fd",		0,	fdboot },
	{ "hd",		0,	hdboot },
	{ "2400",	0,	duartboot },
	{ "1200",	0,	duartboot },
};

int	bootdev;
char	*bootchars = "fh21";
int	usecache;

.
13d
11d
9c
extern ulong edata;

/*
 *  predeclared
 */
int	fdboot(void);
int	hdboot(void);
int	duartboot(void);
int	parse(char*);
int	getline(int);
int	getstr(char*, char*, int, char*, int);
int	menu(void);

char	file[2*NAMELEN];
char	server[NAMELEN];
char	sysname[NAMELEN];
char	user[NAMELEN] = "none";
char	linebuf[256];
.
## diffname pc/main.c 1991/0716
## diff -e /n/bootesdump/1991/0712/sys/src/9/safari/main.c /n/bootesdump/1991/0716/sys/src/9/safari/main.c
432,436c
void
lights(int val)
{
.
429,430c
}
.
423,427c
void
buzz(int f, int d)
.
421d
417,418c
	panic("firmware");
.
411,415c
void
firmware(void)
.
407,408d
404,405c
void
procrestore(Proc *p, uchar *state)
.
402c
 *  Restore what procsave() saves
 *	BUG -- needs floating point support
.
400d
397d
387,395c
procsave(uchar *state, int len)
.
384c
 * Save the part of the process state.
 *	BUG -- needs floating point support
.
349,382d
337,346c
	p->fpstate = FPinit;
	m->fpstate = FPinit;
.
335c
procsetup(Proc *p)
.
317,333c
/*
 *  set up floating point for a new process
 *	BUG -- needs floating point support
 */
.
232a
Conf	conf;

.
227,230c
	u = 0;
	splhi();
	print("exiting\n");
	for(;;)
		;
.
223c
exit(void)
.
215,219c
	p = newproc();
	p->pgrp = newpgrp();
	p->egrp = newegrp();
	p->fgrp = newfgrp();

	strcpy(p->text, "*init*");
	p->fpstate = FPinit;

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

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

	/*
	 * User Stack
	 */
	s = newseg(SG_STACK, USTKTOP-BY2PG, 1);
	p->seg[SSEG] = s;

	/*
	 * Text
	 */
	s = newseg(SG_TEXT, UTZERO, 1);
	p->seg[TSEG] = s;
	segpage(s, newpage(1, 0, UTZERO));
	k = kmap(s->map[0]->pages[0]);
	memmove((ulong*)VA(k), initcode, sizeof initcode);
	kunmap(k);

	ready(p);
.
213c
	Proc *p;
	Segment *s;
	User *up;
	KMap *k;
.
211c
userinit(void)
.
205,207c
	chandevinit();

/*	kickpager();	/* BUG */
	touser();
.
176,203c
	/*
	 * These are o.k. because rootinit is null.
	 * Then early kproc's will have a root and dot.
	 */
	u->slash = (*devtab[0].attach)(0);
	u->dot = clone(u->slash, 0);
.
167,174c
	spllo();
.
130,165c
	u->nerrlab = 0;
	m->proc = u->p;
	u->p->state = Running;
	u->p->mach = m;
.
127,128c
	Chan *c;
.
121,125c
void
init0(void)
.
96,118c
	n = m->machno;
	memset(m, 0, sizeof(Mach));
	m->machno = n;
	m->mmask = 1<<m->machno;
	m->fpstate = FPinit;
	active.machs = 1;
.
91,94c
	int n;
.
88,89c
void
machinit(void)
.
86c
 *	BUG -- needs floating point support
.
68,82c
	schedinit();
.
63,66c
	chandevreset();
	streaminit();
	trapinit();
	swapinit();
	pageinit();
	userinit();
.
61c
	procinit0();
	initseg();
	grpinit();
	chaninit();
.
59d
56a
	printinit();
.
50,53d
9,47c
void
.
7a
char	user[NAMELEN] = "bootes";
extern long edata;
.
6a
#include	"ureg.h"
#include	"init.h"
.
## diffname pc/main.c 1991/0717
## diff -e /n/bootesdump/1991/0716/sys/src/9/safari/main.c /n/bootesdump/1991/0717/sys/src/9/safari/main.c
271a

int
mouseputc(IOQ *q, int c)
{
	return c;
}

.
188c
	conf.maxialloc = (conf.npage0*BY2PG-PGROUND((ulong)&end));
.
129,140d
99c
	p->sched.sp = USERADDR + BY2PG - 4;
.
96a
	 *
	 * N.B. The -4 for the stack pointer is important.  Gotolabel
	 *	uses the bottom 4 bytes of stack to store it's return pc.
.
33a
print("user inited\n");
.
23a
print("proc inited\n");
.
22a
print("mmu inited\n");
.
## diffname pc/main.c 1991/0718
## diff -e /n/bootesdump/1991/0717/sys/src/9/safari/main.c /n/bootesdump/1991/0718/sys/src/9/safari/main.c
78c
	/*
	 *  fault in the first executable page
	 */
	useless = *((ulong *)UTZERO);

.
76a
print("going to user\n");
.
67a
print("interrupts on\n");
.
56a
long useless;

.
32d
25d
23c
	trapinit();
	clockinit();
	faultinit();
.
20,21d
## diffname pc/main.c 1991/0719
## diff -e /n/bootesdump/1991/0718/sys/src/9/safari/main.c /n/bootesdump/1991/0719/sys/src/9/safari/main.c
278d
191c
	conf.nproc = 20 + 20*mul;
.
185c
	conf.base1 = 1024*1024;
.
111c
	p->sched.sp = USERADDR + BY2PG - 12;
.
107,108c
	 * N.B. The -12 for the stack pointer is important.
	 *	4 bytes for gotolabel's return PC
	 *	8 bytes for optional sp and ss pushed during interrupts
.
84a
	/*  fault in the first stack page
	 */
	print("stack is %lux\n", *((ulong *)(USTKTOP-4)));
	*((ulong *)(USTKTOP-4)) = 0xdeadbeef;
	print("stack is %lux\n", *((ulong *)(USTKTOP-4)));
	delay(5000);

.
83c
	print("text is %lux\n", *((ulong *)(UTZERO+32)));
.
81c
	 *  fault in the first executable page and user stack
.
78d
67,69d
55c
ulong garbage;
.
34d
21a
	kbdinit();
.
15a
	a20enable();
.
## diffname pc/main.c 1991/0720
## diff -e /n/bootesdump/1991/0719/sys/src/9/safari/main.c /n/bootesdump/1991/0720/sys/src/9/safari/main.c
116c
	p->sched.sp = USERADDR + BY2PG - 4;
.
113d
82,88d
77,80c
print("going to user\n");
delay(1000);
.
67a
print("go low\n");
	spllo();

.
## diffname pc/main.c 1991/0723
## diff -e /n/bootesdump/1991/0720/sys/src/9/safari/main.c /n/bootesdump/1991/0723/sys/src/9/safari/main.c
274a
}

/*
 *  headland hip set for the safari.
 *  
 *  serious magic!!!
 */

enum
{
	Head=		0x92,		/* control port */
	 Reset=		(1<<0),		/* reset the 386 */
	 A20ena=	(1<<1),		/* enable address line 20 */
};

/*
 *  enable address bit 20
 */
void
a20enable(void)
{
	outb(Head, A20ena);
}

/*
 *  reset the chip
 */
void
exit(void)
{
	int i;

	u = 0;
	print("exiting\n");
	outb(Head, Reset);
.
21a
	vgainit();
.
## diffname pc/main.c 1991/0727
## diff -e /n/bootesdump/1991/0723/sys/src/9/safari/main.c /n/bootesdump/1991/0727/sys/src/9/safari/main.c
22d
## diffname pc/main.c 1991/0730
## diff -e /n/bootesdump/1991/0727/sys/src/9/safari/main.c /n/bootesdump/1991/0730/sys/src/9/safari/main.c
271,276d
## diffname pc/main.c 1991/0801
## diff -e /n/bootesdump/1991/0730/sys/src/9/safari/main.c /n/bootesdump/1991/0801/sys/src/9/safari/main.c
186c
	conf.maxialloc = 2*1024*1024;
.
80,82d
68d
31a
print("streaminit\n"); delay(1000);
.
30a
print("chandevreset\n"); delay(1000);
.
## diffname pc/main.c 1991/0802
## diff -e /n/bootesdump/1991/0801/sys/src/9/safari/main.c /n/bootesdump/1991/0802/sys/src/9/safari/main.c
268,302d
## diffname pc/main.c 1991/0803
## diff -e /n/bootesdump/1991/0802/sys/src/9/safari/main.c /n/bootesdump/1991/0803/sys/src/9/safari/main.c
267a


/*
 *  special stuff for 80c51 power management and headland system controller
 */
enum
{
	/*
	 *  system control port
	 */
	Head=		0x92,		/* control port */
	 Reset=		(1<<0),		/* reset the 386 */
	 A20ena=	(1<<1),		/* enable address line 20 */

	/*
	 *  power management unit ports
	 */
	Pmudata=	0x198,

	Pmucsr=		0x199,
	 Busy=	0x1,
};

/*
 *  enable address bit 20
 */
void
a20enable(void)
{
	outb(Head, A20ena);
}

/*
 *  reset the chip
 */
void
exit(void)
{
	int i;

	u = 0;
	print("exiting\n");
	outb(Head, Reset);
}

/*
 *  return when pmu ready
 */
static int
pmuready(void)
{
	int tries;

	for(tries = 0; (inb(Pmucsr) & Busy); tries++)
		if(tries > 1000)
			return -1;
	return 0;
}

/*
 *  return when pmu busy
 */
static int
pmubusy(void)
{
	int tries;

	for(tries = 0; !(inb(Pmucsr) & Busy); tries++)
		if(tries > 1000)
			return -1;
	return 0;
}

/*
 *  set a bit in the PMU
 */
int
pmuwrbit(int index, int bit, int pos)
{
	outb(Pmucsr, 0x02);		/* next is command request */
	if(pmuready() < 0)
		return -1;
	outb(Pmudata, (2<<4) | index);	/* send write bit command */
	outb(Pmucsr, 0x01);		/* send available */
	if(pmubusy() < 0)
		return -1;
	outb(Pmucsr, 0x01);		/* next is data */
	if(pmuready() < 0)
		return -1;
	outb(Pmudata, (bit<<3) | pos);	/* send bit to write */
	outb(Pmucsr, 0x01);		/* send available */
	if(pmubusy() < 0)
		return -1;
}

/*
 *  control power to the serial line
 *	onoff == 0 means turn power on
 *	onoff == 1 means off
 */
int
serial(int onoff)
{
	return pmuwrbit(1, onoff, 6);
}

int
owl(int onoff)
{
	return pmuwrbit(0, onoff, 4);
}

int
mail(int onoff)
{
	return pmuwrbit(0, onoff, 1);
}
.
## diffname pc/main.c 1991/0806
## diff -e /n/bootesdump/1991/0803/sys/src/9/safari/main.c /n/bootesdump/1991/0806/sys/src/9/safari/main.c
370a
	int x;

	/*
	 *  set config (enable everything)
	 */
	x = splhi();
	config(0x00);
	splx(x);
.
288c
	 Busy=		0x1,

	/*
	 *  configuration port
	 */
	Pconfig=	0x3F3,
.
## diffname pc/main.c 1991/0808
## diff -e /n/bootesdump/1991/0806/sys/src/9/safari/main.c /n/bootesdump/1991/0808/sys/src/9/safari/main.c
376,383d
## diffname pc/main.c 1991/0809
## diff -e /n/bootesdump/1991/0808/sys/src/9/safari/main.c /n/bootesdump/1991/0809/sys/src/9/safari/main.c
365a
	}
	unlock(&pmulock);
.
364c
	if(pmubusy() < 0){
		unlock(&pmulock);
.
361a
	}
.
360c
	if(pmuready() < 0){
		unlock(&pmulock);
.
358a
	}
.
357c
	if(pmubusy() < 0){
		unlock(&pmulock);
.
354a
	}
.
353c
	if(pmuready() < 0){
		unlock(&pmulock);
.
351a
	lock(&pmulock);
.
348a
Lock pmulock;
.
220a
	conf.nfloppy = 1;
	conf.nhard = 1;
.
33d
31d
## diffname pc/main.c 1991/0810
## diff -e /n/bootesdump/1991/0809/sys/src/9/safari/main.c /n/bootesdump/1991/0810/sys/src/9/safari/main.c
376a
	return 0;
.
## diffname pc/main.c 1991/0821
## diff -e /n/bootesdump/1991/0810/sys/src/9/safari/main.c /n/bootesdump/1991/0821/sys/src/9/safari/main.c
178c
	conf.npage1 = (i-1)*1024/4;
.
## diffname pc/main.c 1991/0823
## diff -e /n/bootesdump/1991/0821/sys/src/9/safari/main.c /n/bootesdump/1991/0823/sys/src/9/safari/main.c
168,178c
	conf.npage1 = (i-2)*1024/4;
.
145a
	conf.npage0 = 640/4;
	conf.base0 = 0;

	/*
	 *  size the non-standard memory
	 */
.
144c
	 *  the first 640k is the standard useful memory
	 *  the next 128K is the display
	 *  the last 256k belongs to the roms
.
20a
	print("%lud K bytes of physical memory\n", 1024 + conf.npage1*BY2PG/1024);
.
## diffname pc/main.c 1991/0827
## diff -e /n/bootesdump/1991/0823/sys/src/9/safari/main.c /n/bootesdump/1991/0827/sys/src/9/safari/main.c
301c
	outb(Head, A20ena);		/* enable memory address bit 20 */
.
299c
meminit(void)
.
201c
	conf.nbitmap = 256*mul;
.
184c
	conf.nproc = 10 + 10*mul;
.
177,178c
	conf.base1 = 0x100000;
	conf.npage1 = ((i-1)*1024*1024 - conf.base1)/BY2PG;
.
21c
	print("%ludK bytes of physical memory\n", (conf.base1 + conf.npage1*BY2PG)/1024);
.
16c
	meminit();
.
## diffname pc/main.c 1991/0828
## diff -e /n/bootesdump/1991/0827/sys/src/9/safari/main.c /n/bootesdump/1991/0828/sys/src/9/safari/main.c
201c
	conf.nbitmap = 512*mul;
.
191c
	conf.nchan = 6*conf.nproc;
.
184c
	conf.nproc = 10 + 20*mul;
.
## diffname pc/main.c 1991/0829
## diff -e /n/bootesdump/1991/0828/sys/src/9/safari/main.c /n/bootesdump/1991/0829/sys/src/9/safari/main.c
184c
	conf.nproc = 30 + 20*mul;
.
## diffname pc/main.c 1991/0905
## diff -e /n/bootesdump/1991/0829/sys/src/9/safari/main.c /n/bootesdump/1991/0905/sys/src/9/safari/main.c
89a

	setvec(Coprocvec, coprocintr);
.
12a


.
## diffname pc/main.c 1991/0906
## diff -e /n/bootesdump/1991/0905/sys/src/9/safari/main.c /n/bootesdump/1991/0906/sys/src/9/safari/main.c
271d
261c
/*
 *  make noise, blink lights
 */
.
248d
243a
	if(u->p->fpstate == FPactive){
		fpsave(&u->fpsave);
		u->p->fpstate = FPinactive;
	}
.
238,239c
 *  Save the mach dependent part of the process state.
.
234c
	fpoff();
.
228d
226a
 *  math coprocessor error
 */
void
matherror(Ureg *ur)
{
	postnote(u->p, 1, "math: 837 error", 0);
}

/*
 *  math coprocessor emulation fault
 */
void
mathemu(Ureg *ur)
{
	switch(u->p->fpstate){
	case FPinit:
		fpinit();
		u->p->fpstate = FPactive;
		break;
	case FPinactive:
		fprestore(&u->fpsave);
		u->p->fpstate = FPactive;
		break;
	case FPactive:
print("emu actv 0x%lux\n", getcr0());
		postnote(u->p, 1, "math: emulation", 0);
		break;
	}
}

/*
 *  math coprocessor segment overrun
 */
void
mathover(Ureg *ur)
{
	postnote(u->p, 1, "math: segment overrun", 0);
}

void
mathinit(void)
{
	setvec(Matherrorvec, matherror);
	setvec(Mathemuvec, mathemu);
	setvec(Mathovervec, mathover);
}

/*
.
101a
	fpoff();
.
93,94d
55d
25a
	mathinit();
.
14d
12a
char	user[NAMELEN] = "bootes";
.
10d
## diffname pc/main.c 1991/0907
## diff -e /n/bootesdump/1991/0906/sys/src/9/safari/main.c /n/bootesdump/1991/0907/sys/src/9/safari/main.c
261c
	pexit("Math overrun", 0);
.
250c
		pexit("Math emu", 0);
.
230c
	pexit("Math error", 0);
.
## diffname pc/main.c 1991/0910
## diff -e /n/bootesdump/1991/0907/sys/src/9/safari/main.c /n/bootesdump/1991/0910/sys/src/9/safari/main.c
97a
	strcpy(p->pgrp->user, user);
.
## diffname pc/main.c 1991/0912
## diff -e /n/bootesdump/1991/0910/sys/src/9/safari/main.c /n/bootesdump/1991/0912/sys/src/9/safari/main.c
268c
	setvec(Matherr1vec, matherror1);
	setvec(Matherr2vec, matherror2);
.
261a
print("mathover\n");
.
250d
234a
 *  math coprocessor error
 */
void
matherror2(Ureg *ur)
{
	outb(0xF0, 0xFF);	/* bad craziness */
print("matherror2\n");
	pexit("Math error", 0);
}

/*
.
230a
print("matherror1\n");
.
229c
matherror1(Ureg *ur)
.
## diffname pc/main.c 1991/0913
## diff -e /n/bootesdump/1991/0912/sys/src/9/safari/main.c /n/bootesdump/1991/0913/sys/src/9/safari/main.c
465c
	static QLock ll;

	qlock(&ll);
	pmuwrbit(0, (val&1), 4);		/* owl */
	pmuwrbit(0, ((val>>1)&1), 1);		/* mail */
	qunlock(&ll);
.
462,463c
void
lights(int val)
.
459c
	static Rendez br;
	static QLock bl;

	qlock(&bl);
	pmuwrbit(0, 0, 6);
	tsleep(&br, return0, 0, d);
	pmuwrbit(0, 1, 6);
	qunlock(&bl);
.
456,457c
void
buzz(int f, int d)
.
446,447c
 *  power to serial port
 *	onoff == 0 means on
.
323,335d
280,281c
	setvec(Matherr1vec, matherror);
	setvec(Matherr2vec, matherror);
.
273d
241,243c
	ulong status;
	int i;
	char *msg;
	char note[ERRLEN];

	/*
	 *  a write cycle to port 0xF0 clears the interrupt latch attached
	 *  to the error# line from the 387
	 */
	outb(0xF0, 0xFF);

	status = fpstatus() & 0xffff;
	msg = "unknown";
	for(i = 0; i < 8; i++)
		if((1<<i) & status){
			msg = mathmsg[i];
			break;
		}
	sprint(note, "math: %s, status 0x%ux, pc 0x%lux", msg, status, ur->pc);
	postnote(u->p, 1, note, NDebug);
.
239c
matherror(Ureg *ur)
.
231,233c
	"invalid",
	"denormalized",
	"div-by-zero",
	"overflow",
	"underflow",
	"precision",
	"stack",
	"error",
};
.
225,229c
char *mathmsg[] =
.
## diffname pc/main.c 1991/0926
## diff -e /n/bootesdump/1991/0913/sys/src/9/safari/main.c /n/bootesdump/1991/0926/sys/src/9/safari/main.c
80a
	if(!waserror()){
		c = namec("#e/terminal", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, "safari", strlen("next station 68040"), 0);
		close(c);
		c = namec("#e/cputype", Acreate, OWRITE, 0600);
		(*devtab[c->type].write)(c, "386", strlen("68020"), 0);
		close(c);
		poperror();
	}
.
## diffname pc/main.c 1991/0927
## diff -e /n/bootesdump/1991/0926/sys/src/9/safari/main.c /n/bootesdump/1991/0927/sys/src/9/safari/main.c
82,87c
		ksetenv("terminal", "safari");
		ksetenv("cputype", "386");
.
## diffname pc/main.c 1991/1001
## diff -e /n/bootesdump/1991/0927/sys/src/9/safari/main.c /n/bootesdump/1991/1001/sys/src/9/safari/main.c
465a
/*
 *  power to modem
 *	onoff == 0 means on
 *	onoff == 1 means off
 */
int
modem(int onoff)
{
	if(pmuwrbit(1, onoff, 0)<0)
		return -1;
	return pmuwrbit(1, 1^onoff, 5);
}

.
## diffname pc/main.c 1991/1029
## diff -e /n/bootesdump/1991/1001/sys/src/9/safari/main.c /n/bootesdump/1991/1029/sys/src/9/safari/main.c
478a
/*
 *  CPU speed
 *	onoff == 0 means 2 MHZ
 *	onoff == 1 means 20 MHZ
 */
int
cpuspeed(int speed)
{
	return pmuwrbit(0, speed, 0);
}

.
## diffname pc/main.c 1991/1101
## diff -e /n/bootesdump/1991/1029/sys/src/9/safari/main.c /n/bootesdump/1991/1101/sys/src/9/safari/main.c
82c
		ksetenv("terminal", "at&t safari");
.
## diffname pc/main.c 1991/1102
## diff -e /n/bootesdump/1991/1101/sys/src/9/safari/main.c /n/bootesdump/1991/1102/sys/src/9/safari/main.c
82c
		ksetterm("at&t %s");
.
## diffname pc/main.c 1991/1105
## diff -e /n/bootesdump/1991/1102/sys/src/9/safari/main.c /n/bootesdump/1991/1105/sys/src/9/safari/main.c
103c
	strcpy(p->user, user);
.
## diffname pc/main.c 1991/1107
## diff -e /n/bootesdump/1991/1105/sys/src/9/safari/main.c /n/bootesdump/1991/1107/sys/src/9/safari/main.c
227a
	conf.dkif = 1;
.
21a
crdump();
.
## diffname pc/main.c 1991/1109
## diff -e /n/bootesdump/1991/1107/sys/src/9/safari/main.c /n/bootesdump/1991/1109/sys/src/9/safari/main.c
104c
	strcpy(p->user, eve);
.
22d
12,13d
## diffname pc/main.c 1991/1112
## diff -e /n/bootesdump/1991/1109/sys/src/9/safari/main.c /n/bootesdump/1991/1112/sys/src/9/safari/main.c
98a
	p->procmode = 0640;
.
20a
vgadump();
.
## diffname pc/main.c 1991/1113
## diff -e /n/bootesdump/1991/1112/sys/src/9/safari/main.c /n/bootesdump/1991/1113/sys/src/9/safari/main.c
512c
}

void
owl(int val)
{
	pmuwrbit(0, (val&1), 4);		/* owl */
.
507,509d
54d
42,44d
32a
	bigcursor();
.
21d
16a
	active.exiting = 0;
	active.machs = 1;
.
## diffname pc/main.c 1991/1210
## diff -e /n/bootesdump/1991/1113/sys/src/9/safari/main.c /n/bootesdump/1991/1210/sys/src/9/safari/main.c
473,512c
	switch(machtype){
	case Attnsx:
		return pmumodem(onoff);
	default:
		return 0;
	}
.
467,468c
 *	onoff == 1 means on
 *	onoff == 0 means off
.
462c
	switch(machtype){
	case Attnsx:
		return pmuserial(onoff);
	default:
		return 0;
	}
.
456,457c
 *	onoff == 1 means on
 *	onoff == 0 means off
.
433,451d
427,431c
	switch(machtype){
	case Attnsx:
		pmulights(val);
		break;
	default:
		break;
.
423,425c
void
lights(int val)
.
421c
 *  each bit in val stands for a light
.
412,417c
	switch(machtype){
	case Attnsx:
		pmubuzz(f, d);
		break;
	default:
		break;
	}
.
409,410c
void
buzz(int f, int d)
.
407c
 *  f == frequency (Hz)
 *  d == duration (ms)
.
398,403c
	switch(machtype){
	case Attnsx:
		return pmucpuspeed(speed);
	default:
		return 0;
	}
.
395,396c
int
cpuspeed(int speed)
.
393c
 *  set cpu speed
 *	0 == low speed
 *	1 == high speed
.
389c
	switch(machtype){
	case Attnsx:
		headreset();		/* via headland chip */
		break;
	case At:
		i8042reset();			/* via keyboard controller */
		break;
	}
.
380c
 *  reset the i387 chip
.
376c
	switch(machtype){
	case Attnsx:
		heada20();		/* via headland chip */
		break;
	case At:
		i8042a20();		/* via keyboard controller */
		break;
	}
.
356,372c
/* enable address bit 20 (extended memory) */
.
347,354d
345c
 *  the following functions all are slightly different from
 *  PC to PC.
.
44a
ident(void)
{
	char *id = (char*)(ROMBIOS + 0xFF40);

	/* check for a safari (tres special) */
	if(strncmp(id, "AT&TNSX", 7) == 0)
		machtype = Attnsx;
	else
		machtype = At;
}

void
.
14a
	ident();
.
10a
int machtype;
.
## diffname pc/main.c 1991/1211
## diff -e /n/bootesdump/1991/1210/sys/src/9/safari/main.c /n/bootesdump/1991/1211/sys/src/9/safari/main.c
392c
		i8042reset();		/* via keyboard controller */
.
24c
	print("\n\n%ludK bytes of physical memory\n", (conf.base1 + conf.npage1*BY2PG)/1024);
.
## diffname pc/main.c 1991/1220
## diff -e /n/bootesdump/1991/1211/sys/src/9/safari/main.c /n/bootesdump/1991/1220/sys/src/9/safari/main.c
279c
	sprint(note, "sys: fp: %s, status 0x%ux, pc 0x%lux", msg, status, ur->pc);
.
## diffname pc/main.c 1992/0103
## diff -e /n/bootesdump/1991/1220/sys/src/9/safari/main.c /n/bootesdump/1992/0103/sys/src/9/safari/main.c
204c
	conf.nproc = 30 + i*5;
.
## diffname pc/main.c 1992/0122
## diff -e /n/bootesdump/1992/0103/sys/src/9/safari/main.c /n/bootesdump/1992/0122/sys/src/9/safari/main.c
348c
procrestore(Proc *p)
.
336c
procsave(Proc *p)
.
## diffname pc/main.c 1992/0208
## diff -e /n/bootesdump/1992/0122/sys/src/9/safari/main.c /n/bootesdump/1992/0208/sys/src/9/safari/main.c
223c
	conf.nsubfont = 10*mul;
.
## diffname pc/main.c 1992/0211
## diff -e /n/bootesdump/1992/0208/sys/src/9/safari/main.c /n/bootesdump/1992/0211/sys/src/9/safari/main.c
223c
	conf.nfont = 10*mul;
	conf.nsubfont = 30*mul;
.
## diffname pc/main.c 1992/0219
## diff -e /n/bootesdump/1992/0211/sys/src/9/safari/main.c /n/bootesdump/1992/0219/sys/src/9/safari/main.c
24c
	print("%ludK bytes of physical memory\n", (conf.base1 + conf.npage1*BY2PG)/1024);
.
## diffname pc/main.c 1992/0228
## diff -e /n/bootesdump/1992/0219/sys/src/9/safari/main.c /n/bootesdump/1992/0228/sys/src/9/safari/main.c
225,226d
## diffname pc/main.c 1992/0320
## diff -e /n/bootesdump/1992/0228/sys/src/9/safari/main.c /n/bootesdump/1992/0320/sys/src/9/safari/main.c
40a
print("userinit\n");
.
36a
print("chandevreset\n");
.
## diffname pc/main.c 1992/0321
## diff -e /n/bootesdump/1992/0320/sys/src/9/safari/main.c /n/bootesdump/1992/0321/sys/src/9/safari/main.c
203d
42d
37d
10d
2c
#include	"../port/lib.h"
.
## diffname pc/main.c 1992/0323
## diff -e /n/bootesdump/1992/0321/sys/src/9/safari/main.c /n/bootesdump/1992/0323/sys/src/9/safari/main.c
152a
}

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];
	char *p, *pp;
	uchar **lsp;

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

	ac = 0;
	av[ac++] = pusharg("/386/9safari");
	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(ulong);
.
140a
	pg = newpage(1, 0, USTKTOP-BY2PG);
	segpage(s, pg);
	k = kmap(pg);
	bootargs(VA(k));
	kunmap(k);
.
105a
	Page *pg;
.
96c
	touser(sp);
.
10a
uchar	*sp;	/* stack pointer for /boot */
.
## diffname pc/main.c 1992/0404
## diff -e /n/bootesdump/1992/0323/sys/src/9/safari/main.c /n/bootesdump/1992/0404/sys/src/9/safari/main.c
433,434c
		putcr3(0);		/* crash and burn */
		for(;;);
.
## diffname pc/main.c 1992/0408
## diff -e /n/bootesdump/1992/0404/sys/src/9/safari/main.c /n/bootesdump/1992/0408/sys/src/9/safari/main.c
434a
		putcr3(0);		/* crash and burn */
.
433d
36d
## diffname pc/main.c 1992/0409
## diff -e /n/bootesdump/1992/0408/sys/src/9/safari/main.c /n/bootesdump/1992/0409/sys/src/9/safari/main.c
424a
etherdump();
return;
.
30a
	kbdinit();
.
28d
## diffname pc/main.c 1992/0411
## diff -e /n/bootesdump/1992/0409/sys/src/9/safari/main.c /n/bootesdump/1992/0411/sys/src/9/safari/main.c
433a
		print("hit the button...");
.
425,426d
## diffname pc/main.c 1992/0429
## diff -e /n/bootesdump/1992/0411/sys/src/9/safari/main.c /n/bootesdump/1992/0429/sys/src/9/safari/main.c
280a
	confinit1();
.
278c
	conf.nfloppy = 2;
.
209c
	 *  the last 256k belongs to the roms and other devices
.
92c
		ksetpcinfo();
.
## diffname pc/main.c 1992/0516
## diff -e /n/bootesdump/1992/0429/sys/src/9/safari/main.c /n/bootesdump/1992/0516/sys/src/9/safari/main.c
88a
	kproc("alarm", alarmkproc, 0);
.
## diffname pc/main.c 1992/0602
## diff -e /n/bootesdump/1992/0516/sys/src/9/safari/main.c /n/bootesdump/1992/0602/sys/src/9/safari/main.c
35d
## diffname pc/main.c 1992/0609
## diff -e /n/bootesdump/1992/0602/sys/src/9/safari/main.c /n/bootesdump/1992/0609/sys/src/9/safari/main.c
281c
	confinit1(mul);
.
## diffname pc/main.c 1992/0610
## diff -e /n/bootesdump/1992/0609/sys/src/9/safari/main.c /n/bootesdump/1992/0610/sys/src/9/safari/main.c
393,397d
## diffname pc/main.c 1992/0622
## diff -e /n/bootesdump/1992/0610/sys/src/9/safari/main.c /n/bootesdump/1992/0622/sys/src/9/safari/main.c
262,265d
## diffname pc/main.c 1992/0625
## diff -e /n/bootesdump/1992/0622/sys/src/9/safari/main.c /n/bootesdump/1992/0625/sys/src/9/safari/main.c
276c

.
251,267d
246,248d
243a
	/* for meminit() */
	conf.topofmem = i*MB;

.
242a
	conf.upages = (conf.npage*70)/100;
.
239,241c
	conf.base1 = 1*MB;
	conf.npage1 = ((i-1)*MB - conf.base1)/BY2PG;
.
234c
		l = (long*)(KZERO|(i*MB));
.
228c
			l = (long*)(KZERO|(j*MB));
.
222c
		l = (long*)(KZERO|(i*MB));
.
110,111c
	p->egrp = smalloc(sizeof(Egrp));
	p->egrp->ref = 1;
	p->fgrp = smalloc(sizeof(Fgrp));
	p->fgrp->ref = 1;
.
38d
33,34d
25a
	pageinit();
.
24d
21a
	xinit();
.
## diffname pc/main.c 1992/0711
## diff -e /n/bootesdump/1992/0625/sys/src/9/safari/main.c /n/bootesdump/1992/0711/sys/src/9/safari/main.c
398,399d
369a
	USED(p);
.
357a
	USED(p);
.
329a
	USED(ur);
.
308a
	USED(ur);
.
177d
70,71d
## diffname pc/main.c 1992/0715
## diff -e /n/bootesdump/1992/0711/sys/src/9/safari/main.c /n/bootesdump/1992/0715/sys/src/9/safari/main.c
239a

	ktop = PGROUND((ulong)end);
	ktop = PADDR(ktop);
	conf.npage0 -= ktop/BY2PG;
	conf.base0 += ktop;
.
201a
	ulong ktop;
.
## diffname pc/main.c 1992/0725
## diff -e /n/bootesdump/1992/0715/sys/src/9/safari/main.c /n/bootesdump/1992/0725/sys/src/9/safari/main.c
262,263d
259d
250d
201d
## diffname pc/main.c 1992/0804
## diff -e /n/bootesdump/1992/0725/sys/src/9/safari/main.c /n/bootesdump/1992/0804/sys/src/9/safari/main.c
358a
	if(u->p->state == Moribund)
		return;
.
## diffname pc/main.c 1992/0805
## diff -e /n/bootesdump/1992/0804/sys/src/9/safari/main.c /n/bootesdump/1992/0805/sys/src/9/safari/main.c
358,363c
	if(p->fpstate == FPactive){
		if(p->state == Moribund)
			fpoff();
		else
			fpsave(&u->fpsave);
		p->fpstate = FPinactive;
.
330c
print("sys: fp: math overrun pc 0x%lux pid %d\n", ur->pc, u->p->pid);
	pexit("math overrun", 0);
.
318c
		panic("math emu", 0);
.
297a
print("%s cr0 %lux\n", note, getcr0());
.
## diffname pc/main.c 1992/0806
## diff -e /n/bootesdump/1992/0805/sys/src/9/safari/main.c /n/bootesdump/1992/0806/sys/src/9/safari/main.c
297,299c
	if(msg == 0){
		sprint(note, "sys: fp: unknown fppc=0x%lux", u->fpsave.pc);
		postnote(u->p, 1, note, NDebug);
	}
	if(ur->pc & KZERO)
		panic("fp: status %lux fppc=0x%lux pc=0x%lux", status,
			u->fpsave.pc, ur->pc);
.
294a
			sprint(note, "sys: fp: %s fppc=0x%lux", msg, u->fpsave.pc);
			postnote(u->p, 1, note, NDebug);
.
290,291c
	/*
	 *  save floating point state to check out error
	 */
	fpenv(&u->fpsave);
	status = u->fpsave.status;

	msg = 0;
.
## diffname pc/main.c 1992/0807
## diff -e /n/bootesdump/1992/0806/sys/src/9/safari/main.c /n/bootesdump/1992/0807/sys/src/9/safari/main.c
248a
	conf.monitor = 1;
.
## diffname pc/main.c 1992/0808
## diff -e /n/bootesdump/1992/0808/sys/src/9/safari/main.c /n/bootesdump/1992/0808/sys/src/9/pc/main.c
10c
int machtype;	/* machine type, mostly for power management */
.
## diffname pc/main.c 1992/0812
## diff -e /n/bootesdump/1992/0808/sys/src/9/pc/main.c /n/bootesdump/1992/0812/sys/src/9/pc/main.c
417a
	if(ispanic)
		for(;;);
.
414c
exit(int ispanic)
.
## diffname pc/main.c 1992/0902
## diff -e /n/bootesdump/1992/0812/sys/src/9/pc/main.c /n/bootesdump/1992/0902/sys/src/9/pc/main.c
502,503c
	switch(pmutype){
	case PMUnsx20:
.
486,487c
	switch(pmutype){
	case PMUnsx20:
.
469,470c
	switch(pmutype){
	case PMUnsx20:
.
454,455c
	switch(pmutype){
	case PMUnsx20:
.
439,440c
	switch(pmutype){
	case PMUnsx20:
.
420,428c
	i8042reset();		/* via keyboard controller */
	print("can't reset via software, do something drastic!\n");
	for(;;);
.
396,409d
246d
48,51c
	if(strncmp(id, "AT&TNSX", 7) == 0){
		mousetype = MousePS2;
		pmutype = PMUnsx20;
	}else if(strncmp(id, "NCRD.0", 6) == 0){
		mousetype = MousePS2;
		pmutype = PMUother;
	}else{
		mousetype = Mouseserial;
		pmutype = PMUother;
	}
.
41a
/*
 *  this should be changed to describe architecture dependencies outside the
 *  PC model
 */
.
17c
	i8042a20();		/* enable address lines 20 and up */
.
10c
int mousetype;
int pmutype;
.
## diffname pc/main.c 1992/0903
## diff -e /n/bootesdump/1992/0902/sys/src/9/pc/main.c /n/bootesdump/1992/0903/sys/src/9/pc/main.c
416,418c

	switch(resettype){
	case Resetheadland:
		headreset();
	case Reset8042:
		i8042reset();		/* via keyboard controller */
	default:
		print("Reset the machine!\n");
		for(;;);
	}
.
192a
	cp[64] = 0;
	if(strncmp(cp, "fd!", 3) == 0){
		sprint(buf, "local!#f/fd%ddisk", atoi(cp+3));
		av[ac++] = pusharg(buf);
	} else if(strncmp(cp, "hd!", 3) == 0){
		sprint(buf, "local!#w/hd%ddisk", atoi(cp+3));
		av[ac++] = pusharg(buf);
	}
.
186a
	char *cp = BOOTLINE;
	char buf[64];
.
61d
58c
		resettype = Reset8042;
.
55a
		resettype = Resetheadland;
.
52d
44,45c
 *  This tries to capture architecture dependencies since things
 *  like power management/reseting/mouse are outside the hardware
 *  model.
.
13a
uchar *sp;	/* stack pointer for /boot */

.
12c
int resettype;
.
9a
/* configuration parameters */
.
## diffname pc/main.c 1992/0904
## diff -e /n/bootesdump/1992/0903/sys/src/9/pc/main.c /n/bootesdump/1992/0904/sys/src/9/pc/main.c
63,64d
61d
57d
11c
enum
{
	/* what kind of power management */
	PMUother=	0,
	PMUnsx20=	1,

	/* how to reset the processor */
	Resetother=	0,
	Reset8042=	1,
	Resetheadland=	2,
};
.
## diffname pc/main.c 1992/0915
## diff -e /n/bootesdump/1992/0904/sys/src/9/pc/main.c /n/bootesdump/1992/0915/sys/src/9/pc/main.c
269c
	conf.upages = (conf.npage*60)/100;
.
## diffname pc/main.c 1992/0918
## diff -e /n/bootesdump/1992/0915/sys/src/9/pc/main.c /n/bootesdump/1992/0918/sys/src/9/pc/main.c
108c
		strcpy(tstr, machtype);
		strcat(tstr, " %s");
		ksetterm(tstr);
.
89a
	char tstr[32];

.
69c
	}else if(strcmp(machtype, "NCRD.0") == 0){
.
66c
	for(i = 0; i < 8; i++){
		if(isprint(id[i]) == 0)
			break;
		machtype[i] = id[i];
	}
	if(i == 0)
		strcpy(machtype, "generic");
	if(strcmp(machtype, "AT&TNSX") == 0){
.
64a
	int i;
.
23a
char machtype[9];
.
8a
#include	<ctype.h>
.
## diffname pc/main.c 1992/0923
## diff -e /n/bootesdump/1992/0918/sys/src/9/pc/main.c /n/bootesdump/1992/0923/sys/src/9/pc/main.c
537d
532,535c
	if(arch->modempower)
		return (*arch->modempower)(onoff);
	else
.
521d
516,519c
	if(arch->serialpower)
		return (*arch->serialpower)(onoff);
	else
.
499,505c
	if(arch->lights)
		(*arch->lights)(val);
.
484,490c
	if(arch->buzz)
		(*arch->buzz)(f, d);
.
474d
469,472c
	if(arch->cpuspeed)
		return (*arch->cpuspeed)(speed);
	else
.
450,458c
	(*arch->reset)();
.
120c
		strcpy(tstr, arch->id);
.
72,81c
	arch = *p;
.
69,70c
	for(p = knownarch; *p != &generic; p++)
		if(strncmp((*p)->id, id, strlen((*p)->id)) == 0)
.
67c
	PCArch **p;
.
54d
28a
extern PCArch nsx20, generic, ncr3170;

PCArch *arch;
PCArch *knownarch[] =
{
	&nsx20,
	&ncr3170,
	&generic,
};

.
18,26d
11,16d
## diffname pc/main.c 1992/1002
## diff -e /n/bootesdump/1992/0923/sys/src/9/pc/main.c /n/bootesdump/1992/1002/sys/src/9/pc/main.c
268c

	pcnt = screenbits()-1;		/* Calculate % of memory for page pool */
	pcnt = 70 - (pcnt*10);
	conf.upages = (conf.npage*pcnt)/100;
.
229a
	int pcnt;
.
## diffname pc/main.c 1992/1014
## diff -e /n/bootesdump/1992/1002/sys/src/9/pc/main.c /n/bootesdump/1992/1014/sys/src/9/pc/main.c
277a

	pcnt = screenbits()-1;		/* Calculate % of memory for page pool */
	pcnt = 70 - (pcnt*10);
	conf.upages = (conf.npage*pcnt)/100;
	if(conf.npage - conf.upages < 1572864/BY2PG)
		conf.upages = conf.npage - 1572864/BY2PG;
.
270,273d
## diffname pc/main.c 1992/1016
## diff -e /n/bootesdump/1992/1014/sys/src/9/pc/main.c /n/bootesdump/1992/1016/sys/src/9/pc/main.c
279a

	ktop = PGROUND((ulong)end);
	ktop = PADDR(ktop);
	conf.npage0 -= ktop/BY2PG;
	conf.base0 += ktop;
.
270,274d
267c
	conf.npage1 = (i*MB - conf.base1)/BY2PG;
.
## diffname pc/main.c 1992/1019
## diff -e /n/bootesdump/1992/1016/sys/src/9/pc/main.c /n/bootesdump/1992/1019/sys/src/9/pc/main.c
265a
	i--;
.
261a
		l--;
.
256c
			l--;
			*l = ~x;
.
254c
		for(j = 1; j < i; j++){
.
249a
		l--;
.
245c
	for(i=2; i<17; i++){
.
## diffname pc/main.c 1992/1103
## diff -e /n/bootesdump/1992/1019/sys/src/9/pc/main.c /n/bootesdump/1992/1103/sys/src/9/pc/main.c
297c
	conf.nhard = 2;
.
## diffname pc/main.c 1992/1106
## diff -e /n/bootesdump/1992/1103/sys/src/9/pc/main.c /n/bootesdump/1992/1106/sys/src/9/pc/main.c
295d
292,293d
## diffname pc/main.c 1992/1110
## diff -e /n/bootesdump/1992/1106/sys/src/9/pc/main.c /n/bootesdump/1992/1110/sys/src/9/pc/main.c
273a
	conf.ldepth = 1;
.
## diffname pc/main.c 1992/1111
## diff -e /n/bootesdump/1992/1110/sys/src/9/pc/main.c /n/bootesdump/1992/1111/sys/src/9/pc/main.c
274c
	conf.ldepth = 2;
.
## diffname pc/main.c 1992/1112
## diff -e /n/bootesdump/1992/1111/sys/src/9/pc/main.c /n/bootesdump/1992/1112/sys/src/9/pc/main.c
274c
	conf.ldepth = 1;
.
## diffname pc/main.c 1992/1113
## diff -e /n/bootesdump/1992/1112/sys/src/9/pc/main.c /n/bootesdump/1992/1113/sys/src/9/pc/main.c
274,275c
	conf.ldepth = 0;
	pcnt = (1<<conf.ldepth)-1;		/* Calculate % of memory for page pool */
.
235c
	 *  the next 128K is the display, I/O mem, and BIOS
.
## diffname pc/main.c 1992/1121
## diff -e /n/bootesdump/1992/1113/sys/src/9/pc/main.c /n/bootesdump/1992/1121/sys/src/9/pc/main.c
278,279c
	if(conf.npage - conf.upages < (2*MB)/BY2PG)
		conf.upages = conf.npage - (2*MB)/BY2PG;
.
## diffname pc/main.c 1993/0114
## diff -e /n/bootesdump/1992/1121/sys/src/9/pc/main.c /n/bootesdump/1993/0114/sys/src/9/pc/main.c
208c
		sprint(buf, "local!#h/hd%ddisk", atoi(cp+3));
.
## diffname pc/main.c 1993/0206
## diff -e /n/bootesdump/1993/0114/sys/src/9/pc/main.c /n/bootesdump/1993/0206/sys/src/9/pc/main.c
293d
## diffname pc/main.c 1993/0217
## diff -e /n/bootesdump/1993/0206/sys/src/9/pc/main.c /n/bootesdump/1993/0217/sys/src/9/pc/main.c
278,279c
	if(conf.npage - conf.upages < ((3*MB)/4)/BY2PG)
		conf.upages = conf.npage - ((3*MB)/4)/BY2PG;
.
266a
		memset((char*)(KZERO|((i-1)*MB)), 0, MB);
.
## diffname pc/main.c 1993/0223
## diff -e /n/bootesdump/1993/0217/sys/src/9/pc/main.c /n/bootesdump/1993/0223/sys/src/9/pc/main.c
279,280d
## diffname pc/main.c 1993/0330
## diff -e /n/bootesdump/1993/0223/sys/src/9/pc/main.c /n/bootesdump/1993/0330/sys/src/9/pc/main.c
285a

	/*
	 *  parse configuration args from dos file p9rc
	 */
	cp = BOOTARGS;	/* where b.com leaves it's config */
	cp[BOOTARGSLEN-1] = 0;
	i = getfields(cp, line, MAXCONF, '\n');
	for(j = 0; j < i; j++){
		cp = strchr(line[j], '\r');
		if(cp)
			*cp = 0;
		cp = strchr(line[j], '=');
		if(cp == 0)
			continue;
		*cp++ = 0;
		if(cp - line[j] >= NAMELEN+1)
			*(line[j]+NAMELEN-1) = 0;
		confname[nconf] = line[j];
		confval[nconf] = cp;
		nconf++;
	}
.
231a
	char *cp;
	char *line[MAXCONF];
.
104a
		for(i = 0; i < nconf; i++)
			ksetenv(confname[i], confval[i]);
.
84a
	int i;
.
23a
/* where b.com leaves configuration info */
#define BOOTARGS	((char*)(KZERO|1024))
#define	BOOTARGSLEN	1024
#define	MAXCONF		32

char *confname[MAXCONF];
char *confval[MAXCONF];
int nconf;

.
## diffname pc/main.c 1993/0401
## diff -e /n/bootesdump/1993/0330/sys/src/9/pc/main.c /n/bootesdump/1993/0401/sys/src/9/pc/main.c
322,328d
299a
	conf.nproc = 30 + i*5;
	conf.monitor = 1;
	conf.nswap = conf.nproc*80;
	conf.nimage = 50;
	conf.copymode = 0;			/* copy on write */
	conf.nfloppy = 2;
	conf.nhard = 2;
.
## diffname pc/main.c 1993/0413
## diff -e /n/bootesdump/1993/0401/sys/src/9/pc/main.c /n/bootesdump/1993/0413/sys/src/9/pc/main.c
306a
	conf.nmach = 1;
.
## diffname pc/main.c 1993/0416
## diff -e /n/bootesdump/1993/0413/sys/src/9/pc/main.c /n/bootesdump/1993/0416/sys/src/9/pc/main.c
308,329d
290,291c
	if(pcnt < 10)
		pcnt = 70;
.
288d
247a
	 *  parse configuration args from dos file p9rc
	 */
	cp = BOOTARGS;	/* where b.com leaves it's config */
	cp[BOOTARGSLEN-1] = 0;
	n = getfields(cp, line, MAXCONF, '\n');
	for(j = 0; j < n; j++){
		cp = strchr(line[j], '\r');
		if(cp)
			*cp = 0;
		cp = strchr(line[j], '=');
		if(cp == 0)
			continue;
		*cp++ = 0;
		if(cp - line[j] >= NAMELEN+1)
			*(line[j]+NAMELEN-1) = 0;
		confname[nconf] = line[j];
		confval[nconf] = cp;
		if(strcmp(confname[nconf], "kernelpercent") == 0)
			pcnt = 100 - atoi(confval[nconf]);
		nconf++;
	}

	/*
.
246a
	pcnt = 0;

.
241c
	long x, i, j, n, *l;
.
## diffname pc/main.c 1993/0915
## diff -e /n/bootesdump/1993/0416/sys/src/9/pc/main.c /n/fornaxdump/1993/0915/sys/src/brazil/pc/main.c
542a
}

static int
parseether(uchar *to, char *from)
{
	char nip[4];
	char *p;
	int i;

	p = from;
	for(i = 0; i < 6; i++){
		if(*p == 0)
			return -1;
		nip[0] = *p++;
		if(*p == 0)
			return -1;
		nip[1] = *p++;
		nip[2] = 0;
		to[i] = strtoul(nip, 0, 16);
		if(*p == ':')
			p++;
	}
	return 0;
}

int
isaconfig(char *class, int ctlrno, ISAConf *isa)
{
	char cc[NAMELEN], *p, *q;
	int n;

	sprint(cc, "%s%d", class, ctlrno);
	for(n = 0; n < nconf; n++){
		if(strncmp(confname[n], cc, NAMELEN))
			continue;
		p = confval[n];
		while(*p){
			while(*p == ' ' || *p == '\t')
				p++;
			if(*p == '\0')
				break;
			if(strncmp(p, "type=", 5) == 0){
				p += 5;
				for(q = isa->type; q < &isa->type[NAMELEN-1]; q++){
					if(*p == '\0' || *p == ' ' || *p == '\t')
						break;
					*q = *p++;
				}
				*q = '\0';
			}
			else if(strncmp(p, "port=", 5) == 0)
				isa->port = strtoul(p+5, &p, 0);
			else if(strncmp(p, "irq=", 4) == 0)
				isa->irq = strtoul(p+4, &p, 0);
			else if(strncmp(p, "mem=", 4) == 0)
				isa->mem = strtoul(p+4, &p, 0);
			else if(strncmp(p, "size=", 5) == 0)
				isa->size = strtoul(p+5, &p, 0);
			else if(strncmp(p, "ea=", 3) == 0)
				parseether(isa->ea, p+3);
			while(*p && *p != ' ' && *p != '\t')
				p++;
		}
		return 1;
	}
	return 0;
.
476,477c
	if(ispanic){
		if(cpuflag)
			delay(10000);
		else
			for(;;);
	}
.
448c
			fpsave(&up->fpsave);
.
415c
print("sys: fp: math overrun pc 0x%lux pid %d\n", ur->pc, up->pid);
.
399,400c
		fprestore(&up->fpsave);
		up->fpstate = FPactive;
.
396c
		up->fpstate = FPactive;
.
393c
	switch(up->fpstate){
.
383c
			up->fpsave.pc, ur->pc);
.
378,379c
		sprint(note, "sys: fp: unknown fppc=0x%lux", up->fpsave.pc);
		postnote(up->p, 1, note, NDebug);
.
373,374c
			sprint(note, "sys: fp: %s fppc=0x%lux", msg, up->fpsave.pc);
			postnote(up->p, 1, note, NDebug);
.
366,367c
	fpenv(&up->fpsave);
	status = up->fpsave.status;
.
318,324c
	conf.nproc = 30 + ((conf.npage*BY2PG)/MB)*5;
.
309,311c
	/*
	 *  bank0 usually goes from the end of kernel bss to the end of memory
	 */
	ktop = PGROUND((ulong)end);
	ktop = PADDR(ktop);
	conf.base0 = ktop;
	for(i = 1; mmap[i] == 'x'; i++)
		;
	conf.npage0 = (i*MB - ktop)/BY2PG;
	conf.topofmem = i*MB;

	/*
	 *  bank1 usually goes from the end of BOOTARGS to 640k
	 */
	conf.base1 = (ulong)(BOOTARGS+BOOTARGSLEN);
	conf.base1 = PGROUND(conf.base1);
	conf.base1 = PADDR(conf.base1);
	conf.npage1 = (640*1024-conf.base1)/BY2PG;

	/*
	 *  if there is a hole in memory (due to a shadow BIOS) make the
	 *  memory after the hole be bank 1. The memory from 0 to 640k
	 *  is lost.
	 */
	for(; i <= MAXMEG; i++)
		if(mmap[i] == 'x'){
			conf.base1 = i*MB;
			for(j = i+1; mmap[j] == 'x'; j++)
				;
			conf.npage1 = (j - i)*MB/BY2PG;
			conf.topofmem = j*MB;
			break;
		}

.
302,306c
		if(*mapaddr(KZERO|(i*MB)) == x && *mapaddr(KZERO|((i+1)*MB-BY2WD)) == x){
			mmap[i] = 'x';
			/*
			 *  zero memory to set ECC but skip over the kernel
			 */
			if(i != 1)
				for(j = 0; j < MB/BY2PG; j += BY2PG)
					memset(mapaddr(KZERO|(i*MB+j)), 0, BY2PG);
		}
.
300c
		 *  check for correct value
.
298a

.
295,297c
			*mapaddr(KZERO|(j*MB)) = ~x;
			*mapaddr(KZERO|((j+1)*MB-BY2WD)) = ~x;
.
292c
		 *  write the first and last word in all previous megs to
		 *  handle address wrap around
.
288,290c
		*mapaddr(KZERO|(i*MB)) = x;
		*mapaddr(KZERO|((i+1)*MB-BY2WD)) = x;

.
286c
		 *  write the first & last word in a megabyte of memory
.
284c
	for(i = 1; i <= MAXMEG; i++){
.
277,282c
	memset(mmap, ' ', sizeof(mmap));
.
273,275c
	 *  size memory above 1 meg. Kernel sits at 1 meg.  We
	 *  only recognize MB size chunks.
.
271d
252c
	cp = BOOTARGS;	/* where b.com leaves its config */
.
241c
	long x, i, j, n;
.
238a
addconf(char *name, char *val)
{
	if(nconf >= MAXCONF)
		return;
	confname[nconf] = name;
	confval[nconf] = val;
	nconf++;
}

char*
getconf(char *name)
{
	int i;

	for(i = 0; i < nconf; i++)
		if(strcmp(confname[i], name) == 0)
			return confval[i];
	return 0;
}

void
.
222a
	if(buf[0]){
		cp = strchr(buf, '!');
		if(cp){
			strcpy(bootdisk, cp+1);
			addconf("bootdisk", bootdisk);
		}
	}
.
221a
	} else if(strncmp(cp, "s!", 2) == 0){
		sprint(buf, "local!#w/sd%dfs", atoi(cp+2));
		av[ac++] = pusharg(buf);
	} else if(strncmp(cp, "sd!", 3) == 0){
		sprint(buf, "local!#w/sd%ddisk", atoi(cp+3));
		av[ac++] = pusharg(buf);
.
220c
		sprint(buf, "local!#H/hd%ddisk", atoi(cp+3));
.
218a
	} else if(strncmp(cp, "h!", 2) == 0){
		sprint(buf, "local!#H/hd%dfs", atoi(cp+2));
		av[ac++] = pusharg(buf);
.
215a
	buf[0] = 0;
.
182c
	pg = newpage(1, 0, UTZERO);
	memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
	segpage(s, pg);
.
180a
	s->flushme++;
.
169c
	s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
.
159,166d
155,156c
	p->sched.sp = (ulong)p->kstack+KSTACK-(1+MAXSYSARG)*BY2WD;
.
122a
	kproc("alarm", alarmkproc, 0);
.
120a
		for(i = 0; i < nconf; i++)
			if(confname[i])
				ksetenv(confname[i], confval[i]);
.
115,116d
111c
	iallocinit();
.
108,109c
	up->slash = namec("#/", Atodir, 0, 0);
	up->dot = clone(up->slash, 0);
.
97,100c
	up->nerrlab = 0;
	m->proc = up->p;
	up->state = Running;
	up->mach = m;
.
55d
53a
	links();
.
42a
	dmainit();
.
32a
/* memory map */
#define MAXMEG 64
char mmap[MAXMEG+2];

.
28a
char bootdisk[NAMELEN];
.
## diffname pc/main.c 1993/1013
## diff -e /n/fornaxdump/1993/0915/sys/src/brazil/pc/main.c /n/fornaxdump/1993/1013/sys/src/brazil/pc/main.c
537c
	up = 0;
.
442c
		postnote(up, 1, note, NDebug);
.
437c
			postnote(up, 1, note, NDebug);
.
139d
104,106d
97a
ksetterm(char *f)
{
	char buf[2*NAMELEN];

	sprint(buf, f, conffile);
	ksetenv("terminal", buf);
}

void
.
## diffname pc/main.c 1993/1113
## diff -e /n/fornaxdump/1993/1013/sys/src/brazil/pc/main.c /n/fornaxdump/1993/1113/sys/src/brazil/pc/main.c
545c
		if(cpuserver)
.
295c
	 *  parse configuration args from dos file plan9.ini
.
95,96d
## diffname pc/main.c 1993/1124
## diff -e /n/fornaxdump/1993/1113/sys/src/brazil/pc/main.c /n/fornaxdump/1993/1124/sys/src/brazil/pc/main.c
488,491c
	setvec(Matherr1vec, matherror, 0);
	setvec(Matherr2vec, matherror, 0);
	setvec(Mathemuvec, mathemu, 0);
	setvec(Mathovervec, mathover, 0);
.
480c
	USED(ur, arg);
.
478c
mathover(Ureg *ur, void *arg)
.
458c
	USED(ur, arg);
.
456c
mathemu(Ureg *ur, void *arg)
.
422a
	USED(arg);

.
416c
matherror(Ureg *ur, void *arg)
.
## diffname pc/main.c 1994/0219
## diff -e /n/fornaxdump/1993/1124/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0219/sys/src/brazil/pc/main.c
218c
	av[ac++] = pusharg("/386/9dos");
.
## diffname pc/main.c 1994/0302
## diff -e /n/fornaxdump/1994/0219/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0302/sys/src/brazil/pc/main.c
394c
	switch(x86()){
	case 386:
		conf.copymode = 1;	/* copy on reference */
		break;
	default:
	case 486:
		conf.copymode = 0;	/* copy on write */
		break;
	}
.
60a
	printcpufreq();
.
## diffname pc/main.c 1994/0322
## diff -e /n/fornaxdump/1994/0302/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0322/sys/src/brazil/pc/main.c
389a
	conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG;
.
122d
## diffname pc/main.c 1994/0331
## diff -e /n/fornaxdump/1994/0322/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0331/sys/src/brazil/pc/main.c
93a

	/* Setup call back ring buffer */
	m->cbin = m->calls;
	m->cbout = m->calls;
	m->cbend = &m->calls[NCALLBACK];
.
## diffname pc/main.c 1994/0505
## diff -e /n/fornaxdump/1994/0331/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0505/sys/src/brazil/pc/main.c
349,351c
			if(i != 1){
				for(j = 0; j < MB/BY2PG; j += BY2PG){
					lp = mapaddr(KZERO|(i*MB+j));
					for(n = 0; n < BY2PG/BY2WD; n++)
						lp[n] = x + n;
				}
				for(j = 0; j < MB/BY2PG; j += BY2PG){
					lp = mapaddr(KZERO|(i*MB+j));
					for(n = 0; n < BY2PG/(2*BY2WD); n++){
						y = lp[n];
						lp[n] = ~lp[n^((BY2PG/BY2WD)-1)];
						lp[n^((BY2PG/BY2WD)-1)] = ~y;
					}
				}
				for(j = 0; j < MB/BY2PG; j += BY2PG){
					lp = mapaddr(KZERO|(i*MB+j));
					for(n = 0; n < BY2PG/BY2WD; n++)
						if(lp[n] != ~(x + (n^((BY2PG/BY2WD)-1))))
							mmap[i] = ' ';
					memset(lp, 0, BY2PG);
				}
			}
.
347a
			 *  do a quick memory test also
.
291a
	long *lp;
.
289c
	long x, y, i, j, n;
.
## diffname pc/main.c 1994/0508
## diff -e /n/fornaxdump/1994/0505/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0508/sys/src/brazil/pc/main.c
94,98d
## diffname pc/main.c 1994/0513
## diff -e /n/fornaxdump/1994/0508/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0513/sys/src/brazil/pc/main.c
312a
		if(strcmp(confname[nconf], "defmaxmsg") == 0){
			i = atoi(confval[nconf]);
			if(i < defmaxmsg && i >=128)
				defmaxmsg = i;
		}
.
289a
	extern int defmaxmsg;
.
## diffname pc/main.c 1994/0521
## diff -e /n/fornaxdump/1994/0513/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0521/sys/src/brazil/pc/main.c
70c
 *  like power management/resetting/mouse are outside the hardware
.
## diffname pc/main.c 1994/0525
## diff -e /n/fornaxdump/1994/0521/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0525/sys/src/brazil/pc/main.c
70c
 *  like power management/reseting/mouse are outside the hardware
.
## diffname pc/main.c 1994/0607
## diff -e /n/fornaxdump/1994/0525/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0607/sys/src/brazil/pc/main.c
318a
		/* HACK: where should this come from? */
		if(strcmp(confname[nconf], "filaddr") == 0)
			strcpy(filaddr, confval[nconf]);
.
29a
char filaddr[NAMELEN];
.
## diffname pc/main.c 1994/0609
## diff -e /n/fornaxdump/1994/0607/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0609/sys/src/brazil/pc/main.c
65a
print("CR0 %lux\n", getcr0());
.
## diffname pc/main.c 1994/0610
## diff -e /n/fornaxdump/1994/0609/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0610/sys/src/brazil/pc/main.c
66d
## diffname pc/main.c 1994/0812
## diff -e /n/fornaxdump/1994/0610/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0812/sys/src/brazil/pc/main.c
152a
	p->rgrp = newrgrp();
.
## diffname pc/main.c 1994/0813
## diff -e /n/fornaxdump/1994/0812/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0813/sys/src/brazil/pc/main.c
577,579d
571d
399c
	conf.npage1 = (640*1024 - conf.base1)/BY2PG;
.
396c
	conf.base1 = (ulong)(BOOTARGS + BOOTARGSLEN);
.
394c
	 *  bank1 usually goes from the end of BOOTARGS to 640k - crash space
.
390c
	conf.npage0 = (i*MB - ktop - CRASHSIZE)/BY2PG;
	crasharea = KZERO|(conf.base0 + conf.npage0*BY2PG);
.
378a
			 */
.
356d
65a
conf.npage0 += CRASHSIZE;
.
33a
ulong crasharea;
.
## diffname pc/main.c 1994/0814
## diff -e /n/fornaxdump/1994/0813/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0814/sys/src/brazil/pc/main.c
417a

	/* make crasharea a virtual address */
	crasharea |= KZERO;
	crashend |= KZERO;
.
415a
			if(crasharea < conf.base1 + BY2PG*conf.npage1)
				conf.npage1 -= PGROUND(CRASHSIZE)/BY2PG;
.
405c
	 *  if there is a hole in memory (e.g. due to a shadow BIOS) make the
.
397c
	 *  bank1 usually goes from the end of BOOTARGS to 640k
.
394a
	if(crasharea < conf.base0 + BY2PG*conf.npage0)
		conf.npage0 -= PGROUND(CRASHSIZE)/BY2PG;
.
392,393c
	conf.npage0 = (i*MB - ktop)/BY2PG;
.
383a

.
381a
		if(memclrtest(i, j, x) < 0)
			mmap[i] = ' ';
.
355,380c
		x += 0x3141526;
	}

	/*
	 *  zero and clear all except first 2 meg and crash area.
	 *  put crash area at high end of memory.
	 */
	x = 0x12345678;
	for(i = MAXMEG; i > 1; i--){
		if(mmap[i] != 'x')
			continue;
		j = MB;
		if(crasharea == 0){
			crasharea = i*MB - CRASHSIZE;
			crashend = crasharea + CRASHSIZE;
			j = MB - CRASHSIZE;
.
353c
		if(*mapaddr(KZERO|(i*MB)) == x && *mapaddr(KZERO|((i+1)*MB-BY2WD)) == x)
.
327a

.
323d
291d
288c
	long x, i, j, n;
.
284a
/*
 *  zero memory to set ECC.
 *  do a quick memory test also.
 *
 *  if any part of a meg is missing/broken, drop the whole meg.
 */
int
memclrtest(int meg, int len, long seed)
{
	int j, n;
	long y;
	long *lp;
	
	for(j = 0; j < len; j += BY2PG){
		lp = mapaddr(KZERO|(meg*MB+j));
		for(n = 0; n < BY2PG/BY2WD; n++)
			lp[n] = seed + n;
	}
	for(j = 0; j < len; j += BY2PG){
		lp = mapaddr(KZERO|(meg*MB+j));
		for(n = 0; n < BY2PG/(2*BY2WD); n++){
			y = lp[n];
			lp[n] = ~lp[n^((BY2PG/BY2WD)-1)];
			lp[n^((BY2PG/BY2WD)-1)] = ~y;
		}
	}
	for(j = 0; j < len; j += BY2PG){
		lp = mapaddr(KZERO|(meg*MB+j));
		for(n = 0; n < BY2PG/BY2WD; n++)
			if(lp[n] != ~(seed + (n^((BY2PG/BY2WD)-1))))
				return -1;
		memset(lp, 0, BY2PG);
	}
	return 0;
}

.
67d
34d
## diffname pc/main.c 1994/0815
## diff -e /n/fornaxdump/1994/0814/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0815/sys/src/brazil/pc/main.c
403c
			j = MB - PGROUND(CRASHSIZE);
.
401c
			crasharea = (i+1)*MB - PGROUND(CRASHSIZE);
.
386,387c
		if(*mapaddr(KZERO|(i*MB)) == x)
			if(*mapaddr(KZERO|((i+1)*MB-BY2WD)) == x)
				mmap[i] = 'x';
.
314c
		memset(lp, '!', BY2PG);
.
287c
 *  if any part of a meg is missing/broken, return -1.
.
## diffname pc/main.c 1994/0817
## diff -e /n/fornaxdump/1994/0815/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0817/sys/src/brazil/pc/main.c
448,451d
444,445d
421,422d
400,406c
		if(memclrtest(i, MB, x) < 0)
.
393,394c
	 *  zero and clear all except first 2 meg.
.
## diffname pc/main.c 1994/0823
## diff -e /n/fornaxdump/1994/0817/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0823/sys/src/brazil/pc/main.c
731a
			else if(strncmp(p, "freq=", 5) == 0)
				isa->freq = strtoul(p+5, &p, 0);
.
## diffname pc/main.c 1994/0923
## diff -e /n/fornaxdump/1994/0823/sys/src/brazil/pc/main.c /n/fornaxdump/1994/0923/sys/src/brazil/pc/main.c
445c
	conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
.
## diffname pc/main.c 1994/1007
## diff -e /n/fornaxdump/1994/0923/sys/src/brazil/pc/main.c /n/fornaxdump/1994/1007/sys/src/brazil/pc/main.c
52a
	ns16552install();
.
## diffname pc/main.c 1994/1031
## diff -e /n/fornaxdump/1994/1007/sys/src/brazil/pc/main.c /n/fornaxdump/1994/1031/sys/src/brazil/pc/main.c
455d
451c
	case 3:
.
## diffname pc/main.c 1994/1111
## diff -e /n/fornaxdump/1994/1031/sys/src/brazil/pc/main.c /n/fornaxdump/1994/1111/sys/src/brazil/pc/main.c
240c
	} else if(strncmp(cp, "e!", 2) == 0)
		av[ac++] = pusharg("-n");
.
## diffname pc/main.c 1994/1210
## diff -e /n/fornaxdump/1994/1111/sys/src/brazil/pc/main.c /n/fornaxdump/1994/1210/sys/src/brazil/pc/main.c
438a

	/*
 	 *  add address space holes holes under 16 meg to available
	 *  isa space.
	 */
	romscan();
	if(conf.topofmem < 16*MB)
		putisa(conf.topofmem, 16*MB - conf.topofmem);
.
362a

.
321a
romscan(void)
{
	uchar *p;

	p = (uchar*)(KZERO+0xC8000);
	while(p < (uchar*)(KZERO+0xE0000)){
		p[0] = 0x55;
		p[1] = 0xAA;
		p[2] = 4;
		if(p[0] != 0x55 || p[1] != 0xAA){
			putisa(PADDR(p), 2048);
			p += 2048;
			continue;
		}
		p += p[2]*512;
	}

	p = (uchar*)(KZERO+0xE0000);
	if(p[0] != 0x55 || p[1] != 0xAA)
		putisa(PADDR(p), 64*1024);
}

void
.
320a
/*
 *  look for unused address space in 0xC8000 to 1 meg
 */
.
316c
/*		memset(lp, '!', BY2PG);/**/
.
## diffname pc/main.c 1995/0117
## diff -e /n/fornaxdump/1994/1210/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0117/sys/src/brazil/pc/main.c
364c
	n = getfields(cp, line, MAXCONF, "\n");
.
## diffname pc/main.c 1995/02021
## diff -e /n/fornaxdump/1995/0117/sys/src/brazil/pc/main.c /n/fornaxdump/1995/02021/sys/src/brazil/pc/main.c
222d
## diffname pc/main.c 1995/0222
## diff -e /n/fornaxdump/1995/02021/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0222/sys/src/brazil/pc/main.c
777a

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

	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	screenputs(buf, n);

	return n;
}

int
cistrcmp(char *a, char *b)
{
	int ac, bc;

	for(;;){
		ac = *a++;
		bc = *b++;
	
		if(ac >= 'A' && ac <= 'Z')
			ac = 'a' + (ac - 'A');
		if(bc >= 'A' && bc <= 'Z')
			bc = 'a' + (bc - 'A');
		ac -= bc;
		if(ac)
			return ac;
		if(bc == 0)
			break;
	}
	return 0;
}
.
## diffname pc/main.c 1995/0329
## diff -e /n/fornaxdump/1995/0222/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0329/sys/src/brazil/pc/main.c
63a
	links();
.
62d
## diffname pc/main.c 1995/0426
## diff -e /n/fornaxdump/1995/0329/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0426/sys/src/brazil/pc/main.c
357a

.
## diffname pc/main.c 1995/0523
## diff -e /n/fornaxdump/1995/0426/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0523/sys/src/brazil/pc/main.c
429a
 */
.
427a
/*
.
36c
#define MAXMEG 128
.
## diffname pc/main.c 1995/0527
## diff -e /n/fornaxdump/1995/0523/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0527/sys/src/brazil/pc/main.c
488,495d
389d
## diffname pc/main.c 1995/0803
## diff -e /n/fornaxdump/1995/0527/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0803/sys/src/brazil/pc/main.c
756a
			else if(strncmp(p, "dma=", 4) == 0)
				isa->dma = strtoul(p+5, &p, 0);
.
## diffname pc/main.c 1995/0920
## diff -e /n/fornaxdump/1995/0803/sys/src/brazil/pc/main.c /n/fornaxdump/1995/0920/sys/src/brazil/pc/main.c
765,766c
			else if(strncmp(p, "ea=", 3) == 0){
				if(parseether(isa->ea, p+3) == -1)
					memset(isa->ea, 0, 6);
			}
			else if(isa->nopt < NISAOPT){
				r = isa->opt[isa->nopt];
				while(*p && *p != ' ' && *p != '\t'){
					*r++ = *p++;
					if(r-isa->opt[isa->nopt] >= ISAOPTLEN-1)
						break;
				}
				*r = '\0';
				isa->nopt++;
			}
.
737a
		isa->nopt = 0;
.
731c
	char cc[NAMELEN], *p, *q, *r;
.
## diffname pc/main.c 1995/1019
## diff -e /n/fornaxdump/1995/0920/sys/src/brazil/pc/main.c /n/fornaxdump/1995/1019/sys/src/brazil/pc/main.c
342,343c
	if(p[0] != 0x55 || p[1] != 0xAA){
		p[0] = 0xff;
		p[64*1024-1] = 0xff;
		if(p[0] == 0xff && p[64*1024-1] == 0xff)
			putisa(PADDR(p), 64*1024);
	}
.
338c
		p[0] = 0xff;
		p[2048-1] = 0xff;
		if(p[0] == 0xff && p[2048-1] == 0xff)
			putisa(PADDR(p), 2048);
		p += 2048;
.
333,335c
		if(p[0] == 0x55 && p[1] == 0xAA){
			p += p[2]*512;
.
## diffname pc/main.c 1995/1121
## diff -e /n/fornaxdump/1995/1019/sys/src/brazil/pc/main.c /n/fornaxdump/1995/1121/sys/src/brazil/pc/main.c
130a
		if(cpuserver)
			ksetenv("service", "cpu");
		else
			ksetenv("service", "terminal");
.
## diffname pc/main.c 1995/1219
## diff -e /n/fornaxdump/1995/1121/sys/src/brazil/pc/main.c /n/fornaxdump/1995/1219/sys/src/brazil/pc/main.c
352c
		if(p[0] != 0xCC && p[64*1024-1] != 0xCC)
.
350c
		p[0] = 0xCC;
.
341,343c
		p[0] = 0xCC;
		p[2048-1] = 0xCC;
		if(p[0] != 0xCC && p[2048-1] != 0xCC)
.
## diffname pc/main.c 1996/01171
## diff -e /n/fornaxdump/1995/1219/sys/src/brazil/pc/main.c /n/fornaxdump/1996/01171/sys/src/brazil/pc/main.c
648c
	} else
		delay(1000);
.
642a
	spllo();
.
55d
52a
	trapinit();
.
## diffname pc/main.c 1996/0202
## diff -e /n/fornaxdump/1996/01171/sys/src/brazil/pc/main.c /n/fornaxdump/1996/0202/sys/src/brazil/pc/main.c
641a
	active.machs = 0;
.
## diffname pc/main.c 1996/0203
## diff -e /n/fornaxdump/1996/0202/sys/src/brazil/pc/main.c /n/fornaxdump/1996/0203/sys/src/brazil/pc/main.c
377,379c
		if(*line[j] == '#')
			continue;
.
375c

	/*
	 * Strip out '\r', change '\t' -> ' '.
	 */
	p = cp;
	for(q = cp; *q; q++){
		if(*q == '\r')
			continue;
		if(*q == '\t')
			*q = ' ';
		*p++ = *q;
	}
	*p = 0;

	n = getcfields(cp, line, MAXCONF, '\n');
.
369d
363,364c
	char *cp, *line[MAXCONF], *p, *q;
.
356a
static int
getcfields(char *lp, char **fields, int n, char sep)
{
	int i;

	for(i=0; lp && *lp && i<n; i++){
		while(*lp == sep)
			*lp++=0;
		if(*lp == 0)
			break;
		fields[i]=lp;
		while(*lp && *lp != sep){
			if(*lp == '\\' && *(lp+1) == '\n')
				*lp++ = ' ';
			lp++;
		}
	}
	return i;
}

.
## diffname pc/main.c 1996/0214
## diff -e /n/fornaxdump/1996/0203/sys/src/brazil/pc/main.c /n/fornaxdump/1996/0214/sys/src/brazil/pc/main.c
839c
	va_start(arg, fmt);
	n = doprint(buf, buf+sizeof(buf), fmt, arg) - buf;
	va_end(arg);

.
837a
	va_list arg;
.
## diffname pc/main.c 1996/0425
## diff -e /n/fornaxdump/1996/0214/sys/src/brazil/pc/main.c /n/fornaxdump/1996/0425/sys/src/brazil/pc/main.c
804c
				isa->dma = strtoul(p+4, &p, 0);
.
## diffname pc/main.c 1996/0612
## diff -e /n/fornaxdump/1996/0425/sys/src/brazil/pc/main.c /n/fornaxdump/1996/0612/sys/src/brazil/pc/main.c
525a
	if(cpuserver)
		conf.nproc *= 2;
.
## diffname pc/main.c 1996/0619
## diff -e /n/fornaxdump/1996/0612/sys/src/brazil/pc/main.c /n/fornaxdump/1996/0619/sys/src/brazil/pc/main.c
527c
		conf.nproc += conf.nproc/2;
.
## diffname pc/main.c 1997/0109
## diff -e /n/fornaxdump/1996/0619/sys/src/brazil/pc/main.c /n/fornaxdump/1997/0109/sys/src/brazil/pc/main.c
527c
		conf.nproc *= 3;
.
## diffname pc/main.c 1997/0327
## diff -e /n/fornaxdump/1997/0109/sys/src/brazil/pc/main.c /n/emeliedump/1997/0327/sys/src/brazil/pc/main.c
869a
	return 0;
}

int
cistrncmp(char *a, char *b, int n)
{
	unsigned ac, bc;

	while(n > 0){
		ac = *a++;
		bc = *b++;
		n--;

		if(ac >= 'A' && ac <= 'Z')
			ac = 'a' + (ac - 'A');
		if(bc >= 'A' && bc <= 'Z')
			bc = 'a' + (bc - 'A');

		ac -= bc;
		if(ac)
			return ac;
		if(bc == 0)
			break;
	}

.
813,816d
811c
			else if(cistrncmp(p, "freq=", 5) == 0)
.
809c
			else if(cistrncmp(p, "size=", 5) == 0)
.
807c
			else if(cistrncmp(p, "mem=", 4) == 0)
.
805c
			else if(cistrncmp(p, "dma=", 4) == 0)
.
803c
			else if(cistrncmp(p, "irq=", 4) == 0)
.
801c
			else if(cistrncmp(p, "port=", 5) == 0)
.
792c
			if(cistrncmp(p, "type=", 5) == 0){
.
783c
		if(cistrncmp(confname[n], cc, NAMELEN))
.
695,775d
689,693d
686c
	arch->reset();
.
683c
	}
	else
.
678c
	for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
		delay(TK2MS(2));
		if(active.machs == 0 && consactive() == 0)
			break;
	}

	if(active.ispanic && m->machno == 0){
.
671,676c
	if(once)
		print("cpu%d: exiting\n", m->machno);
.
666,669c
	lock(&active);
	if(ispanic)
		active.ispanic = ispanic;
	else if(m->machno == 0 && (active.machs & (1<<m->machno)) == 0)
		active.ispanic = 0;
	once = active.machs & (1<<m->machno);
	active.machs &= ~(1<<m->machno);
	active.exiting = 1;
	unlock(&active);
.
663,664c
	int ms, once;
.
661c
exit(int ispanic)
.
657,659d
626,629c
	intrenable(VectorCERR, matherror, 0, BUSUNKNOWN);
	if(X86FAMILY(m->cpuidax) == 3)
		intrenable(VectorIRQ13, matherror, 0, BUSUNKNOWN);
	intrenable(VectorCNA, mathemu, 0, BUSUNKNOWN);
	intrenable(VectorCSO, mathover, 0, BUSUNKNOWN);
.
618,619d
616c
mathover(Ureg*, void*)
.
596d
594c
mathemu(Ureg*, void*)
.
559,560d
552c
matherror(Ureg *ur, void*)
.
530,533c
	conf.nimage = 200;
.
528c
	if(conf.nproc > 2000)
		conf.nproc = 2000;
.
519d
444,517d
431,442c
	meminit();
.
426,427d
421c
		if(cistrcmp(confname[nconf], "defmaxmsg") == 0){
.
419c
		if(cistrcmp(confname[nconf], "kernelpercent") == 0)
.
407c
	pcnt = 0;
	n = getcfields(cp, line, MAXCONF, "\n");
.
386,387d
382,383c
	char *cp;
	char *line[MAXCONF], *p, *q;
.
380c
	long i, j, n;
.
373a

.
367,368c
		fields[i] = lp;
		while(*lp && strchr(sep, *lp) == 0){
.
362,364c
	for(i = 0; lp && *lp && i < n; i++){
		while(*lp && strchr(sep, *lp) != 0)
			*lp++ = 0;
.
358c
getcfields(char* lp, char** fields, int n, char* sep)
.
288,356d
226c
	cp[BOOTLINELEN-1] = 0;
.
131,134d
122c
	up->dot = cclone(up->slash, 0);
.
94,95c
	m->machno = machno;
	m->pdb = pdb;
.
92c
	machno = m->machno;
	pdb = m->pdb;
.
90c
	int machno;
	void *pdb;
.
76,87d
70,74d
62c
	cpuidprint();
.
59a
	if(arch->clockenable)
		arch->clockenable();
.
57,58d
55a
	mmuinit();
	if(arch->intrinit)
		arch->intrinit();
	ns16552install();			/* botch: config */
.
52,54c
	if(isoldbcom)
		print("    ****OLD B.COM - UPGRADE****\n");
.
49c
	trapinit();
.
46a
	active.exiting = 0;
	cpuidentify();
	bcompatibility();
	memscan();
	archinit();
.
45d
42,43c
	outb(0x3F2, 0x00);		/* botch: turn off the floppy motor */

	/*
	 * There is a little leeway here in the ordering but care must be
	 * taken with dependencies:
	 *	function		depends on
	 *	========		==========
	 *	machinit		m->machno, m->pdb
	 *	cpuidentify		m
	 *	memscan			cpuidentify (needs to know processor
	 *				type for caching, etc.)
	 *	archinit		memscan (MP config table may be at the
	 *				top of system physical memory);
	 *				conf.nmach (not critical, mpinit will check);
	 *	confinit		meminit
	 *	arch->intrinit		trapinit
	 */
	conf.nmach = 1;
	MACHP(0) = (Mach*)CPU0MACH;
	m->pdb = (void*)CPU0PDB;
.
38a
static int isoldbcom;

static void
bcompatibility(void)
{
	uchar *bda;

	if(strncmp(BOOTARGS, "ZORT 0\r\n", 8) == 0)
		return;
	isoldbcom = 1;

	memmove(BOOTARGS, KADDR(1024), BOOTARGSLEN);
	memmove(BOOTLINE, KADDR(0x100), BOOTLINELEN);

	bda = KADDR(0x400);
	bda[0x13] = 639;
	bda[0x14] = 639>>8;
}

.
35,37c
extern void ns16552install(void);	/* botch: config */
.
30d
14,26c
/*
 * Where configuration info is left for the loaded programme.
 * This will turn into a structure as more is done by the boot loader
 * (e.g. why parse the .ini file twice?).
 * There are 1024 bytes available at CONFADDR.
 */
#define BOOTLINE	((char *)CONFADDR)
#define BOOTLINELEN	64
#define BOOTARGS	((char*)(CONFADDR+BOOTLINELEN))
#define	BOOTARGSLEN	(1024-BOOTLINELEN)
.
12c
static  uchar *sp;	/* stack pointer for /boot */
.
10a
Mach *m;
.
9d
## diffname pc/main.c 1997/0328
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/pc/main.c /n/emeliedump/1997/0328/sys/src/brazil/pc/main.c
83a
	dmainit();
.
## diffname pc/main.c 1997/0329
## diff -e /n/emeliedump/1997/0328/sys/src/brazil/pc/main.c /n/emeliedump/1997/0329/sys/src/brazil/pc/main.c
380c
	meminit(maxmem);
.
370,373c
		if(cistrcmp(confname[nconf], "*maxmem") == 0)
			maxmem = strtoul(confval[nconf], 0, 0);
		if(cistrcmp(confname[nconf], "*kernelpercent") == 0)
			pcnt = 100 - strtol(confval[nconf], 0, 0);
		if(cistrcmp(confname[nconf], "*defmaxmsg") == 0){
			i = strtol(confval[nconf], 0, 0);
.
356a
	maxmem = 0;
.
336a
	ulong maxmem;
.
261c
		sprint(buf, "local!#w/sd%ddisk", strtol(cp+3, 0, 0));
.
258c
		sprint(buf, "local!#w/sd%dfs", strtol(cp+2, 0, 0));
.
255c
		sprint(buf, "local!#H/hd%ddisk", strtol(cp+3, 0, 0));
.
252c
		sprint(buf, "local!#H/hd%dfs", strtol(cp+2, 0, 0));
.
249c
		sprint(buf, "local!#f/fd%ddisk", strtol(cp+3, 0, 0));
.
156c
			if(confname[i] && confname[i][0] != '*')
.
154a
		if(cpuserver)
			ksetenv("service", "cpu");
		else
			ksetenv("service", "terminal");
.
86d
82a
	archinit();
.
80,81d
77a
	screeninit();
.
69,70c
	 *	arch->intrinit		depends on: trapinit
.
60,67c
	 *	function		dependencies
	 *	========		============
	 *	machinit		depends on: m->machno, m->pdb
	 *	cpuidentify		depends on :m
	 *	confinit		calls: meminit
	 *	meminit			depends on: cpuidentify (needs to know processor
	 *				  type for caching, etc.)
	 *	archinit		depends on: meminit (MP config table may be at the
	 *				  top of system physical memory);
.
20c
#define BOOTLINE	((char*)CONFADDR)
.
## diffname pc/main.c 1997/0403
## diff -e /n/emeliedump/1997/0329/sys/src/brazil/pc/main.c /n/emeliedump/1997/0403/sys/src/brazil/pc/main.c
342,384c
	if(p = getconf("*maxmem"))
		maxmem = strtoul(p, 0, 0);
	else
		maxmem = 0;
	if(p = getconf("*kernelpercent"))
		pcnt = 100 - strtol(p, 0, 0);
	else
		pcnt = 0;
	if(p = getconf("*defmaxmsg")){
		i = strtol(p, 0, 0);
		if(i < defmaxmsg && i >=128)
			defmaxmsg = i;
.
340a
	extern int defmaxmsg;
.
335,339c
	char *p;
	int i, pcnt;
.
311,331d
306c
		if(cistrcmp(confname[i], name) == 0)
.
80d
77a
	options();
.
63c
	 *	cpuidentify		depends on: m
.
55c
	outb(0x3F2, 0x00);			/* botch: turn off the floppy motor */
.
47,49c
		bda = KADDR(0x400);
		bda[0x13] = 639;
		bda[0x14] = 639>>8;
	}

	/*
	 *  parse configuration args from dos file plan9.ini
	 */
	cp = BOOTARGS;	/* where b.com leaves its config */
	cp[BOOTARGSLEN-1] = 0;

	/*
	 * Strip out '\r', change '\t' -> ' '.
	 */
	p = cp;
	for(q = cp; *q; q++){
		if(*q == '\r')
			continue;
		if(*q == '\t')
			*q = ' ';
		*p++ = *q;
	}
	*p = 0;

	n = getcfields(cp, line, MAXCONF, "\n");
	for(i = 0; i < n; i++){
		if(*line[i] == '#')
			continue;
		cp = strchr(line[i], '=');
		if(cp == 0)
			continue;
		*cp++ = 0;
		if(cp - line[i] >= NAMELEN+1)
			*(line[i]+NAMELEN-1) = 0;
		confname[nconf] = line[i];
		confval[nconf] = cp;
		nconf++;
	}
.
44,45c
		memmove(BOOTARGS, KADDR(1024), BOOTARGSLEN);
		memmove(BOOTLINE, KADDR(0x100), BOOTLINELEN);
.
40,42c
	if(strncmp(BOOTARGS, "ZORT 0\r\n", 8)){
		isoldbcom = 1;
.
38a
	long i, n;
	char *cp, *line[MAXCONF], *p, *q;
.
36c
options(void)
.
34a
static int
getcfields(char* lp, char** fields, int n, char* sep)
{
	int i;

	for(i = 0; lp && *lp && i < n; i++){
		while(*lp && strchr(sep, *lp) != 0)
			*lp++ = 0;
		if(*lp == 0)
			break;
		fields[i] = lp;
		while(*lp && strchr(sep, *lp) == 0){
			if(*lp == '\\' && *(lp+1) == '\n')
				*lp++ = ' ';
			lp++;
		}
	}

	return i;
}

.
## diffname pc/main.c 1997/0404
## diff -e /n/emeliedump/1997/0403/sys/src/brazil/pc/main.c /n/emeliedump/1997/0404/sys/src/brazil/pc/main.c
141d
## diffname pc/main.c 1997/0522
## diff -e /n/emeliedump/1997/0404/sys/src/brazil/pc/main.c /n/emeliedump/1997/0522/sys/src/brazil/pc/main.c
156d
142a
	cpuidprint();
.
## diffname pc/main.c 1997/0603
## diff -e /n/emeliedump/1997/0522/sys/src/brazil/pc/main.c /n/emeliedump/1997/0603/sys/src/brazil/pc/main.c
236a
	p->fgrp->fd = smalloc(DELTAFD*sizeof(Chan*));
	p->fgrp->nfd = DELTAFD;
.
## diffname pc/main.c 1997/0606
## diff -e /n/emeliedump/1997/0603/sys/src/brazil/pc/main.c /n/emeliedump/1997/0606/sys/src/brazil/pc/main.c
235,238c
	p->fgrp = dupfgrp(nil);
.
## diffname pc/main.c 1997/1101
## diff -e /n/emeliedump/1997/0606/sys/src/brazil/pc/main.c /n/emeliedump/1997/1101/sys/src/brazil/pc/main.c
391,392c
	if(cpuserver) {
		if(pcnt < 10)
			pcnt = 70;
	} else {
		if(pcnt < 10) {
			if(conf.npage*BY2PG < 16*MB)
				pcnt = 40;
			else
				pcnt = 60;
		}
		if(conf.npage*BY2PG < 16*MB)
			poolsetparam("Image", 0, 0, 4*1024*1024);
	}
.
168c
	ulong *pdb;
.
157a
conf.monitor = 1;
.
131c
	m->pdb = (ulong*)CPU0PDB;
.
8a
#include	"pool.h"
.
## diffname pc/main.c 1997/1104
## diff -e /n/emeliedump/1997/1101/sys/src/brazil/pc/main.c /n/emeliedump/1997/1104/sys/src/brazil/pc/main.c
395a
		poolsetparam("Main", BY2PG*conf.npage*(100-pcnt)/100, 0, 0);
.
## diffname pc/main.c 1997/1108
## diff -e /n/emeliedump/1997/1104/sys/src/brazil/pc/main.c /n/emeliedump/1997/1108/sys/src/brazil/pc/main.c
406a
	poolsetparam("Main", BY2PG*conf.npage*(100-pcnt)/100, 0, 0);

.
405a
		/*
		 * give terminals lots of image memory, too; the dynamic allocation
		 * will balance the load properly, we hope.
		 */
		poolsetparam("Image", BY2PG*conf.npage*(100-pcnt)/100, 0, 0);
.
396d
## diffname pc/main.c 1998/0420
## diff -e /n/emeliedump/1997/1108/sys/src/brazil/pc/main.c /n/emeliedump/1998/0420/sys/src/brazil/pc/main.c
411c
	poolsetparam("Main", (BY2PG*conf.npage/100)*(100-pcnt), 0, 0);
.
409c
		poolsetparam("Image", (BY2PG*conf.npage/100)*(100-pcnt), 0, 0);
.
406,407c
		 * give terminals lots of image memory, too; the dynamic
		 * allocation will balance the load properly, we hope.
		 * be careful with 32-bit overflow.
.
402a
		/*
		 * Make sure terminals with low memory get at least
		 * 4MB on the first Image chunk allocation.
		 */
.
## diffname pc/main.c 1998/0605
## diff -e /n/emeliedump/1998/0420/sys/src/brazil/pc/main.c /n/emeliedump/1998/0605/sys/src/brazil/pc/main.c
544a

	/*
	 * Switch to the prototype page tables for this processor.
	 * While this processor is in the scheduler, the process could run
	 * on another processor and exit, returning the page tables to
	 * the free list where they could be reallocated and overwritten.
	 * When this processor eventually has to get an entry from the
	 * trashed page tables it will crash.
	 */
	mmuflushtlb(PADDR(m->pdb));
.
## diffname pc/main.c 1998/0825
## diff -e /n/emeliedump/1998/0605/sys/src/brazil/pc/main.c /n/emeliedump/1998/0825/sys/src/brazil/pc/main.c
321c
		sprint(buf, "local!#w/sd%lddisk", strtol(cp+3, 0, 0));
.
318c
		sprint(buf, "local!#w/sd%ldfs", strtol(cp+2, 0, 0));
.
315c
		sprint(buf, "local!#H/hd%lddisk", strtol(cp+3, 0, 0));
.
312c
		sprint(buf, "local!#H/hd%ldfs", strtol(cp+2, 0, 0));
.
309c
		sprint(buf, "local!#f/fd%lddisk", strtol(cp+3, 0, 0));
.
## diffname pc/main.c 1998/0910
## diff -e /n/emeliedump/1998/0825/sys/src/brazil/pc/main.c /n/emeliedump/1998/0910/sys/src/brazil/pc/main.c
517,519c
		intrenable(IrqIRQ13, matherror, 0, BUSUNKNOWN);
	trapenable(VectorCNA, mathemu, 0);
	trapenable(VectorCSO, mathover, 0);
.
515c
	trapenable(VectorCERR, matherror, 0);
.
506c
static void
.
485c
static void
.
445c
static void
.
430c
static char* mathmsg[] =
.
411c
		 * allocation will balance the load properly, hopefully.
.
## diffname pc/main.c 1998/0916
## diff -e /n/emeliedump/1998/0910/sys/src/brazil/pc/main.c /n/emeliedump/1998/0916/sys/src/brazil/pc/main.c
542a
		}
.
541c
		else{
			/*
			 * Fpsave() stores without handling pending
			 * unmasked exeptions. Postnote() can't be called
			 * here as sleep() already has up->rlock, so
			 * the handling of pending exceptions is delayed
			 * until the process runs again and generates an
			 * emulation fault to activate the FPU.
			 */
.
493a
		/*
		 * Before restoring the state, check for any pending
		 * exceptions, there's no way to restore the state without
		 * generating an unmasked exception.
		 * More attention should probably be paid here to the
		 * exception masks and error summary.
		 */
		if((up->fpsave.status & ~up->fpsave.control) & 0x07F){
			mathnote();
			break;
		}
.
478,479c
		panic("fp: status %lux fppc=0x%lux pc=0x%lux",
			up->fpsave.status, up->fpsave.pc, ur->pc);
.
465,476d
463c
	mathnote();
.
457c
	if(!(m->cpuiddx & 0x01))
		outb(0xF0, 0xFF);
.
448,452d
441a
static void
mathnote(void)
{
	int i;
	ulong status;
	char *msg, note[ERRLEN];

	status = up->fpsave.status;

	/*
	 * Some attention should probably be paid here to the
	 * exception masks and error summary.
	 */
	msg = "unknown";
	for(i = 0; i < 8; i++){
		if(!((1<<i) & status))
			continue;
		msg = mathmsg[i];
		break;
	}
	sprint(note, "sys: fp: %s fppc=0x%lux", msg, up->fpsave.pc);
	postnote(up, 1, note, NDebug);
}

.
426a
	conf.nswppo = 4096;
.
## diffname pc/main.c 1998/1120
## diff -e /n/emeliedump/1998/0916/sys/src/brazil/pc/main.c /n/emeliedump/1998/1120/sys/src/brazil/pc/main.c
428c

	/*
	 * Guess how much is taken by the large permanent
	 * datastructures. Mntcache and Mntrpc are not accounted for
	 * (probably ~300KB).
	 */
	kpages *= BY2PG;
	kpages -= conf.upages*sizeof(Page)
		+ conf.nproc*sizeof(Proc)
		+ conf.nimage*sizeof(Image)
		+ conf.nswap
		+ conf.nswppo*sizeof(Page);
	poolsetparam("Main", kpages, 0, 0);
	if(!cpuserver){
		/*
		 * give terminals lots of image memory, too; the dynamic
		 * allocation will balance the load properly, hopefully.
		 * be careful with 32-bit overflow.
		 */
		poolsetparam("Image", kpages, 0, 0);
	}
.
425a
	conf.nimage = 200;
.
418d
416c
	conf.upages = conf.npage - kpages;
.
409,414d
402a
		kpages = conf.npage - (conf.npage*userpcnt)/100;

.
401c
				userpcnt = 60;
.
399c
				userpcnt = 40;
.
397c
		if(userpcnt < 10) {
.
394,395c
		if(userpcnt < 10)
			userpcnt = 70;
		kpages = conf.npage - (conf.npage*userpcnt)/100;

		/*
		 * Hack for the big boys. Only good while physmem < 4GB.
		 * Give the kernel a max. of 16MB + enough to allocate the
		 * page pool.
		 * This is an overestimate as conf.upages < conf.npages.
		 */
		if(kpages > (16*MB + conf.npage*sizeof(Page))/BY2PG)
			kpages = (16*MB + conf.npage*sizeof(Page))/BY2PG;
.
383c
		userpcnt = 0;
.
381c
		userpcnt = 100 - strtol(p, 0, 0);
.
372,373c
	int i, userpcnt;
	ulong kpages, maxmem;
.
## diffname pc/main.c 1998/1124
## diff -e /n/emeliedump/1998/1120/sys/src/brazil/pc/main.c /n/emeliedump/1998/1124/sys/src/brazil/pc/main.c
423,433c
	conf.ialloc = (kpages/2)*BY2PG;
.
405a
			conf.nimage = 2000;
		}
.
404c
		if(kpages > (16*MB + conf.npage*sizeof(Page))/BY2PG){
.
402a
		 * The patch of nimage is a band-aid, scanning the whole
		 * page list in imagereclaim just takes too long.
.
392a

	conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
	if(cpuserver)
		conf.nproc *= 3;
	if(conf.nproc > 2000)
		conf.nproc = 2000;
	conf.nimage = 200;
	conf.nswap = conf.nproc*80;
	conf.nswppo = 4096;

.
## diffname pc/main.c 1999/0129
## diff -e /n/emeliedump/1998/1124/sys/src/brazil/pc/main.c /n/emeliedump/1999/0129/sys/src/brazil/pc/main.c
457c
		poolsetparam("Image", kpages, 0, 0, nil);
.
450c
	poolsetparam("Main", kpages, 0, 0, nil);
.
434c
			poolsetparam("Image", 0, 0, 4*1024*1024, nil);
.
## diffname pc/main.c 1999/0217
## diff -e /n/emeliedump/1999/0129/sys/src/brazil/pc/main.c /n/emeliedump/1999/0217/sys/src/brazil/pc/main.c
155a
print("arch %s\n", arch->id);
.
## diffname pc/main.c 1999/0218
## diff -e /n/emeliedump/1999/0217/sys/src/brazil/pc/main.c /n/emeliedump/1999/0218/sys/src/brazil/pc/main.c
156d
## diffname pc/main.c 1999/0422
## diff -e /n/emeliedump/1999/0218/sys/src/brazil/pc/main.c /n/emeliedump/1999/0422/sys/src/brazil/pc/main.c
160a
	pageinit();
.
147d
## diffname pc/main.c 1999/0629
## diff -e /n/emeliedump/1999/0422/sys/src/brazil/pc/main.c /n/emeliedump/1999/0629/sys/src/brazil/pc/main.c
202a
	cnameclose(up->slash->name);
	up->slash->name = newcname("/");
.
## diffname pc/main.c 1999/0709
## diff -e /n/emeliedump/1999/0629/sys/src/brazil/pc/main.c /n/emeliedump/1999/0709/sys/src/brazil/pc/main.c
420a
			kpages += (conf.nproc*KSTACK)/BY2PG;
.
## diffname pc/main.c 1999/0710
## diff -e /n/emeliedump/1999/0709/sys/src/brazil/pc/main.c /n/emeliedump/1999/0710/sys/src/brazil/pc/main.c
460c
		poolsetparam(imagmem, kpages, 0, 0, nil);
.
453c
	poolsetparam(mainmem, kpages, 0, 0, nil);
.
437c
			poolsetparam(imagmem, 0, 4*1024*1024, 0, nil);
.
## diffname pc/main.c 1999/0711
## diff -e /n/emeliedump/1999/0710/sys/src/brazil/pc/main.c /n/emeliedump/1999/0711/sys/src/brazil/pc/main.c
460c
		poolconfig(imagmem, kpages, 0, 0, nil);
.
453c
	poolconfig(mainmem, kpages, 0, 0, nil);
.
437c
			poolconfig(imagmem, 0, 4*1024*1024, 0, nil);
.
## diffname pc/main.c 1999/0712
## diff -e /n/emeliedump/1999/0711/sys/src/brazil/pc/main.c /n/emeliedump/1999/0712/sys/src/brazil/pc/main.c
460c
		poolsetparam(imagmem, kpages, 0, 0, nil);
.
453c
	poolsetparam(mainmem, kpages, 0, 0, nil);
.
437c
			poolsetparam(imagmem, 0, 4*1024*1024, 0, nil);
.
## diffname pc/main.c 1999/0713
## diff -e /n/emeliedump/1999/0712/sys/src/brazil/pc/main.c /n/emeliedump/1999/0713/sys/src/brazil/pc/main.c
460c
		poolconfig(imagmem, kpages, 0, 0, nil);
.
453c
	poolconfig(mainmem, kpages, 0, 0, nil);
.
437c
			poolconfig(imagmem, 0, 4*1024*1024, 0, nil);
.
133a
	ioinit();
.
## diffname pc/main.c 1999/0714
## diff -e /n/emeliedump/1999/0713/sys/src/brazil/pc/main.c /n/emeliedump/1999/0714/sys/src/brazil/pc/main.c
461c
		imagmem->maxsize = kpages;
.
454c
	mainmem->maxsize = kpages;
.
438c
			imagmem->minarena = 4*1024*1024;
.
## diffname pc/main.c 1999/0819
## diff -e /n/emeliedump/1999/0714/sys/src/brazil/pc/main.c /n/emeliedump/1999/0819/sys/src/brazil/pc/main.c
571,573c
		intrenable(IrqIRQ13, matherror, 0, BUSUNKNOWN, "matherror");
	trapenable(VectorCNA, mathemu, 0, "mathemu");
	trapenable(VectorCSO, mathover, 0, "mathover");
.
569c
	trapenable(VectorCERR, matherror, 0, "matherror");
.
## diffname pc/main.c 1999/0820
## diff -e /n/emeliedump/1999/0819/sys/src/brazil/pc/main.c /n/emeliedump/1999/0820/sys/src/brazil/pc/main.c
726a
*/
.
711a
/*
.
## diffname pc/main.c 1999/1109
## diff -e /n/emeliedump/1999/0820/sys/src/brazil/pc/main.c /n/emeliedump/1999/1109/sys/src/9/pc/main.c
387,391d
377d
375c
	int userpcnt;
.
## diffname pc/main.c 2000/0518
## diff -e /n/emeliedump/1999/1109/sys/src/9/pc/main.c /n/emeliedump/2000/0518/sys/src/9/pc/main.c
314,324c
	} else if(strncmp(cp, "sd", 2) == 0){
		sprint(buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3));
.
311,312c
	if(strncmp(cp, "fd", 2) == 0){
		sprint(buf, "local!#f/fd%lddisk", strtol(cp+2, 0, 0));
.
## diffname pc/main.c 2000/0531
## diff -e /n/emeliedump/2000/0518/sys/src/9/pc/main.c /n/emeliedump/2000/0531/sys/src/9/pc/main.c
317c
	} else if(strncmp(cp, "ether", 5) == 0)
.
## diffname pc/main.c 2000/0609
## diff -e /n/emeliedump/2000/0531/sys/src/9/pc/main.c /n/emeliedump/2000/0609/sys/src/9/pc/main.c
404,405c
		if(kpages > (32*MB + conf.npage*sizeof(Page))/BY2PG){
			kpages = (32*MB + conf.npage*sizeof(Page))/BY2PG;
.
398c
		 * Give the kernel fixed max + enough to allocate the
.
## diffname pc/main.c 2000/0721
## diff -e /n/emeliedump/2000/0609/sys/src/9/pc/main.c /n/emeliedump/2000/0721/sys/src/9/pc/main.c
24c
#define	BOOTARGSLEN	(4096-0x200-BOOTLINELEN)
.
19c
 * There are XXX bytes available at CONFADDR.
.
## diffname pc/main.c 2000/1012
## diff -e /n/emeliedump/2000/0721/sys/src/9/pc/main.c /n/emeliedump/2000/1012/sys/src/9/pc/main.c
256c
	p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD);
.
252c
	 * N.B. make sure there's enough space for syscall to check
	 *	for valid args and 
.
## diffname pc/main.c 2001/0123
## diff -e /n/emeliedump/2000/1012/sys/src/9/pc/main.c /n/emeliedump/2001/0123/sys/src/9/pc/main.c
761a

/*
 *  put the processor in the halt state if we've no processes to run.
 *  an interrupt will get us going again.
 */
void
idlehands(void)
{
	if(conf.nmach == 1)
		halt();
}
.
## diffname pc/main.c 2001/0527
## diff -e /n/emeliedump/2001/0123/sys/src/9/pc/main.c /n/emeliedump/2001/0527/sys/src/9/pc/main.c
697,714d
680,691d
652,667c
		isa->nopt = tokenize(confval[n], isa->opt, NISAOPT);
		for(i = 0; i < isa->nopt; i++){
			p = isa->opt[i];
			if(cistrncmp(p, "type=", 5) == 0)
				isa->type = p + 5;
.
650c
		if(cistrcmp(confname[n], cc) != 0)
.
648c
	snprint(cc, sizeof cc, "%s%d", class, ctlrno);
.
645,646c
	char cc[32], *p;
	int i, n;
.
468c
	char *msg, note[ERRMAX];
.
244,245c
	kstrdup(&eve, "");
	kstrdup(&p->text, "*init*");
	kstrdup(&p->user, eve);

.
206c
	up->dot = cclone(up->slash);
.
183c
	char buf[2*KNAMELEN];
.
177a

	/*
	 * For polled uart output at boot, need
	 * a default delay constant. 100000 should
	 * be enough for a while. Cpuidentify will
	 * calculate the real value later.
	 */
	m->loopconst = 100000;
.
151d
146,147d
139a
	screeninit();
.
138c
	ioinit();
	i8250console();
	print("\nPlan 9\n");
.
134d
113,129d
101,103c
		*cp++ = '\0';
.
99c
		if(cp == nil)
.
94c
	n = getfields(cp, line, MAXCONF, 1, "\n");
.
64,74d
60d
32,56d
27c
char bootdisk[KNAMELEN];
.
## diffname pc/main.c 2001/1011
## diff -e /n/emeliedump/2001/0527/sys/src/9/pc/main.c /n/emeliedump/2001/1011/sys/src/9/pc/main.c
358,359c
		if(kpages > (64*MB + conf.npage*sizeof(Page))/BY2PG){
			kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
.
## diffname pc/main.c 2002/0109
## diff -e /n/emeliedump/2001/1011/sys/src/9/pc/main.c /n/emeliedump/2002/0109/sys/src/9/pc/main.c
625c
	return 1;
.
602,623c
	p = getconf(cc);
	if(p == nil)
		return 0;

	isa->nopt = tokenize(p, isa->opt, NISAOPT);
	for(i = 0; i < isa->nopt; i++){
		p = isa->opt[i];
		if(cistrncmp(p, "type=", 5) == 0)
			isa->type = p + 5;
		else if(cistrncmp(p, "port=", 5) == 0)
			isa->port = strtoul(p+5, &p, 0);
		else if(cistrncmp(p, "irq=", 4) == 0)
			isa->irq = strtoul(p+4, &p, 0);
		else if(cistrncmp(p, "dma=", 4) == 0)
			isa->dma = strtoul(p+4, &p, 0);
		else if(cistrncmp(p, "mem=", 4) == 0)
			isa->mem = strtoul(p+4, &p, 0);
		else if(cistrncmp(p, "size=", 5) == 0)
			isa->size = strtoul(p+5, &p, 0);
		else if(cistrncmp(p, "freq=", 5) == 0)
			isa->freq = strtoul(p+5, &p, 0);
.
599c
	int i;
.
591a
void
reboot(void *entry, void *code, ulong size)
{
	void (*f)(ulong, ulong, ulong);
	ulong *pdb;

	writeconf();

	shutdown(0);

	/*
	 * should be the only processor running now
	 */

	print("shutting down...\n");
	delay(200);

	splhi();

	/* turn off buffered serial console */
	serialoq = nil;

	/* shutdown devices */
	chandevshutdown();

	/*
	 * Modify the machine page table to directly map the low 4MB of memory
	 * This allows the reboot code to turn off the page mapping
	 */
	pdb = m->pdb;
	pdb[PDX(0)] = pdb[PDX(KZERO)];
	mmuflushtlb(PADDR(pdb));

	/* setup reboot trampoline function */
	f = (void*)REBOOTADDR;
	memmove(f, rebootcode, sizeof(rebootcode));

	print("rebooting...\n");

	/* off we go - never to return */
	(*f)(PADDR(entry), PADDR(code), size);
}


void
exit(int ispanic)
{
	shutdown(ispanic);
.
590a
}
.
559,560c
static void
shutdown(int ispanic)
.
332,333d
323,326d
321c
	ulong kpages;
.
315a
static void
writeconf(void)
{
	char *p, *q;
	int n;

	p = getconfenv();

	if(waserror()) {
		free(p);
		nexterror();
	}

	/* convert to name=value\n format */
	for(q=p; *q; q++) {
		q += strlen(q);
		*q = '=';
		q += strlen(q);
		*q = '\n';
	}
	n = q - p + 1;
	if(n >= BOOTARGSLEN)
		error("kernel configuration too large");
	memset(BOOTLINE, 0, BOOTLINELEN);
	memmove(BOOTARGS, p, n);
	poperror();
	free(p);
}

.
293,304d
273,279d
262a

	/* when boot is changed to only use rc, this code can go away */
.
171,172c
			ksetenv(confname[i], confval[i], 1);
.
169c
			ksetenv("service", "terminal", 0);
.
167c
			ksetenv("service", "cpu", 0);
.
162,165c
		snprint(buf, sizeof(buf), "%s %s", arch->id, conffile);
		ksetenv("terminal", buf, 0);
		ksetenv("cputype", "386", 0);
.
144c
	char buf[2*KNAMELEN];
.
132,140d
110a
mach0init(void)
{
	conf.nmach = 1;
	MACHP(0) = (Mach*)CPU0MACH;
	m->pdb = (ulong*)CPU0PDB;

	machinit();

	active.machs = 1;
	active.exiting = 0;
}

void
.
85a
	meminit();
.
83a

.
82a

.
74,79c
	mach0init();
.
30a
uchar	*sp;	/* user stack of init proc */
.
27a
Conf	conf;
.
25c
#define	MAXCONF		64
.
19c
 * There are 3584 bytes available at CONFADDR.
.
13,14d
9a
#include	"reboot.h"
.
## diffname pc/main.c 2002/0114
## diff -e /n/emeliedump/2002/0109/sys/src/9/pc/main.c /n/emeliedump/2002/0114/sys/src/9/pc/main.c
498c
		panic("math emu");
.
467c
		panic("fp: status %ux fppc=0x%lux pc=0x%lux",
.
## diffname pc/main.c 2002/0217
## diff -e /n/emeliedump/2002/0114/sys/src/9/pc/main.c /n/emeliedump/2002/0217/sys/src/9/pc/main.c
78a
	quotefmtinstall();
.
## diffname pc/main.c 2002/0323
## diff -e /n/emeliedump/2002/0217/sys/src/9/pc/main.c /n/emeliedump/2002/0323/sys/src/9/pc/main.c
174a
		}
.
173c
		for(i = 0; i < nconf; i++){
			if(confname[i][0] != '*')
				ksetenv(confname[i], confval[i], 0);
.
## diffname pc/main.c 2002/0405
## diff -e /n/emeliedump/2002/0323/sys/src/9/pc/main.c /n/emeliedump/2002/0405/sys/src/9/pc/main.c
82a
	i8253init();
.
## diffname pc/main.c 2002/0410
## diff -e /n/emeliedump/2002/0405/sys/src/9/pc/main.c /n/emeliedump/2002/0410/sys/src/9/pc/main.c
95a
	timersinit();
.
32a

.
## diffname pc/main.c 2002/0411
## diff -e /n/emeliedump/2002/0410/sys/src/9/pc/main.c /n/emeliedump/2002/0411/sys/src/9/pc/main.c
99c
	kbdenable();
.
83a
	kbdinit();
.
## diffname pc/main.c 2002/0412
## diff -e /n/emeliedump/2002/0411/sys/src/9/pc/main.c /n/emeliedump/2002/0412/sys/src/9/pc/main.c
564d
137a
	m->gdt = gdt;
.
134a
	gdt = m->gdt;
.
131a
	Segdesc *gdt;
.
119a
	m->gdt = (Segdesc*)CPU0GDT;
.
## diffname pc/main.c 2002/0609
## diff -e /n/emeliedump/2002/0412/sys/src/9/pc/main.c /n/emeliedump/2002/0609/sys/src/9/pc/main.c
107a
	i8253link();
.
## diffname pc/main.c 2002/0703
## diff -e /n/emeliedump/2002/0609/sys/src/9/pc/main.c /n/emeliedump/2002/0703/sys/src/9/pc/main.c
31c
uchar *sp;	/* user stack of init proc */
.
27c
Conf conf;
.
## diffname pc/main.c 2002/0821
## diff -e /n/emeliedump/2002/0703/sys/src/9/pc/main.c /n/emeliedump/2002/0821/sys/src/9/pc/main.c
106a
{int x; uvlong start, end;
rdtsc(&start);
for(x = 0; x < 10000; x++) rdtsc(&end);
print("%lld\n", end-start);
}
.
## diffname pc/main.c 2002/0822
## diff -e /n/emeliedump/2002/0821/sys/src/9/pc/main.c /n/emeliedump/2002/0822/sys/src/9/pc/main.c
107,111d
## diffname pc/main.c 2002/0824
## diff -e /n/emeliedump/2002/0822/sys/src/9/pc/main.c /n/emeliedump/2002/0824/sys/src/9/pc/main.c
489a
	if(up->fpstate & FPillegal){
		/* someone did floating point in a note handler */
		postnote(up, 1, "sys: floating point in note handler", NDebug);
		return;
	}
.
## diffname pc/main.c 2002/0915
## diff -e /n/emeliedump/2002/0824/sys/src/9/pc/main.c /n/emeliedump/2002/0915/sys/src/9/pc/main.c
456c
	if(status & 0x01){
		if(status & 0x30){
			if(status & 0x200)
				msg = "stack overflow";
			else
				msg = "stack underflow";
		}else
			msg = "invalid operation";
	}
	sprint(note, "sys: fp: %s fppc=0x%lux status=0x%lux", msg, up->fpsave.pc, status);
.
449,450c
	msg = "unknown exception";
	for(i = 1; i <= 5; i++){
.
426,433c
	nil,	/* handled below */
	"denormalized operand",
	"division by zero",
	"numeric overflow",
	"numeric underflow",
	"precision loss",
.
## diffname pc/main.c 2002/1010
## diff -e /n/emeliedump/2002/0915/sys/src/9/pc/main.c /n/emeliedump/2002/1010/sys/src/9/pc/main.c
142a
	m->perf.period = 1;
.
## diffname pc/main.c 2003/0102
## diff -e /n/emeliedump/2002/1010/sys/src/9/pc/main.c /n/emeliedump/2003/0102/sys/src/9/pc/main.c
686a
	isa->type = "";
.
## diffname pc/main.c 2003/0326
## diff -e /n/emeliedump/2003/0102/sys/src/9/pc/main.c /n/emeliedump/2003/0326/sys/src/9/pc/main.c
586a
	 *
	 * If there's only one processor, this can't happen.
	 * You might think it would be a win not to do this in that case,
	 * especially on VMware, but it turns out not to matter.
.
33d

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].