summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2018-10-09 18:23:09 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-11 17:33:49 -0700
commita313e2fe2c78de8c2270483a1654ebd0f6530ccd (patch)
treea76e9cf355f325a4d78afa79fe25755221905dbe
parent3edb1220d1ef859df4ff4c7f2dece30d763deb6f (diff)
downloadchrome-ec-a313e2fe2c78de8c2270483a1654ebd0f6530ccd.tar.gz
cr50: CCD Info indicates whether all CCD capabilities are default.
CR50 provides whether CCD capabilities are default or not. Factory process can utilize this value instead of CCD cap bitmap information. Users can use either 'gsctool -I' or CR50 console command 'ccd'. BRANCH=cr50_tools BUG=b:117200472 TEST=manually set and clear the password using gsctool -a -F and check the result of gsctool -I. Change-Id: Ic6be2ce880476c3a73150fe0e29007dd6a7e328f Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1272190 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/ccd_config.c25
-rw-r--r--extra/usb_updater/gsctool.c5
-rw-r--r--include/ccd_config.h14
3 files changed, 41 insertions, 3 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c
index fa7c1cb133..c6946522c5 100644
--- a/common/ccd_config.c
+++ b/common/ccd_config.c
@@ -193,6 +193,23 @@ static void raw_set_cap(enum ccd_capability cap,
}
/**
+ * Check CCD configuration is reset to default value.
+ *
+ * @return 1 if it is in default mode.
+ * 0 otherwise.
+ */
+static int raw_check_all_caps_default(void)
+{
+ uint32_t i;
+
+ for (i = 0; i < CCD_CAP_COUNT; i++)
+ if (raw_get_cap(i, 0) != CCD_CAP_STATE_DEFAULT)
+ return 0;
+
+ return 1;
+}
+
+/**
* Check if a password is set.
* @return 1 if password is set, 0 if it's not
*/
@@ -693,6 +710,9 @@ static int command_ccd_info(void)
board_fwmp_allows_unlock() ? "" : " fwmp_lock",
board_vboot_dev_mode_enabled() ? " dev_mode" : "");
+ ccprintf("Capabilities are %s.\n", raw_check_all_caps_default() ?
+ "default" : "modified");
+
ccputs("Use 'ccd help' to print subcommands\n");
return EC_SUCCESS;
}
@@ -1327,7 +1347,10 @@ static enum vendor_cmd_rc ccd_get_info(struct vendor_cmd_params *p)
response.ccd_flags = htobe32(raw_get_flags());
response.ccd_state = ccd_get_state();
- response.ccd_has_password = raw_has_password();
+ response.ccd_indicator_bitmap = raw_has_password() ?
+ CCD_INDICATOR_BIT_HAS_PASSWORD : 0;
+ response.ccd_indicator_bitmap |= raw_check_all_caps_default() ?
+ CCD_INDICATOR_BIT_ALL_CAPS_DEFAULT : 0;
response.ccd_force_disabled = force_disabled;
for (i = 0; i < ARRAY_SIZE(response.ccd_caps_current); i++) {
response.ccd_caps_current[i] =
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c
index 66b859f675..577998aaf4 100644
--- a/extra/usb_updater/gsctool.c
+++ b/extra/usb_updater/gsctool.c
@@ -1522,7 +1522,8 @@ static void print_ccd_info(void *response, size_t response_size)
/* Now report CCD state on the console. */
printf("State: %s\n", ccd_info.ccd_state > ARRAY_SIZE(state_names) ?
"Error" : state_names[ccd_info.ccd_state]);
- printf("Password: %s\n", ccd_info.ccd_has_password ? "Set" : "None");
+ printf("Password: %s\n", (ccd_info.ccd_indicator_bitmap &
+ CCD_INDICATOR_BIT_HAS_PASSWORD) ? "Set" : "None");
printf("Flags: %#06x\n", ccd_info.ccd_flags);
printf("Capabilities, current and default:\n");
for (i = 0; i < CCD_CAP_COUNT; i++) {
@@ -1572,6 +1573,8 @@ static void print_ccd_info(void *response, size_t response_size)
caps_bitmap |= (1 << i);
}
printf("CCD caps bitmap: %#x\n", caps_bitmap);
+ printf("Capabilities are %s.\n", (ccd_info.ccd_indicator_bitmap &
+ CCD_INDICATOR_BIT_ALL_CAPS_DEFAULT) ? "default" : "modified");
}
static void process_ccd_state(struct transfer_descriptor *td, int ccd_unlock,
diff --git a/include/ccd_config.h b/include/ccd_config.h
index 4cc84ae770..5f21479cef 100644
--- a/include/ccd_config.h
+++ b/include/ccd_config.h
@@ -206,9 +206,21 @@ struct ccd_info_response {
uint32_t ccd_flags;
uint8_t ccd_state;
uint8_t ccd_force_disabled;
- uint8_t ccd_has_password;
+ /*
+ * A bitmap indicating ccd internal state.
+ * See "enum ccd_indicator_bits" below.
+ */
+ uint8_t ccd_indicator_bitmap;
} __packed;
+enum ccd_indicator_bits {
+ /* has_password? */
+ CCD_INDICATOR_BIT_HAS_PASSWORD = (1 << 0),
+
+ /* Are CCD capabilities in CCD_CAP_STATE_DEFAULT */
+ CCD_INDICATOR_BIT_ALL_CAPS_DEFAULT = (1 << 1),
+};
+
/**
* Initialize CCD configuration at boot.
*