window interface: add close method

Add a close method, that when called does whatever is appropriate for
the given implementation.

Note: There are a few methods that don't map nicely, and therefore it
makes sense to add a close() to this interface.

Change-Id: If001446b2248715ea76147ea35a99a729ba5a404
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/lpc_aspeed.cpp b/lpc_aspeed.cpp
index dabea8a..50ce2a9 100644
--- a/lpc_aspeed.cpp
+++ b/lpc_aspeed.cpp
@@ -43,6 +43,10 @@
     return std::make_unique<LpcMapperAspeed>(regionAddress, regionSize);
 }
 
+void LpcMapperAspeed::close()
+{
+}
+
 std::pair<std::uint32_t, std::uint32_t>
     LpcMapperAspeed::mapWindow(std::uint32_t address, std::uint32_t length)
 {
diff --git a/lpc_aspeed.hpp b/lpc_aspeed.hpp
index f3608d0..e89662c 100644
--- a/lpc_aspeed.hpp
+++ b/lpc_aspeed.hpp
@@ -23,6 +23,8 @@
         regionAddress(regionAddress),
         regionSize(regionSize), sys(sys){};
 
+    void close() override;
+
     std::pair<std::uint32_t, std::uint32_t>
         mapWindow(std::uint32_t address, std::uint32_t length) override;
 
diff --git a/lpc_handler.cpp b/lpc_handler.cpp
index e5b49a2..32acf1d 100644
--- a/lpc_handler.cpp
+++ b/lpc_handler.cpp
@@ -33,7 +33,7 @@
 
 bool LpcDataHandler::close()
 {
-    /* TODO: implement ioctl call to close window. */
+    mapper->close();
 
     return setInitializedAndReturn(false);
 }
diff --git a/lpc_nuvoton.cpp b/lpc_nuvoton.cpp
index 83b0160..b4e5477 100644
--- a/lpc_nuvoton.cpp
+++ b/lpc_nuvoton.cpp
@@ -41,6 +41,10 @@
     return std::make_unique<LpcMapperNuvoton>(regionAddress);
 }
 
+void LpcMapperNuvoton::close()
+{
+}
+
 /*
  * The host buffer address is configured by host through
  * SuperIO. On BMC side the max memory can be mapped is 4kB with the caveat that
diff --git a/lpc_nuvoton.hpp b/lpc_nuvoton.hpp
index bf53e29..b72a673 100644
--- a/lpc_nuvoton.hpp
+++ b/lpc_nuvoton.hpp
@@ -29,6 +29,8 @@
         regionAddress(regionAddress),
         sys(sys){};
 
+    void close() override;
+
     std::pair<std::uint32_t, std::uint32_t>
         mapWindow(std::uint32_t address, std::uint32_t length) override;
 
diff --git a/test/window_mapper_mock.hpp b/test/window_mapper_mock.hpp
index 4d401c4..c8a75c6 100644
--- a/test/window_mapper_mock.hpp
+++ b/test/window_mapper_mock.hpp
@@ -16,6 +16,7 @@
   public:
     virtual ~HardwareInterfaceMock() = default;
 
+    MOCK_METHOD0(close, ());
     MOCK_METHOD2(mapWindow,
                  std::pair<std::uint32_t, std::uint32_t>(std::uint32_t,
                                                          std::uint32_t));
diff --git a/window_hw_interface.hpp b/window_hw_interface.hpp
index d00bfcd..60c600f 100644
--- a/window_hw_interface.hpp
+++ b/window_hw_interface.hpp
@@ -18,6 +18,12 @@
     virtual ~HardwareMapperInterface() = default;
 
     /**
+     * Close the mapper.  This could mean, send an ioctl to turn off the region,
+     * or unmap anything mmapped.
+     */
+    virtual void close() = 0;
+
+    /**
      * Returns a windowOffset and windowSize if the requested window was mapped.
      *
      * TODO: If the length requested is too large, windowSize will be written