plan 9 kernel history: overview | file list | diff list

1991/0823/pc/main.c (diff list | history)

1991/0625/sys/src/9/pc/main.c:1,151991/0629/sys/src/9/pc/main.c:1,56 (short | long)
1991/0625    
main(void) 
1991/0629    
#include <u.h> 
 
#define	WIDTH	80 
#define	HEIGHT	22 
#define SCREEN	((char *)0xB8000) 
int pos; 
 
void 
prchar(int x) 
1991/0625    
{ 
1991/0629    
	if(x == '\n'){ 
		pos = pos/WIDTH; 
		pos = (pos+1)*WIDTH; 
	} else { 
		SCREEN[pos++] = x; 
		SCREEN[pos++] = 0x43; 
	} 
	if(pos >= WIDTH*HEIGHT) 
		pos = 0; 
1991/0625    
} 
 
trap(void) 
1991/0629    
void 
prstr(char *s) 
1991/0625    
{ 
1991/0629    
	while(*s) 
		prchar(*s++); 
1991/0625    
} 
 
edata(void) 
1991/0629    
void 
prdig(ulong x) 
1991/0625    
{ 
1991/0629    
	if(x < 0xA) 
		prchar('0' + x); 
	else 
		prchar('A' + x); 
1991/0625    
} 
 
end(void) 
1991/0629    
void 
prhex(ulong x) 
1991/0625    
{ 
1991/0629    
	ulong y; 
 
	if(x <= 0xF){ 
		prdig(x); 
	} else { 
		y = x&0xF; 
		prhex(x>>4); 
		prdig(y); 
	} 
1991/0625    
} 
1991/0629    
 
main(void) 
{ 
	prstr("hello world\n"); 
} 
 
1991/0629/sys/src/9/pc/main.c:1,561991/0702/sys/src/9/pc/main.c:1,39 (short | long)
1991/0629    
#include <u.h> 
1991/0702    
#include	"u.h" 
#include	"lib.h" 
#include	"dat.h" 
#include	"fns.h" 
1991/0629    
 
#define	WIDTH	80 
#define	HEIGHT	22 
#define SCREEN	((char *)0xB8000) 
int pos; 
                 
void 
prchar(int x) 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0629    
	if(x == '\n'){ 
		pos = pos/WIDTH; 
		pos = (pos+1)*WIDTH; 
	} else { 
		SCREEN[pos++] = x; 
		SCREEN[pos++] = 0x43; 
1991/0702    
	for(;;){ 
		print("%x ", kbdc()); 
1991/0629    
	} 
	if(pos >= WIDTH*HEIGHT) 
		pos = 0; 
1991/0625    
} 
 
1991/0629    
void 
prstr(char *s) 
1991/0702    
delay(int l) 
1991/0625    
{ 
1991/0629    
	while(*s) 
		prchar(*s++); 
1991/0625    
} 
1991/0702    
	int i; 
1991/0625    
 
1991/0629    
void 
prdig(ulong x) 
1991/0625    
{ 
1991/0629    
	if(x < 0xA) 
		prchar('0' + x); 
	else 
		prchar('A' + x); 
1991/0702    
	while(--l){ 
		for(i=0; i < 10000; i++) 
			; 
	} 
1991/0625    
} 
 
1991/0629    
void 
prhex(ulong x) 
1991/0702    
int 
sprint(char *s, char *fmt, ...) 
1991/0625    
{ 
1991/0629    
	ulong y; 
                 
	if(x <= 0xF){ 
		prdig(x); 
	} else { 
		y = x&0xF; 
		prhex(x>>4); 
		prdig(y); 
	} 
1991/0702    
	return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s; 
1991/0625    
} 
1991/0629    
 
main(void) 
1991/0702    
int 
print(char *fmt, ...) 
1991/0629    
{ 
	prstr("hello world\n"); 
} 
1991/0702    
	char buf[PRINTSIZE]; 
	int n; 
1991/0629    
 
1991/0702    
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
	return n; 
} 
1991/0702/sys/src/9/pc/main.c:5,131991/0703/sys/src/9/pc/main.c:5,18 (short | long)
1991/0629    
 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0702    
	for(;;){ 
		print("%x ", kbdc()); 
1991/0629    
	} 
1991/0703    
	screeninit(); 
	print("screen inited\n"); 
	trapinit(); 
	print("traps inited\n"); 
	kbdinit(); 
	print("kbd inited\n"); 
	sti(); 
	for(;;); 
1991/0625    
} 
 
1991/0629    
void 
1991/0702/sys/src/9/pc/main.c:36,391991/0703/sys/src/9/pc/main.c:41,56
1991/0702    
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
	return n; 
1991/0703    
} 
 
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(;;); 
1991/0702    
} 
1991/0703/sys/src/9/pc/main.c:11,171991/0705/sys/src/9/pc/main.c:11,17 (short | long)
1991/0703    
	print("traps inited\n"); 
	kbdinit(); 
	print("kbd inited\n"); 
	sti(); 
1991/0705    
	spllo(); 
1991/0703    
	for(;;); 
1991/0625    
} 
 
1991/0703/sys/src/9/pc/main.c:53,561991/0705/sys/src/9/pc/main.c:53,61
1991/0703    
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
	for(;;); 
1991/0705    
} 
 
