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

2001/0728/alphapc/devarch.c (diff list | history)

2000/0401/sys/src/9/alphapc/devarch.c:55,622000/0726/sys/src/9/alphapc/devarch.c:55,62 (short | long)
2000/0401    
	iomap.maps[i].next = nil; 
	iomap.free = iomap.maps; 
 
	// a dummy entry at 2^16 
	ioalloc(0x10000, 1, 0, "dummy"); 
2000/0726    
	// a dummy entry at 2^17 
	ioalloc(0x20000, 1, 0, "dummy"); 
2000/0401    
} 
 
static long cputyperead(char*, int, ulong); 
2000/0726/sys/src/9/alphapc/devarch.c:27,502001/0727/sys/src/9/alphapc/devarch.c:27,96 (short | long)
2000/0401    
} iomap; 
 
enum { 
	Qdir, 
	Qcputype, 
	Qioalloc, 
2001/0727    
	Qdir = 0, 
	Qioalloc = 1, 
2000/0401    
	Qiob, 
	Qiow, 
	Qiol, 
	Qirqalloc, 
2001/0727    
	Qbase, 
 
	Qmax = 16, 
2000/0401    
}; 
 
static Dirtab ioallocdir[] = { 
	"cputype",	{ Qcputype, 0 },	0,	0444, 
2001/0727    
typedef long Rdwrfn(Chan*, void*, long, vlong); 
 
static Rdwrfn *readfn[Qmax]; 
static Rdwrfn *writefn[Qmax]; 
 
static Dirtab archdir[] = { 
	".",	{ Qdir, 0, QTDIR },	0,	0555, 
2000/0401    
	"ioalloc",	{ Qioalloc, 0 },	0,	0444, 
	"iob",		{ Qiob, 0 },		0,	0660, 
	"iow",		{ Qiow, 0 },		0,	0660, 
	"iol",		{ Qiol, 0 },		0,	0660, 
	"irqalloc",	{ Qirqalloc, 0},	0,	0444, 
}; 
2001/0727    
Lock archwlock;	/* the lock is only for changing archdir */ 
int narchdir = Qbase; 
2000/0401    
 
2001/0727    
/* 
 * Add a file to the #P listing.  Once added, you can't delete it. 
 * You can't add a file with the same name as one already there, 
 * and you get a pointer to the Dirtab entry so you can do things 
 * like change the Qid version.  Changing the Qid path is disallowed. 
 */ 
Dirtab* 
addarchfile(char *name, int perm, Rdwrfn *rdfn, Rdwrfn *wrfn) 
{ 
	int i; 
	Dirtab d; 
	Dirtab *dp; 
 
	memset(&d, 0, sizeof d); 
	strcpy(d.name, name); 
	d.perm = perm; 
 
	lock(&archwlock); 
	if(narchdir >= Qmax){ 
		unlock(&archwlock); 
		return nil; 
	} 
 
	for(i=0; i<narchdir; i++) 
		if(strcmp(archdir[i].name, name) == 0){ 
			unlock(&archwlock); 
			return nil; 
		} 
 
	d.qid.path = narchdir; 
	archdir[narchdir] = d; 
	readfn[narchdir] = rdfn; 
	writefn[narchdir] = wrfn; 
	dp = &archdir[narchdir++]; 
	unlock(&archwlock); 
 
	return dp; 
} 
 
2000/0401    
void 
ioinit(void) 
{ 
2000/0726/sys/src/9/alphapc/devarch.c:59,662001/0727/sys/src/9/alphapc/devarch.c:105,110
2000/0726    
	ioalloc(0x20000, 1, 0, "dummy"); 
2000/0401    
} 
 
static long cputyperead(char*, int, ulong); 
                 
// 
//	alloc some io port space and remember who it was 
//	alloced to.  if port < 0, find a free region. 
2000/0726/sys/src/9/alphapc/devarch.c:115,1212001/0727/sys/src/9/alphapc/devarch.c:159,165
2000/0401    
	m->tag[sizeof(m->tag)-1] = 0; 
	*l = m; 
 
	ioallocdir[0].qid.vers++; 
2001/0727    
	archdir[0].qid.vers++; 
2000/0401    
 
	unlock(&iomap); 
	return m->start; 
2000/0726/sys/src/9/alphapc/devarch.c:138,1442001/0727/sys/src/9/alphapc/devarch.c:182,188
2000/0401    
		if((*l)->start > port) 
			break; 
	} 
	ioallocdir[0].qid.vers++; 
