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

1994/1111/pc/main.c (diff list | history)

pc/main.c on 1991/0702
1991/0702    
#include	"u.h" 
1992/0321    
#include	"../port/lib.h" 
1991/0706    
#include	"mem.h" 
1991/0702    
#include	"dat.h" 
#include	"fns.h" 
1991/0706    
#include	"io.h" 
1991/0716    
#include	"ureg.h" 
#include	"init.h" 
1992/0918    
#include	<ctype.h> 
1991/0629    
 
1992/0904    
 
1992/0903    
uchar *sp;	/* stack pointer for /boot */ 
 
1992/0923    
extern PCArch nsx20, generic, ncr3170; 
 
PCArch *arch; 
PCArch *knownarch[] = 
{ 
	&nsx20, 
	&ncr3170, 
	&generic, 
}; 
 
1993/0330    
/* where b.com leaves configuration info */ 
#define BOOTARGS	((char*)(KZERO|1024)) 
#define	BOOTARGSLEN	1024 
#define	MAXCONF		32 
 
1993/0915    
char bootdisk[NAMELEN]; 
1994/0607    
char filaddr[NAMELEN]; 
1993/0330    
char *confname[MAXCONF]; 
char *confval[MAXCONF]; 
int nconf; 
 
1993/0915    
/* memory map */ 
#define MAXMEG 64 
char mmap[MAXMEG+2]; 
 
1991/0716    
void 
1991/0702    
main(void) 
1991/0625    
{ 
1991/1210    
	ident(); 
1992/0902    
	i8042a20();		/* enable address lines 20 and up */ 
1991/0711    
	machinit(); 
1991/1113    
	active.exiting = 0; 
	active.machs = 1; 
1991/0711    
	confinit(); 
1992/0625    
	xinit(); 
1993/0915    
	dmainit(); 
1991/0703    
	screeninit(); 
1991/0716    
	printinit(); 
1991/0711    
	mmuinit(); 
1994/1007    
	ns16552install(); 
1992/0625    
	pageinit(); 
1991/0718    
	trapinit(); 
1991/0906    
	mathinit(); 
1991/0718    
	clockinit(); 
	faultinit(); 
1992/0409    
	kbdinit(); 
1991/0716    
	procinit0(); 
	initseg(); 
1993/0915    
	links(); 
1994/0302    
	printcpufreq(); 
1991/0716    
	chandevreset(); 
	swapinit(); 
	userinit(); 
	schedinit(); 
1991/0712    
} 
1991/0706    
 
1992/0902    
/* 
1992/0903    
 *  This tries to capture architecture dependencies since things 
1994/0525    
 *  like power management/reseting/mouse are outside the hardware 
1992/0903    
 *  model. 
1992/0902    
 */ 
1991/0716    
void 
1991/1210    
ident(void) 
{ 
	char *id = (char*)(ROMBIOS + 0xFF40); 
1992/0923    
	PCArch **p; 
1991/1210    
 
1992/0923    
	for(p = knownarch; *p != &generic; p++) 
		if(strncmp((*p)->id, id, strlen((*p)->id)) == 0) 
1992/0918    
			break; 
1992/0923    
	arch = *p; 
1991/1210    
} 
 
void 
1991/0716    
machinit(void) 
1991/0712    
{ 
1991/0716    
	int n; 
1991/0712    
 
1991/0716    
	n = m->machno; 
	memset(m, 0, sizeof(Mach)); 
	m->machno = n; 
	m->mmask = 1<<m->machno; 
1991/0625    
} 
 
1991/0716    
void 
1993/1013    
ksetterm(char *f) 
{ 
	char buf[2*NAMELEN]; 
 
	sprint(buf, f, conffile); 
	ksetenv("terminal", buf); 
} 
 
void 
1991/0716    
init0(void) 
1991/0712    
{ 
1993/0330    
	int i; 
1992/0918    
	char tstr[32]; 
 
1993/0915    
	up->nerrlab = 0; 
1991/0712    
 
1991/0720    
	spllo(); 
 
1991/0716    
	/* 
	 * These are o.k. because rootinit is null. 
	 * Then early kproc's will have a root and dot. 
	 */ 
1993/0915    
	up->slash = namec("#/", Atodir, 0, 0); 
	up->dot = clone(up->slash, 0); 
1991/0712    
 
1991/0716    
	chandevinit(); 
 
1991/0926    
	if(!waserror()){ 
1992/0923    
		strcpy(tstr, arch->id); 
1992/0918    
		strcat(tstr, " %s"); 
		ksetterm(tstr); 
1991/0927    
		ksetenv("cputype", "386"); 
1993/0915    
		for(i = 0; i < nconf; i++) 
			if(confname[i]) 
				ksetenv(confname[i], confval[i]); 
1991/0926    
		poperror(); 
	} 
1993/0915    
	kproc("alarm", alarmkproc, 0); 
1992/0323    
	touser(sp); 
1991/0712    
} 
 
