summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-02-10 15:59:31 +0530
committerRatan Gupta <ratagupt@in.ibm.com>2017-02-14 22:51:34 +0530
commit6eed4032cb2b08a8b9d41329fc3553a65269cbde (patch)
tree910352e3d3726b4f86c39d7b5bfee166439987a1
parent19c617b7dbbcb065b1a283e184310f60096ff180 (diff)
downloadipmi-fru-parser-6eed4032cb2b08a8b9d41329fc3553a65269cbde.zip
ipmi-fru-parser-6eed4032cb2b08a8b9d41329fc3553a65269cbde.tar.gz
Create the generated FRU Map in cpp.
Change-Id: Id83220e5e2876f4112ba76d698b2062e2a08dd3d Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
-rw-r--r--Makefile.am8
-rw-r--r--frup.hpp18
-rwxr-xr-xscripts/fru_gen.py8
-rw-r--r--scripts/writefru.mako.cpp (renamed from scripts/writefru.mako.hpp)26
-rw-r--r--writefrudata.cpp15
5 files changed, 37 insertions, 38 deletions
diff --git a/Makefile.am b/Makefile.am
index 288ac61..c626404 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-BUILT_SOURCES=fru-gen.hpp
+BUILT_SOURCES=fru-gen.cpp
AM_DEFAULT_SOURCE_EXT = .cpp
CLEANFILES=$(BUILT_SOURCES)
@@ -12,7 +12,7 @@ phosphor_read_eeprom_LDADD = libwritefrudata.la
libwritefrudatadir = ${libdir}
libwritefrudata_LTLIBRARIES = libwritefrudata.la
-libwritefrudata_la_SOURCES = frup.cpp writefrudata.cpp
+libwritefrudata_la_SOURCES = frup.cpp fru-gen.cpp writefrudata.cpp
libwritefrudata_la_LDFLAGS = $(SYSTEMD_LIBS) $(libmapper_LIBS) -version-info 1:0:0 -shared
libwritefrudata_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(libmapper_CFLAGS)
@@ -22,5 +22,5 @@ libstrgfnhandler_la_SOURCES = strgfnhandler.cpp
libstrgfnhandler_la_LDFLAGS = -version-info 1:0:0 -shared
libstrgfnhandler_la_LIBADD = libwritefrudata.la
-fru-gen.hpp:
- $(AM_V_GEN)@FRUGEN@ -o $(top_builddir) generate-hpp
+fru-gen.cpp:
+ $(AM_V_GEN)@FRUGEN@ -o $(top_builddir) generate-cpp
diff --git a/frup.hpp b/frup.hpp
index ca5fa96..ad342fc 100644
--- a/frup.hpp
+++ b/frup.hpp
@@ -3,7 +3,8 @@
#include <systemd/sd-bus.h>
#include <array>
-
+#include <string>
+#include <map>
enum ipmi_fru_area_type
{
@@ -74,6 +75,21 @@ 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>;
+
+using DbusProperty = std::string;
+using DbusPropertyMap = std::map<DbusProperty,IPMIFruMap>;
+
+using DbusInterface = std::string;
+using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
+
+using FruInstancePath = std::string;
+using FruInstanceMap = std::map<FruInstancePath,DbusInterfaceMap>;
+
+using FruId = uint32_t;
+using FruMap = std::map<FruId,FruInstanceMap>;
/* Parse an IPMI write fru data message into a dictionary containing name value pair of VPD entries.*/
int parse_fru (const void* msgbuf, sd_bus_message* vpdtbl);
diff --git a/scripts/fru_gen.py b/scripts/fru_gen.py
index aca86e8..2771498 100755
--- a/scripts/fru_gen.py
+++ b/scripts/fru_gen.py
@@ -7,7 +7,7 @@ import argparse
from mako.template import Template
-def generate_hpp(inventory_yaml, output_dir):
+def generate_cpp(inventory_yaml, output_dir):
with open(os.path.join(script_dir, inventory_yaml), 'r') as f:
ifile = yaml.safe_load(f)
if not isinstance(ifile, dict):
@@ -17,9 +17,9 @@ def generate_hpp(inventory_yaml, output_dir):
t = Template(filename=os.path.join(
script_dir,
- "writefru.mako.hpp"))
+ "writefru.mako.cpp"))
- output_hpp = os.path.join(output_dir, "fru-gen.hpp")
+ output_hpp = os.path.join(output_dir, "fru-gen.cpp")
with open(output_hpp, 'w') as fd:
fd.write(t.render(fruDict=ifile))
@@ -27,7 +27,7 @@ def generate_hpp(inventory_yaml, output_dir):
def main():
valid_commands = {
- 'generate-hpp': generate_hpp
+ 'generate-cpp': generate_cpp
}
parser = argparse.ArgumentParser(
description="IPMI FRU parser and code generator")
diff --git a/scripts/writefru.mako.hpp b/scripts/writefru.mako.cpp
index a5c2f24..7573862 100644
--- a/scripts/writefru.mako.hpp
+++ b/scripts/writefru.mako.cpp
@@ -1,30 +1,8 @@
// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
-#pragma once
-
#include <iostream>
+#include "frup.hpp"
-#include <string>
-#include <list>
-#include <map>
-
-using IPMIFruMetadata = std::string;
-using IPMIFruMetadataValue = std::string;
-using IPMIFruMap = std::map<IPMIFruMetadata,IPMIFruMetadataValue>;
-
-using DbusProperty = std::string;
-using DbusPropertyMap = std::map<DbusProperty,IPMIFruMap>;
-
-using DbusInterface = std::string;
-using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
-
-using FruInstancePath = std::string;
-using FruInstanceMap = std::map<FruInstancePath,DbusInterfaceMap>;
-
-using FruId = uint32_t;
-using FruMap = std::map<FruId,FruInstanceMap>;
-
-
-const FruMap frus = {
+extern const FruMap frus = {
% for key in fruDict.iterkeys():
{${key},{
<%
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 00d5b5b..c5f2539 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -15,7 +15,6 @@
#include <mapper.h>
#include "frup.hpp"
#include "fru-area.hpp"
-#include "fru-gen.hpp"
#include <sdbusplus/server.hpp>
// OpenBMC System Manager dbus framework
@@ -24,13 +23,19 @@ const char *sys_intf_name = "org.openbmc.managers.System";
extern const FruMap frus;
+using Property = std::string;
+using Value = sdbusplus::message::variant<bool, int64_t, std::string>;
+// Association between property and its value
+using PropertyMap = std::map<Property, Value>;
+
+using Interface = std::string;
// Association between interface and the dbus property
-using InterfaceList = std::map<std::string,
- std::map<std::string, std::string>>;
+using InterfaceMap = std::map<Interface, PropertyMap>;
-// Association between property and its value
-using PropertiesList = std::map<std::string, std::string>;
+using Object = sdbusplus::message::object_path;
+// Association between object and the interfaces.
+using ObjectMap = std::map<Object, InterfaceMap>;
//----------------------------------------------------------------
// Constructor
OpenPOWER on IntegriCloud