2001/0727    
	archdir[0].qid.vers++; 
2000/0401    
	unlock(&iomap); 
} 
 
2000/0726/sys/src/9/alphapc/devarch.c:175,1962001/0727/sys/src/9/alphapc/devarch.c:219,240
2000/0401    
	return devattach('P', spec); 
} 
 
int 
archwalk(Chan* c, char* name) 
2001/0727    
Walkqid* 
archwalk(Chan* c, Chan *nc, char** name, int nname) 
2000/0401    
{ 
	return devwalk(c, name, ioallocdir, nelem(ioallocdir), devgen); 
2001/0727    
	return devwalk(c, nc, name, nname, archdir, narchdir, devgen); 
2000/0401    
} 
 
static void 
archstat(Chan* c, char* dp) 
2001/0727    
static int 
archstat(Chan* c, uchar* dp, int n) 
2000/0401    
{ 
	devstat(c, dp, ioallocdir, nelem(ioallocdir), devgen); 
2001/0727    
	return devstat(c, dp, n, archdir, narchdir, devgen); 
2000/0401    
} 
 
static Chan* 
archopen(Chan* c, int omode) 
{ 
	return devopen(c, omode, ioallocdir, nelem(ioallocdir), devgen); 
2001/0727    
	return devopen(c, omode, archdir, nelem(archdir), devgen); 
2000/0401    
} 
 
