summaryrefslogtreecommitdiff
path: root/lib/ipmi_fru.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-05-08 22:59:02 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-05-08 22:59:02 +0200
commit342ebce798fe98ede64939a49bbc3770d8214649 (patch)
treeb55927f05ec0d294ababcb2b4519b7e1a628d5f8 /lib/ipmi_fru.c
parent97d6a2e491c6ed08473beb2c4bac47c5cbc1201a (diff)
Imported Upstream version 1.8.17upstream/1.8.17
Diffstat (limited to 'lib/ipmi_fru.c')
-rw-r--r--lib/ipmi_fru.c65
1 files changed, 25 insertions, 40 deletions
diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
index 40f98e7..5c94b08 100644
--- a/lib/ipmi_fru.c
+++ b/lib/ipmi_fru.c
@@ -50,6 +50,16 @@
#define FRU_MULTIREC_CHUNK_SIZE (255 + sizeof(struct fru_multirec_header))
+/* From lib/dimm_spd.c: */
+int
+ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id);
+
+/* From src/plugins/ipmi_intf.c: */
+void
+ipmi_intf_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size);
+void
+ipmi_intf_set_max_response_data_size(struct ipmi_intf * intf, uint16_t size);
+
extern int verbose;
static void ipmi_fru_read_to_bin(struct ipmi_intf * intf, char * pFileName, uint8_t fruId);
@@ -810,12 +820,11 @@ fru_area_print_multirec_bloc(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset)
{
uint8_t * fru_data = NULL;
- uint32_t fru_len, i;
+ uint32_t i;
struct fru_multirec_header * h;
uint32_t last_off, len;
i = last_off = offset;
- fru_len = 0;
fru_data = malloc(fru->size + 1);
if (fru_data == NULL) {
@@ -1592,7 +1601,6 @@ static void ipmi_fru_oemkontron_get( int argc, char ** argv,uint8_t * fru_data,
printf("Kontron OEM Information Record\n");
version = oh->record_version;
- int blockstart;
uint8_t blockCount;
uint8_t blockIndex=0;
@@ -1613,7 +1621,6 @@ static void ipmi_fru_oemkontron_get( int argc, char ** argv,uint8_t * fru_data,
void * pRecordData;
uint8_t nameLen;
- blockstart = offset;
nameLen = ( fru_data[offset++] &= 0x3F );
printf(" Name: %*.*s\n",nameLen, nameLen, (const char *)(fru_data+offset));
@@ -1743,7 +1750,6 @@ static int ipmi_fru_oemkontron_edit( int argc, char ** argv,uint8_t * fru_data,
version = oh->record_version;
if( version == formatVersion ){
- int blockstart;
uint8_t blockCount;
uint8_t blockIndex=0;
@@ -1765,8 +1771,6 @@ static int ipmi_fru_oemkontron_edit( int argc, char ** argv,uint8_t * fru_data,
void * pRecordData;
uint8_t nameLen;
- blockstart = offset;
-
nameLen = ( fru_data[offset++] & 0x3F );
if( version == 0 || version == 1 )
@@ -3357,6 +3361,9 @@ ipmi_fru_edit_multirec(struct ipmi_intf * intf, uint8_t id ,
retStatus = ipmi_fru_get_multirec_location_from_fru(intf, id, &fruInfo,
&offFruMultiRec,
&fruMultiRecSize);
+ if (retStatus != 0) {
+ return retStatus;
+ }
lprintf(LOG_DEBUG, "FRU Size : %lu\n", fruMultiRecSize);
@@ -3406,14 +3413,13 @@ ipmi_fru_edit_multirec(struct ipmi_intf * intf, uint8_t id ,
{
uint8_t * fru_data;
- uint32_t fru_len, i;
+ uint32_t i;
uint32_t offset= offFruMultiRec;
struct fru_multirec_header * h;
uint32_t last_off, len;
uint8_t error=0;
i = last_off = offset;
- fru_len = 0;
memset(&fru, 0, sizeof(fru));
fru_data = malloc(fru.size + 1);
@@ -3560,6 +3566,9 @@ ipmi_fru_get_multirec(struct ipmi_intf * intf, uint8_t id ,
retStatus = ipmi_fru_get_multirec_location_from_fru(intf, id, &fruInfo,
&offFruMultiRec,
&fruMultiRecSize);
+ if (retStatus != 0) {
+ return retStatus;
+ }
lprintf(LOG_DEBUG, "FRU Size : %lu\n", fruMultiRecSize);
@@ -3609,14 +3618,13 @@ ipmi_fru_get_multirec(struct ipmi_intf * intf, uint8_t id ,
{
uint8_t * fru_data;
- uint32_t fru_len, i;
+ uint32_t i;
uint32_t offset= offFruMultiRec;
struct fru_multirec_header * h;
uint32_t last_off, len;
uint8_t error=0;
i = last_off = offset;
- fru_len = 0;
fru_data = malloc(fru.size + 1);
if (fru_data == NULL) {
@@ -4851,7 +4859,7 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
uint8_t *fru_data_new = NULL;
uint8_t *fru_area = NULL;
uint32_t fru_field_offset, fru_field_offset_tmp;
- uint32_t fru_section_len, old_section_len, header_offset;
+ uint32_t fru_section_len, header_offset;
uint32_t chassis_offset, board_offset, product_offset;
uint32_t chassis_len, board_len, product_len, product_len_new;
int num_byte_change = 0, padding_len = 0;
@@ -4925,9 +4933,6 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
goto ipmi_fru_set_field_string_rebuild_out;
}
- /* Keep length for future old section display */
- old_section_len = fru_section_len;
-
/*************************
3) Seek to field index */
for (i = 0;i <= f_index; i++) {
@@ -5042,6 +5047,11 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
header.offset.product += change_size_by_8;
}
+ if ((f_type == 'c' ) || (f_type == 'b' ) || (f_type == 'p' )) {
+ printf("Change multi offset from %d to %d\n", header.offset.multi, header.offset.multi + change_size_by_8);
+ header.offset.multi += change_size_by_8;
+ }
+
/* Adjust length of the section */
if (f_type == 'c')
{
@@ -5141,31 +5151,6 @@ ipmi_fru_set_field_string_rebuild(struct ipmi_intf * intf, uint8_t fruId,
#ifdef DBG_RESIZE_FRU
printf("Calculate New Checksum: %x\n", (0 - cksum));
#endif
-
- /****** ENABLE to show section modified before and after ********/
- #if 0
- printf("Section: ");
- for( counter = 0; counter <old_section_len; counter ++ )
- {
- if((counter %16) == 0)
- {
- printf("\n");
- }
- printf( "%02X ", *(fru_data_old + header_offset + counter) );
- }
- printf("\n");
-
- printf("Section: ");
- for( counter = 0; counter <fru_section_len; counter ++ )
- {
- if((counter %16) == 0)
- {
- printf("\n");
- }
- printf( "%02X ", *(fru_data_new + header_offset + counter) );
- }
- printf("\n");
- #endif
}
else
{