blob: f9a8983509bd984ee9324c766f59b7c83a2c44bc [file] [log] [blame]
Patrick Venturec7ca2912018-11-02 11:38:33 -07001#pragma once
2
3#include <blobs-ipmid/blobs.hpp>
Patrick Venture192d60f2018-11-06 11:11:59 -08004#include <cstdint>
Patrick Venture68cf64f2018-11-06 10:46:51 -08005#include <memory>
Patrick Venture148cd652018-11-06 10:59:47 -08006#include <string>
7#include <vector>
Patrick Venturec7ca2912018-11-02 11:38:33 -07008
9namespace blobs
10{
11
Patrick Venturedf3e6ae2018-11-02 17:37:18 -070012enum class FirmwareUpdateFlags
13{
14 bt = (1 << 8), /* Expect to send contents over IPMI BlockTransfer. */
15 p2a = (1 << 9), /* Expect to send contents over P2A bridge. */
16 lpc = (1 << 10), /* Expect to send contents over LPC bridge. */
17};
18
Patrick Venturec7ca2912018-11-02 11:38:33 -070019/**
20 * Register only one firmware blob handler that will manage all sessions.
21 */
22class FirmwareBlobHandler : public GenericBlobInterface
23{
24 public:
Patrick Venture148cd652018-11-06 10:59:47 -080025 static std::unique_ptr<GenericBlobInterface>
Patrick Venture192d60f2018-11-06 11:11:59 -080026 CreateFirmwareBlobHandler(const std::vector<std::string>& firmwares,
27 std::uint32_t transports);
Patrick Venture68cf64f2018-11-06 10:46:51 -080028
Patrick Venture192d60f2018-11-06 11:11:59 -080029 FirmwareBlobHandler(const std::vector<std::string>& firmwares,
30 std::uint32_t transports) :
31 baseFirmwares(firmwares),
32 transports(transports)
Patrick Venture148cd652018-11-06 10:59:47 -080033 {
34 }
Patrick Venturec7ca2912018-11-02 11:38:33 -070035 ~FirmwareBlobHandler() = default;
36 FirmwareBlobHandler(const FirmwareBlobHandler&) = default;
37 FirmwareBlobHandler& operator=(const FirmwareBlobHandler&) = default;
38 FirmwareBlobHandler(FirmwareBlobHandler&&) = default;
39 FirmwareBlobHandler& operator=(FirmwareBlobHandler&&) = default;
40
41 bool canHandleBlob(const std::string& path) override;
42 std::vector<std::string> getBlobIds() override;
43 bool deleteBlob(const std::string& path) override;
44 bool stat(const std::string& path, struct BlobMeta* meta) override;
45 bool open(uint16_t session, uint16_t flags,
46 const std::string& path) override;
47 std::vector<uint8_t> read(uint16_t session, uint32_t offset,
48 uint32_t requestedSize) override;
49 bool write(uint16_t session, uint32_t offset,
50 const std::vector<uint8_t>& data) override;
51 bool writeMeta(uint16_t session, uint32_t offset,
52 const std::vector<uint8_t>& data) override;
53 bool commit(uint16_t session, const std::vector<uint8_t>& data) override;
54 bool close(uint16_t session) override;
55 bool stat(uint16_t session, struct BlobMeta* meta) override;
56 bool expire(uint16_t session) override;
Patrick Venture148cd652018-11-06 10:59:47 -080057
58 private:
59 std::vector<std::string> baseFirmwares;
Patrick Venture192d60f2018-11-06 11:11:59 -080060 std::uint32_t transports;
Patrick Venturec7ca2912018-11-02 11:38:33 -070061};
62
63} // namespace blobs