304
325
rc = sdr_copy_to_sdrr(intf, 1, myaddr, myaddr);
306
327
/* Now fill the SDRR with remote sensors */
307
for (i = 0, slave_addr = 0xB0; i < maxslot; i++, slave_addr += 2) {
308
/* Hole in the PICMG 2.9 mapping */
309
if (slave_addr == 0xC2) slave_addr += 2;
310
if(sdr_copy_to_sdrr(intf, 0, slave_addr, myaddr) < 0)
329
for (i = 0, slave_addr = 0xB0; i < maxslot; i++, slave_addr += 2) {
330
/* Hole in the PICMG 2.9 mapping */
331
if (slave_addr == 0xC2) slave_addr += 2;
332
if(sdr_copy_to_sdrr(intf, 0, slave_addr, myaddr) < 0)
341
int ipmi_hex_to_dec( char * strchar, unsigned char * pDecValue)
344
unsigned char retValue = 0;
347
(strlen(strchar) == 4)
356
if((strchar[2] >= '0') && (strchar[2] <= '9'))
358
retValue += ((strchar[2]-'0') * 16);
360
else if((strchar[2] >= 'a') && (strchar[2] <= 'f'))
362
retValue += (((strchar[2]-'a') + 10) * 16);
364
else if((strchar[2] >= 'A') && (strchar[2] <= 'F'))
366
retValue += (((strchar[2]-'A') + 10) * 16);
373
if((strchar[3] >= '0') && (strchar[3] <= '9'))
375
retValue += ((strchar[3]-'0'));
377
else if((strchar[3] >= 'a') && (strchar[3] <= 'f'))
379
retValue += (((strchar[3]-'a') + 10));
381
else if((strchar[3] >= 'A') && (strchar[3] <= 'F'))
383
retValue += (((strchar[3]-'A') + 10));
393
* pDecValue = retValue;
397
lprintf(LOG_ERR, "Must be Hex value of 4 characters (Ex.: 0x24)\n");
405
#define MAX_NUM_SLOT 128
406
int ipmi_parse_range_list(const char *rangeList, unsigned char * pHexList)
410
unsigned char listOffset = 0;
413
char * inProcessString = (char *) rangeList;
415
/* Discard empty string */
416
if(strlen(rangeList) == 0)
421
/* First, cut to comma separated string */
422
nextString = strstr( rangeList, "," );
424
if(nextString != rangeList)
426
unsigned char isLast;
427
/* We get a valid string so far */
432
if(nextString != NULL)
443
/* At this point, it is a single entry or a range */
444
rangeString = strstr( inProcessString, "-" );
445
if(rangeString == NULL)
447
unsigned char decValue = 0;
450
rc = ipmi_hex_to_dec( inProcessString, &decValue);
454
if((decValue % 2) == 0)
456
pHexList[listOffset++] = decValue;
460
lprintf(LOG_ERR, "I2c address provided value must be even.\n");
466
unsigned char startValue = 0;
467
unsigned char endValue = 0;
470
(*rangeString)= 0; /* Cut string*/
474
rc = ipmi_hex_to_dec( inProcessString, &startValue);
476
rc = ipmi_hex_to_dec( rangeString, &endValue);
480
if(((startValue % 2) == 0) && ((endValue % 2) == 0))
484
pHexList[listOffset++] = startValue;
487
while(startValue != endValue);
488
pHexList[listOffset++] = endValue;
492
lprintf(LOG_ERR, "I2c address provided value must be even.\n");
499
/* Setup for next string */
500
inProcessString = nextString;
501
nextString = strstr( rangeList, "," );
503
}while ((isLast == 0) && (rc == 0));
510
ipmi_sdr_add_from_list(struct ipmi_intf *intf, const char *rangeList)
515
int myaddr = intf->target_addr;
516
unsigned char listValue[MAX_NUM_SLOT];
518
memset( listValue, 0, MAX_NUM_SLOT );
520
/* Build list from string */
521
if(ipmi_parse_range_list(rangeList, listValue) != 0)
523
lprintf(LOG_ERR, "Range - List invalid, cannot be parsed.");
528
unsigned char counter = 0;
529
printf("List to scan: (Built-in) ");
530
while(listValue[counter] != 0)
532
printf("%02x ", listValue[counter]);
538
printf("Clearing SDR Repository\n");
539
if (ipmi_sdr_repo_clear(intf)) {
540
lprintf(LOG_ERR, "Cannot erase SDRR. Give up.");
544
/* First fill the SDRR from local built-in sensors */
545
printf("Sanning built-in sensors..\n");
546
rc = sdr_copy_to_sdrr(intf, 1, myaddr, myaddr);
548
/* Now fill the SDRR with provided sensors list */
550
unsigned char counter = 0;
551
while((rc == 0) && (listValue[counter] != 0))
553
slave_addr = listValue[counter];
554
printf("Scanning %02Xh..\n", slave_addr);
555
if(sdr_copy_to_sdrr(intf, 0, slave_addr, myaddr) < 0)