pci: implement sending firmware image over p2a

Implement sending firmware image over p2a via the aspeed-p2a-ctrl
driver.

Test configuration:
# Image is static, uses the PCI bridge, and requires the ASPEED
# PCI-to-AHB hardware implementation.
EXTRA_OECONF_append_quanta-q71l = " --enable-static-layout"
EXTRA_OECONF_append_quanta-q71l = " --enable-pci-bridge"
EXTRA_OECONF_append_quanta-q71l = " --enable-aspeed-p2a"
EXTRA_OECONF_append_quanta-q71l = " MAPPED_ADDRESS=0x47FF0000"

Tested: Verified via md5sum the image-bmc file sent from the host via
this tool matches the hash of /run/initramfs/bmc-image.  This code can
be used to send any file down, but was only tested with a "static"
layout build.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I430bc7444f06f4f93a63e3bf2646bd195eaa2e52
diff --git a/tools/p2a.hpp b/tools/p2a.hpp
index f229449..eda8f61 100644
--- a/tools/p2a.hpp
+++ b/tools/p2a.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "interface.hpp"
+#include "internal/sys.hpp"
 #include "io.hpp"
 #include "pci.hpp"
 
@@ -9,6 +10,7 @@
 
 constexpr std::uint16_t aspeedVendorId = 0x1a03;
 constexpr std::uint16_t aspeedDeviceId = 0x2000;
+constexpr std::size_t aspeedP2aOffset = 0x10000;
 constexpr std::size_t aspeedP2aConfig = 0x0f000;
 constexpr std::size_t aspeedP2aBridge = 0x0f004;
 constexpr std::uint32_t p2ABridgeEnabled = 0x1;
@@ -20,9 +22,10 @@
 {
   public:
     P2aDataHandler(ipmiblob::BlobInterface* blob, HostIoInterface* io,
-                   PciUtilInterface* pci) :
+                   PciUtilInterface* pci,
+                   const internal::Sys* sys = &internal::sys_impl) :
         blob(blob),
-        io(io), pci(pci)
+        io(io), pci(pci), sys(sys)
     {
     }
 
@@ -36,6 +39,7 @@
     ipmiblob::BlobInterface* blob;
     HostIoInterface* io;
     PciUtilInterface* pci;
+    const internal::Sys* sys;
 };
 
 } // namespace host_tool