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