ipmi: start implementing flashDataBlock
Change-Id: I780c0e5da77a027ce23a674bd3fdbf08b8a81c14
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/flash-ipmi.hpp b/flash-ipmi.hpp
index deef582..db7765e 100644
--- a/flash-ipmi.hpp
+++ b/flash-ipmi.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <vector>
+
#include "host-ipmid/ipmid-api.h"
/* Clearer way to represent the subcommand size. */
@@ -70,12 +72,21 @@
uint32_t length; /* Maximum image length is 4GiB (little-endian) */
} __attribute__((packed));
+struct ChunkHdr
+{
+ uint8_t cmd;
+ uint32_t offset; /* 0-based write offset */
+ uint8_t data[];
+} __attribute__((packed));
+
class UpdateInterface
{
public:
virtual ~UpdateInterface() = default;
virtual bool start(uint32_t length) = 0;
+ virtual bool flashData(uint32_t offset,
+ const std::vector<uint8_t>& bytes) = 0;
};
class FlashUpdate : public UpdateInterface
@@ -96,6 +107,15 @@
*/
bool start(uint32_t length) override;
+ /**
+ * Attempt to write the bytes at the offset.
+ *
+ * @param[in] offset - the 0-based byte offset into the flash image.
+ * @param[in] bytes - the bytes to write.
+ * @return true on success, false otherwise.
+ */
+ bool flashData(uint32_t offset, const std::vector<uint8_t>& bytes) override;
+
private:
/**
* Tries to close out and delete anything staged.