blob: ed3455bc15a541282d711633f55bc1d6d817ca9d [file] [log] [blame]
Patrick Venture25528b42018-11-06 18:29:43 -08001#pragma once
2
Patrick Venture400c6362018-11-06 20:06:11 -08003#include <cstdint>
Patrick Venturea78e39f2018-11-06 18:37:06 -08004#include <functional>
5#include <memory>
6#include <string>
Patrick Venture400c6362018-11-06 20:06:11 -08007#include <vector>
Patrick Venturea78e39f2018-11-06 18:37:06 -08008
Patrick Venture25528b42018-11-06 18:29:43 -08009namespace blobs
10{
11
12/**
13 * Each image update mechanism must implement the ImageHandlerInterface.
14 */
15class ImageHandlerInterface
16{
17 public:
18 virtual ~ImageHandlerInterface() = default;
19
20 /**
21 * open the firmware update mechanism.
22 *
Patrick Venturea78e39f2018-11-06 18:37:06 -080023 * @param[in] path - the path passed to the handler (the blob_id).
Patrick Venture25528b42018-11-06 18:29:43 -080024 * @return bool - returns true on success.
25 */
Patrick Venturea78e39f2018-11-06 18:37:06 -080026 virtual bool open(const std::string& path) = 0;
Patrick Venture400c6362018-11-06 20:06:11 -080027
28 /**
Patrick Venture68bb1432018-11-09 20:08:48 -080029 * close the image.
30 */
31 virtual void close() = 0;
32
33 /**
Patrick Venture400c6362018-11-06 20:06:11 -080034 * write data to the staged file.
35 *
36 * @param[in] offset - 0-based offset into the file.
37 * @param[in] data - the data to write.
38 * @return bool - returns true on success.
39 */
40 virtual bool write(std::uint32_t offset,
41 const std::vector<std::uint8_t>& data) = 0;
Patrick Venturea78e39f2018-11-06 18:37:06 -080042};
43
44struct HandlerPack
45{
46 std::string blobName;
47 ImageHandlerInterface* handler;
Patrick Venture25528b42018-11-06 18:29:43 -080048};
49
50} // namespace blobs