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