firmware: add read/write configuration methods
A data handler may require the host-side client to read or write
configuration information. Therefore, implement a method for
controlling this in the data handler object.
Change-Id: Id7f8ff54d90cece2e8751773a8696638c2a2ea77
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 2ee4155..59ef651 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -304,17 +304,30 @@
return item->second->imageHandler->write(offset, bytes);
}
+/*
+ * If the active session (image or hash) is over LPC, this allows
+ * configuring it. This option is only available before you start
+ * writing data for the given item (image or hash). This will return
+ * false at any other part. -- the lpc handler portion will know to return
+ * false.
+ */
bool FirmwareBlobHandler::writeMeta(uint16_t session, uint32_t offset,
const std::vector<uint8_t>& data)
{
- /*
- * If the active session (image or hash) is over LPC, this allows
- * configuring it. This option is only available before you start
- * writing data for the given item (image or hash). This will return
- * false at any other part.
- */
- return false;
+ auto item = lookup.find(session);
+ if (item == lookup.end())
+ {
+ return false;
+ }
+
+ if (item->second->flags & FirmwareUpdateFlags::ipmi)
+ {
+ return false;
+ }
+
+ return item->second->dataHandler->write(data);
}
+
bool FirmwareBlobHandler::commit(uint16_t session,
const std::vector<uint8_t>& data)
{