summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-06-09 16:21:26 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-18 18:45:14 +0000
commitdbc452b86b2541e9b0ec2c8a2c9ba724c66f9ce4 (patch)
tree648d33238b5f1ca3e2e3170d6dd2ea651fe7cff3
parent49a02d634caaa5db07653f1669ff9ae35268116d (diff)
downloadchrome-ec-dbc452b86b2541e9b0ec2c8a2c9ba724c66f9ce4.tar.gz
gsctool: add support for getting AP RO boot status
Add support for running the VENDOR_CC_GET_AP_RO_STATUS vendor command. BUG=b:182594555 TEST=gsctool -aB prints the AP RO verification status Change-Id: If14073894441657746a84cff8f778fd57a126625 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2951963 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--extra/usb_updater/gsctool.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c
index 62c1cff112..72cb576685 100644
--- a/extra/usb_updater/gsctool.c
+++ b/extra/usb_updater/gsctool.c
@@ -24,6 +24,7 @@
#include "config.h"
+#include "ap_ro_integrity_check.h"
#include "ccd_config.h"
#include "compile_time_macros.h"
#include "flash_log.h"
@@ -264,6 +265,8 @@ static const struct option_container cmd_line_options[] = {
{{"any", no_argument, NULL, 'a'},
"Try any interfaces to find Cr50"
" (-d, -s, -t are all ignored)"},
+ {{"get_apro_boot_status", no_argument, NULL, 'B'},
+ "get the stored ap ro boot state"},
{{"binvers", no_argument, NULL, 'b'},
"Report versions of Cr50 image's "
"RW and RO headers, do not update"},
@@ -2275,6 +2278,49 @@ static int process_get_apro_hash(struct transfer_descriptor *td)
return 0;
}
+static int process_get_apro_boot_status(struct transfer_descriptor *td)
+{
+ size_t response_size;
+ uint8_t response;
+ const char * const desc = "getting apro status";
+ int rv = 0;
+
+ response_size = sizeof(response);
+
+ rv = send_vendor_command(td, VENDOR_CC_GET_AP_RO_STATUS, NULL, 0,
+ &response, &response_size);
+ if (rv != VENDOR_RC_SUCCESS) {
+ fprintf(stderr, "Error %d %s\n", rv, desc);
+ return update_error;
+ }
+ if (response_size != 1) {
+ fprintf(stderr, "Unexpected response size %zd while %s\n",
+ response_size, desc);
+ return update_error;
+ }
+
+ /* Print the response and meaning, as in 'enum ap_ro_status'. */
+ printf("AP RO status = %d: ", response);
+ switch (response) {
+ case AP_RO_NOT_RUN:
+ printf("not run\n");
+ break;
+ case AP_RO_PASS:
+ printf("pass\n");
+ break;
+ case AP_RO_FAIL:
+ printf("FAIL\n");
+ break;
+ case AP_RO_UNSUPPORTED:
+ printf("unsupported\n");
+ break;
+ default:
+ fprintf(stderr, "unknown status\n");
+ return update_error;
+ }
+
+ return 0;
+}
static int process_get_boot_mode(struct transfer_descriptor *td)
{
@@ -2980,6 +3026,7 @@ int main(int argc, char *argv[])
int try_all_transfer = 0;
int tpm_mode = 0;
int get_apro_hash = 0;
+ int get_apro_boot_status = 0;
bool show_machine_output = false;
int tstamp = 0;
const char *tstamp_arg = NULL;
@@ -3004,6 +3051,7 @@ int main(int argc, char *argv[])
*/
const struct options_map omap[] = {
{ 'b', &binary_vers },
+ { 'B', &get_apro_boot_status },
{ 'c', &corrupt_inactive_rw },
{ 'D', &is_dauntless },
{ 'f', &show_fw_ver },
@@ -3206,6 +3254,7 @@ int main(int argc, char *argv[])
!ccd_unlock &&
!corrupt_inactive_rw &&
!get_apro_hash &&
+ !get_apro_boot_status &&
!get_boot_mode &&
!get_flog &&
!get_endorsement_seed &&
@@ -3326,6 +3375,9 @@ int main(int argc, char *argv[])
if (get_apro_hash)
exit(process_get_apro_hash(&td));
+ if (get_apro_boot_status)
+ exit(process_get_apro_boot_status(&td));
+
if (get_boot_mode)
exit(process_get_boot_mode(&td));