2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 13:57:41 +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;
switch (type) {
case 4:
print_label(label, 24); print_label(label, 24);
printf("SDRAM DIMM SPD\n"); printf("SDRAM DIMM SPD\n");
} else if(((int) a) == 7) { break;
case 7:
print_label(label, 24); print_label(label, 24);
printf("DDR SDRAM DIMM SPD\n"); printf("DDR SDRAM DIMM SPD\n");
} else if(((int) a) == 17) { break;
case 17:
print_label(label, 24); print_label(label, 24);
printf("RAMBUS RIMM SPD\n"); printf("RAMBUS RIMM SPD\n");
rambus = 1; break;
} else if(((int) a) == 0) { case 0: /* Sony Vaio EEPROM? */
vaio = 1; case 255: /* EDID EEPROM? */
break;
default:
printf("Unknown EEPROM type (%d)\n", type);
free_the_label(&label);
return;
}
} else { } else {
free_the_label(&label); free_the_label(&label);
return; return;
} }
} } else {
} else free_the_label(&label);
printf("ERROR: data 1\n"); printf("ERROR: data 1\n");
return;
}
free_the_label(&label); free_the_label(&label);
if(vaio) { if (type == 0) { /* Sony Vaio EEPROM */
/* first make sure it is a Vaio EEPROM (could still be some ddcmon) */ char buffer[33];
if(!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) &&
!sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) && /* first make sure it is a Sony Vaio EEPROM */
!sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)) { if (!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a)
if(((int) a) != 0 || ((int) b) != 0 || ((int) c) !=0) { && !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b)
/* not a memory chip nor a Vaio EEPROM, so leave */ && !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)) {
if (((int) a) != 0 || ((int) b) != 0 || ((int) c) != 0) {
printf("Unknown EEPROM type (0).\n");
return; return;
} }
} else { } else {
printf("ERROR: data Vaio 2\n"); printf("ERROR: data Vaio 1\n");
return; return;
} }
}
if(vaio) { /* must be a real Sony Vaio EEPROM */
char buffer[33];
memset(buffer, '\0', 33); memset(buffer, '\0', 33);
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_NAME, &label, &valid)
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_NAME, &label,&valid) && && valid) {
valid) { for (i = 0, a = 1; i < 32 && a != 0; i++) /* stop at first zero */
a=1; if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME+i, &a)
for(i=0; i<32 && a!=0; i++) && a != 0)
if(!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME+i, &a) && a!=0) buffer[i] = (char) a;
buffer[i]=(char)a;
print_label(label, 24); print_label(label, 24);
printf("%s\n", buffer); printf("%s\n", buffer);
} else } else
printf("ERROR: data Vaio 1\n"); printf("ERROR: data Vaio 2\n");
free_the_label(&label); free_the_label(&label);
memset(buffer, '\0', 33);
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_SERIAL, &label,&valid) && if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_SERIAL, &label, &valid)
valid) { && valid) {
a=1; for (i = 0, a = 1; i < 32 && a != 0; i++) /* stop at first zero */
for(i=0; i<32 && a!=0; i++) /* stop at first zero */ if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_SERIAL+i, &a)
if(!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_SERIAL+i, &a) && a!=0) && a != 0)
buffer[i]=(char)a; buffer[i] = (char) a;
print_label(label, 24); print_label(label, 24);
printf("%s\n", buffer); printf("%s\n", buffer);
} else } else
printf("ERROR: data Vaio 3\n"); printf("ERROR: data Vaio 3\n");
free_the_label(&label); free_the_label(&label);
return; return;
} }
if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_ROWADDR, &label,&valid) && if (type == 255) { /* EDID EEPROM */
!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) && /* make sure it is an EDID EEPROM */
!sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) && if (!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a)
!sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c) && && !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b)
!sensors_get_feature(*name, SENSORS_EEPROM_BANKS, &d)) { && !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c)
if (valid) { && !sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME, &d)) {
if (((int) a) != 255 || ((int) b) != 255 || ((int) c) != 255
|| ((int) d) != 0)
printf("Unknown EEPROM type (255).\n");
else
/* must be a real EDID EEPROM */
printf("Either use the ddcmon driver instead of the eeprom driver,\n"
"or run the decode-edid script.\n");
} else
printf("ERROR: data EDID\n");
return;
}
/* 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); print_label(label, 24);
if(rambus) { if (type == 17) { /* RAMBUS */
i = (((int) a) & 0x0f) + ((((int) a) & 0xf0) >> 4) + i = (((int) a) & 0x0f) + (((int) a) >> 4) + (((int) c) & 0x07) - 13;
(((int) c) & 0x07) - 13; k = 1;
if(i > 0 && i <= 12) } else { /* SDRAM */
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; i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17;
if(i > 0 && i <= 12 && c <= 8 && d <= 8) if (((int) c) <= 8 && ((int) d) <= 8)
printf("%d\n", (1 << i) * ((int) c) * ((int) d)); k = ((int) c) * ((int) d);
}
if(i > 0 && i <= 12 && k > 0)
printf("%d\n", (1 << i) * k);
else else
{ printf("invalid (%d %d %d %d)\n",
printf("invalid\n"); (int) a, (int) b, (int) c, (int) d);
printf("%d %d %d %d\n", (int) a, (int) b, (int) c, (int) d);
}
}
}
} else } else
printf("ERROR: data 2\n"); printf("ERROR: data 2\n");
free_the_label(&label); free_the_label(&label);
} }
void print_it87(const sensors_chip_name *name) void print_it87(const sensors_chip_name *name)