vboot: remove VbExEcEnteringMode and friends

After informing EC of the mode chosen by vboot, it is stored
in a global and never accessed again.  Remove this function,
its calls, and its tests.

Also note some significant issues which existed:
(1) Using accessor VbGetMode for tests, rather than just
    overriding VbExEcEnteringMode when needed.
(2) The tests checking the value sent to VbExEcEnteringMode
    (vboot_api_kernel2_tests and vboot_detach_menu_tests)
    actually call the function themselves.

BUG=b:124141368, chromium:1014379
TEST=make clean && make runtests
BRANCH=none

Change-Id: Ib8e510a1e1c663bb3f8238a9ad15e3e64d7350b0
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1864533
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1830239
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Julius Werner <jwerner@chromium.org>
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 9f1b955..d07852a 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -710,13 +710,6 @@
 vb2_error_t VbExEcProtect(int devidx, enum VbSelectFirmware_t select);
 
 /**
- * Info the EC of the boot mode selected by the AP.
- * mode: Normal, Developer, or Recovery
- */
-enum VbEcBootMode_t {VB_EC_NORMAL, VB_EC_DEVELOPER, VB_EC_RECOVERY };
-vb2_error_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode);
-
-/**
  * Perform EC post-verification / updating / jumping actions.
  *
  * This routine is called to perform certain actions that must wait until
diff --git a/firmware/include/vboot_test.h b/firmware/include/vboot_test.h
index a825bd9..bdd1f37 100644
--- a/firmware/include/vboot_test.h
+++ b/firmware/include/vboot_test.h
@@ -8,7 +8,9 @@
 #ifndef VBOOT_REFERENCE_TEST_API_H_
 #define VBOOT_REFERENCE_TEST_API_H_
 
-/*
+/****************************************************************************
+ * 2rsa.c
+ *
  * Internal functions from 2rsa.c that have error conditions we can't trigger
  * from the public APIs.  These include checks for bad algorithms where the
  * next call level up already checks for bad algorithms, etc.
@@ -21,8 +23,8 @@
 vb2_error_t vb2_check_padding(const uint8_t *sig,
 			      const struct vb2_public_key *key);
 
-enum VbEcBootMode_t;
-enum VbEcBootMode_t VbGetMode(void);
+/****************************************************************************
+ * vboot_api_kernel.c */
 
 struct RollbackSpaceFwmp;
 struct RollbackSpaceFwmp *VbApiKernelGetFwmp(void);
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index fe1e7e3..68419aa 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -391,7 +391,6 @@
 			rv = VbBootRecoveryMenu(ctx);
 		else
 			rv = VbBootRecovery(ctx);
-		VbExEcEnteringMode(0, VB_EC_RECOVERY);
 	} else if (DIAGNOSTIC_UI && vb2_nv_get(ctx, VB2_NV_DIAG_REQUEST)) {
 		vb2_nv_set(ctx, VB2_NV_DIAG_REQUEST, 0);
 
@@ -418,11 +417,9 @@
 			rv = VbBootDeveloperMenu(ctx);
 		else
 			rv = VbBootDeveloper(ctx);
-		VbExEcEnteringMode(0, VB_EC_DEVELOPER);
 	} else {
 		/* Normal boot */
 		rv = VbBootNormal(ctx);
-		VbExEcEnteringMode(0, VB_EC_NORMAL);
 	}
 
  VbSelectAndLoadKernel_exit:
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index c30aa8e..770be35 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -17,8 +17,6 @@
 #include "vboot_api.h"
 #include "vboot_test.h"
 
-static enum VbEcBootMode_t vboot_mode;
-
 void VbExSleepMs(uint32_t msec)
 {
 }
@@ -128,12 +126,6 @@
 	return VB2_SUCCESS;
 }
 
-vb2_error_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode)
-{
-	vboot_mode = mode;
-	return VB2_SUCCESS;
-}
-
 vb2_error_t VbExEcVbootDone(int in_recovery)
 {
 	return VB2_SUCCESS;
@@ -155,11 +147,6 @@
 	return VB2_SUCCESS;
 }
 
