blob: 1d1cb2dbfc9dfe862eb03411dd8b545dee3ca390 [file] [log] [blame]
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -07001#pragma once
2
3#include "interface.hpp"
Patrick Venture18bbe3c2019-05-14 11:40:57 -07004#include "internal/sys.hpp"
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -07005#include "io.hpp"
6#include "pci.hpp"
Patrick Venturecf9b2192019-06-27 12:09:52 -07007#include "progress.hpp"
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -07008
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -07009#include <ipmiblob/blob_interface.hpp>
Patrick Venture9b37b092020-05-28 20:58:57 -070010
11#include <cstdint>
Medad CChienc8445aa2020-04-23 09:47:46 +080012#include <vector>
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070013
Patrick Venture24141612019-05-03 17:59:18 -070014constexpr std::size_t aspeedP2aConfig = 0x0f000;
15constexpr std::size_t aspeedP2aBridge = 0x0f004;
16constexpr std::uint32_t p2ABridgeEnabled = 0x1;
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070017
Medad CChienc8445aa2020-04-23 09:47:46 +080018struct PciDeviceInfo
19{
20 std::uint16_t VID;
21 std::uint16_t DID;
22 std::size_t Offset;
23 std::size_t Length;
24 std::uint16_t bar;
25};
26
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070027namespace host_tool
28{
29
30class P2aDataHandler : public DataInterface
31{
32 public:
33 P2aDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io,
Patrick Venturecf9b2192019-06-27 12:09:52 -070034 PciUtilInterface* pci, ProgressInterface* progress,
Patrick Venture18bbe3c2019-05-14 11:40:57 -070035 const internal::Sys* sys = &internal::sys_impl) :
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070036 blob(blob),
Patrick Venturecf9b2192019-06-27 12:09:52 -070037 io(io), pci(pci), progress(progress), sys(sys)
Patrick Venture9b37b092020-05-28 20:58:57 -070038 {}
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070039
40 bool sendContents(const std::string& input, std::uint16_t session) override;
Patrick Venture84778b82019-06-26 20:11:09 -070041 ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const override
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070042 {
Patrick Venture84778b82019-06-26 20:11:09 -070043 return ipmi_flash::FirmwareFlags::UpdateFlags::p2a;
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070044 }
45
46 private:
47 ipmiblob::BlobInterface* blob;
48 HostIoInterface* io;
49 PciUtilInterface* pci;
Patrick Venturecf9b2192019-06-27 12:09:52 -070050 ProgressInterface* progress;
Patrick Venture18bbe3c2019-05-14 11:40:57 -070051 const internal::Sys* sys;
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070052
Medad CChienc8445aa2020-04-23 09:47:46 +080053 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};
Patrick Ventureb5bf0fc2019-05-03 14:33:49 -070060} // namespace host_tool