hiomap: Implement mark_dirty

Change-Id: Ib86f4979130f05964035dcc73e62763ce227e984
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/hiomap.cpp b/hiomap.cpp
index e817f27..07a3afb 100644
--- a/hiomap.cpp
+++ b/hiomap.cpp
@@ -376,6 +376,39 @@
     return IPMI_CC_OK;
 }
 
+static ipmi_ret_t hiomap_mark_dirty(ipmi_request_t request,
+                                    ipmi_response_t response,
+                                    ipmi_data_len_t data_len,
+                                    ipmi_context_t context)
+{
+    struct hiomap *ctx = static_cast<struct hiomap *>(context);
+
+    if (*data_len < 4)
+    {
+        return IPMI_CC_REQ_DATA_LEN_INVALID;
+    }
+
+    uint8_t *reqdata = (uint8_t *)request;
+    auto m = ctx->bus->new_method_call(HIOMAPD_SERVICE, HIOMAPD_OBJECT,
+                                       HIOMAPD_IFACE_V2, "MarkDirty");
+    /* FIXME: Assumes v2 */
+    m.append(le16toh(get<uint16_t>(&reqdata[0]))); /* offset */
+    m.append(le16toh(get<uint16_t>(&reqdata[2]))); /* size */
+
+    try
+    {
+        auto reply = ctx->bus->call(m);
+
+        *data_len = 0;
+    }
+    catch (const exception::SdBusError &e)
+    {
+        return hiomap_xlate_errno(e.get_errno());
+    }
+
+    return IPMI_CC_OK;
+}
+
 static const hiomap_command hiomap_commands[] = {
     [0] = NULL, /* 0 is an invalid command ID */
     [1] = hiomap_reset,
@@ -384,6 +417,7 @@
     [4] = hiomap_create_read_window,
     [5] = hiomap_close_window,
     [6] = hiomap_create_write_window,
+    [7] = hiomap_mark_dirty,
 };
 
 /* FIXME: Define this in the "right" place, wherever that is */