blob: b206f56d8db569e90e13d19f4fef3bac503f989e [file] [log] [blame]
Patrick Venturec7ca2912018-11-02 11:38:33 -07001#pragma once
2
3#include <blobs-ipmid/blobs.hpp>
Patrick Venture68cf64f2018-11-06 10:46:51 -08004#include <memory>
Patrick Venture148cd652018-11-06 10:59:47 -08005#include <string>
6#include <vector>
Patrick Venturec7ca2912018-11-02 11:38:33 -07007
8namespace blobs
9{
10
Patrick Venturedf3e6ae2018-11-02 17:37:18 -070011enum class FirmwareUpdateFlags
12{
13 bt = (1 << 8), /* Expect to send contents over IPMI BlockTransfer. */
14 p2a = (1 << 9), /* Expect to send contents over P2A bridge. */
15 lpc = (1 << 10), /* Expect to send contents over LPC bridge. */
16};
17
Patrick Venturec7ca2912018-11-02 11:38:33 -070018/**
19 * Register only one firmware blob handler that will manage all sessions.
20 */
21class FirmwareBlobHandler : public GenericBlobInterface
22{
23 public:
Patrick Venture148cd652018-11-06 10:59:47 -080024 static std::unique_ptr<GenericBlobInterface>
25 CreateFirmwareBlobHandler(const std::vector<std::string>& firmwares);
Patrick Venture68cf64f2018-11-06 10:46:51 -080026
Patrick Venture148cd652018-11-06 10:59:47 -080027 explicit FirmwareBlobHandler(const std::vector<std::string>& firmwares) :
28 baseFirmwares(firmwares)
29 {
30 }
Patrick Venturec7ca2912018-11-02 11:38:33 -070031 ~FirmwareBlobHandler() = default;
32 FirmwareBlobHandler(const FirmwareBlobHandler&) = default;
33 FirmwareBlobHandler& operator=(const FirmwareBlobHandler&) = default;
34 FirmwareBlobHandler(FirmwareBlobHandler&&) = default;
35 FirmwareBlobHandler& operator=(FirmwareBlobHandler&&) = default;
36
37 bool canHandleBlob(const std::string& path) override;
38 std::vector<std::string> getBlobIds() override;
39 bool deleteBlob(const std::string& path) override;
40 bool stat(const std::string& path, struct BlobMeta* meta) override;
41 bool open(uint16_t session, uint16_t flags,
42 const std::string& path) override;
43 std::vector<uint8_t> read(uint16_t session, uint32_t offset,
44 uint32_t requestedSize) override;
45 bool write(uint16_t session, uint32_t offset,
46 const std::vector<uint8_t>& data) override;
47 bool writeMeta(uint16_t session, uint32_t offset,
48 const std::vector<uint8_t>& data) override;
49 bool commit(uint16_t session, const std::vector<uint8_t>& data) override;
50 bool close(uint16_t session) override;
51 bool stat(uint16_t session, struct BlobMeta* meta) override;
52 bool expire(uint16_t session) override;
Patrick Venture148cd652018-11-06 10:59:47 -080053
54 private:
55 std::vector<std::string> baseFirmwares;
Patrick Venturec7ca2912018-11-02 11:38:33 -070056};
57
58} // namespace blobs