Changeset 1582

Show
Ignore:
Timestamp:
11/07/02 14:56:54 (11 years ago)
Author:
khali
Message:

Apply dmi_scan fixes from Linux kernel 2.5.43

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r1581 r1582  
    2929  Makefile: Take kernel source location from /lib/modules/x.x.x/build 
    3030  Module adm1021: Add support for MC1066 
    31   Module dmi_scan: Rename symbol duplicated in kernel 
     31  Module dmi_scan: Rename symbol duplicated in kernel; Apply fixes from 
     32                   kernel 2.5.43 
    3233  Module gl518sm: Iterate allowed only for rev 0x00 
    3334  Module i2c-amd756: Configure base address for nForce support; 
  • lm-sensors/trunk/kernel/busses/dmi_scan.c

    r1541 r1582  
    3737                return ""; 
    3838        s--; 
    39         while(s>0) 
     39        while(s>0 && *bp) 
    4040        { 
    4141                bp+=strlen(bp); 
     
    5656        struct dmi_header *dm; 
    5757        u8 *data; 
    58         int i=1; 
     58        int i=0; 
    5959                 
    6060        buf = ioremap(base, len); 
     
    6565 
    6666        /* 
    67          *      Stop when we see al the items the table claimed to have 
     67         *      Stop when we see all the items the table claimed to have 
    6868         *      OR we run off the end of the table (also happens) 
    6969         */ 
    7070  
    71         while(i<num && (data - buf) < len) 
     71        while(i<num && data-buf+sizeof(struct dmi_header)<=len) 
    7272        { 
    7373                dm=(struct dmi_header *)data; 
    74          
    7574                /* 
    76                  *      Avoid misparsing crud if the length of the last 
    77                  *      record is crap  
     75                 *  We want to know the total length (formated area and strings) 
     76                 *  before decoding to make sure we won't run off the table in 
     77                 *  dmi_decode or dmi_string 
    7878                 */ 
    79                 if((data-buf+dm->length) >= len) 
    80                         break; 
    81                 decode(dm);              
    8279                data+=dm->length; 
    83                 /* 
    84                  *      Don't go off the end of the data if there is 
    85                  *      stuff looking like string fill past the end 
    86                  */ 
    87                 while((data-buf) < len && (*data || data[1])) 
     80                while(data-buf<len-1 && (data[0] || data[1])) 
    8881                        data++; 
     82                if(data-buf<len-1) 
     83                        decode(dm); 
    8984                data+=2; 
    9085                i++; 
     
    9590 
    9691 
     92inline static int __init dmi_checksum(u8 *buf) 
     93{ 
     94        u8 sum=0; 
     95        int a; 
     96         
     97        for(a=0; a<15; a++) 
     98                sum+=buf[a]; 
     99        return (sum==0); 
     100} 
     101 
    97102static int __init dmi_iterate(void (*decode)(struct dmi_header *)) 
    98103{ 
    99         unsigned char buf[20]; 
    100         long fp=0xE0000L; 
    101         fp -= 16; 
     104        u8 buf[15]; 
     105        u32 fp=0xF0000; 
    102106 
    103107#ifdef CONFIG_SIMNOW 
     
    111115        while( fp < 0xFFFFF) 
    112116        { 
    113                 fp+=16; 
    114                 isa_memcpy_fromio(buf, fp, 20); 
    115                 if(memcmp(buf, "_DMI_", 5)==0) 
     117                isa_memcpy_fromio(buf, fp, 15); 
     118                if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf)) 
    116119                { 
    117120                        u16 num=buf[13]<<8|buf[12]; 
     
    119122                        u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]; 
    120123 
    121                         dmi_printk((KERN_INFO "DMI %d.%d present.\n", 
    122                                 buf[14]>>4, buf[14]&0x0F)); 
     124                        /* 
     125                         * DMI version 0.0 means that the real version is taken from 
     126                         * the SMBIOS version, which we don't know at this point. 
     127                         */ 
     128                        if(buf[14]!=0) 
     129                                dmi_printk((KERN_INFO "DMI %d.%d present.\n", 
     130                                        buf[14]>>4, buf[14]&0x0F)); 
     131                        else 
     132                                dmi_printk((KERN_INFO "DMI present.\n")); 
    123133                        dmi_printk((KERN_INFO "%d structures occupying %d bytes.\n", 
    124                                 buf[13]<<8|buf[12], 
    125                                 buf[7]<<8|buf[6])); 
     134                                num, len)); 
    126135                        dmi_printk((KERN_INFO "DMI table at 0x%08X.\n", 
    127                                 buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8])); 
     136                                base)); 
    128137                        if(dmi_table(base,len, num, decode)==0) 
    129138                                return 0; 
    130139                } 
     140                fp+=16; 
    131141        } 
    132142        return -1; 
     
    164174{ 
    165175        u8 *data = (u8 *)dm; 
    166         char *p; 
    167176         
    168177        switch(dm->type) 
    169178        { 
    170179                case  0: 
    171                         p=dmi_string(dm,data[4]); 
    172                         if(*p) 
    173                         { 
    174                                 dmi_printk(("BIOS Vendor: %s\n", p)); 
    175                                 dmi_save_ident(dm, DMI_BIOS_VENDOR, 4); 
    176                                 dmi_printk(("BIOS Version: %s\n",  
    177                                         dmi_string(dm, data[5]))); 
    178                                 dmi_save_ident(dm, DMI_BIOS_VERSION, 5); 
    179                                 dmi_printk(("BIOS Release: %s\n", 
    180                                         dmi_string(dm, data[8]))); 
    181                                 dmi_save_ident(dm, DMI_BIOS_DATE, 8); 
    182                         } 
     180                        dmi_printk(("BIOS Vendor: %s\n", 
     181                                dmi_string(dm, data[4]))); 
     182                        dmi_save_ident(dm, DMI_BIOS_VENDOR, 4); 
     183                        dmi_printk(("BIOS Version: %s\n",  
     184                                dmi_string(dm, data[5]))); 
     185                        dmi_save_ident(dm, DMI_BIOS_VERSION, 5); 
     186                        dmi_printk(("BIOS Release: %s\n", 
     187                                dmi_string(dm, data[8]))); 
     188                        dmi_save_ident(dm, DMI_BIOS_DATE, 8); 
    183189                        break; 
    184                          
    185190                case 1: 
    186                         p=dmi_string(dm,data[4]); 
    187                         if(*p) 
    188                         { 
    189                                 dmi_printk(("System Vendor: %s.\n",p)); 
    190                                 dmi_save_ident(dm, DMI_SYS_VENDOR, 4); 
    191                                 dmi_printk(("Product Name: %s.\n", 
    192                                         dmi_string(dm, data[5]))); 
    193                                 dmi_save_ident(dm, DMI_PRODUCT_NAME, 5); 
    194                                 dmi_printk(("Version %s.\n", 
    195                                         dmi_string(dm, data[6]))); 
    196                                 dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6); 
    197                                 dmi_printk(("Serial Number %s.\n", 
    198                                         dmi_string(dm, data[7]))); 
    199                         } 
     191                        dmi_printk(("System Vendor: %s\n", 
     192                                dmi_string(dm, data[4]))); 
     193                        dmi_save_ident(dm, DMI_SYS_VENDOR, 4); 
     194                        dmi_printk(("Product Name: %s\n", 
     195                                dmi_string(dm, data[5]))); 
     196                        dmi_save_ident(dm, DMI_PRODUCT_NAME, 5); 
     197                        dmi_printk(("Version: %s\n", 
     198                                dmi_string(dm, data[6]))); 
     199                        dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6); 
     200                        dmi_printk(("Serial Number: %s\n", 
     201                                dmi_string(dm, data[7]))); 
    200202                        break; 
    201203                case 2: 
    202                         p=dmi_string(dm,data[4]); 
    203                         if(*p) 
    204                         { 
    205                                 dmi_printk(("Board Vendor: %s.\n",p)); 
    206                                 dmi_save_ident(dm, DMI_BOARD_VENDOR, 4); 
    207                                 dmi_printk(("Board Name: %s.\n", 
    208                                         dmi_string(dm, data[5]))); 
    209                                 dmi_save_ident(dm, DMI_BOARD_NAME, 5); 
    210                                 dmi_printk(("Board Version: %s.\n", 
    211                                         dmi_string(dm, data[6]))); 
    212                                 dmi_save_ident(dm, DMI_BOARD_VERSION, 6); 
    213                         } 
    214                         break; 
    215                 case 3: 
    216                         p=dmi_string(dm,data[8]); 
    217                         if(*p && *p!=' ') 
    218                                 dmi_printk(("Asset Tag: %s.\n", p)); 
     204                        dmi_printk(("Board Vendor: %s\n", 
     205                                dmi_string(dm, data[4]))); 
     206                        dmi_save_ident(dm, DMI_BOARD_VENDOR, 4); 
     207                        dmi_printk(("Board Name: %s\n", 
     208                                dmi_string(dm, data[5]))); 
     209                        dmi_save_ident(dm, DMI_BOARD_NAME, 5); 
     210                        dmi_printk(("Board Version: %s\n", 
     211                                dmi_string(dm, data[6]))); 
     212                        dmi_save_ident(dm, DMI_BOARD_VERSION, 6); 
    219213                        break; 
    220214        }