blob: bcac0a82536f57fa534f579b7092d449f6b5b716 [file] [log] [blame]
Patrick Venture00887592018-12-11 10:57:06 -08001#pragma once
2
3#include "blob_interface.hpp"
Patrick Venturecf2d1b12018-12-11 18:22:36 -08004#include "ipmi_interface.hpp"
Patrick Venture00887592018-12-11 10:57:06 -08005
6class BlobHandler : public BlobInterface
7{
8 public:
Patrick Venturec79faa12018-12-12 13:12:21 -08009 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 Venturecf2d1b12018-12-11 18:22:36 -080024 explicit BlobHandler(IpmiInterface* ipmi) : ipmi(ipmi){};
Patrick Venture00887592018-12-11 10:57:06 -080025
Patrick Venturec79faa12018-12-12 13:12:21 -080026 /**
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 Venture00887592018-12-11 10:57:06 -080053 std::vector<std::string> getBlobList() override;
Patrick Venture0bf8bf02018-12-12 20:43:25 -080054 StatResponse getStat(const std::string& id) override;
Patrick Venture0533d0b2018-12-13 08:48:24 -080055 std::uint16_t
56 openBlob(const std::string& id,
57 blobs::FirmwareBlobHandler::UpdateFlags handlerFlags) override;
Patrick Venturecf2d1b12018-12-11 18:22:36 -080058
59 private:
60 IpmiInterface* ipmi;
Patrick Venture00887592018-12-11 10:57:06 -080061};