Patrick Venture | 0088759 | 2018-12-11 10:57:06 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "blob_interface.hpp" |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 4 | #include "ipmi_interface.hpp" |
Patrick Venture | 0088759 | 2018-12-11 10:57:06 -0800 | [diff] [blame] | 5 | |
| 6 | class BlobHandler : public BlobInterface |
| 7 | { |
| 8 | public: |
Patrick Venture | c79faa1 | 2018-12-12 13:12:21 -0800 | [diff] [blame] | 9 | enum BlobOEMCommands |
| 10 | { |
| 11 | bmcBlobGetCount = 0, |
| 12 | bmcBlobEnumerate = 1, |
| 13 | bmcBlobOpen = 2, |
| 14 | bmcBlobRead = 3, |
| 15 | bmcBlobWrite = 4, |
| 16 | bmcBlobCommit = 5, |
| 17 | bmcBlobClose = 6, |
| 18 | bmcBlobDelete = 7, |
| 19 | bmcBlobStat = 8, |
| 20 | bmcBlobSessionStat = 9, |
| 21 | bmcBlobWriteMeta = 10, |
| 22 | }; |
| 23 | |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 24 | explicit BlobHandler(IpmiInterface* ipmi) : ipmi(ipmi){}; |
Patrick Venture | 0088759 | 2018-12-11 10:57:06 -0800 | [diff] [blame] | 25 | |
Patrick Venture | c79faa1 | 2018-12-12 13:12:21 -0800 | [diff] [blame] | 26 | /** |
| 27 | * Send the contents of the payload to IPMI, this method handles wrapping |
| 28 | * with the OEN, subcommand and CRC. |
| 29 | * |
| 30 | * @param[in] command - the blob command. |
| 31 | * @param[in] payload - the payload bytes. |
| 32 | * @return the bytes returned from the ipmi interface. |
| 33 | */ |
| 34 | std::vector<std::uint8_t> |
| 35 | sendIpmiPayload(BlobOEMCommands command, |
| 36 | const std::vector<std::uint8_t>& payload); |
| 37 | |
| 38 | /** |
| 39 | * Retrieve the blob count. |
| 40 | * |
| 41 | * @return the number of blob_ids found (0 on failure). |
| 42 | */ |
| 43 | int getBlobCount(); |
| 44 | |
| 45 | /** |
| 46 | * Given an index into the list of blobs, return the name. |
| 47 | * |
| 48 | * @param[in] index - the index into the list of blob ids. |
| 49 | * @return the name as a string or empty on failure. |
| 50 | */ |
| 51 | std::string enumerateBlob(std::uint32_t index); |
| 52 | |
Patrick Venture | 0088759 | 2018-12-11 10:57:06 -0800 | [diff] [blame] | 53 | std::vector<std::string> getBlobList() override; |
Patrick Venture | 0bf8bf0 | 2018-12-12 20:43:25 -0800 | [diff] [blame] | 54 | StatResponse getStat(const std::string& id) override; |
Patrick Venture | 0533d0b | 2018-12-13 08:48:24 -0800 | [diff] [blame^] | 55 | std::uint16_t |
| 56 | openBlob(const std::string& id, |
| 57 | blobs::FirmwareBlobHandler::UpdateFlags handlerFlags) override; |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 58 | |
| 59 | private: |
| 60 | IpmiInterface* ipmi; |
Patrick Venture | 0088759 | 2018-12-11 10:57:06 -0800 | [diff] [blame] | 61 | }; |