hiomap: Implement get_flash_info
Change-Id: Ic70da5f7554453e4cd476c1d4c67027e342092ff
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/hiomap.cpp b/hiomap.cpp
index b5b9e81..de6515e 100644
--- a/hiomap.cpp
+++ b/hiomap.cpp
@@ -253,10 +253,41 @@
return IPMI_CC_OK;
}
+static ipmi_ret_t hiomap_get_flash_info(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);
+
+ auto m = ctx->bus->new_method_call(HIOMAPD_SERVICE, HIOMAPD_OBJECT,
+ HIOMAPD_IFACE_V2, "GetFlashInfo");
+ try
+ {
+ auto reply = ctx->bus->call(m);
+
+ uint16_t flashSize, eraseSize;
+ reply.read(flashSize, eraseSize);
+
+ uint8_t *respdata = (uint8_t *)response;
+ put(&respdata[0], htole16(flashSize));
+ put(&respdata[2], htole16(eraseSize));
+
+ *data_len = 4;
+ }
+ 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,
[2] = hiomap_get_info,
+ [3] = hiomap_get_flash_info,
};
/* FIXME: Define this in the "right" place, wherever that is */