summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2017-06-01 19:00:43 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-06-02 15:13:42 +0000
commitaeb726df2fb7e0a3510242337c79994592ed1523 (patch)
tree2229e8343191c2c1d80159198b5d1105e83fd3cf
parent5098b03916fd7a90605b6e3774ee536ef9108a94 (diff)
downloadipmi-fru-parser-aeb726df2fb7e0a3510242337c79994592ed1523.zip
ipmi-fru-parser-aeb726df2fb7e0a3510242337c79994592ed1523.tar.gz
fru_gen: reduce map in generated data
Eliminate one level of the generated "frus" map by creating a structure for the lowest-level member. This should reduce the impact of a gcc bug that consumes excessive memory when compiling the generated map. Also removed the runtime calculation of the 'delimiter' character and instead generated it in the fru_gen python script. Resolves openbmc/openbmc#1441. Resolves openbmc/openbmc#1166. Change-Id: Iafe049d034354d58b68d357b4f49fd5e21b2c8c7 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
-rw-r--r--frup.hpp11
-rw-r--r--scripts/writefru.mako.cpp13
-rw-r--r--writefrudata.cpp34
3 files changed, 22 insertions, 36 deletions
diff --git a/frup.hpp b/frup.hpp
index ad342fc..09ffc9f 100644
--- a/frup.hpp
+++ b/frup.hpp
@@ -75,12 +75,15 @@ enum openbmc_vpd_key_id
using IPMIFruInfo = std::array<std::pair<std::string,std::string>,
OPENBMC_VPD_KEY_MAX>;
-using IPMIFruMetadata = std::string;
-using IPMIFruMetadataValue = std::string;
-using IPMIFruMap = std::map<IPMIFruMetadata,IPMIFruMetadataValue>;
+struct IPMIFruData
+{
+ std::string section;
+ std::string property;
+ std::string delimiter;
+};
using DbusProperty = std::string;
-using DbusPropertyMap = std::map<DbusProperty,IPMIFruMap>;
+using DbusPropertyMap = std::map<DbusProperty,IPMIFruData>;
using DbusInterface = std::string;
using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
diff --git a/scripts/writefru.mako.cpp b/scripts/writefru.mako.cpp
index 6180e13..82941a4 100644
--- a/scripts/writefru.mako.cpp
+++ b/scripts/writefru.mako.cpp
@@ -14,9 +14,16 @@ extern const FruMap frus = {
{"${interface}",{
% for dbus_property,property_value in properties.items():
{"${dbus_property}",{
- % for name,value in property_value.items():
- {"${name}","${value}"},
- % endfor
+ "${property_value.get("IPMIFruSection", "")}",
+ "${property_value.get("IPMIFruProperty", "")}", \
+<%
+ delimiter = property_value.get("IPMIFruValueDelimiter")
+ if not delimiter:
+ delimiter = ""
+ else:
+ delimiter = '\\' + hex(delimiter)[1:]
+%>
+ "${delimiter}"
}},
% endfor
}},
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 27ea6e2..97282ea 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -360,37 +360,13 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec, sd_bus* bus_sd)
PropertyMap props;//store all the properties
for (auto& properties : interfaceList.second)
{
- std::string section, property, delimiter, value;
- for (auto& info : properties.second)
- {
- if (info.first == "IPMIFruSection")
- {
- section = std::move(info.second);
- }
- if (info.first == "IPMIFruProperty")
- {
- property = std::move(info.second);
- }
- if (info.first == "IPMIFruValueDelimiter")
- {
- //Read the delimeter as ascii value
- //convert it into char
- if( info.second.length() > 0 )
- {
- char dlm = ' ';
- rc = sscanf(info.second.c_str(),"%hhd",&dlm);
- if (rc > 0)
- {
- delimiter = std::string(1,dlm);
- }
- }
- }
-
- }
+ std::string value;
+ decltype(auto) pdata = properties.second;
- if (!section.empty() && !property.empty())
+ if (!pdata.section.empty() && !pdata.property.empty())
{
- value = getFRUValue(section, property, delimiter, fruData);
+ value = getFRUValue(pdata.section, pdata.property,
+ pdata.delimiter, fruData);
}
props.emplace(std::move(properties.first), std::move(value));
}
OpenPOWER on IntegriCloud