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/lpc.c b/lpc.c
index 9435246..3dc761a 100644
--- a/lpc.c
+++ b/lpc.c
@@ -27,7 +27,7 @@
 #include "mboxd.h"
 #include "common.h"
 #include "lpc.h"
-#include "flash.h"
+#include "backend.h"
 #include <linux/aspeed-lpc-ctrl.h>
 
 #define LPC_CTRL_PATH		"/dev/aspeed-lpc-ctrl"
@@ -108,9 +108,9 @@
 		 * The mask is because the top nibble is the host LPC FW space,
 		 * we want space 0.
 		 */
-		.addr = 0x0FFFFFFF & -context->flash_size,
+		.addr = 0x0FFFFFFF & -context->backend.flash_size,
 		.offset = 0,
-		.size = context->flash_size
+		.size = context->backend.flash_size
 	};
 
 	if (context->state & MAPS_FLASH) {
@@ -124,7 +124,7 @@
 
 	MSG_INFO("Pointing HOST LPC bus at the flash\n");
 	MSG_INFO("Assuming %dMB of flash: HOST LPC 0x%08x\n",
-		context->flash_size >> 20, map.addr);
+		context->backend.flash_size >> 20, map.addr);
 
 	if (ioctl(context->fds[LPC_CTRL_FD].fd, ASPEED_LPC_CTRL_IOCTL_MAP, &map)
 			== -1) {
@@ -138,7 +138,8 @@
 	 * Since the host now has access to the flash it can change it out from
 	 * under us
 	 */
-	return flash_set_bytemap(context, 0, context->flash_size, FLASH_DIRTY);
+	return flash_set_bytemap(context, 0, context->backend.flash_size,
+				 FLASH_DIRTY);
 }
 
 /*