flash: Introduce flash_validate()

Clean up the protocol_negotiate_version() mess. The existing approach
came about due to viewing the vpnor implementation as an edge case in
its own right. The code becomes much neater if we consider all backends
as equal and afford them the callbacks necessary for correct behaviour.

Change-Id: Ifaeee9da459818cf22b2f137ddc5b8d0356b9be9
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/flash.h b/flash.h
index 44f5155..2760563 100644
--- a/flash.h
+++ b/flash.h
@@ -4,6 +4,7 @@
 #ifndef FLASH_H
 #define FLASH_H
 
+#include <stdbool.h>
 #include <stdint.h>
 
 #define FLASH_DIRTY	0x00
@@ -16,6 +17,8 @@
 
 int flash_dev_init(struct mbox_context *context);
 void flash_dev_free(struct mbox_context *context);
+int flash_validate(struct mbox_context *context, uint32_t offset,
+		   uint32_t size, bool ro);
 int64_t flash_copy(struct mbox_context *context, uint32_t offset, void *mem,
 		   uint32_t size);
 int flash_set_bytemap(struct mbox_context *context, uint32_t offset,