From b18f5bf2db0fba2e7e539f68645836036d940d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 29 Apr 2015 15:44:44 +0200 Subject: Imported Upstream version 2.9.6 --- util/ievents.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 6 deletions(-) (limited to 'util/ievents.c') diff --git a/util/ievents.c b/util/ievents.c index 72c0b24..f0034b2 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.96"; static char *progname = "ievents"; static char fsensdesc = 0; /* 1= get extended sensor descriptions*/ static char fcanonical = 0; /* 1= show canonical, delimited output*/ @@ -193,10 +193,10 @@ static const char *sensor_types[NSTYPES] = { /* 2Eh */ "ME" /* 0xDC == ME Node Manager */ }; -#define NFWERRS 15 +#define NFWERRS 14 static struct { /* See Table 36-3, type 0Fh, offset 00h */ int code; char *msg; - } fwerrs[NFWERRS] = { + } fwerrs[NFWERRS + 1] = { { 0x00, "Unspecified"}, { 0x01, "No system memory"}, { 0x02, "No usable memory"}, @@ -214,10 +214,10 @@ static struct { /* See Table 36-3, type 0Fh, offset 00h */ { 0x0E, "Reserved" } }; -#define NFWSTAT 27 +#define NFWSTAT 26 static struct { /* See Table 36-3, type 0Fh, offset 01h & 02h */ int code; char *msg; - } fwstat[NFWSTAT] = { + } fwstat[NFWSTAT + 1] = { { 0x00, "Unspecified"}, { 0x01, "Memory init"}, { 0x02, "Hard disk init"}, @@ -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) { -- cgit v1.2.3