data handler: add close method
Add the close method which, when called should turn off whatever bridge
was used.
Change-Id: Idbf16bd6777d0b9c3f537d0b9d3fdff22e7c319e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/data_handler.hpp b/data_handler.hpp
index 6c660c8..1bee432 100644
--- a/data_handler.hpp
+++ b/data_handler.hpp
@@ -23,6 +23,13 @@
virtual bool open() = 0;
/**
+ * Close the data transport mechanism.
+ *
+ * @return true if successful
+ */
+ virtual bool close() = 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 a723461..1c441d6 100644
--- a/lpc_handler.cpp
+++ b/lpc_handler.cpp
@@ -15,6 +15,12 @@
return true;
}
+bool LpcDataHandler::close()
+{
+ /* TODO: implement ioctl call to close window. */
+ return false;
+}
+
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 e74c59f..c60b782 100644
--- a/lpc_handler.hpp
+++ b/lpc_handler.hpp
@@ -27,6 +27,7 @@
LpcDataHandler() = default;
bool open() override;
+ bool close() 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 3fa7ec9..dce1098 100644
--- a/pci_handler.cpp
+++ b/pci_handler.cpp
@@ -9,8 +9,15 @@
bool PciDataHandler::open()
{
- /* For the ASPEED P2A driver, this method will enable the memory region to
- * use.
+ /* TODO: For the ASPEED P2A driver, this method will enable the memory
+ * region to use.
+ */
+ return false;
+}
+
+bool PciDataHandler::close()
+{
+ /* TODO: Turn off the P2A bridge and region to disable host-side access.
*/
return false;
}
diff --git a/pci_handler.hpp b/pci_handler.hpp
index ba09d51..755ee18 100644
--- a/pci_handler.hpp
+++ b/pci_handler.hpp
@@ -23,6 +23,7 @@
PciDataHandler() = default;
bool open() override;
+ bool close() 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 44cc376..44c3aae 100644
--- a/test/data_mock.hpp
+++ b/test/data_mock.hpp
@@ -13,6 +13,7 @@
virtual ~DataHandlerMock() = default;
MOCK_METHOD0(open, bool());
+ MOCK_METHOD0(close, 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>());