From db735bf6850285d491927199dfd50540975950e8 Mon Sep 17 00:00:00 2001 From: Francois Isabelle Date: Fri, 14 Sep 2007 19:50:14 +0000 Subject: [PATCH] SPD support: added additionnal parameters to allow specifying 'channel number' as well as maximum 'read size', since some SMI or IPMB channels can't support 64 bytes. this should be fully backward compatible as options are optionnal and a the end of the original ones: usage: spd [channel] [maxread] --- ipmitool/lib/ipmi_raw.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ipmitool/lib/ipmi_raw.c b/ipmitool/lib/ipmi_raw.c index e97eabf..13fb03c 100644 --- a/ipmitool/lib/ipmi_raw.c +++ b/ipmitool/lib/ipmi_raw.c @@ -133,6 +133,8 @@ int ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv) { struct ipmi_rs *rsp; + uint8_t msize = IPMI_I2C_MASTER_MAX_SIZE; /* allow to override default */ + uint8_t channel = 0; uint8_t i2cbus = 0; uint8_t i2caddr = 0; uint8_t spd_data[RAW_SPD_SIZE]; @@ -141,24 +143,30 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv) memset(spd_data, 0, RAW_SPD_SIZE); if (argc < 2 || strncmp(argv[0], "help", 4) == 0) { - lprintf(LOG_NOTICE, "usage: spd "); + lprintf(LOG_NOTICE, "usage: spd [channel] [maxread]"); return 0; } - i2cbus = (uint8_t)strtoul(argv[0], NULL, 0); - i2caddr = (uint8_t)strtoul(argv[1], NULL, 0); + i2cbus = (uint8_t)strtoul(argv[0], NULL, 0); + i2caddr = (uint8_t)strtoul(argv[1], NULL, 0); + if( argc >= 3 ){ + channel = (uint8_t)strtoul(argv[2], NULL, 0); + } + if( argc >= 4 ){ + msize = (uint8_t)strtoul(argv[3], NULL, 0); + } - i2cbus = ((i2cbus & 7) << 1) | 1; + i2cbus = ((channel & 0xF) << 4) | ((i2cbus & 7) << 1) | 1; - for (i = 0; i < RAW_SPD_SIZE; i+= IPMI_I2C_MASTER_MAX_SIZE) { + for (i = 0; i < RAW_SPD_SIZE; i+= msize) { rsp = ipmi_master_write_read(intf, i2cbus, i2caddr, - (uint8_t *)&i, 1, IPMI_I2C_MASTER_MAX_SIZE); + (uint8_t *)&i, 1, msize ); if (rsp == NULL) { lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read"); return -1; } - memcpy(spd_data+i, rsp->data, IPMI_I2C_MASTER_MAX_SIZE); + memcpy(spd_data+i, rsp->data, msize); } ipmi_spd_print(spd_data, i);