pci: add region parameter to constructor
Add region parameter to constructor for PCI handler so that it knows
what value to send the host when requested.
Change-Id: Iefe1302aaaa43819f84b9730d01ff61dd545e2ef
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/configure.ac b/configure.ac
index da02696..52efb04 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,12 @@
AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
)
+AC_ARG_VAR(PCI_PHYSICAL_ADDRESS, [The physical address to use on the BMC for the PCI-to-AHB Bridge.])
+AS_IF([test "x$PCI_PHYSICAL_ADDRESS" == "x"],
+ [AC_DEFINE(PCI_PHYSICAL_ADDRESS, [0], [Default address to 0.])],
+ [AC_DEFINE(PCI_PHYSICAL_ADDRESS, [$PCI_PHYSICAL_ADDRESS], [Value for PCI-to-AHB bridge set.])]
+)
+
# Create configured output
AC_CONFIG_FILES([Makefile test/Makefile])
AC_OUTPUT
diff --git a/main.cpp b/main.cpp
index 5304c50..7095d15 100644
--- a/main.cpp
+++ b/main.cpp
@@ -21,7 +21,7 @@
HashFileHandler hashHandler;
StaticLayoutHandler staticLayoutHandler;
LpcDataHandler lpcDataHandler;
-PciDataHandler pciDataHandler;
+PciDataHandler pciDataHandler(PCI_PHYSICAL_ADDRESS);
std::vector<HandlerPack> supportedFirmware = {
{FirmwareBlobHandler::hashBlobID, &hashHandler},
diff --git a/pci_handler.cpp b/pci_handler.cpp
index dce1098..4937742 100644
--- a/pci_handler.cpp
+++ b/pci_handler.cpp
@@ -38,7 +38,7 @@
{
/* PCI handler does require returning a configuration from read. */
struct PciConfigResponse reply;
- reply.address = 0;
+ reply.address = regionAddress;
std::vector<std::uint8_t> bytes;
bytes.resize(sizeof(reply));
diff --git a/pci_handler.hpp b/pci_handler.hpp
index 755ee18..b72cab9 100644
--- a/pci_handler.hpp
+++ b/pci_handler.hpp
@@ -20,13 +20,17 @@
class PciDataHandler : public DataInterface
{
public:
- PciDataHandler() = default;
+ explicit PciDataHandler(std::uint32_t regionAddress) :
+ regionAddress(regionAddress){};
bool open() override;
bool close() override;
std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
bool write(const std::vector<std::uint8_t>& configuration) override;
std::vector<std::uint8_t> read() override;
+
+ private:
+ std::uint32_t regionAddress;
};
} // namespace blobs