void 
sched(void) 
{ 
1991/0702    
} 
1991/0705/sys/src/9/pc/main.c:1,181991/0706/sys/src/9/pc/main.c:1,27 (short | long)
1991/0702    
#include	"u.h" 
#include	"lib.h" 
1991/0706    
#include	"mem.h" 
1991/0702    
#include	"dat.h" 
#include	"fns.h" 
1991/0706    
#include	"io.h" 
1991/0629    
 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0703    
	screeninit(); 
	print("screen inited\n"); 
	trapinit(); 
	print("traps inited\n"); 
	kbdinit(); 
	print("kbd inited\n"); 
1991/0706    
	clockinit(); 
	mmuinit(); 
	floppyinit(); 
1991/0705    
	spllo(); 
1991/0703    
	for(;;); 
1991/0706    
	for(;;){ 
		int c; 
 
		c = getc(&kbdq); 
		if(c!=-1) 
			screenputc(c); 
		idle(); 
	} 
1991/0625    
} 
 
1991/0629    
void 
1991/0705/sys/src/9/pc/main.c:21,271991/0706/sys/src/9/pc/main.c:30,36
1991/0702    
	int i; 
1991/0625    
 
1991/0702    
	while(--l){ 
		for(i=0; i < 10000; i++) 
1991/0706    
		for(i=0; i < 100; i++) 
1991/0702    
			; 
	} 
1991/0625    
} 
1991/0705/sys/src/9/pc/main.c:52,581991/0706/sys/src/9/pc/main.c:61,71
1991/0703    
	screenputs("panic: ", 7); 
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
	for(;;); 
1991/0706    
	screenputs("\n", 1); 
	INT0ENABLE; 
	spllo(); 
	for(;;) 
		idle(); 
1991/0705    
} 
 
void 
1991/0706/sys/src/9/pc/main.c:14,191991/0709/sys/src/9/pc/main.c:14,20 (short | long)
1991/0706    
	mmuinit(); 
	floppyinit(); 
1991/0705    
	spllo(); 
1991/0709    
	floppystart(0); 
1991/0706    
	for(;;){ 
		int c; 
 
1991/0706/sys/src/9/pc/main.c:21,261991/0709/sys/src/9/pc/main.c:22,32
1991/0706    
		if(c!=-1) 
			screenputc(c); 
		idle(); 
1991/0709    
		if((TK2SEC(m->ticks)%5)==0) 
			if((TK2SEC(m->ticks)%10)==0) 
				floppystop(0); 
			else 
				floppystart(0); 
1991/0706    
	} 
1991/0625    
} 
 
1991/0706/sys/src/9/pc/main.c:62,681991/0709/sys/src/9/pc/main.c:68,73
1991/0703    
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
1991/0706    
	screenputs("\n", 1); 
	INT0ENABLE; 
	spllo(); 
	for(;;) 
		idle(); 
1991/0709/sys/src/9/pc/main.c:5,211991/0711/sys/src/9/pc/main.c:5,36 (short | long)
1991/0702    
#include	"fns.h" 
1991/0706    
#include	"io.h" 
1991/0629    
 
1991/0711    
 
char sysname[NAMELEN]; 
Conf	conf; 
char	user[NAMELEN] = "bootes"; 
 
extern ulong edata; 
 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0711    
	int i; 
 
	machinit(); 
	confinit(); 
1991/0703    
	screeninit(); 
1991/0711    
	print("%d pages in bank0, %d pages in bank1\n", conf.npage0, conf.npage1); 
	print("edata == %lux, end == %lux\n", &edata, &end); 
1991/0703    
	trapinit(); 
1991/0711    
	mmuinit(); 
	clockinit(); 
	alarminit(); 
1991/0703    
	kbdinit(); 
1991/0706    
	clockinit(); 
	mmuinit(); 
	floppyinit(); 
1991/0705    
	spllo(); 
1991/0709    
	floppystart(0); 
1991/0706    
	for(;;){ 
1991/0711    
 
	for(i=0; i<100; i++){ 
1991/0706    
		int c; 
 
		c = getc(&kbdq); 
1991/0709/sys/src/9/pc/main.c:22,461991/0711/sys/src/9/pc/main.c:37,155
1991/0706    
		if(c!=-1) 
			screenputc(c); 
		idle(); 
1991/0709    
		if((TK2SEC(m->ticks)%5)==0) 
			if((TK2SEC(m->ticks)%10)==0) 
				floppystop(0); 
			else 
				floppystart(0); 
1991/0711    
		floppyseek(0, 0); 
		floppyseek(0, 18*512*20); 
1991/0706    
	} 
1991/0711    
	for(;;); 
1991/0625    
} 
 
1991/0629    
void 
1991/0711    
machinit(void) 
{ 
	int n; 
 
	n = m->machno; 
	memset(m, 0, sizeof(Mach)); 
	m->machno = n; 
	m->mmask = 1<<m->machno; 
	active.machs = 1; 
} 
 
void 
1991/0702    
delay(int l) 
1991/0625    
{ 
1991/0702    
	int i; 
1991/0625    
 
1991/0702    
	while(--l){ 
1991/0706    
		for(i=0; i < 100; i++) 
1991/0711    
		for(i=0; i < 404; i++) 
1991/0702    
			; 
	} 
1991/0625    
} 
 