1991/0629    
void 
1991/0716    
userinit(void) 
1991/0711    
{ 
1991/0716    
	Proc *p; 
	Segment *s; 
	KMap *k; 
1992/0323    
	Page *pg; 
1991/0905    
 
1991/0716    
	p = newproc(); 
	p->pgrp = newpgrp(); 
1992/0625    
	p->egrp = smalloc(sizeof(Egrp)); 
	p->egrp->ref = 1; 
	p->fgrp = smalloc(sizeof(Fgrp)); 
	p->fgrp->ref = 1; 
1994/0812    
	p->rgrp = newrgrp(); 
1991/1112    
	p->procmode = 0640; 
1991/0716    
 
	strcpy(p->text, "*init*"); 
1991/1109    
	strcpy(p->user, eve); 
1991/0716    
	p->fpstate = FPinit; 
1991/0906    
	fpoff(); 
1991/0716    
 
	/* 
	 * Kernel Stack 
1991/0717    
	 * 
1991/0719    
	 * N.B. The -12 for the stack pointer is important. 
	 *	4 bytes for gotolabel's return PC 
1991/0716    
	 */ 
	p->sched.pc = (ulong)init0; 
1993/0915    
	p->sched.sp = (ulong)p->kstack+KSTACK-(1+MAXSYSARG)*BY2WD; 
1991/0716    
 
	/* 
	 * User Stack 
	 */ 
1993/0915    
	s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); 
1991/0716    
	p->seg[SSEG] = s; 
1992/0323    
	pg = newpage(1, 0, USTKTOP-BY2PG); 
	segpage(s, pg); 
	k = kmap(pg); 
	bootargs(VA(k)); 
	kunmap(k); 
1991/0716    
 
	/* 
	 * Text 
	 */ 
	s = newseg(SG_TEXT, UTZERO, 1); 
1993/0915    
	s->flushme++; 
1991/0716    
	p->seg[TSEG] = s; 
1993/0915    
	pg = newpage(1, 0, UTZERO); 
	memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); 
	segpage(s, pg); 
1991/0716    
	k = kmap(s->map[0]->pages[0]); 
	memmove((ulong*)VA(k), initcode, sizeof initcode); 
	kunmap(k); 
 
	ready(p); 
1992/0323    
} 
 
uchar * 
pusharg(char *p) 
{ 
	int n; 
 
	n = strlen(p)+1; 
	sp -= n; 
	memmove(sp, p, n); 
	return sp; 
} 
 
void 
bootargs(ulong base) 
{ 
 	int i, ac; 
	uchar *av[32]; 
	uchar **lsp; 
1992/0903    
	char *cp = BOOTLINE; 
	char buf[64]; 
1992/0323    
 
	sp = (uchar*)base + BY2PG - MAXSYSARG*BY2WD; 
 
	ac = 0; 
1994/0219    
	av[ac++] = pusharg("/386/9dos"); 
1992/0323    
	av[ac++] = pusharg("-p"); 
1992/0903    
	cp[64] = 0; 
1993/0915    
	buf[0] = 0; 
1992/0903    
	if(strncmp(cp, "fd!", 3) == 0){ 
		sprint(buf, "local!#f/fd%ddisk", atoi(cp+3)); 
		av[ac++] = pusharg(buf); 
1993/0915    
	} else if(strncmp(cp, "h!", 2) == 0){ 
		sprint(buf, "local!#H/hd%dfs", atoi(cp+2)); 
		av[ac++] = pusharg(buf); 
1992/0903    
	} else if(strncmp(cp, "hd!", 3) == 0){ 
1993/0915    
		sprint(buf, "local!#H/hd%ddisk", atoi(cp+3)); 
1992/0903    
		av[ac++] = pusharg(buf); 
1993/0915    
	} 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); 
