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

1998/0710/pc/archgeneric.c (diff list | history)

1998/0702/sys/src/9/pc/archgeneric.c:17,221998/0710/sys/src/9/pc/archgeneric.c:17,24 (short | long | prev | next)
add cycletimerinit, cycletimer. set as arch->fastclock on Pentium+
rsc Fri Mar 4 12:44:25 2005
1992/0923    
} 
 
1997/0327    
void (*coherence)(void) = nop; 
1998/0710    
void cycletimerinit(void); 
uvlong cycletimer(uvlong*); 
1997/0327    
 
PCArch* arch; 
extern PCArch* knownarch[]; 
1998/0702/sys/src/9/pc/archgeneric.c:32,371998/0710/sys/src/9/pc/archgeneric.c:34,41
1997/0327    
	i8259enable,				/* intrenable */ 
 
	i8253enable,				/* clockenable */ 
1998/0710    
 
	i8253read,				/* read the standard timer */ 
1997/0327    
}; 
 
typedef struct { 
1998/0702/sys/src/9/pc/archgeneric.c:185,1901998/0710/sys/src/9/pc/archgeneric.c:189,200
1997/0327    
			arch->intrenable = archgeneric.intrenable; 
	} 
 
1998/0710    
	/* pick the better timer */ 
	if(X86FAMILY(m->cpuidax) >= 5){ 
		cycletimerinit(); 
		arch->fastclock = cycletimer; 
	} 
 
1997/0327    
	/* 
	 * Decide whether to use copy-on-reference (386 and mp). 
	 */ 
1998/0702/sys/src/9/pc/archgeneric.c:193,1961998/0710/sys/src/9/pc/archgeneric.c:203,234
1997/0327    
 
	if(X86FAMILY(m->cpuidax) == 6 /*&& conf.nmach > 1*/) 
		coherence = wbflush; 
1998/0710    
} 
 
static uvlong fasthz; 
 
void 
cycletimerinit(void) 
{ 
	fasthz = 1000000LL*m->cpumhz; 
} 
 
/* 
 *  return the most precice clock we have 
 */ 
uvlong 
cycletimer(uvlong *hz) 
{ 
	uvlong tsc; 
 
	rdmsr(0x10, (vlong*)&tsc); 
	if(hz != nil) 
		*hz = fasthz; 
	return tsc; 
} 
 
uvlong 
fastticks(uvlong *hz) 
{ 
	return (*arch->fastclock)(hz); 
1997/0327    
} 


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