1991/0711    
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; 
} 
 
1991/0702    
int 
sprint(char *s, char *fmt, ...) 
1991/0625    
{ 
1991/0709/sys/src/9/pc/main.c:73,791991/0711/sys/src/9/pc/main.c:182,231
1991/0706    
		idle(); 
1991/0705    
} 
 
1991/0711    
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); 
} 
 
1991/0705    
void 
sched(void) 
1991/0711    
{ } 
 
void 
ready(Proc*p) 
{ } 
 
int 
postnote(Proc*p, int x, char* y, int z) 
1991/0705    
{ 
1991/0711    
	panic("postnote"); 
1991/0702    
} 
1991/0711/sys/src/9/pc/main.c:6,201991/0712/sys/src/9/pc/main.c:6,55 (short | long)
1991/0706    
#include	"io.h" 
1991/0629    
 
1991/0711    
 
char sysname[NAMELEN]; 
1991/0712    
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]; 
1991/0711    
Conf	conf; 
char	user[NAMELEN] = "bootes"; 
 
extern ulong edata; 
 
1991/0712    
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; 
 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0711    
	int i; 
1991/0712    
	char	*path;			/* file path */ 
	char	element[2*NAMELEN];	/* next element in a file path */ 
	char	def[2*NAMELEN]; 
1991/0711    
 
	machinit(); 
	confinit(); 
1991/0711/sys/src/9/pc/main.c:30,481991/0712/sys/src/9/pc/main.c:65,212
1991/0706    
	floppyinit(); 
1991/0705    
	spllo(); 
1991/0711    
 
	for(i=0; i<100; i++){ 
1991/0706    
		int c; 
1991/0712    
	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"); 
	} 
} 
1991/0706    
 
		c = getc(&kbdq); 
		if(c!=-1) 
			screenputc(c); 
		idle(); 
1991/0711    
		floppyseek(0, 0); 
		floppyseek(0, 18*512*20); 
1991/0712    
/* 
 *  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; 
		} 
1991/0706    
	} 
1991/0711    
	for(;;); 
1991/0712    
 
	return -1; 
1991/0625    
} 
 
1991/0712    
/* 
 *  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) 
{ 
} 
 
1991/0629    
void 
1991/0711    
machinit(void) 
{ 
1991/0711/sys/src/9/pc/main.c:216,2211991/0712/sys/src/9/pc/main.c:380,388
1991/0711    
	return (void*)(p|KZERO); 
} 
 
1991/0712    
/* 
 *  some dummy's so we can use kernel code 
 */ 
1991/0705    
void 
sched(void) 
1991/0711    
{ } 
1991/0711/sys/src/9/pc/main.c:228,2311991/0712/sys/src/9/pc/main.c:395,437
1991/0711    
postnote(Proc*p, int x, char* y, int z) 
1991/0705    
{ 
1991/0711    
	panic("postnote"); 
1991/0712    
} 
 
 
/* 
 *  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); 
1991/0702    
} 
1991/0712/sys/src/9/pc/main.c:4,2351991/0716/sys/src/9/pc/main.c:4,145 (short | long)
1991/0702    
#include	"dat.h" 
#include	"fns.h" 
1991/0706    
#include	"io.h" 
1991/0716    
#include	"ureg.h" 
#include	"init.h" 
1991/0629    
 
1991/0716    
char	user[NAMELEN] = "bootes"; 
extern long edata; 
1991/0711    
 
1991/0712    
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]; 
1991/0711    
Conf	conf; 
                 
                 
1991/0712    
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; 
                 
1991/0716    
void 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0712    
	char	*path;			/* file path */ 
	char	element[2*NAMELEN];	/* next element in a file path */ 
	char	def[2*NAMELEN]; 
1991/0711    
                 
	machinit(); 
	confinit(); 
1991/0703    
	screeninit(); 
1991/0716    
	printinit(); 
1991/0711    
	print("%d pages in bank0, %d pages in bank1\n", conf.npage0, conf.npage1); 
	print("edata == %lux, end == %lux\n", &edata, &end); 
1991/0703    
	trapinit(); 
1991/0711    
	mmuinit(); 
	clockinit(); 
1991/0716    
	procinit0(); 
	initseg(); 
	grpinit(); 
	chaninit(); 
1991/0711    
	alarminit(); 
1991/0703    
	kbdinit(); 
1991/0706    
	clockinit(); 
	floppyinit(); 
1991/0705    
	spllo(); 
1991/0716    
	chandevreset(); 
	streaminit(); 
	trapinit(); 
	swapinit(); 
	pageinit(); 
	userinit(); 
1991/0711    
 
1991/0712    
	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"); 
	} 
1991/0716    
	schedinit(); 
1991/0712    
} 
1991/0706    
 
1991/0712    
/* 
 *  parse the server line.  return 0 if OK, -1 if bullshit 
1991/0716    
 *	BUG -- needs floating point support 
1991/0712    
 */ 
int 
parse(char *line) 
1991/0716    
void 
machinit(void) 
1991/0712    
{ 
	char *def[3]; 
	char **d; 
	char *s; 
	int i; 
1991/0716    
	int n; 
1991/0712    
 
	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; 
		} 
1991/0706    
	} 
1991/0712    
                 
	return -1; 
