mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-29 05:17:50 +00:00
Upadted dmidecode to version 1.4
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1488 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
parent
ab9060943d
commit
359b15a603
@ -1,12 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
* DMI decode rev 1.2
|
* DMI decode rev 1.4
|
||||||
*
|
*
|
||||||
* (C) 2000,2001 Alan Cox <alan@redhat.com>
|
* (C) 2000,2001 Alan Cox <alan@redhat.com>
|
||||||
*
|
*
|
||||||
* 2-July-2001 Matt Domsch <Matt_Domsch@dell.com>
|
* 2-July-2001 Matt Domsch <Matt_Domsch@dell.com>
|
||||||
* Additional structures displayed per SMBIOS 2.3.1 spec
|
* Additional structures displayed per SMBIOS 2.3.1 spec
|
||||||
*
|
*
|
||||||
* 8/3/02 Enhanced and incorporated in lm_sensors 2.6.5
|
* 13-December-2001 Arjan van de Ven <arjanv@redhat.com>
|
||||||
|
* Fix memory bank type (DMI case 6)
|
||||||
|
*
|
||||||
|
* 3-August-2002 Mark D. Studebaker <mds@paradyne.com>
|
||||||
|
* Better indent in dump_raw_data
|
||||||
|
* Fix return value in dmi_bus_name
|
||||||
|
* Additional sensor fields decoded
|
||||||
|
* Fix compilation warnings
|
||||||
|
*
|
||||||
|
* 6-August-2002 Jean Delvare <khali@linux-fr.org>
|
||||||
|
* Reposition file pointer after DMI table display
|
||||||
|
* Disable first RSD PTR checksum (was not correct anyway)
|
||||||
|
* Show actual DMI struct count and occupied size
|
||||||
|
* Check for NULL after malloc
|
||||||
|
* Use SEEK_* constants instead of numeric values
|
||||||
|
* Code optimization (and warning fix) in DMI cases 10 and 14
|
||||||
|
* Add else's to avoid unneeded cascaded if's in main loop
|
||||||
|
* Code optimization in DMI information display
|
||||||
|
* Fix all compilation warnings
|
||||||
|
*
|
||||||
|
* 9-August-2002 Jean Delvare <khali@linux-fr.org>
|
||||||
|
* Better DMI struct count/size error display
|
||||||
|
* More careful memory access in dmi_table
|
||||||
|
* DMI case 13 (Language) decoded
|
||||||
|
* C++ style comments removed
|
||||||
|
* Commented out code removed
|
||||||
|
* DMI 0.0 case handled
|
||||||
|
* Fix return value in dmi_port_type and dmi_port_connector_type
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Public license. If you want to use it in with
|
* Licensed under the GNU Public license. If you want to use it in with
|
||||||
* another license just ask.
|
* another license just ask.
|
||||||
@ -298,12 +325,16 @@ const char *dmi_port_connector_type(u8 code)
|
|||||||
if(code == 0xFF)
|
if(code == 0xFF)
|
||||||
return "Other";
|
return "Other";
|
||||||
|
|
||||||
if (code > 0xA4)
|
if(code <= 0x21)
|
||||||
return "";
|
return connector_type[code];
|
||||||
return connector_type[code];
|
|
||||||
|
|
||||||
|
if((code >= 0xA0) && (code <= 0xA4))
|
||||||
|
return connector_type[code-0xA0+0x22];
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *dmi_port_type(u8 code)
|
const char *dmi_port_type(u8 code)
|
||||||
{
|
{
|
||||||
static const char *port_type[]={
|
static const char *port_type[]={
|
||||||
@ -346,10 +377,13 @@ const char *dmi_port_type(u8 code)
|
|||||||
if(code == 0xFF)
|
if(code == 0xFF)
|
||||||
return "Other";
|
return "Other";
|
||||||
|
|
||||||
if (code > 0xA1)
|
if (code <= 0x1F)
|
||||||
return "";
|
return port_type[code];
|
||||||
return port_type[code];
|
|
||||||
|
|
||||||
|
if ((code >= 0xA0) && (code <= 0xA1))
|
||||||
|
return port_type[code-0xA0+0x20];
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dmi_processor_type(u8 code)
|
const char *dmi_processor_type(u8 code)
|
||||||
@ -611,7 +645,12 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
u8 *data;
|
u8 *data;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
if(lseek(fd, (long)base, 0)==-1)
|
if(buf==NULL)
|
||||||
|
{
|
||||||
|
perror("dmi: malloc");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(lseek(fd, (long)base, SEEK_SET)==-1)
|
||||||
{
|
{
|
||||||
perror("dmi: lseek");
|
perror("dmi: lseek");
|
||||||
return;
|
return;
|
||||||
@ -622,15 +661,21 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data = buf;
|
data = buf;
|
||||||
while(i<num)
|
while(data+sizeof(struct dmi_header)<=(u8*)buf+len)
|
||||||
{
|
{
|
||||||
u32 u;
|
u32 u, u2;
|
||||||
u32 u2;
|
|
||||||
dm=(struct dmi_header *)data;
|
dm=(struct dmi_header *)data;
|
||||||
printf("Handle 0x%04X\n\tDMI type %d, %d bytes.\n",
|
printf("Handle 0x%04X\n\tDMI type %d, %d bytes.\n",
|
||||||
dm->handle,
|
dm->handle,
|
||||||
dm->type, dm->length);
|
dm->type, dm->length);
|
||||||
|
|
||||||
|
/* we won't read beyond allocated memory */
|
||||||
|
if(data+dm->length>(u8*)buf+len)
|
||||||
|
{
|
||||||
|
printf("\tIncomplete structure, abort decoding.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch(dm->type)
|
switch(dm->type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -734,7 +779,7 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
if(data[6])
|
if(data[6])
|
||||||
printf("\t\tSpeed: %dnS\n", data[6]);
|
printf("\t\tSpeed: %dnS\n", data[6]);
|
||||||
printf("\t\tType: ");
|
printf("\t\tType: ");
|
||||||
dmi_decode_ram(data[7]);
|
dmi_decode_ram(data[8]<<8|data[7]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("\t\tInstalled Size: ");
|
printf("\t\tInstalled Size: ");
|
||||||
switch(data[9]&0x7F)
|
switch(data[9]&0x7F)
|
||||||
@ -842,13 +887,13 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
printf("\tOn Board Devices Information\n");
|
printf("\tOn Board Devices Information\n");
|
||||||
for (u=0; u<((dm->length - 4)/2); u++) {
|
for (u=2; u*2+1<dm->length; u++) {
|
||||||
printf("\t\tDescription: %s : %s\n",
|
printf("\t\tDescription: %s : %s\n",
|
||||||
dmi_string(dm, data[5+(2*u)]),
|
dmi_string(dm, data[1+2*u]),
|
||||||
(data[4+(2*u)]) & 0x80 ?
|
(data[2*u]) & 0x80 ?
|
||||||
"Enabled" : "Disabled");
|
"Enabled" : "Disabled");
|
||||||
printf("\t\tType: %s\n",
|
printf("\t\tType: %s\n",
|
||||||
dmi_onboard_type(data[4+(2*u)]));
|
dmi_onboard_type(data[2*u]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,11 +913,16 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
|
|
||||||
case 13:
|
case 13:
|
||||||
printf("\tBIOS Language Information\n");
|
printf("\tBIOS Language Information\n");
|
||||||
|
printf("\t\tInstallable Languages: %u\n", data[4]);
|
||||||
|
for (u=1; u<=data[4]; u++) {
|
||||||
|
printf("\t\t\t%s\n", dmi_string(dm,u));
|
||||||
|
}
|
||||||
|
printf("\t\tCurrently Installed Language: %s\n", dmi_string(dm, data[21]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 14:
|
case 14:
|
||||||
printf("\tGroup Associations\n");
|
printf("\tGroup Associations\n");
|
||||||
for (u=0; u<(dm->length - 5)/3 ; u++) {
|
for (u=0; 3*u+7<dm->length; u++) {
|
||||||
printf("\t\tGroup Name: %s\n",
|
printf("\t\tGroup Name: %s\n",
|
||||||
dmi_string(dm,data[4]));
|
dmi_string(dm,data[4]));
|
||||||
printf("\t\t\tType: 0x%02x\n", *(data+5+(u*3)));
|
printf("\t\t\tType: 0x%02x\n", *(data+5+(u*3)));
|
||||||
@ -882,21 +932,21 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 15:
|
case 15:
|
||||||
printf("\tEvent Log\n");
|
printf("\tEvent Log\n");
|
||||||
printf("\t\tLog Area: %d bytes.\n",
|
printf("\t\tLog Area: %d bytes.\n",
|
||||||
data[5]<<8|data[4]);
|
data[5]<<8|data[4]);
|
||||||
printf("\t\tLog Header At: %d.\n",
|
printf("\t\tLog Header At: %d.\n",
|
||||||
data[7]<<8|data[6]);
|
data[7]<<8|data[6]);
|
||||||
printf("\t\tLog Data At: %d.\n",
|
printf("\t\tLog Data At: %d.\n",
|
||||||
data[9]<<8|data[8]);
|
data[9]<<8|data[8]);
|
||||||
printf("\t\tLog Type: %d.\n",
|
printf("\t\tLog Type: %d.\n",
|
||||||
data[10]);
|
data[10]);
|
||||||
if(data[11]&(1<<0))
|
if(data[11]&(1<<0))
|
||||||
printf("\t\tLog Valid: Yes.\n");
|
printf("\t\tLog Valid: Yes.\n");
|
||||||
if(data[11]&(1<<1))
|
if(data[11]&(1<<1))
|
||||||
printf("\t\t**Log Is Full**.\n");
|
printf("\t\t**Log Is Full**.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
printf("\tPhysical Memory Array\n");
|
printf("\tPhysical Memory Array\n");
|
||||||
@ -1087,27 +1137,32 @@ static void dmi_table(int fd, u32 base, int len, int num)
|
|||||||
data+=2;
|
data+=2;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if(i!=num)
|
||||||
|
{
|
||||||
|
printf("Wrong DMI structures count: %d announced, %d decoded.\n", num, i);
|
||||||
|
}
|
||||||
|
if(data-(u8*)buf!=len)
|
||||||
|
{
|
||||||
|
printf("Wrong DMI structures length: %d bytes announced, %d bytes decoded.\n", len, data-(u8*)buf);
|
||||||
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char key[8]={'R','S','D',' ','P','T','R',' '};
|
int main(void)
|
||||||
|
|
||||||
char zot[16];
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
unsigned char buf[20];
|
unsigned char buf[20];
|
||||||
int fd=open("/dev/mem", O_RDONLY);
|
int fd=open("/dev/mem", O_RDONLY);
|
||||||
long fp=0xE0000L;
|
long fp=0xE0000L;
|
||||||
|
u8 smmajver=0, smminver=0;
|
||||||
if(fd==-1)
|
if(fd==-1)
|
||||||
{
|
{
|
||||||
perror("/dev/mem");
|
perror("/dev/mem");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(lseek(fd,fp,0)==-1)
|
if(lseek(fd, fp, SEEK_SET)==-1)
|
||||||
{
|
{
|
||||||
perror("seek");
|
perror("lseek");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1119,41 +1174,34 @@ int main(int argc, char *argv[])
|
|||||||
fp+=16;
|
fp+=16;
|
||||||
if(read(fd, buf, 16)!=16)
|
if(read(fd, buf, 16)!=16)
|
||||||
perror("read");
|
perror("read");
|
||||||
// if(memcmp(buf, zot, 16)==0)
|
else if(memcmp(buf, "_SM_", 4)==0)
|
||||||
// printf("*");
|
printf("SMBIOS %d.%d present.\n", smmajver=buf[6], smminver=buf[7]);
|
||||||
if(memcmp(buf, "_SM_", 4)==0) {
|
else if(memcmp(buf, "_SYSID_", 7)==0)
|
||||||
printf("SMBIOS %d.%d present.\n", buf[6], buf[7]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(memcmp(buf, "_SYSID_", 7)==0)
|
|
||||||
printf("SYSID present.\n");
|
printf("SYSID present.\n");
|
||||||
if(memcmp(buf, "_DMI_", 5)==0)
|
else if(memcmp(buf, "_DMI_", 5)==0)
|
||||||
{
|
{
|
||||||
u16 num=buf[13]<<8|buf[12];
|
u16 num=buf[13]<<8|buf[12];
|
||||||
u16 len=buf[7]<<8|buf[6];
|
u16 len=buf[7]<<8|buf[6];
|
||||||
u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
|
u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
|
||||||
|
|
||||||
printf("DMI %d.%d present.\n",
|
printf("DMI %d.%d present.\n",
|
||||||
buf[14]>>4, buf[14]&0x0F);
|
buf[14]?buf[14]>>4:smmajver, buf[14]?buf[14]&0x0F:smminver);
|
||||||
printf("%d structures occupying %d bytes.\n",
|
printf("%d structures occupying %d bytes.\n",
|
||||||
buf[13]<<8|buf[12],
|
num, len);
|
||||||
buf[7]<<8|buf[6]);
|
|
||||||
printf("DMI table at 0x%08X.\n",
|
printf("DMI table at 0x%08X.\n",
|
||||||
buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]);
|
base);
|
||||||
dmi_table(fd, base,len, num);
|
dmi_table(fd, base, len, num);
|
||||||
|
|
||||||
|
/* dmi_table moved us far away */
|
||||||
|
lseek(fd, fp+16, SEEK_SET);
|
||||||
}
|
}
|
||||||
if(memcmp(buf, "$PnP", 4)==0)
|
else if(memcmp(buf, "$PnP", 4)==0)
|
||||||
printf("PNP BIOS present.\n");
|
printf("PNP BIOS present.\n");
|
||||||
if(memcmp(buf, key, 8)==0)
|
else if(memcmp(buf, "RSD PTR ", 8)==0)
|
||||||
{
|
{
|
||||||
int a;
|
int a;
|
||||||
unsigned char sum=0;
|
unsigned char sum=0;
|
||||||
unsigned int i=0, checksum=0;
|
printf("RSD PTR found at 0x%lX.\n", fp);
|
||||||
printf("RSD PTR found at 0x%lX\n", fp);
|
|
||||||
for (i=0; i<20; i++) checksum += buf[i];
|
|
||||||
if (checksum != 0) {
|
|
||||||
printf("checksum failed.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(buf[15]!=0)
|
if(buf[15]!=0)
|
||||||
{
|
{
|
||||||
@ -1163,7 +1211,7 @@ int main(int argc, char *argv[])
|
|||||||
fwrite(buf+9, 6, 1, stdout);
|
fwrite(buf+9, 6, 1, stdout);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
read(fd,buf+16,4);
|
read(fd,buf+16,4);
|
||||||
lseek(fd, -4, 1);
|
lseek(fd, -4, SEEK_CUR);
|
||||||
for(a=0;a<20;a++)
|
for(a=0;a<20;a++)
|
||||||
sum+=buf[a];
|
sum+=buf[a];
|
||||||
if(sum!=0)
|
if(sum!=0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user