static void 
2000/0726/sys/src/9/alphapc/devarch.c:206,2222001/0727/sys/src/9/alphapc/devarch.c:250,266
2000/0401    
static long 
archread(Chan *c, void *a, long n, vlong offset) 
{ 
	char *p; 
	IOMap *m; 
	char buf[Linelen+1]; 
2001/0727    
	char buf[Linelen+1], *p; 
2000/0401    
	int port; 
	ushort *sp; 
	ulong *lp; 
2001/0727    
	IOMap *m; 
	Rdwrfn *fn; 
2000/0401    
 
	switch(c->qid.path & ~CHDIR){ 
2001/0727    
	switch((ulong)c->qid.path){ 
2000/0401    
 
	case Qdir: 
		return devdirread(c, a, n, ioallocdir, nelem(ioallocdir), devgen); 
2001/0727    
		return devdirread(c, a, n, archdir, nelem(archdir), devgen); 
2000/0401    
 
	case Qiob: 
		port = offset; 
2000/0726/sys/src/9/alphapc/devarch.c:248,2602001/0727/sys/src/9/alphapc/devarch.c:292,300
2000/0401    
	case Qioalloc: 
		break; 
 
	case Qirqalloc: 
		return irqallocread(a, n, offset); 
                 
	case Qcputype: 
		return cputyperead(a, n, offset); 
                 
	default: 
2001/0727    
		if(c->qid.path < narchdir && (fn = readfn[c->qid.path])) 
			return fn(c, a, n, offset); 
2000/0401    
		error(Eperm); 
		break; 
	} 
2000/0726/sys/src/9/alphapc/devarch.c:281,2922001/0727/sys/src/9/alphapc/devarch.c:321,333
2000/0401    
static long 
archwrite(Chan *c, void *a, long n, vlong offset) 
{ 
2001/0727    
	char *p; 
2000/0401    
	int port; 
	ushort *sp; 
	ulong *lp; 
	char *p; 
2001/0727    
	Rdwrfn *fn; 
2000/0401    
 
	switch(c->qid.path & ~CHDIR){ 
2001/0727    
	switch((ulong)c->qid.path){ 
2000/0401    
 
	case Qiob: 
		p = a; 
2000/0726/sys/src/9/alphapc/devarch.c:316,3212001/0727/sys/src/9/alphapc/devarch.c:357,364
2000/0401    
		return n*4; 
 
	default: 
2001/0727    
		if(c->qid.path < narchdir && (fn = writefn[c->qid.path])) 
			return fn(c, a, n, offset); 
2000/0401    
		error(Eperm); 
		break; 
	} 
2000/0726/sys/src/9/alphapc/devarch.c:329,3352001/0727/sys/src/9/alphapc/devarch.c:372,377
2000/0401    
	devreset, 
	devinit, 
	archattach, 
	devclone, 
	archwalk, 
	archstat, 
	archopen, 
2000/0726/sys/src/9/alphapc/devarch.c:366,3872001/0727/sys/src/9/alphapc/devarch.c:408,413
2000/0401    
}; 
 
void 
archinit(void) 
{ 
	PCArch **p; 
                 
	arch = 0; 
	for(p = knownarch; *p; p++){ 
		if((*p)->ident && (*p)->ident() == 0){ 
			arch = *p; 
			break; 
		} 
	} 
	if(arch == 0) 
		arch = &archgeneric; 
} 
                 
void 
cpuidprint(void) 
{ 
	int i, maj, min; 
2000/0726/sys/src/9/alphapc/devarch.c:419,4252001/0727/sys/src/9/alphapc/devarch.c:445,451
2000/0401    
} 
 
static long 
cputyperead(char *a, int n, ulong offset) 
2001/0727    
cputyperead(Chan*, void *a, long n, vlong offset) 
2000/0401    
{ 
	char str[32], *cputype; 
	ulong mhz, maj; 
2000/0726/sys/src/9/alphapc/devarch.c:434,4372001/0727/sys/src/9/alphapc/devarch.c:460,481
2000/0401    
 
	snprint(str, sizeof(str), "%s %lud\n", cputype, mhz); 
	return readstr(offset, a, n, str); 
2001/0727    
} 
 
void 
archinit(void) 
{ 
	PCArch **p; 
 
	arch = 0; 
	for(p = knownarch; *p; p++){ 
		if((*p)->ident && (*p)->ident() == 0){ 
			arch = *p; 
			break; 
		} 
	} 
	if(arch == 0) 
		arch = &archgeneric; 
 
	addarchfile("cputype", 0444, cputyperead, nil); 
2000/0401    
} 
2001/0727/sys/src/9/alphapc/devarch.c:452,4582001/0728/sys/src/9/alphapc/devarch.c:452,458 (short | long)
2000/0401    
	Hwcpu *cpu; 
 
	mhz = (m->cpuhz+999999)/1000000; 
	cpu = (Hwcpu*) ((ulong)hwrpb + hwrpb->cpuoff); 
2001/0728    
	cpu = (Hwcpu*) ((ulong)hwrpb + hwrpb->cpuoff);	/* NB CPU 0 */ 
2000/0401    
	cputype = "unknown"; 
	maj = (ulong)cpu->cputype; 
	if (maj < nelem(cpunames)) 
2001/0728/sys/src/9/alphapc/devarch.c:51,562001/1023/sys/src/9/alphapc/devarch.c:51,58 (short | long)
2000/0401    
}; 
2001/0727    
Lock archwlock;	/* the lock is only for changing archdir */ 
int narchdir = Qbase; 
2001/1023    
int (*_pcmspecial)(char *, ISAConf *); 
void (*_pcmspecialclose)(int); 
2000/0401    
 
2001/0727    
/* 
 * Add a file to the #P listing.  Once added, you can't delete it. 
2001/0728/sys/src/9/alphapc/devarch.c:478,4812001/1023/sys/src/9/alphapc/devarch.c:480,496
2001/0727    
		arch = &archgeneric; 
 
	addarchfile("cputype", 0444, cputyperead, nil); 
2001/1023    
} 
 
int 
pcmspecial(char *idstr, ISAConf *isa) 
{ 
	return (_pcmspecial  != nil)? _pcmspecial(idstr, isa): -1; 
} 
 
void 
pcmspecialclose(int a) 
{ 
	if (_pcmspecialclose != nil) 
		_pcmspecialclose(a); 
2000/0401    
} 
2001/1023/sys/src/9/alphapc/devarch.c:372,3782002/0109/sys/src/9/alphapc/devarch.c:372,379 (short | long)
2000/0401    
	"arch", 
 
	devreset, 
	devinit, 
2002/0109    
	devinit,	 
	devshutdown, 
2000/0401    
	archattach, 
	archwalk, 
	archstat, 
2002/0109/sys/src/9/alphapc/devarch.c:401,4132002/1130/sys/src/9/alphapc/devarch.c:401,449 (short | long)
2000/0401    
 
static char	*sysnames[] = 
{ 
// [26]		"EB164", 
[26]		"AlphaPC 164", 
2002/1130    
[1]		"Alpha Demo. Unit", 
[2]		"DEC 4000; Cobra", 
[3]		"DEC 7000; Ruby", 
[4]		"DEC 3000/500; Flamingo family (TC)", 
[6]		"DEC 2000/300; Jensen (EISA/ISA)", 
[7]		"DEC 3000/300; Pelican (TC)", 
[8]		"Avalon A12; Avalon Multicomputer", 
[9]		"DEC 2100/A500; Sable", 
[10]		"DEC APXVME/64; AXPvme (VME?)", 
[11]		"DEC AXPPCI/33; NoName (PCI/ISA)", 
[12]		"DEC 21000; TurboLaser (PCI/EISA)", 
[13]		"DEC 2100/A50; Avanti (PCI/ISA)", 
[14]		"DEC MUSTANG; Mustang", 
[15]		"DEC KN20AA; kn20aa (PCI/EISA)", 
[17]		"DEC 1000; Mikasa (PCI/ISA?)", 
[19]		"EB66; EB66 (PCI/ISA?)",		// DEC? 
[20]		"EB64P; EB64+ (PCI/ISA?)",		// DEC? 
[21]		"Alphabook1; Alphabook", 
[22]		"DEC 4100; Rawhide (PCI/EISA)", 
[23]		"DEC EV45/PBP; Lego", 
[24]		"DEC 2100A/A500; Lynx", 
[26]		"DEC AlphaPC 164",	// only supported one: "EB164 (PCI/ISA)" 
[27]		"DEC 1000A; Noritake", 
[28]		"DEC AlphaVME/224; Cortex", 
[30]		"DEC 550; Miata (PCI/ISA)", 
[32]		"DEC EV56/PBP; Takara", 
[33]		"DEC AlphaVME/320; Yukon (VME?)", 
[34]		"DEC 6600; MonetGoldrush", 
// 200 and up is Alpha Processor Inc. machines 
// [201]	"API UP1000; Nautilus", 
2000/0401    
}; 
 
static char	*cpunames[] = 
{ 
[7]		"21164A", 
2002/1130    
[1]		"EV3", 
[2]		"EV4: 21064", 
[3]		"Simulation", 
[4]		"LCA4: 2106[68]", 
[5]		"EV5: 21164", 
[6]		"EV45: 21064A", 
[7]		"21164A",		/* only supported one: EV56 */ 
[8]		"EV6: 21264", 
[9]		"PCA256: 21164PC", 
2000/0401    
}; 
 
void 
2002/0109/sys/src/9/alphapc/devarch.c:430,4362002/1130/sys/src/9/alphapc/devarch.c:466,472
2000/0401    
		s = "<unknown>"; 
		if (hwrpb->systype < nelem(sysnames)) 
			s = sysnames[hwrpb->systype]; 
		print("DEC %s (%llux, %llux, %llux)\n", s, hwrpb->systype, hwrpb->sysvar, hwrpb->sysrev); 
2002/1130    
		print("%s (%llux, %llux, %llux)\n", s, hwrpb->systype, hwrpb->sysvar, hwrpb->sysrev); 
2000/0401    
	} 
 
	for (i = 0; i < hwrpb->ncpu; i++) { 


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