lkml.org 
[lkml]   [1997]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectx86 clock *speed* probing - very final
it's clock_speed and it will stay clock_speed! :)
I assume that some programs will rely on that.

code is undefined for SMP. SMP-People! Could someone extend this to SMP
architectures? Or give me some helpful hints?

Cheers, Stephan

patch follows:
-------------------------- cut here ----------------------
--- linux/arch/i386/kernel/setup.c.old Mon Jan 27 18:32:56 1997
+++ linux/arch/i386/kernel/setup.c Sat Feb 1 18:44:10 1997
@@ -8,6 +8,12 @@
* This file handles the architecture-dependent parts of initialization
*/

+/*
+ * processor clock speed probing code added
+ * needs cpuid and rdtsc instructions
+ * 02/01/97 by Stephan Meyer <Stephan.Meyer@munich.netsurf.de>
+ */
+
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
@@ -204,6 +210,46 @@
request_region(0xf0,0x10,"npu");
}

+#ifndef __SMP__
+
+static char * get_clock_speed()
+{
+ unsigned long int a,b,j,q;
+ static char buffer[20];
+ if (!have_cpuid) {
+ strcpy(buffer,"no_tsc");
+ return buffer;
+ }
+ __asm__ __volatile__ (
+ "movl $1,%%eax
+ cpuid"
+ :"=d" (a)
+ :
+ :"%eax","%ebx","%ecx","%edx");
+ if ((a & 0x10)==0) {
+ strcpy(buffer,"no_tsc");
+ return buffer;
+ }
+ j=jiffies;
+ for (;j==jiffies;); j=jiffies;
+ __asm__ __volatile__ (
+ "rdtsc"
+ : "=a" (a)
+ :
+ : "%eax","%edx");
+ for (;j==jiffies;);
+ __asm__ __volatile__ (
+ "rdtsc"
+ : "=a" (b)
+ :
+ : "%eax","%edx");
+ q=((b-a)+(500000/HZ))/(1000000/HZ);
+ sprintf(buffer,"%i MHz",(int) q);
+ return buffer;
+}
+
+#endif
+
static const char * i486model(unsigned int nr)
{
static const char *model[] = {
@@ -287,12 +333,18 @@
len += sprintf(buffer+len,"processor\t: %d\n"
"cpu\t\t: %c86\n"
"model\t\t: %s\n"
+#ifndef __SMP__
+ "clock_speed\t: %s\n"
+#endif
"vendor_id\t: %s\n",
CPUN,
CD(x86)+'0',
CD(have_cpuid) ?
getmodel(CD(x86), CD(x86_model)) :
"unknown",
+#ifndef __SMP__
+ get_clock_speed(),
+#endif
CD(x86_vendor_id));

if (CD(x86_mask))
----------------------------- cut here ---------------------------

-----------------------------------------------
Stephan Meyer
+49-89-4301114
Stephan.Meyer@munich.netsurf.de
http://fatman.mathematik.tu-muenchen.de/~meyer/
-----------------------------------------------

\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.029 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site