summaryrefslogtreecommitdiff
path: root/util/ievents.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-08-09 11:42:23 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-08-09 11:42:23 +0200
commit2c088f61bf4d73964e4d73f09412ec74a52e5518 (patch)
tree63f521249dbc05c69c3b05e757882232714a2d8b /util/ievents.c
parent9d9bae11084226b2e1473243d546b149cdf9e5c9 (diff)
changes to version 2.9.4
Diffstat (limited to 'util/ievents.c')
-rw-r--r--util/ievents.c113
1 files changed, 111 insertions, 2 deletions
diff --git a/util/ievents.c b/util/ievents.c
index 72c0b24..cbc7622 100644
--- a/util/ievents.c
+++ b/util/ievents.c
@@ -76,7 +76,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define SELprintf printf
#define SMS_SA 0x41
#define SMI_SA 0x21
-static char *progver = "2.93";
+static char *progver = "2.94";
static char *progname = "ievents";
static char fsensdesc = 0; /* 1= get extended sensor descriptions*/
static char fcanonical = 0; /* 1= show canonical, delimited output*/
@@ -607,6 +607,115 @@ static char *mem_str(int off)
return(pstr);
}
+#ifdef NEW
+#define OEM_CODE_IN_BYTE2 0x80
+#define OEM_CODE_IN_BYTE3 0x20
+static int decode_mem_default(uchar data1, uchar data2, uchar data3,
+ char *desc, int *psz)
+{
+ char tmpdesc[80];
+ int tmpsz = sizeof(tmpdesc);
+ int dsz, incr;
+ if ((psz == NULL) || (desc == NULL)) return -1;
+ dsz = *psz;
+ /*
+ * Based on the above error, we need to find whcih memory slot or
+ * Card has got the Errors/Sel Generated.
+ */
+ if(data1 & OEM_CODE_IN_BYTE2 ) {
+ /* Find the Card Type */
+ if((0x0F != (data2 >> 4)) && ((data2 >> 4) < 0x08))
+ {
+ tmpData = ('A'+ (data2 >> 4));
+ if( (sensor_type == SENSOR_TYPE_MEMORY ) && (0x0B == rec->sel_type.standard_type.event_type) )
+ {
+ snprintf(tmpdesc, tmpsz, "Bad Card %c", tmpData);
+ } else {
+ snprintf(tmpdesc, tmpsz, "Card %c", tmpData);
+ }
+ strcat(desc, tmpdesc);
+ } /* Find the Bank Number of the DIMM */
+ if (0x0F != (data2 & MASK_LOWER_NIBBLE))
+ {
+ if(0x51 == version)
+ {
+ snprintf(tmpdesc, tmpsz, "Bank %d", ((data2 & 0x0F)+1));
+ strcat(desc, tmpdesc);
+ } else {
+ incr = (data2 & 0x0f) << 3;
+ }
+ }
+
+ }
+ /* Find the DIMM Number of the Memory which has Generated the Fault or Sel */
+ if(data1 & OEM_CODE_IN_BYTE3 )
+ {
+ // Based on the IPMI Spec Need Identify the DIMM Details.
+ // For the SPEC 1.5 Only the DIMM Number is Valid.
+ if(0x51 == version)
+ {
+ snprintf(tmpdesc, tmpsz, "DIMM %c", ('A'+ data3));
+ strcat(desc, tmpdesc);
+ }
+ /* For the SPEC 2.0 Decode the DIMM Number as it supports more*/
+ else if( ((data2 >> 4) > 0x07) && (0x0F != (data2 >> 4) ))
+ {
+ strcpy(dimmStr, " DIMM");
+ str = desc+strlen(desc);
+ dimmsPerNode = 4;
+ if(0x09 == (data2 >> 4)) dimmsPerNode = 6;
+ else if(0x0A == (data2 >> 4)) dimmsPerNode = 8;
+ else if(0x0B == (data2 >> 4)) dimmsPerNode = 9;
+ else if(0x0C == (data2 >> 4)) dimmsPerNode = 12;
+ else if(0x0D == (data2 >> 4)) dimmsPerNode = 24;
+ else if(0x0E == (data2 >> 4)) dimmsPerNode = 3;
+ count = 0;
+ for (i = 0; i < 8; i++)
+ {
+ if (BIT(i) & data3)
+ {
+ if(count)
+ {
+ strcat(str,",");
+ count = 0x00;
+ }
+ node = (incr + i)/dimmsPerNode;
+ dimmNum = ((incr + i)%dimmsPerNode)+1;
+ dimmStr[5] = node + 'A';
+ sprintf(tmpdesc,"%d",dimmNum);
+ for(j = 0; j < strlen(tmpdesc);j++)
+ dimmStr[6+j] = tmpdesc[j];
+ dimmStr[6+j] = '\0';
+ strcat(str,dimmStr); // final DIMM Details.
+ count++;
+ }
+ }
+ } else {
+ strcpy(dimmStr, " DIMM");
+ str = desc+strlen(desc);
+ count = 0;
+ for (i = 0; i < 8; i++)
+ {
+ if (BIT(i) & data3)
+ {
+ // check if more than one DIMM, if so add a comma to the string.
+ sprintf(tmpdesc,"%d",(i + incr + 1));
+ if(count)
+ {
+ strcat(str,",");
+ count = 0x00;
+ }
+ for(j = 0; j < strlen(tmpdesc);j++)
+ dimmStr[5+j] = tmpdesc[j];
+ dimmStr[5+j] = '\0';
+ strcat(str, dimmStr);
+ count++;
+ }
+ }
+ }
+ }
+}
+#endif
#if defined(METACOMMAND)
/* METACOMMAND is defined for ipmiutil meta-command build. */
@@ -974,7 +1083,7 @@ int file_grep(char *fname, char *pattn, char *line, int sline,
int nstart = 0;
int bufsz;
- if (bmode == 2) nstart = *nret;
+ if ((bmode == 2) && (nret != NULL)) nstart = *nret;
bufsz = sizeof(buff);
fp = fopen(fname,"r");
if (fp == NULL) {