Show
Ignore:
Timestamp:
02/18/02 01:43:24 (13 years ago)
Author:
mds
Message:

update from Jean Delvare - handle new /proc entries and other

changes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/eeprom/decode-vaio.pl

    r1309 r1325  
    1818# 
    1919# Version 0.1  2002-02-06  Jean Delvare <khali@linux-fr.org> 
     20# Version 0.2  2002-02-16  Jean Delvare <khali@linux-fr.org> 
     21#  Fixed to work with the new, simplified /proc interface names of the eeprom driver 
     22#  (lm_sensors 2.6.3 and greater.) 
     23#  Shifted data display by 4 columns left. 
     24# Version 0.3  2002-02-17  Jean Delvare <khali@linux-fr.org> 
     25#  Added UUID field at 0x10 (added decode_uuid.) 
     26#  Merged decode_string and decode_string32. 
     27#  Added unknown field at 0x20. 
     28#  Moved header and footer to BEGIN and END, respectivly. 
     29#  Reformated history to match those of the other decode scripts. 
     30#  Deleted decode_char (made useless by decode_string.) 
     31#  Reordered field display, changed some labels. 
     32#  Added old /proc interface check. 
    2033# 
    2134# EEPROM data decoding for Sony Vaio laptops.  
    2235# 
    23 # Two assumptions: lm_sensors-2.x installed, 
     36# Two assumptions: lm_sensors-2.6.3 or greater installed, 
    2437# and Perl is at /usr/bin/perl 
    2538# 
    26 # Please note that this is a guess-only work.  I don't expect much help from 
    27 # Sony, so if someone can provide information, please contact me.  I used my 
     39# Please note that this is a guess-only work.  Sony support refused to help 
     40# me, so if someone can provide information, please contact me.  I used my 
    2841# PCG-GR214EP as a base, but I can't promise that this script will work with 
    2942# other models.  Any feedback appreciated anyway. 
     
    3649        my ($label,$value) = @_; 
    3750         
    38         printf("\%20s : \%s\n",$label,$value); 
    39 } 
    40  
    41 sub decode_char 
    42 { 
    43         my ($bus,$addr,$base,$offset,$length) = @_; 
    44          
    45         my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); 
    46         open(FH,$filename) || die "Can't open $filename"; 
    47         my $line=<FH>; 
    48         close(FH); 
    49          
    50         my @bytes=split(/[ \n]/,$line); 
    51         @bytes=@bytes[$offset..$offset+$length-1]; 
    52         my $string=''; 
    53         my $item; 
    54         while(defined($item=shift(@bytes))) 
    55         { 
    56                 $string.=chr($item); 
    57         } 
    58          
    59         return($string); 
     51        printf("\%16s : \%s\n",$label,$value); 
    6052} 
    6153 
     
    6456        my ($bus,$addr,$base,$offset,$length) = @_; 
    6557 
    66         my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); 
    67         open(FH,$filename) || die "Can't open $filename"; 
    68         my $line=<FH>; 
    69         close(FH); 
     58        my $line=''; 
     59        my $remains=$length+$offset; 
     60        while($remains>0) 
     61        { 
     62                my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/".sprintf('%02x',$base); 
     63                open(FH,$filename) || die "Can't open $filename"; 
     64                $line.=<FH>; 
     65                close(FH); 
     66                $remains-=16; 
     67                $base+=16; 
     68        } 
    7069 
    7170        my @bytes=split(/[ \n]/,$line); 
     
    8180} 
    8281 
    83 sub decode_string32 
     82sub decode_uuid 
    8483{ 
    8584        my ($bus,$addr,$base) = @_; 
    8685 
    87         my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); 
     86        my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/".sprintf('%02x',$base); 
    8887        open(FH,$filename) || die "Can't open $filename"; 
    8988        my $line=<FH>; 
    90         close(FH); 
    91         $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data".($base+16).'-'.($base+31); 
    92         open(FH,$filename) || die "Can't open $filename"; 
    93         $line.=<FH>; 
    9489        close(FH); 
    9590 
     
    9792        my $string=''; 
    9893        my $item; 
    99         while(defined($item=shift(@bytes)) && ($item!=0)) 
     94 
     95        for(my $i=0;$i<16;$i++) 
    10096        { 
    101                 $string.=chr($item); 
     97                $string.=sprintf('%02x',shift(@bytes)); 
     98                if(($i==3)||($i==5)||($i==7)||($i==9)) 
     99                { 
     100                        $string.='-'; 
     101                } 
    102102        } 
    103          
     103 
    104104        return($string); 
    105105} 
     
    109109        my ($bus,$addr) = @_; 
    110110         
    111         print_item('Model name',decode_string32($bus,$addr,128).' ['.decode_char($bus,$addr,160,10,4).']'); 
     111        print_item('Machine Name',decode_string($bus,$addr,128,0,32)); 
     112        print_item('Serial Number',decode_string($bus,$addr,192,0,32)); 
     113        print_item('UUID',decode_uuid($bus,$addr,16)); 
    112114        print_item('Revision',decode_string($bus,$addr,160,0,10)); 
    113         print_item('Serial number',decode_string32($bus,$addr,192)); 
    114         print_item('Timestamp',decode_string32($bus,$addr,224)); 
     115        print_item('Model Number','PCG-'.decode_string($bus,$addr,160,10,4)); 
     116        print_item('?',decode_string($bus,$addr,32,0,16)); 
     117        print_item('?',decode_string($bus,$addr,224,0,32)); 
    115118} 
    116119 
    117 print("Sony Vaio EEPROM Decoder\n"); 
    118 print("Written by Jean Delvare.  Copyright 2002.\n"); 
    119 print("Version 0.1\n\n"); 
     120BEGIN 
     121{ 
     122        print("Sony Vaio EEPROM Decoder\n"); 
     123        print("Written by Jean Delvare.  Copyright 2002.\n"); 
     124        print("Version 0.3\n\n"); 
     125} 
     126 
     127END 
     128{ 
     129        print("\n"); 
     130} 
    120131 
    121132if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57') 
    122133{ 
    123         vaio_decode('0','57'); 
     134        if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57/data0-15') 
     135        { 
     136                print("Deprecated old interface found.  Please upgrade to lm_sensors 2.6.3 or greater."); 
     137        } 
     138        else 
     139        { 
     140                vaio_decode('0','57'); 
     141        } 
    124142} 
    125143else 
    126144{ 
    127         print("Vaio eeprom not found.  Please make sure that the eeprom module is loaded.\n"); 
     145        print("Vaio EEPROM not found.  Please make sure that the eeprom module is loaded.\n"); 
    128146        print("If you believe this is an error, please contact me <khali\@linux-fr.org>\n"); 
    129147        print("so that we may see how to fix the problem.\n"); 
    130148} 
    131  
    132 print("\n");