1 #pragma once 2 3 #include "interface.hpp" 4 #include "internal/sys.hpp" 5 #include "io.hpp" 6 #include "pci.hpp" 7 #include "progress.hpp" 8 9 #include <cstdint> 10 #include <ipmiblob/blob_interface.hpp> 11 #include <vector> 12 13 constexpr std::size_t aspeedP2aConfig = 0x0f000; 14 constexpr std::size_t aspeedP2aBridge = 0x0f004; 15 constexpr std::uint32_t p2ABridgeEnabled = 0x1; 16 17 struct PciDeviceInfo 18 { 19 std::uint16_t VID; 20 std::uint16_t DID; 21 std::size_t Offset; 22 std::size_t Length; 23 std::uint16_t bar; 24 }; 25 26 namespace host_tool 27 { 28 29 class P2aDataHandler : public DataInterface 30 { 31 public: 32 P2aDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io, 33 PciUtilInterface* pci, ProgressInterface* progress, 34 const internal::Sys* sys = &internal::sys_impl) : 35 blob(blob), 36 io(io), pci(pci), progress(progress), sys(sys) 37 { 38 } 39 40 bool sendContents(const std::string& input, std::uint16_t session) override; 41 ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const override 42 { 43 return ipmi_flash::FirmwareFlags::UpdateFlags::p2a; 44 } 45 46 private: 47 ipmiblob::BlobInterface* blob; 48 HostIoInterface* io; 49 PciUtilInterface* pci; 50 ProgressInterface* progress; 51 const internal::Sys* sys; 52 53 constexpr struct PciDeviceInfo static aspeedPciDeviceInfo = { 54 0x1a03, 0x2000, 0x10000, 0x10000, 1}; 55 constexpr struct PciDeviceInfo static nuvotonPciDeviceInfo = { 56 0x1050, 0x0750, 0x0, 0x4000, 0}; 57 const std::vector<PciDeviceInfo> PCIDeviceList = {aspeedPciDeviceInfo, 58 nuvotonPciDeviceInfo}; 59 }; 60 } // namespace host_tool 61