1991/0716    
	n = m->machno; 
	memset(m, 0, sizeof(Mach)); 
	m->machno = n; 
	m->mmask = 1<<m->machno; 
	m->fpstate = FPinit; 
	active.machs = 1; 
1991/0625    
} 
 
1991/0712    
/* 
 *  read a line from the keyboard. 
 */ 
int 
getline(int quiet) 
1991/0716    
void 
init0(void) 
1991/0712    
{ 
	int c, i=0; 
	long start; 
1991/0716    
	Chan *c; 
1991/0712    
 
	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; 
} 
1991/0716    
	u->nerrlab = 0; 
	m->proc = u->p; 
	u->p->state = Running; 
	u->p->mach = m; 
1991/0712    
 
/* 
 *  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; 
1991/0716    
	spllo(); 
1991/0712    
 
	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; 
} 
1991/0716    
	/* 
	 * 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); 
1991/0712    
 
int 
menu(void) 
{ 
1991/0716    
	chandevinit(); 
 
/*	kickpager();	/* BUG */ 
	touser(); 
1991/0712    
} 
 
1991/0629    
void 
1991/0711    
machinit(void) 
1991/0716    
userinit(void) 
1991/0711    
{ 
	int n; 
1991/0716    
	Proc *p; 
	Segment *s; 
	User *up; 
	KMap *k; 
1991/0711    
 
	n = m->machno; 
	memset(m, 0, sizeof(Mach)); 
	m->machno = n; 
	m->mmask = 1<<m->machno; 
	active.machs = 1; 
1991/0716    
	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); 
1991/0711    
} 
 
void 
1991/0702    
delay(int l) 
1991/0716    
exit(void) 
1991/0625    
{ 
1991/0702    
	int i; 
1991/0625    
 
1991/0702    
	while(--l){ 
1991/0711    
		for(i=0; i < 404; i++) 
1991/0702    
			; 
	} 
1991/0716    
	u = 0; 
	splhi(); 
	print("exiting\n"); 
	for(;;) 
		; 
1991/0625    
} 
 
1991/0716    
Conf	conf; 
 
1991/0711    
void 
confinit(void) 
{ 
1991/0712/sys/src/9/pc/main.c:314,4371991/0716/sys/src/9/pc/main.c:224,271
1991/0711    
	conf.cntrlp = 0; 
} 
 
1991/0702    
int 
sprint(char *s, char *fmt, ...) 
1991/0625    
{ 
1991/0702    
	return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s; 
1991/0625    
} 
1991/0629    
                 
1991/0702    
int 
print(char *fmt, ...) 
1991/0629    
{ 
1991/0702    
	char buf[PRINTSIZE]; 
	int n; 
1991/0629    
                 
1991/0702    
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
	return n; 
1991/0703    
} 
                 
1991/0716    
/* 
 *  set up floating point for a new process 
 *	BUG -- needs floating point support 
 */ 
1991/0703    
void 
panic(char *fmt, ...) 
1991/0716    
procsetup(Proc *p) 
1991/0703    
{ 
	char buf[PRINTSIZE]; 
	int n; 
                 
	screenputs("panic: ", 7); 
	n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; 
	screenputs(buf, n); 
1991/0706    
	screenputs("\n", 1); 
	spllo(); 
	for(;;) 
		idle(); 
1991/0716    
	p->fpstate = FPinit; 
	m->fpstate = FPinit; 
1991/0705    
} 
 
1991/0711    
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); 
} 
                 
1991/0712    
/* 
 *  some dummy's so we can use kernel code 
1991/0716    
 * Save the part of the process state. 
 *	BUG -- needs floating point support 
1991/0712    
 */ 
1991/0705    
void 
sched(void) 
1991/0711    
{ } 
                 
void 
ready(Proc*p) 
{ } 
                 
int 
postnote(Proc*p, int x, char* y, int z) 
1991/0716    
procsave(uchar *state, int len) 
1991/0705    
{ 
1991/0711    
	panic("postnote"); 
1991/0712    
} 
 
                 
/* 
 *  boot from hard disk 
1991/0716    
 *  Restore what procsave() saves 
 *	BUG -- needs floating point support 
1991/0712    
 */ 
int 
hdboot(void) 
1991/0716    
void 
procrestore(Proc *p, uchar *state) 
1991/0712    
{ 
	print("hdboot unimplemented\n"); 
	return -1; 
} 
 
/* 
 *  boot from the duart 
 */ 
int 
duartboot(void) 
1991/0716    
void 
firmware(void) 
1991/0712    
{ 
	print("duartboot unimplemented\n"); 
	return -1; 
1991/0716    
	panic("firmware"); 
1991/0712    
} 
 
#include "dosfs.h" 
 
/* 
 *  boot from the floppy 
 */ 
int 
fdboot(void) 
1991/0716    
void 
buzz(int f, int d) 
1991/0712    
{ 
	Dosbpb b; 
	extern int dosboot(Dosbpb*); 
1991/0716    
} 
1991/0712    
 
	print("booting from floppy 0\n"); 
	b.seek = floppyseek; 
	b.read = floppyread; 
	b.dev = 0; 
	return dosboot(&b); 
