Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "interface.hpp" |
Patrick Venture | 18bbe3c | 2019-05-14 11:40:57 -0700 | [diff] [blame] | 4 | #include "internal/sys.hpp" |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 5 | #include "io.hpp" |
| 6 | #include "pci.hpp" |
Patrick Venture | cf9b219 | 2019-06-27 12:09:52 -0700 | [diff] [blame] | 7 | #include "progress.hpp" |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 8 | |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 9 | #include <ipmiblob/blob_interface.hpp> |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 10 | |
| 11 | #include <cstdint> |
Medad CChien | c8445aa | 2020-04-23 09:47:46 +0800 | [diff] [blame] | 12 | #include <vector> |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 13 | |
Patrick Venture | 2414161 | 2019-05-03 17:59:18 -0700 | [diff] [blame] | 14 | constexpr std::size_t aspeedP2aConfig = 0x0f000; |
| 15 | constexpr std::size_t aspeedP2aBridge = 0x0f004; |
| 16 | constexpr std::uint32_t p2ABridgeEnabled = 0x1; |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 17 | |
Medad CChien | c8445aa | 2020-04-23 09:47:46 +0800 | [diff] [blame] | 18 | struct 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 Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 27 | namespace host_tool |
| 28 | { |
| 29 | |
| 30 | class P2aDataHandler : public DataInterface |
| 31 | { |
| 32 | public: |
| 33 | P2aDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io, |
Patrick Venture | cf9b219 | 2019-06-27 12:09:52 -0700 | [diff] [blame] | 34 | PciUtilInterface* pci, ProgressInterface* progress, |
Patrick Venture | 18bbe3c | 2019-05-14 11:40:57 -0700 | [diff] [blame] | 35 | const internal::Sys* sys = &internal::sys_impl) : |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 36 | blob(blob), |
Patrick Venture | cf9b219 | 2019-06-27 12:09:52 -0700 | [diff] [blame] | 37 | io(io), pci(pci), progress(progress), sys(sys) |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 38 | {} |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 39 | |
| 40 | bool sendContents(const std::string& input, std::uint16_t session) override; |
Patrick Venture | 84778b8 | 2019-06-26 20:11:09 -0700 | [diff] [blame] | 41 | ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const override |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 42 | { |
Patrick Venture | 84778b8 | 2019-06-26 20:11:09 -0700 | [diff] [blame] | 43 | return ipmi_flash::FirmwareFlags::UpdateFlags::p2a; |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | private: |
| 47 | ipmiblob::BlobInterface* blob; |
| 48 | HostIoInterface* io; |
| 49 | PciUtilInterface* pci; |
Patrick Venture | cf9b219 | 2019-06-27 12:09:52 -0700 | [diff] [blame] | 50 | ProgressInterface* progress; |
Patrick Venture | 18bbe3c | 2019-05-14 11:40:57 -0700 | [diff] [blame] | 51 | const internal::Sys* sys; |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 52 | |
Medad CChien | c8445aa | 2020-04-23 09:47:46 +0800 | [diff] [blame] | 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 | }; |
Patrick Venture | b5bf0fc | 2019-05-03 14:33:49 -0700 | [diff] [blame] | 60 | } // namespace host_tool |