vboot2: More specific errors for unimplemented external APIs

When porting vboot2 to a platform, it's common to copy 2stub.c and
then start implementing APIs.  Adding explicit errors makes it clearer
when an unimplemented API is called.

BUG=chromium:370082
BRANCH=none
TEST=VBOOT2=1 make runtests

Change-Id: I1f412b7ed4b431dbdbdee5e33b27bf7206186918
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204960
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
diff --git a/firmware/2lib/2stub.c b/firmware/2lib/2stub.c
index a544a4f..7c9e5b1 100644
--- a/firmware/2lib/2stub.c
+++ b/firmware/2lib/2stub.c
@@ -10,7 +10,7 @@
 
 int vb2ex_tpm_clear_owner(struct vb2_context *ctx)
 {
-	return VB2_SUCCESS;
+	return VB2_ERROR_EX_TPM_CLEAR_OWNER_UNIMPLEMENTED;
 }
 
 int vb2ex_read_resource(struct vb2_context *ctx,
@@ -19,5 +19,5 @@
 			void *buf,
 			uint32_t size)
 {
-	return VB2_SUCCESS;
+	return VB2_ERROR_EX_READ_RESOURCE_UNIMPLEMENTED;
 }
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index fb00936..77d0dd8 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -336,6 +336,9 @@
 	 */
 	VB2_ERROR_EX = VB2_ERROR_BASE + 0x0a0000,
 
+	/* Read resource not implemented */
+	VB2_ERROR_EX_READ_RESOURCE_UNIMPLEMENTED,
+
 	/* Resource index not found */
 	VB2_ERROR_EX_READ_RESOURCE_INDEX,
 
@@ -345,6 +348,9 @@
 	/* TPM clear owner failed */
 	VB2_ERROR_EX_TPM_CLEAR_OWNER,
 
+	/* TPM clear owner not implemented */
+	VB2_ERROR_EX_TPM_CLEAR_OWNER_UNIMPLEMENTED,
+
         /**********************************************************************
 	 * Highest non-zero error generated inside vboot library.  Note that
 	 * error codes passed through vboot when it calls external APIs may