mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-01-22 06:12:19 +08:00
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 <i2cbus> <i2caddr> [channel] [maxread]
This commit is contained in:
parent
7959b894b4
commit
db735bf685
@ -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 <i2cbus> <i2caddr>");
|
||||
lprintf(LOG_NOTICE, "usage: spd <i2cbus> <i2caddr> [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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user