Skip to content

Commit

Permalink
Fix FRU board mfg date and time.
Browse files Browse the repository at this point in the history
VPD data is in BCD format and needs translation.

Resolves #138

Signed-off-by: Jim Yuan <jim.yuan@supermicro.com>
Change-Id: Ib3de6a7cc75876bc04930643c02bfc7734723db5
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/58945
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
  • Loading branch information
jimsmc authored and wghoffa committed May 17, 2018
1 parent 1b81968 commit 01be61c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/usr/ipmi/ipmifruinv.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2014,2017 */
/* Contributors Listed Below - COPYRIGHT 2014,2018 */
/* [+] International Business Machines Corp. */
/* [+] Jim Yuan */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -379,6 +380,11 @@ void IpmiFruInv::setAreaSize(std::vector<uint8_t> &io_data, uint8_t i_offset)
return;
}

static inline uint8_t bcd2_to_int(uint8_t bcd)
{
return ((bcd >> 4) & 0xF) * 10 + (bcd & 0xF);
}

// Function to compute the correct data for the Mfg date/time section.
// IPMI expects the time to be in seconds from 01/01/1996.
errlHndl_t IpmiFruInv::formatMfgData(std::vector<uint8_t> i_mfgDateData,
Expand Down Expand Up @@ -426,12 +432,13 @@ errlHndl_t IpmiFruInv::formatMfgData(std::vector<uint8_t> i_mfgDateData,
// into a uint64 representing number of minute since 1/1/96

// The vpd data is expected to be in this format VVCCYYmmDDHHMMSS
uint8_t century = i_mfgDateData.at(1);
uint8_t year = i_mfgDateData.at(2);
uint8_t month = i_mfgDateData.at(3);
uint8_t day = i_mfgDateData.at(4);
uint8_t hour = i_mfgDateData.at(5);
uint8_t minute = i_mfgDateData.at(6);
// Note that it is Binary Coded Decimal(BCD). Need to translate to int.
uint8_t century = bcd2_to_int(i_mfgDateData.at(1));
uint8_t year = bcd2_to_int(i_mfgDateData.at(2));
uint8_t month = bcd2_to_int(i_mfgDateData.at(3));
uint8_t day = bcd2_to_int(i_mfgDateData.at(4));
uint8_t hour = bcd2_to_int(i_mfgDateData.at(5));
uint8_t minute = bcd2_to_int(i_mfgDateData.at(6));

// Subtract year
uint8_t numOfYears = (century*100 + year) - 1996;
Expand Down

0 comments on commit 01be61c

Please sign in to comment.