1991/0716    
void 
lights(int val) 
{ 
1991/0702    
} 
1991/0716/sys/src/9/pc/main.c:20,261991/0717/sys/src/9/pc/main.c:20,28 (short | long)
1991/0711    
	print("%d pages in bank0, %d pages in bank1\n", conf.npage0, conf.npage1); 
	print("edata == %lux, end == %lux\n", &edata, &end); 
	mmuinit(); 
1991/0717    
print("mmu inited\n"); 
1991/0716    
	procinit0(); 
1991/0717    
print("proc inited\n"); 
1991/0716    
	initseg(); 
	grpinit(); 
	chaninit(); 
1991/0716/sys/src/9/pc/main.c:31,361991/0717/sys/src/9/pc/main.c:33,39
1991/0716    
	swapinit(); 
	pageinit(); 
	userinit(); 
1991/0717    
print("user inited\n"); 
1991/0711    
 
1991/0716    
	schedinit(); 
1991/0712    
} 
1991/0716/sys/src/9/pc/main.c:94,1021991/0717/sys/src/9/pc/main.c:97,108
1991/0716    
 
	/* 
	 * Kernel Stack 
1991/0717    
	 * 
	 * N.B. The -4 for the stack pointer is important.  Gotolabel 
	 *	uses the bottom 4 bytes of stack to store it's return pc. 
1991/0716    
	 */ 
	p->sched.pc = (ulong)init0; 
	p->sched.sp = USERADDR + BY2PG - 24; 
1991/0717    
	p->sched.sp = USERADDR + BY2PG - 4; 
1991/0716    
	p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); 
 
	/* 
1991/0716/sys/src/9/pc/main.c:126,1431991/0717/sys/src/9/pc/main.c:132,137
1991/0716    
	ready(p); 
1991/0711    
} 
 
void 
1991/0716    
exit(void) 
1991/0625    
{ 
1991/0702    
	int i; 
1991/0625    
                 
1991/0716    
	u = 0; 
	splhi(); 
	print("exiting\n"); 
	for(;;) 
		; 
1991/0625    
} 
                 
1991/0716    
Conf	conf; 
 
1991/0711    
void 
1991/0716/sys/src/9/pc/main.c:185,1911991/0717/sys/src/9/pc/main.c:179,185
1991/0711    
	conf.base1 = 1024/4; 
 
	conf.npage = conf.npage0 + conf.npage1; 
	conf.maxialloc = (640*1024-256*1024-BY2PG); 
1991/0717    
	conf.maxialloc = (conf.npage0*BY2PG-PGROUND((ulong)&end)); 
1991/0711    
 
	mul = 1; 
	conf.nproc = 20 + 50*mul; 
1991/0716/sys/src/9/pc/main.c:269,2711991/0717/sys/src/9/pc/main.c:263,272
1991/0716    
lights(int val) 
{ 
1991/0702    
} 
1991/0717    
 
int 
mouseputc(IOQ *q, int c) 
{ 
	return c; 
} 
 
1991/0717/sys/src/9/pc/main.c:17,281991/0718/sys/src/9/pc/main.c:17,27 (short | long)
1991/0711    
	confinit(); 
1991/0703    
	screeninit(); 
1991/0716    
	printinit(); 
1991/0711    
	print("%d pages in bank0, %d pages in bank1\n", conf.npage0, conf.npage1); 
	print("edata == %lux, end == %lux\n", &edata, &end); 
	mmuinit(); 
1991/0717    
print("mmu inited\n"); 
1991/0718    
	trapinit(); 
	clockinit(); 
	faultinit(); 
1991/0716    
	procinit0(); 
1991/0717    
print("proc inited\n"); 
1991/0716    
	initseg(); 
	grpinit(); 
	chaninit(); 
1991/0717/sys/src/9/pc/main.c:29,351991/0718/sys/src/9/pc/main.c:28,33
1991/0711    
	alarminit(); 
1991/0716    
	chandevreset(); 
	streaminit(); 
	trapinit(); 
	swapinit(); 
	pageinit(); 
	userinit(); 
1991/0717/sys/src/9/pc/main.c:54,591991/0718/sys/src/9/pc/main.c:52,59
1991/0716    
	active.machs = 1; 
1991/0625    
} 
 
1991/0718    
long useless; 
 
1991/0716    
void 
init0(void) 
1991/0712    
{ 
1991/0717/sys/src/9/pc/main.c:65,701991/0718/sys/src/9/pc/main.c:65,71
1991/0716    
	u->p->mach = m; 
1991/0712    
 
1991/0716    
	spllo(); 
1991/0718    
print("interrupts on\n"); 
1991/0712    
 
1991/0716    
	/* 
	 * These are o.k. because rootinit is null. 
1991/0717/sys/src/9/pc/main.c:74,811991/0718/sys/src/9/pc/main.c:75,87
1991/0716    
	u->dot = clone(u->slash, 0); 
1991/0712    
 
1991/0716    
	chandevinit(); 
1991/0718    
print("going to user\n"); 
1991/0716    
 
/*	kickpager();	/* BUG */ 
1991/0718    
	/* 
	 *  fault in the first executable page 
	 */ 
	useless = *((ulong *)UTZERO); 
 
1991/0716    
	touser(); 
1991/0712    
} 
 
