mboxd: Refactor and rename mbox.h to mboxd.h

Refine the purpose of the header file to represent what's required for
the daemon itself, not its constituent pieces. Rather, split those
definitions out to their respective header files and include them as
necessary.

Finally the header file is renamed to better reflect its purpose.

Change-Id: I48c409f57d96c844589cd865b24f197477dfe87c
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/control.c b/control.c
index 01a2e5f..5470e45 100644
--- a/control.c
+++ b/control.c
@@ -3,8 +3,9 @@
 #include <errno.h>
 #include <stdlib.h>
 
+#include "common.h"
 #include "dbus.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "flash.h"
 #include "lpc.h"
 #include "transport_mbox.h"
diff --git a/control_dbus.c b/control_dbus.c
index c970b8f..c8c6463 100644
--- a/control_dbus.c
+++ b/control_dbus.c
@@ -7,7 +7,7 @@
 #include "common.h"
 #include "dbus.h"
 #include "control_dbus.h"
-#include "mbox.h"
+#include "mboxd.h"
 
 typedef int (*control_action)(struct mbox_context *context);
 
diff --git a/control_dbus.h b/control_dbus.h
index 4a3b2ff..17e4dec 100644
--- a/control_dbus.h
+++ b/control_dbus.h
@@ -1,7 +1,7 @@
 #ifndef DBUS_CONTROL_H
 #define DBUS_CONTROL_H
 
-#include "mbox.h"
+struct mbox_context;
 
 int control_dbus_init(struct mbox_context *context);
 void control_dbus_free(struct mbox_context *context);
diff --git a/control_legacy.c b/control_legacy.c
index 8ef9ea9..3e9a6df 100644
--- a/control_legacy.c
+++ b/control_legacy.c
@@ -6,7 +6,7 @@
 #include "common.h"
 #include "dbus.h"
 #include "control_dbus.h"
-#include "mbox.h"
+#include "mboxd.h"
 
 /* Command IDs (Legacy interface) */
 #define DBUS_C_PING            0x00
diff --git a/flash.c b/flash.c
index ee527dc..e6058f0 100644
--- a/flash.c
+++ b/flash.c
@@ -26,7 +26,7 @@
 #include <errno.h>
 #include <mtd/mtd-abi.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "common.h"
 #include "flash.h"
 
diff --git a/flash.h b/flash.h
index f646908..44f5155 100644
--- a/flash.h
+++ b/flash.h
@@ -4,13 +4,15 @@
 #ifndef FLASH_H
 #define FLASH_H
 
+#include <stdint.h>
+
 #define FLASH_DIRTY	0x00
 #define FLASH_ERASED	0x01
 
 /* Estimate as to how long (milliseconds) it takes to access a MB from flash */
 #define FLASH_ACCESS_MS_PER_MB		8000
 
-#include "mbox.h"
+struct mbox_context;
 
 int flash_dev_init(struct mbox_context *context);
 void flash_dev_free(struct mbox_context *context);
diff --git a/lpc.c b/lpc.c
index f64e5d1..9435246 100644
--- a/lpc.c
+++ b/lpc.c
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "common.h"
 #include "lpc.h"
 #include "flash.h"
diff --git a/lpc.h b/lpc.h
index cf91d42..eca78b2 100644
--- a/lpc.h
+++ b/lpc.h
@@ -4,6 +4,8 @@
 #ifndef LPC_H
 #define LPC_H
 
+struct mbox_context;
+
 int lpc_dev_init(struct mbox_context *context);
 void lpc_dev_free(struct mbox_context *context);
 int lpc_map_flash(struct mbox_context *context);
diff --git a/lpc_reset.c b/lpc_reset.c
index b1e7939..9b64aa7 100644
--- a/lpc_reset.c
+++ b/lpc_reset.c
@@ -3,9 +3,10 @@
 
 #define _GNU_SOURCE
 
-#include "mbox.h"
 #include "lpc.h"
 
