Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <blobs-ipmid/blobs.hpp> |
Patrick Venture | 68cf64f | 2018-11-06 10:46:51 -0800 | [diff] [blame] | 4 | #include <memory> |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame^] | 5 | #include <string> |
| 6 | #include <vector> |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 7 | |
| 8 | namespace blobs |
| 9 | { |
| 10 | |
Patrick Venture | df3e6ae | 2018-11-02 17:37:18 -0700 | [diff] [blame] | 11 | enum 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 Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 18 | /** |
| 19 | * Register only one firmware blob handler that will manage all sessions. |
| 20 | */ |
| 21 | class FirmwareBlobHandler : public GenericBlobInterface |
| 22 | { |
| 23 | public: |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame^] | 24 | static std::unique_ptr<GenericBlobInterface> |
| 25 | CreateFirmwareBlobHandler(const std::vector<std::string>& firmwares); |
Patrick Venture | 68cf64f | 2018-11-06 10:46:51 -0800 | [diff] [blame] | 26 | |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame^] | 27 | explicit FirmwareBlobHandler(const std::vector<std::string>& firmwares) : |
| 28 | baseFirmwares(firmwares) |
| 29 | { |
| 30 | } |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 31 | ~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 Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame^] | 53 | |
| 54 | private: |
| 55 | std::vector<std::string> baseFirmwares; |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } // namespace blobs |