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/protocol.c b/protocol.c
index 8eb06ae..2a04d89 100644
--- a/protocol.c
+++ b/protocol.c
@@ -532,3 +532,38 @@
{
return;
}
+
+/* Don't do any state manipulation, just perform the reset */
+int __protocol_reset(struct mbox_context *context)
+{
+ windows_reset_all(context);
+
+ return lpc_reset(context);
+}
+
+/* Prevent the host from performing actions whilst reset takes place */
+int protocol_reset(struct mbox_context *context)
+{
+ int rc;
+
+ rc = protocol_events_clear(context, BMC_EVENT_DAEMON_READY);
+ if (rc < 0) {
+ MSG_ERR("Failed to clear daemon ready state, reset failed\n");
+ return rc;
+ }
+
+ rc = __protocol_reset(context);
+ if (rc < 0) {
+ MSG_ERR("Failed to reset protocol, daemon remains not ready\n");
+ return rc;
+ }
+
+ rc = protocol_events_set(context,
+ BMC_EVENT_DAEMON_READY | BMC_EVENT_PROTOCOL_RESET);
+ if (rc < 0) {
+ MSG_ERR("Failed to set daemon ready state, daemon remains not ready\n");
+ return rc;
+ }
+
+ return 0;
+}