summaryrefslogtreecommitdiffstats
path: root/tools/lpc.hpp
blob: 17367bbd5aa8b07c1adb1feb37a58cd2ab8af345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include "interface.hpp"
#include "internal/sys.hpp"
#include "io.hpp"
#include "progress.hpp"

#include <cstdint>
#include <ipmiblob/blob_interface.hpp>

namespace host_tool
{

struct LpcRegion
{
    /* Host LPC address at which the chunk is to be mapped. */
    std::uint32_t address;
    /* Size of the chunk to be mapped. */
    std::uint32_t length;
} __attribute__((packed));

class LpcDataHandler : public DataInterface
{
  public:
    LpcDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io,
                   std::uint32_t address, std::uint32_t length,
                   ProgressInterface* progress,
                   const internal::Sys* sys = &internal::sys_impl) :
        blob(blob),
        io(io), address(address), length(length), progress(progress),
        sys(sys){};

    bool sendContents(const std::string& input, std::uint16_t session) override;
    ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const override
    {
        return ipmi_flash::FirmwareFlags::UpdateFlags::lpc;
    }

  private:
    ipmiblob::BlobInterface* blob;
    HostIoInterface* io;
    std::uint32_t address;
    std::uint32_t length;
    ProgressInterface* progress;
    const internal::Sys* sys;
};

} // namespace host_tool
OpenPOWER on IntegriCloud