summaryrefslogtreecommitdiffstats
path: root/occ_pass_through.cpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-04-17 23:21:52 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-04-26 16:23:01 +0530
commit67d50ad6126f278cd76416e32877b3462abc07dd (patch)
tree4c427bdf4637e0330f55ab6e3816b9aca3f32350 /occ_pass_through.cpp
parent38b08d791b159424c9c9f9a21876f73f6020062b (diff)
downloadopenpower-occ-control-67d50ad6126f278cd76416e32877b3462abc07dd.tar.gz
openpower-occ-control-67d50ad6126f278cd76416e32877b3462abc07dd.zip
Write payload to OCC and read it back
This will utilize the OCC driver to send Amester payload to OCC and does a read to get the contents of OCC-SRAM and passes it back. Change-Id: I68627b21665256df6fabad7768bb139dd6d1b99b Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'occ_pass_through.cpp')
-rw-r--r--occ_pass_through.cpp47
1 files changed, 46 insertions, 1 deletions
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index 88a0d29..1b3bffa 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -1,6 +1,7 @@
#include <memory>
#include <algorithm>
#include <fcntl.h>
+#include <errno.h>
#include <phosphor-logging/log.hpp>
#include "occ_pass_through.hpp"
#include "occ_finder.hpp"
@@ -62,9 +63,53 @@ int PassThrough::openDevice()
std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
{
- return {};
+ using namespace phosphor::logging;
+
+ std::vector<int32_t> response {};
+
+ // Amester packs data in 4 bytes
+ ssize_t size = command.size() * sizeof(int32_t);
+ auto rc = write((fd)(), command.data(), size);
+ if (rc < 0 || (rc != size))
+ {
+ log<level::ERR>("Error writing to OCC");
+
+ // In the next commit, it will have exceptions.
+ return response;
+ }
+
+ // Now read the response. This would be the content of occ-sram
+ while(1)
+ {
+ errno = 0;
+ int32_t data {};
+ auto len = read((fd)(), &data, sizeof(data));
+ if (len > 0)
+ {
+ response.emplace_back(data);
+ }
+ else if (len < 0 && errno == EAGAIN)
+ {
+ // We may have data coming still
+ continue;
+ }
+ else if (len == 0)
+ {
+ // We have read all that we can.
+ break;
+ }
+ else
+ {
+ // Will have exception in the next commit.
+ log<level::ERR>("Error reading from OCC");
+ break;
+ }
+ }
+
+ return response;
}
+
} // namespace pass_through
} // namespace occ
} // namespace open_power
OpenPOWER on IntegriCloud