mboxd: Add a backend abstraction layer to mboxd.

Introduce a backend abstraction, enabling multiple implementations to be
compiled in at once. This change formally abstracts the two existing
backends, mtd and vpnor.

With the backend abstraction in place, subsequent backends are easier to
implement.

This change is based of Evan's work and he retains authorship credit. I
(AJ) have reworked the patch to pass the vpnor tests, refactored some
parts to enable broader use of const structures and others to clarify
the initialisation sequences.

Due to the existing lack of abstraction the patch has unfortunately
wide-ranging impacts. I've whittled it down as much as I consider
reasonable.

Change-Id: I29984a36dae4ea86ec00b853d2a756f0b9afb3ec
Signed-off-by: Evan Lojewski <github@meklort.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/vpnor/pnor_partition_table.cpp b/vpnor/pnor_partition_table.cpp
index 7e99ae2..2a9442b 100644
--- a/vpnor/pnor_partition_table.cpp
+++ b/vpnor/pnor_partition_table.cpp
@@ -14,8 +14,11 @@
 #include <phosphor-logging/elog-errors.hpp>
 #include <regex>
 
+extern "C" {
+#include "backend.h"
 #include "common.h"
 #include "mboxd.h"
+}
 
 namespace openpower
 {
@@ -28,11 +31,11 @@
 namespace partition
 {
 
-Table::Table(const struct mbox_context* ctx) :
+Table::Table(const struct backend* be) :
     szBytes(sizeof(pnor_partition_table)), numParts(0),
-    blockSize(1 << ctx->erase_size_shift), pnorSize(ctx->flash_size)
+    blockSize(1 << be->erase_size_shift), pnorSize(be->flash_size)
 {
-    preparePartitions(ctx);
+    preparePartitions((const struct vpnor_data*)be->priv);
     prepareHeader();
     hostTbl = endianFixup(tbl);
 }
@@ -74,10 +77,10 @@
     tbl.resize(capacity());
 }
 
-void Table::preparePartitions(const struct mbox_context* ctx)
+void Table::preparePartitions(const struct vpnor_data* priv)
 {
-    const fs::path roDir = ctx->paths.ro_loc;
-    const fs::path patchDir = ctx->paths.patch_loc;
+    const fs::path roDir(priv->paths.ro_loc);
+    const fs::path patchDir(priv->paths.patch_loc);
     fs::path tocFile = roDir / PARTITION_TOC_FILE;
     allocateMemory(tocFile);