Add backend_adjust_offset to avoid the windows overlap

In mihawk, the windows overlap will cause the cache coherence.
Hostboot writes the SPD data to BMC through a window and read it
back with another window. It causes the data missed and DIMM lost.

Hostboot log
   23.80714|<<DBG-956|SPD::getMemType() - MemType: 0xff, Error: NoHUID: 0x30008.

BMC log: The overlaped windows
  Window @ 0x756e0000 for size 0x00046000 maps flash offset 0x000e7000
  Window @ 0x757e0000 for size 0x00048000 maps flash offset 0x000e5000

Tested: 1. In mihawk, it can fix the SPD cache coherence issue
        2. Add unit test to verify VPNOR offset alignment

Change-Id: I92670ade4e2a91b5c49a0acabfc0456f90d49b93
Signed-off-by: Alvin Wang <alvinwang@msn.com>
[AJ: Remove some MSG_INFO() spam, fix whitespace issues]
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/windows.c b/windows.c
index ebe16c1..a62b50c 100644
--- a/windows.c
+++ b/windows.c
@@ -574,26 +574,14 @@
 		window_reset(context, cur);
 	}
 
-/*
- * In case of the virtual pnor, as of now it's possible that a window may
- * have content less than it's max size. We basically copy one flash partition
- * per window, and some partitions are smaller than the max size. An offset
- * right after such a small partition ends should lead to new mapping. The code
- * below prevents that.
- */
-#ifndef VIRTUAL_PNOR_ENABLED
+	/* Adjust the offset for alignment by the backend. It will help prevent the
+	 * overlap.
+	 */
 	if (!exact) {
-		/*
-		 * It would be nice to align the offsets which we map to window
-		 * size, this will help prevent overlap which would be an
-		 * inefficient use of our reserved memory area (we would like
-		 * to "cache" as much of the acutal flash as possible in
-		 * memory). If we're protocol V1 however we must ensure the
-		 * offset requested is exactly mapped.
-		 */
-		offset &= ~(cur->size - 1);
+		if (backend_align_offset(&(context->backend), &offset, cur->size)) {
+			MSG_ERR("Can't adjust the offset by backend\n");
+		}
 	}
-#endif
 
 	if (offset > context->backend.flash_size) {
 		MSG_ERR("Tried to open read window past flash limit\n");