mbox_msg: Move handler table to struct mbox_context

This allows us to provide alternative implementations for the handlers
as necessary. The vpnor feature, which enforces the read-only property
of FFS partitions, requires this for handling CREATE_WRITE_WINDOW.

Change-Id: Ia969a6f085244b194c500e66b62adca5e10bacba
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd_msg.c b/mboxd_msg.c
index 46679b8..4ca8e24 100644
--- a/mboxd_msg.c
+++ b/mboxd_msg.c
@@ -33,9 +33,6 @@
 static int mbox_handle_flush_window(struct mbox_context *context, union mbox_regs *req,
 			     struct mbox_msg *resp);
 
-typedef int (*mboxd_mbox_handler)(struct mbox_context *, union mbox_regs *,
-				  struct mbox_msg *);
-
 /*
  * write_bmc_event_reg() - Write to the BMC controlled status register (reg 15)
  * @context:	The mbox context pointer
@@ -754,7 +751,8 @@
 		resp.response = -rc;
 	} else {
 		/* Commands start at 1 so we have to subtract 1 from the cmd */
-		rc = mbox_handlers[req->msg.command - 1](context, req, &resp);
+		mboxd_mbox_handler h = context->handlers[req->msg.command - 1];
+		rc = h(context, req, &resp);
 		if (rc < 0) {
 			MSG_ERR("Error handling mbox cmd: %d\n",
 				req->msg.command);
@@ -835,6 +833,8 @@
 {
 	int fd;
 
+	context->handlers = mbox_handlers;
+
 	/* Open MBOX Device */
 	fd = open(path, O_RDWR | O_NONBLOCK);
 	if (fd < 0) {