Vboot wrapper API - crossystem and header files

Header file changes for wrapper API implementation

Crossystem support for reading recovery reason from VbSharedData, and
explicit support for version 1 VbSharedData structs.

BUG=chromium-os:16970
TEST=make && make runtests; run crossystem on Alex and make sure it still reports recovery_reason in recovery mode.

Change-Id: I15195b899583e425d3c9e8df09842d764528e2cb
Reviewed-on: http://gerrit.chromium.org/gerrit/3203
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 7ad5d80..54d0856 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -36,8 +36,9 @@
   VDAT_INT_FW_VERSION_TPM,           /* Current firmware version in TPM */
   VDAT_INT_KERNEL_VERSION_TPM,       /* Current kernel version in TPM */
   VDAT_INT_TRIED_FIRMWARE_B,         /* Tried firmware B due to fwb_tries */
-  VDAT_INT_KERNEL_KEY_VERIFIED       /* Kernel key verified using
+  VDAT_INT_KERNEL_KEY_VERIFIED,      /* Kernel key verified using
                                       * signature, not just hash */
+  VDAT_INT_RECOVERY_REASON           /* Recovery reason for current boot */
 } VdatIntField;
 
 
@@ -325,6 +326,11 @@
     case VDAT_INT_KERNEL_KEY_VERIFIED:
       value = (sh->flags & VBSD_KERNEL_KEY_VERIFIED ? 1 : 0);
       break;
+    case VDAT_INT_RECOVERY_REASON:
+      /* Field added in struct version 2 */
+      if (sh->struct_version >= 2)
+        value = sh->recovery_reason;
+      break;
   }
 
   Free(sh);
@@ -373,6 +379,8 @@
     value = GetVdatInt(VDAT_INT_KERNEL_VERSION_TPM);
   } else if (!strcasecmp(name,"tried_fwb")) {
     value = GetVdatInt(VDAT_INT_TRIED_FIRMWARE_B);
+  } else if (!strcasecmp(name,"recovery_reason")) {
+    value = GetVdatInt(VDAT_INT_RECOVERY_REASON);
   }
 
   return value;