From 3071b82b5847396136b19acd8c2aa3f4e8f6cd42 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 23 Aug 2016 15:14:56 -0700 Subject: Remove unused CONFIG_CONSOLE_RESTRICTED_INPUT option Nothing has used this config option since Spring and Skate, back in early 2014. There's nothing in ToT that uses it at all. I want to add something similar for other purposes, and having two similar-sounding options will just cause confusion. NOTE: Although the comments in include/system.h said that the two functions system_get_console_force_enabled() system_set_console_force_enabled() were only useful when CONFIG_CONSOLE_RESTRICTED_INPUT is defined, they were being used in chip/stm32/system.c. But since the bkpdata registers are only accessible to the EC, there was no way to initialize or modify the one relevant bit that those functions cared about, so they almost certainly had no effect. BUG=chrome-os-partner:55322 BRANCH=none TEST=make buildall Change-Id: Id41541193d4559f5c507bdd0268b049166af4497 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/374525 --- chip/stm32/system.c | 37 +++---------------------------------- common/console.c | 30 ------------------------------ include/config.h | 7 ------- include/system.h | 7 ------- 4 files changed, 3 insertions(+), 78 deletions(-) diff --git a/chip/stm32/system.c b/chip/stm32/system.c index ea8c91390d..605f095f95 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -18,8 +18,6 @@ #include "version.h" #include "watchdog.h" -#define CONSOLE_BIT_MASK 0x8000 - enum bkpdata_index { BKPDATA_INDEX_SCRATCHPAD, /* General-purpose scratchpad */ BKPDATA_INDEX_SAVED_RESET_FLAGS, /* Saved reset flags */ @@ -128,15 +126,12 @@ static void check_reset_cause(void) uint32_t raw_cause = STM32_RCC_CSR; uint32_t pwr_status = STM32_PWR_CSR; - uint32_t console_en = flags & CONSOLE_BIT_MASK; - flags &= ~CONSOLE_BIT_MASK; - /* Clear the hardware reset cause by setting the RMVF bit */ STM32_RCC_CSR |= 1 << 24; /* Clear SBF in PWR_CSR */ STM32_PWR_CR |= 1 << 3; /* Clear saved reset flags */ - bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, 0 | console_en); + bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, 0); if (raw_cause & 0x60000000) { /* @@ -248,9 +243,6 @@ void system_reset(int flags) { uint32_t save_flags = 0; - uint32_t console_en = bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS) & - CONSOLE_BIT_MASK; - /* Disable interrupts to avoid task swaps during reboot */ interrupt_disable(); @@ -265,7 +257,7 @@ void system_reset(int flags) if (flags & SYSTEM_RESET_HARD) save_flags |= RESET_FLAG_HARD; - bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, save_flags | console_en); + bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, save_flags); if (flags & SYSTEM_RESET_HARD) { #ifdef CONFIG_SOFTWARE_PANIC @@ -336,10 +328,7 @@ const char *system_get_chip_vendor(void) const char *system_get_chip_name(void) { - if (system_get_console_force_enabled()) - return STRINGIFY(CHIP_VARIANT-unsafe); - else - return STRINGIFY(CHIP_VARIANT); + return STRINGIFY(CHIP_VARIANT); } const char *system_get_chip_revision(void) @@ -380,26 +369,6 @@ int system_set_vbnvcontext(const uint8_t *block) return EC_SUCCESS; } -int system_set_console_force_enabled(int val) -{ - uint16_t flags = bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS); - - if (val) - flags |= CONSOLE_BIT_MASK; - else - flags &= ~CONSOLE_BIT_MASK; - - return bkpdata_write(BKPDATA_INDEX_SAVED_RESET_FLAGS, flags); -} - -int system_get_console_force_enabled(void) -{ - if (bkpdata_read(BKPDATA_INDEX_SAVED_RESET_FLAGS) & CONSOLE_BIT_MASK) - return 1; - else - return 0; -} - int system_is_reboot_warm(void) { #if defined(CHIP_FAMILY_STM32F0) || defined(CHIP_FAMILY_STM32F3) diff --git a/common/console.c b/common/console.c index c451de041f..e64d07f8d7 100644 --- a/common/console.c +++ b/common/console.c @@ -646,15 +646,6 @@ void console_has_input(void) void console_task(void) { -#ifdef CONFIG_CONSOLE_RESTRICTED_INPUT - /* the console is not available due to security restrictions */ - if (system_is_locked() && !system_get_console_force_enabled()) { - ccprintf("Console is DISABLED (WP is ON).\n"); - while (1) - task_wait_event(-1); - } -#endif - console_init(); while (1) { @@ -741,27 +732,6 @@ DECLARE_CONSOLE_COMMAND(help, command_help, "[ list | ]", "Print command help"); -#ifdef CONFIG_CONSOLE_RESTRICTED_INPUT -static int command_force_enabled(int argc, char **argv) -{ - int val; - - if (argc < 2) - return EC_ERROR_PARAM_COUNT; - - if (!parse_bool(argv[1], &val)) - return EC_ERROR_PARAM1; - - system_set_console_force_enabled(val); - ccprintf("Console force enabled = %s\n", val ? "on" : "off"); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(forceen, command_force_enabled, - "", - "Force enable console"); -#endif - #ifdef CONFIG_CONSOLE_HISTORY static int command_history(int argc, char **argv) { diff --git a/include/config.h b/include/config.h index 7a62d2988e..2abb6df74c 100644 --- a/include/config.h +++ b/include/config.h @@ -668,13 +668,6 @@ /* Max length of a single line of input */ #define CONFIG_CONSOLE_INPUT_LINE_SIZE 80 -/* - * Disable EC console input if the system is locked. This is needed for - * security on platforms where the EC console is accessible from outside the - * case - for example, via a special USB dongle. - */ -#undef CONFIG_CONSOLE_RESTRICTED_INPUT - /* * Enable the experimental console. * diff --git a/include/system.h b/include/system.h index 7b08683ac0..55b841facd 100644 --- a/include/system.h +++ b/include/system.h @@ -301,13 +301,6 @@ void board_hibernate_late(void) __attribute__((weak)); /* Minimum duration to get proper hibernation */ #define SYSTEM_HIB_MINIMUM_DURATION 0, 150000 -/** - * Get/Set console force enable status. This is only supported/used on platform - * with CONFIG_CONSOLE_RESTRICTED_INPUT defined. - */ -int system_get_console_force_enabled(void); -int system_set_console_force_enabled(int enabled); - /** * Read the real-time clock. * -- cgit v1.2.1