protocol: Introduce protocol_reset()

protocol_reset() encapsulates the actions necessary to return the LPC
state to what's required to boot the host. This is backend dependent;
for the mtd backend we can simply point the bridge at the host flash
AHB mapping, and for the virtual pnor we want to rearrange the content
of the LPC reserved memory (leaving the bridge pointed there). In either
case the state of the FWH address space is distured, so inform the host
as necessary.

Change-Id: Ie8efd1f703a3616c33f76f4e735c1efea039146c
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd.c b/mboxd.c
index 84bbf69..c2f2623 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -147,21 +147,9 @@
 				context->terminate = true;
 				break;
 			case SIGHUP:
-				/* Host didn't request reset -> Notify it */
-				if (windows_reset_all(context)) {
-				       rc = protocol_events_set(context,
-						     BMC_EVENT_WINDOW_RESET);
-				       if (rc < 0) {
-					      MSG_ERR("Failed to notify host of reset, expect host-side corruption\n");
-					      break;
-				       }
-				}
-				rc = lpc_reset(context);
+				rc = protocol_reset(context);
 				if (rc < 0) {
-					MSG_ERR("WARNING: Failed to point the "
-						"LPC bus back to flash on "
-						"SIGHUP\nIf the host requires "
-						"this expect problems...\n");
+					MSG_ERR("Failed to reset on SIGHUP\n");
 				}
 				break;
 			default:
@@ -191,15 +179,9 @@
 		}
 	}
 
-	/* Best to reset windows and the lpc mapping for safety */
-	/* Host didn't request reset -> Notify it */
-	windows_reset_all(context);
-
-	rc = lpc_reset(context);
-	/* Not much we can do if this fails */
+	rc = protocol_reset(context);
 	if (rc < 0) {
-		MSG_ERR("WARNING: Failed to point the LPC bus back to flash\n"
-			"If the host requires this expect problems...\n");
+		MSG_ERR("Failed to reset during poll loop cleanup\n");
 	}
 
 	return rc;
@@ -407,10 +389,7 @@
 #endif
 
 	/* Set the LPC bus mapping */
-	rc = lpc_reset(context);
-	if (rc) {
-		MSG_ERR("LPC configuration failed, RESET required: %d\n", rc);
-	}
+	__protocol_reset(context);
 
 	/* We're ready to go, alert the host */
 	context->bmc_events |= BMC_EVENT_DAEMON_READY;