blob: e22c335b4f1f49ce80a485410183da5c933010bd [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 Venturec7ca2912018-11-02 11:38:33 -07005
6namespace blobs
7{
8
Patrick Venturedf3e6ae2018-11-02 17:37:18 -07009enum class FirmwareUpdateFlags
10{
11 bt = (1 << 8), /* Expect to send contents over IPMI BlockTransfer. */
12 p2a = (1 << 9), /* Expect to send contents over P2A bridge. */
13 lpc = (1 << 10), /* Expect to send contents over LPC bridge. */
14};
15
Patrick Venturec7ca2912018-11-02 11:38:33 -070016/**
17 * Register only one firmware blob handler that will manage all sessions.
18 */
19class FirmwareBlobHandler : public GenericBlobInterface
20{
21 public:
Patrick Venture68cf64f2018-11-06 10:46:51 -080022 static std::unique_ptr<GenericBlobInterface> CreateFirmwareBlobHandler();
23
Patrick Venturec7ca2912018-11-02 11:38:33 -070024 FirmwareBlobHandler() = default;
25 ~FirmwareBlobHandler() = default;
26 FirmwareBlobHandler(const FirmwareBlobHandler&) = default;
27 FirmwareBlobHandler& operator=(const FirmwareBlobHandler&) = default;
28 FirmwareBlobHandler(FirmwareBlobHandler&&) = default;
29 FirmwareBlobHandler& operator=(FirmwareBlobHandler&&) = default;
30
31 bool canHandleBlob(const std::string& path) override;
32 std::vector<std::string> getBlobIds() override;
33 bool deleteBlob(const std::string& path) override;
34 bool stat(const std::string& path, struct BlobMeta* meta) override;
35 bool open(uint16_t session, uint16_t flags,
36 const std::string& path) override;
37 std::vector<uint8_t> read(uint16_t session, uint32_t offset,
38 uint32_t requestedSize) override;
39 bool write(uint16_t session, uint32_t offset,
40 const std::vector<uint8_t>& data) override;
41 bool writeMeta(uint16_t session, uint32_t offset,
42 const std::vector<uint8_t>& data) override;
43 bool commit(uint16_t session, const std::vector<uint8_t>& data) override;
44 bool close(uint16_t session) override;
45 bool stat(uint16_t session, struct BlobMeta* meta) override;
46 bool expire(uint16_t session) override;
47};
48
49} // namespace blobs