2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 05:48:07 +00:00

Rewrote print_eeprom().

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1884 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare 2003-07-17 16:41:12 +00:00
parent 3efe48f865
commit b3528cbdbc

View File

@ -1,7 +1,7 @@
/* /*
chips.c - Part of sensors, a user-space program for hardware monitoring chips.c - Part of sensors, a user-space program for hardware monitoring
Copyright (c) 1998, 1999, 2001 Frodo Looijaard <frodol@dds.nl> Copyright (c) 1998-2003 Frodo Looijaard <frodol@dds.nl>, Mark D.
and Mark D. Studebaker <mdsxyz123@yahoo.com> Studebaker <mdsxyz123@yahoo.com> and the lm_sensors team
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -2705,114 +2705,140 @@ void print_ddcmon(const sensors_chip_name *name)
} }
/*
* (Khali, 2003-07-17) Almost entierly rewritten. Reindented for clarity,
* simplified at some places, added support for EDID EEPROMs (well,
* redirection more than support).
*/
void print_eeprom(const sensors_chip_name *name) void print_eeprom(const sensors_chip_name *name)
{ {
char *label = NULL; char *label = NULL;
double a, b, c, d; double a, b, c, d;
int valid, i, rambus=0, vaio=0; int valid, i, type;
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_TYPE, &label,&valid) && if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_TYPE, &label, &valid)
!sensors_get_feature(*name, SENSORS_EEPROM_TYPE, &a)) { && !sensors_get_feature(*name, SENSORS_EEPROM_TYPE, &a)) {
if (valid) { if (valid) {
if(((int) a) == 4) { type = (int) a;
print_label(label, 24); switch (type) {
printf("SDRAM DIMM SPD\n"); case 4:
} else if(((int) a) == 7) { print_label(label, 24);
print_label(label, 24); printf("SDRAM DIMM SPD\n");
printf("DDR SDRAM DIMM SPD\n"); break;
} else if(((int) a) == 17) { case 7:
print_label(label, 24); print_label(label, 24);
printf("RAMBUS RIMM SPD\n"); printf("DDR SDRAM DIMM SPD\n");
rambus = 1; break;
} else if(((int) a) == 0) { case 17:
vaio = 1; print_label(label, 24);
printf("RAMBUS RIMM SPD\n");
break;
case 0: /* Sony Vaio EEPROM? */
case 255: /* EDID EEPROM? */
break;
default:
printf("Unknown EEPROM type (%d)\n", type);
free_the_label(&label);
return;
}
} else {
free_the_label(&label);
return;
}
} else { } else {
free_the_label(&label); free_the_label(&label);
return; printf("ERROR: data 1\n");
return;
} }
} free_the_label(&label);
} else
printf("ERROR: data 1\n"); if (type == 0) { /* Sony Vaio EEPROM */
free_the_label(&label); char buffer[33];
if(vaio) { /* first make sure it is a Sony Vaio EEPROM */
/* first make sure it is a Vaio EEPROM (could still be some ddcmon) */ if (!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a)
if(!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) && && !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b)
!sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) && && !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)) {
!sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)) { if (((int) a) != 0 || ((int) b) != 0 || ((int) c) != 0) {
if(((int) a) != 0 || ((int) b) != 0 || ((int) c) !=0) { printf("Unknown EEPROM type (0).\n");
/* not a memory chip nor a Vaio EEPROM, so leave */ return;
return; }
} else {
printf("ERROR: data Vaio 1\n");
return;
}
/* must be a real Sony Vaio EEPROM */
memset(buffer, '\0', 33);
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_NAME, &label, &valid)
&& valid) {
for (i = 0, a = 1; i < 32 && a != 0; i++) /* stop at first zero */
if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME+i, &a)
&& a != 0)
buffer[i] = (char) a;
print_label(label, 24);
printf("%s\n", buffer);
} else
printf("ERROR: data Vaio 2\n");
free_the_label(&label);
memset(buffer, '\0', 33);
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_SERIAL, &label, &valid)
&& valid) {
for (i = 0, a = 1; i < 32 && a != 0; i++) /* stop at first zero */
if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_SERIAL+i, &a)
&& a != 0)
buffer[i] = (char) a;
print_label(label, 24);
printf("%s\n", buffer);
} else
printf("ERROR: data Vaio 3\n");
free_the_label(&label);
return;
} }
} else {
printf("ERROR: data Vaio 2\n");
return;
}
}
if(vaio) { if (type == 255) { /* EDID EEPROM */
char buffer[33]; /* make sure it is an EDID EEPROM */
memset(buffer, '\0', 33); if (!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a)
&& !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b)
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_NAME, &label,&valid) && && !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)
valid) { && !sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME, &d)) {
a=1; if (((int) a) != 255 || ((int) b) != 255 || ((int) c) != 255
for(i=0; i<32 && a!=0; i++) || ((int) d) != 0)
if(!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME+i, &a) && a!=0) printf("Unknown EEPROM type (255).\n");
buffer[i]=(char)a; else
print_label(label, 24); /* must be a real EDID EEPROM */
printf("%s\n", buffer); printf("Either use the ddcmon driver instead of the eeprom driver,\n"
} else "or run the decode-edid script.\n");
printf("ERROR: data Vaio 1\n"); } else
free_the_label(&label); printf("ERROR: data EDID\n");
return;
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_SERIAL, &label,&valid) && }
valid) {
a=1;
for(i=0; i<32 && a!=0; i++) /* stop at first zero */
if(!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_SERIAL+i, &a) && a!=0)
buffer[i]=(char)a;
print_label(label, 24);
printf("%s\n", buffer);
} else
printf("ERROR: data Vaio 3\n");
free_the_label(&label);
return;
}
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_ROWADDR, &label,&valid) &&
!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) &&
!sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) &&
!sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c) &&
!sensors_get_feature(*name, SENSORS_EEPROM_BANKS, &d)) {
if (valid) {
print_label(label, 24);
if(rambus) {
i = (((int) a) & 0x0f) + ((((int) a) & 0xf0) >> 4) +
(((int) c) & 0x07) - 13;
if(i > 0 && i <= 12)
printf("%d\n", (1 << i));
else
{
printf("invalid\n");
printf("%d %d %d %d\n", (int) a, (int) b, (int) c, (int) d);
}
} else {
i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17;
if(i > 0 && i <= 12 && c <= 8 && d <= 8)
printf("%d\n", (1 << i) * ((int) c) * ((int) d));
else
{
printf("invalid\n");
printf("%d %d %d %d\n", (int) a, (int) b, (int) c, (int) d);
}
}
}
} else
printf("ERROR: data 2\n");
free_the_label(&label);
/* regular memory chips */
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_ROWADDR, &label, &valid)
&& !sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a)
&& !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b)
&& !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)
&& !sensors_get_feature(*name, SENSORS_EEPROM_BANKS, &d)
&& valid) {
int k = 0; /* multiplier, 0 if invalid */
print_label(label, 24);
if (type == 17) { /* RAMBUS */
i = (((int) a) & 0x0f) + (((int) a) >> 4) + (((int) c) & 0x07) - 13;
k = 1;
} else { /* SDRAM */
i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17;
if (((int) c) <= 8 && ((int) d) <= 8)
k = ((int) c) * ((int) d);
}
if(i > 0 && i <= 12 && k > 0)
printf("%d\n", (1 << i) * k);
else
printf("invalid (%d %d %d %d)\n",
(int) a, (int) b, (int) c, (int) d);
} else
printf("ERROR: data 2\n");
free_the_label(&label);
} }
void print_it87(const sensors_chip_name *name) void print_it87(const sensors_chip_name *name)