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