xref: /openbmc/phosphor-ipmi-flash/tools/p2a.hpp (revision cf9b2195)
1b5bf0fc2SPatrick Venture #pragma once
2b5bf0fc2SPatrick Venture 
3b5bf0fc2SPatrick Venture #include "interface.hpp"
418bbe3c6SPatrick Venture #include "internal/sys.hpp"
5b5bf0fc2SPatrick Venture #include "io.hpp"
6b5bf0fc2SPatrick Venture #include "pci.hpp"
7*cf9b2195SPatrick Venture #include "progress.hpp"
8b5bf0fc2SPatrick Venture 
9b5bf0fc2SPatrick Venture #include <cstdint>
10b5bf0fc2SPatrick Venture #include <ipmiblob/blob_interface.hpp>
11b5bf0fc2SPatrick Venture 
12b5bf0fc2SPatrick Venture constexpr std::uint16_t aspeedVendorId = 0x1a03;
13b5bf0fc2SPatrick Venture constexpr std::uint16_t aspeedDeviceId = 0x2000;
1418bbe3c6SPatrick Venture constexpr std::size_t aspeedP2aOffset = 0x10000;
1524141611SPatrick Venture constexpr std::size_t aspeedP2aConfig = 0x0f000;
1624141611SPatrick Venture constexpr std::size_t aspeedP2aBridge = 0x0f004;
1724141611SPatrick Venture constexpr std::uint32_t p2ABridgeEnabled = 0x1;
18b5bf0fc2SPatrick Venture 
19b5bf0fc2SPatrick Venture namespace host_tool
20b5bf0fc2SPatrick Venture {
21b5bf0fc2SPatrick Venture 
22b5bf0fc2SPatrick Venture class P2aDataHandler : public DataInterface
23b5bf0fc2SPatrick Venture {
24b5bf0fc2SPatrick Venture   public:
25b5bf0fc2SPatrick Venture     P2aDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io,
26*cf9b2195SPatrick Venture                    PciUtilInterface* pci, ProgressInterface* progress,
2718bbe3c6SPatrick Venture                    const internal::Sys* sys = &internal::sys_impl) :
28b5bf0fc2SPatrick Venture         blob(blob),
29*cf9b2195SPatrick Venture         io(io), pci(pci), progress(progress), sys(sys)
30b5bf0fc2SPatrick Venture     {
31b5bf0fc2SPatrick Venture     }
32b5bf0fc2SPatrick Venture 
33b5bf0fc2SPatrick Venture     bool sendContents(const std::string& input, std::uint16_t session) override;
3484778b8dSPatrick Venture     ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const override
35b5bf0fc2SPatrick Venture     {
3684778b8dSPatrick Venture         return ipmi_flash::FirmwareFlags::UpdateFlags::p2a;
37b5bf0fc2SPatrick Venture     }
38b5bf0fc2SPatrick Venture 
39b5bf0fc2SPatrick Venture   private:
40b5bf0fc2SPatrick Venture     ipmiblob::BlobInterface* blob;
41b5bf0fc2SPatrick Venture     HostIoInterface* io;
42b5bf0fc2SPatrick Venture     PciUtilInterface* pci;
43*cf9b2195SPatrick Venture     ProgressInterface* progress;
4418bbe3c6SPatrick Venture     const internal::Sys* sys;
45b5bf0fc2SPatrick Venture };
46b5bf0fc2SPatrick Venture 
47b5bf0fc2SPatrick Venture } // namespace host_tool
48