1991/0718/sys/src/9/pc/main.c:13,181991/0719/sys/src/9/pc/main.c:13,19 (short | long)
1991/0716    
void 
1991/0702    
main(void) 
1991/0625    
{ 
1991/0719    
	a20enable(); 
1991/0711    
	machinit(); 
	confinit(); 
1991/0703    
	screeninit(); 
1991/0718/sys/src/9/pc/main.c:19,241991/0719/sys/src/9/pc/main.c:20,26
1991/0716    
	printinit(); 
1991/0711    
	mmuinit(); 
1991/0718    
	trapinit(); 
1991/0719    
	kbdinit(); 
1991/0718    
	clockinit(); 
	faultinit(); 
1991/0716    
	procinit0(); 
1991/0718/sys/src/9/pc/main.c:31,371991/0719/sys/src/9/pc/main.c:33,38
1991/0716    
	swapinit(); 
	pageinit(); 
	userinit(); 
1991/0717    
print("user inited\n"); 
1991/0711    
 
1991/0716    
	schedinit(); 
1991/0712    
} 
1991/0718/sys/src/9/pc/main.c:52,581991/0719/sys/src/9/pc/main.c:53,59
1991/0716    
	active.machs = 1; 
1991/0625    
} 
 
1991/0718    
long useless; 
1991/0719    
ulong garbage; 
1991/0718    
 
1991/0716    
void 
init0(void) 
1991/0718/sys/src/9/pc/main.c:64,721991/0719/sys/src/9/pc/main.c:65,70
1991/0716    
	u->p->state = Running; 
	u->p->mach = m; 
1991/0712    
 
1991/0716    
	spllo(); 
1991/0718    
print("interrupts on\n"); 
1991/0712    
                 
1991/0716    
	/* 
	 * These are o.k. because rootinit is null. 
	 * Then early kproc's will have a root and dot. 
1991/0718/sys/src/9/pc/main.c:75,871991/0719/sys/src/9/pc/main.c:73,91
1991/0716    
	u->dot = clone(u->slash, 0); 
1991/0712    
 
1991/0716    
	chandevinit(); 
1991/0718    
print("going to user\n"); 
1991/0716    
 
1991/0718    
	/* 
	 *  fault in the first executable page 
1991/0719    
	 *  fault in the first executable page and user stack 
1991/0718    
	 */ 
	useless = *((ulong *)UTZERO); 
1991/0719    
	print("text is %lux\n", *((ulong *)(UTZERO+32))); 
1991/0718    
 
1991/0719    
	/*  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); 
 
1991/0716    
	touser(); 
1991/0712    
} 
 
1991/0718/sys/src/9/pc/main.c:104,1141991/0719/sys/src/9/pc/main.c:108,119
1991/0716    
	/* 
	 * Kernel Stack 
1991/0717    
	 * 
	 * N.B. The -4 for the stack pointer is important.  Gotolabel 
	 *	uses the bottom 4 bytes of stack to store it's return pc. 
1991/0719    
	 * 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 
1991/0716    
	 */ 
	p->sched.pc = (ulong)init0; 
1991/0717    
	p->sched.sp = USERADDR + BY2PG - 4; 
1991/0719    
	p->sched.sp = USERADDR + BY2PG - 12; 
1991/0716    
	p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); 
 
	/* 
1991/0718/sys/src/9/pc/main.c:182,1941991/0719/sys/src/9/pc/main.c:187,199
1991/0711    
	 *  the last 128k belongs to the roms 
	 */ 
	conf.npage1 = (i)*1024/4; 
	conf.base1 = 1024/4; 
1991/0719    
	conf.base1 = 1024*1024; 
1991/0711    
 
	conf.npage = conf.npage0 + conf.npage1; 
1991/0717    
	conf.maxialloc = (conf.npage0*BY2PG-PGROUND((ulong)&end)); 
1991/0711    
 
	mul = 1; 
	conf.nproc = 20 + 50*mul; 
1991/0719    
	conf.nproc = 20 + 20*mul; 
1991/0711    
	conf.npgrp = conf.nproc/2; 
	conf.nseg = conf.nproc*3; 
	conf.npagetab = (conf.nseg*14)/10; 
1991/0718/sys/src/9/pc/main.c:275,2781991/0719/sys/src/9/pc/main.c:280,282
1991/0717    
{ 
	return c; 
} 
                 
1991/0719/sys/src/9/pc/main.c:65,701991/0720/sys/src/9/pc/main.c:65,73 (short | long)
1991/0716    
	u->p->state = Running; 
	u->p->mach = m; 
1991/0712    
 
1991/0720    
print("go low\n"); 
	spllo(); 
 
1991/0716    
	/* 
	 * These are o.k. because rootinit is null. 
	 * Then early kproc's will have a root and dot. 
1991/0719/sys/src/9/pc/main.c:74,911991/0720/sys/src/9/pc/main.c:77,85
1991/0712    
 
1991/0716    
	chandevinit(); 
 
1991/0718    
	/* 
1991/0719    
	 *  fault in the first executable page and user stack 
1991/0718    
	 */ 
1991/0719    
	print("text is %lux\n", *((ulong *)(UTZERO+32))); 
1991/0720    
print("going to user\n"); 
delay(1000); 
1991/0718    
 
