- Add support for AMC type 17h record.

This commit is contained in:
Jean-Michel Audet 2011-05-17 13:20:06 +00:00
parent eb22beb537
commit 348cd98287

View File

@ -1,34 +1,34 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <ipmitool/ipmi.h>
#include <ipmitool/log.h>
@ -47,14 +47,14 @@
#endif
/*
* Apparently some systems have problems with FRU access greater than 16 bytes
* at a time, even when using byte (not word) access. In order to ensure we
* work with the widest variety of hardware request size is capped at 16 bytes.
* Since this may result in slowdowns on some systems with lots of FRU data you
* can undefine this to enable larger (up to 32 bytes at a time) access.
*
* TODO: make this a command line option
*/
* Apparently some systems have problems with FRU access greater than 16 bytes
* at a time, even when using byte (not word) access. In order to ensure we
* work with the widest variety of hardware request size is capped at 16 bytes.
* Since this may result in slowdowns on some systems with lots of FRU data you
* can undefine this to enable larger (up to 32 bytes at a time) access.
*
* TODO: make this a command line option
*/
#define LIMIT_ALL_REQUEST_SIZE 1
#define FRU_MULTIREC_CHUNK_SIZE (255 + sizeof(struct fru_multirec_header))
@ -89,12 +89,12 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
uint32_t offset, uint32_t length, uint8_t *frubuf);
/* get_fru_area_str - Parse FRU area string from raw data
*
* @data: raw FRU data
* @offset: offset into data for area
*
* returns pointer to FRU area string
*/
*
* @data: raw FRU data
* @offset: offset into data for area
*
* returns pointer to FRU area string
*/
char * get_fru_area_str(uint8_t * data, uint32_t * offset)
{
static const char bcd_plus[] = "0123456789 -.:,_";
@ -192,22 +192,19 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset)
}
/* build_fru_bloc - build fru bloc for write protection
*
* @intf: ipmi interface
* @fru_info: information about FRU device
* @id : Fru id
* @soffset : Source offset (from buffer)
* @doffset : Destination offset (in device)
* @length : Size of data to write (in bytes)
* @pFrubuf : Pointer on data to write
*
* returns 0 on success
* returns -1 on error
*/
*
* @intf: ipmi interface
* @fru_info: information about FRU device
* @id : Fru id
* @soffset : Source offset (from buffer)
* @doffset : Destination offset (in device)
* @length : Size of data to write (in bytes)
* @pFrubuf : Pointer on data to write
*
* returns 0 on success
* returns -1 on error
*/
#define FRU_NUM_BLOC_COMMON_HEADER 6
typedef struct ipmi_fru_bloc
{
@ -474,8 +471,6 @@ build_fru_bloc(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
}
int
write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
uint16_t soffset, uint16_t doffset,
@ -694,17 +689,17 @@ write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
#endif
/* read_fru_area - fill in frubuf[offset:length] from the FRU[offset:length]
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset into buffer
* @length: how much to read
* @frubuf: buffer read into
*
* returns -1 on error
* returns 0 if successful
*/
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset into buffer
* @length: how much to read
* @frubuf: buffer read into
*
* returns -1 on error
* returns 0 if successful
*/
int
read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
uint32_t offset, uint32_t length, uint8_t *frubuf)
@ -799,17 +794,17 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
}
/* read_fru_area - fill in frubuf[offset:length] from the FRU[offset:length]
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset into buffer
* @length: how much to read
* @frubuf: buffer read into
*
* returns -1 on error
* returns 0 if successful
*/
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset into buffer
* @length: how much to read
* @frubuf: buffer read into
*
* returns -1 on error
* returns 0 if successful
*/
int
read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
uint32_t offset, uint32_t length, uint8_t *frubuf)
@ -957,12 +952,12 @@ fru_area_print_multirec_bloc(struct ipmi_intf * intf, struct fru_info * fru,
/* fru_area_print_chassis - Print FRU Chassis Area
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
static void
fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset)
@ -1030,12 +1025,12 @@ fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
}
/* fru_area_print_board - Print FRU Board Area
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
static void
fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset)
@ -1126,12 +1121,12 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
}
/* fru_area_print_product - Print FRU Product Area
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
static void
fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset)
@ -1227,15 +1222,13 @@ fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
free(fru_data);
}
/* fru_area_print_multirec - Print FRU Multi Record Area
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
*
* @intf: ipmi interface
* @fru: fru info
* @id: fru id
* @offset: offset pointer
*/
static void
fru_area_print_multirec(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset)
@ -1427,14 +1420,14 @@ fru_area_print_multirec(struct ipmi_intf * intf, struct fru_info * fru,
}
/* ipmi_fru_query_new_value - Query new values to replace original FRU content
*
* @data: FRU data
* @offset: offset of the bytes to be modified in data
* @len: size of the modified data
*
* returns : TRUE if data changed
* returns : FALSE if data not changed
*/
*
* @data: FRU data
* @offset: offset of the bytes to be modified in data
* @len: size of the modified data
*
* returns : TRUE if data changed
* returns : FALSE if data not changed
*/
int ipmi_fru_query_new_value(uint8_t *data,int offset, size_t len)
{
int status=FALSE;
@ -1472,37 +1465,37 @@ int ipmi_fru_query_new_value(uint8_t *data,int offset, size_t len)
}
/* ipmi_fru_oemkontron_edit -
* Query new values to replace original FRU content
* This is a generic enough to support any type of 'OEM' record
* because the user supplies 'IANA number' , 'record Id' and 'record' version'
*
* However, the parser must have 'apriori' knowledge of the record format
* The currently supported record is :
*
* IANA : 15000 (Kontron)
* RECORD ID : 3
* RECORD VERSION: 0 (or 1)
*
* I would have like to put that stuff in an OEM specific file, but apart for
* the record format information, all commands are really standard 'FRU' command
*
*
* @data: FRU data
* @offset: start of the current multi record (start of header)
* @len: len of the current record (excluding header)
* @h: pointer to record header
* @oh: pointer to OEM /PICMG header
*
* returns: TRUE if data changed
* returns: FALSE if data not changed
*/
* Query new values to replace original FRU content
* This is a generic enough to support any type of 'OEM' record
* because the user supplies 'IANA number' , 'record Id' and 'record' version'
*
* However, the parser must have 'apriori' knowledge of the record format
* The currently supported record is :
*
* IANA : 15000 (Kontron)
* RECORD ID : 3
* RECORD VERSION: 0 (or 1)
*
* I would have like to put that stuff in an OEM specific file, but apart for
* the record format information, all commands are really standard 'FRU' command
*
*
* @data: FRU data
* @offset: start of the current multi record (start of header)
* @len: len of the current record (excluding header)
* @h: pointer to record header
* @oh: pointer to OEM /PICMG header
*
* returns: TRUE if data changed
* returns: FALSE if data not changed
*/
#define OEM_KONTRON_INFORMATION_RECORD 3
#define EDIT_OEM_KONTRON_COMPLETE_ARG_COUNT 12
#define GET_OEM_KONTRON_COMPLETE_ARG_COUNT 5
/*
./src/ipmitool fru edit 0
oem 15000 3 0 name instance FIELD1 FIELD2 FIELD3 crc32
oem 15000 3 0 name instance FIELD1 FIELD2 FIELD3 crc32
*/
#define OEM_KONTRON_SUBCOMMAND_ARG_POS 2
@ -1860,16 +1853,16 @@ static int ipmi_fru_oemkontron_edit( int argc, char ** argv,uint8_t * fru_data,
}
/* ipmi_fru_picmg_ext_edit - Query new values to replace original FRU content
*
* @data: FRU data
* @offset: start of the current multi record (start of header)
* @len: len of the current record (excluding header)
* @h: pointer to record header
* @oh: pointer to OEM /PICMG header
*
* returns: TRUE if data changed
* returns: FALSE if data not changed
*/
*
* @data: FRU data
* @offset: start of the current multi record (start of header)
* @len: len of the current record (excluding header)
* @h: pointer to record header
* @oh: pointer to OEM /PICMG header
*
* returns: TRUE if data changed
* returns: FALSE if data not changed
*/
static int ipmi_fru_picmg_ext_edit(uint8_t * fru_data,
int off,int len,
struct fru_multirec_header *h,
@ -1881,8 +1874,9 @@ static int ipmi_fru_picmg_ext_edit(uint8_t * fru_data,
int length = len;
offset += sizeof(struct fru_multirec_oem_header);
if(oh->record_id == FRU_AMC_ACTIVATION )
switch (oh->record_id)
{
case FRU_AMC_ACTIVATION:
printf(" FRU_AMC_ACTIVATION\n");
{
int index=offset;
@ -1891,14 +1885,14 @@ static int ipmi_fru_picmg_ext_edit(uint8_t * fru_data,
max_current = fru_data[offset];
max_current |= fru_data[++offset]<<8;
printf(" Maximum Internal Current(@12V): %02.2f A (0x%02x)\n",
(float)(max_current) / 10.0f , max_current);
printf(" Maximum Internal Current(@12V): %.2f A (0x%02x)\n",
(float)max_current / 10.0f, max_current);
if( ipmi_fru_query_new_value(fru_data,index,2) ){
max_current = fru_data[index];
max_current |= fru_data[++index]<<8;
printf(" New Maximum Internal Current(@12V): %02.2f A (0x%02x)\n",
(float)(max_current) / 10.0f , max_current);
printf(" New Maximum Internal Current(@12V): %.2f A (0x%02x)\n",
(float)max_current / 10.0f, max_current);
hasChanged = TRUE;
}
@ -1914,11 +1908,35 @@ static int ipmi_fru_picmg_ext_edit(uint8_t * fru_data,
(struct fru_picmgext_activation_record *) &fru_data[offset];
printf(" IPMB-Address: 0x%x\n", a->ibmb_addr);
printf(" Max. Module Current: %i A\n", a->max_module_curr/10);
printf(" Max. Module Current: %.2f A\n", (float)a->max_module_curr / 10.0f);
printf("\n");
}
}
break;
case FRU_AMC_CURRENT:
printf(" FRU_AMC_CURRENT\n");
{
int index=offset;
unsigned char current;
current = fru_data[index];
printf(" Current draw(@12V): %.2f A (0x%02x)\n",
(float)current / 10.0f, current);
if( ipmi_fru_query_new_value(fru_data, index, 1) ){
current = fru_data[index];
printf(" New Current draw(@12V): %.2f A (0x%02x)\n",
(float)current / 10.0f, current);
hasChanged = TRUE;
}
}
break;
}
if( hasChanged ){
uint8_t record_checksum =0;
@ -1951,13 +1969,13 @@ static int ipmi_fru_picmg_ext_edit(uint8_t * fru_data,
}
/* ipmi_fru_picmg_ext_print - prints OEM fru record (PICMG)
*
* @fru_data: FRU data
* @offset: offset of the bytes to be modified in data
* @length: size of the record
*
* returns : n/a
*/
*
* @fru_data: FRU data
* @offset: offset of the bytes to be modified in data
* @length: size of the record
*
* returns : n/a
*/
static void ipmi_fru_picmg_ext_print(uint8_t * fru_data, int off, int length)
{
struct fru_multirec_oem_header *h;
@ -2250,10 +2268,10 @@ static void ipmi_fru_picmg_ext_print(uint8_t * fru_data, int off, int length)
unsigned char current;
printf(" FRU_AMC_CURRENT\n");
//recVersion = fru_data[offset++];
current = fru_data[offset];
printf(" Current draw: %.1f A @ 12V => %.2f Watt\n",
(float) current/10.0, ((float)current/10.0)*12.0);
printf(" Current draw(@12V): %.2f A [ %.2f Watt ]\n",
(float)current / 10.0f,
(float)current / 10.0f * 12.0f);
printf("\n");
}
break;
@ -2266,10 +2284,10 @@ static void ipmi_fru_picmg_ext_print(uint8_t * fru_data, int off, int length)
max_current = fru_data[offset];
max_current |= fru_data[++offset]<<8;
printf(" Maximum Internal Current(@12V): %.2f A [ %.2f Watt ]\n",
(float) max_current / 10,
(float) max_current / 10 * 12);
printf(" Module Activation Readiness: %i sec.\n", fru_data[++offset]);
(float)max_current / 10.0f,
(float)max_current / 10.0f * 12.0f);
printf(" Module Activation Readiness: %i sec.\n", fru_data[++offset]);
printf(" Descriptor Count: %i\n", fru_data[++offset]);
printf("\n");
@ -2279,7 +2297,7 @@ static void ipmi_fru_picmg_ext_print(uint8_t * fru_data, int off, int length)
(struct fru_picmgext_activation_record *) &fru_data[offset];
printf(" IPMB-Address: 0x%x\n", a->ibmb_addr);
printf(" Max. Module Current: %.2f A\n", (float)a->max_module_curr/10);
printf(" Max. Module Current: %.2f A\n", (float)a->max_module_curr / 10.0f);
printf("\n");
}
}
@ -2675,14 +2693,14 @@ static void ipmi_fru_picmg_ext_print(uint8_t * fru_data, int off, int length)
/* __ipmi_fru_print - Do actual work to print a FRU by its ID
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
static int
__ipmi_fru_print(struct ipmi_intf * intf, uint8_t id)
{
@ -2810,12 +2828,12 @@ __ipmi_fru_print(struct ipmi_intf * intf, uint8_t id)
}
/* ipmi_fru_print - Print a FRU from its SDR locator record
*
* @intf: ipmi interface
* @fru: SDR FRU Locator Record
*
* returns -1 on error
*/
*
* @intf: ipmi interface
* @fru: SDR FRU Locator Record
*
* returns -1 on error
*/
int
ipmi_fru_print(struct ipmi_intf * intf, struct sdr_record_fru_locator * fru)
{
@ -2887,11 +2905,11 @@ ipmi_fru_print(struct ipmi_intf * intf, struct sdr_record_fru_locator * fru)
}
/* ipmi_fru_print_all - Print builtin FRU + SDR FRU Locator records
*
* @intf: ipmi interface
*
* returns -1 on error
*/
*
* @intf: ipmi interface
*
* returns -1 on error
*/
static int
ipmi_fru_print_all(struct ipmi_intf * intf)
{
@ -3051,15 +3069,13 @@ ipmi_fru_write_from_bin(struct ipmi_intf * intf,
free(pFruBuf);
}
/* ipmi_fru_edit_multirec - Query new values to replace original FRU content
*
* @intf: interface to use
* @id: FRU id to work on
*
* returns: nothing
*/
*
* @intf: interface to use
* @id: FRU id to work on
*
* returns: nothing
*/
/* Work in progress, copy paste most of the stuff for other functions in this
file ... not elegant yet */
static int
@ -3222,12 +3238,12 @@ ipmi_fru_edit_multirec(struct ipmi_intf * intf, uint8_t id ,
}
/* ipmi_fru_get_multirec - Query new values to replace original FRU content
*
* @intf: interface to use
* @id: FRU id to work on
*
* returns: nothing
*/
*
* @intf: interface to use
* @id: FRU id to work on
*
* returns: nothing
*/
/* Work in progress, copy paste most of the stuff for other functions in this
file ... not elegant yet */
static int
@ -3370,7 +3386,6 @@ ipmi_fru_get_multirec(struct ipmi_intf * intf, uint8_t id ,
return 0;
}
static int
ipmi_fru_upg_ekeying(struct ipmi_intf * intf,
char * pFileName,
@ -3666,16 +3681,15 @@ ipmi_fru_get_multirec_location_from_fru(struct ipmi_intf * intf,
return 0;
}
/* ipmi_fru_get_internal_use_offset - Retreive internal use offset
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
static int
ipmi_fru_get_internal_use_info( struct ipmi_intf * intf,
uint8_t id,
@ -3765,7 +3779,6 @@ ipmi_fru_get_internal_use_info( struct ipmi_intf * intf,
return -1;
}
lprintf(LOG_DEBUG, "fru.header.version: 0x%x",
header.version);
lprintf(LOG_DEBUG, "fru.header.offset.internal: 0x%x",
@ -3812,16 +3825,15 @@ ipmi_fru_get_internal_use_info( struct ipmi_intf * intf,
return 0;
}
/* ipmi_fru_info_internal_use - print internal use info
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
static int
ipmi_fru_info_internal_use(struct ipmi_intf * intf, uint8_t id)
{
@ -3845,16 +3857,15 @@ ipmi_fru_info_internal_use(struct ipmi_intf * intf, uint8_t id)
return 0;
}
/* ipmi_fru_read_internal_use - print internal use are in hex or file
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
static int
ipmi_fru_read_internal_use(struct ipmi_intf * intf, uint8_t id, char * pFileName)
{
@ -3921,14 +3932,14 @@ ipmi_fru_read_internal_use(struct ipmi_intf * intf, uint8_t id, char * pFileName
}
/* ipmi_fru_write_internal_use - print internal use are in hex or file
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
*
* @intf: ipmi interface
* @id: fru id
*
* returns -1 on error
* returns 0 if successful
* returns 1 if device not present
*/
static int
ipmi_fru_write_internal_use(struct ipmi_intf * intf, uint8_t id, char * pFileName)
{
@ -4006,8 +4017,6 @@ ipmi_fru_write_internal_use(struct ipmi_intf * intf, uint8_t id, char * pFileNam
}
int
ipmi_fru_main(struct ipmi_intf * intf, int argc, char ** argv)
{
@ -4209,19 +4218,20 @@ ipmi_fru_main(struct ipmi_intf * intf, int argc, char ** argv)
return rc;
}
/* ipmi_fru_set_field_string - Set a field string to a new value, Need to be the same size. If
* size if not equal, the function ipmi_fru_set_field_string_rebuild
* will be called.
*
* @intf: ipmi interface
* @id: fru id
* @f_type: Type of the Field : c=Chassis b=Board p=Product
* @f_index: findex of the field, zero indexed.
* @f_string: NULL terminated string
*
* returns -1 on error
* returns 1 if successful
*/
* size if not equal, the function ipmi_fru_set_field_string_rebuild
* will be called.
*
* @intf: ipmi interface
* @id: fru id
* @f_type: Type of the Field : c=Chassis b=Board p=Product
* @f_index: findex of the field, zero indexed.
* @f_string: NULL terminated string
*
* returns -1 on error
* returns 1 if successful
*/
static int
ipmi_fru_set_field_string(struct ipmi_intf * intf, uint8_t fruId, uint8_t
f_type, uint8_t f_index, char *f_string)
@ -4413,25 +4423,25 @@ f_type, uint8_t f_index, char *f_string)
Board
*/
/* ipmi_fru_set_field_string_rebuild - Set a field string to a new value, When size are not
* the same size.
*
* This function can update a string within of the following section when the size is not equal:
*
* - Chassis
* - Product
* - Board
*
* @intf: ipmi interface
* @fruId: fru id
* @fru: info about fru
* @header: contain the header of the FRU
* @f_type: Type of the Field : c=Chassis b=Board p=Product
* @f_index: findex of the field, zero indexed.
* @f_string: NULL terminated string
*
* returns -1 on error
* returns 1 if successful
*/
* the same size.
*
* This function can update a string within of the following section when the size is not equal:
*
* - Chassis
* - Product
* - Board
*
* @intf: ipmi interface
* @fruId: fru id
* @fru: info about fru
* @header: contain the header of the FRU
* @f_type: Type of the Field : c=Chassis b=Board p=Product
* @f_index: findex of the field, zero indexed.
* @f_string: NULL terminated string
*
* returns -1 on error
* returns 1 if successful
*/
#define DBG_RESIZE_FRU
static int
@ -4534,7 +4544,6 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
return -1;
}
#ifdef DBG_RESIZE_FRU
printf("Section Length: %lu\n", fru_section_len);
#endif
@ -4703,7 +4712,8 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
(fru_data_old + header_offset + fru_section_len - 1)
-
(fru_data_old + fru_field_offset_tmp + strlen(f_string) + 1)
));
)
);
#endif
memcpy(
@ -4716,7 +4726,6 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
)
);
/* Add Padding if required */
for(counter = 0; counter < padding_len; counter ++)
{