1994/1111    
	} else if(strncmp(cp, "e!", 2) == 0) 
		av[ac++] = pusharg("-n"); 
1993/0915    
	if(buf[0]){ 
		cp = strchr(buf, '!'); 
		if(cp){ 
			strcpy(bootdisk, cp+1); 
			addconf("bootdisk", bootdisk); 
		} 
	} 
1992/0323    
 
	/* 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); 
1991/0711    
} 
 
1991/0716    
Conf	conf; 
 
1991/0711    
void 
1993/0915    
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; 
} 
 
1994/0814    
/* 
 *  zero memory to set ECC. 
 *  do a quick memory test also. 
 * 
1994/0815    
 *  if any part of a meg is missing/broken, return -1. 
1994/0814    
 */ 
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; 
1994/0815    
		memset(lp, '!', BY2PG); 
1994/0814    
	} 
	return 0; 
} 
 
1993/0915    
void 
1991/0711    
confinit(void) 
{ 
1994/0814    
	long x, i, j, n; 
1992/1002    
	int pcnt; 
1992/0715    
	ulong ktop; 
1993/0330    
	char *cp; 
	char *line[MAXCONF]; 
1994/0513    
	extern int defmaxmsg; 
1991/0711    
 
1993/0416    
	pcnt = 0; 
 
1991/0711    
	/* 
1993/1113    
	 *  parse configuration args from dos file plan9.ini 
1993/0416    
	 */ 
1993/0915    
	cp = BOOTARGS;	/* where b.com leaves its config */ 
1993/0416    
	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]); 
1994/0513    
		if(strcmp(confname[nconf], "defmaxmsg") == 0){ 
			i = atoi(confval[nconf]); 
			if(i < defmaxmsg && i >=128) 
				defmaxmsg = i; 
		} 
1994/0607    
		if(strcmp(confname[nconf], "filaddr") == 0) 
			strcpy(filaddr, confval[nconf]); 
1993/0416    
		nconf++; 
	} 
1994/0814    
 
1993/0416    
	/* 
1993/0915    
	 *  size memory above 1 meg. Kernel sits at 1 meg.  We 
	 *  only recognize MB size chunks. 
1991/0711    
	 */ 
1993/0915    
	memset(mmap, ' ', sizeof(mmap)); 
1991/0711    
	x = 0x12345678; 
1993/0915    
	for(i = 1; i <= MAXMEG; i++){ 
1991/0711    
		/* 
1993/0915    
		 *  write the first & last word in a megabyte of memory 
1991/0711    
		 */ 
1993/0915    
		*mapaddr(KZERO|(i*MB)) = x; 
		*mapaddr(KZERO|((i+1)*MB-BY2WD)) = x; 
 
1991/0711    
		/* 
1993/0915    
		 *  write the first and last word in all previous megs to 
		 *  handle address wrap around 
1991/0711    
		 */ 
1992/1019    
		for(j = 1; j < i; j++){ 
1993/0915    
			*mapaddr(KZERO|(j*MB)) = ~x; 
			*mapaddr(KZERO|((j+1)*MB-BY2WD)) = ~x; 
1991/0711    
		} 
1993/0915    
 
1991/0711    
		/* 
1993/0915    
		 *  check for correct value 
1991/0711    
		 */ 
1994/0815    
		if(*mapaddr(KZERO|(i*MB)) == x) 
			if(*mapaddr(KZERO|((i+1)*MB-BY2WD)) == x) 
				mmap[i] = 'x'; 
1994/0814    
		x += 0x3141526; 
	} 
 
	/* 
1994/0817    
	 *  zero and clear all except first 2 meg. 
1994/0814    
	 */ 
	x = 0x12345678; 
	for(i = MAXMEG; i > 1; i--){ 
		if(mmap[i] != 'x') 
			continue; 
1994/0817    
		if(memclrtest(i, MB, x) < 0) 
1994/0814    
			mmap[i] = ' '; 
1991/0711    
		x += 0x3141526; 
	} 
1994/0814    
 
1993/0915    
	/* 
	 *  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++) 
		; 
1994/0814    
	conf.npage0 = (i*MB - ktop)/BY2PG; 
1993/0915    
	conf.topofmem = i*MB; 
 
	/* 
1994/0814    
	 *  bank1 usually goes from the end of BOOTARGS to 640k 
1993/0915    
	 */ 
