blob: 73f0d9411f236db8a22c324069da685cd77d0fe4 [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.
Patrick Venture339dece2018-12-14 18:32:04 -080033 * @throws BlobException.
Patrick Venturec79faa12018-12-12 13:12:21 -080034 */
35 std::vector<std::uint8_t>
36 sendIpmiPayload(BlobOEMCommands command,
37 const std::vector<std::uint8_t>& payload);
38
39 /**
40 * Retrieve the blob count.
41 *
42 * @return the number of blob_ids found (0 on failure).
43 */
44 int getBlobCount();
45
46 /**
47 * Given an index into the list of blobs, return the name.
48 *
49 * @param[in] index - the index into the list of blob ids.
50 * @return the name as a string or empty on failure.
51 */
52 std::string enumerateBlob(std::uint32_t index);
53
Patrick Venture00887592018-12-11 10:57:06 -080054 std::vector<std::string> getBlobList() override;
Patrick Venture339dece2018-12-14 18:32:04 -080055
56 /**
57 * @throws BlobException.
58 */
Patrick Venture0bf8bf02018-12-12 20:43:25 -080059 StatResponse getStat(const std::string& id) override;
Patrick Venture339dece2018-12-14 18:32:04 -080060
61 /**
62 * @throws BlobException.
63 */
Patrick Venture0533d0b2018-12-13 08:48:24 -080064 std::uint16_t
65 openBlob(const std::string& id,
66 blobs::FirmwareBlobHandler::UpdateFlags handlerFlags) override;
Patrick Venturecf2d1b12018-12-11 18:22:36 -080067
68 private:
69 IpmiInterface* ipmi;
Patrick Venture00887592018-12-11 10:57:06 -080070};