data handler: add open method

Add open method to data handler object.  The exact purpose of this
method will vary by transport mechanism.

Change-Id: I3d1fa3914e010ac7590455ae3f948a1d9d5cee4b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/data_handler.hpp b/data_handler.hpp
index 2df5b15..6c660c8 100644
--- a/data_handler.hpp
+++ b/data_handler.hpp
@@ -15,6 +15,14 @@
     virtual ~DataInterface() = default;
 
     /**
+     * Initialize data transport mechanism.  Calling this should be idempotent
+     * if possible.
+     *
+     * @return true if successful
+     */
+    virtual bool open() = 0;
+
+    /**
      * Copy bytes from external interface (blocking call).
      *
      * @param[in] length - number of bytes to copy
diff --git a/lpc_handler.cpp b/lpc_handler.cpp
index 94bc73d..a723461 100644
--- a/lpc_handler.cpp
+++ b/lpc_handler.cpp
@@ -7,6 +7,14 @@
 namespace blobs
 {
 
+bool LpcDataHandler::open()
+{
+    /* For the ASPEED LPC CTRL driver, the ioctl is required to set up the
+     * window, with information from write() below.
+     */
+    return true;
+}
+
 std::vector<std::uint8_t> LpcDataHandler::copyFrom(std::uint32_t length)
 {
     /* TODO: implement this. */
diff --git a/lpc_handler.hpp b/lpc_handler.hpp
index 27f0e03..e74c59f 100644
--- a/lpc_handler.hpp
+++ b/lpc_handler.hpp
@@ -26,6 +26,7 @@
   public:
     LpcDataHandler() = default;
 
+    bool open() override;
     std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
     bool write(const std::vector<std::uint8_t>& configuration) override;
     std::vector<std::uint8_t> read() override;
diff --git a/pci_handler.cpp b/pci_handler.cpp
index 852d846..3fa7ec9 100644
--- a/pci_handler.cpp
+++ b/pci_handler.cpp
@@ -7,6 +7,14 @@
 namespace blobs
 {
 
+bool PciDataHandler::open()
+{
+    /* For the ASPEED P2A driver, this method will enable the memory region to
+     * use.
+     */
+    return false;
+}
+
 std::vector<std::uint8_t> PciDataHandler::copyFrom(std::uint32_t length)
 {
     /* TODO: implement this. */
diff --git a/pci_handler.hpp b/pci_handler.hpp
index 2594f09..ba09d51 100644
--- a/pci_handler.hpp
+++ b/pci_handler.hpp
@@ -22,6 +22,7 @@
   public:
     PciDataHandler() = default;
 
+    bool open() override;
     std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
     bool write(const std::vector<std::uint8_t>& configuration) override;
     std::vector<std::uint8_t> read() override;
diff --git a/test/data_mock.hpp b/test/data_mock.hpp
index a79c562..44cc376 100644
--- a/test/data_mock.hpp
+++ b/test/data_mock.hpp
@@ -12,6 +12,7 @@
   public:
     virtual ~DataHandlerMock() = default;
 
+    MOCK_METHOD0(open, bool());
     MOCK_METHOD1(copyFrom, std::vector<std::uint8_t>(std::uint32_t));
     MOCK_METHOD1(write, bool(const std::vector<std::uint8_t>&));
     MOCK_METHOD0(read, std::vector<std::uint8_t>());