1991/0719    
	/*  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); 
                 
1991/0716    
	touser(); 
1991/0712    
} 
 
1991/0719/sys/src/9/pc/main.c:110,1191991/0720/sys/src/9/pc/main.c:104,112
1991/0717    
	 * 
1991/0719    
	 * 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 
1991/0716    
	 */ 
	p->sched.pc = (ulong)init0; 
1991/0719    
	p->sched.sp = USERADDR + BY2PG - 12; 
1991/0720    
	p->sched.sp = USERADDR + BY2PG - 4; 
1991/0716    
	p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); 
 
	/* 
1991/0720/sys/src/9/pc/main.c:19,241991/0723/sys/src/9/pc/main.c:19,25 (short | long)
1991/0703    
	screeninit(); 
1991/0716    
	printinit(); 
1991/0711    
	mmuinit(); 
1991/0723    
	vgainit(); 
1991/0718    
	trapinit(); 
1991/0719    
	kbdinit(); 
1991/0718    
	clockinit(); 
1991/0720/sys/src/9/pc/main.c:272,2751991/0723/sys/src/9/pc/main.c:273,311
1991/0717    
mouseputc(IOQ *q, int c) 
{ 
	return c; 
1991/0723    
} 
 
/* 
 *  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); 
1991/0717    
} 
1991/0723/sys/src/9/pc/main.c:19,251991/0727/sys/src/9/pc/main.c:19,24 (short | long)
1991/0703    
	screeninit(); 
1991/0716    
	printinit(); 
1991/0711    
	mmuinit(); 
1991/0723    
	vgainit(); 
1991/0718    
	trapinit(); 
1991/0719    
	kbdinit(); 
1991/0718    
	clockinit(); 
1991/0727/sys/src/9/pc/main.c:268,2791991/0730/sys/src/9/pc/main.c:268,273 (short | long)
1991/0716    
{ 
1991/0702    
} 
1991/0717    
 
int 
mouseputc(IOQ *q, int c) 
{ 
	return c; 
1991/0723    
} 
                 
/* 
 *  headland hip set for the safari. 
 *   
1991/0730/sys/src/9/pc/main.c:28,341991/0801/sys/src/9/pc/main.c:28,36 (short | long)
1991/0716    
	grpinit(); 
	chaninit(); 
1991/0711    
	alarminit(); 
1991/0801    
print("chandevreset\n"); delay(1000); 
1991/0716    
	chandevreset(); 
1991/0801    
print("streaminit\n"); delay(1000); 
1991/0716    
	streaminit(); 
	swapinit(); 
	pageinit(); 
1991/0730/sys/src/9/pc/main.c:65,711991/0801/sys/src/9/pc/main.c:67,72
1991/0716    
	u->p->state = Running; 
	u->p->mach = m; 
1991/0712    
 
1991/0720    
print("go low\n"); 
	spllo(); 
 
1991/0716    
	/* 
1991/0730/sys/src/9/pc/main.c:77,851991/0801/sys/src/9/pc/main.c:78,83
1991/0712    
 
1991/0716    
	chandevinit(); 
 
1991/0720    
print("going to user\n"); 
delay(1000); 
1991/0718    
                 
1991/0716    
	touser(); 
1991/0712    
} 
 
1991/0730/sys/src/9/pc/main.c:183,1891991/0801/sys/src/9/pc/main.c:181,187
1991/0719    
	conf.base1 = 1024*1024; 
1991/0711    
 
	conf.npage = conf.npage0 + conf.npage1; 
1991/0717    
	conf.maxialloc = (conf.npage0*BY2PG-PGROUND((ulong)&end)); 
1991/0801    
	conf.maxialloc = 2*1024*1024; 
1991/0711    
 
	mul = 1; 
1991/0719    
	conf.nproc = 20 + 20*mul; 
1991/0801/sys/src/9/pc/main.c:265,3021991/0802/sys/src/9/pc/main.c:265,267 (short | long)
1991/0716    
lights(int val) 
{ 
1991/0702    
} 
1991/0717    
                 
1991/0723    
/* 
 *  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); 
1991/0717    
} 
1991/0802/sys/src/9/pc/main.c:265,2671991/0803/sys/src/9/pc/main.c:265,384 (short | long)
1991/0716    
lights(int val) 
{ 
1991/0702    
} 
1991/0803    
 
 
/* 
 *  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); 
} 
1991/0803/sys/src/9/pc/main.c:285,2911991/0806/sys/src/9/pc/main.c:285,296 (short | long)
1991/0803    
	Pmudata=	0x198, 
 
	Pmucsr=		0x199, 
	 Busy=	0x1, 
1991/0806    
	 Busy=		0x1, 
 
	/* 
	 *  configuration port 
	 */ 
	Pconfig=	0x3F3, 
1991/0803    
}; 
 
/* 
1991/0803/sys/src/9/pc/main.c:368,3731991/0806/sys/src/9/pc/main.c:373,386
1991/0803    
int 
serial(int onoff) 
{ 
1991/0806    
	int x; 
 
	/* 
	 *  set config (enable everything) 
	 */ 
	x = splhi(); 
	config(0x00); 
	splx(x); 
1991/0803    
	return pmuwrbit(1, onoff, 6); 
} 
 