+struct mbox_context;
+
 /*
  * lpc_reset() - Reset the lpc bus mapping
  * @context:	The mbox context pointer
diff --git a/mboxd.c b/mboxd.c
index a9ef8d9..3c10998 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -27,7 +27,7 @@
 #include <systemd/sd-bus.h>
 
 #include "config.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "common.h"
 #include "dbus.h"
 #include "control_dbus.h"
diff --git a/mbox.h b/mboxd.h
similarity index 62%
rename from mbox.h
rename to mboxd.h
index c2db30c..8fd3183 100644
--- a/mbox.h
+++ b/mboxd.h
@@ -12,6 +12,7 @@
 #include "protocol.h"
 #include "transport.h"
 #include "vpnor/mboxd_pnor_partition_table.h"
+#include "windows.h"
 
 enum api_version {
 	API_VERSION_INVAL	= 0,
@@ -24,29 +25,6 @@
 
 #define THIS_NAME			"Mailbox Daemon"
 
-/* Command Values */
-#define MBOX_C_RESET_STATE		0x01
-#define MBOX_C_GET_MBOX_INFO		0x02
-#define MBOX_C_GET_FLASH_INFO		0x03
-#define MBOX_C_READ_WINDOW		0x04
-#define MBOX_C_CLOSE_WINDOW		0x05
-#define MBOX_C_WRITE_WINDOW		0x06
-#define MBOX_C_WRITE_DIRTY		0x07
-#define MBOX_C_WRITE_FLUSH		0x08
-#define MBOX_C_ACK			0x09
-#define MBOX_C_WRITE_ERASE		0x0a
-#define NUM_MBOX_CMDS			MBOX_C_WRITE_ERASE
-
-/* Response Values */
-#define MBOX_R_SUCCESS			0x01
-#define MBOX_R_PARAM_ERROR		0x02
-#define MBOX_R_WRITE_ERROR		0x03
-#define MBOX_R_SYSTEM_ERROR		0x04
-#define MBOX_R_TIMEOUT			0x05
-#define MBOX_R_BUSY			0x06
-#define MBOX_R_WINDOW_ERROR		0x07
-#define MBOX_R_SEQ_ERROR		0x08
-
 /* Argument Flags */
 #define FLAGS_NONE			0x00
 #define FLAGS_SHORT_LIFETIME		0x01
@@ -64,21 +42,6 @@
 					BMC_EVENT_FLASH_CTRL_LOST | \
 					BMC_EVENT_DAEMON_READY)
 
-/* MBOX Registers */
-#define MBOX_HOST_PATH			"/dev/aspeed-mbox"
-#define MBOX_HOST_TIMEOUT_SEC		1
-#define MBOX_ARGS_BYTES			11
-#define MBOX_REG_BYTES			16
-#define MBOX_HOST_EVENT			14
-#define MBOX_BMC_EVENT			15
-
-#define BLOCK_SIZE_SHIFT_V1		12 /* 4K */
-
-/* Window Dirty/Erase bytemap masks */
-#define WINDOW_CLEAN			0x00
-#define WINDOW_DIRTY			0x01
-#define WINDOW_ERASED			0x02
-
 /* Put polled file descriptors first */
 #define DBUS_FD			0
 #define MBOX_FD			1
@@ -91,6 +54,7 @@
 #define MAPS_FLASH		(1 << 0)
 #define MAPS_MEM		(1 << 1)
 #define STATE_SUSPENDED		(1 << 7)
+
 enum mbox_state {
 	/* Still Initing */
 	UNINITIALISED = 0,
@@ -104,37 +68,6 @@
 	SUSPEND_MAPS_MEM = STATE_SUSPENDED | MAPS_MEM
 };
 
