Merge remote-tracking branch 'goog/upstream-master' into D2-SC-022 am: 7ac0566074

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/nos/host/generic/+/14635582

Change-Id: Ic413bbc31690a0115fed1b550e8055b9b1315810
diff --git a/nugget/include/app_nugget.h b/nugget/include/app_nugget.h
index 6a51365..525e774 100644
--- a/nugget/include/app_nugget.h
+++ b/nugget/include/app_nugget.h
@@ -350,6 +350,26 @@
  * @errors             APP_ERROR_BOGUS_ARGS
  */
 
+enum nugget_sjtag_avb_boot_lock_result {
+   AVB_BOOT_LOCK_DISABLED,
+   AVB_BOOT_LOCK_ENABLED,
+   AVB_BOOT_LOCK_ERROR,
+};
+
+#define NUGGET_PARAM_SJTAG_ALLOW 0x0013
+/*
+ * Get the SJTAG ALLOW
+ *
+ * This always returns the current state of the SJTAG ALLOW feature.
+ *
+ * @param args         <none>
+ * @param arg_len        0
+ * @param reply        0(DISALLOW) OR 1(ALLOW)
+ * @param reply_len    1 byte
+ *
+ * @errors             APP_ERROR_BOGUS_ARGS
+ */
+
 /****************************************************************************/
 /* Test related commands */
 
@@ -392,10 +412,11 @@
 
 /*
  * This struct is specific to Citadel and Nugget OS, but it's enough for the
- * AP-side implementation to translate into the info required for the HAL
- * structs.
+ * AP-side implementation to translate into the info required for the power
+ * stats service.
  */
-struct nugget_app_low_power_stats {
+#define NUGGET_APP_LOW_POWER_STATS_MAGIC 0xC0DEACE1
+struct nugget_app_low_power_stats { /* version 1 */
   /* All times in usecs */
   uint64_t hard_reset_count;                    /* Cleared by power loss */
   uint64_t time_since_hard_reset;
@@ -408,6 +429,18 @@
   uint64_t time_spent_in_deep_sleep;
   uint64_t time_at_ap_reset;
   uint64_t time_at_ap_bootloader_done;
+  /*
+   * New fields for v1, used by factory tests. The caller can tell whether the
+   * firmare supports these fields by checking the v1_magic value.
+   */
+  uint32_t v1_magic; /* NUGGET_APP_LOW_POWER_STATS_MAGIC */
+  uint32_t temp;
+  struct {
+    unsigned int phone_on_l : 1;
+    unsigned int vol_up_l : 1;
+    unsigned int vol_dn_l : 1;
+    unsigned int _padding : 29; /* pad to 32 bits */
+  } signals;
 } __packed;
 
 #define NUGGET_PARAM_GET_LOW_POWER_STATS 0x200
@@ -540,6 +573,21 @@
  * @param reply_len    0
  */
 
+#define NUGGET_PARAM_TRIGGER_PIN 0xF005
+/**
+ * Get/Set trigger pin level
+ *
+ * This command asks GSC to set the level (0|1) of an otherwise unused GPIO,
+ * to signal external test equipment.
+ *
+ * @param args         0     OR   1
+ * @param arg_len      0     OR   1 byte
+ * @param reply        current state (0 or 1)
+ * @param reply_len    1 byte
+ *
+ * @errors             APP_ERROR_BOGUS_ARGS
+ */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/nugget/proto/nugget/app/keymaster/keymaster_defs.proto b/nugget/proto/nugget/app/keymaster/keymaster_defs.proto
index 719215e..da597b1 100644
--- a/nugget/proto/nugget/app/keymaster/keymaster_defs.proto
+++ b/nugget/proto/nugget/app/keymaster/keymaster_defs.proto
@@ -31,7 +31,7 @@
   ULONG = 0x50000;         /* 5 << 16 */
   DATE = 0x60000;          /* 6 << 16 */
   BOOL = 0x70000;          /* 7 << 16 */
-  /*  BIGNUM = 0x80000;         8 << 16 */  /* Unused. */
+  BIGNUM_ = 0x80000;       /* 8 << 16 */
   BYTES = 0x90000;         /* 9 << 16 */
   ULONG_REP = 0xA0000;     /* 10 << 16 */
 };
@@ -104,7 +104,9 @@
   /* RESERVED: AUTH_TOKEN = 0x903ea; // (TagType:BYTES | 1002) */
   MAC_LENGTH = 0x303eb; // (TagType:UINT | 1003)
   RESET_SINCE_ID_ROTATION = 0x703ec; // (TagType:BOOL | 1004)
-  CONFIRMATION_TOKEN = 0x903ed;// (TagType:BYTES | 1005)
+  CONFIRMATION_TOKEN = 0x903ed; // (TagType:BYTES | 1005)
+  CERTIFICATE_SERIAL = 0x803ee; // (TagType:BIGNUM | 1006)
+  CERTIFICATE_SUBJECT = 0x903ef; // (TagType:BYTES | 1007)
 };
 
 enum Algorithm {