-enum VbEcBootMode_t VbGetMode(void)
-{
-	return vboot_mode;
-}
-
 vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num)
 {
 	return 1;
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index 3e2ae04..0b82bdc 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -471,9 +471,7 @@
 static void VbBootTest(void)
 {
 	ResetMocks();
-	VbExEcEnteringMode(0, VB_EC_NORMAL);
 	TEST_EQ(VbBootNormal(&ctx), 1002, "VbBootNormal()");
-	TEST_EQ(VbGetMode(), VB_EC_NORMAL, "vboot_mode normal");
 
 	ResetMocks();
 	vb2_nv_set(&ctx, VB2_NV_DISPLAY_REQUEST, 1);
@@ -498,9 +496,7 @@
 
 	/* Proceed after timeout */
 	ResetMocks();
-	VbExEcEnteringMode(0, VB_EC_DEVELOPER);
 	TEST_EQ(VbBootDeveloper(&ctx), 1002, "Timeout");
-	TEST_EQ(VbGetMode(), VB_EC_DEVELOPER, "vboot_mode developer");
 	TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_WARNING,
 		"  warning screen");
 	TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0,
@@ -1068,11 +1064,9 @@
 	/* Shutdown requested in loop */
 	ResetMocks();
 	MockGpioAfter(10, GPIO_SHUTDOWN);
-	VbExEcEnteringMode(0, VB_EC_RECOVERY);
 	TEST_EQ(VbBootRecovery(&ctx),
 		VBERROR_SHUTDOWN_REQUESTED,
 		"Shutdown requested");
-	TEST_EQ(VbGetMode(), VB_EC_RECOVERY, "vboot_mode recovery");
 
 	TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0,
 		"  recovery reason");
@@ -1081,7 +1075,6 @@
 
 	/* Shutdown requested by keyboard */
 	ResetMocks();
-	VbExEcEnteringMode(0, VB_EC_RECOVERY);
 	mock_keypress[0] = VB_BUTTON_POWER_SHORT_PRESS;
 	TEST_EQ(VbBootRecovery(&ctx),
 		VBERROR_SHUTDOWN_REQUESTED,
diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c
index 8d134e4..7374882 100644
--- a/tests/vboot_detach_menu_tests.c
+++ b/tests/vboot_detach_menu_tests.c
@@ -114,7 +114,6 @@
 {
 	ResetMocks();
 	shared->flags |= VBSD_BOOT_DEV_SWITCH_ON;
-	VbExEcEnteringMode(0, VB_EC_DEVELOPER);
 	shutdown_request_calls_left = -1;
 }
 
@@ -123,7 +122,6 @@
 	ResetMocks();
 	shared->flags |= VBSD_BOOT_REC_SWITCH_ON;
 	trust_ec = 1;
-	VbExEcEnteringMode(0, VB_EC_RECOVERY);
 }
 
 /* Mock functions */
@@ -276,7 +274,6 @@
 	/* Proceed after timeout */
 	ResetMocksForDeveloper();
 	TEST_EQ(VbBootDeveloperMenu(&ctx), vbtlk_retval_fixed, "Timeout");
-	TEST_EQ(VbGetMode(), VB_EC_DEVELOPER, "vboot_mode developer");
 	TEST_EQ(screens_displayed[0], VB_SCREEN_DEVELOPER_WARNING_MENU,
 		"  warning screen");
 	TEST_EQ(screens_displayed[1], VB_SCREEN_BLANK, "  final blank screen");
@@ -1295,10 +1292,8 @@
 
 	/* Shutdown requested in BROKEN */
 	ResetMocks();
-	VbExEcEnteringMode(0, VB_EC_RECOVERY);
 	TEST_EQ(VbBootRecoveryMenu(&ctx), VBERROR_SHUTDOWN_REQUESTED,
 		"Shutdown requested in BROKEN");
-	TEST_EQ(VbGetMode(), VB_EC_RECOVERY, "vboot_mode recovery");
 	TEST_EQ(vb2_nv_get(&ctx, VB2_NV_RECOVERY_REQUEST), 0, "  no recovery");
 	TEST_EQ(debug_info_displayed, 0, "  no debug info");
 	TEST_EQ(screens_displayed[0], VB_SCREEN_OS_BROKEN,