summaryrefslogtreecommitdiff
path: root/common/rma_auth.c
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@google.com>2018-05-22 15:55:23 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-30 20:38:53 -0700
commit5a23e3f49ac76e854b51279bc4c2a922ef24339c (patch)
tree541be148b982c8d54267fa6fe60ca05168ce22ea /common/rma_auth.c
parent7b0018521683070cfa5beda948a8ea5278d802cc (diff)
downloadchrome-ec-5a23e3f49ac76e854b51279bc4c2a922ef24339c.tar.gz
cr50: refactor rma mode into factory mode
We're doing a bit of refactoring to break out factory mode into its own file. Now factory reset and rma reset will be two methods of entering factory mode. Factory mode can be disabled with the disable_factory vendor command. Factory mode means all ccd capabilities are set to Always and WP is permanently disabled. When factory mode is disabled, all capabilities are reset to Default and WP is reset to follow battery presence. This adds 56 bytes. BUG=none BRANCH=cr50 TEST=verify rma reset will enable factory mode. Change-Id: I21c6f7b4341e3a18e213e438bbd17c67739b85fa Signed-off-by: Mary Ruthven <mruthven@google.com> Reviewed-on: https://chromium-review.googlesource.com/1069789 Commit-Ready: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/rma_auth.c')
-rw-r--r--common/rma_auth.c76
1 files changed, 1 insertions, 75 deletions
diff --git a/common/rma_auth.c b/common/rma_auth.c
index 87894e70ad..e3d5470aad 100644
--- a/common/rma_auth.c
+++ b/common/rma_auth.c
@@ -322,79 +322,6 @@ static enum vendor_cmd_rc get_challenge(uint8_t *buf, size_t *buf_size)
#endif
return VENDOR_RC_SUCCESS;
}
-
-static uint8_t ccd_hook_active;
-
-static void ccd_config_changed(void)
-{
- if (!ccd_hook_active)
- return;
-
- CPRINTF("%s: CCD change saved, rebooting\n", __func__);
- cflush();
- system_reset(SYSTEM_RESET_HARD);
-}
-DECLARE_HOOK(HOOK_CCD_CHANGE, ccd_config_changed, HOOK_PRIO_LAST);
-
-static void rma_reset_failed(void)
-{
- ccd_hook_active = 0;
- CPRINTF("%s: CCD RMA reset failed\n");
- deassert_ec_rst();
-}
-DECLARE_DEFERRED(rma_reset_failed);
-
-/* The below time constants are way longer than should be required in practice:
- *
- * Time it takes to finish processing TPM command which provided valid RMA
- * authentication code.
- */
-#define TPM_PROCESSING_TIME (1 * SECOND)
-
-/*
- * Time it takse TPM reset function to wipe out the NVMEM and reboot the
- * device.
- */
-#define TPM_RESET_TIME (10 * SECOND)
-
-/* Total time deep sleep should not be allowed. */
-#define DISABLE_SLEEP_TIME (TPM_PROCESSING_TIME + TPM_RESET_TIME)
-
-static void enter_rma_mode(void)
-{
- int rv;
-
- CPRINTF("%s: resetting TPM\n", __func__);
-
- /*
- * Let's make sure the rest of the system is out of the way while TPM
- * is being wiped out.
- */
- assert_ec_rst();
-
- if (tpm_reset_request(1, 1) != EC_SUCCESS) {
- CPRINTF("%s: TPM reset attempt failed\n", __func__);
- deassert_ec_rst();
- return;
- }
-
- tpm_reinstate_nvmem_commits();
-
- CPRINTF("%s: TPM reset succeeded, RMA resetting CCD\n", __func__);
-
- ccd_hook_active = 1;
- rv = ccd_reset_config(CCD_RESET_RMA);
- if (rv != EC_SUCCESS)
- rma_reset_failed();
-
- /*
- * Make sure we never end up with the EC held in reset, no matter what
- * prevents the proper RMA flow from succeeding.
- */
- hook_call_deferred(&rma_reset_failed_data, TPM_RESET_TIME);
-}
-DECLARE_DEFERRED(enter_rma_mode);
-
/*
* Compare response sent by the operator with the pre-compiled auth code.
* Return error code or success depending on the comparison results.
@@ -419,8 +346,7 @@ static enum vendor_cmd_rc process_response(uint8_t *buf,
if (rv == EC_SUCCESS) {
CPRINTF("%s: success!\n", __func__);
*response_size = 0;
- delay_sleep_by(DISABLE_SLEEP_TIME);
- hook_call_deferred(&enter_rma_mode_data, TPM_PROCESSING_TIME);
+ enable_ccd_factory_mode();
return VENDOR_RC_SUCCESS;
}