tools: p2a: read the PCI configuration

Read the PCI configuration from the blob handler itself.  Don't use this
yet, but read it.

Tested: Verified with a bugfix in ipmi-blob-tool that it was able to
read back and print the value configured into the BMC image.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I49a8c93508e64a65fd37b50ec2b437f0016272f2
diff --git a/tools/p2a.cpp b/tools/p2a.cpp
index 5f9880a..5dcf6c9 100644
--- a/tools/p2a.cpp
+++ b/tools/p2a.cpp
@@ -17,6 +17,9 @@
 #include "p2a.hpp"
 
 #include "pci.hpp"
+#include "pci_handler.hpp"
+
+#include <cstring>
 
 namespace host_tool
 {
@@ -74,6 +77,17 @@
     std::fprintf(stderr, "The bridge is enabled!\n");
 
     /* Read the configuration via blobs metadata (stat). */
+    ipmiblob::StatResponse stat = blob->getStat(session);
+    if (stat.metadata.size() != sizeof(blobs::PciConfigResponse))
+    {
+        std::fprintf(stderr, "Didn't receive expected size of metadata for "
+                             "PCI Configuration response\n");
+        return false;
+    }
+
+    blobs::PciConfigResponse pciResp;
+    std::memcpy(&pciResp, stat.metadata.data(), sizeof(pciResp));
+    std::fprintf(stderr, "Received address: 0x%x\n", pciResp.address);
 
 #if 0
     /* Configure the mmio to point there. */