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

1990/11211/port/devboot.c (diff list | history)

1990/11211/sys/src/9/port/devboot.c:1,1221990/1127/sys/src/9/port/devboot.c:1,124 (short | long | prev | next)
1990/0424    
#include	"u.h" 
#include	"lib.h" 
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
#include	"errno.h" 
#include	"devtab.h" 
 
enum{ 
	Qdir, 
	Qboot, 
	Qmem, 
}; 
 
Dirtab bootdir[]={ 
	"boot",		Qboot,		0,			0666, 
	"mem",		Qmem,		0,			0666, 
1990/1127    
	"boot",		{Qboot},	0,	0666, 
	"mem",		{Qmem},		0,	0666, 
1990/0424    
}; 
 
#define	NBOOT	(sizeof bootdir/sizeof(Dirtab)) 
 
void 
bootreset(void) 
{ 
} 
 
void 
bootinit(void) 
{ 
} 
 
Chan* 
bootattach(char *spec) 
{ 
	return devattach('b', spec); 
} 
 
Chan* 
bootclone(Chan *c, Chan *nc) 
{ 
	return devclone(c, nc); 
} 
 
int	  
bootwalk(Chan *c, char *name) 
{ 
	return devwalk(c, name, bootdir, NBOOT, devgen); 
} 
 
void	  
bootstat(Chan *c, char *dp) 
{ 
	devstat(c, dp, bootdir, NBOOT, devgen); 
} 
 
Chan* 
bootopen(Chan *c, int omode) 
{ 
	return devopen(c, omode, bootdir, NBOOT, devgen); 
} 
 
void	  
bootcreate(Chan *c, char *name, int omode, ulong perm) 
{ 
1990/11211    
	error(Eperm); 
1990/0424    
} 
 
/* 
 * sysremove() knows this is a nop 
 */ 
void	  
bootclose(Chan *c) 
{ 
} 
 
long	  
bootread(Chan *c, void *buf, long n) 
{ 
	switch(c->qid & ~CHDIR){ 
1990/1127    
	switch(c->qid.path & ~CHDIR){ 
1990/0424    
	case Qdir: 
		return devdirread(c, buf, n, bootdir, NBOOT, devgen); 
	} 
 
1990/11211    
	error(Egreg); 
1990/0424    
} 
 
long	  
bootwrite(Chan *c, void *buf, long n) 
{ 
	ulong pc; 
 
	switch(c->qid & ~CHDIR){ 
1990/1127    
	switch(c->qid.path & ~CHDIR){ 
1990/0424    
	case Qmem: 
		/* kernel memory.  BUG: shouldn't be so easygoing. BUG: mem mapping? */ 
		if(c->offset>=KZERO && c->offset<KZERO+conf.npage*BY2PG){ 
/*			print("%ux, %d\n", c->offset, n);/**/ 
			if(c->offset+n > KZERO+conf.npage*BY2PG) 
				n = KZERO+conf.npage*BY2PG - c->offset; 
			memcpy((char*)c->offset, buf, n); 
			return n; 
		} 
1990/1127    
		print("bootwrite: bad addr %lux\n", c->offset); 
1990/11211    
		error(Ebadarg); 
1990/0424    
 
	case Qboot: 
		pc = *(ulong*)buf; 
		splhi(); 
		gotopc(pc); 
	} 
1990/1127    
	print("bootwrite: bad path %d\n", c->qid.path); 
1990/11211    
	error(Ebadarg); 
1990/0424    
} 
 
void	  
bootremove(Chan *c) 
{ 
1990/11211    
	error(Eperm); 
1990/0424    
} 
 
void	  
bootwstat(Chan *c, char *dp) 
{ 
1990/11211    
	error(Eperm); 
1990/0424    
} 


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