1994/0813    
	conf.base1 = (ulong)(BOOTARGS + BOOTARGSLEN); 
1993/0915    
	conf.base1 = PGROUND(conf.base1); 
	conf.base1 = PADDR(conf.base1); 
1994/0813    
	conf.npage1 = (640*1024 - conf.base1)/BY2PG; 
1993/0915    
 
	/* 
1994/0814    
	 *  if there is a hole in memory (e.g. due to a shadow BIOS) make the 
1993/0915    
	 *  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; 
		} 
 
1991/0711    
	conf.npage = conf.npage0 + conf.npage1; 
1992/1113    
	conf.ldepth = 0; 
1993/0416    
	if(pcnt < 10) 
		pcnt = 70; 
1992/1014    
	conf.upages = (conf.npage*pcnt)/100; 
1994/0322    
	conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG; 
1992/1016    
 
1994/0923    
	conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5; 
1993/0401    
	conf.monitor = 1; 
	conf.nswap = conf.nproc*80; 
	conf.nimage = 50; 
1994/0302    
	switch(x86()){ 
1994/1031    
	case 3: 
1994/0302    
		conf.copymode = 1;	/* copy on reference */ 
		break; 
	default: 
		conf.copymode = 0;	/* copy on write */ 
		break; 
	} 
1993/0401    
	conf.nfloppy = 2; 
	conf.nhard = 2; 
1993/0413    
	conf.nmach = 1; 
1991/0711    
} 
 
1991/0913    
char *mathmsg[] = 
1991/0906    
{ 
1991/0913    
	"invalid", 
	"denormalized", 
	"div-by-zero", 
	"overflow", 
	"underflow", 
	"precision", 
	"stack", 
	"error", 
}; 
1991/0906    
 
/* 
1991/0912    
 *  math coprocessor error 
 */ 
void 
1993/1124    
matherror(Ureg *ur, void *arg) 
1991/0912    
{ 
1991/0913    
	ulong status; 
	int i; 
	char *msg; 
	char note[ERRLEN]; 
 
1993/1124    
	USED(arg); 
 
1991/0913    
	/* 
	 *  a write cycle to port 0xF0 clears the interrupt latch attached 
	 *  to the error# line from the 387 
	 */ 
	outb(0xF0, 0xFF); 
 
1992/0806    
	/* 
	 *  save floating point state to check out error 
	 */ 
1993/0915    
	fpenv(&up->fpsave); 
	status = up->fpsave.status; 
1992/0806    
 
	msg = 0; 
1991/0913    
	for(i = 0; i < 8; i++) 
		if((1<<i) & status){ 
			msg = mathmsg[i]; 
1993/0915    
			sprint(note, "sys: fp: %s fppc=0x%lux", msg, up->fpsave.pc); 
1993/1013    
			postnote(up, 1, note, NDebug); 
1991/0913    
			break; 
		} 
1992/0806    
	if(msg == 0){ 
1993/0915    
		sprint(note, "sys: fp: unknown fppc=0x%lux", up->fpsave.pc); 
1993/1013    
		postnote(up, 1, note, NDebug); 
1992/0806    
	} 
	if(ur->pc & KZERO) 
		panic("fp: status %lux fppc=0x%lux pc=0x%lux", status, 
1993/0915    
			up->fpsave.pc, ur->pc); 
1991/0912    
} 
 
/* 
1991/0906    
 *  math coprocessor emulation fault 
 */ 
void 
1993/1124    
mathemu(Ureg *ur, void *arg) 
1991/0906    
{ 
1993/1124    
	USED(ur, arg); 
1993/0915    
	switch(up->fpstate){ 
1991/0906    
	case FPinit: 
		fpinit(); 
1993/0915    
		up->fpstate = FPactive; 
1991/0906    
		break; 
	case FPinactive: 
1993/0915    
		fprestore(&up->fpsave); 
		up->fpstate = FPactive; 
1991/0906    
		break; 
	case FPactive: 
1992/0805    
		panic("math emu", 0); 
1991/0906    
		break; 
	} 
} 
 
/* 
 *  math coprocessor segment overrun 
 */ 
void 
1993/1124    
mathover(Ureg *ur, void *arg) 
1991/0906    
{ 
1993/1124    
	USED(ur, arg); 
1993/0915    
print("sys: fp: math overrun pc 0x%lux pid %d\n", ur->pc, up->pid); 
1992/0805    
	pexit("math overrun", 0); 
1991/0906    
} 
 
