Add calls to the SBE FIFO device driver to perform the SBE
chip operations.

Change-Id: I2f1204efc8196e9d331789e7910f90537834ddde
Signed-off-by: Murulidhar Nataraju <murulidhar@in.ibm.com>
diff --git a/file.hpp b/file.hpp
new file mode 100644
index 0000000..33df65f
--- /dev/null
+++ b/file.hpp
@@ -0,0 +1,72 @@
+#pragma once
+
+#include <unistd.h>
+namespace openpower
+{
+namespace sbe
+{
+namespace internal
+{
+
+/** @class FileDescriptor
+ *  @brief Provide RAII file descriptor
+ */
+class FileDescriptor
+{
+    private:
+        /** @brief File descriptor for the SBE FIFO device */
+        int fd = -1;
+
+    public:
+        FileDescriptor() = delete;
+        FileDescriptor(const FileDescriptor&) = delete;
+        FileDescriptor& operator=(const FileDescriptor&) = delete;
+        FileDescriptor(FileDescriptor&&) = delete;
+        FileDescriptor& operator=(FileDescriptor&&) = delete;
+
+        /** @brief Opens the input file and saves the file descriptor
+         *
+         *  @param[in] devPath - Path of the file
+         *  @para,[in] accessModes - File access modes
+         */
+        FileDescriptor(const char* devPath, int accessModes)
+        {
+            fd = open(devPath, accessModes);
+            if (fd < 0)
+            {
+                //TODO:use elog infrastructure
+                std::ostringstream errMsg;
+                errMsg << "Opening the device with device path:" <<
+                       devPath << " and access modes:" << accessModes <<
+                       ",Failed with errno" << errno;
+                throw std::runtime_error(errMsg.str().c_str());
+            }
+
+        }
+
+        /** @brief Saves File descriptor and uses it to do file operation
+         *
+         *  @param[in] fd - File descriptor
+         */
+        FileDescriptor(int fd) : fd(fd)
+        {
+            // Nothing
+        }
+
+        ~FileDescriptor()
+        {
+            if (fd >= 0)
+            {
+                close(fd);
+            }
+        }
+
+        int operator()()
+        {
+            return fd;
+        }
+};
+
+} // namespace internal
+} // namespace sbe
+} // namespace openpower