1991/0806/sys/src/9/pc/main.c:373,3861991/0808/sys/src/9/pc/main.c:373,378 (short | long)
1991/0803    
int 
serial(int onoff) 
{ 
1991/0806    
	int x; 
                 
	/* 
	 *  set config (enable everything) 
	 */ 
	x = splhi(); 
	config(0x00); 
	splx(x); 
1991/0803    
	return pmuwrbit(1, onoff, 6); 
} 
 
1991/0808/sys/src/9/pc/main.c:28,361991/0809/sys/src/9/pc/main.c:28,34 (short | long)
1991/0716    
	grpinit(); 
	chaninit(); 
1991/0711    
	alarminit(); 
1991/0801    
print("chandevreset\n"); delay(1000); 
1991/0716    
	chandevreset(); 
1991/0801    
print("streaminit\n"); delay(1000); 
1991/0716    
	streaminit(); 
	swapinit(); 
	pageinit(); 
1991/0808/sys/src/9/pc/main.c:218,2231991/0809/sys/src/9/pc/main.c:216,223
1991/0711    
	conf.arp = 32; 
	conf.frag = 32; 
	conf.cntrlp = 0; 
1991/0809    
	conf.nfloppy = 1; 
	conf.nhard = 1; 
1991/0711    
} 
 
1991/0716    
/* 
1991/0808/sys/src/9/pc/main.c:346,3681991/0809/sys/src/9/pc/main.c:346,379
1991/0803    
/* 
 *  set a bit in the PMU 
 */ 
1991/0809    
Lock pmulock; 
1991/0803    
int 
pmuwrbit(int index, int bit, int pos) 
{ 
1991/0809    
	lock(&pmulock); 
1991/0803    
	outb(Pmucsr, 0x02);		/* next is command request */ 
	if(pmuready() < 0) 
1991/0809    
	if(pmuready() < 0){ 
		unlock(&pmulock); 
1991/0803    
		return -1; 
1991/0809    
	} 
1991/0803    
	outb(Pmudata, (2<<4) | index);	/* send write bit command */ 
	outb(Pmucsr, 0x01);		/* send available */ 
	if(pmubusy() < 0) 
1991/0809    
	if(pmubusy() < 0){ 
		unlock(&pmulock); 
1991/0803    
		return -1; 
1991/0809    
	} 
1991/0803    
	outb(Pmucsr, 0x01);		/* next is data */ 
	if(pmuready() < 0) 
1991/0809    
	if(pmuready() < 0){ 
		unlock(&pmulock); 
1991/0803    
		return -1; 
1991/0809    
	} 
1991/0803    
	outb(Pmudata, (bit<<3) | pos);	/* send bit to write */ 
	outb(Pmucsr, 0x01);		/* send available */ 
	if(pmubusy() < 0) 
1991/0809    
	if(pmubusy() < 0){ 
		unlock(&pmulock); 
1991/0803    
		return -1; 
1991/0809    
	} 
	unlock(&pmulock); 
1991/0803    
} 
 
/* 
1991/0809/sys/src/9/pc/main.c:374,3791991/0810/sys/src/9/pc/main.c:374,380 (short | long)
1991/0803    
		return -1; 
1991/0809    
	} 
	unlock(&pmulock); 
1991/0810    
	return 0; 
1991/0803    
} 
 
/* 
1991/0810/sys/src/9/pc/main.c:175,1811991/0821/sys/src/9/pc/main.c:175,181 (short | long)
1991/0711    
	/* 
	 *  the last 128k belongs to the roms 
	 */ 
	conf.npage1 = (i)*1024/4; 
1991/0821    
	conf.npage1 = (i-1)*1024/4; 
1991/0719    
	conf.base1 = 1024*1024; 
1991/0711    
 
	conf.npage = conf.npage0 + conf.npage1; 
1991/0821/sys/src/9/pc/main.c:18,231991/0823/sys/src/9/pc/main.c:18,24 (short | long)
1991/0711    
	confinit(); 
1991/0703    
	screeninit(); 
1991/0716    
	printinit(); 
1991/0823    
	print("%lud K bytes of physical memory\n", 1024 + conf.npage1*BY2PG/1024); 
1991/0711    
	mmuinit(); 
1991/0718    
	trapinit(); 
1991/0719    
	kbdinit(); 
1991/0821/sys/src/9/pc/main.c:141,1481991/0823/sys/src/9/pc/main.c:142,157
1991/0711    
	int mul; 
 
	/* 
	 *  size memory 
1991/0823    
	 *  the first 640k is the standard useful memory 
	 *  the next 128K is the display 
	 *  the last 256k belongs to the roms 
1991/0711    
	 */ 
1991/0823    
	conf.npage0 = 640/4; 
	conf.base0 = 0; 
 
	/* 
	 *  size the non-standard memory 
	 */ 
1991/0711    
	x = 0x12345678; 
	for(i=1; i<16; i++){ 
		/* 
1991/0821/sys/src/9/pc/main.c:165,1811991/0823/sys/src/9/pc/main.c:174,180
1991/0711    
			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 
	 */ 
1991/0821    
	conf.npage1 = (i-1)*1024/4; 
1991/0823    
	conf.npage1 = (i-2)*1024/4; 
1991/0719    
	conf.base1 = 1024*1024; 
1991/0711    
 
	conf.npage = conf.npage0 + conf.npage1; 
Too many diffs (26 > 25). Stopping.


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)