diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2018-01-31 21:41:45 +0530 |
---|---|---|
committer | Ratan Gupta <ratagupt@in.ibm.com> | 2018-02-13 10:59:45 +0530 |
commit | 6edfc5c16cfe85e7c50a3574e3d6ef81b1895ad4 (patch) | |
tree | 6ad37f5effef9cc084efb0405dbe728bc095b99a /ipmi_fru_info_area.cpp | |
parent | 2f66f00ed7889499e85eb44a2f73c003d25092bf (diff) | |
download | phosphor-host-ipmid-6edfc5c16cfe85e7c50a3574e3d6ef81b1895ad4.tar.gz phosphor-host-ipmid-6edfc5c16cfe85e7c50a3574e3d6ef81b1895ad4.zip |
FRU: Change the type code to ASCII
In board and product area format there is type and length
field for each field.
6-7 bit of typelength field specifies the type and first
five bits specify the length.a
eg:- Board Manufacturer type/length byte followed by actual
number of bytes defined in first five bits of type length
of Board Manufacturer field.
Change-Id: Iaaf608cc93829fb1dd8d0c54a49bd467a7cadbea
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'ipmi_fru_info_area.cpp')
-rw-r--r-- | ipmi_fru_info_area.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ipmi_fru_info_area.cpp b/ipmi_fru_info_area.cpp index 24b8f0b..64fa222 100644 --- a/ipmi_fru_info_area.cpp +++ b/ipmi_fru_info_area.cpp @@ -33,6 +33,8 @@ static constexpr auto endOfCustomFields = 0xC1; static constexpr auto commonHeaderFormatSize = 0x8; //size in bytes static constexpr auto manufacturingDateSize = 0x3; static constexpr auto areaSizeOffset = 0x1; +static constexpr uint8_t typeASCII = 0xC0; +static constexpr auto maxRecordAttributeValue = 0x1F; /** * @brief Format Beginning of Individual IPMI FRU Data Section @@ -120,8 +122,19 @@ void appendData(const Property& key, const PropertyMap& propMap, { value.erase(0, 2); } - data.emplace_back(value.length()); - std::copy(value.begin(), value.end(), std::back_inserter(data)); + + // 5 bits for length + // if length is greater then 31(2^5) bytes then trim the data to 31 bytess. + auto valueLength = (value.length() > maxRecordAttributeValue) ? + maxRecordAttributeValue : value.length(); + // 2 bits for type + // Set the type to ascii + uint8_t typeLength = valueLength | ipmi::fru::typeASCII; + + data.emplace_back(typeLength); + std::copy(value.begin(), + value.begin() + valueLength, + std::back_inserter(data)); } else { |