void 
mathinit(void) 
{ 
1993/1124    
	setvec(Matherr1vec, matherror, 0); 
	setvec(Matherr2vec, matherror, 0); 
	setvec(Mathemuvec, mathemu, 0); 
	setvec(Mathovervec, mathover, 0); 
1991/0906    
} 
 
/* 
1991/0716    
 *  set up floating point for a new process 
 */ 
1991/0703    
void 
1991/0716    
procsetup(Proc *p) 
1991/0703    
{ 
1991/0716    
	p->fpstate = FPinit; 
1991/0906    
	fpoff(); 
1991/0705    
} 
 
1991/0712    
/* 
1991/0906    
 *  Save the mach dependent part of the process state. 
1991/0712    
 */ 
1991/0705    
void 
1992/0122    
procsave(Proc *p) 
1991/0705    
{ 
1992/0805    
	if(p->fpstate == FPactive){ 
		if(p->state == Moribund) 
			fpoff(); 
		else 
1993/0915    
			fpsave(&up->fpsave); 
1992/0805    
		p->fpstate = FPinactive; 
1991/0906    
	} 
1991/0712    
} 
 
/* 
1991/0716    
 *  Restore what procsave() saves 
1991/0712    
 */ 
1991/0716    
void 
1992/0122    
procrestore(Proc *p) 
1991/0712    
{ 
1992/0711    
	USED(p); 
1991/0712    
} 
 
1991/0906    
/* 
1991/1210    
 *  the following functions all are slightly different from 
 *  PC to PC. 
1991/0803    
 */ 
 
void 
1992/0812    
exit(int ispanic) 
1991/0803    
{ 
1993/1013    
	up = 0; 
1991/0803    
	print("exiting\n"); 
1993/0915    
	if(ispanic){ 
1993/1113    
		if(cpuserver) 
1993/0915    
			delay(10000); 
		else 
			for(;;); 
	} 
1992/0903    
 
1992/0923    
	(*arch->reset)(); 
1991/0803    
} 
 
/* 
1991/1210    
 *  set cpu speed 
 *	0 == low speed 
 *	1 == high speed 
1991/0803    
 */ 
1991/1210    
int 
cpuspeed(int speed) 
1991/0803    
{ 
1992/0923    
	if(arch->cpuspeed) 
		return (*arch->cpuspeed)(speed); 
	else 
1991/1210    
		return 0; 
1991/0803    
} 
 
/* 
1991/1210    
 *  f == frequency (Hz) 
 *  d == duration (ms) 
1991/0803    
 */ 
1991/1210    
void 
buzz(int f, int d) 
1991/0803    
{ 
1992/0923    
	if(arch->buzz) 
		(*arch->buzz)(f, d); 
1991/0803    
} 
 
/* 
1991/1210    
 *  each bit in val stands for a light 
1991/0803    
 */ 
1991/1210    
void 
lights(int val) 
1991/0803    
{ 
1992/0923    
	if(arch->lights) 
		(*arch->lights)(val); 
1991/0803    
} 
 
/* 
1991/0913    
 *  power to serial port 
1991/1210    
 *	onoff == 1 means on 
 *	onoff == 0 means off 
1991/0803    
 */ 
int 
serial(int onoff) 
{ 
1992/0923    
	if(arch->serialpower) 
		return (*arch->serialpower)(onoff); 
	else 
1991/1210    
		return 0; 
1991/0803    
} 
 
1991/1001    
/* 
 *  power to modem 
1991/1210    
 *	onoff == 1 means on 
 *	onoff == 0 means off 
1991/1001    
 */ 
int 
modem(int onoff) 
{ 
1992/0923    
	if(arch->modempower) 
		return (*arch->modempower)(onoff); 
	else 
1991/1210    
		return 0; 
1993/0915    
} 
 
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); 
1994/0823    
			else if(strncmp(p, "freq=", 5) == 0) 
				isa->freq = strtoul(p+5, &p, 0); 
1993/0915    
			else if(strncmp(p, "ea=", 3) == 0) 
				parseether(isa->ea, p+3); 
			while(*p && *p != ' ' && *p != '\t') 
				p++; 
		} 
		return 1; 
	} 
	return 0; 
1991/0803    
} 


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