-#define FLASH_OFFSET_UNINIT	0xFFFFFFFF
-
-struct window_context {
-	void *mem;			/* Portion of Reserved Memory Region */
-	uint32_t flash_offset;		/* Flash area the window maps (bytes) */
-	uint32_t size;			/* Window Size (bytes) power-of-2 */
-	uint8_t *dirty_bmap;		/* Bytemap of the dirty/erased state */
-	uint32_t age;			/* Used for LRU eviction scheme */
-};
-
-struct window_list {
-	uint32_t num;
-	uint32_t max_age;
-	uint32_t default_size;
-	struct window_context *window;
-};
-
-struct mbox_msg {
-	uint8_t command;
-	uint8_t seq;
-	uint8_t args[MBOX_ARGS_BYTES];
-	uint8_t response;
-};
-
-union mbox_regs {
-	uint8_t raw[MBOX_REG_BYTES];
-	struct mbox_msg msg;
-};
-
-struct mbox_context;
-
 struct mbox_context {
 	enum api_version version;
 	const struct protocol_ops *protocol;
diff --git a/protocol.c b/protocol.c
index c18083f..c6934e6 100644
--- a/protocol.c
+++ b/protocol.c
@@ -7,10 +7,12 @@
 
 #include "common.h"
 #include "flash.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "lpc.h"
 #include "windows.h"
 
+#define BLOCK_SIZE_SHIFT_V1		12 /* 4K */
+
 /*
  * protocol_events_set() - Set BMC events
  * @context:	The mbox context pointer
diff --git a/protocol_negotiate_version.c b/protocol_negotiate_version.c
index 849363f..16b8e64 100644
--- a/protocol_negotiate_version.c
+++ b/protocol_negotiate_version.c
@@ -4,7 +4,7 @@
 
 #include <errno.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "protocol.h"
 
 static const struct protocol_ops protocol_ops_v1 = {
diff --git a/test/bmc_event_ack_v2.c b/test/bmc_event_ack_v2.c
index c9056de..51f026e 100644
--- a/test/bmc_event_ack_v2.c
+++ b/test/bmc_event_ack_v2.c
@@ -7,7 +7,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "mbox.h"
+#include "mboxd.h"
+#include "protocol.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/close_window_v2.c b/test/close_window_v2.c
index ae9c7f4..9b646f6 100644
--- a/test/close_window_v2.c
+++ b/test/close_window_v2.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/create_oversize_window.c b/test/create_oversize_window.c
index fa0f99d..2c842cb 100644
--- a/test/create_oversize_window.c
+++ b/test/create_oversize_window.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/create_read_window_v2.c b/test/create_read_window_v2.c
index 12f0208..4e8d1d2 100644
--- a/test/create_read_window_v2.c
+++ b/test/create_read_window_v2.c
@@ -2,8 +2,9 @@
 // Copyright (C) 2018 IBM Corp.
 
 #include <assert.h>
+#include <string.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/create_write_window_v2.c b/test/create_write_window_v2.c
index 568735a..b0e246e 100644
--- a/test/create_write_window_v2.c
+++ b/test/create_write_window_v2.c
@@ -2,8 +2,9 @@
 // Copyright (C) 2018 IBM Corp.
 
 #include <assert.h>
+#include <string.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/create_zero_size_window.c b/test/create_zero_size_window.c
index 14cff6c..3e936d0 100644
--- a/test/create_zero_size_window.c
+++ b/test/create_zero_size_window.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/flash_copy.c b/test/flash_copy.c
index 565bb0c..08dfc1a 100644
--- a/test/flash_copy.c
+++ b/test/flash_copy.c
@@ -10,7 +10,7 @@
 #include <unistd.h>
 
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "flash.h"
 
 #include "test/tmpf.h"
diff --git a/test/flash_erase.c b/test/flash_erase.c
index acbf378..3d299dd 100644
--- a/test/flash_erase.c
+++ b/test/flash_erase.c
@@ -5,12 +5,14 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 
 #include <linux/types.h>
 
-#include "mbox.h"
+#include "common.h"
+#include "mboxd.h"
 #include "flash.h"
 
 #include "test/tmpf.h"
diff --git a/test/flash_write.c b/test/flash_write.c
index cec6c92..1b55dbe 100644
--- a/test/flash_write.c
+++ b/test/flash_write.c
@@ -2,13 +2,16 @@
 // Copyright (C) 2018 IBM Corp.
 
 #include <assert.h>
+#include <mtd/mtd-abi.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <unistd.h>
 
-#include "mbox.h"
+#include "common.h"
+#include "mboxd.h"
 #include "flash.h"
 
 #include "test/tmpf.h"
diff --git a/test/get_flash_info_v2.c b/test/get_flash_info_v2.c
index 7fb3703..36ef8ac 100644
--- a/test/get_flash_info_v2.c
+++ b/test/get_flash_info_v2.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/get_mbox_info_v2.c b/test/get_mbox_info_v2.c
index bcfa2ef..081d3b8 100644
--- a/test/get_mbox_info_v2.c
+++ b/test/get_mbox_info_v2.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/get_mbox_info_v2_timeout.c b/test/get_mbox_info_v2_timeout.c
index c296f5a..f401360 100644
--- a/test/get_mbox_info_v2_timeout.c
+++ b/test/get_mbox_info_v2_timeout.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/implicit_flush.c b/test/implicit_flush.c
index 8c79cff..74275e4 100644
--- a/test/implicit_flush.c
+++ b/test/implicit_flush.c
@@ -4,7 +4,7 @@
 #include <assert.h>
 #include <sys/mman.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/invalid_command.c b/test/invalid_command.c
index c486dc5..36d0acc 100644
--- a/test/invalid_command.c
+++ b/test/invalid_command.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/mark_read_dirty.c b/test/mark_read_dirty.c
index ea2774a..766e3dc 100644
--- a/test/mark_read_dirty.c
+++ b/test/mark_read_dirty.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/mark_write_dirty_v2.c b/test/mark_write_dirty_v2.c
index 365750f..0c929fe 100644
--- a/test/mark_write_dirty_v2.c
+++ b/test/mark_write_dirty_v2.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/mark_write_erased_v2.c b/test/mark_write_erased_v2.c
index 4698ed3..9c0f172 100644
--- a/test/mark_write_erased_v2.c
+++ b/test/mark_write_erased_v2.c
@@ -4,7 +4,7 @@
 #include <assert.h>
 #include <sys/mman.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/mbox.c b/test/mbox.c
index 1b14430..6549813 100644
--- a/test/mbox.c
+++ b/test/mbox.c
@@ -13,7 +13,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "flash.h"
 #include "lpc.h"
 #include "transport_mbox.h"
diff --git a/test/mbox.h b/test/mbox.h
index 30d36b6..8c1bff9 100644
--- a/test/mbox.h
+++ b/test/mbox.h
@@ -8,7 +8,7 @@
 #include <stdint.h>
 
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "tmpf.h"
diff --git a/test/read_window_cycle.c b/test/read_window_cycle.c
index ec2bc37..8220c63 100644
--- a/test/read_window_cycle.c
+++ b/test/read_window_cycle.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/read_window_mark_write_erased.c b/test/read_window_mark_write_erased.c
index 61e760d..498ac62 100644
--- a/test/read_window_mark_write_erased.c
+++ b/test/read_window_mark_write_erased.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/read_window_write_flush.c b/test/read_window_write_flush.c
index 0131cb8..0f1cace 100644
--- a/test/read_window_write_flush.c
+++ b/test/read_window_write_flush.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/request_high_version.c b/test/request_high_version.c
index 9ffbba4..b8ad7a1 100644
--- a/test/request_high_version.c
+++ b/test/request_high_version.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/request_low_version.c b/test/request_low_version.c
index 7b7abf7..3670f61 100644
--- a/test/request_low_version.c
+++ b/test/request_low_version.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/reset_state.c b/test/reset_state.c
index 05f98d6..7e542a6 100644
--- a/test/reset_state.c
+++ b/test/reset_state.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/sequence_numbers.c b/test/sequence_numbers.c
index 201a5bd..3770a1b 100644
--- a/test/sequence_numbers.c
+++ b/test/sequence_numbers.c
@@ -3,7 +3,7 @@
 
 #include <assert.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/write_flush_v2.c b/test/write_flush_v2.c
index ff1be25..fafa7d0 100644
--- a/test/write_flush_v2.c
+++ b/test/write_flush_v2.c
@@ -4,7 +4,7 @@
 #include <assert.h>
 #include <sys/mman.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/test/write_window_dirty_erase.c b/test/write_window_dirty_erase.c
index 9bc25e7..e839890 100644
--- a/test/write_window_dirty_erase.c
+++ b/test/write_window_dirty_erase.c
@@ -4,7 +4,7 @@
 #include <assert.h>
 #include <sys/mman.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "transport_mbox.h"
 
 #include "test/mbox.h"
diff --git a/transport.h b/transport.h
index d6ec39e..e6a4584 100644
--- a/transport.h
+++ b/transport.h
@@ -4,7 +4,7 @@
 #ifndef TRANSPORT_H
 #define TRANSPORT_H
 
-#include "mbox.h"
+struct mbox_context;
 
 struct transport_ops {
 	int (*flush_events)(struct mbox_context *context);
diff --git a/transport_mbox.c b/transport_mbox.c
index 5db978f..d325b19 100644
--- a/transport_mbox.c
+++ b/transport_mbox.c
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "common.h"
 #include "transport_mbox.h"
 #include "windows.h"
diff --git a/transport_mbox.h b/transport_mbox.h
index c9d494d..b55da5e 100644
--- a/transport_mbox.h
+++ b/transport_mbox.h
@@ -4,8 +4,52 @@
 #ifndef MBOXD_MSG_H
 #define MBOXD_MSG_H
 
-#include "common.h"
-#include "mbox.h"
+#include <stdint.h>
+
+struct mbox_context;
+
+/* Command Values */
+#define MBOX_C_RESET_STATE		0x01
+#define MBOX_C_GET_MBOX_INFO		0x02
+#define MBOX_C_GET_FLASH_INFO		0x03
+#define MBOX_C_READ_WINDOW		0x04
+#define MBOX_C_CLOSE_WINDOW		0x05
+#define MBOX_C_WRITE_WINDOW		0x06
+#define MBOX_C_WRITE_DIRTY		0x07
+#define MBOX_C_WRITE_FLUSH		0x08
+#define MBOX_C_ACK			0x09
+#define MBOX_C_WRITE_ERASE		0x0a
+#define NUM_MBOX_CMDS			MBOX_C_WRITE_ERASE
+
+/* Response Values */
+#define MBOX_R_SUCCESS			0x01
+#define MBOX_R_PARAM_ERROR		0x02
+#define MBOX_R_WRITE_ERROR		0x03
+#define MBOX_R_SYSTEM_ERROR		0x04
+#define MBOX_R_TIMEOUT			0x05
+#define MBOX_R_BUSY			0x06
+#define MBOX_R_WINDOW_ERROR		0x07
+#define MBOX_R_SEQ_ERROR		0x08
+
+/* MBOX Registers */
+#define MBOX_HOST_PATH			"/dev/aspeed-mbox"
+#define MBOX_HOST_TIMEOUT_SEC		1
+#define MBOX_ARGS_BYTES			11
+#define MBOX_REG_BYTES			16
+#define MBOX_HOST_EVENT			14
+#define MBOX_BMC_EVENT			15
+
+struct mbox_msg {
+	uint8_t command;
+	uint8_t seq;
+	uint8_t args[MBOX_ARGS_BYTES];
+	uint8_t response;
+};
+
+union mbox_regs {
+	uint8_t raw[MBOX_REG_BYTES];
+	struct mbox_msg msg;
+};
 
 int transport_mbox_dispatch(struct mbox_context *context);
 int transport_mbox_init(struct mbox_context *context);
diff --git a/vpnor/lpc_reset.cpp b/vpnor/lpc_reset.cpp
index 3874b5e..8143737 100644
--- a/vpnor/lpc_reset.cpp
+++ b/vpnor/lpc_reset.cpp
@@ -18,7 +18,7 @@
  */
 
 extern "C" {
-#include "mbox.h"
+#include "mboxd.h"
 #include "lpc.h"
 }
 
diff --git a/vpnor/mboxd_pnor_partition_table.cpp b/vpnor/mboxd_pnor_partition_table.cpp
index 329e065..23fc4cf 100644
--- a/vpnor/mboxd_pnor_partition_table.cpp
+++ b/vpnor/mboxd_pnor_partition_table.cpp
@@ -7,7 +7,7 @@
 #include "mboxd_pnor_partition_table.h"
 #include "pnor_partition_table.hpp"
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "pnor_partition_table.hpp"
 #include "config.h"
 #include "xyz/openbmc_project/Common/error.hpp"
diff --git a/vpnor/pnor_partition.hpp b/vpnor/pnor_partition.hpp
index eb63a39..e98890d 100644
--- a/vpnor/pnor_partition.hpp
+++ b/vpnor/pnor_partition.hpp
@@ -3,7 +3,7 @@
 #pragma once
 
 extern "C" {
-#include "mbox.h"
+#include "mboxd.h"
 };
 
 #include "mboxd_pnor_partition_table.h"
diff --git a/vpnor/pnor_partition_table.cpp b/vpnor/pnor_partition_table.cpp
index 4ad07bc..c77b938 100644
--- a/vpnor/pnor_partition_table.cpp
+++ b/vpnor/pnor_partition_table.cpp
@@ -3,6 +3,7 @@
 #include "pnor_partition_table.hpp"
 #include "common.h"
 #include "config.h"
+#include "mboxd.h"
 #include "xyz/openbmc_project/Common/error.hpp"
 #include <phosphor-logging/elog-errors.hpp>
 #include <syslog.h>
diff --git a/vpnor/pnor_partition_table.hpp b/vpnor/pnor_partition_table.hpp
index 10dccdd..8b80d74 100644
--- a/vpnor/pnor_partition_table.hpp
+++ b/vpnor/pnor_partition_table.hpp
@@ -7,9 +7,10 @@
 #include <numeric>
 #include <experimental/filesystem>
 #include "common.h"
-#include "mbox.h"
 #include "pnor_partition_defs.h"
 
+struct mbox_context;
+
 namespace openpower
 {
 namespace virtual_pnor
diff --git a/vpnor/protocol.cpp b/vpnor/protocol.cpp
index 57b35a7..e5e1ad8 100644
--- a/vpnor/protocol.cpp
+++ b/vpnor/protocol.cpp
@@ -3,7 +3,7 @@
 #include "config.h"
 
 extern "C" {
-#include "mbox.h"
+#include "mboxd.h"
 #include "protocol.h"
 #include "vpnor/protocol.h"
 }
diff --git a/vpnor/protocol_negotiate_version.cpp b/vpnor/protocol_negotiate_version.cpp
index 4aff8db..046d536 100644
--- a/vpnor/protocol_negotiate_version.cpp
+++ b/vpnor/protocol_negotiate_version.cpp
@@ -5,7 +5,7 @@
 #include <errno.h>
 
 extern "C" {
-#include "mbox.h"
+#include "mboxd.h"
 #include "protocol.h"
 #include "vpnor/protocol.h"
 }
diff --git a/vpnor/test/tmpd.hpp b/vpnor/test/tmpd.hpp
index 09d53ee..19890eb 100644
--- a/vpnor/test/tmpd.hpp
+++ b/vpnor/test/tmpd.hpp
@@ -8,7 +8,7 @@
 #include <experimental/filesystem>
 
 #include "config.h"
-#include "mbox.h"
+#include "mboxd.h"
 #include "vpnor/pnor_partition_table.hpp"
 
 namespace openpower
diff --git a/vpnor/test/write_patch.cpp b/vpnor/test/write_patch.cpp
index 5d93fc9..e5a367d 100644
--- a/vpnor/test/write_patch.cpp
+++ b/vpnor/test/write_patch.cpp
@@ -11,7 +11,7 @@
 
 #include "config.h"
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 extern "C" {
 #include "flash.h"
 }
diff --git a/vpnor/test/write_patch_resize.cpp b/vpnor/test/write_patch_resize.cpp
index b55727b..28a73ce 100644
--- a/vpnor/test/write_patch_resize.cpp
+++ b/vpnor/test/write_patch_resize.cpp
@@ -12,7 +12,7 @@
 
 #include "config.h"
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 
 extern "C" {
 #include "flash.h"
diff --git a/vpnor/test/write_prsv.cpp b/vpnor/test/write_prsv.cpp
index c358ae1..21a0366 100644
--- a/vpnor/test/write_prsv.cpp
+++ b/vpnor/test/write_prsv.cpp
@@ -9,7 +9,7 @@
 #include <unistd.h>
 
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 extern "C" {
 #include "flash.h"
 }
diff --git a/vpnor/test/write_ro.cpp b/vpnor/test/write_ro.cpp
index 95e953c..13c0eae 100644
--- a/vpnor/test/write_ro.cpp
+++ b/vpnor/test/write_ro.cpp
@@ -9,7 +9,7 @@
 #include <unistd.h>
 
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 
 extern "C" {
 #include "flash.h"
diff --git a/vpnor/test/write_rw.cpp b/vpnor/test/write_rw.cpp
index 88ef97f..c40af6a 100644
--- a/vpnor/test/write_rw.cpp
+++ b/vpnor/test/write_rw.cpp
@@ -9,7 +9,7 @@
 #include <unistd.h>
 
 #include "common.h"
-#include "mbox.h"
+#include "mboxd.h"
 extern "C" {
 #include "flash.h"
 }
diff --git a/windows.c b/windows.c
index b56f73f..b11ea4a 100644
--- a/windows.c
+++ b/windows.c
@@ -25,7 +25,7 @@
 #include <inttypes.h>
 #include <mtd/mtd-abi.h>
 
-#include "mbox.h"
+#include "mboxd.h"
 #include "common.h"
 #include "transport_mbox.h"
 #include "windows.h"
diff --git a/windows.h b/windows.h
index 711f77f..1e90066 100644
--- a/windows.h
+++ b/windows.h
@@ -7,7 +7,29 @@
 #define WINDOWS_NO_FLUSH	false
 #define WINDOWS_WITH_FLUSH	true
 
-#include "mbox.h"
+struct mbox_context;
+
+/* Window Dirty/Erase bytemap masks */
+#define WINDOW_CLEAN			0x00
+#define WINDOW_DIRTY			0x01
+#define WINDOW_ERASED			0x02
+
+#define FLASH_OFFSET_UNINIT	0xFFFFFFFF
+
+struct window_context {
+	void *mem;			/* Portion of Reserved Memory Region */
+	uint32_t flash_offset;		/* Flash area the window maps (bytes) */
+	uint32_t size;			/* Window Size (bytes) power-of-2 */
+	uint8_t *dirty_bmap;		/* Bytemap of the dirty/erased state */
+	uint32_t age;			/* Used for LRU eviction scheme */
+};
+
+struct window_list {
+	uint32_t num;
+	uint32_t max_age;
+	uint32_t default_size;
+	struct window_context *window;
+};
 
 /* Initialisation Functions */
 int windows_init(struct mbox_context *context);