summaryrefslogtreecommitdiffstats
path: root/storageaddsel.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-10-31 17:25:33 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2017-11-03 17:55:15 +0530
commitb647d5be78df54b3dab6a91476412474a6cb7e1d (patch)
treeb0a547cbbcdc6cb518f8d1a38f66c051c6f0f201 /storageaddsel.cpp
parentb0b395b670b6e496dda0ce117e1b5a1e195ab0e9 (diff)
downloadphosphor-host-ipmid-b647d5be78df54b3dab6a91476412474a6cb7e1d.tar.gz
phosphor-host-ipmid-b647d5be78df54b3dab6a91476412474a6cb7e1d.zip
Commit a MaintenanceProcedure log entry on a 0xDE SEL record
In the case of a procedure callout, HB sends a eSEL of 0xDF type. It is followed by a Add SEL record with OEM record type 0xDE and byte 11 in the record indicate the procedure associated with the eSEL. Resolves openbmc/openbmc#2368 Change-Id: Ia57f423c9d533cd8968b613d7522b409a9820198 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'storageaddsel.cpp')
-rw-r--r--storageaddsel.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 01147ac..82ac74b 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -241,3 +241,48 @@ void send_esel(uint16_t recordid) {
return;
}
+
+std::string readESEL(const char* fileName)
+{
+ std::string content;
+ std::ifstream handle(fileName);
+
+ if (handle.fail())
+ {
+ log<level::ERR>("Failed to open eSEL", entry("FILENAME=%s", fileName));
+ return content;
+ }
+
+ handle.seekg(0, std::ios::end);
+ content.resize(handle.tellg());
+ handle.seekg(0, std::ios::beg);
+ handle.read(&content[0], content.size());
+ handle.close();
+
+ return content;
+}
+
+void createProcedureLogEntry(uint8_t procedureNum)
+{
+ // Read the eSEL data from the file.
+ static constexpr auto eSELFile = "/tmp/esel";
+ auto eSELData = readESEL(eSELFile);
+
+ // Each byte in eSEL is formatted as %02x with a space between bytes and
+ // insert '/0' at the end of the character array.
+ static constexpr auto byteSeparator = 3;
+ std::unique_ptr<char[]> data(new char[
+ (eSELData.size() * byteSeparator) + 1]());
+
+ for (size_t i = 0; i < eSELData.size(); i++)
+ {
+ sprintf(&data[i * byteSeparator], "%02x ", eSELData[i]);
+ }
+ data[eSELData.size() * byteSeparator] = '\0';
+
+ using error = sdbusplus::org::open_power::Host::Error::MaintenanceProcedure;
+ using metadata = org::open_power::Host::MaintenanceProcedure;
+
+ report<error>(metadata::ESEL(data.get()),
+ metadata::PROCEDURE(static_cast<uint32_t>(procedureNum)));
+}
OpenPOWER on IntegriCloud