summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-20 20:09:42 -0700
committerPatrick Venture <venture@google.com>2018-10-29 09:04:32 -0700
commita19bd0c5aeb0dd9d8ef7da2917ae18175ada7676 (patch)
treea4af51a288546d69da118d85e3e18537fb17b863
parentb4c333f96cb9f981d1fcbef8d2953bcf8ea2d701 (diff)
downloadipmi-fru-parser-a19bd0c5aeb0dd9d8ef7da2917ae18175ada7676.tar.gz
ipmi-fru-parser-a19bd0c5aeb0dd9d8ef7da2917ae18175ada7676.zip
IPMIFruArea: move source into separate fru_area.cpp
Move the implementation of the class into its own source file. Change-Id: I02d941dd8173f0cede8cdfe8af1fdc5f5418abb4 Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--Makefile.am1
-rw-r--r--fru_area.cpp83
-rw-r--r--writefrudata.cpp74
3 files changed, 84 insertions, 74 deletions
diff --git a/Makefile.am b/Makefile.am
index 5862009..41daebb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,6 +17,7 @@ phosphor_read_eeprom_LDADD = libwritefrudata.la
lib_LTLIBRARIES = libwritefrudata.la
libwritefrudata_la_SOURCES = frup.cpp \
fru-gen.cpp \
+ fru_area.cpp \
writefrudata.cpp \
extra-properties-gen.cpp
libwritefrudata_la_LDFLAGS = $(SYSTEMD_LIBS) \
diff --git a/fru_area.cpp b/fru_area.cpp
new file mode 100644
index 0000000..1f90064
--- /dev/null
+++ b/fru_area.cpp
@@ -0,0 +1,83 @@
+#include "fru_area.hpp"
+
+#include "frup.hpp"
+
+#include <cstdint>
+#include <cstring>
+#include <phosphor-logging/log.hpp>
+
+using namespace phosphor::logging;
+
+//----------------------------------------------------------------
+// Constructor
+//----------------------------------------------------------------
+IPMIFruArea::IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
+ bool bmc_fru)
+{
+ iv_fruid = fruid;
+ iv_type = type;
+ iv_bmc_fru = bmc_fru;
+ iv_valid = false;
+ iv_data = NULL;
+ iv_present = false;
+
+ if (iv_type == IPMI_FRU_AREA_INTERNAL_USE)
+ {
+ iv_name = "INTERNAL_";
+ }
+ else if (iv_type == IPMI_FRU_AREA_CHASSIS_INFO)
+ {
+ iv_name = "CHASSIS_";
+ }
+ else if (iv_type == IPMI_FRU_AREA_BOARD_INFO)
+ {
+ iv_name = "BOARD_";
+ }
+ else if (iv_type == IPMI_FRU_AREA_PRODUCT_INFO)
+ {
+ iv_name = "PRODUCT_";
+ }
+ else if (iv_type == IPMI_FRU_AREA_MULTI_RECORD)
+ {
+ iv_name = "MULTI_";
+ }
+ else
+ {
+ iv_name = IPMI_FRU_AREA_TYPE_MAX;
+ log<level::ERR>("Invalid Area", entry("TYPE=%d", iv_type));
+ }
+}
+
+//-----------------------------------------------------
+// For a FRU area type, accepts the data and updates
+// area specific data.
+//-----------------------------------------------------
+void IPMIFruArea::set_data(const uint8_t* data, const size_t len)
+{
+ iv_len = len;
+ iv_data = new uint8_t[len];
+ std::memcpy(iv_data, data, len);
+}
+
+//-----------------------------------------------------
+// Sets the dbus parameters
+//-----------------------------------------------------
+void IPMIFruArea::update_dbus_paths(const char* bus_name, const char* obj_path,
+ const char* intf_name)
+{
+ iv_bus_name = bus_name;
+ iv_obj_path = obj_path;
+ iv_intf_name = intf_name;
+}
+
+//-------------------
+// Destructor
+//-------------------
+IPMIFruArea::~IPMIFruArea()
+{
+ if (iv_data != NULL)
+ {
+ delete[] iv_data;
+ iv_data = NULL;
+ }
+}
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 1cbf210..978f2b1 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -276,80 +276,6 @@ int updateInventory(FruAreaVector& area_vec, sd_bus* bus_sd)
} // namespace
-//----------------------------------------------------------------
-// Constructor
-//----------------------------------------------------------------
-IPMIFruArea::IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
- bool bmc_fru)
-{
- iv_fruid = fruid;
- iv_type = type;
- iv_bmc_fru = bmc_fru;
- iv_valid = false;
- iv_data = NULL;
- iv_present = false;
-
- if (iv_type == IPMI_FRU_AREA_INTERNAL_USE)
- {
- iv_name = "INTERNAL_";
- }
- else if (iv_type == IPMI_FRU_AREA_CHASSIS_INFO)
- {
- iv_name = "CHASSIS_";
- }
- else if (iv_type == IPMI_FRU_AREA_BOARD_INFO)
- {
- iv_name = "BOARD_";
- }
- else if (iv_type == IPMI_FRU_AREA_PRODUCT_INFO)
- {
- iv_name = "PRODUCT_";
- }
- else if (iv_type == IPMI_FRU_AREA_MULTI_RECORD)
- {
- iv_name = "MULTI_";
- }
- else
- {
- iv_name = IPMI_FRU_AREA_TYPE_MAX;
- log<level::ERR>("Invalid Area", entry("TYPE=%d", iv_type));
- }
-}
-
-//-----------------------------------------------------
-// For a FRU area type, accepts the data and updates
-// area specific data.
-//-----------------------------------------------------
-void IPMIFruArea::set_data(const uint8_t* data, const size_t len)
-{
- iv_len = len;
- iv_data = new uint8_t[len];
- std::memcpy(iv_data, data, len);
-}
-
-//-----------------------------------------------------
-// Sets the dbus parameters
-//-----------------------------------------------------
-void IPMIFruArea::update_dbus_paths(const char* bus_name, const char* obj_path,
- const char* intf_name)
-{
- iv_bus_name = bus_name;
- iv_obj_path = obj_path;
- iv_intf_name = intf_name;
-}
-
-//-------------------
-// Destructor
-//-------------------
-IPMIFruArea::~IPMIFruArea()
-{
- if (iv_data != NULL)
- {
- delete[] iv_data;
- iv_data = NULL;
- }
-}
-
//------------------------------------------------
// Takes the pointer to stream of bytes and length
// and returns the 8 bit checksum
OpenPOWER on IntegriCloud