Changeset 4209

Show
Ignore:
Timestamp:
10/15/06 10:46:36 (8 years ago)
Author:
khali
Message:

Parse /proc/cpuinfo and build a list of CPU from it. This will make it
possible to suggest hardware monitoring drivers based of CPU ID.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/detect/sensors-detect

    r4196 r4209  
    20582058} 
    20592059 
     2060# @cpu is a list of reference to hashes, one hash per CPU. 
     2061# Each entry has the following keys: vendor_id, cpu family, model, 
     2062# model name and stepping, directly taken from /proc/cpuinfo. 
     2063use vars qw(@cpu); 
     2064 
     2065sub initialize_cpu_list 
     2066{ 
     2067  open(local *INPUTFILE, "/proc/cpuinfo") or die "Can't access /proc/cpuinfo!"; 
     2068  local $_; 
     2069  my %entry; 
     2070  while (<INPUTFILE>) { 
     2071    if (m/^processor\s*:\s*(\d+)/) { 
     2072      push @cpu, \%entry if scalar keys(%entry); # Previous entry 
     2073      %entry = (); # New entry 
     2074      next; 
     2075    } 
     2076    if (m/^(vendor_id|cpu family|model|model name|stepping)\s*:\s*(.+)$/) { 
     2077      my $k = $1; 
     2078      my $v = $2; 
     2079      $v =~ s/\s+/ /g;  # Merge multiple spaces 
     2080      $v =~ s/ $//;     # Trim trailing space 
     2081      $entry{$k} = $v; 
     2082      next; 
     2083    } 
     2084  } 
     2085  push @cpu, \%entry if scalar keys(%entry); # Last entry 
     2086  close INPUTFILE; 
     2087} 
     2088 
    20602089########### 
    20612090# MODULES # 
     
    52835312  initialize_modules_supported; 
    52845313  initialize_kernel_version; 
     5314  initialize_cpu_list(); 
    52855315 
    52865316  print "# sensors-detect revision $revision\n\n";