xref: /openbmc/phosphor-ipmi-flash/tools/lpc.hpp (revision 42a44c28)
1 #pragma once
2 
3 #include "interface.hpp"
4 #include "internal/sys.hpp"
5 #include "io.hpp"
6 #include "progress.hpp"
7 
8 #include <ipmiblob/blob_interface.hpp>
9 
10 #include <cstdint>
11 
12 namespace host_tool
13 {
14 
15 struct LpcRegion
16 {
17     /* Host LPC address at which the chunk is to be mapped. */
18     std::uint32_t address;
19     /* Size of the chunk to be mapped. */
20     std::uint32_t length;
21 } __attribute__((packed));
22 
23 class LpcDataHandler : public DataInterface
24 {
25   public:
LpcDataHandler(ipmiblob::BlobInterface * blob,HostIoInterface * io,std::uint32_t address,std::uint32_t length,ProgressInterface * progress,const internal::Sys * sys=& internal::sys_impl)26     LpcDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io,
27                    std::uint32_t address, std::uint32_t length,
28                    ProgressInterface* progress,
29                    const internal::Sys* sys = &internal::sys_impl) :
30         blob(blob), io(io), address(address), length(length),
31         progress(progress), sys(sys) {};
32 
33     bool sendContents(const std::string& input, std::uint16_t session) override;
supportedType() const34     ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const override
35     {
36         return ipmi_flash::FirmwareFlags::UpdateFlags::lpc;
37     }
38 
39   private:
40     ipmiblob::BlobInterface* blob;
41     HostIoInterface* io;
42     std::uint32_t address;
43     std::uint32_t length;
44     ProgressInterface* progress;
45     const internal::Sys* sys;
46 };
47 
48 } // namespace host_tool
49