lpc_handler also requires a BMC address for mapping

Rename the PCI_PHYSICAL_ADDRESS to MAPPED_ADDRESS to refer to a region
of BMC memory reserved for the mapping.

Change-Id: Ie3f0a87a92c985cae0770162bf957caa1c035f82
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/configure.ac b/configure.ac
index 0dd8799..85ee568 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@
 AS_IF([test "x$enable_static_layout" = "xyes"], [
     AX_APPEND_COMPILE_FLAGS([-DENABLE_STATIC_LAYOUT], [CXXFLAGS])
 ])
+
 # Enable P2A, and or LPC (block-transfer is always enabled).
 AC_ARG_ENABLE([pci-bridge],
     AS_HELP_STRING([--enable-pci-bridge],
@@ -46,6 +47,16 @@
     AX_APPEND_COMPILE_FLAGS([-DENABLE_LPC_BRIDGE], [CXXFLAGS])
 ])
 
+# The address used for mapping P2A or LPC into the BMC's memory-space:
+# e.g. https://github.com/openbmc/linux/blob/1da2ce51886a3b2f5db2087f26c661e13ee13b84/arch/arm/boot/dts/aspeed-bmc-quanta-q71l.dts#L26
+# or https://github.com/openbmc/linux/blob/1da2ce51886a3b2f5db2087f26c661e13ee13b84/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts#L166
+# for PCI, this address is passed back to the host and is used directly.
+AC_ARG_VAR(MAPPED_ADDRESS, [The base address of the memory region reserved for mapping.])
+AS_IF([test "x$MAPPED_ADDRESS" == "x"],
+    [AC_DEFINE(MAPPED_ADDRESS, [0], [Default address to 0.])],
+    [AC_DEFINE(MAPPED_ADDRESS, [$MAPPED_ADDRESS], [Value for memory region mapping.])]
+)
+
 AC_ARG_ENABLE([aspeed-lpc],
     AS_HELP_STRING([--enable-aspeed-lpc],
                    [Enable external transfers using Aspeed LPC]))
@@ -96,12 +107,6 @@
     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.])]
-)
-
 AC_ARG_VAR(STATIC_HANDLER_STAGED_NAME, [The file to use for staging the firmware update.])
 AS_IF([test "x$STATIC_HANDLER_STAGED_NAME" == "x"], [STATIC_HANDLER_STAGED_NAME="/run/initramfs/bmc-image"])
 AC_DEFINE_UNQUOTED([STATIC_HANDLER_STAGED_NAME], ["$STATIC_HANDLER_STAGED_NAME"], [The file to use for staging the firmware update.])
diff --git a/lpc_handler.hpp b/lpc_handler.hpp
index 91c976b..52073da 100644
--- a/lpc_handler.hpp
+++ b/lpc_handler.hpp
@@ -29,9 +29,13 @@
     /**
      * Create an LpcDataHandler.
      *
+     * @param[in] regionAddress - BMC address to point the map for the LPC
+     * memory region.
      * @param[in] mapper - pointer to a mapper implementation to use.
      */
-    explicit LpcDataHandler(std::unique_ptr<LpcMapperInterface> mapper) :
+    LpcDataHandler(std::uint32_t regionAddress,
+                   std::unique_ptr<LpcMapperInterface> mapper) :
+        regionAddress(regionAddress),
         mapper(std::move(mapper))
     {
     }
@@ -43,6 +47,7 @@
     std::vector<std::uint8_t> read() override;
 
   private:
+    std::uint32_t regionAddress;
     std::unique_ptr<LpcMapperInterface> mapper;
 };
 
diff --git a/main.cpp b/main.cpp
index 0a43b96..7d87f27 100644
--- a/main.cpp
+++ b/main.cpp
@@ -21,15 +21,17 @@
 
 #ifdef ENABLE_LPC_BRIDGE
 #if defined(ASPEED_LPC)
-LpcDataHandler lpcDataHandler(LpcMapperAspeed::createAspeedMapper());
+LpcDataHandler lpcDataHandler(MAPPED_ADDRESS,
+                              LpcMapperAspeed::createAspeedMapper());
 #elif defined(NUVOTON_LPC)
-LpcDataHandler lpcDataHandler(LpcMapperNuvoton::createNuvotonMapper());
+LpcDataHandler lpcDataHandler(MAPPED_ADDRESS,
+                              LpcMapperNuvoton::createNuvotonMapper());
 #else
 #error "You must specify a hardware implementation."
 #endif
 #endif
 
-PciDataHandler pciDataHandler(PCI_PHYSICAL_ADDRESS);
+PciDataHandler pciDataHandler(MAPPED_ADDRESS);
 
 std::vector<HandlerPack> supportedFirmware = {
     {FirmwareBlobHandler::hashBlobID, &hashHandler},